[mod] latest deps
This commit is contained in:
parent
5ffd6c7630
commit
5a8d24dc49
9 changed files with 990 additions and 2529 deletions
|
|
@ -1,10 +1,15 @@
|
|||
import { EditorState } from '@codemirror/state';
|
||||
|
||||
import { lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, rectangularSelection, crosshairCursor, highlightActiveLine, keymap, EditorView } from '@codemirror/view';
|
||||
|
||||
import { openSearchPanel, highlightSelectionMatches, searchKeymap } from '@codemirror/search';
|
||||
import { openLintPanel, lintGutter, lintKeymap, linter, setDiagnostics, } from "@codemirror/lint"
|
||||
import { indentWithTab, history, defaultKeymap, historyKeymap } from '@codemirror/commands';
|
||||
import { foldGutter, indentOnInput, indentUnit, bracketMatching, foldKeymap, syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language';
|
||||
import { foldGutter, indentOnInput, indentUnit, bracketMatching, foldKeymap, StreamLanguage } from '@codemirror/language';
|
||||
|
||||
import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
|
||||
import { lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLine, keymap, EditorView } from '@codemirror/view';
|
||||
|
||||
import { xQuery } from "@codemirror/legacy-modes/mode/xquery"
|
||||
|
||||
// Theme
|
||||
import { oneDark } from "@codemirror/theme-one-dark";
|
||||
|
|
@ -17,6 +22,7 @@ function simpleWebSocketTransport(uri) {
|
|||
let handlers = [];
|
||||
return new Promise(function (resolve, reject) {
|
||||
let sock = new WebSocket(uri);
|
||||
|
||||
sock.onmessage = e => { for (let h of handlers) h(e.data.toString()); };
|
||||
sock.onerror = e => reject(e);
|
||||
sock.onopen = () => resolve({
|
||||
|
|
@ -58,8 +64,7 @@ const baseExts = [
|
|||
...searchKeymap,
|
||||
...lintKeymap
|
||||
]),
|
||||
xml(),
|
||||
syntaxHighlighting(defaultHighlightStyle, { fallback: true })
|
||||
StreamLanguage.define(xQuery)
|
||||
];
|
||||
|
||||
function createEditorState(initialContents, extensions, options = {}) {
|
||||
|
|
@ -77,44 +82,40 @@ function createEditorView(state, parent) {
|
|||
return new EditorView({ state, parent });
|
||||
}
|
||||
|
||||
class xqLinter {
|
||||
constructor(parameters) {
|
||||
this.fred = parameters;
|
||||
}
|
||||
}
|
||||
function debouncedChangeListener({ delay = 750, onChange }) {
|
||||
let timeoutId = null;
|
||||
let lastContent = '';
|
||||
|
||||
return EditorView.updateListener.of(update => {
|
||||
if (update.docChanged) {
|
||||
const currentContent = update.state.doc.toString();
|
||||
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
timeoutId = setTimeout(() => {
|
||||
if (currentContent !== lastContent) {
|
||||
lastContent = currentContent;
|
||||
onChange(currentContent, update.state);
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function listCommands(view) {
|
||||
return EditorView.updateListener.of(update => {
|
||||
if (update.docChanged) {
|
||||
const currentContent = update.state.doc.toString();
|
||||
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
timeoutId = setTimeout(() => {
|
||||
if (currentContent !== lastContent) {
|
||||
lastContent = currentContent;
|
||||
onChange(currentContent, update.state);
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// map cmd->{keybings,fn}
|
||||
function listCommands(view) {
|
||||
const commands = new Map();
|
||||
const keymaps = view.state.facet(keymap);
|
||||
for (let km of keymaps) {
|
||||
for (let binding of km) {
|
||||
if (binding.run && binding.run.name ) {
|
||||
commands.set(binding.run.name ,{key:binding.key,fn:binding.run});
|
||||
if (binding.run && binding.run.name) {
|
||||
commands.set(binding.run.name, { key: binding.key, fn: binding.run });
|
||||
}
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
};
|
||||
|
||||
export { createEditorState, createEditorView, openSearchPanel, openLintPanel, languageServerSupport, baseExts, simpleWebSocketTransport, linter, LSPPlugin, setDiagnostics, xqLinter, LSPClient,debouncedChangeListener,listCommands };
|
||||
export { createEditorState, createEditorView, openSearchPanel, openLintPanel, languageServerSupport, baseExts, simpleWebSocketTransport, linter, LSPPlugin, setDiagnostics, LSPClient, debouncedChangeListener, listCommands };
|
||||
Loading…
Add table
Add a link
Reference in a new issue