@kerebron/extension-codejar 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 (248) hide show
  1. package/esm/{extension-codejar/src/CodeJar.d.ts → CodeJar.d.ts} +1 -1
  2. package/esm/CodeJar.d.ts.map +1 -0
  3. package/esm/{extension-codejar/src/CodeJar.js → CodeJar.js} +1 -1
  4. package/esm/Decorator.d.ts.map +1 -0
  5. package/esm/{extension-codejar/src/ExtensionCodeJar.d.ts → ExtensionCodeJar.d.ts} +1 -1
  6. package/esm/ExtensionCodeJar.d.ts.map +1 -0
  7. package/esm/{extension-codejar/src/ExtensionCodeJar.js → ExtensionCodeJar.js} +2 -2
  8. package/esm/{extension-codejar/src/NodeCodeJar.d.ts → NodeCodeJar.d.ts} +3 -3
  9. package/esm/NodeCodeJar.d.ts.map +1 -0
  10. package/esm/{extension-codejar/src/NodeCodeJar.js → NodeCodeJar.js} +3 -3
  11. package/esm/{extension-codejar/src/TreeSitterHighlighter.d.ts → TreeSitterHighlighter.d.ts} +1 -1
  12. package/esm/TreeSitterHighlighter.d.ts.map +1 -0
  13. package/esm/{extension-codejar/src/TreeSitterHighlighter.js → TreeSitterHighlighter.js} +3 -8
  14. package/esm/{extension-codejar/src/codeJarBlockNodeView.d.ts → codeJarBlockNodeView.d.ts} +1 -1
  15. package/esm/codeJarBlockNodeView.d.ts.map +1 -0
  16. package/esm/{extension-codejar/src/codeJarBlockNodeView.js → codeJarBlockNodeView.js} +2 -2
  17. package/esm/codeJarLineNumbers.d.ts.map +1 -0
  18. package/esm/mod.d.ts +2 -0
  19. package/esm/mod.d.ts.map +1 -0
  20. package/esm/{extension-codejar/src/mod.js → mod.js} +0 -1
  21. package/esm/utils.d.ts.map +1 -0
  22. package/package.json +10 -6
  23. package/esm/_dnt.polyfills.d.ts +0 -101
  24. package/esm/_dnt.polyfills.d.ts.map +0 -1
  25. package/esm/_dnt.polyfills.js +0 -127
  26. package/esm/editor/src/CoreEditor.d.ts +0 -40
  27. package/esm/editor/src/CoreEditor.d.ts.map +0 -1
  28. package/esm/editor/src/CoreEditor.js +0 -252
  29. package/esm/editor/src/DummyEditorView.d.ts +0 -60
  30. package/esm/editor/src/DummyEditorView.d.ts.map +0 -1
  31. package/esm/editor/src/DummyEditorView.js +0 -277
  32. package/esm/editor/src/Extension.d.ts +0 -31
  33. package/esm/editor/src/Extension.d.ts.map +0 -1
  34. package/esm/editor/src/Extension.js +0 -53
  35. package/esm/editor/src/ExtensionManager.d.ts +0 -32
  36. package/esm/editor/src/ExtensionManager.d.ts.map +0 -1
  37. package/esm/editor/src/ExtensionManager.js +0 -260
  38. package/esm/editor/src/Mark.d.ts +0 -23
  39. package/esm/editor/src/Mark.d.ts.map +0 -1
  40. package/esm/editor/src/Mark.js +0 -51
  41. package/esm/editor/src/Node.d.ts +0 -32
  42. package/esm/editor/src/Node.d.ts.map +0 -1
  43. package/esm/editor/src/Node.js +0 -60
  44. package/esm/editor/src/commands/CommandManager.d.ts +0 -23
  45. package/esm/editor/src/commands/CommandManager.d.ts.map +0 -1
  46. package/esm/editor/src/commands/CommandManager.js +0 -118
  47. package/esm/editor/src/commands/baseCommandFactories.d.ts +0 -3
  48. package/esm/editor/src/commands/baseCommandFactories.d.ts.map +0 -1
  49. package/esm/editor/src/commands/baseCommandFactories.js +0 -836
  50. package/esm/editor/src/commands/createChainableState.d.ts +0 -3
  51. package/esm/editor/src/commands/createChainableState.d.ts.map +0 -1
  52. package/esm/editor/src/commands/createChainableState.js +0 -29
  53. package/esm/editor/src/commands/keyCommandFactories.d.ts +0 -3
  54. package/esm/editor/src/commands/keyCommandFactories.d.ts.map +0 -1
  55. package/esm/editor/src/commands/keyCommandFactories.js +0 -10
  56. package/esm/editor/src/commands/mod.d.ts +0 -7
  57. package/esm/editor/src/commands/mod.d.ts.map +0 -1
  58. package/esm/editor/src/commands/mod.js +0 -76
  59. package/esm/editor/src/commands/replaceCommandFactories.d.ts +0 -3
  60. package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +0 -1
  61. package/esm/editor/src/commands/replaceCommandFactories.js +0 -94
  62. package/esm/editor/src/commands/types.d.ts +0 -18
  63. package/esm/editor/src/commands/types.d.ts.map +0 -1
  64. package/esm/editor/src/commands/types.js +0 -1
  65. package/esm/editor/src/mod.d.ts +0 -9
  66. package/esm/editor/src/mod.d.ts.map +0 -1
  67. package/esm/editor/src/mod.js +0 -8
  68. package/esm/editor/src/nodeToTreeString.d.ts +0 -10
  69. package/esm/editor/src/nodeToTreeString.d.ts.map +0 -1
  70. package/esm/editor/src/nodeToTreeString.js +0 -74
  71. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +0 -6
  72. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +0 -1
  73. package/esm/editor/src/plugins/TrackSelecionPlugin.js +0 -24
  74. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts +0 -23
  75. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts.map +0 -1
  76. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +0 -163
  77. package/esm/editor/src/plugins/input-rules/mod.d.ts +0 -3
  78. package/esm/editor/src/plugins/input-rules/mod.d.ts.map +0 -1
  79. package/esm/editor/src/plugins/input-rules/mod.js +0 -2
  80. package/esm/editor/src/plugins/input-rules/rulebuilders.d.ts +0 -5
  81. package/esm/editor/src/plugins/input-rules/rulebuilders.d.ts.map +0 -1
  82. package/esm/editor/src/plugins/input-rules/rulebuilders.js +0 -50
  83. package/esm/editor/src/plugins/keymap/keymap.d.ts +0 -11
  84. package/esm/editor/src/plugins/keymap/keymap.d.ts.map +0 -1
  85. package/esm/editor/src/plugins/keymap/keymap.js +0 -125
  86. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +0 -4
  87. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +0 -1
  88. package/esm/editor/src/plugins/keymap/w3c-keyname.js +0 -124
  89. package/esm/editor/src/types.d.ts +0 -52
  90. package/esm/editor/src/types.d.ts.map +0 -1
  91. package/esm/editor/src/types.js +0 -1
  92. package/esm/editor/src/ui.d.ts +0 -15
  93. package/esm/editor/src/ui.d.ts.map +0 -1
  94. package/esm/editor/src/ui.js +0 -16
  95. package/esm/editor/src/utilities/SmartOutput.d.ts +0 -41
  96. package/esm/editor/src/utilities/SmartOutput.d.ts.map +0 -1
  97. package/esm/editor/src/utilities/SmartOutput.js +0 -228
  98. package/esm/editor/src/utilities/createNodeFromContent.d.ts +0 -9
  99. package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +0 -1
  100. package/esm/editor/src/utilities/createNodeFromContent.js +0 -32
  101. package/esm/editor/src/utilities/getHtmlAttributes.d.ts +0 -9
  102. package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +0 -1
  103. package/esm/editor/src/utilities/getHtmlAttributes.js +0 -47
  104. package/esm/editor/src/utilities/getShadowRoot.d.ts +0 -2
  105. package/esm/editor/src/utilities/getShadowRoot.d.ts.map +0 -1
  106. package/esm/editor/src/utilities/getShadowRoot.js +0 -16
  107. package/esm/editor/src/utilities/mod.d.ts +0 -6
  108. package/esm/editor/src/utilities/mod.d.ts.map +0 -1
  109. package/esm/editor/src/utilities/mod.js +0 -5
  110. package/esm/editor/src/utilities/toRawTextResult.d.ts +0 -3
  111. package/esm/editor/src/utilities/toRawTextResult.d.ts.map +0 -1
  112. package/esm/editor/src/utilities/toRawTextResult.js +0 -21
  113. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +0 -8
  114. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +0 -1
  115. package/esm/extension-autocomplete/src/AutocompletePlugin.js +0 -232
  116. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +0 -17
  117. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +0 -1
  118. package/esm/extension-autocomplete/src/DefaultRenderer.js +0 -137
  119. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +0 -26
  120. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +0 -1
  121. package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +0 -30
  122. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +0 -11
  123. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +0 -1
  124. package/esm/extension-autocomplete/src/createDefaultMatcher.js +0 -58
  125. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +0 -4
  126. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +0 -1
  127. package/esm/extension-autocomplete/src/createRegexMatcher.js +0 -50
  128. package/esm/extension-autocomplete/src/mod.d.ts +0 -3
  129. package/esm/extension-autocomplete/src/mod.d.ts.map +0 -1
  130. package/esm/extension-autocomplete/src/mod.js +0 -2
  131. package/esm/extension-autocomplete/src/types.d.ts +0 -60
  132. package/esm/extension-autocomplete/src/types.d.ts.map +0 -1
  133. package/esm/extension-autocomplete/src/types.js +0 -1
  134. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +0 -15
  135. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +0 -1
  136. package/esm/extension-basic-editor/src/ExtensionHtml.js +0 -108
  137. package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts +0 -9
  138. package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts.map +0 -1
  139. package/esm/extension-basic-editor/src/NodeCodeBlock.js +0 -58
  140. package/esm/extension-codejar/src/CodeJar.d.ts.map +0 -1
  141. package/esm/extension-codejar/src/Decorator.d.ts.map +0 -1
  142. package/esm/extension-codejar/src/ExtensionCodeJar.d.ts.map +0 -1
  143. package/esm/extension-codejar/src/NodeCodeJar.d.ts.map +0 -1
  144. package/esm/extension-codejar/src/TreeSitterHighlighter.d.ts.map +0 -1
  145. package/esm/extension-codejar/src/codeJarBlockNodeView.d.ts.map +0 -1
  146. package/esm/extension-codejar/src/codeJarLineNumbers.d.ts.map +0 -1
  147. package/esm/extension-codejar/src/mod.d.ts +0 -3
  148. package/esm/extension-codejar/src/mod.d.ts.map +0 -1
  149. package/esm/extension-codejar/src/utils.d.ts.map +0 -1
  150. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +0 -32
  151. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +0 -1
  152. package/esm/extension-lsp/src/DiagnosticPlugin.js +0 -131
  153. package/esm/extension-lsp/src/ExtensionLsp.d.ts +0 -25
  154. package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +0 -1
  155. package/esm/extension-lsp/src/ExtensionLsp.js +0 -126
  156. package/esm/extension-lsp/src/LSPClient.d.ts +0 -56
  157. package/esm/extension-lsp/src/LSPClient.d.ts.map +0 -1
  158. package/esm/extension-lsp/src/LSPClient.js +0 -449
  159. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +0 -8
  160. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +0 -1
  161. package/esm/extension-lsp/src/computeIncrementalChanges.js +0 -82
  162. package/esm/extension-lsp/src/createLspAutocomplete.d.ts +0 -23
  163. package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +0 -1
  164. package/esm/extension-lsp/src/createLspAutocomplete.js +0 -68
  165. package/esm/extension-lsp/src/mod.d.ts +0 -4
  166. package/esm/extension-lsp/src/mod.d.ts.map +0 -1
  167. package/esm/extension-lsp/src/mod.js +0 -3
  168. package/esm/extension-lsp/src/workspace.d.ts +0 -62
  169. package/esm/extension-lsp/src/workspace.d.ts.map +0 -1
  170. package/esm/extension-lsp/src/workspace.js +0 -168
  171. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +0 -36
  172. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +0 -1
  173. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +0 -240
  174. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +0 -26
  175. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +0 -1
  176. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +0 -115
  177. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +0 -22
  178. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +0 -1
  179. package/esm/extension-markdown/src/ExtensionMarkdown.js +0 -48
  180. package/esm/extension-markdown/src/MarkdownParser.d.ts +0 -61
  181. package/esm/extension-markdown/src/MarkdownParser.d.ts.map +0 -1
  182. package/esm/extension-markdown/src/MarkdownParser.js +0 -249
  183. package/esm/extension-markdown/src/MarkdownSerializer.d.ts +0 -42
  184. package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +0 -1
  185. package/esm/extension-markdown/src/MarkdownSerializer.js +0 -325
  186. package/esm/extension-markdown/src/PositionMapper.d.ts +0 -15
  187. package/esm/extension-markdown/src/PositionMapper.d.ts.map +0 -1
  188. package/esm/extension-markdown/src/PositionMapper.js +0 -100
  189. package/esm/extension-markdown/src/TokenSource.d.ts +0 -11
  190. package/esm/extension-markdown/src/TokenSource.d.ts.map +0 -1
  191. package/esm/extension-markdown/src/TokenSource.js +0 -39
  192. package/esm/extension-markdown/src/mdToPmConverter.d.ts +0 -5
  193. package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +0 -1
  194. package/esm/extension-markdown/src/mdToPmConverter.js +0 -111
  195. package/esm/extension-markdown/src/pmToMdConverter.d.ts +0 -16
  196. package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +0 -1
  197. package/esm/extension-markdown/src/pmToMdConverter.js +0 -433
  198. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +0 -4
  199. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +0 -1
  200. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +0 -151
  201. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +0 -3
  202. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +0 -1
  203. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +0 -34
  204. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +0 -6
  205. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +0 -1
  206. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +0 -380
  207. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +0 -3
  208. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +0 -1
  209. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +0 -323
  210. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +0 -9
  211. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +0 -1
  212. package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +0 -308
  213. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +0 -5
  214. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +0 -1
  215. package/esm/extension-markdown/src/treeSitterTokenizer.js +0 -769
  216. package/esm/extension-markdown/src/types.d.ts +0 -28
  217. package/esm/extension-markdown/src/types.d.ts.map +0 -1
  218. package/esm/extension-markdown/src/types.js +0 -131
  219. package/esm/extension-markdown/src/utils.d.ts +0 -8
  220. package/esm/extension-markdown/src/utils.d.ts.map +0 -1
  221. package/esm/extension-markdown/src/utils.js +0 -86
  222. package/esm/tree-sitter-shim/src/main.d.ts +0 -15
  223. package/esm/tree-sitter-shim/src/main.d.ts.map +0 -1
  224. package/esm/tree-sitter-shim/src/main.js +0 -25
  225. package/esm/tree-sitter-shim/src/tree_sitter/language.d.ts +0 -7
  226. package/esm/tree-sitter-shim/src/tree_sitter/language.d.ts.map +0 -1
  227. package/esm/tree-sitter-shim/src/tree_sitter/language.js +0 -5
  228. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +0 -6
  229. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +0 -1
  230. package/esm/tree-sitter-shim/src/tree_sitter/node.js +0 -1
  231. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +0 -7
  232. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +0 -1
  233. package/esm/tree-sitter-shim/src/tree_sitter/parser.js +0 -5
  234. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +0 -6
  235. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +0 -1
  236. package/esm/tree-sitter-shim/src/tree_sitter/tree.js +0 -1
  237. package/esm/wasm/src/mod.d.ts +0 -12
  238. package/esm/wasm/src/mod.d.ts.map +0 -1
  239. package/esm/wasm/src/mod.js +0 -48
  240. package/esm/wasm/wasm.d.ts +0 -138
  241. package/esm/wasm/wasm.d.ts.map +0 -1
  242. package/esm/wasm/wasm.js +0 -120
  243. /package/esm/{extension-codejar/src/Decorator.d.ts → Decorator.d.ts} +0 -0
  244. /package/esm/{extension-codejar/src/Decorator.js → Decorator.js} +0 -0
  245. /package/esm/{extension-codejar/src/codeJarLineNumbers.d.ts → codeJarLineNumbers.d.ts} +0 -0
  246. /package/esm/{extension-codejar/src/codeJarLineNumbers.js → codeJarLineNumbers.js} +0 -0
  247. /package/esm/{extension-codejar/src/utils.d.ts → utils.d.ts} +0 -0
  248. /package/esm/{extension-codejar/src/utils.js → utils.js} +0 -0
