CodeMirror 6.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4767 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2024-01-13 17:40:47 +00:00
parent 24e418344e
commit f72e8cbd91
28 changed files with 155 additions and 520 deletions

66
deps/codemirror_src/editor.mjs vendored Normal file
View File

@ -0,0 +1,66 @@
import {EditorState} from "@codemirror/state"
import {EditorView} from '@codemirror/view';
import {javascript} from "@codemirror/lang-javascript"
import {html} from "@codemirror/lang-html"
import {css} from "@codemirror/lang-css"
import {search} from "@codemirror/search"
import {oneDark} from "@codemirror/theme-one-dark"
import {lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLine, keymap} from '@codemirror/view';
import {foldGutter, indentOnInput, syntaxHighlighting, defaultHighlightStyle, bracketMatching, foldKeymap} from '@codemirror/language';
import {history, defaultKeymap, historyKeymap} from '@codemirror/commands';
import {highlightSelectionMatches, searchKeymap} from '@codemirror/search';
import {autocompletion, closeBracketsKeymap, completionKeymap} from '@codemirror/autocomplete';
import {lintKeymap} from '@codemirror/lint';
let updateListenerExtension = EditorView.updateListener.of((update) => {
if (update.docChanged && update.view.onDocChange) {
update.view.onDocChange();
}
});
const extensions = [
lineNumbers(),
highlightActiveLineGutter(),
highlightSpecialChars(),
history(),
foldGutter(),
drawSelection(),
dropCursor(),
EditorState.allowMultipleSelections.of(true),
indentOnInput(),
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
bracketMatching(),
autocompletion(),
rectangularSelection(),
crosshairCursor(),
highlightActiveLine(),
highlightSelectionMatches(),
keymap.of([
...defaultKeymap,
...searchKeymap,
...historyKeymap,
...foldKeymap,
...completionKeymap,
...lintKeymap
]),
javascript(),
html(),
css(),
search(),
oneDark,
updateListenerExtension,
];
function TildeFriendsEditorView(parent) {
return new EditorView({
extensions: extensions,
parent: parent,
});
};
export {
TildeFriendsEditorView,
EditorState,
EditorView,
extensions,
};

15
deps/codemirror_src/package.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
"dependencies": {
"@codemirror/lang-css": "^6.2.1",
"@codemirror/lang-html": "^6.4.7",
"@codemirror/lang-javascript": "^6.2.1",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@rollup/plugin-node-resolve": "^15.2.3",
"codemirror": "^6.0.1",
"rollup": "^4.9.5"
},
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4"
}
}

12
deps/codemirror_src/rollup.config.mjs vendored Normal file
View File

@ -0,0 +1,12 @@
import {nodeResolve} from "@rollup/plugin-node-resolve"
import terser from '@rollup/plugin-terser';
export default {
input: "./editor.mjs",
output: {
file: "../codemirror/cm6.js",
format: "es",
plugins: [terser()],
},
plugins: [nodeResolve()]
}