0.1.2 • Published 2 years ago
@gdquest/codemirror-freeze v0.1.2
@gdquest/codemirror-freeze
freeze() extension
Purpose
This extension setup a Codemirror view to "freeze" code between specific comment tags.
By default, freeze() has "start-freeze" and "end-freeze" as keywords, but it is customizable by passing the new names in parameter.
Usage
import { basicSetup } from "codemirror";
import { EditorView } from "@codemirror/view";
import { javascript } from "@codemirror/lang-javascript";
import { freeze } from "@gdquest/codemirror-freeze";
new EditorView({
extensions: [basicSetup, javascript(), freeze()],
doc: `
Hello. This is editable.
// start-freeze
This is frozen. Cannot change this line.
// end-freeze
This part is editable.
`.trim(),
});