Wrap editor code in DOMContentLoaded

This commit is contained in:
Thomas Miceli 2023-04-03 00:43:23 +02:00
parent 2aee52e06c
commit 0eb1b103d0
No known key found for this signature in database
GPG key ID: D86C6F6390AF050F

7
public/editor.js vendored
View file

@ -2,6 +2,7 @@ import {EditorView, gutter, keymap, lineNumbers} from "@codemirror/view"
import {Compartment, EditorState, Facet, SelectionRange} from "@codemirror/state"
import {indentLess} from "@codemirror/commands";
document.addEventListener('DOMContentLoaded', () => {
EditorView.theme({}, {dark: true})
let editorsjs = []
@ -103,7 +104,10 @@ function changeBySelectedLine(state, f) {
line = state.doc.lineAt(line.number + 1)
}
let changeSet = state.changes(changes)
return {changes, range: new SelectionRange(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1))}
return {
changes,
range: new SelectionRange(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1))
}
})
}
@ -155,3 +159,4 @@ document.querySelector('form#create').onsubmit = () => {
document.onsubmit = () => {
window.onbeforeunload = null;
}
})