@kerebron/extension-menu 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.
Files changed (235) hide show
  1. package/README.md +1 -106
  2. package/assets/custom-menu.css +6 -26
  3. package/assets/menu.css +2 -2
  4. package/esm/{extension-menu/src/CustomMenuPlugin.d.ts → CustomMenuPlugin.d.ts} +4 -8
  5. package/esm/CustomMenuPlugin.d.ts.map +1 -0
  6. package/esm/{extension-menu/src/CustomMenuPlugin.js → CustomMenuPlugin.js} +10 -111
  7. package/esm/ExtensionCustomMenu.d.ts +11 -0
  8. package/esm/ExtensionCustomMenu.d.ts.map +1 -0
  9. package/esm/ExtensionCustomMenu.js +23 -0
  10. package/esm/{extension-menu/src/buildMenu.d.ts → buildMenu.d.ts} +1 -1
  11. package/esm/buildMenu.d.ts.map +1 -0
  12. package/esm/icons.d.ts.map +1 -0
  13. package/esm/{extension-menu/src/menu.d.ts → menu.d.ts} +1 -1
  14. package/esm/menu.d.ts.map +1 -0
  15. package/esm/{extension-menu/src/mod.d.ts → mod.d.ts} +0 -1
  16. package/esm/mod.d.ts.map +1 -0
  17. package/esm/{extension-menu/src/mod.js → mod.js} +0 -1
  18. package/esm/prompt.d.ts.map +1 -0
  19. package/package.json +6 -8
  20. package/esm/_dnt.polyfills.d.ts +0 -101
  21. package/esm/_dnt.polyfills.d.ts.map +0 -1
  22. package/esm/_dnt.polyfills.js +0 -127
  23. package/esm/editor/src/CoreEditor.d.ts +0 -40
  24. package/esm/editor/src/CoreEditor.d.ts.map +0 -1
  25. package/esm/editor/src/CoreEditor.js +0 -252
  26. package/esm/editor/src/DummyEditorView.d.ts +0 -60
  27. package/esm/editor/src/DummyEditorView.d.ts.map +0 -1
  28. package/esm/editor/src/DummyEditorView.js +0 -277
  29. package/esm/editor/src/Extension.d.ts +0 -31
  30. package/esm/editor/src/Extension.d.ts.map +0 -1
  31. package/esm/editor/src/Extension.js +0 -53
  32. package/esm/editor/src/ExtensionManager.d.ts +0 -32
  33. package/esm/editor/src/ExtensionManager.d.ts.map +0 -1
  34. package/esm/editor/src/ExtensionManager.js +0 -260
  35. package/esm/editor/src/Mark.d.ts +0 -23
  36. package/esm/editor/src/Mark.d.ts.map +0 -1
  37. package/esm/editor/src/Mark.js +0 -51
  38. package/esm/editor/src/Node.d.ts +0 -32
  39. package/esm/editor/src/Node.d.ts.map +0 -1
  40. package/esm/editor/src/Node.js +0 -60
  41. package/esm/editor/src/commands/CommandManager.d.ts +0 -23
  42. package/esm/editor/src/commands/CommandManager.d.ts.map +0 -1
  43. package/esm/editor/src/commands/CommandManager.js +0 -118
  44. package/esm/editor/src/commands/baseCommandFactories.d.ts +0 -3
  45. package/esm/editor/src/commands/baseCommandFactories.d.ts.map +0 -1
  46. package/esm/editor/src/commands/baseCommandFactories.js +0 -836
  47. package/esm/editor/src/commands/createChainableState.d.ts +0 -3
  48. package/esm/editor/src/commands/createChainableState.d.ts.map +0 -1
  49. package/esm/editor/src/commands/createChainableState.js +0 -29
  50. package/esm/editor/src/commands/keyCommandFactories.d.ts +0 -3
  51. package/esm/editor/src/commands/keyCommandFactories.d.ts.map +0 -1
  52. package/esm/editor/src/commands/keyCommandFactories.js +0 -10
  53. package/esm/editor/src/commands/mod.d.ts +0 -7
  54. package/esm/editor/src/commands/mod.d.ts.map +0 -1
  55. package/esm/editor/src/commands/mod.js +0 -76
  56. package/esm/editor/src/commands/replaceCommandFactories.d.ts +0 -3
  57. package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +0 -1
  58. package/esm/editor/src/commands/replaceCommandFactories.js +0 -94
  59. package/esm/editor/src/commands/types.d.ts +0 -18
  60. package/esm/editor/src/commands/types.d.ts.map +0 -1
  61. package/esm/editor/src/commands/types.js +0 -1
  62. package/esm/editor/src/mod.d.ts +0 -9
  63. package/esm/editor/src/mod.d.ts.map +0 -1
  64. package/esm/editor/src/mod.js +0 -8
  65. package/esm/editor/src/nodeToTreeString.d.ts +0 -10
  66. package/esm/editor/src/nodeToTreeString.d.ts.map +0 -1
  67. package/esm/editor/src/nodeToTreeString.js +0 -74
  68. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +0 -6
  69. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +0 -1
  70. package/esm/editor/src/plugins/TrackSelecionPlugin.js +0 -24
  71. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts +0 -23
  72. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts.map +0 -1
  73. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +0 -163
  74. package/esm/editor/src/plugins/keymap/keymap.d.ts +0 -11
  75. package/esm/editor/src/plugins/keymap/keymap.d.ts.map +0 -1
  76. package/esm/editor/src/plugins/keymap/keymap.js +0 -125
  77. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +0 -4
  78. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +0 -1
  79. package/esm/editor/src/plugins/keymap/w3c-keyname.js +0 -124
  80. package/esm/editor/src/types.d.ts +0 -52
  81. package/esm/editor/src/types.d.ts.map +0 -1
  82. package/esm/editor/src/types.js +0 -1
  83. package/esm/editor/src/ui.d.ts +0 -15
  84. package/esm/editor/src/ui.d.ts.map +0 -1
  85. package/esm/editor/src/ui.js +0 -16
  86. package/esm/editor/src/utilities/SmartOutput.d.ts +0 -41
  87. package/esm/editor/src/utilities/SmartOutput.d.ts.map +0 -1
  88. package/esm/editor/src/utilities/SmartOutput.js +0 -228
  89. package/esm/editor/src/utilities/createNodeFromContent.d.ts +0 -9
  90. package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +0 -1
  91. package/esm/editor/src/utilities/createNodeFromContent.js +0 -32
  92. package/esm/editor/src/utilities/getHtmlAttributes.d.ts +0 -9
  93. package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +0 -1
  94. package/esm/editor/src/utilities/getHtmlAttributes.js +0 -47
  95. package/esm/editor/src/utilities/getShadowRoot.d.ts +0 -2
  96. package/esm/editor/src/utilities/getShadowRoot.d.ts.map +0 -1
  97. package/esm/editor/src/utilities/getShadowRoot.js +0 -16
  98. package/esm/editor/src/utilities/mod.d.ts +0 -6
  99. package/esm/editor/src/utilities/mod.d.ts.map +0 -1
  100. package/esm/editor/src/utilities/mod.js +0 -5
  101. package/esm/editor/src/utilities/toRawTextResult.d.ts +0 -3
  102. package/esm/editor/src/utilities/toRawTextResult.d.ts.map +0 -1
  103. package/esm/editor/src/utilities/toRawTextResult.js +0 -21
  104. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +0 -8
  105. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +0 -1
  106. package/esm/extension-autocomplete/src/AutocompletePlugin.js +0 -232
  107. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +0 -17
  108. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +0 -1
  109. package/esm/extension-autocomplete/src/DefaultRenderer.js +0 -137
  110. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +0 -26
  111. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +0 -1
  112. package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +0 -30
  113. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +0 -11
  114. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +0 -1
  115. package/esm/extension-autocomplete/src/createDefaultMatcher.js +0 -58
  116. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +0 -4
  117. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +0 -1
  118. package/esm/extension-autocomplete/src/createRegexMatcher.js +0 -50
  119. package/esm/extension-autocomplete/src/mod.d.ts +0 -3
  120. package/esm/extension-autocomplete/src/mod.d.ts.map +0 -1
  121. package/esm/extension-autocomplete/src/mod.js +0 -2
  122. package/esm/extension-autocomplete/src/types.d.ts +0 -60
  123. package/esm/extension-autocomplete/src/types.d.ts.map +0 -1
  124. package/esm/extension-autocomplete/src/types.js +0 -1
  125. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +0 -15
  126. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +0 -1
  127. package/esm/extension-basic-editor/src/ExtensionHtml.js +0 -108
  128. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +0 -32
  129. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +0 -1
  130. package/esm/extension-lsp/src/DiagnosticPlugin.js +0 -131
  131. package/esm/extension-lsp/src/ExtensionLsp.d.ts +0 -25
  132. package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +0 -1
  133. package/esm/extension-lsp/src/ExtensionLsp.js +0 -126
  134. package/esm/extension-lsp/src/LSPClient.d.ts +0 -56
  135. package/esm/extension-lsp/src/LSPClient.d.ts.map +0 -1
  136. package/esm/extension-lsp/src/LSPClient.js +0 -449
  137. package/esm/extension-lsp/src/LspStatus.d.ts +0 -34
  138. package/esm/extension-lsp/src/LspStatus.d.ts.map +0 -1
  139. package/esm/extension-lsp/src/LspStatus.js +0 -127
  140. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +0 -8
  141. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +0 -1
  142. package/esm/extension-lsp/src/computeIncrementalChanges.js +0 -82
  143. package/esm/extension-lsp/src/createLspAutocomplete.d.ts +0 -23
  144. package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +0 -1
  145. package/esm/extension-lsp/src/createLspAutocomplete.js +0 -68
  146. package/esm/extension-lsp/src/workspace.d.ts +0 -62
  147. package/esm/extension-lsp/src/workspace.d.ts.map +0 -1
  148. package/esm/extension-lsp/src/workspace.js +0 -168
  149. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +0 -36
  150. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +0 -1
  151. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +0 -240
  152. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +0 -26
  153. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +0 -1
  154. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +0 -115
  155. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +0 -22
  156. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +0 -1
  157. package/esm/extension-markdown/src/ExtensionMarkdown.js +0 -48
  158. package/esm/extension-markdown/src/MarkdownParser.d.ts +0 -61
  159. package/esm/extension-markdown/src/MarkdownParser.d.ts.map +0 -1
  160. package/esm/extension-markdown/src/MarkdownParser.js +0 -249
  161. package/esm/extension-markdown/src/MarkdownSerializer.d.ts +0 -42
  162. package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +0 -1
  163. package/esm/extension-markdown/src/MarkdownSerializer.js +0 -325
  164. package/esm/extension-markdown/src/PositionMapper.d.ts +0 -15
  165. package/esm/extension-markdown/src/PositionMapper.d.ts.map +0 -1
  166. package/esm/extension-markdown/src/PositionMapper.js +0 -100
  167. package/esm/extension-markdown/src/TokenSource.d.ts +0 -11
  168. package/esm/extension-markdown/src/TokenSource.d.ts.map +0 -1
  169. package/esm/extension-markdown/src/TokenSource.js +0 -39
  170. package/esm/extension-markdown/src/mdToPmConverter.d.ts +0 -5
  171. package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +0 -1
  172. package/esm/extension-markdown/src/mdToPmConverter.js +0 -111
  173. package/esm/extension-markdown/src/pmToMdConverter.d.ts +0 -16
  174. package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +0 -1
  175. package/esm/extension-markdown/src/pmToMdConverter.js +0 -433
  176. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +0 -4
  177. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +0 -1
  178. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +0 -151
  179. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +0 -3
  180. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +0 -1
  181. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +0 -34
  182. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +0 -6
  183. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +0 -1
  184. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +0 -380
  185. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +0 -3
  186. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +0 -1
  187. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +0 -323
  188. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +0 -9
  189. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +0 -1
  190. package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +0 -308
  191. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +0 -5
  192. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +0 -1
  193. package/esm/extension-markdown/src/treeSitterTokenizer.js +0 -769
  194. package/esm/extension-markdown/src/types.d.ts +0 -28
  195. package/esm/extension-markdown/src/types.d.ts.map +0 -1
  196. package/esm/extension-markdown/src/types.js +0 -131
  197. package/esm/extension-markdown/src/utils.d.ts +0 -8
  198. package/esm/extension-markdown/src/utils.d.ts.map +0 -1
  199. package/esm/extension-markdown/src/utils.js +0 -86
  200. package/esm/extension-menu/src/CustomMenuPlugin.d.ts.map +0 -1
  201. package/esm/extension-menu/src/ExtensionCustomMenu.d.ts +0 -15
  202. package/esm/extension-menu/src/ExtensionCustomMenu.d.ts.map +0 -1
  203. package/esm/extension-menu/src/ExtensionCustomMenu.js +0 -58
  204. package/esm/extension-menu/src/buildMenu.d.ts.map +0 -1
  205. package/esm/extension-menu/src/icons.d.ts.map +0 -1
  206. package/esm/extension-menu/src/menu.d.ts.map +0 -1
  207. package/esm/extension-menu/src/mod.d.ts.map +0 -1
  208. package/esm/extension-menu/src/prompt.d.ts.map +0 -1
  209. package/esm/extension-yjs/src/CollaborationStatus.d.ts +0 -59
  210. package/esm/extension-yjs/src/CollaborationStatus.d.ts.map +0 -1
  211. package/esm/extension-yjs/src/CollaborationStatus.js +0 -286
  212. package/esm/tree-sitter-shim/src/main.d.ts +0 -15
  213. package/esm/tree-sitter-shim/src/main.d.ts.map +0 -1
  214. package/esm/tree-sitter-shim/src/main.js +0 -25
  215. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +0 -6
  216. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +0 -1
  217. package/esm/tree-sitter-shim/src/tree_sitter/node.js +0 -1
  218. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +0 -7
  219. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +0 -1
  220. package/esm/tree-sitter-shim/src/tree_sitter/parser.js +0 -5
  221. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +0 -6
  222. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +0 -1
  223. package/esm/tree-sitter-shim/src/tree_sitter/tree.js +0 -1
  224. package/esm/wasm/src/mod.d.ts +0 -12
  225. package/esm/wasm/src/mod.d.ts.map +0 -1
  226. package/esm/wasm/src/mod.js +0 -48
  227. package/esm/wasm/wasm.d.ts +0 -138
  228. package/esm/wasm/wasm.d.ts.map +0 -1
  229. package/esm/wasm/wasm.js +0 -120
  230. /package/esm/{extension-menu/src/buildMenu.js → buildMenu.js} +0 -0
  231. /package/esm/{extension-menu/src/icons.d.ts → icons.d.ts} +0 -0
  232. /package/esm/{extension-menu/src/icons.js → icons.js} +0 -0
  233. /package/esm/{extension-menu/src/menu.js → menu.js} +0 -0
  234. /package/esm/{extension-menu/src/prompt.d.ts → prompt.d.ts} +0 -0
  235. /package/esm/{extension-menu/src/prompt.js → prompt.js} +0 -0
