Commit 3d3ee5da authored by Jérome Perrin's avatar Jérome Perrin

monaco: support non editable mode

by setting "readOnly" to true.
Monaco also supports applying its style to a <pre> element (like on
https://microsoft.github.io/monaco-editor/playground.html#creating-the-editor-syntax-highlighting-for-html-elements
) but it would be a too big architecture change, a readOnly editor is
enough.
parent 520c6316
...@@ -171,6 +171,8 @@ ...@@ -171,6 +171,8 @@
.push(addExtraLibrary('./monaco-renderjs.d.ts', 'renderjs')) .push(addExtraLibrary('./monaco-renderjs.d.ts', 'renderjs'))
.push(addExtraLibrary('./monaco-jio.d.ts', 'jio')); .push(addExtraLibrary('./monaco-jio.d.ts', 'jio'));
} }
if (modification_dict.hasOwnProperty('editable')){
gadget.editor.updateOptions({readOnly: !this.state.editable});
} }
return queue; return queue;
}) })
......
...@@ -112,6 +112,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/ ...@@ -112,6 +112,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
(editor_dict.hasOwnProperty(gadget.state.editor))) || (editor_dict.hasOwnProperty(gadget.state.editor))) ||
(!gadget.state.editable && gadget.state.editor === 'fck_editor') || (!gadget.state.editable && gadget.state.editor === 'fck_editor') ||
(!gadget.state.editable && gadget.state.editor === 'jsmd_editor') || (!gadget.state.editable && gadget.state.editor === 'jsmd_editor') ||
(!gadget.state.editable && gadget.state.editor === 'monaco') ||
(gadget.state.editor === 'pdf')) { (gadget.state.editor === 'pdf')) {
queue queue
.push(function () { .push(function () {
...@@ -143,6 +144,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/ ...@@ -143,6 +144,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
(editor_dict.hasOwnProperty(gadget.state.editor))) || (editor_dict.hasOwnProperty(gadget.state.editor))) ||
(!gadget.state.editable && gadget.state.editor === 'fck_editor') || (!gadget.state.editable && gadget.state.editor === 'fck_editor') ||
(!gadget.state.editable && gadget.state.editor === 'jsmd_editor') || (!gadget.state.editable && gadget.state.editor === 'jsmd_editor') ||
(!gadget.state.editable && gadget.state.editor === 'monaco') ||
(gadget.state.editor === 'pdf')) { (gadget.state.editor === 'pdf')) {
queue queue
.push(function () { .push(function () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment