- // Will force to remain as ltr for now due to issues when HTML is in editor.
- cm.setOption('direction', 'ltr');
- // Register shortcuts
- cm.setOption('extraKeys', provideShortcuts(editor, Code.getMetaKey()));
-
-
- // Register codemirror events
-
- // Update data on content change
- cm.on('change', (instance, changeObj) => editor.actions.updateAndRender());
-
- // Handle scroll to sync display view
- const onScrollDebounced = debounce(editor.actions.syncDisplayPosition.bind(editor.actions), 100, false);
- cm.on('scroll', instance => onScrollDebounced(instance));
-
- // Handle image paste
- cm.on('paste', (cm, event) => {
- const clipboard = new Clipboard(event.clipboardData || event.dataTransfer);
-
- // Don't handle the event ourselves if no items exist of contains table-looking data
- if (!clipboard.hasItems() || clipboard.containsTabularData()) {
- return;
+ /**
+ * @param {ViewUpdate} v
+ */
+ function onViewUpdate(v) {
+ if (v.docChanged) {
+ editor.actions.updateAndRender();