mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-27 05:13:09 +00:00
update component/key names
This commit is contained in:
@@ -6,9 +6,9 @@ export const HINT_TYPE = {
|
||||
};
|
||||
|
||||
export const SNIPPET_TYPE = {
|
||||
DEFAULT : 0,
|
||||
INLINE_SNIPPET : 1,
|
||||
IMAGE : 2,
|
||||
BLOCK : 0,
|
||||
INLINE : 1,
|
||||
INJECTOR : 2,
|
||||
};
|
||||
|
||||
export const FIELD_TYPE = {
|
||||
@@ -18,9 +18,9 @@ export const FIELD_TYPE = {
|
||||
|
||||
export const PATTERNS = {
|
||||
snippet : {
|
||||
[SNIPPET_TYPE.DEFAULT] : (name)=>new RegExp(`^{{${name}(?:[^a-zA-Z].*)?`),
|
||||
[SNIPPET_TYPE.INLINE_SNIPPET] : (name)=>new RegExp(`{{${name}`),
|
||||
[SNIPPET_TYPE.IMAGE] : ()=>new RegExp(`^\\!\\[(?:[a-zA-Z -]+)?\\]\\(.*\\).*{[a-zA-Z0-9:, "'-]+}$`),
|
||||
[SNIPPET_TYPE.BLOCK] : (name)=>new RegExp(`^{{${name}(?:[^a-zA-Z].*)?`),
|
||||
[SNIPPET_TYPE.INLINE] : (name)=>new RegExp(`{{${name}`),
|
||||
[SNIPPET_TYPE.INJECTOR] : ()=>new RegExp(`^\\!\\[(?:[a-zA-Z -]+)?\\]\\(.*\\).*{[a-zA-Z0-9:, "'-]+}$`),
|
||||
},
|
||||
field : {
|
||||
[FIELD_TYPE.TEXT] : (name)=>new RegExp(`[{,;](${name}):("[^},;"]*"|[^},;]*)`),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const Field = require('./field/field.jsx');
|
||||
const Text = require('./text/text.jsx');
|
||||
const Checkbox = require('./checkbox/checkbox.jsx');
|
||||
|
||||
module.exports = {
|
||||
Field : Field,
|
||||
Text : Text,
|
||||
Checkbox : Checkbox,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require('./field.less');
|
||||
require('./text.less');
|
||||
const React = require('react');
|
||||
const createClass = require('create-react-class');
|
||||
const _ = require('lodash');
|
||||
@@ -10,7 +10,7 @@ const STYLE_FN = (value)=>({
|
||||
width : `calc(${value?.length ?? 0}ch + ${value?.length ? `${DEFAULT_WIDTH} / 2` : DEFAULT_WIDTH})`
|
||||
});
|
||||
|
||||
const Field = createClass({
|
||||
const Text = createClass({
|
||||
fieldRef : {},
|
||||
|
||||
getDefaultProps : function() {
|
||||
@@ -157,4 +157,4 @@ const Field = createClass({
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Field;
|
||||
module.exports = Text;
|
||||
@@ -2,7 +2,7 @@ const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
const { PATTERNS, FIELD_TYPE, HINT_TYPE, UNITS } = require('./widget-elements/constants');
|
||||
require('./widget-elements/hints/hints.jsx');
|
||||
const { Field, Checkbox } = require('./widget-elements');
|
||||
const { Text, Checkbox } = require('./widget-elements');
|
||||
|
||||
// See https://codemirror.net/5/addon/hint/css-hint.js for code reference
|
||||
const pseudoClasses = { 'active' : 1, 'after' : 1, 'before' : 1, 'checked' : 1, 'default' : 1,
|
||||
@@ -87,7 +87,7 @@ module.exports = function(CodeMirror, widgets, cm, setHints) {
|
||||
if(field.type === FIELD_TYPE.CHECKBOX) {
|
||||
return <Checkbox key={genKey(widget.name, n, field.name)} cm={cm} CodeMirror={CodeMirror} n={n} prefix={widget.name} value={field.name}/>;
|
||||
} else if(field.type === FIELD_TYPE.TEXT) {
|
||||
return <Field key={genKey(widget.name, n, field.name)} cm={cm} CodeMirror={CodeMirror} field={field} n={n} text={text} setHints={(f, h)=>setHints(h, f)} getStyleHints={getStyleHints}/>;
|
||||
return <Text key={genKey(widget.name, n, field.name)} cm={cm} CodeMirror={CodeMirror} field={field} n={n} text={text} setHints={(f, h)=>setHints(h, f)} getStyleHints={getStyleHints}/>;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ module.exports = function(CodeMirror, widgets, cm, setHints) {
|
||||
increment : 5,
|
||||
hints : true,
|
||||
};
|
||||
return <Field key={genKey(widget.name, n, style)} cm={cm} CodeMirror={CodeMirror} field={field} n={n} text={text} setHints={(f, h)=>setHints(h, f)} getStyleHints={getStyleHints}/>;
|
||||
return <Text key={genKey(widget.name, n, style)} cm={cm} CodeMirror={CodeMirror} field={field} n={n} text={text} setHints={(f, h)=>setHints(h, f)} getStyleHints={getStyleHints}/>;
|
||||
}).filter(Boolean);
|
||||
|
||||
ReactDOM.render(<React.Fragment>
|
||||
|
||||
Reference in New Issue
Block a user