@latentic/live-markdown 0.3.1 → 0.4.0

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 (341) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +2 -2
  3. package/dist/chunk-V6TY7KAL.js +8 -0
  4. package/dist/chunk-V6TY7KAL.js.map +1 -0
  5. package/dist/codemirror/CodeMirrorMarkdownEditor.d.ts +106 -0
  6. package/dist/codemirror/CodeMirrorMarkdownEditor.js +482 -0
  7. package/dist/codemirror/CodeMirrorMarkdownEditor.js.map +1 -0
  8. package/dist/codemirror/byteOffset.d.ts +17 -0
  9. package/dist/codemirror/byteOffset.js +19 -0
  10. package/dist/codemirror/byteOffset.js.map +1 -0
  11. package/dist/codemirror/caretLayer.d.ts +19 -0
  12. package/dist/codemirror/caretLayer.js +44 -0
  13. package/dist/codemirror/caretLayer.js.map +1 -0
  14. package/dist/codemirror/clipboard/copyRich.d.ts +37 -0
  15. package/dist/codemirror/clipboard/copyRich.js +72 -0
  16. package/dist/codemirror/clipboard/copyRich.js.map +1 -0
  17. package/dist/codemirror/clipboard/htmlToMarkdown.d.ts +20 -0
  18. package/dist/codemirror/clipboard/htmlToMarkdown.js +91 -0
  19. package/dist/codemirror/clipboard/htmlToMarkdown.js.map +1 -0
  20. package/dist/codemirror/clipboard/pasteMarkdown.d.ts +18 -0
  21. package/dist/codemirror/clipboard/pasteMarkdown.js +41 -0
  22. package/dist/codemirror/clipboard/pasteMarkdown.js.map +1 -0
  23. package/dist/codemirror/code/codeHighlight.d.ts +13 -0
  24. package/dist/codemirror/code/codeHighlight.js +15 -0
  25. package/dist/codemirror/code/codeHighlight.js.map +1 -0
  26. package/dist/codemirror/code/codeLangAffordance.d.ts +17 -0
  27. package/dist/codemirror/code/codeLangAffordance.js +80 -0
  28. package/dist/codemirror/code/codeLangAffordance.js.map +1 -0
  29. package/dist/codemirror/code/codeLanguageMenu.d.ts +40 -0
  30. package/dist/codemirror/code/codeLanguageMenu.js +184 -0
  31. package/dist/codemirror/code/codeLanguageMenu.js.map +1 -0
  32. package/dist/codemirror/code/codePalette.d.ts +39 -0
  33. package/dist/codemirror/code/codePalette.js +53 -0
  34. package/dist/codemirror/code/codePalette.js.map +1 -0
  35. package/dist/codemirror/code/fenceAutoClose.d.ts +30 -0
  36. package/dist/codemirror/code/fenceAutoClose.js +171 -0
  37. package/dist/codemirror/code/fenceAutoClose.js.map +1 -0
  38. package/dist/codemirror/code/fenceCaretGuard.d.ts +28 -0
  39. package/dist/codemirror/code/fenceCaretGuard.js +66 -0
  40. package/dist/codemirror/code/fenceCaretGuard.js.map +1 -0
  41. package/dist/codemirror/code/fenceDeleteGuards.d.ts +22 -0
  42. package/dist/codemirror/code/fenceDeleteGuards.js +105 -0
  43. package/dist/codemirror/code/fenceDeleteGuards.js.map +1 -0
  44. package/dist/codemirror/code/fenceTabIndent.d.ts +8 -0
  45. package/dist/codemirror/code/fenceTabIndent.js +50 -0
  46. package/dist/codemirror/code/fenceTabIndent.js.map +1 -0
  47. package/dist/codemirror/code/highlightFence.d.ts +25 -0
  48. package/dist/codemirror/code/highlightFence.js +45 -0
  49. package/dist/codemirror/code/highlightFence.js.map +1 -0
  50. package/dist/codemirror/code/index.d.ts +9 -0
  51. package/dist/codemirror/code/index.js +8 -0
  52. package/dist/codemirror/code/index.js.map +1 -0
  53. package/dist/codemirror/core/codeContext.d.ts +32 -0
  54. package/dist/codemirror/core/codeContext.js +22 -0
  55. package/dist/codemirror/core/codeContext.js.map +1 -0
  56. package/dist/codemirror/core/editorTestHarness.d.ts +31 -0
  57. package/dist/codemirror/core/editorTestHarness.js +69 -0
  58. package/dist/codemirror/core/editorTestHarness.js.map +1 -0
  59. package/dist/codemirror/core/editorTheme.d.ts +39 -0
  60. package/dist/codemirror/core/editorTheme.js +498 -0
  61. package/dist/codemirror/core/editorTheme.js.map +1 -0
  62. package/dist/codemirror/core/hostFacets.d.ts +58 -0
  63. package/dist/codemirror/core/hostFacets.js +27 -0
  64. package/dist/codemirror/core/hostFacets.js.map +1 -0
  65. package/dist/codemirror/core/hrWidget.d.ts +22 -0
  66. package/dist/codemirror/core/hrWidget.js +22 -0
  67. package/dist/codemirror/core/hrWidget.js.map +1 -0
  68. package/dist/codemirror/core/htmlEscape.d.ts +6 -0
  69. package/dist/codemirror/core/htmlEscape.js +12 -0
  70. package/dist/codemirror/core/htmlEscape.js.map +1 -0
  71. package/dist/codemirror/core/index.d.ts +13 -0
  72. package/dist/codemirror/core/index.js +9 -0
  73. package/dist/codemirror/core/index.js.map +1 -0
  74. package/dist/codemirror/core/inlineScan.d.ts +49 -0
  75. package/dist/codemirror/core/inlineScan.js +31 -0
  76. package/dist/codemirror/core/inlineScan.js.map +1 -0
  77. package/dist/codemirror/core/lineStructure.d.ts +47 -0
  78. package/dist/codemirror/core/lineStructure.js +64 -0
  79. package/dist/codemirror/core/lineStructure.js.map +1 -0
  80. package/dist/codemirror/core/linkResolution.d.ts +36 -0
  81. package/dist/codemirror/core/linkResolution.js +58 -0
  82. package/dist/codemirror/core/linkResolution.js.map +1 -0
  83. package/dist/codemirror/core/paint.d.ts +118 -0
  84. package/dist/codemirror/core/paint.js +42 -0
  85. package/dist/codemirror/core/paint.js.map +1 -0
  86. package/dist/codemirror/core/parseToEnd.d.ts +24 -0
  87. package/dist/codemirror/core/parseToEnd.js +38 -0
  88. package/dist/codemirror/core/parseToEnd.js.map +1 -0
  89. package/dist/codemirror/core/plugin.d.ts +32 -0
  90. package/dist/codemirror/core/plugin.js +161 -0
  91. package/dist/codemirror/core/plugin.js.map +1 -0
  92. package/dist/codemirror/core/registry.d.ts +38 -0
  93. package/dist/codemirror/core/registry.js +133 -0
  94. package/dist/codemirror/core/registry.js.map +1 -0
  95. package/dist/codemirror/core/testKeys.d.ts +17 -0
  96. package/dist/codemirror/core/testKeys.js +11 -0
  97. package/dist/codemirror/core/testKeys.js.map +1 -0
  98. package/dist/codemirror/core/treeAt.d.ts +31 -0
  99. package/dist/codemirror/core/treeAt.js +10 -0
  100. package/dist/codemirror/core/treeAt.js.map +1 -0
  101. package/dist/codemirror/extensions/footnoteExtension.d.ts +9 -0
  102. package/dist/codemirror/extensions/footnoteExtension.js +14 -0
  103. package/dist/codemirror/extensions/footnoteExtension.js.map +1 -0
  104. package/dist/codemirror/extensions/highlightExtension.d.ts +9 -0
  105. package/dist/codemirror/extensions/highlightExtension.js +14 -0
  106. package/dist/codemirror/extensions/highlightExtension.js.map +1 -0
  107. package/dist/codemirror/extensions/index.d.ts +12 -0
  108. package/dist/codemirror/extensions/index.js +19 -0
  109. package/dist/codemirror/extensions/index.js.map +1 -0
  110. package/dist/codemirror/extensions/loader.d.ts +24 -0
  111. package/dist/codemirror/extensions/loader.js +33 -0
  112. package/dist/codemirror/extensions/loader.js.map +1 -0
  113. package/dist/codemirror/extensions/mathExtension.d.ts +9 -0
  114. package/dist/codemirror/extensions/mathExtension.js +14 -0
  115. package/dist/codemirror/extensions/mathExtension.js.map +1 -0
  116. package/dist/codemirror/extensions/mermaidExtension.d.ts +9 -0
  117. package/dist/codemirror/extensions/mermaidExtension.js +12 -0
  118. package/dist/codemirror/extensions/mermaidExtension.js.map +1 -0
  119. package/dist/codemirror/extensions/tableExtension.d.ts +13 -0
  120. package/dist/codemirror/extensions/tableExtension.js +39 -0
  121. package/dist/codemirror/extensions/tableExtension.js.map +1 -0
  122. package/dist/codemirror/extensions/types.d.ts +39 -0
  123. package/dist/codemirror/extensions/types.js +1 -0
  124. package/dist/codemirror/extensions/types.js.map +1 -0
  125. package/dist/codemirror/extensions/wikilinkExtension.d.ts +9 -0
  126. package/dist/codemirror/extensions/wikilinkExtension.js +14 -0
  127. package/dist/codemirror/extensions/wikilinkExtension.js.map +1 -0
  128. package/dist/codemirror/features/blockCommandSteps.d.ts +20 -0
  129. package/dist/codemirror/features/blockCommandSteps.js +83 -0
  130. package/dist/codemirror/features/blockCommandSteps.js.map +1 -0
  131. package/dist/codemirror/footnote/footnotePlugin.d.ts +10 -0
  132. package/dist/codemirror/footnote/footnotePlugin.js +78 -0
  133. package/dist/codemirror/footnote/footnotePlugin.js.map +1 -0
  134. package/dist/codemirror/footnote/footnoteScanRule.d.ts +9 -0
  135. package/dist/codemirror/footnote/footnoteScanRule.js +12 -0
  136. package/dist/codemirror/footnote/footnoteScanRule.js.map +1 -0
  137. package/dist/codemirror/footnote/index.d.ts +2 -0
  138. package/dist/codemirror/footnote/index.js +2 -0
  139. package/dist/codemirror/footnote/index.js.map +1 -0
  140. package/dist/codemirror/format/blockCommands.d.ts +17 -0
  141. package/dist/codemirror/format/blockCommands.js +176 -0
  142. package/dist/codemirror/format/blockCommands.js.map +1 -0
  143. package/dist/codemirror/format/formatCommands.d.ts +11 -0
  144. package/dist/codemirror/format/formatCommands.js +132 -0
  145. package/dist/codemirror/format/formatCommands.js.map +1 -0
  146. package/dist/codemirror/format/index.d.ts +4 -0
  147. package/dist/codemirror/format/index.js +3 -0
  148. package/dist/codemirror/format/index.js.map +1 -0
  149. package/dist/codemirror/highlight/highlightPlugin.d.ts +10 -0
  150. package/dist/codemirror/highlight/highlightPlugin.js +66 -0
  151. package/dist/codemirror/highlight/highlightPlugin.js.map +1 -0
  152. package/dist/codemirror/highlight/highlightScanRule.d.ts +8 -0
  153. package/dist/codemirror/highlight/highlightScanRule.js +12 -0
  154. package/dist/codemirror/highlight/highlightScanRule.js.map +1 -0
  155. package/dist/codemirror/highlight/index.d.ts +2 -0
  156. package/dist/codemirror/highlight/index.js +2 -0
  157. package/dist/codemirror/highlight/index.js.map +1 -0
  158. package/dist/codemirror/html/htmlWidget.d.ts +23 -0
  159. package/dist/codemirror/html/htmlWidget.js +67 -0
  160. package/dist/codemirror/html/htmlWidget.js.map +1 -0
  161. package/dist/codemirror/html/index.d.ts +4 -0
  162. package/dist/codemirror/html/index.js +2 -0
  163. package/dist/codemirror/html/index.js.map +1 -0
  164. package/dist/codemirror/image/imageActionMenu.d.ts +14 -0
  165. package/dist/codemirror/image/imageActionMenu.js +112 -0
  166. package/dist/codemirror/image/imageActionMenu.js.map +1 -0
  167. package/dist/codemirror/image/imageEditEvent.d.ts +20 -0
  168. package/dist/codemirror/image/imageEditEvent.js +6 -0
  169. package/dist/codemirror/image/imageEditEvent.js.map +1 -0
  170. package/dist/codemirror/image/imageInsertHandlers.d.ts +13 -0
  171. package/dist/codemirror/image/imageInsertHandlers.js +64 -0
  172. package/dist/codemirror/image/imageInsertHandlers.js.map +1 -0
  173. package/dist/codemirror/image/imageWidget.d.ts +49 -0
  174. package/dist/codemirror/image/imageWidget.js +83 -0
  175. package/dist/codemirror/image/imageWidget.js.map +1 -0
  176. package/dist/codemirror/image/index.d.ts +8 -0
  177. package/dist/codemirror/image/index.js +5 -0
  178. package/dist/codemirror/image/index.js.map +1 -0
  179. package/dist/codemirror/interaction/clickModel.d.ts +43 -0
  180. package/dist/codemirror/interaction/clickModel.js +99 -0
  181. package/dist/codemirror/interaction/clickModel.js.map +1 -0
  182. package/dist/codemirror/interaction/cursorModel.d.ts +10 -0
  183. package/dist/codemirror/interaction/cursorModel.js +58 -0
  184. package/dist/codemirror/interaction/cursorModel.js.map +1 -0
  185. package/dist/codemirror/interaction/deleteNormalizer.d.ts +18 -0
  186. package/dist/codemirror/interaction/deleteNormalizer.js +157 -0
  187. package/dist/codemirror/interaction/deleteNormalizer.js.map +1 -0
  188. package/dist/codemirror/interaction/flankingGuard.d.ts +20 -0
  189. package/dist/codemirror/interaction/flankingGuard.js +48 -0
  190. package/dist/codemirror/interaction/flankingGuard.js.map +1 -0
  191. package/dist/codemirror/interaction/index.d.ts +7 -0
  192. package/dist/codemirror/interaction/index.js +6 -0
  193. package/dist/codemirror/interaction/index.js.map +1 -0
  194. package/dist/codemirror/interaction/visiblePosition.d.ts +43 -0
  195. package/dist/codemirror/interaction/visiblePosition.js +98 -0
  196. package/dist/codemirror/interaction/visiblePosition.js.map +1 -0
  197. package/dist/codemirror/list/bulletWidget.d.ts +61 -0
  198. package/dist/codemirror/list/bulletWidget.js +84 -0
  199. package/dist/codemirror/list/bulletWidget.js.map +1 -0
  200. package/dist/codemirror/list/index.d.ts +4 -0
  201. package/dist/codemirror/list/index.js +3 -0
  202. package/dist/codemirror/list/index.js.map +1 -0
  203. package/dist/codemirror/list/listContinuation.d.ts +28 -0
  204. package/dist/codemirror/list/listContinuation.js +61 -0
  205. package/dist/codemirror/list/listContinuation.js.map +1 -0
  206. package/dist/codemirror/list/listIndent.d.ts +8 -0
  207. package/dist/codemirror/list/listIndent.js +95 -0
  208. package/dist/codemirror/list/listIndent.js.map +1 -0
  209. package/dist/codemirror/list/taskCheckboxWidget.d.ts +42 -0
  210. package/dist/codemirror/list/taskCheckboxWidget.js +47 -0
  211. package/dist/codemirror/list/taskCheckboxWidget.js.map +1 -0
  212. package/dist/codemirror/math/index.d.ts +3 -0
  213. package/dist/codemirror/math/index.js +2 -0
  214. package/dist/codemirror/math/index.js.map +1 -0
  215. package/dist/codemirror/math/mathPlugin.d.ts +10 -0
  216. package/dist/codemirror/math/mathPlugin.js +73 -0
  217. package/dist/codemirror/math/mathPlugin.js.map +1 -0
  218. package/dist/codemirror/math/mathScanRule.d.ts +16 -0
  219. package/dist/codemirror/math/mathScanRule.js +18 -0
  220. package/dist/codemirror/math/mathScanRule.js.map +1 -0
  221. package/dist/codemirror/math/mathWidget.d.ts +15 -0
  222. package/dist/codemirror/math/mathWidget.js +36 -0
  223. package/dist/codemirror/math/mathWidget.js.map +1 -0
  224. package/dist/codemirror/mermaid/index.d.ts +4 -0
  225. package/dist/codemirror/mermaid/index.js +3 -0
  226. package/dist/codemirror/mermaid/index.js.map +1 -0
  227. package/dist/codemirror/mermaid/mermaidPlugin.d.ts +25 -0
  228. package/dist/codemirror/mermaid/mermaidPlugin.js +78 -0
  229. package/dist/codemirror/mermaid/mermaidPlugin.js.map +1 -0
  230. package/dist/codemirror/mermaid/mermaidRender.d.ts +42 -0
  231. package/dist/codemirror/mermaid/mermaidRender.js +136 -0
  232. package/dist/codemirror/mermaid/mermaidRender.js.map +1 -0
  233. package/dist/codemirror/mermaid/mermaidWidget.d.ts +42 -0
  234. package/dist/codemirror/mermaid/mermaidWidget.js +142 -0
  235. package/dist/codemirror/mermaid/mermaidWidget.js.map +1 -0
  236. package/dist/codemirror/selectionLayer.d.ts +43 -0
  237. package/dist/codemirror/selectionLayer.js +135 -0
  238. package/dist/codemirror/selectionLayer.js.map +1 -0
  239. package/dist/codemirror/table/cellDividerWidget.d.ts +9 -0
  240. package/dist/codemirror/table/cellDividerWidget.js +19 -0
  241. package/dist/codemirror/table/cellDividerWidget.js.map +1 -0
  242. package/dist/codemirror/table/index.d.ts +5 -0
  243. package/dist/codemirror/table/index.js +4 -0
  244. package/dist/codemirror/table/index.js.map +1 -0
  245. package/dist/codemirror/table/tableArmed.d.ts +27 -0
  246. package/dist/codemirror/table/tableArmed.js +43 -0
  247. package/dist/codemirror/table/tableArmed.js.map +1 -0
  248. package/dist/codemirror/table/tableCell.d.ts +19 -0
  249. package/dist/codemirror/table/tableCell.js +15 -0
  250. package/dist/codemirror/table/tableCell.js.map +1 -0
  251. package/dist/codemirror/table/tableCellNav.d.ts +51 -0
  252. package/dist/codemirror/table/tableCellNav.js +47 -0
  253. package/dist/codemirror/table/tableCellNav.js.map +1 -0
  254. package/dist/codemirror/table/tableContextMenu.d.ts +22 -0
  255. package/dist/codemirror/table/tableContextMenu.js +139 -0
  256. package/dist/codemirror/table/tableContextMenu.js.map +1 -0
  257. package/dist/codemirror/table/tableEditCommands.d.ts +29 -0
  258. package/dist/codemirror/table/tableEditCommands.js +86 -0
  259. package/dist/codemirror/table/tableEditCommands.js.map +1 -0
  260. package/dist/codemirror/table/tableExcerpt.d.ts +29 -0
  261. package/dist/codemirror/table/tableExcerpt.js +34 -0
  262. package/dist/codemirror/table/tableExcerpt.js.map +1 -0
  263. package/dist/codemirror/table/tableField.d.ts +6 -0
  264. package/dist/codemirror/table/tableField.js +37 -0
  265. package/dist/codemirror/table/tableField.js.map +1 -0
  266. package/dist/codemirror/table/tableGeometry.d.ts +33 -0
  267. package/dist/codemirror/table/tableGeometry.js +28 -0
  268. package/dist/codemirror/table/tableGeometry.js.map +1 -0
  269. package/dist/codemirror/table/tableInline.d.ts +37 -0
  270. package/dist/codemirror/table/tableInline.js +105 -0
  271. package/dist/codemirror/table/tableInline.js.map +1 -0
  272. package/dist/codemirror/table/tableModel.d.ts +45 -0
  273. package/dist/codemirror/table/tableModel.js +98 -0
  274. package/dist/codemirror/table/tableModel.js.map +1 -0
  275. package/dist/codemirror/tablev2/bridgeRules.d.ts +48 -0
  276. package/dist/codemirror/tablev2/bridgeRules.js +42 -0
  277. package/dist/codemirror/tablev2/bridgeRules.js.map +1 -0
  278. package/dist/codemirror/tablev2/cellEditingSurface.d.ts +79 -0
  279. package/dist/codemirror/tablev2/cellEditingSurface.js +70 -0
  280. package/dist/codemirror/tablev2/cellEditingSurface.js.map +1 -0
  281. package/dist/codemirror/tablev2/cellText.d.ts +11 -0
  282. package/dist/codemirror/tablev2/cellText.js +12 -0
  283. package/dist/codemirror/tablev2/cellText.js.map +1 -0
  284. package/dist/codemirror/tablev2/inlineCellSurface.d.ts +38 -0
  285. package/dist/codemirror/tablev2/inlineCellSurface.js +162 -0
  286. package/dist/codemirror/tablev2/inlineCellSurface.js.map +1 -0
  287. package/dist/codemirror/tablev2/overlayCellSurface.d.ts +36 -0
  288. package/dist/codemirror/tablev2/overlayCellSurface.js +150 -0
  289. package/dist/codemirror/tablev2/overlayCellSurface.js.map +1 -0
  290. package/dist/codemirror/tablev2/tableEditingSteps.d.ts +12 -0
  291. package/dist/codemirror/tablev2/tableEditingSteps.js +518 -0
  292. package/dist/codemirror/tablev2/tableEditingSteps.js.map +1 -0
  293. package/dist/codemirror/tablev2/tableV2HoverControls.d.ts +23 -0
  294. package/dist/codemirror/tablev2/tableV2HoverControls.js +89 -0
  295. package/dist/codemirror/tablev2/tableV2HoverControls.js.map +1 -0
  296. package/dist/codemirror/tablev2/tableV2Interaction.d.ts +29 -0
  297. package/dist/codemirror/tablev2/tableV2Interaction.js +224 -0
  298. package/dist/codemirror/tablev2/tableV2Interaction.js.map +1 -0
  299. package/dist/codemirror/tablev2/tableV2Selection.d.ts +45 -0
  300. package/dist/codemirror/tablev2/tableV2Selection.js +81 -0
  301. package/dist/codemirror/tablev2/tableV2Selection.js.map +1 -0
  302. package/dist/codemirror/tablev2/tableV2Sync.d.ts +13 -0
  303. package/dist/codemirror/tablev2/tableV2Sync.js +13 -0
  304. package/dist/codemirror/tablev2/tableV2Sync.js.map +1 -0
  305. package/dist/codemirror/tablev2/tableWidgetV2.d.ts +46 -0
  306. package/dist/codemirror/tablev2/tableWidgetV2.js +139 -0
  307. package/dist/codemirror/tablev2/tableWidgetV2.js.map +1 -0
  308. package/dist/codemirror/updateBus.d.ts +29 -0
  309. package/dist/codemirror/updateBus.js +26 -0
  310. package/dist/codemirror/updateBus.js.map +1 -0
  311. package/dist/codemirror/wikilink/index.d.ts +3 -0
  312. package/dist/codemirror/wikilink/index.js +2 -0
  313. package/dist/codemirror/wikilink/index.js.map +1 -0
  314. package/dist/codemirror/wikilink/wikilinkPlugin.d.ts +40 -0
  315. package/dist/codemirror/wikilink/wikilinkPlugin.js +89 -0
  316. package/dist/codemirror/wikilink/wikilinkPlugin.js.map +1 -0
  317. package/dist/codemirror/wikilink/wikilinkScanRule.d.ts +9 -0
  318. package/dist/codemirror/wikilink/wikilinkScanRule.js +13 -0
  319. package/dist/codemirror/wikilink/wikilinkScanRule.js.map +1 -0
  320. package/dist/frontmatter.d.ts +79 -0
  321. package/dist/frontmatter.js +58 -0
  322. package/dist/frontmatter.js.map +1 -0
  323. package/dist/imageInsert.d.ts +66 -0
  324. package/dist/imageInsert.js +111 -0
  325. package/dist/imageInsert.js.map +1 -0
  326. package/dist/imageSrcResolver.d.ts +55 -0
  327. package/dist/imageSrcResolver.js +49 -0
  328. package/dist/imageSrcResolver.js.map +1 -0
  329. package/dist/index.d.ts +35 -880
  330. package/dist/index.js +128 -5996
  331. package/dist/index.js.map +1 -1
  332. package/dist/links/wikilink.d.ts +26 -0
  333. package/dist/links/wikilink.js +54 -0
  334. package/dist/links/wikilink.js.map +1 -0
  335. package/dist/links/workspaceLink.d.ts +34 -0
  336. package/dist/links/workspaceLink.js +60 -0
  337. package/dist/links/workspaceLink.js.map +1 -0
  338. package/dist/types.d.ts +20 -0
  339. package/dist/types.js +1 -0
  340. package/dist/types.js.map +1 -0
  341. package/package.json +7 -3
