相关文章推荐
文雅的小蝌蚪  ·  matlab 每隔 取-掘金·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Currently running into an issue with this.

const configDataNode = document.getElementById('config_data');
    const editor = CodeMirror.fromTextArea(
      document.getElementById('config_data_editor'),
        // lineNumbers: true,
        mode: 'javascript',
        // tabSize: 2,
        // indentWithTabs: true,
        // value: JSON.stringify(gon.config.initialData, 2, 2),
    editor.on('change', changeObject => {
      const {text} = changeObject;
      configDataNode.value = text;

Here is my code.

It is happening due to TextArea object's value field is undefined and thus inside the CodeMirror codemirror.js library options.value is initialising the doc variable also undefined, and thus later in source modeOption is getting matched with doc child field (if the doc is undefined, how a object key may exists).

var textarea_editor = document.getElementById("RichTextArea");
// so explicitly assign value to textarea object.
textarea_editor.value = "";
this.editor = CodeMirror.fromTextArea(textarea_editor, {
     tabSize: 4,
     mode: 'text/plain',
     theme: 'default',
     lineNumbers: true,
     styleActiveSelected: true,
     styleActiveLine: true,
     indentWithTabs: true,
     matchBrackets: true,
     highlightMatches: true,

Hope this may help someone.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.