0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-27 05:13:09 +00:00

refactor CodeMirror library instantiation

This commit is contained in:
Charlie Humphreys
2023-07-15 00:20:38 -05:00
parent 9d6a9c4ebf
commit 4c087e9aa5
5 changed files with 48 additions and 45 deletions

View File

@@ -3,6 +3,7 @@ const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const { NUMBER_PATTERN, HINT_TYPE, PATTERNS } = require('../constants');
const CodeMirror = require('../../../code-mirror.js');
const DEFAULT_WIDTH = '30px';
@@ -121,7 +122,7 @@ const Text = createClass({
}
},
onChange : function (e){
const { cm, text, field, n, CodeMirror } = this.props;
const { cm, text, field, n } = this.props;
const pattern = PATTERNS.field[field.type](field.name);
const [_, label, current] = text.match(pattern) ?? [null, field.name, ''];
let index = text.indexOf(`${label}:${current}`);