@@ -0,0 +1,47 @@
1
+ import "../../chunk-V6TY7KAL.js";
2
+ function rowCount(model) {
3
+ return 1 + model.data.rows.length;
4
+ }
5
+ function cellAt(model, row, col) {
6
+ const cells = row === 0 ? model.data.header : model.data.rows[row - 1];
7
+ return cells?.[col] ?? null;
8
+ }
9
+ function positionOf(model, from) {
10
+ for (let row = 0; row < rowCount(model); row++) {
11
+ const cells = row === 0 ? model.data.header : model.data.rows[row - 1];
12
+ const col = cells.findIndex((cell) => cell.from === from);
13
+ if (col >= 0) return { row, col };
14
+ }
15
+ return null;
16
+ }
17
+ function stepCell(model, row, col, dir) {
18
+ return stepGrid(rowCount(model), model.data.header.length, row, col, dir);
19
+ }
20
+ function stepGrid(rows, cols, row, col, dir) {
21
+ switch (dir) {
22
+ case "next":
23
+ if (col + 1 < cols) return { kind: "cell", row, col: col + 1 };
24
+ if (row + 1 < rows) return { kind: "cell", row: row + 1, col: 0 };
25
+ return { kind: "exit", edge: "after" };
26
+ case "prev":
27
+ if (col > 0) return { kind: "cell", row, col: col - 1 };
28
+ if (row > 0) return { kind: "cell", row: row - 1, col: cols - 1 };
29
+ return { kind: "exit", edge: "before" };
30
+ case "down":
31
+ return row + 1 < rows ? { kind: "cell", row: row + 1, col } : { kind: "exit", edge: "below" };
32
+ case "up":
33
+ return row > 0 ? { kind: "cell", row: row - 1, col } : { kind: "exit", edge: "above" };
34
+ }
35
+ }
36
+ function exitCaretPos(edge, from, to, docLength) {
37
+ return edge === "above" || edge === "before" ? Math.max(0, from - 1) : Math.min(to + 1, docLength);
38
+ }
39
+ export {
40
+ cellAt,
41
+ exitCaretPos,
42
+ positionOf,
43
+ rowCount,
44
+ stepCell,
45
+ stepGrid
46
+ };
47
+ //# sourceMappingURL=tableCellNav.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemirror/table/tableCellNav.ts"],"sourcesContent":["import { type TableModel } from \"./tableModel\";\n\n/**\n * Pure geometry for moving the caret between table cells. A table is rendered as\n * one atomic block whose cells are edited in per-cell subviews; navigation maps\n * a (row, col) + direction to the next cell or to an exit out of the table. Row 0\n * is the header; the `| --- |` delimiter row is not navigable. Kept pure (no\n * EditorView) so the step math is unit-testable; mounting lives in\n * {@link mountCellSubview}.\n */\n\n/** Navigable rows: the header plus every body row. */\nexport function rowCount(model: TableModel): number {\n return 1 + model.data.rows.length;\n}\n\n/** The cell at (row, col) — row 0 is the header — or null when out of range. */\nexport function cellAt(model: TableModel, row: number, col: number) {\n const cells = row === 0 ? model.data.header : model.data.rows[row - 1];\n return cells?.[col] ?? null;\n}\n\n/** The (row, col) of the cell whose source starts at `from`, or null. */\nexport function positionOf(model: TableModel, from: number): { row: number; col: number } | null {\n for (let row = 0; row < rowCount(model); row++) {\n const cells = row === 0 ? model.data.header : model.data.rows[row - 1];\n const col = cells.findIndex((cell) => cell.from === from);\n if (col >= 0) return { row, col };\n }\n return null;\n}\n\nexport type NavDir = \"next\" | \"prev\" | \"up\" | \"down\";\nexport type ExitEdge = \"above\" | \"below\" | \"before\" | \"after\";\nexport type NavTarget =\n | { kind: \"cell\"; row: number; col: number }\n | { kind: \"exit\"; edge: ExitEdge };\n\n/**\n * Where `dir` moves from (row, col): an adjacent cell, or an exit edge when it\n * leaves the table. `next`/`prev` (Tab / shift-Tab, or Left/Right at a cell's\n * text edge) wrap across rows in reading order; `up`/`down` stay in the column.\n */\nexport function stepCell(model: TableModel, row: number, col: number, dir: NavDir): NavTarget {\n return stepGrid(rowCount(model), model.data.header.length, row, col, dir);\n}\n\n/** {@link stepCell} on bare grid dimensions — the tablev2 bridge has the\n * dimensions but no model object. Single home for the step math. */\nexport function stepGrid(\n rows: number,\n cols: number,\n row: number,\n col: number,\n dir: NavDir,\n): NavTarget {\n switch (dir) {\n case \"next\":\n if (col + 1 < cols) return { kind: \"cell\", row, col: col + 1 };\n if (row + 1 < rows) return { kind: \"cell\", row: row + 1, col: 0 };\n return { kind: \"exit\", edge: \"after\" };\n case \"prev\":\n if (col > 0) return { kind: \"cell\", row, col: col - 1 };\n if (row > 0) return { kind: \"cell\", row: row - 1, col: cols - 1 };\n return { kind: \"exit\", edge: \"before\" };\n case \"down\":\n return row + 1 < rows ? { kind: \"cell\", row: row + 1, col } : { kind: \"exit\", edge: \"below\" };\n case \"up\":\n return row > 0 ? { kind: \"cell\", row: row - 1, col } : { kind: \"exit\", edge: \"above\" };\n }\n}\n\n/**\n * Where the caret lands when leaving the table at `edge`. The table is one atomic\n * block spanning [from, to]: a caret at `from` is shoved forward past the whole\n * block by CodeMirror, and a caret at `to` stays on the block's last (hidden) row\n * — either boundary keeps the caret on the grid, so a stray arrow press is then\n * needed to clear it. Stepping one position outward reaches the real neighbouring\n * line: `from - 1` ends the line above, `to + 1` starts the line below (the blank\n * line a GFM table is separated by). Both are clamped to the document.\n */\nexport function exitCaretPos(edge: ExitEdge, from: number, to: number, docLength: number): number {\n return edge === \"above\" || edge === \"before\"\n ? Math.max(0, from - 1)\n : Math.min(to + 1, docLength);\n}\n"],"mappings":";AAYO,SAAS,SAAS,OAA2B;AAClD,SAAO,IAAI,MAAM,KAAK,KAAK;AAC7B;AAGO,SAAS,OAAO,OAAmB,KAAa,KAAa;AAClE,QAAM,QAAQ,QAAQ,IAAI,MAAM,KAAK,SAAS,MAAM,KAAK,KAAK,MAAM,CAAC;AACrE,SAAO,QAAQ,GAAG,KAAK;AACzB;AAGO,SAAS,WAAW,OAAmB,MAAmD;AAC/F,WAAS,MAAM,GAAG,MAAM,SAAS,KAAK,GAAG,OAAO;AAC9C,UAAM,QAAQ,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KAAK,GAAG,SAAS;AAChC;","names":[]}
@@ -0,0 +1,22 @@
1
+ import { EditorView } from '@codemirror/view';
2
+
3
+ interface ShowTableMenuArgs {
4
+ x: number;
5
+ y: number;
6
+ view: EditorView;
7
+ /** A document position inside the target cell (its `data-cell-from`). */
8
+ pos: number;
9
+ /** When provided (tablev2), a "Select row/column/table" group is offered;
10
+ * the host owns the selection state. */
11
+ selectCells?: (axis: "row" | "column" | "table") => void;
12
+ }
13
+ /** The rendered cells of the row or column the target cell sits in — located by
14
+ * the `data-cell-from` the widget stamps on each `<th>`/`<td>`. Used to tint
15
+ * the row/column a menu item is about to act on. Exported for tests. */
16
+ declare function targetCells(view: EditorView, pos: number, axis: "row" | "column"): HTMLElement[];
17
+ /** Right-click menu over a table cell: insert/delete rows and columns. Each item
18
+ * runs the matching {@link tableEditCommands} builder against the cell position
19
+ * and dispatches the change. */
20
+ declare function showTableMenu(args: ShowTableMenuArgs): void;
21
+
22
+ export { showTableMenu, targetCells };
@@ -0,0 +1,139 @@
1
+ import "../../chunk-V6TY7KAL.js";
2
+ import {
3
+ addColumnAfter,
4
+ addColumnBefore,
5
+ addRowAbove,
6
+ addRowBelow,
7
+ deleteColumn,
8
+ deleteRow
9
+ } from "./tableEditCommands.js";
10
+ import { commentOnExcerptFacet } from "../core/hostFacets.js";
11
+ import { columnExcerptAt, rowExcerptAt } from "./tableExcerpt.js";
12
+ const HOVER_CLASS = "cm-table-cell--hover";
13
+ const COMMENTING_CLASS = "cm-table-cell--commenting";
14
+ function targetCells(view, pos, axis) {
15
+ const cell = view.dom.querySelector(`[data-cell-from="${pos}"]`);
16
+ if (!(cell instanceof HTMLElement)) return [];
17
+ const row = cell.closest("tr");
18
+ if (!row) return [];
19
+ if (axis === "row") {
20
+ return Array.from(row.querySelectorAll("th, td"));
21
+ }
22
+ const table = cell.closest("table");
23
+ const col = Array.from(row.children).indexOf(cell);
24
+ if (!table || col < 0) return [];
25
+ return Array.from(table.querySelectorAll("tr")).map((tr) => tr.children[col]).filter((el) => el instanceof HTMLElement);
26
+ }
27
+ function showTableMenu(args) {
28
+ const menu = document.createElement("div");
29
+ menu.className = "cm-table-menu";
30
+ menu.setAttribute("role", "menu");
31
+ menu.style.cssText = "position:fixed;z-index:1000;display:flex;flex-direction:column;min-width:12rem;padding:0.25rem 0;background:var(--cds-layer-01,#ffffff);border:0.0625rem solid var(--cds-border-subtle-01,#e0e0e0);border-radius:0.125rem;box-shadow:0 0.25rem 0.75rem rgba(0,0,0,0.15);font:0.875rem/1.4 var(--cds-body-01-font-family,-apple-system,BlinkMacSystemFont,sans-serif);";
32
+ menu.style.left = `${args.x}px`;
33
+ menu.style.top = `${args.y}px`;
34
+ let clearHighlight = null;
35
+ function highlightTarget(axis) {
36
+ clearHighlight?.();
37
+ const cells = targetCells(args.view, args.pos, axis);
38
+ cells.forEach((cell) => cell.classList.add(HOVER_CLASS));
39
+ clearHighlight = () => {
40
+ cells.forEach((cell) => cell.classList.remove(HOVER_CLASS));
41
+ clearHighlight = null;
42
+ };
43
+ }
44
+ function destroy() {
45
+ clearHighlight?.();
46
+ menu.remove();
47
+ document.removeEventListener("mousedown", onOutside, true);
48
+ document.removeEventListener("keydown", onEscape, true);
49
+ }
50
+ function onOutside(event) {
51
+ if (!menu.contains(event.target)) destroy();
52
+ }
53
+ function onEscape(event) {
54
+ if (event.key === "Escape") destroy();
55
+ }
56
+ function addAction(label, run, danger = false) {
57
+ const button = document.createElement("button");
58
+ button.type = "button";
59
+ button.className = danger ? "cm-table-menu__item cm-table-menu__item--danger" : "cm-table-menu__item";
60
+ button.setAttribute("role", "menuitem");
61
+ button.textContent = label;
62
+ button.style.cssText = "appearance:none;background:transparent;border:none;text-align:left;width:100%;padding:0.4rem 0.75rem;cursor:pointer;font:inherit;color:" + (danger ? "var(--cds-text-error,#da1e28)" : "var(--cds-text-primary,#161616)") + ";";
63
+ button.addEventListener("mouseenter", () => {
64
+ button.style.background = "var(--cds-layer-hover-01,#e8e8e8)";
65
+ });
66
+ button.addEventListener("mouseleave", () => {
67
+ button.style.background = "transparent";
68
+ });
69
+ button.addEventListener("click", () => {
70
+ run();
71
+ destroy();
72
+ });
73
+ menu.appendChild(button);
74
+ return button;
75
+ }
76
+ function add(label, command, danger = false) {
77
+ addAction(
78
+ label,
79
+ () => {
80
+ const change = command(args.view.state, args.pos);
81
+ if (change) {
82
+ args.view.dispatch({ changes: change, userEvent: "input.table.structure" });
83
+ args.view.focus();
84
+ }
85
+ },
86
+ danger
87
+ );
88
+ }
89
+ function separator() {
90
+ const sep = document.createElement("div");
91
+ sep.className = "cm-table-menu__sep";
92
+ sep.style.cssText = "height:0.0625rem;margin:0.25rem 0;background:var(--cds-border-subtle-01,#e0e0e0);";
93
+ menu.appendChild(sep);
94
+ }
95
+ const comment = args.view.state.facet(commentOnExcerptFacet);
96
+ if (comment) {
97
+ let commentOn2 = function(axis) {
98
+ const excerpt = (axis === "row" ? rowExcerptAt : columnExcerptAt)(args.view.state, args.pos);
99
+ if (!excerpt) return;
100
+ targetCells(args.view, args.pos, axis).forEach((c) => c.classList.add(COMMENTING_CLASS));
101
+ comment(excerpt, { x: args.x, y: args.y });
102
+ };
103
+ var commentOn = commentOn2;
104
+ const rowItem = addAction("Comment on this row", () => commentOn2("row"));
105
+ rowItem.addEventListener("mouseenter", () => highlightTarget("row"));
106
+ rowItem.addEventListener("mouseleave", () => clearHighlight?.());
107
+ const columnItem = addAction("Comment on this column", () => commentOn2("column"));
108
+ columnItem.addEventListener("mouseenter", () => highlightTarget("column"));
109
+ columnItem.addEventListener("mouseleave", () => clearHighlight?.());
110
+ separator();
111
+ }
112
+ if (args.selectCells) {
113
+ const select = (axis) => () => args.selectCells(axis);
114
+ addAction("Select row", select("row"));
115
+ addAction("Select column", select("column"));
116
+ addAction("Select table", select("table"));
117
+ separator();
118
+ }
119
+ add("Insert row above", addRowAbove);
120
+ add("Insert row below", addRowBelow);
121
+ add("Delete row", deleteRow, true);
122
+ separator();
123
+ add("Insert column left", addColumnBefore);
124
+ add("Insert column right", addColumnAfter);
125
+ add("Delete column", deleteColumn, true);
126
+ document.body.appendChild(menu);
127
+ const rect = menu.getBoundingClientRect();
128
+ if (rect.right > window.innerWidth) menu.style.left = `${args.x - rect.width}px`;
129
+ if (rect.bottom > window.innerHeight) menu.style.top = `${args.y - rect.height}px`;
130
+ setTimeout(() => {
131
+ document.addEventListener("mousedown", onOutside, true);
132
+ document.addEventListener("keydown", onEscape, true);
133
+ }, 0);
134
+ }
135
+ export {
136
+ showTableMenu,
137
+ targetCells
138
+ };
139
+ //# sourceMappingURL=tableContextMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemirror/table/tableContextMenu.ts"],"sourcesContent":["import { type ChangeSpec, type EditorState } from \"@codemirror/state\";\nimport { type EditorView } from \"@codemirror/view\";\n\nimport {\n addColumnAfter,\n addColumnBefore,\n addRowAbove,\n addRowBelow,\n deleteColumn,\n deleteRow,\n} from \"./tableEditCommands\";\nimport { commentOnExcerptFacet } from \"../core/hostFacets\";\nimport { columnExcerptAt, rowExcerptAt } from \"./tableExcerpt\";\n\ntype TableCommand = (state: EditorState, pos: number) => ChangeSpec | null;\n\n/** Previews the row/column a \"Comment on this row/column\" item targets. */\nconst HOVER_CLASS = \"cm-table-cell--hover\";\n/** Held on a row/column's cells (styled like the hover) while the host's comment\n * composer for it is open; the host clears it on close. */\nconst COMMENTING_CLASS = \"cm-table-cell--commenting\";\n\ninterface ShowTableMenuArgs {\n x: number;\n y: number;\n view: EditorView;\n /** A document position inside the target cell (its `data-cell-from`). */\n pos: number;\n /** When provided (tablev2), a \"Select row/column/table\" group is offered;\n * the host owns the selection state. */\n selectCells?: (axis: \"row\" | \"column\" | \"table\") => void;\n}\n\n/** The rendered cells of the row or column the target cell sits in — located by\n * the `data-cell-from` the widget stamps on each `<th>`/`<td>`. Used to tint\n * the row/column a menu item is about to act on. Exported for tests. */\nexport function targetCells(view: EditorView, pos: number, axis: \"row\" | \"column\"): HTMLElement[] {\n const cell = view.dom.querySelector(`[data-cell-from=\"${pos}\"]`);\n if (!(cell instanceof HTMLElement)) return [];\n const row = cell.closest(\"tr\");\n if (!row) return [];\n if (axis === \"row\") {\n return Array.from(row.querySelectorAll<HTMLElement>(\"th, td\"));\n }\n const table = cell.closest(\"table\");\n const col = Array.from(row.children).indexOf(cell);\n if (!table || col < 0) return [];\n return Array.from(table.querySelectorAll<HTMLElement>(\"tr\"))\n .map((tr) => tr.children[col])\n .filter((el): el is HTMLElement => el instanceof HTMLElement);\n}\n\n/** Right-click menu over a table cell: insert/delete rows and columns. Each item\n * runs the matching {@link tableEditCommands} builder against the cell position\n * and dispatches the change. */\nexport function showTableMenu(args: ShowTableMenuArgs): void {\n const menu = document.createElement(\"div\");\n menu.className = \"cm-table-menu\";\n menu.setAttribute(\"role\", \"menu\");\n // Styled inline: the menu mounts on document.body, outside the editor element\n // that CodeMirror scopes its theme styles to, so a stylesheet rule never\n // reaches it. Inline styles always apply.\n menu.style.cssText =\n \"position:fixed;z-index:1000;display:flex;flex-direction:column;min-width:12rem;\" +\n \"padding:0.25rem 0;background:var(--cds-layer-01,#ffffff);\" +\n \"border:0.0625rem solid var(--cds-border-subtle-01,#e0e0e0);border-radius:0.125rem;\" +\n \"box-shadow:0 0.25rem 0.75rem rgba(0,0,0,0.15);\" +\n \"font:0.875rem/1.4 var(--cds-body-01-font-family,-apple-system,BlinkMacSystemFont,sans-serif);\";\n menu.style.left = `${args.x}px`;\n menu.style.top = `${args.y}px`;\n\n // Tint the row/column a menu item targets while it's hovered, so you see what\n // you're about to act on before you click. A theme class on the cells (cleared\n // on leave and on close) — distinct from the persistent `--commenting` class a\n // chosen comment leaves behind for the host to clear.\n let clearHighlight: (() => void) | null = null;\n function highlightTarget(axis: \"row\" | \"column\"): void {\n clearHighlight?.();\n const cells = targetCells(args.view, args.pos, axis);\n cells.forEach((cell) => cell.classList.add(HOVER_CLASS));\n clearHighlight = () => {\n cells.forEach((cell) => cell.classList.remove(HOVER_CLASS));\n clearHighlight = null;\n };\n }\n\n function destroy(): void {\n clearHighlight?.();\n menu.remove();\n document.removeEventListener(\"mousedown\", onOutside, true);\n document.removeEventListener(\"keydown\", onEscape, true);\n }\n function onOutside(event: MouseEvent): void {\n if (!menu.contains(event.target as Node)) destroy();\n }\n function onEscape(event: KeyboardEvent): void {\n if (event.key === \"Escape\") destroy();\n }\n\n function addAction(label: string, run: () => void, danger = false): HTMLButtonElement {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = danger\n ? \"cm-table-menu__item cm-table-menu__item--danger\"\n : \"cm-table-menu__item\";\n button.setAttribute(\"role\", \"menuitem\");\n button.textContent = label;\n button.style.cssText =\n \"appearance:none;background:transparent;border:none;text-align:left;width:100%;\" +\n \"padding:0.4rem 0.75rem;cursor:pointer;font:inherit;color:\" +\n (danger ? \"var(--cds-text-error,#da1e28)\" : \"var(--cds-text-primary,#161616)\") +\n \";\";\n button.addEventListener(\"mouseenter\", () => {\n button.style.background = \"var(--cds-layer-hover-01,#e8e8e8)\";\n });\n button.addEventListener(\"mouseleave\", () => {\n button.style.background = \"transparent\";\n });\n button.addEventListener(\"click\", () => {\n run();\n destroy();\n });\n menu.appendChild(button);\n return button;\n }\n\n /** A structural-edit item: run the command builder and dispatch its change. */\n function add(label: string, command: TableCommand, danger = false): void {\n addAction(\n label,\n () => {\n const change = command(args.view.state, args.pos);\n if (change) {\n args.view.dispatch({ changes: change, userEvent: \"input.table.structure\" });\n args.view.focus();\n }\n },\n danger,\n );\n }\n\n function separator(): void {\n const sep = document.createElement(\"div\");\n sep.className = \"cm-table-menu__sep\";\n sep.style.cssText =\n \"height:0.0625rem;margin:0.25rem 0;background:var(--cds-border-subtle-01,#e0e0e0);\";\n menu.appendChild(sep);\n }\n\n // \"Comment on this row/column\" — only when the host wired the facet (a desktop\n // shell with the comment composer). Hands the row/column off as an excerpt +\n // the click point; the host opens its comment composer there. The chosen\n // row/column keeps the `--commenting` tint until the host closes the composer.\n const comment = args.view.state.facet(commentOnExcerptFacet);\n if (comment) {\n function commentOn(axis: \"row\" | \"column\"): void {\n const excerpt = (axis === \"row\" ? rowExcerptAt : columnExcerptAt)(args.view.state, args.pos);\n if (!excerpt) return;\n targetCells(args.view, args.pos, axis).forEach((c) => c.classList.add(COMMENTING_CLASS));\n comment!(excerpt, { x: args.x, y: args.y });\n }\n const rowItem = addAction(\"Comment on this row\", () => commentOn(\"row\"));\n rowItem.addEventListener(\"mouseenter\", () => highlightTarget(\"row\"));\n rowItem.addEventListener(\"mouseleave\", () => clearHighlight?.());\n const columnItem = addAction(\"Comment on this column\", () => commentOn(\"column\"));\n columnItem.addEventListener(\"mouseenter\", () => highlightTarget(\"column\"));\n columnItem.addEventListener(\"mouseleave\", () => clearHighlight?.());\n separator();\n }\n\n if (args.selectCells) {\n const select = (axis: \"row\" | \"column\" | \"table\") => () => args.selectCells!(axis);\n addAction(\"Select row\", select(\"row\"));\n addAction(\"Select column\", select(\"column\"));\n addAction(\"Select table\", select(\"table\"));\n separator();\n }\n\n add(\"Insert row above\", addRowAbove);\n add(\"Insert row below\", addRowBelow);\n add(\"Delete row\", deleteRow, true);\n separator();\n add(\"Insert column left\", addColumnBefore);\n add(\"Insert column right\", addColumnAfter);\n add(\"Delete column\", deleteColumn, true);\n\n document.body.appendChild(menu);\n\n const rect = menu.getBoundingClientRect();\n if (rect.right > window.innerWidth) menu.style.left = `${args.x - rect.width}px`;\n if (rect.bottom > window.innerHeight) menu.style.top = `${args.y - rect.height}px`;\n\n setTimeout(() => {\n document.addEventListener(\"mousedown\", onOutside, true);\n document.addEventListener(\"keydown\", onEscape, true);\n }, 0);\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,iBAAiB,oBAAoB;AAK9C,MAAM,cAAc;AAGpB,MAAM,mBAAmB;AAgBlB,SAAS,YAAY,MAAkB,KAAa,MAAuC;A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E9E,aAAW,MAAM;AACf,aAAS,iBAAiB,aAAa,WAAW,IAAI;AACtD,aAAS,iBAAiB,WAAW,UAAU,IAAI;AAAA,EACrD,GAAG,CAAC;AACN;","names":["commentOn"]}
@@ -0,0 +1,29 @@
1
+ import { EditorState, ChangeSpec } from '@codemirror/state';
2
+
3
+ /**
4
+ * Insert an empty row below the row at `pos`. From the header or delimiter the
5
+ * new row becomes the first body row (right after the delimiter).
6
+ */
7
+ declare function addRowBelow(state: EditorState, pos: number): ChangeSpec | null;
8
+ /**
9
+ * Insert an empty row above the body row at `pos`. From the header or delimiter
10
+ * it inserts as the first body row.
11
+ */
12
+ declare function addRowAbove(state: EditorState, pos: number): ChangeSpec | null;
13
+ /**
14
+ * Delete the body row at `pos`. A no-op on the header or delimiter (those define
15
+ * the table); deleting the last body row is allowed and leaves an empty-bodied
16
+ * table.
17
+ */
18
+ declare function deleteRow(state: EditorState, pos: number): ChangeSpec | null;
19
+ /** Insert an empty column to the right of the cursor's column. */
20
+ declare function addColumnAfter(state: EditorState, pos: number): ChangeSpec | null;
21
+ /** Insert an empty column to the left of the cursor's column. */
22
+ declare function addColumnBefore(state: EditorState, pos: number): ChangeSpec | null;
23
+ /** Delete the cursor's column from every row. No-op on a single-column table. */
24
+ declare function deleteColumn(state: EditorState, pos: number): ChangeSpec | null;
25
+ /** Remove the whole table at `pos` (its source lines and the line break after
26
+ * them); the surrounding prose is untouched. */
27
+ declare function deleteTable(state: EditorState, pos: number): ChangeSpec | null;
28
+
29
+ export { addColumnAfter, addColumnBefore, addRowAbove, addRowBelow, deleteColumn, deleteRow, deleteTable };
@@ -0,0 +1,86 @@
1
+ import "../../chunk-V6TY7KAL.js";
2
+ import { columnAt, modelAt, pipes } from "./tableGeometry.js";
3
+ function emptyRow(columns) {
4
+ return "|" + " |".repeat(columns);
5
+ }
6
+ function frame(state, model) {
7
+ const header = state.doc.lineAt(model.from);
8
+ return { header, delimiter: state.doc.lineAt(header.to + 1) };
9
+ }
10
+ function addRowBelow(state, pos) {
11
+ const model = modelAt(state, pos);
12
+ if (!model) return null;
13
+ const { delimiter } = frame(state, model);
14
+ const current = state.doc.lineAt(pos);
15
+ const after = current.from <= delimiter.from ? delimiter : current;
16
+ return { from: after.to, insert: "\n" + emptyRow(model.data.header.length) };
17
+ }
18
+ function addRowAbove(state, pos) {
19
+ const model = modelAt(state, pos);
20
+ if (!model) return null;
21
+ const { delimiter } = frame(state, model);
22
+ const current = state.doc.lineAt(pos);
23
+ const row = emptyRow(model.data.header.length);
24
+ if (current.from <= delimiter.from) {
25
+ return { from: delimiter.to, insert: "\n" + row };
26
+ }
27
+ return { from: current.from, insert: row + "\n" };
28
+ }
29
+ function deleteRow(state, pos) {
30
+ const model = modelAt(state, pos);
31
+ if (!model) return null;
32
+ const { delimiter } = frame(state, model);
33
+ const current = state.doc.lineAt(pos);
34
+ if (current.from <= delimiter.from) return null;
35
+ return { from: current.from - 1, to: current.to };
36
+ }
37
+ function insertColumn(state, pos, offset) {
38
+ const model = modelAt(state, pos);
39
+ if (!model) return null;
40
+ const boundary = columnAt(state, pos) + offset;
41
+ const start = state.doc.lineAt(model.from).number;
42
+ const end = state.doc.lineAt(model.to).number;
43
+ const changes = [];
44
+ for (let n = start; n <= end; n++) {
45
+ const line = state.doc.line(n);
46
+ const p = pipes(state, line);
47
+ if (boundary < p.length) {
48
+ changes.push({ from: p[boundary] + 1, insert: n === start + 1 ? " --- |" : " |" });
49
+ }
50
+ }
51
+ return changes.length ? changes : null;
52
+ }
53
+ function addColumnAfter(state, pos) {
54
+ return insertColumn(state, pos, 1);
55
+ }
56
+ function addColumnBefore(state, pos) {
57
+ return insertColumn(state, pos, 0);
58
+ }
59
+ function deleteColumn(state, pos) {
60
+ const model = modelAt(state, pos);
61
+ if (!model || model.data.header.length <= 1) return null;
62
+ const col = columnAt(state, pos);
63
+ const start = state.doc.lineAt(model.from).number;
64
+ const end = state.doc.lineAt(model.to).number;
65
+ const changes = [];
66
+ for (let n = start; n <= end; n++) {
67
+ const p = pipes(state, state.doc.line(n));
68
+ if (col + 1 < p.length) changes.push({ from: p[col], to: p[col + 1] });
69
+ }
70
+ return changes.length ? changes : null;
71
+ }
72
+ function deleteTable(state, pos) {
73
+ const model = modelAt(state, pos);
74
+ if (!model) return null;
75
+ return { from: model.from, to: Math.min(state.doc.length, model.to + 1) };
76
+ }
77
+ export {
78
+ addColumnAfter,
79
+ addColumnBefore,
80
+ addRowAbove,
81
+ addRowBelow,
82
+ deleteColumn,
83
+ deleteRow,
84
+ deleteTable
85
+ };
86
+ //# sourceMappingURL=tableEditCommands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemirror/table/tableEditCommands.ts"],"sourcesContent":["import { type ChangeSpec, type EditorState } from \"@codemirror/state\";\n\nimport { type TableModel } from \"./tableModel\";\nimport { columnAt, modelAt, pipes } from \"./tableGeometry\";\n\n/**\n * Structural table edits — add/remove rows (columns land next) — as pure\n * `ChangeSpec` builders computed from the Lezer tree, never from the rendered\n * DOM. Each takes the document position the action targets (a cell the cursor or\n * a control sits in) and returns the change, or null when `pos` isn't in a table.\n * The rebuilt table widget re-renders from the new source, so there's nothing to\n * keep in sync.\n */\n\n/** An empty body row with `columns` cells: `| | | … |`. */\nfunction emptyRow(columns: number): string {\n return \"|\" + \" |\".repeat(columns);\n}\n\n/** The header + delimiter lines of `model` (the delimiter is the line after the\n * header). */\nfunction frame(state: EditorState, model: TableModel) {\n const header = state.doc.lineAt(model.from);\n return { header, delimiter: state.doc.lineAt(header.to + 1) };\n}\n\n/**\n * Insert an empty row below the row at `pos`. From the header or delimiter the\n * new row becomes the first body row (right after the delimiter).\n */\nexport function addRowBelow(state: EditorState, pos: number): ChangeSpec | null {\n const model = modelAt(state, pos);\n if (!model) return null;\n const { delimiter } = frame(state, model);\n const current = state.doc.lineAt(pos);\n const after = current.from <= delimiter.from ? delimiter : current;\n return { from: after.to, insert: \"\\n\" + emptyRow(model.data.header.length) };\n}\n\n/**\n * Insert an empty row above the body row at `pos`. From the header or delimiter\n * it inserts as the first body row.\n */\nexport function addRowAbove(state: EditorState, pos: number): ChangeSpec | null {\n const model = modelAt(state, pos);\n if (!model) return null;\n const { delimiter } = frame(state, model);\n const current = state.doc.lineAt(pos);\n const row = emptyRow(model.data.header.length);\n if (current.from <= delimiter.from) {\n return { from: delimiter.to, insert: \"\\n\" + row };\n }\n return { from: current.from, insert: row + \"\\n\" };\n}\n\n/**\n * Delete the body row at `pos`. A no-op on the header or delimiter (those define\n * the table); deleting the last body row is allowed and leaves an empty-bodied\n * table.\n */\nexport function deleteRow(state: EditorState, pos: number): ChangeSpec | null {\n const model = modelAt(state, pos);\n if (!model) return null;\n const { delimiter } = frame(state, model);\n const current = state.doc.lineAt(pos);\n if (current.from <= delimiter.from) return null;\n // Take the line and the newline that precedes it, joining its neighbours.\n return { from: current.from - 1, to: current.to };\n}\n\n/**\n * Insert an empty column at the pipe boundary `offset` past the cursor's column\n * (1 = to its right, 0 = to its left), in every row. The delimiter row gets a\n * `---` cell, content rows an empty one.\n */\nfunction insertColumn(state: EditorState, pos: number, offset: 0 | 1): ChangeSpec | null {\n const model = modelAt(state, pos);\n if (!model) return null;\n const boundary = columnAt(state, pos) + offset;\n const start = state.doc.lineAt(model.from).number;\n const end = state.doc.lineAt(model.to).number;\n const changes: ChangeSpec[] = [];\n for (let n = start; n <= end; n++) {\n const line = state.doc.line(n);\n const p = pipes(state, line);\n if (boundary < p.length) {\n changes.push({ from: p[boundary] + 1, insert: n === start + 1 ? \" --- |\" : \" |\" });\n }\n }\n return changes.length ? changes : null;\n}\n\n/** Insert an empty column to the right of the cursor's column. */\nexport function addColumnAfter(state: EditorState, pos: number): ChangeSpec | null {\n return insertColumn(state, pos, 1);\n}\n\n/** Insert an empty column to the left of the cursor's column. */\nexport function addColumnBefore(state: EditorState, pos: number): ChangeSpec | null {\n return insertColumn(state, pos, 0);\n}\n\n/** Delete the cursor's column from every row. No-op on a single-column table. */\nexport function deleteColumn(state: EditorState, pos: number): ChangeSpec | null {\n const model = modelAt(state, pos);\n if (!model || model.data.header.length <= 1) return null;\n const col = columnAt(state, pos);\n const start = state.doc.lineAt(model.from).number;\n const end = state.doc.lineAt(model.to).number;\n const changes: ChangeSpec[] = [];\n for (let n = start; n <= end; n++) {\n const p = pipes(state, state.doc.line(n));\n if (col + 1 < p.length) changes.push({ from: p[col], to: p[col + 1] });\n }\n return changes.length ? changes : null;\n}\n\n/** Remove the whole table at `pos` (its source lines and the line break after\n * them); the surrounding prose is untouched. */\nexport function deleteTable(state: EditorState, pos: number): ChangeSpec | null {\n const model = modelAt(state, pos);\n if (!model) return null;\n return { from: model.from, to: Math.min(state.doc.length, model.to + 1) };\n}\n"],"mappings":";AAGA,SAAS,UAAU,SAAS,aAAa;AAYzC,SAAS,SAAS,SAAyB;AACzC,SAAO,MAAM,MAAM,OAAO,OAAO;AACnC;AAIA,SAAS,MAAM,OAAoB,OAAmB;AACpD,QAAM,SAAS,MAAM,IAAI,OAAO,MAAM,IAAI;AAC1C,SAAO,EAAE,QAAQ,WAAW,MAAM,IAAI,OAAO,OAAO,KAAK,CAAC,EAAE;AAC9D;AAMO,SAAS,YAAY,OAAoB,KAAgC;AAC9E,QAAM,QAAQ,QAAQ,OAAO,GAAG;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,KAAK;AACxC,QAAM,UAAU,MAAM,IAAI,OAAO,GAAG;AACpC,QAAM,QAAQ,QAAQ,QAAQ,UAAU,OAAO,YAAY;AAC3D,SAAO,EAAE,MAAM,MAAM,IAAI,QAAQ,OAAO,SAAS,MAAM,KAAK,OAAO,MAAM,EAAE;AAC7E;AAMO,SAAS,YAAY,OAAoB,KAAgC;AAC9E,QAAM,QAAQ,QAAQ,OAAO,GAAG;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,KAAK;AACxC,QAAM,UAAU,MAAM,IAAI,OAAO,GAAG;A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AAClF,SAAO,aAAa,OAAO,KAAK,CAAC;AACnC;AAGO,SAAS,aAAa,OAAoB,KAAgC;AAC/E,QAAM,QAAQ,QAAQ,OAAO,GAAG;AAChC,MAAI,CAAC,SAAS,MAAM,KAAK,OAAO,UAAU,EAAG,QAAO;AACpD,QAAM,MAAM,SAAS,OAAO,GAAG;AAC/B,QAAM,QAAQ,MAAM,IAAI,OAAO,MAAM,IAAI,EAAE;AAC3C,QAAM,MAAM,MAAM,IAAI,OAAO,MAAM,EAAE,EAAE;AACvC,QAAM,UAAwB,CAAC;AAC/B,WAAS,IAAI,OAAO,KAAK,KAAK,KAAK;AACjC,UAAM,IAAI,MAAM,OAAO,MAAM,IAAI,KAAK,CAAC,CAAC;AACxC,QAAI,MAAM,IAAI,EAAE,OAAQ,SAAQ,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC;AAAA,EACvE;AACA,SAAO,QAAQ,SAAS,UAAU;AACpC;AAIO,SAAS,YAAY,OAAoB,KAAgC;AAC9E,QAAM,QAAQ,QAAQ,OAAO,GAAG;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,EAAE,MAAM,MAAM,MAAM,IAAI,KAAK,IAAI,MAAM,IAAI,QAAQ,MAAM,KAAK,CAAC,EAAE;AAC1E;","names":[]}
@@ -0,0 +1,29 @@
1
+ import { EditorState } from '@codemirror/state';
2
+ import { SourceRange } from '../../types.js';
3
+
4
+ /**
5
+ * Pull a table row or column out as a self-contained markdown table fragment,
6
+ * paired with the source range it came from. Drives the table context menu's
7
+ * "Ask the assistant about this row/column": the fragment is the quoted excerpt
8
+ * the assistant sees, the range anchors the chat's source chip.
9
+ */
10
+ interface TableExcerpt {
11
+ text: string;
12
+ range: SourceRange;
13
+ }
14
+ /**
15
+ * The row at `pos` as a standalone table — the header and delimiter lines plus
16
+ * this row, verbatim — so the assistant receives valid, self-describing markdown.
17
+ * Right-clicking the header row yields just the header. Range = the clicked row's
18
+ * line. Null when `pos` isn't in a table.
19
+ */
20
+ declare function rowExcerptAt(state: EditorState, pos: number): TableExcerpt | null;
21
+ /**
22
+ * The column at `pos` as a one-column table — its header cell, a delimiter, and
23
+ * the cell from every body row. Range = the whole table (a column's source is
24
+ * non-contiguous, so the chip anchors to the table). Null when `pos` isn't in a
25
+ * table.
26
+ */
27
+ declare function columnExcerptAt(state: EditorState, pos: number): TableExcerpt | null;
28
+
29
+ export { type TableExcerpt, columnExcerptAt, rowExcerptAt };
@@ -0,0 +1,34 @@
1
+ import "../../chunk-V6TY7KAL.js";
2
+ import { byteRangeOf } from "../byteOffset.js";
3
+ import { columnAt, modelAt, pipes } from "./tableGeometry.js";
4
+ function cellText(state, lineNumber, col) {
5
+ const line = state.doc.line(lineNumber);
6
+ const ps = pipes(state, line);
7
+ if (col + 1 >= ps.length) return "";
8
+ return state.sliceDoc(ps[col] + 1, ps[col + 1]).trim();
9
+ }
10
+ function rowExcerptAt(state, pos) {
11
+ const model = modelAt(state, pos);
12
+ if (!model) return null;
13
+ const header = state.doc.lineAt(model.from);
14
+ const row = state.doc.lineAt(pos);
15
+ const lines = row.from <= header.to ? [header.text] : [header.text, state.doc.line(header.number + 1).text, row.text];
16
+ return { text: lines.join("\n"), range: byteRangeOf(state, row.from, row.to) };
17
+ }
18
+ function columnExcerptAt(state, pos) {
19
+ const model = modelAt(state, pos);
20
+ if (!model) return null;
21
+ const col = columnAt(state, pos);
22
+ const headerLine = state.doc.lineAt(model.from).number;
23
+ const lastLine = state.doc.lineAt(model.to).number;
24
+ const lines = [`| ${cellText(state, headerLine, col)} |`, "| --- |"];
25
+ for (let n = headerLine + 2; n <= lastLine; n++) {
26
+ lines.push(`| ${cellText(state, n, col)} |`);
27
+ }
28
+ return { text: lines.join("\n"), range: byteRangeOf(state, model.from, model.to) };
29
+ }
30
+ export {
31
+ columnExcerptAt,
32
+ rowExcerptAt
33
+ };
34
+ //# sourceMappingURL=tableExcerpt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemirror/table/tableExcerpt.ts"],"sourcesContent":["import { type EditorState } from \"@codemirror/state\";\n\nimport { type SourceRange } from \"../../types\";\nimport { byteRangeOf } from \"../byteOffset\";\nimport { columnAt, modelAt, pipes } from \"./tableGeometry\";\n\n/**\n * Pull a table row or column out as a self-contained markdown table fragment,\n * paired with the source range it came from. Drives the table context menu's\n * \"Ask the assistant about this row/column\": the fragment is the quoted excerpt\n * the assistant sees, the range anchors the chat's source chip.\n */\nexport interface TableExcerpt {\n text: string;\n range: SourceRange;\n}\n\n/** Source text of column `col` on table line `lineNumber` (between its pipes),\n * trimmed; empty string when the line has no such cell. */\nfunction cellText(state: EditorState, lineNumber: number, col: number): string {\n const line = state.doc.line(lineNumber);\n const ps = pipes(state, line);\n if (col + 1 >= ps.length) return \"\";\n return state.sliceDoc(ps[col] + 1, ps[col + 1]).trim();\n}\n\n/**\n * The row at `pos` as a standalone table — the header and delimiter lines plus\n * this row, verbatim — so the assistant receives valid, self-describing markdown.\n * Right-clicking the header row yields just the header. Range = the clicked row's\n * line. Null when `pos` isn't in a table.\n */\nexport function rowExcerptAt(state: EditorState, pos: number): TableExcerpt | null {\n const model = modelAt(state, pos);\n if (!model) return null;\n const header = state.doc.lineAt(model.from);\n const row = state.doc.lineAt(pos);\n const lines =\n row.from <= header.to\n ? [header.text]\n : [header.text, state.doc.line(header.number + 1).text, row.text];\n return { text: lines.join(\"\\n\"), range: byteRangeOf(state, row.from, row.to) };\n}\n\n/**\n * The column at `pos` as a one-column table — its header cell, a delimiter, and\n * the cell from every body row. Range = the whole table (a column's source is\n * non-contiguous, so the chip anchors to the table). Null when `pos` isn't in a\n * table.\n */\nexport function columnExcerptAt(state: EditorState, pos: number): TableExcerpt | null {\n const model = modelAt(state, pos);\n if (!model) return null;\n const col = columnAt(state, pos);\n const headerLine = state.doc.lineAt(model.from).number;\n const lastLine = state.doc.lineAt(model.to).number;\n const lines = [`| ${cellText(state, headerLine, col)} |`, \"| --- |\"];\n for (let n = headerLine + 2; n <= lastLine; n++) {\n lines.push(`| ${cellText(state, n, col)} |`);\n }\n return { text: lines.join(\"\\n\"), range: byteRangeOf(state, model.from, model.to) };\n}\n"],"mappings":";AAGA,SAAS,mBAAmB;AAC5B,SAAS,UAAU,SAAS,aAAa;AAezC,SAAS,SAAS,OAAoB,YAAoB,KAAqB;AAC7E,QAAM,OAAO,MAAM,IAAI,KAAK,UAAU;AACtC,QAAM,KAAK,MAAM,OAAO,IAAI;AAC5B,MAAI,MAAM,KAAK,GAAG,OAAQ,QAAO;AACjC,SAAO,MAAM,SAAS,GAAG,GAAG,IAAI,GAAG,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK;AACvD;AAQO,SAAS,aAAa,OAAoB,KAAkC;AACjF,QAAM,QAAQ,QAAQ,OAAO,GAAG;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,SAAS,MAAM,IAAI,OAAO,MAAM,IAAI;AAC1C,QAAM,MAAM,MAAM,IAAI,OAAO,GAAG;AAChC,QAAM,QACJ,IAAI,QAAQ,OAAO,KACf,CAAC,OAAO,IAAI,IACZ,CAAC,OAAO,MAAM,MAAM,IAAI,KAAK,OAAO,SAAS,CAAC,EAAE,MAAM,IAAI,IAAI;AACpE,SAAO,EAAE,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO,YAAY,OAAO,IAAI,MAAM,IAAI,EAAE,EAAE;AAC/E;AAQO,SAAS,gBAAgB,OAAoB,KAAkC;AACpF,QAAM,QAAQ,QAAQ,OAAO,GAAG;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,MAAM,SAAS,OAAO,GAAG;AAC/B,QAAM,aAAa,MAAM,IAAI,OAAO,MAAM,IAAI,EAAE;AAChD,QAAM,WAAW,MAAM,IAAI,OAAO,MAAM,EAAE,EAAE;AAC5C,QAAM,QAAQ,CAAC,KAAK,SAAS,OAAO,YAAY,GAAG,CAAC,MAAM,SAAS;AACnE,WAAS,IAAI,aAAa,GAAG,KAAK,UAAU,KAAK;AAC/C,UAAM,KAAK,KAAK,SAAS,OAAO,GAAG,GAAG,CAAC,IAAI;AAAA,EAC7C;AACA,SAAO,EAAE,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO,YAAY,OAAO,MAAM,MAAM,MAAM,EAAE,EAAE;AACnF;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { StateField } from '@codemirror/state';
2
+ import { DecorationSet } from '@codemirror/view';
3
+
4
+ declare const tableField: StateField<DecorationSet>;
5
+
6
+ export { tableField };
@@ -0,0 +1,37 @@
1
+ import "../../chunk-V6TY7KAL.js";
2
+ import { syntaxTree } from "@codemirror/language";
3
+ import { StateField } from "@codemirror/state";
4
+ import { Decoration, EditorView } from "@codemirror/view";
5
+ import { parseTableNode } from "./tableModel.js";
6
+ import { TableWidgetV2 } from "../tablev2/tableWidgetV2.js";
7
+ function buildTableDecorations(state) {
8
+ const ranges = [];
9
+ syntaxTree(state).iterate({
10
+ enter(node) {
11
+ if (node.name !== "Table") return;
12
+ for (const model of parseTableNode(state, node.node)) {
13
+ ranges.push(
14
+ Decoration.replace({
15
+ widget: new TableWidgetV2(model.data, model.from, model.to),
16
+ block: true
17
+ }).range(model.from, model.to)
18
+ );
19
+ }
20
+ }
21
+ });
22
+ return Decoration.set(ranges, true);
23
+ }
24
+ const tableField = StateField.define({
25
+ create: buildTableDecorations,
26
+ update(value, tr) {
27
+ if (tr.docChanged || syntaxTree(tr.state) !== syntaxTree(tr.startState)) {
28
+ return buildTableDecorations(tr.state);
29
+ }
30
+ return value;
31
+ },
32
+ provide: (f) => EditorView.decorations.from(f)
33
+ });
34
+ export {
35
+ tableField
36
+ };
37
+ //# sourceMappingURL=tableField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemirror/table/tableField.ts"],"sourcesContent":["import { syntaxTree } from \"@codemirror/language\";\nimport { type EditorState, StateField, type Range } from \"@codemirror/state\";\nimport { Decoration, type DecorationSet, EditorView } from \"@codemirror/view\";\n\nimport { parseTableNode } from \"./tableModel\";\nimport { TableWidgetV2 } from \"../tablev2/tableWidgetV2\";\n\nfunction buildTableDecorations(state: EditorState): DecorationSet {\n const ranges: Range<Decoration>[] = [];\n syntaxTree(state).iterate({\n enter(node) {\n if (node.name !== \"Table\") return;\n // One Lezer Table node can hold several tables (back-to-back, no blank\n // line between); each becomes its own widget over its own source range.\n for (const model of parseTableNode(state, node.node)) {\n ranges.push(\n Decoration.replace({\n widget: new TableWidgetV2(model.data, model.from, model.to),\n block: true,\n }).range(model.from, model.to),\n );\n }\n },\n });\n return Decoration.set(ranges, true);\n}\n\nexport const tableField = StateField.define<DecorationSet>({\n create: buildTableDecorations,\n update(value, tr) {\n // Rebuild on edits AND when the parser advances. CodeMirror parses lazily,\n // so on a long document the tables below the initially-parsed region only\n // enter the syntax tree as the user scrolls; without rebuilding on parse\n // progress they never get decorated and stay as raw `| … |` markdown.\n if (tr.docChanged || syntaxTree(tr.state) !== syntaxTree(tr.startState)) {\n return buildTableDecorations(tr.state);\n }\n return value;\n },\n provide: (f) => EditorView.decorations.from(f),\n});\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAA2B,kBAA8B;AACzD,SAAS,YAAgC,kBAAkB;AAE3D,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAE9B,SAAS,sBAAsB,OAAmC;AAChE,QAAM,SAA8B,CAAC;AACrC,aAAW,KAAK,EAAE,QAAQ;AAAA,IACxB,MAAM,MAAM;AACV,UAAI,KAAK,SAAS,QAAS;AAG3B,iBAAW,SAAS,eAAe,OAAO,KAAK,IAAI,GAAG;AACpD,eAAO;AAAA,UACL,WAAW,QAAQ;AAAA,YACjB,QAAQ,IAAI,cAAc,MAAM,MAAM,MAAM,MAAM,MAAM,EAAE;AAAA,YAC1D,OAAO;AAAA,UACT,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,EAAE;AAAA,QAC/B;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACD,SAAO,WAAW,IAAI,QAAQ,IAAI;AACpC;AAEO,MAAM,aAAa,WAAW,OAAsB;AAAA,EACzD,QAAQ;AAAA,EACR,OAAO,OAAO,IAAI;AAKhB,QAAI,GAAG,cAAc,WAAW,GAAG,KAAK,MAAM,WAAW,GAAG,UAAU,GAAG;AACvE,aAAO,sBAAsB,GAAG,KAAK;AAAA,IACvC;AACA,WAAO;AAAA,EACT;AAAA,EACA,SAAS,CAAC,MAAM,WAAW,YAAY,KAAK,CAAC;AAC/C,CAAC;","names":[]}
@@ -0,0 +1,33 @@
1
+ import { EditorState } from '@codemirror/state';
2
+ import { TableModel } from './tableModel.js';
3
+
4
+ /**
5
+ * Position → table geometry: which table a document offset falls in, and the
6
+ * pipe boundaries / column index of a cell. Shared by the structural edit
7
+ * commands and the row/column excerpt builder — both reason about a table from a
8
+ * cell position, so the geometry lives apart from either's specific job.
9
+ */
10
+ /** Minimal Lezer node shape — `parseTableNode`'s, plus `parent` for walking up. */
11
+ type LezerNode = {
12
+ readonly name: string;
13
+ readonly from: number;
14
+ readonly to: number;
15
+ readonly firstChild: LezerNode | null;
16
+ readonly nextSibling: LezerNode | null;
17
+ readonly parent: LezerNode | null;
18
+ };
19
+ /**
20
+ * The table model whose source range encloses `pos`, or null. Resolves the
21
+ * enclosing `Table` node, then — since Lezer merges blank-line-less tables into
22
+ * one node — picks the back-to-back sub-table that actually contains `pos`.
23
+ */
24
+ declare function modelAt(state: EditorState, pos: number): TableModel | null;
25
+ /** Absolute positions of the unescaped `|` pipes in `line`. */
26
+ declare function pipes(state: EditorState, line: {
27
+ from: number;
28
+ to: number;
29
+ }): number[];
30
+ /** The 0-based column `pos` sits in — the cell after the last pipe before it. */
31
+ declare function columnAt(state: EditorState, pos: number): number;
32
+
33
+ export { type LezerNode, columnAt, modelAt, pipes };
@@ -0,0 +1,28 @@
1
+ import "../../chunk-V6TY7KAL.js";
2
+ import { parseTableNode } from "./tableModel.js";
3
+ import { treeAt } from "../core/treeAt.js";
4
+ function modelAt(state, pos) {
5
+ let node = treeAt(state, pos).resolveInner(pos, 1);
6
+ while (node && node.name !== "Table") node = node.parent;
7
+ if (!node) return null;
8
+ return parseTableNode(state, node).find((m) => pos >= m.from && pos <= m.to) ?? null;
9
+ }
10
+ function pipes(state, line) {
11
+ const text = state.doc.sliceString(line.from, line.to);
12
+ const out = [];
13
+ for (let i = 0; i < text.length; i++) {
14
+ if (text[i] === "|" && text[i - 1] !== "\\") out.push(line.from + i);
15
+ }
16
+ return out;
17
+ }
18
+ function columnAt(state, pos) {
19
+ const line = state.doc.lineAt(pos);
20
+ const before = pipes(state, line).filter((p) => p < pos).length;
21
+ return Math.max(0, before - 1);
22
+ }
23
+ export {
24
+ columnAt,
25
+ modelAt,
26
+ pipes
27
+ };
28
+ //# sourceMappingURL=tableGeometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemirror/table/tableGeometry.ts"],"sourcesContent":["import { type EditorState } from \"@codemirror/state\";\n\nimport { parseTableNode, type TableModel } from \"./tableModel\";\nimport { treeAt } from \"../core/treeAt\";\n\n/**\n * Position → table geometry: which table a document offset falls in, and the\n * pipe boundaries / column index of a cell. Shared by the structural edit\n * commands and the row/column excerpt builder — both reason about a table from a\n * cell position, so the geometry lives apart from either's specific job.\n */\n\n/** Minimal Lezer node shape — `parseTableNode`'s, plus `parent` for walking up. */\nexport type LezerNode = {\n readonly name: string;\n readonly from: number;\n readonly to: number;\n readonly firstChild: LezerNode | null;\n readonly nextSibling: LezerNode | null;\n readonly parent: LezerNode | null;\n};\n\n/**\n * The table model whose source range encloses `pos`, or null. Resolves the\n * enclosing `Table` node, then — since Lezer merges blank-line-less tables into\n * one node — picks the back-to-back sub-table that actually contains `pos`.\n */\nexport function modelAt(state: EditorState, pos: number): TableModel | null {\n // side +1: at a boundary, resolve the node that STARTS at `pos` (the table),\n // not the gap before it — so the table's own `from` (used for keyboard entry\n // and cell navigation) still finds it. Inside a cell this is unchanged.\n let node = treeAt(state, pos).resolveInner(pos, 1) as unknown as LezerNode | null;\n while (node && node.name !== \"Table\") node = node.parent;\n if (!node) return null;\n return parseTableNode(state, node).find((m) => pos >= m.from && pos <= m.to) ?? null;\n}\n\n/** Absolute positions of the unescaped `|` pipes in `line`. */\nexport function pipes(state: EditorState, line: { from: number; to: number }): number[] {\n const text = state.doc.sliceString(line.from, line.to);\n const out: number[] = [];\n for (let i = 0; i < text.length; i++) {\n if (text[i] === \"|\" && text[i - 1] !== \"\\\\\") out.push(line.from + i);\n }\n return out;\n}\n\n/** The 0-based column `pos` sits in — the cell after the last pipe before it. */\nexport function columnAt(state: EditorState, pos: number): number {\n const line = state.doc.lineAt(pos);\n const before = pipes(state, line).filter((p) => p < pos).length;\n return Math.max(0, before - 1);\n}\n"],"mappings":";AAEA,SAAS,sBAAuC;AAChD,SAAS,cAAc;AAwBhB,SAAS,QAAQ,OAAoB,KAAgC;AAI1E,MAAI,OAAO,OAAO,OAAO,GAAG,EAAE,aAAa,KAAK,CAAC;AACjD,SAAO,QAAQ,KAAK,SAAS,QAAS,QAAO,KAAK;AAClD,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,eAAe,OAAO,IAAI,EAAE,KAAK,CAAC,MAAM,OAAO,EAAE,QAAQ,OAAO,EAAE,EAAE,KAAK;AAClF;AAGO,SAAS,MAAM,OAAoB,MAA8C;AACtF,QAAM,OAAO,MAAM,IAAI,YAAY,KAAK,MAAM,KAAK,EAAE;AACrD,QAAM,MAAgB,CAAC;AACvB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,QAAI,KAAK,CAAC,MAAM,OAAO,KAAK,IAAI,CAAC,MAAM,KAAM,KAAI,KAAK,KAAK,OAAO,CAAC;AAAA,EACrE;AACA,SAAO;AACT;AAGO,SAAS,SAAS,OAAoB,KAAqB;AAChE,QAAM,OAAO,MAAM,IAAI,OAAO,GAAG;AACjC,QAAM,SAAS,MAAM,OAAO,IAAI,EAAE,OAAO,CAAC,MAAM,IAAI,GAAG,EAAE;AACzD,SAAO,KAAK,IAAI,GAAG,SAAS,CAAC;AAC/B;","names":[]}
@@ -0,0 +1,37 @@
1
+ import { EditorState } from '@codemirror/state';
2
+
3
+ /**
4
+ * Renders a table cell's inline markdown to an HTML string by walking the Lezer
5
+ * inline nodes already parsed inside the `TableCell`, styled through the SAME
6
+ * {@link NODE_RULES} the live editor uses: a `mark` paint becomes a `<span>`
7
+ * carrying that rule's class (`cm-strong`, `cm-inline-code`, `cm-link`, …), so
8
+ * a cell's bold/code/link is painted by the exact `.cm-*` theme rules as body
9
+ * text — not a second, drifting set of styles. Hidden chrome drops out;
10
+ * not-yet-styled constructs pass through as raw markdown, matching how the
11
+ * body leaves them today. Cells render STRINGS, not DOM, so a `widget` paint
12
+ * passes the node's raw source through (the cell's DOMPurify pass keeps
13
+ * allow-listed inline HTML like `<br>` and drops the rest).
14
+ *
15
+ * Reading the parsed tree (rather than re-parsing the cell string) preserves
16
+ * escaped pipes and leaves literal inline HTML (`<br>`) in the gaps between
17
+ * nodes intact — the cell's DOMPurify pass (tableCell.ts) sanitises the result.
18
+ */
19
+
20
+ type SyntaxNodeLike = {
21
+ readonly name: string;
22
+ readonly from: number;
23
+ readonly to: number;
24
+ readonly firstChild: SyntaxNodeLike | null;
25
+ readonly nextSibling: SyntaxNodeLike | null;
26
+ };
27
+ /**
28
+ * Inline-render one `TableCell` node to a (still-to-be-sanitised) HTML string.
29
+ *
30
+ * The constructs Lezer parses come from the tree; the four it does not
31
+ * (wikilink, highlight, footnote, math) are carved out of the cell's text first
32
+ * and take precedence over the tree walk — the same order the body renders in,
33
+ * where a scanning plugin's replace decoration covers the marks beneath it.
34
+ */
35
+ declare function renderInlineCell(state: EditorState, cell: SyntaxNodeLike): string;
36
+
37
+ export { renderInlineCell };