@kerebron/extension-codemirror 0.4.5 → 0.4.7
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/esm/{extension-codemirror/src/ExtensionCodeMirror.d.ts → ExtensionCodeMirror.d.ts} +1 -2
- package/esm/ExtensionCodeMirror.d.ts.map +1 -0
- package/esm/{extension-codemirror/src/ExtensionCodeMirror.js → ExtensionCodeMirror.js} +2 -3
- package/esm/{extension-codemirror/src/NodeCodeMirror.d.ts → NodeCodeMirror.d.ts} +3 -3
- package/esm/NodeCodeMirror.d.ts.map +1 -0
- package/esm/{extension-codemirror/src/NodeCodeMirror.js → NodeCodeMirror.js} +2 -2
- package/esm/{extension-codemirror/src/codeMirrorBlockNodeView.d.ts → codeMirrorBlockNodeView.d.ts} +1 -1
- package/esm/codeMirrorBlockNodeView.d.ts.map +1 -0
- package/esm/defaults.d.ts.map +1 -0
- package/esm/languageLoaders.d.ts.map +1 -0
- package/esm/languages.d.ts.map +1 -0
- package/esm/{extension-codemirror/src/lsp → lsp}/LSPExtension.d.ts +2 -2
- package/esm/lsp/LSPExtension.d.ts.map +1 -0
- package/esm/lsp/completion.d.ts.map +1 -0
- package/esm/lsp/hover.d.ts.map +1 -0
- package/esm/lsp/index.d.ts.map +1 -0
- package/esm/{extension-codemirror/src/lsp → lsp}/plugin.d.ts +3 -3
- package/esm/lsp/plugin.d.ts.map +1 -0
- package/esm/{extension-codemirror/src/lsp → lsp}/plugin.js +2 -2
- package/esm/lsp/pos.d.ts.map +1 -0
- package/esm/lsp/text.d.ts.map +1 -0
- package/esm/lsp/theme.d.ts.map +1 -0
- package/esm/remote-selections.d.ts.map +1 -0
- package/esm/{extension-codemirror/src/remote-sync.d.ts → remote-sync.d.ts} +1 -1
- package/esm/remote-sync.d.ts.map +1 -0
- package/esm/{extension-codemirror/src/types.d.ts → types.d.ts} +1 -1
- package/esm/types.d.ts.map +1 -0
- package/esm/{extension-codemirror/src/utils.d.ts → utils.d.ts} +1 -1
- package/esm/utils.d.ts.map +1 -0
- package/package.json +30 -6
- package/esm/_dnt.polyfills.d.ts +0 -101
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -127
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/editor/src/CoreEditor.d.ts +0 -40
- package/esm/editor/src/CoreEditor.d.ts.map +0 -1
- package/esm/editor/src/CoreEditor.js +0 -252
- package/esm/editor/src/DummyEditorView.d.ts +0 -60
- package/esm/editor/src/DummyEditorView.d.ts.map +0 -1
- package/esm/editor/src/DummyEditorView.js +0 -277
- package/esm/editor/src/Extension.d.ts +0 -31
- package/esm/editor/src/Extension.d.ts.map +0 -1
- package/esm/editor/src/Extension.js +0 -53
- package/esm/editor/src/ExtensionManager.d.ts +0 -32
- package/esm/editor/src/ExtensionManager.d.ts.map +0 -1
- package/esm/editor/src/ExtensionManager.js +0 -260
- package/esm/editor/src/Mark.d.ts +0 -23
- package/esm/editor/src/Mark.d.ts.map +0 -1
- package/esm/editor/src/Mark.js +0 -51
- package/esm/editor/src/Node.d.ts +0 -32
- package/esm/editor/src/Node.d.ts.map +0 -1
- package/esm/editor/src/Node.js +0 -60
- package/esm/editor/src/commands/CommandManager.d.ts +0 -23
- package/esm/editor/src/commands/CommandManager.d.ts.map +0 -1
- package/esm/editor/src/commands/CommandManager.js +0 -118
- package/esm/editor/src/commands/baseCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/baseCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/baseCommandFactories.js +0 -836
- package/esm/editor/src/commands/createChainableState.d.ts +0 -3
- package/esm/editor/src/commands/createChainableState.d.ts.map +0 -1
- package/esm/editor/src/commands/createChainableState.js +0 -29
- package/esm/editor/src/commands/keyCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/keyCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/keyCommandFactories.js +0 -10
- package/esm/editor/src/commands/mod.d.ts +0 -7
- package/esm/editor/src/commands/mod.d.ts.map +0 -1
- package/esm/editor/src/commands/mod.js +0 -76
- package/esm/editor/src/commands/replaceCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/replaceCommandFactories.js +0 -94
- package/esm/editor/src/commands/types.d.ts +0 -18
- package/esm/editor/src/commands/types.d.ts.map +0 -1
- package/esm/editor/src/mod.d.ts +0 -9
- package/esm/editor/src/mod.d.ts.map +0 -1
- package/esm/editor/src/mod.js +0 -8
- package/esm/editor/src/nodeToTreeString.d.ts +0 -10
- package/esm/editor/src/nodeToTreeString.d.ts.map +0 -1
- package/esm/editor/src/nodeToTreeString.js +0 -74
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +0 -6
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +0 -1
- package/esm/editor/src/plugins/TrackSelecionPlugin.js +0 -24
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts +0 -23
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts.map +0 -1
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +0 -163
- package/esm/editor/src/plugins/input-rules/mod.d.ts +0 -3
- package/esm/editor/src/plugins/input-rules/mod.d.ts.map +0 -1
- package/esm/editor/src/plugins/input-rules/mod.js +0 -2
- package/esm/editor/src/plugins/input-rules/rulebuilders.d.ts +0 -5
- package/esm/editor/src/plugins/input-rules/rulebuilders.d.ts.map +0 -1
- package/esm/editor/src/plugins/input-rules/rulebuilders.js +0 -50
- package/esm/editor/src/plugins/keymap/keymap.d.ts +0 -11
- package/esm/editor/src/plugins/keymap/keymap.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/keymap.js +0 -125
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +0 -4
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/w3c-keyname.js +0 -124
- package/esm/editor/src/types.d.ts +0 -52
- package/esm/editor/src/types.d.ts.map +0 -1
- package/esm/editor/src/types.js +0 -1
- package/esm/editor/src/ui.d.ts +0 -15
- package/esm/editor/src/ui.d.ts.map +0 -1
- package/esm/editor/src/ui.js +0 -16
- package/esm/editor/src/utilities/SmartOutput.d.ts +0 -41
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +0 -1
- package/esm/editor/src/utilities/SmartOutput.js +0 -228
- package/esm/editor/src/utilities/createNodeFromContent.d.ts +0 -9
- package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +0 -1
- package/esm/editor/src/utilities/createNodeFromContent.js +0 -32
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts +0 -9
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +0 -1
- package/esm/editor/src/utilities/getHtmlAttributes.js +0 -47
- package/esm/editor/src/utilities/getShadowRoot.d.ts +0 -2
- package/esm/editor/src/utilities/getShadowRoot.d.ts.map +0 -1
- package/esm/editor/src/utilities/getShadowRoot.js +0 -16
- package/esm/editor/src/utilities/mod.d.ts +0 -6
- package/esm/editor/src/utilities/mod.d.ts.map +0 -1
- package/esm/editor/src/utilities/mod.js +0 -5
- package/esm/editor/src/utilities/toRawTextResult.d.ts +0 -3
- package/esm/editor/src/utilities/toRawTextResult.d.ts.map +0 -1
- package/esm/editor/src/utilities/toRawTextResult.js +0 -21
- package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +0 -8
- package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +0 -1
- package/esm/extension-autocomplete/src/AutocompletePlugin.js +0 -232
- package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +0 -17
- package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +0 -1
- package/esm/extension-autocomplete/src/DefaultRenderer.js +0 -137
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +0 -26
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +0 -1
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +0 -30
- package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +0 -11
- package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +0 -1
- package/esm/extension-autocomplete/src/createDefaultMatcher.js +0 -58
- package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +0 -4
- package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +0 -1
- package/esm/extension-autocomplete/src/createRegexMatcher.js +0 -50
- package/esm/extension-autocomplete/src/mod.d.ts +0 -3
- package/esm/extension-autocomplete/src/mod.d.ts.map +0 -1
- package/esm/extension-autocomplete/src/mod.js +0 -2
- package/esm/extension-autocomplete/src/types.d.ts +0 -60
- package/esm/extension-autocomplete/src/types.d.ts.map +0 -1
- package/esm/extension-autocomplete/src/types.js +0 -1
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +0 -15
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/ExtensionHtml.js +0 -108
- package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts +0 -9
- package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/NodeCodeBlock.js +0 -58
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +0 -24
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +0 -35
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +0 -25
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +0 -96
- package/esm/extension-codemirror/src/ExtensionCodeMirror.d.ts.map +0 -1
- package/esm/extension-codemirror/src/NodeCodeMirror.d.ts.map +0 -1
- package/esm/extension-codemirror/src/codeMirrorBlockNodeView.d.ts.map +0 -1
- package/esm/extension-codemirror/src/defaults.d.ts.map +0 -1
- package/esm/extension-codemirror/src/languageLoaders.d.ts.map +0 -1
- package/esm/extension-codemirror/src/languages.d.ts.map +0 -1
- package/esm/extension-codemirror/src/lsp/LSPExtension.d.ts.map +0 -1
- package/esm/extension-codemirror/src/lsp/completion.d.ts.map +0 -1
- package/esm/extension-codemirror/src/lsp/hover.d.ts.map +0 -1
- package/esm/extension-codemirror/src/lsp/index.d.ts.map +0 -1
- package/esm/extension-codemirror/src/lsp/plugin.d.ts.map +0 -1
- package/esm/extension-codemirror/src/lsp/pos.d.ts.map +0 -1
- package/esm/extension-codemirror/src/lsp/text.d.ts.map +0 -1
- package/esm/extension-codemirror/src/lsp/theme.d.ts.map +0 -1
- package/esm/extension-codemirror/src/remote-selections.d.ts.map +0 -1
- package/esm/extension-codemirror/src/remote-sync.d.ts.map +0 -1
- package/esm/extension-codemirror/src/types.d.ts.map +0 -1
- package/esm/extension-codemirror/src/types.js +0 -1
- package/esm/extension-codemirror/src/utils.d.ts.map +0 -1
- package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +0 -32
- package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +0 -1
- package/esm/extension-lsp/src/DiagnosticPlugin.js +0 -131
- package/esm/extension-lsp/src/ExtensionLsp.d.ts +0 -25
- package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +0 -1
- package/esm/extension-lsp/src/ExtensionLsp.js +0 -126
- package/esm/extension-lsp/src/LSPClient.d.ts +0 -56
- package/esm/extension-lsp/src/LSPClient.d.ts.map +0 -1
- package/esm/extension-lsp/src/LSPClient.js +0 -449
- package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +0 -8
- package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +0 -1
- package/esm/extension-lsp/src/computeIncrementalChanges.js +0 -82
- package/esm/extension-lsp/src/createLspAutocomplete.d.ts +0 -23
- package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +0 -1
- package/esm/extension-lsp/src/createLspAutocomplete.js +0 -68
- package/esm/extension-lsp/src/mod.d.ts +0 -4
- package/esm/extension-lsp/src/mod.d.ts.map +0 -1
- package/esm/extension-lsp/src/mod.js +0 -3
- package/esm/extension-lsp/src/workspace.d.ts +0 -62
- package/esm/extension-lsp/src/workspace.d.ts.map +0 -1
- package/esm/extension-lsp/src/workspace.js +0 -168
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +0 -36
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +0 -1
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +0 -240
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +0 -26
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +0 -1
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +0 -115
- package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +0 -22
- package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +0 -1
- package/esm/extension-markdown/src/ExtensionMarkdown.js +0 -48
- package/esm/extension-markdown/src/MarkdownParser.d.ts +0 -61
- package/esm/extension-markdown/src/MarkdownParser.d.ts.map +0 -1
- package/esm/extension-markdown/src/MarkdownParser.js +0 -249
- package/esm/extension-markdown/src/MarkdownSerializer.d.ts +0 -42
- package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +0 -1
- package/esm/extension-markdown/src/MarkdownSerializer.js +0 -325
- package/esm/extension-markdown/src/PositionMapper.d.ts +0 -15
- package/esm/extension-markdown/src/PositionMapper.d.ts.map +0 -1
- package/esm/extension-markdown/src/PositionMapper.js +0 -100
- package/esm/extension-markdown/src/TokenSource.d.ts +0 -11
- package/esm/extension-markdown/src/TokenSource.d.ts.map +0 -1
- package/esm/extension-markdown/src/TokenSource.js +0 -39
- package/esm/extension-markdown/src/mdToPmConverter.d.ts +0 -5
- package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +0 -1
- package/esm/extension-markdown/src/mdToPmConverter.js +0 -111
- package/esm/extension-markdown/src/pmToMdConverter.d.ts +0 -16
- package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +0 -1
- package/esm/extension-markdown/src/pmToMdConverter.js +0 -433
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +0 -4
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +0 -1
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +0 -151
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +0 -3
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +0 -1
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +0 -34
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +0 -6
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +0 -1
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +0 -380
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +0 -3
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +0 -1
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +0 -323
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +0 -9
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +0 -1
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +0 -308
- package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +0 -5
- package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +0 -1
- package/esm/extension-markdown/src/treeSitterTokenizer.js +0 -769
- package/esm/extension-markdown/src/types.d.ts +0 -28
- package/esm/extension-markdown/src/types.d.ts.map +0 -1
- package/esm/extension-markdown/src/types.js +0 -131
- package/esm/extension-markdown/src/utils.d.ts +0 -8
- package/esm/extension-markdown/src/utils.d.ts.map +0 -1
- package/esm/extension-markdown/src/utils.js +0 -86
- package/esm/tree-sitter-shim/src/main.d.ts +0 -15
- package/esm/tree-sitter-shim/src/main.d.ts.map +0 -1
- package/esm/tree-sitter-shim/src/main.js +0 -25
- package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +0 -6
- package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +0 -1
- package/esm/tree-sitter-shim/src/tree_sitter/node.js +0 -1
- package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +0 -7
- package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +0 -1
- package/esm/tree-sitter-shim/src/tree_sitter/parser.js +0 -5
- package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +0 -6
- package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +0 -1
- package/esm/tree-sitter-shim/src/tree_sitter/tree.js +0 -1
- package/esm/wasm/src/mod.d.ts +0 -12
- package/esm/wasm/src/mod.d.ts.map +0 -1
- package/esm/wasm/src/mod.js +0 -48
- package/esm/wasm/wasm.d.ts +0 -138
- package/esm/wasm/wasm.d.ts.map +0 -1
- package/esm/wasm/wasm.js +0 -120
- /package/esm/{extension-codemirror/src/codeMirrorBlockNodeView.js → codeMirrorBlockNodeView.js} +0 -0
- /package/esm/{extension-codemirror/src/defaults.d.ts → defaults.d.ts} +0 -0
- /package/esm/{extension-codemirror/src/defaults.js → defaults.js} +0 -0
- /package/esm/{extension-codemirror/src/languageLoaders.d.ts → languageLoaders.d.ts} +0 -0
- /package/esm/{extension-codemirror/src/languageLoaders.js → languageLoaders.js} +0 -0
- /package/esm/{extension-codemirror/src/languages.d.ts → languages.d.ts} +0 -0
- /package/esm/{extension-codemirror/src/languages.js → languages.js} +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/LSPExtension.js +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/completion.d.ts +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/completion.js +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/hover.d.ts +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/hover.js +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/index.d.ts +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/index.js +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/pos.d.ts +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/pos.js +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/text.d.ts +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/text.js +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/theme.d.ts +0 -0
- /package/esm/{extension-codemirror/src/lsp → lsp}/theme.js +0 -0
- /package/esm/{extension-codemirror/src/remote-selections.d.ts → remote-selections.d.ts} +0 -0
- /package/esm/{extension-codemirror/src/remote-selections.js → remote-selections.js} +0 -0
- /package/esm/{extension-codemirror/src/remote-sync.js → remote-sync.js} +0 -0
- /package/esm/{editor/src/commands/types.js → types.js} +0 -0
- /package/esm/{extension-codemirror/src/utils.js → utils.js} +0 -0
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import { Node as ProseMirrorNode } from 'prosemirror-model';
|
|
3
|
-
import { ExtensionManager } from './ExtensionManager.js';
|
|
4
|
-
import { EditorState } from 'prosemirror-state';
|
|
5
|
-
import { CommandManager } from './commands/CommandManager.js';
|
|
6
|
-
import { nodeToTreeString } from './nodeToTreeString.js';
|
|
7
|
-
import { DummyEditorView } from './DummyEditorView.js';
|
|
8
|
-
import { createNodeFromObject } from './utilities/createNodeFromContent.js';
|
|
9
|
-
import { defaultUi } from './ui.js';
|
|
10
|
-
function ensureDocSchema(doc, schema) {
|
|
11
|
-
if (doc.type.schema === schema) {
|
|
12
|
-
return doc;
|
|
13
|
-
}
|
|
14
|
-
const json = doc.toJSON();
|
|
15
|
-
return ProseMirrorNode.fromJSON(schema, json);
|
|
16
|
-
}
|
|
17
|
-
export class CoreEditor extends EventTarget {
|
|
18
|
-
constructor(config = {}) {
|
|
19
|
-
super();
|
|
20
|
-
Object.defineProperty(this, "config", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: {
|
|
25
|
-
element: undefined,
|
|
26
|
-
extensions: [],
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "extensionManager", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "commandManager", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(this, "view", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: void 0
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(this, "state", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "ui", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: defaultUi(this)
|
|
58
|
-
});
|
|
59
|
-
this.config = {
|
|
60
|
-
...this.config,
|
|
61
|
-
...config,
|
|
62
|
-
};
|
|
63
|
-
this.commandManager = new CommandManager(this);
|
|
64
|
-
this.extensionManager = new ExtensionManager(this.config.extensions || [], this, this.commandManager);
|
|
65
|
-
this.extensionManager.created();
|
|
66
|
-
// const content = this.options.content ? this.options.content : {
|
|
67
|
-
// type: this.extensionManager.schema.topNodeType.name,
|
|
68
|
-
// content: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC,
|
|
69
|
-
// };
|
|
70
|
-
const content = this.config.content
|
|
71
|
-
? this.config.content
|
|
72
|
-
: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC;
|
|
73
|
-
this.createView(content);
|
|
74
|
-
this.setupPlugins();
|
|
75
|
-
}
|
|
76
|
-
getExtension(name) {
|
|
77
|
-
return this.extensionManager.getExtension(name);
|
|
78
|
-
}
|
|
79
|
-
get schema() {
|
|
80
|
-
return this.extensionManager.schema;
|
|
81
|
-
}
|
|
82
|
-
get run() {
|
|
83
|
-
return this.commandManager.run;
|
|
84
|
-
}
|
|
85
|
-
get commandFactories() {
|
|
86
|
-
return this.commandManager.commandFactories;
|
|
87
|
-
}
|
|
88
|
-
chain() {
|
|
89
|
-
return this.commandManager.createChain();
|
|
90
|
-
}
|
|
91
|
-
can() {
|
|
92
|
-
return this.commandManager.createCan();
|
|
93
|
-
}
|
|
94
|
-
createView(content) {
|
|
95
|
-
const doc = createNodeFromObject(content, this.schema);
|
|
96
|
-
this.state = EditorState.create({ doc });
|
|
97
|
-
if (this.config.element) {
|
|
98
|
-
const view = new EditorView(this.config.element, {
|
|
99
|
-
state: this.state,
|
|
100
|
-
attributes: {
|
|
101
|
-
class: 'kb-editor',
|
|
102
|
-
},
|
|
103
|
-
dispatchTransaction: (tx) => this.dispatchTransaction(tx),
|
|
104
|
-
});
|
|
105
|
-
this.view = view;
|
|
106
|
-
const parent = this.config.element.parentNode;
|
|
107
|
-
if (parent) {
|
|
108
|
-
const observer = new MutationObserver((mutations) => {
|
|
109
|
-
for (const mutation of mutations) {
|
|
110
|
-
for (const removedNode of mutation.removedNodes) {
|
|
111
|
-
if (removedNode.contains(view.dom)) {
|
|
112
|
-
// Editor DOM was removed
|
|
113
|
-
observer.disconnect(); // Prevent multiple calls
|
|
114
|
-
view.destroy();
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
this.view = new DummyEditorView({
|
|
124
|
-
state: this.state,
|
|
125
|
-
dispatchTransaction: (tx) => this.dispatchTransaction(tx),
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
const event = new CustomEvent('doc:loaded', {
|
|
129
|
-
detail: {
|
|
130
|
-
editor: this,
|
|
131
|
-
doc,
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
this.dispatchEvent(event);
|
|
135
|
-
}
|
|
136
|
-
dispatchTransaction(transaction) {
|
|
137
|
-
this.state = this.state.apply(transaction);
|
|
138
|
-
if (this.view) {
|
|
139
|
-
this.view.updateState(this.state);
|
|
140
|
-
const event = new CustomEvent('transaction', {
|
|
141
|
-
detail: {
|
|
142
|
-
editor: this,
|
|
143
|
-
transaction,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
this.dispatchEvent(event);
|
|
147
|
-
}
|
|
148
|
-
if (transaction.docChanged) {
|
|
149
|
-
const event = new CustomEvent('changed', {
|
|
150
|
-
detail: {
|
|
151
|
-
editor: this,
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
this.dispatchEvent(event);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
setupPlugins() {
|
|
158
|
-
this.state = this.state.reconfigure({
|
|
159
|
-
plugins: this.extensionManager.plugins,
|
|
160
|
-
});
|
|
161
|
-
if (this.view) {
|
|
162
|
-
this.view.updateState(this.state);
|
|
163
|
-
this.view.setProps({
|
|
164
|
-
nodeViews: this.extensionManager.nodeViews,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
clearDocument() {
|
|
169
|
-
const content = {
|
|
170
|
-
type: this.extensionManager.schema.topNodeType.name,
|
|
171
|
-
content: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC.content,
|
|
172
|
-
};
|
|
173
|
-
this.setDocument(content);
|
|
174
|
-
}
|
|
175
|
-
setDocument(content) {
|
|
176
|
-
let doc = createNodeFromObject(content, this.schema, {
|
|
177
|
-
errorOnInvalidContent: true,
|
|
178
|
-
});
|
|
179
|
-
doc = ensureDocSchema(doc, this.schema);
|
|
180
|
-
this.state = EditorState.create({
|
|
181
|
-
doc,
|
|
182
|
-
plugins: this.state.plugins,
|
|
183
|
-
storedMarks: this.state.storedMarks,
|
|
184
|
-
});
|
|
185
|
-
if (this.view) {
|
|
186
|
-
this.view.updateState(this.state);
|
|
187
|
-
}
|
|
188
|
-
const event = new CustomEvent('doc:loaded', {
|
|
189
|
-
detail: {
|
|
190
|
-
editor: this,
|
|
191
|
-
doc,
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
this.dispatchEvent(event);
|
|
195
|
-
}
|
|
196
|
-
getDocument() {
|
|
197
|
-
return this.state.doc;
|
|
198
|
-
}
|
|
199
|
-
async loadDocument(mediaType, content) {
|
|
200
|
-
const converter = this.extensionManager.converters[mediaType];
|
|
201
|
-
if (!converter) {
|
|
202
|
-
throw new Error('Converter not found for: ' + mediaType);
|
|
203
|
-
}
|
|
204
|
-
const doc = await converter.toDoc(content);
|
|
205
|
-
this.state = EditorState.create({
|
|
206
|
-
doc,
|
|
207
|
-
plugins: this.state.plugins,
|
|
208
|
-
storedMarks: this.state.storedMarks,
|
|
209
|
-
});
|
|
210
|
-
if (this.view) {
|
|
211
|
-
this.view.updateState(this.state);
|
|
212
|
-
}
|
|
213
|
-
const event = new CustomEvent('doc:loaded', {
|
|
214
|
-
detail: {
|
|
215
|
-
editor: this,
|
|
216
|
-
doc,
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
this.dispatchEvent(event);
|
|
220
|
-
}
|
|
221
|
-
async saveDocument(mediaType) {
|
|
222
|
-
const converter = this.extensionManager.converters[mediaType];
|
|
223
|
-
if (!converter) {
|
|
224
|
-
throw new Error('Converter not found for: ' + mediaType);
|
|
225
|
-
}
|
|
226
|
-
const json = this.state.doc.toJSON();
|
|
227
|
-
const clonedDoc = ProseMirrorNode.fromJSON(this.state.schema, json);
|
|
228
|
-
return await converter.fromDoc(clonedDoc);
|
|
229
|
-
}
|
|
230
|
-
getJSON() {
|
|
231
|
-
return this.state.doc.toJSON();
|
|
232
|
-
}
|
|
233
|
-
clone(options = {}) {
|
|
234
|
-
return new CoreEditor({
|
|
235
|
-
...options,
|
|
236
|
-
extensions: [...(this.config.extensions || [])],
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
debug(doc) {
|
|
240
|
-
if (!doc) {
|
|
241
|
-
doc = this.state.doc;
|
|
242
|
-
}
|
|
243
|
-
console.debug(nodeToTreeString(doc));
|
|
244
|
-
}
|
|
245
|
-
destroy() {
|
|
246
|
-
const event = new CustomEvent('beforeDestroy', {
|
|
247
|
-
detail: {},
|
|
248
|
-
});
|
|
249
|
-
this.dispatchEvent(event);
|
|
250
|
-
this.view.destroy();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { EditorState, Plugin, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { Mark, Node } from 'prosemirror-model';
|
|
3
|
-
import { EditorView, MarkView, NodeView } from 'prosemirror-view';
|
|
4
|
-
import { Decoration, DecorationSource } from 'prosemirror-view';
|
|
5
|
-
export declare class DummyEditorView {
|
|
6
|
-
private _props;
|
|
7
|
-
private directPlugins;
|
|
8
|
-
private nodeViews;
|
|
9
|
-
private prevDirectPlugins;
|
|
10
|
-
private pluginViews;
|
|
11
|
-
state: EditorState;
|
|
12
|
-
constructor(props: DirectEditorProps);
|
|
13
|
-
editable: boolean;
|
|
14
|
-
get composing(): boolean;
|
|
15
|
-
get dom(): {
|
|
16
|
-
addEventListener(): void;
|
|
17
|
-
removeEventListener(): void;
|
|
18
|
-
};
|
|
19
|
-
get props(): DirectEditorProps;
|
|
20
|
-
update(props: DirectEditorProps): void;
|
|
21
|
-
setProps(props: Partial<DirectEditorProps>): void;
|
|
22
|
-
updateState(state: EditorState): void;
|
|
23
|
-
private updateStateInner;
|
|
24
|
-
scrollToSelection(): void;
|
|
25
|
-
private destroyPluginViews;
|
|
26
|
-
private updatePluginViews;
|
|
27
|
-
someProp<PropName extends keyof EditorProps, Result>(propName: PropName, f: (value: NonNullable<EditorProps[PropName]>) => Result): Result | undefined;
|
|
28
|
-
someProp<PropName extends keyof EditorProps>(propName: PropName): NonNullable<EditorProps[PropName]> | undefined;
|
|
29
|
-
hasFocus(): boolean;
|
|
30
|
-
focus(): void;
|
|
31
|
-
destroy(): void;
|
|
32
|
-
get isDestroyed(): boolean;
|
|
33
|
-
dispatchEvent(event: Event): void;
|
|
34
|
-
dispatch: (tr: Transaction) => void;
|
|
35
|
-
}
|
|
36
|
-
export type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
|
|
37
|
-
export type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => MarkView;
|
|
38
|
-
export interface DOMEventMap extends HTMLElementEventMap {
|
|
39
|
-
[event: string]: any;
|
|
40
|
-
}
|
|
41
|
-
export interface EditorProps<P = any> {
|
|
42
|
-
nodeViews?: {
|
|
43
|
-
[node: string]: NodeViewConstructor;
|
|
44
|
-
};
|
|
45
|
-
markViews?: {
|
|
46
|
-
[mark: string]: MarkViewConstructor;
|
|
47
|
-
};
|
|
48
|
-
editable?: (this: P, state: EditorState) => boolean;
|
|
49
|
-
attributes?: {
|
|
50
|
-
[name: string]: string;
|
|
51
|
-
} | ((state: EditorState) => {
|
|
52
|
-
[name: string]: string;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
export interface DirectEditorProps extends EditorProps {
|
|
56
|
-
state: EditorState;
|
|
57
|
-
plugins?: readonly Plugin[];
|
|
58
|
-
dispatchTransaction?: (tr: Transaction) => void;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=DummyEditorView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DummyEditorView.d.ts","sourceRoot":"","sources":["../../../src/editor/src/DummyEditorView.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
// Headless View to be used on Server-side
|
|
2
|
-
// TODO: remove all unnecessary props and methods
|
|
3
|
-
/// An editor view manages the DOM structure that represents an
|
|
4
|
-
/// editable document. Its state and behavior are determined by its
|
|
5
|
-
/// [props](#view.DirectEditorProps).
|
|
6
|
-
export class DummyEditorView {
|
|
7
|
-
/// Create a view. `place` may be a DOM node that the editor should
|
|
8
|
-
/// be appended to, a function that will place it into the document,
|
|
9
|
-
/// or an object whose `mount` property holds the node to use as the
|
|
10
|
-
/// document container. If it is `null`, the editor will not be
|
|
11
|
-
/// added to the document.
|
|
12
|
-
constructor(props) {
|
|
13
|
-
/// @internal
|
|
14
|
-
Object.defineProperty(this, "_props", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: void 0
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "directPlugins", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: void 0
|
|
25
|
-
});
|
|
26
|
-
/// @internal
|
|
27
|
-
Object.defineProperty(this, "nodeViews", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: true,
|
|
30
|
-
writable: true,
|
|
31
|
-
value: void 0
|
|
32
|
-
});
|
|
33
|
-
Object.defineProperty(this, "prevDirectPlugins", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
writable: true,
|
|
37
|
-
value: []
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(this, "pluginViews", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true,
|
|
43
|
-
value: []
|
|
44
|
-
});
|
|
45
|
-
/// The view's current [state](#state.EditorState).
|
|
46
|
-
Object.defineProperty(this, "state", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true,
|
|
50
|
-
value: void 0
|
|
51
|
-
});
|
|
52
|
-
/// Indicates whether the editor is currently [editable](#view.EditorProps.editable).
|
|
53
|
-
Object.defineProperty(this, "editable", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: void 0
|
|
58
|
-
});
|
|
59
|
-
this._props = props;
|
|
60
|
-
this.state = props.state;
|
|
61
|
-
this.directPlugins = props.plugins || [];
|
|
62
|
-
this.directPlugins.forEach(checkStateComponent);
|
|
63
|
-
this.dispatch = this.dispatch.bind(this);
|
|
64
|
-
this.editable = getEditable(this);
|
|
65
|
-
this.nodeViews = buildNodeViews(this);
|
|
66
|
-
// TODO initInput(this)
|
|
67
|
-
this.updatePluginViews();
|
|
68
|
-
}
|
|
69
|
-
/// Holds `true` when a
|
|
70
|
-
/// [composition](https://w3c.github.io/uievents/#events-compositionevents)
|
|
71
|
-
/// is active.
|
|
72
|
-
get composing() {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
get dom() {
|
|
76
|
-
return {
|
|
77
|
-
addEventListener() { },
|
|
78
|
-
removeEventListener() { },
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/// The view's current [props](#view.EditorProps).
|
|
82
|
-
get props() {
|
|
83
|
-
if (this._props.state != this.state) {
|
|
84
|
-
let prev = this._props;
|
|
85
|
-
this._props = {};
|
|
86
|
-
for (let name in prev)
|
|
87
|
-
this._props[name] = prev[name];
|
|
88
|
-
this._props.state = this.state;
|
|
89
|
-
}
|
|
90
|
-
return this._props;
|
|
91
|
-
}
|
|
92
|
-
/// Update the view's props. Will immediately cause an update to
|
|
93
|
-
/// the DOM.
|
|
94
|
-
update(props) {
|
|
95
|
-
let prevProps = this._props;
|
|
96
|
-
this._props = props;
|
|
97
|
-
if (props.plugins) {
|
|
98
|
-
props.plugins.forEach(checkStateComponent);
|
|
99
|
-
this.directPlugins = props.plugins;
|
|
100
|
-
}
|
|
101
|
-
this.updateStateInner(props.state, prevProps);
|
|
102
|
-
}
|
|
103
|
-
/// Update the view by updating existing props object with the object
|
|
104
|
-
/// given as argument. Equivalent to `view.update(Object.assign({},
|
|
105
|
-
/// view.props, props))`.
|
|
106
|
-
setProps(props) {
|
|
107
|
-
let updated = {};
|
|
108
|
-
for (let name in this._props) {
|
|
109
|
-
updated[name] = this._props[name];
|
|
110
|
-
}
|
|
111
|
-
updated.state = this.state;
|
|
112
|
-
for (let name in props)
|
|
113
|
-
updated[name] = props[name];
|
|
114
|
-
this.update(updated);
|
|
115
|
-
}
|
|
116
|
-
/// Update the editor's `state` prop, without touching any of the
|
|
117
|
-
/// other props.
|
|
118
|
-
updateState(state) {
|
|
119
|
-
this.updateStateInner(state, this._props);
|
|
120
|
-
}
|
|
121
|
-
updateStateInner(state, prevProps) {
|
|
122
|
-
let prev = this.state, redraw = false, updateSel = false;
|
|
123
|
-
// When stored marks are added, stop composition, so that they can
|
|
124
|
-
// be displayed.
|
|
125
|
-
if (state.storedMarks && this.composing) {
|
|
126
|
-
// TODO clearComposition(this)
|
|
127
|
-
updateSel = true;
|
|
128
|
-
}
|
|
129
|
-
this.state = state;
|
|
130
|
-
let pluginsChanged = prev.plugins != state.plugins ||
|
|
131
|
-
this._props.plugins != prevProps.plugins;
|
|
132
|
-
if (pluginsChanged || this._props.plugins != prevProps.plugins ||
|
|
133
|
-
this._props.nodeViews != prevProps.nodeViews) {
|
|
134
|
-
let nodeViews = buildNodeViews(this);
|
|
135
|
-
if (changedNodeViews(nodeViews, this.nodeViews)) {
|
|
136
|
-
this.nodeViews = nodeViews;
|
|
137
|
-
redraw = true;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
this.editable = getEditable(this);
|
|
141
|
-
let updateDoc = redraw;
|
|
142
|
-
if (updateDoc || !state.selection.eq(prev.selection))
|
|
143
|
-
updateSel = true;
|
|
144
|
-
if (updateSel) {
|
|
145
|
-
// Work around an issue in Chrome, IE, and Edge where changing
|
|
146
|
-
// the DOM around an active selection puts it into a broken
|
|
147
|
-
// state where the thing the user sees differs from the
|
|
148
|
-
// selection reported by the Selection object (#710, #973,
|
|
149
|
-
// #1011, #1013, #1035).
|
|
150
|
-
let forceSelUpdate = false;
|
|
151
|
-
if (updateDoc) {
|
|
152
|
-
// If the node that the selection points into is written to,
|
|
153
|
-
// Chrome sometimes starts misreporting the selection, so this
|
|
154
|
-
// tracks that and forces a selection reset when our update
|
|
155
|
-
// did write to the node.
|
|
156
|
-
// TODO if (this.composing) this.input.compositionNode = findCompositionNode(this)
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
this.updatePluginViews(prev);
|
|
160
|
-
}
|
|
161
|
-
/// @internal
|
|
162
|
-
scrollToSelection() {
|
|
163
|
-
}
|
|
164
|
-
destroyPluginViews() {
|
|
165
|
-
let view;
|
|
166
|
-
while (view = this.pluginViews.pop())
|
|
167
|
-
if (view.destroy)
|
|
168
|
-
view.destroy();
|
|
169
|
-
}
|
|
170
|
-
updatePluginViews(prevState) {
|
|
171
|
-
if (!prevState || prevState.plugins != this.state.plugins ||
|
|
172
|
-
this.directPlugins != this.prevDirectPlugins) {
|
|
173
|
-
this.prevDirectPlugins = this.directPlugins;
|
|
174
|
-
this.destroyPluginViews();
|
|
175
|
-
for (let i = 0; i < this.directPlugins.length; i++) {
|
|
176
|
-
let plugin = this.directPlugins[i];
|
|
177
|
-
if (plugin.spec.view) {
|
|
178
|
-
this.pluginViews.push(plugin.spec.view(this));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
for (let i = 0; i < this.state.plugins.length; i++) {
|
|
182
|
-
let plugin = this.state.plugins[i];
|
|
183
|
-
if (plugin.spec.view) {
|
|
184
|
-
this.pluginViews.push(plugin.spec.view(this));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
for (let i = 0; i < this.pluginViews.length; i++) {
|
|
190
|
-
let pluginView = this.pluginViews[i];
|
|
191
|
-
if (pluginView.update)
|
|
192
|
-
pluginView.update(this, prevState);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
someProp(propName, f) {
|
|
197
|
-
let prop = this._props && this._props[propName], value;
|
|
198
|
-
if (prop != null && (value = f ? f(prop) : prop)) {
|
|
199
|
-
return value;
|
|
200
|
-
}
|
|
201
|
-
for (let i = 0; i < this.directPlugins.length; i++) {
|
|
202
|
-
let prop = this.directPlugins[i].props[propName];
|
|
203
|
-
if (prop != null && (value = f ? f(prop) : prop)) {
|
|
204
|
-
return value;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
let plugins = this.state.plugins;
|
|
208
|
-
if (plugins) {
|
|
209
|
-
for (let i = 0; i < plugins.length; i++) {
|
|
210
|
-
let prop = plugins[i].props[propName];
|
|
211
|
-
if (prop != null && (value = f ? f(prop) : prop))
|
|
212
|
-
return value;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/// Query whether the view has focus.
|
|
217
|
-
hasFocus() {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
/// Focus the editor.
|
|
221
|
-
focus() {
|
|
222
|
-
}
|
|
223
|
-
/// Removes the editor from the DOM and destroys all [node
|
|
224
|
-
/// views](#view.NodeView).
|
|
225
|
-
destroy() {
|
|
226
|
-
this.destroyPluginViews();
|
|
227
|
-
}
|
|
228
|
-
/// This is true when the view has been
|
|
229
|
-
/// [destroyed](#view.DummyEditorView.destroy) (and thus should not be
|
|
230
|
-
/// used anymore).
|
|
231
|
-
get isDestroyed() {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
/// Used for testing.
|
|
235
|
-
dispatchEvent(event) {
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
DummyEditorView.prototype.dispatch = function (tr) {
|
|
239
|
-
let dispatchTransaction = this.props.dispatchTransaction;
|
|
240
|
-
if (dispatchTransaction)
|
|
241
|
-
dispatchTransaction.call(this, tr);
|
|
242
|
-
else
|
|
243
|
-
this.updateState(this.state.apply(tr));
|
|
244
|
-
};
|
|
245
|
-
function getEditable(view) {
|
|
246
|
-
return !view.someProp('editable', (value) => value(view.state) === false);
|
|
247
|
-
}
|
|
248
|
-
function buildNodeViews(view) {
|
|
249
|
-
let result = Object.create(null);
|
|
250
|
-
function add(obj) {
|
|
251
|
-
for (let prop in obj) {
|
|
252
|
-
if (!Object.prototype.hasOwnProperty.call(result, prop)) {
|
|
253
|
-
result[prop] = obj[prop];
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
view.someProp('nodeViews', add);
|
|
258
|
-
view.someProp('markViews', add);
|
|
259
|
-
return result;
|
|
260
|
-
}
|
|
261
|
-
function changedNodeViews(a, b) {
|
|
262
|
-
let nA = 0, nB = 0;
|
|
263
|
-
for (let prop in a) {
|
|
264
|
-
if (a[prop] != b[prop])
|
|
265
|
-
return true;
|
|
266
|
-
nA++;
|
|
267
|
-
}
|
|
268
|
-
for (let _ in b)
|
|
269
|
-
nB++;
|
|
270
|
-
return nA != nB;
|
|
271
|
-
}
|
|
272
|
-
function checkStateComponent(plugin) {
|
|
273
|
-
if (plugin.spec.state || plugin.spec.filterTransaction ||
|
|
274
|
-
plugin.spec.appendTransaction) {
|
|
275
|
-
throw new RangeError('Plugins passed directly to the view must not have a state component');
|
|
276
|
-
}
|
|
277
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'prosemirror-state';
|
|
2
|
-
import type { Node, Schema, SchemaSpec } from 'prosemirror-model';
|
|
3
|
-
import { type CoreEditor } from './CoreEditor.js';
|
|
4
|
-
import type { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
5
|
-
import { CommandFactories, CommandShortcuts } from './commands/mod.js';
|
|
6
|
-
export interface ExtensionConfig {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
requires: Array<Extension | string>;
|
|
9
|
-
}
|
|
10
|
-
export interface Converter {
|
|
11
|
-
fromDoc(document: Node): Promise<Uint8Array>;
|
|
12
|
-
toDoc(content: Uint8Array): Promise<Node>;
|
|
13
|
-
}
|
|
14
|
-
export declare abstract class Extension {
|
|
15
|
-
protected config: Partial<ExtensionConfig>;
|
|
16
|
-
readonly type = "extension";
|
|
17
|
-
abstract name: string;
|
|
18
|
-
protected editor: CoreEditor;
|
|
19
|
-
readonly conflicts?: Array<string>;
|
|
20
|
-
constructor(config?: Partial<ExtensionConfig>);
|
|
21
|
-
setEditor(editor: CoreEditor): void;
|
|
22
|
-
getEditor(): CoreEditor;
|
|
23
|
-
created(): void;
|
|
24
|
-
getInputRules(): InputRule[];
|
|
25
|
-
getProseMirrorPlugins(): Plugin[];
|
|
26
|
-
getCommandFactories(editor: CoreEditor): Partial<CommandFactories>;
|
|
27
|
-
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
28
|
-
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
29
|
-
setupSpec(spec: SchemaSpec): void;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=Extension.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,eAAe;IAE9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAEnB,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7C,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,8BAAsB,SAAS;IAOV,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC;IAN7D,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,MAAM,EAAG,UAAU,CAAC;IAE9B,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEN,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM;IAGlE,SAAS,CAAC,MAAM,EAAE,UAAU;IAI5B,SAAS;IAIT,OAAO;IAGP,aAAa,IAAI,SAAS,EAAE;IAI5B,qBAAqB,IAAI,MAAM,EAAE;IAIjC,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIlE,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAInE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAI5E,SAAS,CAAC,IAAI,EAAE,UAAU;CAE3B"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export class Extension {
|
|
2
|
-
constructor(config = {}) {
|
|
3
|
-
Object.defineProperty(this, "config", {
|
|
4
|
-
enumerable: true,
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
value: config
|
|
8
|
-
});
|
|
9
|
-
Object.defineProperty(this, "type", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true,
|
|
13
|
-
value: 'extension'
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(this, "editor", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: void 0
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(this, "conflicts", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true,
|
|
25
|
-
value: void 0
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
setEditor(editor) {
|
|
29
|
-
this.editor = editor;
|
|
30
|
-
}
|
|
31
|
-
getEditor() {
|
|
32
|
-
return this.editor;
|
|
33
|
-
}
|
|
34
|
-
created() {
|
|
35
|
-
}
|
|
36
|
-
getInputRules() {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
getProseMirrorPlugins() {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
getCommandFactories(editor) {
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
45
|
-
getKeyboardShortcuts(editor) {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
getConverters(editor, schema) {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
setupSpec(spec) {
|
|
52
|
-
}
|
|
53
|
-
}
|