@kerebron/extension-menu 0.4.4 → 0.4.6

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,240 +0,0 @@
1
- import { Token } from './types.js';
2
- const blankMark = { open: '', close: '', mixable: true };
3
- const blankNode = { open: '', close: '' };
4
- function generateInlineTokens(input) {
5
- const tokens = [];
6
- let currentPos = -1;
7
- let currentText = '';
8
- for (const [text, inlinePos] of input) {
9
- if (true || currentPos !== inlinePos) {
10
- if (currentText.length > 0) {
11
- const token = new Token('text', '', 0);
12
- token.meta = 'generateInline1';
13
- token.map = [currentPos];
14
- token.content = currentText;
15
- tokens.push(token);
16
- }
17
- currentText = '';
18
- currentPos = inlinePos;
19
- }
20
- currentText += text;
21
- }
22
- if (currentText.length > 0) {
23
- const token = new Token('text', '', 0);
24
- token.meta = 'generateInline2';
25
- token.map = [currentPos];
26
- token.content = currentText;
27
- tokens.push(token);
28
- }
29
- return tokens;
30
- }
31
- export class DocumentMarkdownInlineTokenizer {
32
- constructor(nodes, marks, options) {
33
- Object.defineProperty(this, "nodes", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: nodes
38
- });
39
- Object.defineProperty(this, "marks", {
40
- enumerable: true,
41
- configurable: true,
42
- writable: true,
43
- value: marks
44
- });
45
- Object.defineProperty(this, "options", {
46
- enumerable: true,
47
- configurable: true,
48
- writable: true,
49
- value: options
50
- });
51
- }
52
- getMark(name) {
53
- let info = this.marks[name];
54
- if (!info) {
55
- // if (this.options.strict !== false) {
56
- // throw new Error(
57
- // `Mark type \`${name}\` not supported by Markdown renderer`,
58
- // );
59
- // }
60
- return blankMark;
61
- }
62
- return info;
63
- }
64
- renderInline(parent, currentPos, level) {
65
- const active = [];
66
- const trailing = [];
67
- const inlineTokens = [];
68
- const progress = (node, offset, index) => {
69
- const inlinePos = currentPos + offset;
70
- let marks = node ? node.marks : [];
71
- // Remove marks from `hard_break` that are the last node inside
72
- // that mark to prevent parser edge cases with new lines just
73
- // before closing marks.
74
- // TODO:
75
- if (node && node.type.name === this.options.hardBreakNodeName) {
76
- marks = marks.filter((m) => {
77
- if (index + 1 == parent.childCount)
78
- return false;
79
- let next = parent.child(index + 1);
80
- return m.isInSet(next.marks) &&
81
- (!next.isText || /\S/.test(next.text));
82
- });
83
- }
84
- const leading = trailing.splice(0, trailing.length);
85
- // If whitespace has to be expelled from the node, adjust
86
- // leading and trailing accordingly.
87
- if (node.isText && marks.some((mark) => {
88
- let info = this.getMark(mark.type.name);
89
- return info && info.expelEnclosingWhitespace && !mark.isInSet(active);
90
- })) {
91
- let [_, lead, rest] = /^(\s*)(.*)$/m.exec(node.text);
92
- if (lead) {
93
- leading.push([lead, inlinePos]);
94
- node = rest ? node.withText(rest) : null;
95
- if (!node)
96
- marks = active;
97
- }
98
- }
99
- if (node.isText && marks.some((mark) => {
100
- let info = this.getMark(mark.type.name);
101
- return info && info.expelEnclosingWhitespace &&
102
- (index == parent.childCount - 1 ||
103
- !mark.isInSet(parent.child(index + 1).marks));
104
- })) {
105
- let [_, rest, trail] = /^(.*?)(\s*)$/m.exec(node.text);
106
- if (trail) {
107
- trailing.push([trail, inlinePos]);
108
- node = rest ? node.withText(rest) : null;
109
- if (!node)
110
- marks = active;
111
- }
112
- }
113
- let inner = marks.length ? marks[marks.length - 1] : null;
114
- let noEsc = inner && this.getMark(inner.type.name).escape === false;
115
- let len = marks.length - (noEsc ? 1 : 0);
116
- // Try to reorder 'mixable' marks, such as em and strong, which
117
- // in Markdown may be opened and closed in different order, so
118
- // that order of the marks for the token matches the order in
119
- // active.
120
- outer: for (let i = 0; i < len; i++) {
121
- let mark = marks[i];
122
- if (!this.getMark(mark.type.name).mixable)
123
- break;
124
- for (let j = 0; j < active.length; j++) {
125
- let other = active[j];
126
- if (!this.getMark(other.type.name).mixable)
127
- break;
128
- if (mark.eq(other)) {
129
- if (i > j) {
130
- marks = marks.slice(0, j).concat(mark).concat(marks.slice(j, i))
131
- .concat(marks.slice(i + 1, len));
132
- }
133
- else if (j > i) {
134
- marks = marks.slice(0, i).concat(marks.slice(i + 1, j)).concat(mark).concat(marks.slice(j, len));
135
- }
136
- continue outer;
137
- }
138
- }
139
- }
140
- // Find the prefix of the mark set that didn't change
141
- let keep = 0;
142
- while (keep < Math.min(active.length, len) && marks[keep].eq(active[keep]))
143
- ++keep;
144
- // Close the marks that need to be closed
145
- while (keep < active.length) {
146
- const x = active.pop();
147
- this.markString(x, false, inlineTokens);
148
- }
149
- // Output any previously expelled trailing whitespace outside the marks
150
- inlineTokens.push(...generateInlineTokens(leading.splice(0, leading.length)));
151
- // Open the marks that need to be opened
152
- while (active.length < len) {
153
- let add = marks[active.length];
154
- active.push(add);
155
- this.markString(add, true, inlineTokens);
156
- }
157
- // Render the node. Special case code marks, since their content
158
- // may not be escaped.
159
- if (noEsc && node.isText) {
160
- this.markString(inner, true, inlineTokens);
161
- if (node.text) {
162
- const token = new Token('text', '', 0);
163
- token.meta = 'noEscText';
164
- token.map = [inlinePos];
165
- token.content = node.text;
166
- inlineTokens.push(token);
167
- }
168
- this.markString(inner, false, inlineTokens);
169
- }
170
- else {
171
- const nodeSpec = this.nodes[node.type.name]
172
- ? this.nodes[node.type.name](node, currentPos)
173
- : blankNode;
174
- let tag = '';
175
- if (node.type.spec.toDOM) {
176
- const dom = node.type.spec.toDOM(node);
177
- if (Array.isArray(dom) && dom.length > 0) {
178
- tag = dom[0];
179
- }
180
- }
181
- if (nodeSpec.selfClose) {
182
- if (typeof nodeSpec.selfClose === 'string') {
183
- const token = new Token(nodeSpec.selfClose, tag, 0);
184
- token.meta = 'nodeSpec.selfClose';
185
- token.level = level;
186
- token.map = [inlinePos];
187
- inlineTokens.push(token);
188
- }
189
- else {
190
- const token = nodeSpec.selfClose(node);
191
- token.meta = '!nodeSpec.selfClose';
192
- token.level = level;
193
- token.map = [inlinePos];
194
- inlineTokens.push(token);
195
- }
196
- }
197
- }
198
- };
199
- parent.forEach((child, offset, index) => progress(child, offset, index));
200
- // Close the marks that need to be closed
201
- while (active.length > 0) {
202
- const x = active.pop();
203
- this.markString(x, false, inlineTokens);
204
- }
205
- // Output any previously expelled trailing whitespace outside the marks
206
- inlineTokens.push(...generateInlineTokens(trailing.splice(0, trailing.length)));
207
- return inlineTokens;
208
- }
209
- markString(mark, open, tokens) {
210
- let info = this.getMark(mark.type.name);
211
- let value = open ? info.open : info.close;
212
- if (!value) {
213
- /** Skip unknown marks (like textColor, highlight) - they'll be lost in markdown but won't crash */
214
- console.warn('Unsupported mark type for markdown: ' + mark.type.name +
215
- ', available types: ' +
216
- Object.keys(this.marks).join(', ') + '. Mark will be ignored.');
217
- return;
218
- }
219
- const token = typeof value == 'string' ? value : value(mark);
220
- let tag = '';
221
- if (mark.type.spec.toDOM) {
222
- const dom = mark.type.spec.toDOM(mark, true);
223
- if (Array.isArray(dom) && dom.length > 0) {
224
- tag = dom[0];
225
- }
226
- }
227
- if (typeof value === 'string') {
228
- const token = new Token(value, tag, open ? 1 : -1);
229
- token.meta = 'markString';
230
- tokens.push(token);
231
- }
232
- else {
233
- const token = value(mark);
234
- if (token) {
235
- token.meta = token.meta || 'markString()';
236
- tokens.push(token);
237
- }
238
- }
239
- }
240
- }
@@ -1,26 +0,0 @@
1
- import type { Node } from 'prosemirror-model';
2
- import { Token } from './types.js';
3
- import { DocumentMarkdownInlineTokenizer, DocumentMarkdownTokenizerSpec, MarkTokenizerSpec } from './DocumentMarkdownInlineTokenizer.js';
4
- export declare class DocumentMarkdownTokenizer {
5
- readonly nodes: {
6
- [node: string]: (node: Node, index: number) => DocumentMarkdownTokenizerSpec;
7
- };
8
- readonly marks: {
9
- [mark: string]: MarkTokenizerSpec;
10
- };
11
- readonly options: {
12
- hardBreakNodeName: string;
13
- };
14
- private tokens;
15
- inlineTokenizer: DocumentMarkdownInlineTokenizer;
16
- constructor(nodes: {
17
- [node: string]: (node: Node, index: number) => DocumentMarkdownTokenizerSpec;
18
- }, marks: {
19
- [mark: string]: MarkTokenizerSpec;
20
- }, options?: {
21
- hardBreakNodeName: string;
22
- });
23
- iterateNode(node: Node, currentPos: number, level?: number): void;
24
- serialize(content: Node, options?: {}): Token[];
25
- }
26
- //# sourceMappingURL=DocumentMarkdownTokenizer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DocumentMarkdownTokenizer.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/DocumentMarkdownTokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,EAC7B,iBAAiB,EAClB,MAAM,sCAAsC,CAAC;AAI9C,qBAAa,yBAAyB;IAKlC,QAAQ,CAAC,KAAK,EAAE;QACd,CAAC,IAAI,EAAE,MAAM,GAAG,CACd,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,KACV,6BAA6B,CAAC;KACpC;IACD,QAAQ,CAAC,KAAK,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAA;KAAE;IACrD,QAAQ,CAAC,OAAO,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE;IAXjD,OAAO,CAAC,MAAM,CAAoB;IAClC,eAAe,EAAE,+BAA+B,CAAC;gBAGtC,KAAK,EAAE;QACd,CAAC,IAAI,EAAE,MAAM,GAAG,CACd,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,KACV,6BAA6B,CAAC;KACpC,EACQ,KAAK,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAA;KAAE,EAC5C,OAAO,GAAE;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAE5C;IASH,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,SAAK;IA8EtD,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,GAAE,EAAO,GAAG,KAAK,EAAE;CAIpD"}
@@ -1,115 +0,0 @@
1
- import { Token } from './types.js';
2
- import { DocumentMarkdownInlineTokenizer, } from './DocumentMarkdownInlineTokenizer.js';
3
- const blankNode = { open: '', close: '' };
4
- export class DocumentMarkdownTokenizer {
5
- constructor(nodes, marks, options = {
6
- hardBreakNodeName: 'hard_break',
7
- }) {
8
- Object.defineProperty(this, "nodes", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: nodes
13
- });
14
- Object.defineProperty(this, "marks", {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value: marks
19
- });
20
- Object.defineProperty(this, "options", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: options
25
- });
26
- Object.defineProperty(this, "tokens", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: []
31
- });
32
- Object.defineProperty(this, "inlineTokenizer", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: void 0
37
- });
38
- this.inlineTokenizer = new DocumentMarkdownInlineTokenizer(nodes, marks, options);
39
- }
40
- iterateNode(node, currentPos, level = -1) {
41
- const nodeSpec = this.nodes[node.type.name]
42
- ? this.nodes[node.type.name](node, currentPos)
43
- : blankNode;
44
- let tag = '';
45
- if (node.type.spec.toDOM) {
46
- const dom = node.type.spec.toDOM(node);
47
- if (Array.isArray(dom) && dom.length > 0) {
48
- tag = dom[0];
49
- }
50
- }
51
- if (nodeSpec.open) {
52
- if (typeof nodeSpec.open === 'string') {
53
- const token = new Token(nodeSpec.open, tag, 1);
54
- token.level = level;
55
- token.meta = 'nodeSpec.open';
56
- token.map = [currentPos];
57
- this.tokens.push(token);
58
- }
59
- else {
60
- const token = nodeSpec.open(node);
61
- token.level = level;
62
- token.meta = 'nodeSpec.open()';
63
- token.map = [currentPos];
64
- this.tokens.push(token);
65
- }
66
- }
67
- if (nodeSpec.selfClose) {
68
- if (typeof nodeSpec.selfClose === 'string') {
69
- const token = new Token(nodeSpec.selfClose, tag, 0);
70
- token.level = level;
71
- token.map = [currentPos];
72
- this.tokens.push(token);
73
- }
74
- else {
75
- const token = nodeSpec.selfClose(node);
76
- token.level = level;
77
- token.map = [currentPos];
78
- this.tokens.push(token);
79
- }
80
- return;
81
- }
82
- if (node.inlineContent) {
83
- const token = new Token('inline', '', 0);
84
- token.level = level + 1;
85
- token.map = [currentPos];
86
- this.tokens.push(token);
87
- token.children = this.inlineTokenizer.renderInline(node, currentPos + 1, level + 1);
88
- }
89
- else if (node.childCount > 0) {
90
- node.forEach((child, offset) => {
91
- this.iterateNode(child, currentPos + offset + 1, level + 1);
92
- });
93
- }
94
- if (nodeSpec.close) {
95
- if (typeof nodeSpec.close === 'string') {
96
- const token = new Token(nodeSpec.close, tag, -1);
97
- token.meta = 'nodeSpec.close';
98
- token.level = level;
99
- // token.map = [currentPos];
100
- this.tokens.push(token);
101
- }
102
- else {
103
- const token = nodeSpec.close(node);
104
- token.meta = 'nodeSpec.close()';
105
- token.level = level;
106
- // token.map = [currentPos];
107
- this.tokens.push(token);
108
- }
109
- }
110
- }
111
- serialize(content, options = {}) {
112
- this.iterateNode(content, -1); // doc does not have index, so I put -1 for correct calculation
113
- return this.tokens;
114
- }
115
- }
@@ -1,22 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,48 +0,0 @@
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
- }
@@ -1,61 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownParser.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/MarkdownParser.ts"],"names":[],"mappings":"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"}