ssssssss-team/spider-flow · error · Error

inputStyle can not (yet) be changed in a running editor

Error message

inputStyle can not (yet) be changed in a running editor

What it means

The inputStyle option ('textarea' vs 'contenteditable') determines how the editor captures keyboard input and is only read at construction time. Its option handler deliberately throws because changing it on a live editor is not implemented.

Solutions

  1. Re-create the editor with the desired inputStyle: capture value/mode/options, destroy (cm.toTextArea() or remove), and re-instantiate
  2. Set inputStyle only in the constructor options object
  3. Guard the settings code so inputStyle is only applied on first creation

Example fix

// before
cm.setOption("inputStyle", "contenteditable");
// after
var val = cm.getValue(), opts = cm.options;
cm.toTextArea();
cm = CodeMirror.fromTextArea(textareaEl,
  Object.assign({}, opts, {inputStyle: "contenteditable", value: val}));
Defensive patterns

Strategy: fallback

Validate before calling

function applyInputStyle(cm, style) {
  if (cm.getOption("inputStyle") !== style) {
    recreateEditorWithOption(cm, "inputStyle", style); // setOption will throw
  }
}

Try / catch

try {
  cm.setOption("inputStyle", style);
} catch (e) {
  if (/inputStyle can not/.test(e.message)) {
    recreateEditor(cm, {inputStyle: style}); // destroy + re-create with new option
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling cm.setOption('inputStyle', 'contenteditable'|'textarea') after the editor instance was created, or an options UI applying saved inputStyle to an already-initialized editor.

Common situations: Settings panels that persist user preferences and apply them via setOption, mobile-detection code switching input styles at runtime, or framework wrappers re-applying all options on update.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of ssssssss-team/spider-flow@c799cca99c (2026-09-08). Data as JSON: /api/errors/98fad507f628203b. Report an issue: GitHub.

Appendix: source

Thrown at spider-flow-web/src/main/resources/static/js/codemirror/codemirror.js:7720

        for (var pos = 0;;) {
          var found = line.text.indexOf(val, pos);
          if (found == -1) { break }
          pos = found + val.length;
          newBreaks.push(Pos(lineNo, found));
        }
        lineNo++;
      });
      for (var i = newBreaks.length - 1; i >= 0; i--)
        { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
    });
    option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
      cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
      if (old != Init) { cm.refresh(); }
    });
    option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true);
    option("electricChars", true);
    option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
      throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
    }, true);
    option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true);
    option("autocorrect", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true);
    option("autocapitalize", false, function (cm, val) { return cm.getInputField().autocapitalize = val; }, true);
    option("rtlMoveVisually", !windows);
    option("wholeLineUpdateBefore", true);

    option("theme", "default", function (cm) {
      themeChanged(cm);
      updateGutters(cm);
    }, true);
    option("keyMap", "default", function (cm, val, old) {
      var next = getKeyMap(val);
      var prev = old != Init && getKeyMap(old);
      if (prev && prev.detach) { prev.detach(cm, next); }
      if (next.attach) { next.attach(cm, prev || null); }
    });
    option("extraKeys", null);

View on GitHub (pinned to c799cca99c)