diff --git a/example/example.js b/example/example.js index ecc53ba..326c417 100644 --- a/example/example.js +++ b/example/example.js @@ -19,7 +19,8 @@ require(['vs/editor/editor.main', 'MonacoCollabExt'], function(m, MonacoCollabEx const target = monaco.editor.create(document.getElementById("target-editor"), { value: editorContents, theme: "vs-dark'", - language: 'javascript' + language: 'javascript', + readOnly: true }); const remoteCursorManager = new MonacoCollabExt.RemoteCursorManager({ @@ -68,13 +69,19 @@ require(['vs/editor/editor.main', 'MonacoCollabExt'], function(m, MonacoCollabEx const sourceContentManager = new MonacoCollabExt.EditorContentManager({ editor: source, onInsert(index, text) { + target.updateOptions({readOnly: false}); targetContentManager.insert(index, text); + target.updateOptions({readOnly: true}); }, onReplace(index, length, text) { + target.updateOptions({readOnly: false}); targetContentManager.replace(index, length, text); + target.updateOptions({readOnly: true}); }, onDelete(index, length) { + target.updateOptions({readOnly: false}); targetContentManager.delete(index, length); + target.updateOptions({readOnly: true}); } }); });