( text: string, editorType: string, extensions: Array<Extension> = [], editable: boolean )
| 47 | ]); |
| 48 | |
| 49 | export 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 | |
| 91 | function fromEditorType(editorType: string) { |
| 92 | if(editorType === "javascript") return javascript(); |
no test coverage detected