@@ -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"}
@@ -1,100 +0,0 @@
1
- function findFirstLetterPosition(node, startPos) {
2
- let firstLetterPos = -1;
3
- let textLen = 0;
4
- node.descendants((child, posInParent) => {
5
- if (child.isText && child.text && child.text.length > 0) {
6
- firstLetterPos = startPos + posInParent + 1; // First char of first text node
7
- textLen = child.text.length;
8
- return false; // Stop
9
- }
10
- return true;
11
- });
12
- if (firstLetterPos === -1) {
13
- return null;
14
- }
15
- return [firstLetterPos, textLen];
16
- }
17
- export class PositionMapper {
18
- constructor(editor, rawTextMap) {
19
- Object.defineProperty(this, "rawTextMap", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: rawTextMap
24
- });
25
- Object.defineProperty(this, "rawTextArr", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: void 0
30
- });
31
- Object.defineProperty(this, "doc", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: void 0
36
- });
37
- this.doc = editor.state.doc;
38
- this.rawTextArr = [];
39
- for (const item of rawTextMap) {
40
- if (item.nodeIdx > 0) {
41
- this.rawTextArr.push({
42
- nodeIdx: item.nodeIdx,
43
- maxNodeIdx: item.nodeIdx,
44
- targetPos: item.targetPos,
45
- targetRow: item.targetRow,
46
- targetCol: item.targetCol,
47
- });
48
- }
49
- }
50
- this.rawTextArr.sort((b, a) => b.nodeIdx - a.nodeIdx);
51
- for (let i = 0; i < this.rawTextArr.length; i++) {
52
- const next = i + 1;
53
- if (next < this.rawTextArr.length) {
54
- this.rawTextArr[i].maxNodeIdx = this.rawTextArr[next].nodeIdx - 1;
55
- }
56
- else {
57
- this.rawTextArr[i].maxNodeIdx = this.doc.nodeSize;
58
- }
59
- }
60
- }
61
- toRawTextPos(pos) {
62
- for (let i = 0; i < this.rawTextArr.length; i++) {
63
- const item = this.rawTextArr[i];
64
- if (pos >= item.nodeIdx && pos <= item.maxNodeIdx) {
65
- return item.targetPos + pos - item.nodeIdx;
66
- }
67
- }
68
- return -1;
69
- }
70
- toRawTextLspPos(pos) {
71
- for (let i = 0; i < this.rawTextArr.length; i++) {
72
- const item = this.rawTextArr[i];
73
- if (pos >= item.nodeIdx && pos <= item.maxNodeIdx) {
74
- return {
75
- line: item.targetRow,
76
- character: item.targetCol + pos - item.nodeIdx,
77
- };
78
- }
79
- }
80
- return { line: 0, character: 0 };
81
- }
82
- fromLineChar(line, character) {
83
- for (let i = 0; i < this.rawTextArr.length; i++) {
84
- const item = this.rawTextArr[i];
85
- const len = item.maxNodeIdx - item.nodeIdx + 1;
86
- if (item.targetRow === line) {
87
- if (character >= item.targetCol && character < item.targetCol + len) {
88
- const offset = character - item.targetCol;
89
- return item.nodeIdx + offset;
90
- }
91
- const nextItem = this.rawTextArr[i + 1];
92
- const isLastInRow = !nextItem || nextItem.targetRow > item.targetRow;
93
- if (isLastInRow && character >= item.targetCol + len) {
94
- return item.maxNodeIdx;
95
- }
96
- }
97
- }
98
- return -1;
99
- }
100
- }
@@ -1,11 +0,0 @@
1
- export declare class TokenSource<K> {
2
- private tokens;
3
- private currentPos;
4
- constructor(tokens: Array<K>);
5
- get pos(): number;
6
- iterate(start: number, callback: (token: K, tokenNo: number) => void): void;
7
- append(tokens: Array<K>): number;
8
- trim(pos: number): void;
9
- rewind(tokenNo?: number): void;
10
- }
11
- //# sourceMappingURL=TokenSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TokenSource.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/TokenSource.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW,CAAC,CAAC;IAGZ,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,UAAU,CAAS;gBAEP,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAIpC,IAAI,GAAG,WAEN;IAED,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI;IAWpE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAKvB,IAAI,CAAC,GAAG,EAAE,MAAM;IAIhB,MAAM,CAAC,OAAO,GAAE,MAAW;CAM5B"}
@@ -1,39 +0,0 @@
1
- export class TokenSource {
2
- constructor(tokens) {
3
- Object.defineProperty(this, "tokens", {
4
- enumerable: true,
5
- configurable: true,
6
- writable: true,
7
- value: tokens
8
- });
9
- Object.defineProperty(this, "currentPos", {
10
- enumerable: true,
11
- configurable: true,
12
- writable: true,
13
- value: void 0
14
- });
15
- this.currentPos = 0;
16
- }
17
- get pos() {
18
- return this.currentPos;
19
- }
20
- iterate(start, callback) {
21
- for (this.currentPos = start; this.currentPos < this.tokens.length; this.currentPos++) {
22
- const token = this.tokens[this.currentPos];
23
- callback(token, this.currentPos);
24
- }
25
- }
26
- append(tokens) {
27
- this.tokens.push(...tokens);
28
- return this.tokens.length - tokens.length;
29
- }
30
- trim(pos) {
31
- this.tokens.splice(pos);
32
- }
33
- rewind(tokenNo = -1) {
34
- if (tokenNo < 0) {
35
- throw new RangeError('Invalid rewind pos: ' + tokenNo);
36
- }
37
- this.currentPos = tokenNo;
38
- }
39
- }
@@ -1,5 +0,0 @@
1
- import { Node, Schema } from 'prosemirror-model';
2
- import { MdConfig } from './ExtensionMarkdown.js';
3
- export declare function mdToPmConverter(buffer: Uint8Array, config: MdConfig, schema: Schema): Promise<Node>;
4
- export declare function mdToPmConverterText(content: string, config: MdConfig, schema: Schema): Promise<Node>;
5
- //# sourceMappingURL=mdToPmConverter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mdToPmConverter.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/mdToPmConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAelD,wBAAsB,eAAe,CACnC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA2Gf"}
@@ -1,111 +0,0 @@
1
- import { DOMParser } from 'prosemirror-model';
2
- import { elementFromString } from '../../extension-basic-editor/src/ExtensionHtml.js';
3
- import { MarkdownParser } from './MarkdownParser.js';
4
- import { sitterTokenizer } from './treeSitterTokenizer.js';
5
- function listIsTight(tokens, i) {
6
- while (++i < tokens.length) {
7
- if (tokens[i].type != 'list_item_open')
8
- return tokens[i].hidden;
9
- }
10
- return false;
11
- }
12
- export async function mdToPmConverter(buffer, config, schema) {
13
- const content = new TextDecoder().decode(buffer);
14
- return mdToPmConverterText(content, config, schema);
15
- }
16
- export async function mdToPmConverterText(content, config, schema) {
17
- const tokenizer = await sitterTokenizer(config.cdnUrl);
18
- const defaultMarkdownParser = new MarkdownParser(schema, tokenizer, {
19
- frontmatter: {
20
- node: 'frontmatter',
21
- },
22
- blockquote: { block: 'blockquote' },
23
- paragraph: { block: 'paragraph' },
24
- task_item: { block: 'task_item' },
25
- task_list: {
26
- block: 'task_list',
27
- },
28
- list_item: { block: 'list_item' },
29
- bullet_list: {
30
- block: 'bullet_list',
31
- getAttrs: (_, tokens, i) => ({ tight: listIsTight(tokens, i) }),
32
- },
33
- ordered_list: {
34
- block: 'ordered_list',
35
- getAttrs: (tok, tokens, i) => ({
36
- start: +tok.attrGet('start') || 1,
37
- tight: listIsTight(tokens, i),
38
- }),
39
- },
40
- dl: {
41
- block: 'dl',
42
- },
43
- dt: {
44
- block: 'dt',
45
- },
46
- dd: {
47
- block: 'dd',
48
- },
49
- heading: {
50
- block: 'heading',
51
- getAttrs: (tok) => ({ level: +tok.tag.slice(1) }),
52
- },
53
- code_block: { block: 'code_block', noCloseToken: true },
54
- fence: {
55
- block: 'code_block',
56
- getAttrs: (tok) => ({ lang: tok.attrGet('lang') || undefined }),
57
- noCloseToken: true,
58
- },
59
- hr: { node: 'hr' },
60
- image: {
61
- node: 'image',
62
- getAttrs: (tok) => {
63
- const firstChild = tok.children ? tok.children[0] : undefined;
64
- return {
65
- src: tok.attrGet('src'),
66
- title: tok.attrGet('title') || null,
67
- alt: firstChild?.content || null,
68
- };
69
- },
70
- },
71
- hardbreak: { node: 'br' },
72
- em: { mark: 'em' },
73
- underline: { mark: 'underline' },
74
- strong: { mark: 'strong' },
75
- strike: { mark: 'strike' },
76
- link: {
77
- mark: 'link',
78
- getAttrs: (tok) => ({
79
- href: tok.attrGet('href'),
80
- title: tok.attrGet('title') || null,
81
- }),
82
- },
83
- code: { mark: 'code' },
84
- html_block: {
85
- custom: (state, token, tokens, i) => {
86
- const parser = DOMParser.fromSchema(schema);
87
- const parsed = parser.parse(elementFromString(token.content));
88
- // state.importNodes(parsed.children); // breaks lsptoy example
89
- },
90
- },
91
- footnote_ref: {
92
- block: 'code_block',
93
- },
94
- table: {
95
- block: 'table',
96
- },
97
- tr: {
98
- block: 'table_row',
99
- },
100
- td: {
101
- block: 'table_cell',
102
- },
103
- th: {
104
- block: 'table_header',
105
- },
106
- thead: {
107
- ignore: true,
108
- },
109
- });
110
- return defaultMarkdownParser.parse(content);
111
- }
@@ -1,16 +0,0 @@
1
- import { Node, Schema } from 'prosemirror-model';
2
- import { type CoreEditor, RawTextResult, SourceMap } from '../../editor/src/mod.js';
3
- import { MdConfig } from './ExtensionMarkdown.js';
4
- export interface MdContext {
5
- meta: Record<string, any>;
6
- }
7
- export declare function pmToMdConverter(document: Node, config: MdConfig, schema: Schema, editor: CoreEditor): Promise<Uint8Array>;
8
- export interface MarkdownResult extends RawTextResult {
9
- debugMap: Record<number, {
10
- targetRow: number;
11
- targetCol: number;
12
- }>;
13
- sourceMap?: SourceMap;
14
- }
15
- export declare function syncPmToMdConverter(document: Node, config: MdConfig, schema: Schema, editor: CoreEditor): MarkdownResult;
16
- //# sourceMappingURL=pmToMdConverter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pmToMdConverter.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/pmToMdConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIjE,OAAO,EACL,KAAK,UAAU,EAIf,aAAa,EACb,SAAS,EACV,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AA+ClD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B;AAkCD,wBAAsB,eAAe,CACnC,QAAQ,EAAE,IAAI,EACd,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,IAAI,EACd,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,GACjB,cAAc,CA+ahB"}