const readonlyPlugin = new Plugin({
key: new PluginKey('readonly'),
filterTransaction: (transaction) => transaction.docChanged === false,
});
to allow ProseMirror to be read-only while still allowing text selection.
If move the cursor into a display math node, I can still modify its (source) content, but when I move the cursor outside, ProseMirror becomes unhappy:
index.js:2233 Uncaught RangeError: Invalid content for node doc: <paragraph("asdfasdf"), paragraph, math_display("\
at NodeType.checkContent (index.js:2233:19)
at close$1 (index.js:748:15)
at replaceOuter (index.js:706:16)
at replace (index.js:693:12)
at Node.replace (index.js:1329:16)
at StepResult.fromReplace (index.js:409:38)
at ReplaceStep.apply (index.js:705:27)
at Transaction.maybeStep (index.js:1932:27)
at Transaction.step (index.js:1922:27)
at T.dispatchInner (prosemirror-math.js:130:13)
The net outcome is still the intended one: the document is unmodified. Nonetheless, the experience would be smoother if there were a way to prevent modifications outright.
I use a simple plugin like this:
to allow ProseMirror to be read-only while still allowing text selection.
If move the cursor into a display math node, I can still modify its (source) content, but when I move the cursor outside, ProseMirror becomes unhappy:
The net outcome is still the intended one: the document is unmodified. Nonetheless, the experience would be smoother if there were a way to prevent modifications outright.