@kerebron/extension-lsp 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +82 -0
- package/esm/_dnt.polyfills.d.ts +101 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +127 -0
- package/esm/_dnt.shims.d.ts +6 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/editor/src/CoreEditor.d.ts +40 -0
- package/esm/editor/src/CoreEditor.d.ts.map +1 -0
- package/esm/editor/src/CoreEditor.js +252 -0
- package/esm/editor/src/DummyEditorView.d.ts +60 -0
- package/esm/editor/src/DummyEditorView.d.ts.map +1 -0
- package/esm/editor/src/DummyEditorView.js +277 -0
- package/esm/editor/src/Extension.d.ts +31 -0
- package/esm/editor/src/Extension.d.ts.map +1 -0
- package/esm/editor/src/Extension.js +53 -0
- package/esm/editor/src/ExtensionManager.d.ts +32 -0
- package/esm/editor/src/ExtensionManager.d.ts.map +1 -0
- package/esm/editor/src/ExtensionManager.js +260 -0
- package/esm/editor/src/Mark.d.ts +23 -0
- package/esm/editor/src/Mark.d.ts.map +1 -0
- package/esm/editor/src/Mark.js +51 -0
- package/esm/editor/src/Node.d.ts +32 -0
- package/esm/editor/src/Node.d.ts.map +1 -0
- package/esm/editor/src/Node.js +60 -0
- package/esm/editor/src/commands/CommandManager.d.ts +23 -0
- package/esm/editor/src/commands/CommandManager.d.ts.map +1 -0
- package/esm/editor/src/commands/CommandManager.js +118 -0
- package/esm/editor/src/commands/baseCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/baseCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/baseCommandFactories.js +836 -0
- package/esm/editor/src/commands/createChainableState.d.ts +3 -0
- package/esm/editor/src/commands/createChainableState.d.ts.map +1 -0
- package/esm/editor/src/commands/createChainableState.js +29 -0
- package/esm/editor/src/commands/keyCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/keyCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/keyCommandFactories.js +10 -0
- package/esm/editor/src/commands/mod.d.ts +7 -0
- package/esm/editor/src/commands/mod.d.ts.map +1 -0
- package/esm/editor/src/commands/mod.js +76 -0
- package/esm/editor/src/commands/replaceCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/replaceCommandFactories.js +94 -0
- package/esm/editor/src/commands/types.d.ts +18 -0
- package/esm/editor/src/commands/types.d.ts.map +1 -0
- package/esm/editor/src/commands/types.js +1 -0
- package/esm/editor/src/mod.d.ts +9 -0
- package/esm/editor/src/mod.d.ts.map +1 -0
- package/esm/editor/src/mod.js +8 -0
- package/esm/editor/src/nodeToTreeString.d.ts +10 -0
- package/esm/editor/src/nodeToTreeString.d.ts.map +1 -0
- package/esm/editor/src/nodeToTreeString.js +74 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +6 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +1 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.js +24 -0
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts +23 -0
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts.map +1 -0
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +163 -0
- package/esm/editor/src/plugins/keymap/keymap.d.ts +11 -0
- package/esm/editor/src/plugins/keymap/keymap.d.ts.map +1 -0
- package/esm/editor/src/plugins/keymap/keymap.js +125 -0
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +4 -0
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +1 -0
- package/esm/editor/src/plugins/keymap/w3c-keyname.js +124 -0
- package/esm/editor/src/types.d.ts +52 -0
- package/esm/editor/src/types.d.ts.map +1 -0
- package/esm/editor/src/types.js +1 -0
- package/esm/editor/src/ui.d.ts +15 -0
- package/esm/editor/src/ui.d.ts.map +1 -0
- package/esm/editor/src/ui.js +16 -0
- package/esm/editor/src/utilities/SmartOutput.d.ts +41 -0
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -0
- package/esm/editor/src/utilities/SmartOutput.js +228 -0
- package/esm/editor/src/utilities/createNodeFromContent.d.ts +9 -0
- package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +1 -0
- package/esm/editor/src/utilities/createNodeFromContent.js +32 -0
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts +9 -0
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +1 -0
- package/esm/editor/src/utilities/getHtmlAttributes.js +47 -0
- package/esm/editor/src/utilities/getShadowRoot.d.ts +2 -0
- package/esm/editor/src/utilities/getShadowRoot.d.ts.map +1 -0
- package/esm/editor/src/utilities/getShadowRoot.js +16 -0
- package/esm/editor/src/utilities/mod.d.ts +6 -0
- package/esm/editor/src/utilities/mod.d.ts.map +1 -0
- package/esm/editor/src/utilities/mod.js +5 -0
- package/esm/editor/src/utilities/toRawTextResult.d.ts +3 -0
- package/esm/editor/src/utilities/toRawTextResult.d.ts.map +1 -0
- package/esm/editor/src/utilities/toRawTextResult.js +21 -0
- package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +8 -0
- package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/AutocompletePlugin.js +232 -0
- package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +17 -0
- package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/DefaultRenderer.js +137 -0
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +26 -0
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +30 -0
- package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +11 -0
- package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/createDefaultMatcher.js +58 -0
- package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +4 -0
- package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/createRegexMatcher.js +50 -0
- package/esm/extension-autocomplete/src/mod.d.ts +3 -0
- package/esm/extension-autocomplete/src/mod.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/mod.js +2 -0
- package/esm/extension-autocomplete/src/types.d.ts +60 -0
- package/esm/extension-autocomplete/src/types.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/types.js +1 -0
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +15 -0
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/ExtensionHtml.js +108 -0
- package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +32 -0
- package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +1 -0
- package/esm/extension-lsp/src/DiagnosticPlugin.js +131 -0
- package/esm/extension-lsp/src/ExtensionLsp.d.ts +25 -0
- package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +1 -0
- package/esm/extension-lsp/src/ExtensionLsp.js +126 -0
- package/esm/extension-lsp/src/LSPClient.d.ts +56 -0
- package/esm/extension-lsp/src/LSPClient.d.ts.map +1 -0
- package/esm/extension-lsp/src/LSPClient.js +449 -0
- package/esm/extension-lsp/src/LspWebSocketTransport.d.ts +20 -0
- package/esm/extension-lsp/src/LspWebSocketTransport.d.ts.map +1 -0
- package/esm/extension-lsp/src/LspWebSocketTransport.js +137 -0
- package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +8 -0
- package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +1 -0
- package/esm/extension-lsp/src/computeIncrementalChanges.js +82 -0
- package/esm/extension-lsp/src/createLspAutocomplete.d.ts +23 -0
- package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +1 -0
- package/esm/extension-lsp/src/createLspAutocomplete.js +68 -0
- package/esm/extension-lsp/src/mod.d.ts +5 -0
- package/esm/extension-lsp/src/mod.d.ts.map +1 -0
- package/esm/extension-lsp/src/mod.js +4 -0
- package/esm/extension-lsp/src/types.d.ts +20 -0
- package/esm/extension-lsp/src/types.d.ts.map +1 -0
- package/esm/extension-lsp/src/types.js +1 -0
- package/esm/extension-lsp/src/workspace.d.ts +62 -0
- package/esm/extension-lsp/src/workspace.d.ts.map +1 -0
- package/esm/extension-lsp/src/workspace.js +168 -0
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +36 -0
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +1 -0
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +240 -0
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +26 -0
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +1 -0
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +115 -0
- package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +22 -0
- package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +1 -0
- package/esm/extension-markdown/src/ExtensionMarkdown.js +48 -0
- package/esm/extension-markdown/src/MarkdownParser.d.ts +61 -0
- package/esm/extension-markdown/src/MarkdownParser.d.ts.map +1 -0
- package/esm/extension-markdown/src/MarkdownParser.js +249 -0
- package/esm/extension-markdown/src/MarkdownSerializer.d.ts +42 -0
- package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +1 -0
- package/esm/extension-markdown/src/MarkdownSerializer.js +325 -0
- package/esm/extension-markdown/src/PositionMapper.d.ts +15 -0
- package/esm/extension-markdown/src/PositionMapper.d.ts.map +1 -0
- package/esm/extension-markdown/src/PositionMapper.js +100 -0
- package/esm/extension-markdown/src/TokenSource.d.ts +11 -0
- package/esm/extension-markdown/src/TokenSource.d.ts.map +1 -0
- package/esm/extension-markdown/src/TokenSource.js +39 -0
- package/esm/extension-markdown/src/mdToPmConverter.d.ts +5 -0
- package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +1 -0
- package/esm/extension-markdown/src/mdToPmConverter.js +111 -0
- package/esm/extension-markdown/src/pmToMdConverter.d.ts +16 -0
- package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +1 -0
- package/esm/extension-markdown/src/pmToMdConverter.js +433 -0
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +4 -0
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +151 -0
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +3 -0
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +34 -0
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +6 -0
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +380 -0
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +3 -0
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +323 -0
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +9 -0
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +308 -0
- package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +5 -0
- package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +1 -0
- package/esm/extension-markdown/src/treeSitterTokenizer.js +769 -0
- package/esm/extension-markdown/src/types.d.ts +28 -0
- package/esm/extension-markdown/src/types.d.ts.map +1 -0
- package/esm/extension-markdown/src/types.js +131 -0
- package/esm/extension-markdown/src/utils.d.ts +8 -0
- package/esm/extension-markdown/src/utils.d.ts.map +1 -0
- package/esm/extension-markdown/src/utils.js +86 -0
- package/esm/package.json +3 -0
- package/esm/tree-sitter-shim/src/main.d.ts +15 -0
- package/esm/tree-sitter-shim/src/main.d.ts.map +1 -0
- package/esm/tree-sitter-shim/src/main.js +25 -0
- package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +6 -0
- package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +1 -0
- package/esm/tree-sitter-shim/src/tree_sitter/node.js +1 -0
- package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +7 -0
- package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +1 -0
- package/esm/tree-sitter-shim/src/tree_sitter/parser.js +5 -0
- package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +6 -0
- package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +1 -0
- package/esm/tree-sitter-shim/src/tree_sitter/tree.js +1 -0
- package/esm/wasm/src/mod.d.ts +12 -0
- package/esm/wasm/src/mod.d.ts.map +1 -0
- package/esm/wasm/src/mod.js +48 -0
- package/esm/wasm/wasm.d.ts +138 -0
- package/esm/wasm/wasm.d.ts.map +1 -0
- package/esm/wasm/wasm.js +120 -0
- package/package.json +31 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MarkSpec, Node as ProseMirrorNode, NodeSpec } from 'prosemirror-model';
|
|
2
|
+
import type { Mark } from '../Mark.js';
|
|
3
|
+
import type { Node } from '../Node.js';
|
|
4
|
+
type MarkOfNode = Mark | Node;
|
|
5
|
+
export declare function getHtmlAttributes(extension: MarkOfNode, node: ProseMirrorNode): Record<string, any>;
|
|
6
|
+
export declare function setHtmlAttributes(extension: MarkOfNode, element: HTMLElement): Record<string, any>;
|
|
7
|
+
export declare function addAttributesToSchema(spec: MarkSpec | NodeSpec, extension: MarkOfNode): void;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=getHtmlAttributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHtmlAttributes.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/getHtmlAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,IAAI,IAAI,eAAe,EACvB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9B,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,eAAe,uBAmBtB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,uBAc5E;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EACzB,SAAS,EAAE,UAAU,QAetB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function getHtmlAttributes(extension, node) {
|
|
2
|
+
const attrs = {};
|
|
3
|
+
if (extension.attributes) {
|
|
4
|
+
for (const [key, value] of Object.entries(extension.attributes)) {
|
|
5
|
+
if ('undefined' !== typeof node.attrs[key]) {
|
|
6
|
+
attrs[key] = node.attrs[key];
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
if (value.toDom) {
|
|
10
|
+
attrs[key] = value.toDom(node);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
attrs[key] = value.default;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return attrs;
|
|
19
|
+
}
|
|
20
|
+
export function setHtmlAttributes(extension, element) {
|
|
21
|
+
const attrs = {};
|
|
22
|
+
if (extension.attributes) {
|
|
23
|
+
for (const [key, value] of Object.entries(extension.attributes)) {
|
|
24
|
+
if (value.fromDom) {
|
|
25
|
+
attrs[key] = value.fromDom(element);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
attrs[key] = value.default;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return attrs;
|
|
33
|
+
}
|
|
34
|
+
export function addAttributesToSchema(spec, extension) {
|
|
35
|
+
const attrs = {};
|
|
36
|
+
if (extension.attributes) {
|
|
37
|
+
if (!spec.attrs) {
|
|
38
|
+
spec.attrs = {};
|
|
39
|
+
}
|
|
40
|
+
for (const [key, value] of Object.entries(extension.attributes)) {
|
|
41
|
+
spec.attrs[key] = value;
|
|
42
|
+
if (!value.toDom) {
|
|
43
|
+
value.toDom = (node) => node.attrs[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getShadowRoot.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/getShadowRoot.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAiBvE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function getShadowRoot(element) {
|
|
2
|
+
let current = element;
|
|
3
|
+
while (current) {
|
|
4
|
+
if (current.toString() === '[object ShadowRoot]') {
|
|
5
|
+
return current;
|
|
6
|
+
}
|
|
7
|
+
if (current instanceof ShadowRoot) {
|
|
8
|
+
if (current.host) {
|
|
9
|
+
return current.host.shadowRoot || undefined;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
current = current.parentElement ||
|
|
13
|
+
((current instanceof ShadowRoot) ? current.host : undefined);
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/mod.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toRawTextResult.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/toRawTextResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,aAAa,CAwB3E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function toRawTextResult(content, nodeIdx = 0) {
|
|
2
|
+
const lines = content.split('\n');
|
|
3
|
+
const rawTextMap = [];
|
|
4
|
+
let targetPos = 0;
|
|
5
|
+
let targetRow = 0;
|
|
6
|
+
for (const line of lines) {
|
|
7
|
+
rawTextMap.push({
|
|
8
|
+
nodeIdx,
|
|
9
|
+
targetRow,
|
|
10
|
+
targetCol: 0,
|
|
11
|
+
targetPos,
|
|
12
|
+
});
|
|
13
|
+
targetRow++;
|
|
14
|
+
targetPos += line.length + 1;
|
|
15
|
+
nodeIdx += line.length + 1;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
content,
|
|
19
|
+
rawTextMap,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { type CoreEditor } from '../../editor/src/mod.js';
|
|
3
|
+
import type { AutocompleteConfig } from './ExtensionAutocomplete.js';
|
|
4
|
+
export declare const AutocompletePluginKey: PluginKey<any>;
|
|
5
|
+
export declare class AutocompletePlugin<Item, TSelected> extends Plugin {
|
|
6
|
+
constructor(config: AutocompleteConfig, editor: CoreEditor);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=AutocompletePlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutocompletePlugin.d.ts","sourceRoot":"","sources":["../../../src/extension-autocomplete/src/AutocompletePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,yBAAyB,CAAC;AAE1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AASrE,eAAO,MAAM,qBAAqB,gBAAgC,CAAC;AAEnE,qBAAa,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAE,SAAQ,MAAM;gBACjD,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU;CA2R3D"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
3
|
+
import { createDefaultMatcher } from './createDefaultMatcher.js';
|
|
4
|
+
import { DefaultRenderer } from './DefaultRenderer.js';
|
|
5
|
+
export const AutocompletePluginKey = new PluginKey('autocomplete');
|
|
6
|
+
export class AutocompletePlugin extends Plugin {
|
|
7
|
+
constructor(config, editor) {
|
|
8
|
+
let props;
|
|
9
|
+
const renderer = config.renderer ||
|
|
10
|
+
new DefaultRenderer(editor);
|
|
11
|
+
super({
|
|
12
|
+
key: AutocompletePluginKey,
|
|
13
|
+
view() {
|
|
14
|
+
return {
|
|
15
|
+
update: async (view, prevState) => {
|
|
16
|
+
const prev = this.key?.getState(prevState);
|
|
17
|
+
const next = this.key?.getState(view.state);
|
|
18
|
+
const moved = prev.active && next.active &&
|
|
19
|
+
prev.range.from !== next.range.from;
|
|
20
|
+
const started = !prev.active && next.active;
|
|
21
|
+
const stopped = prev.active && !next.active;
|
|
22
|
+
const changed = !started && !stopped && prev.query !== next.query;
|
|
23
|
+
const handleStart = started || (moved && changed);
|
|
24
|
+
const handleChange = changed || moved;
|
|
25
|
+
let handleExit = stopped || (moved && changed);
|
|
26
|
+
if (!handleStart && !handleChange && !handleExit) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const state = handleExit && !handleStart ? prev : next;
|
|
30
|
+
// await new Promise(r => setTimeout(r, 100));
|
|
31
|
+
const decorationNode = view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`);
|
|
32
|
+
props = {
|
|
33
|
+
range: state.range,
|
|
34
|
+
query: state.query,
|
|
35
|
+
text: state.text,
|
|
36
|
+
items: [],
|
|
37
|
+
command: (selected) => {
|
|
38
|
+
if (!config.onSelect) {
|
|
39
|
+
return () => { };
|
|
40
|
+
}
|
|
41
|
+
return config.onSelect(selected, state.range);
|
|
42
|
+
},
|
|
43
|
+
decorationNode,
|
|
44
|
+
// virtual node for popper.js or tippy.js
|
|
45
|
+
// this can be used for building popups without a DOM node
|
|
46
|
+
clientRect: decorationNode
|
|
47
|
+
? () => {
|
|
48
|
+
// because of `items` can be asynchrounous we’ll search for the current decoration node
|
|
49
|
+
const { decorationId } = this.key?.getState(editor.state); // eslint-disable-line
|
|
50
|
+
const currentDecorationNode = view.dom.querySelector(`[data-decoration-id="${decorationId}"]`);
|
|
51
|
+
return currentDecorationNode?.getBoundingClientRect() || null;
|
|
52
|
+
}
|
|
53
|
+
: null,
|
|
54
|
+
};
|
|
55
|
+
if (handleStart) {
|
|
56
|
+
renderer?.onBeforeStart?.(props);
|
|
57
|
+
}
|
|
58
|
+
if (handleChange) {
|
|
59
|
+
renderer?.onBeforeUpdate?.(props);
|
|
60
|
+
}
|
|
61
|
+
if (handleChange || handleStart) {
|
|
62
|
+
if (config.getItems) {
|
|
63
|
+
try {
|
|
64
|
+
const ctx = { state, range: state.range, isActive: true };
|
|
65
|
+
props.items = await config.getItems(state.query, ctx);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (err.isLSP) {
|
|
69
|
+
props.items = [];
|
|
70
|
+
console.error('LSP error config.getItems()', err.message, config.getItems);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (props.items.length === 0) {
|
|
77
|
+
handleExit = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (handleExit) {
|
|
82
|
+
renderer?.onExit?.(props);
|
|
83
|
+
}
|
|
84
|
+
if (handleChange) {
|
|
85
|
+
renderer?.onUpdate?.(props);
|
|
86
|
+
}
|
|
87
|
+
if (handleStart) {
|
|
88
|
+
renderer?.onStart?.(props);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
destroy: () => {
|
|
92
|
+
if (!props) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
renderer?.onExit?.(props);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
state: {
|
|
100
|
+
// Initialize the plugin's internal state.
|
|
101
|
+
init() {
|
|
102
|
+
const state = {
|
|
103
|
+
manual: false,
|
|
104
|
+
active: false,
|
|
105
|
+
range: {
|
|
106
|
+
from: 0,
|
|
107
|
+
to: 0,
|
|
108
|
+
},
|
|
109
|
+
query: null,
|
|
110
|
+
text: null,
|
|
111
|
+
composing: false,
|
|
112
|
+
};
|
|
113
|
+
return state;
|
|
114
|
+
},
|
|
115
|
+
// Apply changes to the plugin state from a view transaction.
|
|
116
|
+
apply(transaction, prev, _oldState, state) {
|
|
117
|
+
// const { isEditable } = editor; // TODO
|
|
118
|
+
const isEditable = true;
|
|
119
|
+
const { composing } = editor.view;
|
|
120
|
+
const { selection } = transaction;
|
|
121
|
+
const { empty, from } = selection;
|
|
122
|
+
const next = { ...prev };
|
|
123
|
+
const meta = transaction.getMeta(AutocompletePluginKey);
|
|
124
|
+
if (!meta && !transaction.isGeneric) {
|
|
125
|
+
return next;
|
|
126
|
+
}
|
|
127
|
+
if (meta?.type === 'deactivate') {
|
|
128
|
+
console.info('Deactivate autocomplete');
|
|
129
|
+
next.active = false;
|
|
130
|
+
return next;
|
|
131
|
+
}
|
|
132
|
+
if (meta?.type === 'activate') {
|
|
133
|
+
console.info('Trigger manual autocomplete');
|
|
134
|
+
next.range = { from: selection.from, to: selection.to };
|
|
135
|
+
next.active = true;
|
|
136
|
+
next.manual = true;
|
|
137
|
+
next.query = null;
|
|
138
|
+
return next;
|
|
139
|
+
}
|
|
140
|
+
next.composing = composing;
|
|
141
|
+
const parentNode = selection.$anchor.parent;
|
|
142
|
+
if (!['code_block'].includes(parentNode?.type.name) && isEditable &&
|
|
143
|
+
(empty || editor.view.composing)) {
|
|
144
|
+
// Reset active state if we just left the previous suggestion range
|
|
145
|
+
if ((from < prev.range.from || from > prev.range.to) && !composing &&
|
|
146
|
+
!prev.composing) {
|
|
147
|
+
next.active = false;
|
|
148
|
+
}
|
|
149
|
+
const matchers = config.matchers ||
|
|
150
|
+
[createDefaultMatcher()];
|
|
151
|
+
let match = undefined;
|
|
152
|
+
for (const matcher of matchers) {
|
|
153
|
+
match = matcher(selection.$from);
|
|
154
|
+
if (match) {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const decorationId = `id_${Math.floor(Math.random() * 0xffffffff)}`;
|
|
159
|
+
// If we found a match, update the current state to show it
|
|
160
|
+
if (match && (!config.allow || config.allow({
|
|
161
|
+
state,
|
|
162
|
+
range: match.range,
|
|
163
|
+
isActive: prev.active,
|
|
164
|
+
}))) {
|
|
165
|
+
console.info('Trigger matcher autocomplete', match);
|
|
166
|
+
next.active = true;
|
|
167
|
+
next.decorationId = prev.decorationId
|
|
168
|
+
? prev.decorationId
|
|
169
|
+
: decorationId;
|
|
170
|
+
next.range = match.range;
|
|
171
|
+
next.query = match.query;
|
|
172
|
+
next.text = match.text;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
next.active = false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
next.active = false;
|
|
180
|
+
}
|
|
181
|
+
next.manual = false;
|
|
182
|
+
// Make sure to empty the range if suggestion is inactive
|
|
183
|
+
if (!next.active) {
|
|
184
|
+
next.decorationId = null;
|
|
185
|
+
next.range = { from: 0, to: 0 };
|
|
186
|
+
next.query = null;
|
|
187
|
+
next.text = null;
|
|
188
|
+
}
|
|
189
|
+
return next;
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
props: {
|
|
193
|
+
// Call the keydown hook if suggestion is active.
|
|
194
|
+
handleKeyDown(view, event) {
|
|
195
|
+
const { active, range } = this.getState(view.state);
|
|
196
|
+
if (event.key === ' ' && event.ctrlKey) {
|
|
197
|
+
const tr = view.state.tr.setMeta(AutocompletePluginKey, {
|
|
198
|
+
type: 'activate',
|
|
199
|
+
});
|
|
200
|
+
console.info('Manual autocomplete key');
|
|
201
|
+
view.dispatch(tr);
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
if (active) {
|
|
205
|
+
return renderer?.onKeyDown?.({ view, event, range }) || false;
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
208
|
+
},
|
|
209
|
+
// Setup decorator on the currently active suggestion.
|
|
210
|
+
decorations(state) {
|
|
211
|
+
const { active, range, decorationId } = this.getState(state);
|
|
212
|
+
if (!active) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
const node = document.createElement('span');
|
|
216
|
+
node.className = config.decorationClass || 'kb-autocomplete--decor';
|
|
217
|
+
node.setAttribute('data-decoration-id', decorationId);
|
|
218
|
+
return DecorationSet.create(state.doc, [
|
|
219
|
+
Decoration.widget(range.from, node),
|
|
220
|
+
]);
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
renderer.addEventListener('close', () => {
|
|
225
|
+
const tr = editor.state.tr.setMeta(AutocompletePluginKey, {
|
|
226
|
+
type: 'deactivate',
|
|
227
|
+
});
|
|
228
|
+
console.info('Manual autocomplete deactivate');
|
|
229
|
+
editor.view.dispatch(tr);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CoreEditor } from '../../editor/src/mod.js';
|
|
2
|
+
import { AutocompleteRenderer, SuggestionKeyDownProps, SuggestionProps } from './types.js';
|
|
3
|
+
export declare class DefaultRenderer<Item> extends EventTarget implements AutocompleteRenderer {
|
|
4
|
+
private editor;
|
|
5
|
+
command: (props: any) => void;
|
|
6
|
+
wrapper: HTMLElement | undefined;
|
|
7
|
+
items: Array<Item>;
|
|
8
|
+
pos: number;
|
|
9
|
+
constructor(editor: CoreEditor);
|
|
10
|
+
onStart(props: SuggestionProps<Item>): void;
|
|
11
|
+
onUpdate(props: SuggestionProps<Item>): void;
|
|
12
|
+
onExit(): void;
|
|
13
|
+
onKeyDown(props: SuggestionKeyDownProps): boolean;
|
|
14
|
+
createListItem(item: Item, cnt: number): any;
|
|
15
|
+
recreateList(props?: SuggestionProps<Item>): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=DefaultRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultRenderer.d.ts","sourceRoot":"","sources":["../../../src/extension-autocomplete/src/DefaultRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EAChB,MAAM,YAAY,CAAC;AAIpB,qBAAa,eAAe,CAAC,IAAI,CAAE,SAAQ,WACzC,YAAW,oBAAoB;IAMnB,OAAO,CAAC,MAAM;IAL1B,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9B,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAM;IACxB,GAAG,EAAE,MAAM,CAAM;gBAEG,MAAM,EAAE,UAAU;IAKtC,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC;IAiBpC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC;IAMrC,MAAM;IASN,SAAS,CAAC,KAAK,EAAE,sBAAsB;IA0CvC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM;IAatC,YAAY,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC;CAyB3C"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const CSS_PREFIX = 'kb-autocomplete';
|
|
2
|
+
export class DefaultRenderer extends EventTarget {
|
|
3
|
+
constructor(editor) {
|
|
4
|
+
super();
|
|
5
|
+
Object.defineProperty(this, "editor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true,
|
|
9
|
+
value: editor
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(this, "command", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: void 0
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "wrapper", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "items", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: []
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "pos", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: -1
|
|
34
|
+
});
|
|
35
|
+
this.command = () => { };
|
|
36
|
+
}
|
|
37
|
+
onStart(props) {
|
|
38
|
+
this.command = props.command;
|
|
39
|
+
if (this.wrapper) {
|
|
40
|
+
this.wrapper.parentElement?.removeChild(this.wrapper);
|
|
41
|
+
}
|
|
42
|
+
const root = ('root' in this.editor.view)
|
|
43
|
+
? this.editor.view.root
|
|
44
|
+
: document || document;
|
|
45
|
+
this.wrapper = document.createElement('ul');
|
|
46
|
+
this.wrapper.classList.add(CSS_PREFIX + '__wrapper');
|
|
47
|
+
(root.body || root).appendChild(this.wrapper);
|
|
48
|
+
this.items.splice(0, this.items.length, ...props.items);
|
|
49
|
+
this.recreateList(props);
|
|
50
|
+
}
|
|
51
|
+
onUpdate(props) {
|
|
52
|
+
this.command = props.command;
|
|
53
|
+
this.items.splice(0, this.items.length, ...props.items);
|
|
54
|
+
this.recreateList(props);
|
|
55
|
+
}
|
|
56
|
+
onExit() {
|
|
57
|
+
if (this.wrapper) {
|
|
58
|
+
this.wrapper.parentNode?.removeChild(this.wrapper);
|
|
59
|
+
this.wrapper = undefined;
|
|
60
|
+
}
|
|
61
|
+
this.dispatchEvent(new Event('close'));
|
|
62
|
+
this.pos = -1;
|
|
63
|
+
}
|
|
64
|
+
onKeyDown(props) {
|
|
65
|
+
if (!this.wrapper) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (this.items.length === 0) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (props.event.key === 'Escape') {
|
|
72
|
+
if (this.wrapper) {
|
|
73
|
+
this.wrapper.parentNode?.removeChild(this.wrapper);
|
|
74
|
+
this.wrapper = undefined;
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (props.event.key === 'ArrowUp') {
|
|
79
|
+
if (this.pos > -1) {
|
|
80
|
+
this.pos = this.pos - 1;
|
|
81
|
+
this.recreateList();
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (props.event.key === 'ArrowDown') {
|
|
86
|
+
if (this.pos < this.items.length - 1) {
|
|
87
|
+
this.pos++;
|
|
88
|
+
this.recreateList();
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if (props.event.key === 'Enter') {
|
|
93
|
+
if (this.pos > -1 && this.pos < this.items.length) {
|
|
94
|
+
this.command(this.items[this.pos]);
|
|
95
|
+
this.items.splice(0, this.items.length);
|
|
96
|
+
this.onExit();
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
createListItem(item, cnt) {
|
|
103
|
+
const li = document.createElement('li');
|
|
104
|
+
if (cnt === this.pos) {
|
|
105
|
+
li.classList.add('active');
|
|
106
|
+
}
|
|
107
|
+
li.innerText = '' + item; // TODO item to string and item formatting
|
|
108
|
+
li.style.cursor = 'pointer';
|
|
109
|
+
li.addEventListener('click', () => {
|
|
110
|
+
this.command(item);
|
|
111
|
+
});
|
|
112
|
+
return li;
|
|
113
|
+
}
|
|
114
|
+
recreateList(props) {
|
|
115
|
+
if (!this.wrapper) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.wrapper.innerHTML = '';
|
|
119
|
+
for (let cnt = 0; cnt < this.items.length; cnt++) {
|
|
120
|
+
const item = this.items[cnt];
|
|
121
|
+
this.wrapper.appendChild(this.createListItem(item, cnt));
|
|
122
|
+
}
|
|
123
|
+
if (this.items.length === 0) {
|
|
124
|
+
this.wrapper.style.display = 'none';
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.wrapper.style.display = '';
|
|
128
|
+
}
|
|
129
|
+
const rect = props?.clientRect?.();
|
|
130
|
+
if (rect?.height) {
|
|
131
|
+
const left = rect.left;
|
|
132
|
+
const bottom = rect.bottom;
|
|
133
|
+
this.wrapper.style.left = left + 'px';
|
|
134
|
+
this.wrapper.style.top = bottom + 'px';
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EditorState, Plugin } from 'prosemirror-state';
|
|
2
|
+
import { Extension, type TextRange } from '../../editor/src/mod.js';
|
|
3
|
+
import { AutocompletePlugin } from './AutocompletePlugin.js';
|
|
4
|
+
import { AutocompleteMatcher, AutocompleteRenderer } from './types.js';
|
|
5
|
+
export interface AutocompleteProps {
|
|
6
|
+
state: EditorState;
|
|
7
|
+
range: TextRange;
|
|
8
|
+
isActive?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface AutocompleteConfig<I = any, TSelected = any> {
|
|
11
|
+
getItems: (query: string, props: AutocompleteProps) => I[] | Promise<I[]>;
|
|
12
|
+
onSelect?: (selected: TSelected, range: TextRange) => void;
|
|
13
|
+
allow?: (props: AutocompleteProps) => boolean;
|
|
14
|
+
matchers?: AutocompleteMatcher[];
|
|
15
|
+
renderer?: AutocompleteRenderer<I, TSelected>;
|
|
16
|
+
decorationTag?: string;
|
|
17
|
+
decorationClass?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class ExtensionAutocomplete extends Extension {
|
|
20
|
+
protected config: AutocompleteConfig;
|
|
21
|
+
name: string;
|
|
22
|
+
plugin: AutocompletePlugin<unknown, unknown>;
|
|
23
|
+
constructor(config: AutocompleteConfig);
|
|
24
|
+
getProseMirrorPlugins(): Plugin[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ExtensionAutocomplete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionAutocomplete.d.ts","sourceRoot":"","sources":["../../../src/extension-autocomplete/src/ExtensionAutocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAmB,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAErF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,GAAG,GAAG;IAC1D,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAE1E,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC3D,KAAK,CAAC,EAAE,CACN,KAAK,EAAE,iBAAiB,KACrB,OAAO,CAAC;IAEb,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAE9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,qBAAsB,SAAQ,SAAS;cAK7B,MAAM,EAAE,kBAAkB;IAJ/C,IAAI,SAAkB;IACtB,MAAM,EAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAGzB,MAAM,EAAE,kBAAkB;IAKtC,qBAAqB,IAAI,MAAM,EAAE;CAK3C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Extension } from '../../editor/src/mod.js';
|
|
2
|
+
import { AutocompletePlugin } from './AutocompletePlugin.js';
|
|
3
|
+
export class ExtensionAutocomplete extends Extension {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
super(config);
|
|
6
|
+
Object.defineProperty(this, "config", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: config
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "name", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: 'autocomplete'
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "plugin", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
getProseMirrorPlugins() {
|
|
26
|
+
return [
|
|
27
|
+
new AutocompletePlugin(this.config, this.editor),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AutocompleteMatcher } from './types.js';
|
|
2
|
+
export declare function escapeForRegEx(string: string): string;
|
|
3
|
+
export interface MatcherConfig {
|
|
4
|
+
char?: string;
|
|
5
|
+
allowSpaces?: boolean;
|
|
6
|
+
allowToIncludeChar?: boolean;
|
|
7
|
+
allowedPrefixes?: string[] | null;
|
|
8
|
+
startOfLine?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function createDefaultMatcher(config?: MatcherConfig): AutocompleteMatcher;
|
|
11
|
+
//# sourceMappingURL=createDefaultMatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDefaultMatcher.d.ts","sourceRoot":"","sources":["../../../src/extension-autocomplete/src/createDefaultMatcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,YAAY,CAAC;AAGlE,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,oBAAoB,CAClC,MAAM,GAAE,aAAkB,GACzB,mBAAmB,CA4ErB"}
|