Version mirrorsharp-codemirror-6-preview
(future mirrorsharp 3.0+) includes a number of breaking changes when compared to mirrorsharp
2.
The goal of this document is to help with migration.
The most noticeable change is in the mirrosharp()
contract, which now uses a container element instead of a textarea
.
// New:
// HTML: <div id="editor"></div>
mirrorsharp(document.getElementById('editor'));
// Old:
// HTML: <textarea id="editor"></textarea>
mirrorsharp(document.getElementById('editor'));
Note that this means you can't get/set the value of textarea directly, as you did with mirrorsharp 2.
To set the initial value, use the text
option, e.g:
mirrorsharp(container, { text: 'initial' });
To get or set the value after the editor is created, use the getText()
and setText()
on the editor instance:
const ms = mirrorsharp(container);
ms.setText(ms.getText() + " // changed");
Version 2 | CM 6 Preview |
---|---|
noInitialConnection |
disconnected |
initialServerOptions |
serverOptions |
forCodeMirror |
codeMirror |
selfDebugEnabled |
No longer available. |
on slowUpdateResult |
Event property x renamed to extensionData . |
on connectionChange |
Events error and close are no longer emitted. Event loss is emitted instead. |
Note that vesion 2 allowed unknown options, while newer versions will throw if any option is not known.
Version 2 | CM 6 Preview |
---|---|
getCodeMirror |
getCodeMirrorView |
destroy({ keepCodeMirror: true }) |
No longer available. However more changes can be done without destroying, e.g. setServiceUrl . |
One of the major changes is that the library now uses CodeMirror 6.
Specific CodeMirror changes are out of scope of this document, but you can find the list in CodeMirror 6 migration guide.