@@ -1,249 +0,0 @@
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
- }
@@ -1,42 +0,0 @@
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
@@ -1 +0,0 @@
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;AAE1C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IAEnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAC9C,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC1C,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACjC;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,UAAU,CAAoB;IACtC,SAAgB,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;gBAE/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAmBlD,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IA2B7B,OAAO,CAAC,MAAM,EAAE,MAAM;IAWtB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAWnD,IAAI,OAAO,sBAEV;CACF;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,YAAY,EACjB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,EAC/B,MAAM,EAAE,KAAK,EAAE,QAgChB;AAED,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,YAAY,EACjB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,KAC5B,OAAO,GAAG,IAAI,CAAC;AAEpB,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CAClC;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,GAAG,CAAe;gBAEd,MAAM,GAAE,wBAA6B;IAcjD,OAAO,KAAK,iBAAiB,GAE5B;IAED,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC;CAiH/C"}
@@ -1,325 +0,0 @@
1
- import { NESTING_CLOSING } from './types.js';
2
- import { getTableTokensHandlers } from './token_handlers/table_token_handlers.js';
3
- import { getBasicTokensHandlers } from './token_handlers/basic_token_handlers.js';
4
- import { getInlineTokensHandlers } from './token_handlers/inline_token_handlers.js';
5
- import { getFootnoteTokensHandlers } from './token_handlers/footnote_token_handlers.js';
6
- import { getListsTokensHandlers } from './token_handlers/lists_token_handlers.js';
7
- import { TokenSource } from './TokenSource.js';
8
- import { SmartOutput } from '../../editor/src/utilities/mod.js';
9
- export function writeIndented(output, text, currentCtx, token) {
10
- const lines = text.split('\n');
11
- const typeIndent = {
12
- ul: 2,
13
- ol: 4,
14
- dl: 2,
15
- tl: 4,
16
- };
17
- let offset = 0;
18
- const startPos = token
19
- ? (token.map && token.map.length > 0 ? token.map[0] : 0)
20
- : 0;
21
- for (let lineNo = 0; lineNo < lines.length; lineNo++) {
22
- const line = lines[lineNo];
23
- if (lineNo === lines.length - 1 && line.length === 0) {
24
- continue;
25
- }
26
- if (output.colPos === 0) {
27
- output.log('> '.repeat(currentCtx.blockquoteCnt).trim());
28
- }
29
- if (output.colPos === 0 && line.length > 0) {
30
- output.log(' '.repeat(currentCtx.footnoteCnt));
31
- const indent = currentCtx.listPath
32
- .slice(0, currentCtx.listPath.length - 1)
33
- .map((type) => typeIndent[type])
34
- .reduce((p, c) => p + c, 0);
35
- if (currentCtx.listType === 'tl') {
36
- output.log(' '.repeat(indent));
37
- if (currentCtx.itemRow === 0) {
38
- output.log('- ');
39
- if (currentCtx.itemSymbol) {
40
- output.log('[x] ');
41
- }
42
- else {
43
- output.log('[ ] ');
44
- }
45
- }
46
- else {
47
- output.log(' ');
48
- }
49
- }
50
- if (currentCtx.listType === 'ul') {
51
- output.log(' '.repeat(indent));
52
- if (currentCtx.itemRow === 0) {
53
- output.log(currentCtx.itemSymbol + ' ');
54
- }
55
- else {
56
- output.log(' ');
57
- }
58
- }
59
- if (currentCtx.listType === 'ol') {
60
- const no = currentCtx.itemSymbol;
61
- output.log(' '.repeat(indent));
62
- if (currentCtx.itemRow === 0) {
63
- output.log(no);
64
- }
65
- else {
66
- output.log(' '.repeat(4));
67
- }
68
- }
69
- if (currentCtx.listType === 'dl') {
70
- if (currentCtx.itemSymbol) {
71
- if (currentCtx.itemRow === 0) {
72
- output.log(`${currentCtx.itemSymbol}`);
73
- }
74
- else {
75
- output.log(' '.repeat(currentCtx.itemSymbol.length));
76
- }
77
- }
78
- }
79
- }
80
- const tok = structuredClone(token);
81
- if (startPos && tok) {
82
- tok.map = [startPos + offset];
83
- }
84
- if (line.length > 0) {
85
- if (currentCtx.blockquoteCnt > 0 &&
86
- output.colPos === currentCtx.blockquoteCnt * 2 - 1) {
87
- output.log(' ');
88
- }
89
- }
90
- output.log(line, tok);
91
- offset += line.length;
92
- if (lineNo < lines.length - 1) {
93
- currentCtx.itemRow++;
94
- const tok = structuredClone(token);
95
- if (startPos && tok) {
96
- tok.map = [startPos + offset];
97
- }
98
- output.log('\n', tok);
99
- offset++;
100
- }
101
- }
102
- }
103
- export class ContextStash {
104
- constructor(handlers) {
105
- Object.defineProperty(this, "ctxStash", {
106
- enumerable: true,
107
- configurable: true,
108
- writable: true,
109
- value: []
110
- });
111
- Object.defineProperty(this, "currentCtx", {
112
- enumerable: true,
113
- configurable: true,
114
- writable: true,
115
- value: void 0
116
- });
117
- Object.defineProperty(this, "output", {
118
- enumerable: true,
119
- configurable: true,
120
- writable: true,
121
- value: void 0
122
- });
123
- this.output = new SmartOutput();
124
- this.currentCtx = {
125
- meta: {},
126
- metaObj: {},
127
- blockquoteCnt: 0,
128
- footnoteCnt: 0,
129
- itemRow: 0,
130
- listPath: [],
131
- itemNumber: 0,
132
- itemSymbol: '',
133
- handlers,
134
- log: (txt, token) => this.output.log(txt, token),
135
- debug: () => { },
136
- };
137
- this.stash('ContextStash.constructor()');
138
- }
139
- stash(reason) {
140
- this.currentCtx.debug(' '.repeat(this.ctxStash.length) + 'stash: ' + reason);
141
- this.ctxStash.push(this.currentCtx);
142
- const funcs = {
143
- log: this.currentCtx.log,
144
- debug: this.currentCtx.debug,
145
- };
146
- const handlers = { ...this.currentCtx.handlers };
147
- const metaObj = { ...this.currentCtx.metaObj };
148
- this.currentCtx = {
149
- ...structuredClone({
150
- ...this.currentCtx,
151
- log: undefined,
152
- debug: undefined,
153
- handlers: undefined,
154
- }),
155
- metaObj,
156
- ...funcs,
157
- handlers: handlers,
158
- };
159
- const rollbackPos = this.ctxStash.length - 1;
160
- return rollbackPos;
161
- }
162
- unstash(reason) {
163
- const ctx = this.ctxStash.pop();
164
- this.currentCtx.debug(' '.repeat(this.ctxStash.length) + 'unstash: ' + reason);
165
- if (!ctx) {
166
- throw new Error('Unstash failed');
167
- }
168
- this.currentCtx = ctx;
169
- }
170
- rollback(rollbackPos, reason) {
171
- const rollbackCtx = this.ctxStash[rollbackPos];
172
- if (!rollbackCtx) {
173
- throw new RangeError('Invalid rollbackPos: ' + rollbackPos);
174
- }
175
- this.currentCtx.debug('rollback ' + reason, rollbackPos);
176
- this.ctxStash.splice(rollbackPos);
177
- this.currentCtx = this.ctxStash[this.ctxStash.length - 1];
178
- }
179
- get current() {
180
- return this.currentCtx;
181
- }
182
- }
183
- export function serializeInlineTokens(ctx, tokenSource, tokens) {
184
- const appendPos = tokenSource.append(tokens);
185
- const oldPos = tokenSource.pos;
186
- tokenSource.rewind(appendPos);
187
- try {
188
- tokenSource.iterate(appendPos, (token, i) => {
189
- const tokenHandlers = ctx.current.handlers[token.type] || ctx.current.handlers['default'];
190
- if (!tokenHandlers) {
191
- throw new Error(`Unknown inline token: ${token.type} ` + JSON.stringify(token) +
192
- `, available hadlers: ${Object.keys(ctx.current.handlers)}`);
193
- }
194
- for (const handler of tokenHandlers) {
195
- if (handler(token, ctx, tokenSource)) {
196
- break;
197
- }
198
- }
199
- if (tokenSource.pos + 1 < appendPos) {
200
- throw new RangeError('Rewinded before inline tokens');
201
- }
202
- });
203
- tokenSource.rewind(oldPos);
204
- }
205
- finally {
206
- tokenSource.trim(appendPos);
207
- }
208
- }
209
- export class MarkdownSerializer {
210
- constructor(config = {}) {
211
- Object.defineProperty(this, "ctx", {
212
- enumerable: true,
213
- configurable: true,
214
- writable: true,
215
- value: void 0
216
- });
217
- this.ctx = new ContextStash({
218
- ...getInlineTokensHandlers(),
219
- ...getTableTokensHandlers(),
220
- ...getBasicTokensHandlers(),
221
- ...getFootnoteTokensHandlers(),
222
- ...getListsTokensHandlers(),
223
- });
224
- if (config.debug) {
225
- this.ctx.current.debug = config.debug;
226
- }
227
- }
228
- get endsWithEmptyLine() {
229
- return this.ctx.output.endsWith('\n\n');
230
- }
231
- serialize(tokens) {
232
- const prevLevelTokenType = {};
233
- const tokenSource = new TokenSource(tokens);
234
- tokenSource.iterate(0, (token, i) => {
235
- if (!this.ctx.current.meta['html_mode']) {
236
- if (token.level === 0 && token.nesting !== NESTING_CLOSING) {
237
- if (this.ctx.output.colPos !== 0) {
238
- this.ctx.current.log('\n');
239
- }
240
- }
241
- if (!this.endsWithEmptyLine) {
242
- if (token.nesting !== NESTING_CLOSING && token.level === 0) {
243
- const prevTopTokenType = prevLevelTokenType[token.level] || '';
244
- if ([
245
- 'hr',
246
- 'paragraph_close',
247
- 'ordered_list_close',
248
- 'bullet_list_close',
249
- 'task_list_close',
250
- 'dl_close',
251
- 'table_close',
252
- 'blockquote_close',
253
- 'footnote_close',
254
- 'code_block',
255
- 'html_block',
256
- ].includes(prevTopTokenType)) {
257
- this.ctx.current.log('\n');
258
- }
259
- if ('heading_close' === prevTopTokenType &&
260
- token.tag !== 'heading_open') {
261
- this.ctx.current.log('\n');
262
- }
263
- }
264
- else if (token.nesting !== NESTING_CLOSING && token.level === 1 &&
265
- 'dt_open' === token.type) {
266
- const prevTokenType = prevLevelTokenType[token.level] || '';
267
- if ([
268
- 'dt_close',
269
- 'dd_close',
270
- ].includes(prevTokenType)) {
271
- this.ctx.current.log('\n');
272
- }
273
- }
274
- }
275
- }
276
- if (token.nesting !== NESTING_CLOSING && token.level > 0) {
277
- const prevTopTokenType = prevLevelTokenType[token.level] || '';
278
- if ([
279
- 'paragraph_close',
280
- ].includes(prevTopTokenType)) {
281
- if (this.ctx.current.blockquoteCnt === token.level) {
282
- writeIndented(this.ctx.output, '\n', this.ctx.current, token);
283
- }
284
- }
285
- }
286
- const tokenHandlers = this.ctx.current.handlers[token.type] ||
287
- this.ctx.current.handlers['default'];
288
- if (token.type === 'inline') {
289
- if (token.children) {
290
- this.ctx.stash('serializeInlineTokens()');
291
- this.ctx.current.log = (txt, token) => {
292
- writeIndented(this.ctx.output, txt, this.ctx.current, token);
293
- };
294
- try {
295
- serializeInlineTokens(this.ctx, tokenSource, token.children);
296
- this.ctx.unstash('serializeInlineTokens()');
297
- }
298
- catch (err) {
299
- this.ctx.current.debug(err.message);
300
- if (err.message === 'Rewinded before inline tokens') {
301
- return;
302
- }
303
- throw err;
304
- }
305
- }
306
- }
307
- else if (!tokenHandlers) {
308
- this.ctx.current.debug('current.handlers', Object.keys(this.ctx.current.handlers).sort());
309
- throw new Error(`Unknown token: ${token.type} ` + JSON.stringify(token));
310
- }
311
- else {
312
- for (const handler of tokenHandlers) {
313
- if (handler(token, this.ctx, tokenSource)) {
314
- break;
315
- }
316
- }
317
- }
318
- prevLevelTokenType[token.level] = token.type;
319
- if (token.nesting === NESTING_CLOSING) {
320
- prevLevelTokenType[token.level + 1] = '';
321
- }
322
- });
323
- return this.ctx.output;
324
- }
325
- }
@@ -1,15 +0,0 @@
1
- import type { Node } from 'prosemirror-model';
2
- import type { CoreEditor, RawTextMapEntry } from '../../editor/src/mod.js';
3
- export declare class PositionMapper {
4
- readonly rawTextMap: Array<RawTextMapEntry>;
5
- private readonly rawTextArr;
6
- readonly doc: Node;
7
- constructor(editor: CoreEditor, rawTextMap: Array<RawTextMapEntry>);
8
- toRawTextPos(pos: number): number;
9
- toRawTextLspPos(pos: number): {
10
- line: number;
11
- character: number;
12
- };
13
- fromLineChar(line: number, character: number): number;
14
- }
15
- //# sourceMappingURL=PositionMapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PositionMapper.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/PositionMapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAiC3E,qBAAa,cAAc;aAMP,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC;IALpD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,SAAgB,GAAG,EAAE,IAAI,CAAC;gBAGxB,MAAM,EAAE,UAAU,EACF,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC;IA0BpD,YAAY,CAAC,GAAG,EAAE,MAAM;IAUxB,eAAe,CAAC,GAAG,EAAE,MAAM;;;;IAa3B,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAoB7C"}