@kerebron/extension-codemirror 0.3.1 → 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/README.md +3 -3
- 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 +13 -4
- package/esm/editor/src/CoreEditor.d.ts.map +1 -1
- package/esm/editor/src/CoreEditor.js +64 -12
- package/esm/editor/src/Extension.d.ts +6 -1
- package/esm/editor/src/Extension.d.ts.map +1 -1
- package/esm/editor/src/Extension.js +21 -1
- package/esm/editor/src/ExtensionManager.d.ts +5 -6
- package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
- package/esm/editor/src/ExtensionManager.js +43 -55
- package/esm/editor/src/Mark.d.ts +3 -0
- package/esm/editor/src/Mark.d.ts.map +1 -1
- package/esm/editor/src/Mark.js +11 -0
- package/esm/editor/src/Node.d.ts +5 -2
- package/esm/editor/src/Node.d.ts.map +1 -1
- package/esm/editor/src/Node.js +13 -2
- package/esm/editor/src/commands/CommandManager.d.ts +13 -6
- package/esm/editor/src/commands/CommandManager.d.ts.map +1 -1
- package/esm/editor/src/commands/CommandManager.js +59 -2
- 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/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 +5 -53
- package/esm/editor/src/commands/mod.d.ts.map +1 -1
- package/esm/editor/src/commands/mod.js +14 -821
- 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 +2 -0
- package/esm/editor/src/mod.d.ts.map +1 -1
- package/esm/editor/src/mod.js +2 -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/types.d.ts +20 -2
- package/esm/editor/src/types.d.ts.map +1 -1
- 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 +9 -7
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -1
- package/esm/editor/src/utilities/SmartOutput.js +35 -20
- 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 +2 -0
- package/esm/editor/src/utilities/mod.d.ts.map +1 -1
- package/esm/editor/src/utilities/mod.js +2 -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-basic-editor/src/NodeCodeBlock.d.ts +9 -0
- package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeCodeBlock.js +58 -0
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +24 -0
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +35 -0
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +25 -0
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +96 -0
- package/esm/extension-codemirror/src/ExtensionCodeMirror.d.ts +15 -2
- package/esm/extension-codemirror/src/ExtensionCodeMirror.d.ts.map +1 -1
- package/esm/extension-codemirror/src/ExtensionCodeMirror.js +74 -2
- package/esm/extension-codemirror/src/NodeCodeMirror.d.ts +13 -9
- package/esm/extension-codemirror/src/NodeCodeMirror.d.ts.map +1 -1
- package/esm/extension-codemirror/src/NodeCodeMirror.js +34 -121
- package/esm/extension-codemirror/src/codeMirrorBlockNodeView.d.ts +3 -2
- package/esm/extension-codemirror/src/codeMirrorBlockNodeView.d.ts.map +1 -1
- package/esm/extension-codemirror/src/codeMirrorBlockNodeView.js +164 -103
- package/esm/extension-codemirror/src/defaults.d.ts +1 -1
- package/esm/extension-codemirror/src/defaults.d.ts.map +1 -1
- package/esm/extension-codemirror/src/defaults.js +4 -3
- package/esm/extension-codemirror/src/languageLoaders.d.ts.map +1 -1
- package/esm/extension-codemirror/src/languageLoaders.js +1 -2
- package/esm/extension-codemirror/src/lsp/LSPExtension.d.ts +14 -0
- package/esm/extension-codemirror/src/lsp/LSPExtension.d.ts.map +1 -0
- package/esm/extension-codemirror/src/lsp/LSPExtension.js +38 -0
- package/esm/extension-codemirror/src/lsp/completion.d.ts +8 -0
- package/esm/extension-codemirror/src/lsp/completion.d.ts.map +1 -0
- package/esm/extension-codemirror/src/lsp/completion.js +179 -0
- package/esm/extension-codemirror/src/lsp/hover.d.ts +5 -0
- package/esm/extension-codemirror/src/lsp/hover.d.ts.map +1 -0
- package/esm/extension-codemirror/src/lsp/hover.js +81 -0
- package/esm/extension-codemirror/src/lsp/index.d.ts +7 -0
- package/esm/extension-codemirror/src/lsp/index.d.ts.map +1 -0
- package/esm/extension-codemirror/src/lsp/index.js +49 -0
- package/esm/extension-codemirror/src/lsp/plugin.d.ts +37 -0
- package/esm/extension-codemirror/src/lsp/plugin.d.ts.map +1 -0
- package/esm/extension-codemirror/src/lsp/plugin.js +125 -0
- package/esm/extension-codemirror/src/lsp/pos.d.ts +5 -0
- package/esm/extension-codemirror/src/lsp/pos.d.ts.map +1 -0
- package/esm/extension-codemirror/src/lsp/pos.js +8 -0
- package/esm/extension-codemirror/src/lsp/text.d.ts +2 -0
- package/esm/extension-codemirror/src/lsp/text.d.ts.map +1 -0
- package/esm/extension-codemirror/src/lsp/text.js +47 -0
- package/esm/extension-codemirror/src/lsp/theme.d.ts +2 -0
- package/esm/extension-codemirror/src/lsp/theme.d.ts.map +1 -0
- package/esm/extension-codemirror/src/lsp/theme.js +76 -0
- package/esm/extension-codemirror/src/{y-remote-selections.d.ts → remote-selections.d.ts} +5 -5
- package/esm/extension-codemirror/src/remote-selections.d.ts.map +1 -0
- package/esm/extension-codemirror/src/{y-remote-selections.js → remote-selections.js} +49 -69
- package/esm/extension-codemirror/src/remote-sync.d.ts +11 -0
- package/esm/extension-codemirror/src/remote-sync.d.ts.map +1 -0
- package/esm/extension-codemirror/src/{y-sync.js → remote-sync.js} +6 -6
- package/esm/extension-codemirror/src/types.d.ts +10 -10
- package/esm/extension-codemirror/src/types.d.ts.map +1 -1
- package/esm/extension-codemirror/src/utils.d.ts +7 -6
- package/esm/extension-codemirror/src/utils.d.ts.map +1 -1
- package/esm/extension-codemirror/src/utils.js +21 -10
- 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/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 +4 -0
- package/esm/extension-lsp/src/mod.d.ts.map +1 -0
- package/esm/extension-lsp/src/mod.js +3 -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/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 +6 -26
- package/esm/extension-codemirror/src/NodeDocumentCode.d.ts +0 -7
- package/esm/extension-codemirror/src/NodeDocumentCode.d.ts.map +0 -1
- package/esm/extension-codemirror/src/NodeDocumentCode.js +0 -37
- package/esm/extension-codemirror/src/y-remote-selections.d.ts.map +0 -1
- package/esm/extension-codemirror/src/y-sync.d.ts +0 -11
- package/esm/extension-codemirror/src/y-sync.d.ts.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Node, Schema } from 'prosemirror-model';
|
|
2
|
+
import { Slice } from 'prosemirror-model';
|
|
3
|
+
import { type Converter, type CoreEditor, Extension } from '../../editor/src/mod.js';
|
|
4
|
+
import { MarkdownResult } from './pmToMdConverter.js';
|
|
5
|
+
import type { Token } from './types.js';
|
|
6
|
+
export interface MdConfig {
|
|
7
|
+
sourceMap?: boolean;
|
|
8
|
+
dispatchSourceMap?: boolean;
|
|
9
|
+
debugTokens?: boolean;
|
|
10
|
+
serializerDebug?: (...args: any[]) => void;
|
|
11
|
+
cdnUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
export type { Token };
|
|
14
|
+
export declare class ExtensionMarkdown extends Extension {
|
|
15
|
+
protected config: Partial<MdConfig>;
|
|
16
|
+
name: string;
|
|
17
|
+
constructor(config?: Partial<MdConfig>);
|
|
18
|
+
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
19
|
+
toMarkdown(source: Node): MarkdownResult;
|
|
20
|
+
fromMarkdown(source: string): Promise<Slice>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ExtensionMarkdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionMarkdown.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/ExtensionMarkdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAErF,OAAO,EACL,cAAc,EAGf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,QAAQ;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,YAAY,EAAE,KAAK,EAAE,CAAC;AAEtB,qBAAa,iBAAkB,SAAQ,SAAS;cAGR,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC;IAF/D,IAAI,SAAc;gBAEoB,MAAM,GAAE,OAAO,CAAC,QAAQ,CAAM;IAI3D,aAAa,CACpB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAmB5B,UAAU,CAAC,MAAM,EAAE,IAAI,GAAG,cAAc;IAWlC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;CAiBnD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Slice } from 'prosemirror-model';
|
|
2
|
+
import { Extension } from '../../editor/src/mod.js';
|
|
3
|
+
import { pmToMdConverter, syncPmToMdConverter, } from './pmToMdConverter.js';
|
|
4
|
+
import { mdToPmConverter, mdToPmConverterText } from './mdToPmConverter.js';
|
|
5
|
+
export class ExtensionMarkdown extends Extension {
|
|
6
|
+
constructor(config = {}) {
|
|
7
|
+
super(config);
|
|
8
|
+
Object.defineProperty(this, "config", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: config
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "name", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: 'markdown'
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
getConverters(editor, schema) {
|
|
22
|
+
return {
|
|
23
|
+
'text/x-markdown': {
|
|
24
|
+
fromDoc: (source) => pmToMdConverter(source, { cdnUrl: this.editor.config.cdnUrl, ...this.config }, schema, editor),
|
|
25
|
+
toDoc: (source) => mdToPmConverter(source, {
|
|
26
|
+
cdnUrl: this.editor.config.cdnUrl,
|
|
27
|
+
...this.config,
|
|
28
|
+
}, schema),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
toMarkdown(source) {
|
|
33
|
+
return syncPmToMdConverter(source, {
|
|
34
|
+
sourceMap: true,
|
|
35
|
+
}, this.editor.schema, this.editor);
|
|
36
|
+
}
|
|
37
|
+
async fromMarkdown(source) {
|
|
38
|
+
const doc = await mdToPmConverterText(source, { cdnUrl: this.editor.config.cdnUrl, ...this.config }, this.editor.schema);
|
|
39
|
+
const fragment = doc.content;
|
|
40
|
+
if (fragment.content.length === 1) {
|
|
41
|
+
const first = fragment.content[0];
|
|
42
|
+
if (first.type.name === 'paragraph') {
|
|
43
|
+
return new Slice(first.content, 0, 0);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return new Slice(fragment, 0, 0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Token } from './types.js';
|
|
2
|
+
import { Attrs, Mark, MarkType, Node, NodeType, Schema } from 'prosemirror-model';
|
|
3
|
+
export declare class MarkdownParseState {
|
|
4
|
+
readonly schema: Schema;
|
|
5
|
+
readonly tokenHandlers: {
|
|
6
|
+
[token: string]: (stat: MarkdownParseState, token: Token, tokens: Token[], i: number) => void;
|
|
7
|
+
};
|
|
8
|
+
stack: {
|
|
9
|
+
type: NodeType;
|
|
10
|
+
attrs: Attrs | null;
|
|
11
|
+
content: Node[];
|
|
12
|
+
marks: readonly Mark[];
|
|
13
|
+
}[];
|
|
14
|
+
constructor(schema: Schema, tokenHandlers: {
|
|
15
|
+
[token: string]: (stat: MarkdownParseState, token: Token, tokens: Token[], i: number) => void;
|
|
16
|
+
});
|
|
17
|
+
top(): {
|
|
18
|
+
type: NodeType;
|
|
19
|
+
attrs: Attrs | null;
|
|
20
|
+
content: Node[];
|
|
21
|
+
marks: readonly Mark[];
|
|
22
|
+
};
|
|
23
|
+
push(elt: Node): void;
|
|
24
|
+
addText(text: string): void;
|
|
25
|
+
openMark(mark: Mark): void;
|
|
26
|
+
closeMark(mark: MarkType): void;
|
|
27
|
+
parseTokens(toks: Token[]): void;
|
|
28
|
+
addNode(type: NodeType, attrs: Attrs | null, content?: readonly Node[]): Node | null;
|
|
29
|
+
openNode(type: NodeType, attrs: Attrs | null): void;
|
|
30
|
+
closeNode(): Node | null;
|
|
31
|
+
importNodes(nodes: readonly Node[]): void;
|
|
32
|
+
}
|
|
33
|
+
export interface ParseSpec {
|
|
34
|
+
node?: string;
|
|
35
|
+
block?: string;
|
|
36
|
+
mark?: string;
|
|
37
|
+
custom?: (stat: MarkdownParseState, token: Token, tokens: Token[], i: number) => void;
|
|
38
|
+
attrs?: Attrs | null;
|
|
39
|
+
getAttrs?: (token: Token, tokenStream: Token[], index: number) => Attrs | null;
|
|
40
|
+
noCloseToken?: boolean;
|
|
41
|
+
ignore?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface MarkdownTokenizer {
|
|
44
|
+
parse(markdown: string, markdownEnv?: Record<string, any>): Array<Token>;
|
|
45
|
+
}
|
|
46
|
+
export declare class MarkdownParser {
|
|
47
|
+
readonly schema: Schema;
|
|
48
|
+
readonly tokenizer: MarkdownTokenizer;
|
|
49
|
+
readonly tokens: {
|
|
50
|
+
[name: string]: ParseSpec;
|
|
51
|
+
};
|
|
52
|
+
tokenHandlers: {
|
|
53
|
+
[token: string]: (stat: MarkdownParseState, token: Token, tokens: Token[], i: number) => void;
|
|
54
|
+
};
|
|
55
|
+
constructor(schema: Schema, tokenizer: MarkdownTokenizer, tokens: {
|
|
56
|
+
[name: string]: ParseSpec;
|
|
57
|
+
});
|
|
58
|
+
parse(text: string, markdownEnv?: Record<string, any>): Node;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=MarkdownParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownParser.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/MarkdownParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,E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CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;IAYhD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;CAc1D"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Mark, } from 'prosemirror-model';
|
|
2
|
+
const __dirname = globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).dirname;
|
|
3
|
+
function maybeMerge(a, b) {
|
|
4
|
+
if (a.isText && b.isText && Mark.sameSet(a.marks, b.marks)) {
|
|
5
|
+
return a.withText(a.text + b.text);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
// Object used to track the context of a running parse.
|
|
9
|
+
export class MarkdownParseState {
|
|
10
|
+
constructor(schema, tokenHandlers) {
|
|
11
|
+
Object.defineProperty(this, "schema", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: schema
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "tokenHandlers", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: tokenHandlers
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "stack", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
this.stack = [{
|
|
30
|
+
type: schema.topNodeType,
|
|
31
|
+
attrs: null,
|
|
32
|
+
content: [],
|
|
33
|
+
marks: Mark.none,
|
|
34
|
+
}];
|
|
35
|
+
}
|
|
36
|
+
top() {
|
|
37
|
+
return this.stack[this.stack.length - 1];
|
|
38
|
+
}
|
|
39
|
+
push(elt) {
|
|
40
|
+
if (this.stack.length)
|
|
41
|
+
this.top().content.push(elt);
|
|
42
|
+
}
|
|
43
|
+
// Adds the given text to the current position in the document,
|
|
44
|
+
// using the current marks as styling.
|
|
45
|
+
addText(text) {
|
|
46
|
+
if (!text)
|
|
47
|
+
return;
|
|
48
|
+
let top = this.top(), nodes = top.content, last = nodes[nodes.length - 1];
|
|
49
|
+
let node = this.schema.text(text, top.marks), merged;
|
|
50
|
+
if (last && (merged = maybeMerge(last, node))) {
|
|
51
|
+
nodes[nodes.length - 1] = merged;
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
nodes.push(node);
|
|
55
|
+
}
|
|
56
|
+
// Adds the given mark to the set of active marks.
|
|
57
|
+
openMark(mark) {
|
|
58
|
+
let top = this.top();
|
|
59
|
+
top.marks = mark.addToSet(top.marks);
|
|
60
|
+
}
|
|
61
|
+
// Removes the given mark from the set of active marks.
|
|
62
|
+
closeMark(mark) {
|
|
63
|
+
let top = this.top();
|
|
64
|
+
top.marks = mark.removeFromSet(top.marks);
|
|
65
|
+
}
|
|
66
|
+
parseTokens(toks) {
|
|
67
|
+
for (let i = 0; i < toks.length; i++) {
|
|
68
|
+
let tok = toks[i];
|
|
69
|
+
let handler = this.tokenHandlers[tok.type];
|
|
70
|
+
if (!handler) {
|
|
71
|
+
console.log(Object.keys(this.tokenHandlers));
|
|
72
|
+
throw new Error('Token type `' + tok.type + '` not supported by Markdown parser');
|
|
73
|
+
}
|
|
74
|
+
handler(this, tok, toks, i);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Add a node at the current position.
|
|
78
|
+
addNode(type, attrs, content) {
|
|
79
|
+
let top = this.top();
|
|
80
|
+
let node = type.createAndFill(attrs, content, top ? top.marks : []);
|
|
81
|
+
if (!node)
|
|
82
|
+
return null;
|
|
83
|
+
this.push(node);
|
|
84
|
+
return node;
|
|
85
|
+
}
|
|
86
|
+
// Wrap subsequent content in a node of the given type.
|
|
87
|
+
openNode(type, attrs) {
|
|
88
|
+
this.stack.push({
|
|
89
|
+
type: type,
|
|
90
|
+
attrs: attrs,
|
|
91
|
+
content: [],
|
|
92
|
+
marks: Mark.none,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// Close and return the node that is currently on top of the stack.
|
|
96
|
+
closeNode() {
|
|
97
|
+
let info = this.stack.pop();
|
|
98
|
+
return this.addNode(info.type, info.attrs, info.content);
|
|
99
|
+
}
|
|
100
|
+
importNodes(nodes) {
|
|
101
|
+
for (const node of nodes) {
|
|
102
|
+
this.push(node);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function attrs(spec, token, tokens, i) {
|
|
107
|
+
if (spec.getAttrs)
|
|
108
|
+
return spec.getAttrs(token, tokens, i);
|
|
109
|
+
// For backwards compatibility when `attrs` is a Function
|
|
110
|
+
else if (spec.attrs instanceof Function)
|
|
111
|
+
return spec.attrs(token);
|
|
112
|
+
else
|
|
113
|
+
return spec.attrs;
|
|
114
|
+
}
|
|
115
|
+
// Code content is represented as a single token with a `content`
|
|
116
|
+
// property in Markdown-it.
|
|
117
|
+
function noCloseToken(spec, type) {
|
|
118
|
+
return spec.noCloseToken || type == 'code_block' ||
|
|
119
|
+
type == 'fence';
|
|
120
|
+
}
|
|
121
|
+
function withoutTrailingNewline(str) {
|
|
122
|
+
return str[str.length - 1] == '\n' ? str.slice(0, str.length - 1) : str;
|
|
123
|
+
}
|
|
124
|
+
function noOp() { }
|
|
125
|
+
function tokenHandlers(schema, tokens) {
|
|
126
|
+
let handlers = Object.create(null);
|
|
127
|
+
for (let type in tokens) {
|
|
128
|
+
let spec = tokens[type];
|
|
129
|
+
if (spec.block) {
|
|
130
|
+
let nodeType = schema.nodes[spec.block];
|
|
131
|
+
if (noCloseToken(spec, type)) {
|
|
132
|
+
handlers[type] = (state, tok, tokens, i) => {
|
|
133
|
+
state.openNode(nodeType, attrs(spec, tok, tokens, i));
|
|
134
|
+
state.addText(withoutTrailingNewline(tok.content));
|
|
135
|
+
state.closeNode();
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
handlers[type + '_open'] = (state, tok, tokens, i) => state.openNode(nodeType, attrs(spec, tok, tokens, i));
|
|
140
|
+
handlers[type + '_close'] = (state) => state.closeNode();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else if (spec.node) {
|
|
144
|
+
let nodeType = schema.nodes[spec.node];
|
|
145
|
+
handlers[type] = (state, tok, tokens, i) => state.addNode(nodeType, attrs(spec, tok, tokens, i));
|
|
146
|
+
}
|
|
147
|
+
else if (spec.mark) {
|
|
148
|
+
let markType = schema.marks[spec.mark];
|
|
149
|
+
if (noCloseToken(spec, type)) {
|
|
150
|
+
handlers[type] = (state, tok, tokens, i) => {
|
|
151
|
+
state.openMark(markType.create(attrs(spec, tok, tokens, i)));
|
|
152
|
+
state.addText(withoutTrailingNewline(tok.content));
|
|
153
|
+
state.closeMark(markType);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
handlers[type + '_open'] = (state, tok, tokens, i) => state.openMark(markType.create(attrs(spec, tok, tokens, i)));
|
|
158
|
+
handlers[type + '_close'] = (state) => state.closeMark(markType);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (spec.custom) {
|
|
162
|
+
const custom = spec.custom;
|
|
163
|
+
handlers[type] = (state, tok, tokens, i) => {
|
|
164
|
+
custom(state, tok, tokens, i);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
else if (spec.ignore) {
|
|
168
|
+
if (noCloseToken(spec, type)) {
|
|
169
|
+
handlers[type] = noOp;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
handlers[type + '_open'] = noOp;
|
|
173
|
+
handlers[type + '_close'] = noOp;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
throw new RangeError('Unrecognized parsing spec ' + JSON.stringify(spec));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
handlers.text = (state, tok) => state.addText(tok.content);
|
|
181
|
+
handlers.inline = (state, tok) => state.parseTokens(tok.children);
|
|
182
|
+
handlers.softbreak = handlers.softbreak || ((state) => state.addText(' '));
|
|
183
|
+
return handlers;
|
|
184
|
+
}
|
|
185
|
+
/// A configuration of a Markdown parser. Such a parser uses
|
|
186
|
+
/// [markdown-it](https://github.com/markdown-it/markdown-it) to
|
|
187
|
+
/// tokenize a file, and then runs the custom rules it is given over
|
|
188
|
+
/// the tokens to create a ProseMirror document tree.
|
|
189
|
+
export class MarkdownParser {
|
|
190
|
+
/// Create a parser with the given configuration. You can configure
|
|
191
|
+
/// the markdown-it parser to parse the dialect you want, and provide
|
|
192
|
+
/// a description of the ProseMirror entities those tokens map to in
|
|
193
|
+
/// the `tokens` object, which maps token names to descriptions of
|
|
194
|
+
/// what to do with them. Such a description is an object, and may
|
|
195
|
+
/// have the following properties:
|
|
196
|
+
constructor(
|
|
197
|
+
/// The parser's document schema.
|
|
198
|
+
schema,
|
|
199
|
+
/// This parser's markdown-it tokenizer.
|
|
200
|
+
tokenizer,
|
|
201
|
+
/// The value of the `tokens` object used to construct this
|
|
202
|
+
/// parser. Can be useful to copy and modify to base other parsers
|
|
203
|
+
/// on.
|
|
204
|
+
tokens) {
|
|
205
|
+
Object.defineProperty(this, "schema", {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
configurable: true,
|
|
208
|
+
writable: true,
|
|
209
|
+
value: schema
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(this, "tokenizer", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
configurable: true,
|
|
214
|
+
writable: true,
|
|
215
|
+
value: tokenizer
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(this, "tokens", {
|
|
218
|
+
enumerable: true,
|
|
219
|
+
configurable: true,
|
|
220
|
+
writable: true,
|
|
221
|
+
value: tokens
|
|
222
|
+
});
|
|
223
|
+
/// @internal
|
|
224
|
+
Object.defineProperty(this, "tokenHandlers", {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
configurable: true,
|
|
227
|
+
writable: true,
|
|
228
|
+
value: void 0
|
|
229
|
+
});
|
|
230
|
+
this.tokenHandlers = tokenHandlers(schema, tokens);
|
|
231
|
+
}
|
|
232
|
+
/// Parse a string as [CommonMark](http://commonmark.org/) markup,
|
|
233
|
+
/// and create a ProseMirror document as prescribed by this parser's
|
|
234
|
+
/// rules.
|
|
235
|
+
///
|
|
236
|
+
/// The second argument, when given, is passed through to the
|
|
237
|
+
/// [Markdown
|
|
238
|
+
/// parser](https://markdown-it.github.io/markdown-it/#MarkdownIt.parse).
|
|
239
|
+
parse(text, markdownEnv = {}) {
|
|
240
|
+
const state = new MarkdownParseState(this.schema, this.tokenHandlers);
|
|
241
|
+
const tokens = this.tokenizer.parse(text, markdownEnv);
|
|
242
|
+
state.parseTokens(tokens);
|
|
243
|
+
let doc;
|
|
244
|
+
do {
|
|
245
|
+
doc = state.closeNode();
|
|
246
|
+
} while (state.stack.length);
|
|
247
|
+
return doc || this.schema.topNodeType.createAndFill();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Token } from './types.js';
|
|
2
|
+
import { TokenSource } from './TokenSource.js';
|
|
3
|
+
import { SmartOutput } from '../../editor/src/utilities/mod.js';
|
|
4
|
+
export declare function writeIndented(output: SmartOutput<Token>, text: string, currentCtx: SerializerContext, token?: Token): void;
|
|
5
|
+
type ListType = 'ul' | 'ol' | 'dl' | 'tl';
|
|
6
|
+
export interface SerializerContext {
|
|
7
|
+
meta: Record<string, any>;
|
|
8
|
+
metaObj: Record<string, any>;
|
|
9
|
+
blockquoteCnt: number;
|
|
10
|
+
footnoteCnt: number;
|
|
11
|
+
listPath: Array<ListType>;
|
|
12
|
+
listType?: ListType;
|
|
13
|
+
itemRow: number;
|
|
14
|
+
itemNumber: number;
|
|
15
|
+
itemSymbol: string;
|
|
16
|
+
handlers: Record<string, Array<TokenHandler>>;
|
|
17
|
+
log: (txt: string, token?: Token) => void;
|
|
18
|
+
debug: (...args: any[]) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare class ContextStash {
|
|
21
|
+
private ctxStash;
|
|
22
|
+
private currentCtx;
|
|
23
|
+
readonly output: SmartOutput<Token>;
|
|
24
|
+
constructor(handlers: Record<string, Array<TokenHandler>>);
|
|
25
|
+
stash(reason: string): number;
|
|
26
|
+
unstash(reason: string): void;
|
|
27
|
+
rollback(rollbackPos: number, reason: string): void;
|
|
28
|
+
get current(): SerializerContext;
|
|
29
|
+
}
|
|
30
|
+
export declare function serializeInlineTokens(ctx: ContextStash, tokenSource: TokenSource<Token>, tokens: Token[]): void;
|
|
31
|
+
export type TokenHandler = (token: Token, ctx: ContextStash, tokenSource: TokenSource<Token>) => boolean | void;
|
|
32
|
+
export interface MarkdownSerializerConfig {
|
|
33
|
+
debug?: (...args: any[]) => void;
|
|
34
|
+
}
|
|
35
|
+
export declare class MarkdownSerializer {
|
|
36
|
+
private ctx;
|
|
37
|
+
constructor(config?: MarkdownSerializerConfig);
|
|
38
|
+
private get endsWithEmptyLine();
|
|
39
|
+
serialize(tokens: Token[]): SmartOutput<Token>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=MarkdownSerializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownSerializer.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/MarkdownSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAOzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,EAC1B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,iBAAiB,EAC7B,KAAK,CAAC,EAAE,KAAK,QAmGd;AAED,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC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