MCPcopy Create free account
hub / github.com/pwa-builder/PWABuilder / getEditorState

Function getEditorState

components/code-editor/src/utils/codemirror.ts:49–89  ·  view source on GitHub ↗
(
  text: string,
  editorType: string,
  extensions: Array<Extension> = [],
  editable: boolean
)

Source from the content-addressed store, hash-verified

47]);
48
49export function getEditorState(
50 text: string,
51 editorType: string,
52 extensions: Array<Extension> = [],
53 editable: boolean
54) {
55 setupEditor();
56
57 return EditorState.create({
58 doc: text,
59 extensions: [
60 lineNumbers(),
61 foldGutter(),
62 drawSelection(),
63 indentOnInput(),
64 highlightActiveLine(),
65 highlightSelectionMatches(),
66 highlightSpecialChars(),
67 syntaxHighlighting(myHighlightStyle),
68 bracketMatching(),
69 closeBrackets(),
70 autocompletion(),
71 rectangularSelection(),
72 indentOnInput(),
73 history(),
74 fromEditorType(editorType),
75 EditorView.editable.of(editable),
76 keymap.of([
77 ...defaultKeymap,
78 ...foldKeymap,
79 ...historyKeymap,
80 ...searchKeymap,
81 ...lintKeymap,
82 ...closeBracketsKeymap,
83 ...completionKeymap,
84 ]),
85 ...extensions,
86 updateStateField,
87 ],
88 });
89}
90
91function fromEditorType(editorType: string) {
92 if(editorType === "javascript") return javascript();

Callers 2

updatedMethod · 0.90
CodeEditorClass · 0.90

Calls 1

fromEditorTypeFunction · 0.85

Tested by

no test coverage detected