@latentic/live-markdown 0.3.0 → 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 +38 -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 -5989
  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
package/dist/index.d.ts CHANGED
@@ -1,880 +1,35 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import * as _codemirror_view from '@codemirror/view';
4
- import { Decoration, ViewPlugin, DecorationSet, ViewUpdate, KeyBinding, EditorView, Command } from '@codemirror/view';
5
- import * as _codemirror_state from '@codemirror/state';
6
- import { EditorState, Facet, Extension } from '@codemirror/state';
7
- import { syntaxTree } from '@codemirror/language';
8
-
9
- /**
10
- * Core value types for the editor's public surface.
11
- *
12
- * `SourceRange` is a half-open byte range into the document; `DocumentTextChange`
13
- * describes one edit. They are structurally identical to the host app's own
14
- * range/change types, so a host can pass its `onChange` straight through without
15
- * adapting structural typing makes them interchangeable.
16
- */
17
- /** A half-open range into the document, in UTF-8 byte offsets. */
18
- interface SourceRange {
19
- start: number;
20
- end: number;
21
- }
22
- /** One text edit: the replaced byte range and the text inserted in its place. */
23
- interface DocumentTextChange {
24
- range: SourceRange;
25
- text: string;
26
- }
27
-
28
- /**
29
- * Rich copy/cut (#135): every copy writes BOTH clipboard flavors —
30
- *
31
- * text/plain — the markdown SOURCE of the selection (lossless: editors,
32
- * terminals, and Compose→Compose round trips);
33
- * text/html — the selection rendered by the host (Google Docs, Slack,
34
- * Word, and Gmail paste it formatted).
35
- *
36
- * The HTML carries {@link COMPOSE_CLIPBOARD_ATTR} so our own paste handler
37
- * prefers the markdown flavor instead of re-converting our rendering.
38
- *
39
- * Stays out of the way of: the table surface's TSV cell-selection copy (a
40
- * capture-phase document listener that preventDefaults first), and CM's
41
- * native empty-selection behavior. Without a host renderer the handler still
42
- * runs — plain-only, but through one code path.
43
- */
44
-
45
- /** Host-supplied markdown → HTML renderer for clipboard writes. Null (the
46
- * default) copies plain markdown only. Wired like the other host seams —
47
- * see hostFacets.ts. */
48
- type RenderClipboardHtml = (markdown: string) => string | null;
49
-
50
- /**
51
- * The rendering contract: one polymorphic shape for "how does a Lezer node
52
- * render", replacing three parallel dispatch surfaces (a data-entry union, a
53
- * widget-name union + builders map, and a contextual-override switch).
54
- *
55
- * NodeRule = (ctx) => Paint — one function per node NAME
56
- * Paint = which CM6 mechanism — a CLOSED union
57
- *
58
- * The openness is split on the right axis: CONSTRUCTS grow (every new node
59
- * adds a rule — one entry, one place, usually one line via the combinators
60
- * below), while the ways to PAINT don't (line class / span mark / hide /
61
- * widget / nothing — CodeMirror's own vocabulary). The single switch over
62
- * `Paint` lives in the painter (plugin.ts) and never changes when a
63
- * construct is added.
64
- *
65
- * Context (the bare-URL lesson: a node name can mean different things in
66
- * different parents) is not a bolt-on — every rule IS a function of context;
67
- * simple rules just ignore it.
68
- *
69
- * Extensions contribute rules through {@link nodeRulesFacet}: a plugin that
70
- * introduces node names ships its rules alongside its grammar, touching no
71
- * core file.
72
- */
73
-
74
- interface NodeLike {
75
- readonly name: string;
76
- readonly from: number;
77
- readonly to: number;
78
- readonly parent: NodeLike | null;
79
- readonly firstChild: NodeLike | null;
80
- readonly nextSibling: NodeLike | null;
81
- readonly prevSibling: NodeLike | null;
82
- getChild(type: string): NodeLike | null;
83
- }
84
- /** Everything a rule may consult. */
85
- interface NodeContext {
86
- readonly name: string;
87
- readonly from: number;
88
- readonly to: number;
89
- /** The parent node's name — the common contextual discriminator. */
90
- readonly parentName: string | undefined;
91
- /** Full structural node, for rules that need siblings/children. */
92
- readonly node: NodeLike;
93
- /** Rules are pure over state — no view dependency, so non-editor
94
- * renderers (table cells) can invoke the same rules. */
95
- readonly state: EditorState;
96
- }
97
- /** One painting instruction, in CodeMirror's own vocabulary. */
98
- type Paint =
99
- /** Stamp a line class — on the node's first line, or every spanned line. */
100
- {
101
- readonly paint: "lineClass";
102
- readonly className: string;
103
- readonly span: "first" | "all";
104
- }
105
- /** Style the node's span. */
106
- | {
107
- readonly paint: "mark";
108
- readonly className: string;
109
- }
110
- /**
111
- * Hide a range (default: the node, plus its one separator space when
112
- * line-leading) and make it atomic to caret motion. `atomicTo` widens the
113
- * atom past the hidden range (marker + space move as one unit).
114
- */
115
- | {
116
- readonly paint: "hide";
117
- readonly range?: {
118
- readonly from: number;
119
- readonly to: number;
120
- };
121
- readonly expandSpace?: boolean;
122
- readonly atomicTo?: number;
123
- }
124
- /** Replace the (hidden) span with a widget decoration. */
125
- | {
126
- readonly paint: "widget";
127
- readonly deco: Decoration;
128
- readonly atomicTo?: number;
129
- }
130
- /** Leave the node alone — visible raw source. */
131
- | {
132
- readonly paint: "none";
133
- };
134
- interface RuleMeta {
135
- readonly intent: "render-raw" | "structural";
136
- readonly why: string;
137
- }
138
- /** How one node name renders. `meta` tags the deliberate do-nothing rules so
139
- * the coverage test can insist their reason is documented. */
140
- type NodeRule = ((ctx: NodeContext) => Paint) & {
141
- readonly meta?: RuleMeta;
142
- };
143
- type NodeRules = Readonly<Record<string, NodeRule>>;
144
- /** Style the node's span with a class. */
145
- declare function mark(className: string): NodeRule;
146
- /** Stamp a line class on every line the node spans. */
147
- declare function line(className: string): NodeRule;
148
- /** Stamp a line class on the node's first line only (headings). */
149
- declare function headingLine(className: string): NodeRule;
150
- /** Hide the node (marker chrome), atomically. */
151
- declare function hideAlways(): NodeRule;
152
- /** Deliberately unstyled-for-now, visible raw — `why` documents the intent. */
153
- declare function raw(why: string): NodeRule;
154
- /** A parser grouping construct, never directly visible — `why` says which. */
155
- declare function structural(why: string): NodeRule;
156
- /**
157
- * Rules contributed by extensions, merged over the base table (an extension
158
- * may also deliberately override a base rule — last provider wins). The
159
- * painter reads THIS, never the base table directly.
160
- */
161
- declare const nodeRulesFacet: Facet<Readonly<Record<string, NodeRule>>, Readonly<Record<string, NodeRule>>>;
162
-
163
- /**
164
- * Constructs Lezer never parses.
165
- *
166
- * Wikilinks, `==highlight==`, footnote references and `$math$` are not
167
- * CommonMark, so no node exists for any of them and the editor finds each by
168
- * scanning text (`codeContext.ts` documents the shared code guard). A renderer
169
- * that walks the tree is therefore blind to all four — which is how a table cell
170
- * came to show `$440 = 2 \times \frac{22}{7} \times r$` as literal source while
171
- * the same expression rendered as mathematics in the paragraph above it.
172
- *
173
- * A feature contributes its pattern and its markup through this facet; the
174
- * string renderers consult the facet and stay ignorant of what the constructs
175
- * are. The decoration plugins keep their own viewport-scanning path — the two
176
- * paths share the pattern, not the machinery, because one produces decorations
177
- * over a live document and the other an HTML string.
178
- */
179
-
180
- interface InlineScanRule {
181
- readonly name: string;
182
- /** Global-flagged; the scanner drives `exec` and resets `lastIndex`. */
183
- readonly pattern: RegExp;
184
- /** Markup for one match. Escaping document text is the rule's job. */
185
- render(match: RegExpExecArray): string;
186
- /**
187
- * Upgrade rendered markup to real DOM, after sanitisation. Only for a
188
- * construct whose rendering is DOM rather than markup (KaTeX): the generated
189
- * nodes bypass the sanitiser, so a hydrate reads inert text from the element
190
- * it replaces and never trusts the document.
191
- */
192
- hydrate?(root: HTMLElement): void;
193
- }
194
- declare const inlineScanRulesFacet: Facet<InlineScanRule, readonly InlineScanRule[]>;
195
- interface InlineScanMatch {
196
- readonly from: number;
197
- readonly to: number;
198
- readonly html: string;
199
- }
200
- /**
201
- * Every rule's matches in `text`, in document order, offset by `at`.
202
- *
203
- * Earliest wins, then longest — two constructs cannot both own one span, and
204
- * the alternative (rule declaration order) would make the result depend on
205
- * extension load order.
206
- */
207
- declare function scanInline(rules: readonly InlineScanRule[], text: string, at?: number): InlineScanMatch[];
208
-
209
- /** Entity-escaping for the string renderers (table cells), which build HTML
210
- * text rather than DOM and so must neutralise markup in document content. */
211
- declare function escapeText(value: string): string;
212
- declare function escapeAttr(value: string): string;
213
-
214
- /**
215
- * A syntax tree that reaches `pos`.
216
- *
217
- * `syntaxTree` returns only what the **viewport** has driven the parser
218
- * through, so `resolveInner` past that point reports the position as bare
219
- * `Document`. Every command that asks "am I inside a list / a fence / a table?"
220
- * then gets "no" and takes the plain-text path: a wrong answer, not a slow one.
221
- *
222
- * Measured in WebKit, the engine we ship on, with real layout — two regimes.
223
- *
224
- * On the frame a document opens the parser has covered a few thousand
225
- * characters: 3,009 of 7,902, viewport 0–331, for an editor 11,404px tall. The
226
- * idle parse then catches up within about half a second, so near the viewport
227
- * this is a race — and it heals before a hand-test can see it.
228
- *
229
- * Further out it never heals. The idle parse stops 100,000 characters past the
230
- * viewport: the tree plateaus at 100,739 for a 167k-character document and a
231
- * 341k one alike, and stays there. `ensureSyntaxTree` resumes from that plateau
232
- * and finishes the 341k document in 43ms — inside the budget above.
233
- *
234
- * Only for questions about a *position*. Decoration plugins iterate
235
- * `view.visibleRanges` and should keep using `syntaxTree` directly: there,
236
- * being limited to the viewport is the point.
237
- */
238
- type Tree = ReturnType<typeof syntaxTree>;
239
- declare function treeAt(state: EditorState, pos: number): Tree;
240
-
241
- /**
242
- * Markdown decoration plugin — the PAINTER. Walks the Lezer tree against the
243
- * visible viewport, asks each node's {@link NodeRule} how to render, and
244
- * applies the returned {@link Paint}.
245
- *
246
- * The painter contains *no* construct knowledge: rules live in the base
247
- * table (`NODE_RULES`) merged with any extension-contributed rules
248
- * (`nodeRulesFacet`). The one switch here is over `Paint` — CodeMirror's
249
- * closed set of mechanisms — so adding a construct, widget, contextual
250
- * override, or whole extension never edits this file.
251
- *
252
- * Perf shape (unchanged from the spike):
253
- * * Walks `view.visibleRanges` against `syntaxTree(view.state)` —
254
- * the work is proportional to the viewport, not the document.
255
- * * Rebuilt on doc change or viewport change.
256
- *
257
- * Decoration ordering (CM6 requires `from`-then-`startSide` ascending):
258
- * * Line decorations collected in one bucket, mark / replace in
259
- * another. The final `Decoration.set` lets CM6 sort defensively,
260
- * costing ~µs on the typical viewport — cheaper than risking the
261
- * "decorations out of order" runtime error.
262
- */
263
-
264
- declare const markdownDecorationsPlugin: ViewPlugin<{
265
- decorations: DecorationSet;
266
- atomic: DecorationSet;
267
- update(update: ViewUpdate): void;
268
- }, undefined>;
269
-
270
- /**
271
- * Editor theme.
272
- *
273
- * Lives in `EditorView.baseTheme` rather than in `global.scss` for
274
- * three load-bearing reasons:
275
- *
276
- * 1. **Line-metric integrity.** CM6 measures line heights from the
277
- * DOM through a `requestMeasure` cycle to compute click → byte
278
- * and scroll → viewport mappings. Styles injected via
279
- * `EditorView.theme` participate in that cycle at the right
280
- * moment; styles from an external sheet can land *after* the
281
- * first measurement, so clicks land on the wrong line until the
282
- * next measure fires. (This was the click-drift the spike
283
- * shipped — fixed by moving here.)
284
- * 2. **Specificity that beats the base theme without `!important`.**
285
- * CM6 ships its monospace-and-purple base theme via the same
286
- * mechanism; layering `EditorView.theme` on top is the only
287
- * collision-free pattern.
288
- * 3. **No margin/padding on heading lines.** Margins between
289
- * `.cm-line` siblings shift visual position without changing
290
- * `offsetTop`, so the metric cache and the eye disagree —
291
- * that's the canonical click-on-wrong-line bug. We change
292
- * `font:` (which doesn't touch line-height), nothing else.
293
- *
294
- * Zettlr's `markdown-editor/theme/editor.ts` is the canonical
295
- * reference for this pattern in the open-source ecosystem.
296
- */
297
- /**
298
- * `EditorView.theme` (not `baseTheme`) — `baseTheme` is the
299
- * low-priority slot meant for theme packages and gets out-specifity'd
300
- * by any app-level CSS (Carbon's globals in our case). `theme` is the
301
- * app-priority slot; our intent is to override CM6's defaults, so
302
- * this is the right tier.
303
- */
304
- declare const editorBaseTheme: _codemirror_state.Extension;
305
-
306
- /**
307
- * Display-time resolution of image `src` values for the editor — the
308
- * environment-agnostic pieces.
309
- *
310
- * Markdown stores image references **workspace-relative and portable** (e.g.
311
- * `images/pasted-….png`), which is what lands on disk and survives moving the
312
- * folder between machines. A WebView, though, can't load a bare relative path
313
- * against its app origin, so a host that streams local files needs to map the
314
- * reference onto its own asset protocol.
315
- *
316
- * This module provides the host-independent parts: the POSIX path helpers
317
- * (`computeFileDir` / `joinPath` / …), the `hasUriScheme` guard, and
318
- * `defaultResolveImageSrc` (render as-is — the browser/SSR default). A desktop
319
- * host composes these with its file API (e.g. Tauri `convertFileSrc`) to build
320
- * its own resolver and injects it via the editor's `resolveImageSrc` prop. The
321
- * stored markdown reference is never rewritten — only the rendered `<img src>`.
322
- *
323
- * Paths are treated as POSIX (`/`), matching the macOS/Linux workspace folders
324
- * this targets. Windows-style drive paths are passed through unresolved.
325
- */
326
- interface ImageResolveContext {
327
- /** Absolute OS directory of the markdown file being edited, or null. */
328
- fileDir: string | null;
329
- }
330
- /**
331
- * True when `src` already carries a URI scheme, a protocol-relative `//`, or a
332
- * bare fragment — i.e. it's directly loadable and needs no path resolution. A
333
- * host's display-src resolver uses this to decide whether to map a relative
334
- * workspace path onto its own asset protocol.
335
- */
336
- declare function hasUriScheme(src: string): boolean;
337
- /**
338
- * Environment-agnostic default for the editor's `resolveImageSrcFacet`: render
339
- * the reference as-is. Data URLs and absolute/schemed URLs load directly; a
340
- * relative ref resolves against the page origin (or shows broken if no backing
341
- * file). A desktop host overrides the facet with its own resolver, which maps
342
- * relative paths onto a local asset protocol.
343
- */
344
- declare function defaultResolveImageSrc(rawSrc: string, _ctx: ImageResolveContext): string;
345
- /**
346
- * The directory a relative image reference resolves against: the folder
347
- * containing the active markdown file. Falls back to the workspace root when
348
- * the file path is unknown, and to null when there's no workspace.
349
- */
350
- declare function computeFileDir(workspaceRoot: string | null | undefined, filePath: string | null | undefined): string | null;
351
- declare function isAbsolutePath(p: string): boolean;
352
- /** POSIX `dirname`: the parent of a path, with trailing slashes ignored. */
353
- declare function dirnamePath(p: string): string;
354
- /**
355
- * Join `rel` onto `dir`, normalizing `.` and `..` segments. Absolute-ness is
356
- * inherited from `dir`; `..` never escapes above an absolute root.
357
- */
358
- declare function joinPath(dir: string, rel: string): string;
359
-
360
- /**
361
- * Host-environment injection seams.
362
- *
363
- * The editor surface is environment-agnostic: it knows how to render and edit
364
- * markdown, but NOT how to read/write files, resolve asset URLs, or open links —
365
- * those depend on where it's embedded (a Tauri desktop shell, a plain browser, a
366
- * server-rendered preview). Each capability is a CM6 facet with a sensible
367
- * browser default; the React host overrides it by setting the facet from a prop.
368
- *
369
- * Keeping these as facets (not React context) lets the non-React CM6 plugins and
370
- * widgets — image paste handlers, the inline `<img>` widget, the click model —
371
- * read them straight off `view.state`.
372
- */
373
-
374
- type ResolveImageSrc = (rawSrc: string, ctx: ImageResolveContext) => string;
375
- type SaveImageBytes = (relPath: string, bytes: Uint8Array) => Promise<void>;
376
- type OpenExternalUrl = (url: string) => void;
377
- /** Viewport point a comment composer should anchor to (the right-click point). */
378
- type CommentAnchor = {
379
- x: number;
380
- y: number;
381
- };
382
- type CommentOnExcerpt = (excerpt: {
383
- text: string;
384
- range: SourceRange;
385
- }, anchor: CommentAnchor) => void;
386
-
387
- interface ToolbarContribution {
388
- readonly id: string;
389
- readonly group: "heading" | "format" | "block" | "insert" | string;
390
- readonly label: string;
391
- readonly icon: ReactNode;
392
- readonly shortcut?: string;
393
- readonly isActive?: (caretContext: CaretContextSnapshot) => boolean;
394
- readonly run: (view: _codemirror_view.EditorView) => void;
395
- }
396
- interface CaretContextSnapshot {
397
- readonly bold: boolean;
398
- readonly italic: boolean;
399
- readonly code: boolean;
400
- readonly link: boolean;
401
- readonly heading: 1 | 2 | 3 | 4 | 5 | 6 | 0;
402
- readonly bulletList: boolean;
403
- readonly orderedList: boolean;
404
- readonly blockquote: boolean;
405
- }
406
- interface MarkdownExtension {
407
- readonly name: string;
408
- readonly version: string;
409
- readonly description?: string;
410
- /** Node rules for constructs this extension's grammar introduces (or
411
- * deliberately overrides) — merged into the decoration painter via
412
- * `nodeRulesFacet`, so an extension never edits the base table. */
413
- readonly rules?: NodeRules;
414
- readonly extensions?: Extension[];
415
- readonly keymap?: KeyBinding[];
416
- readonly toolbar?: ToolbarContribution[];
417
- }
418
-
419
- interface ComposedExtension {
420
- extensions: Extension[];
421
- toolbar: ToolbarContribution[];
422
- }
423
- /**
424
- * Merge extension modules into one set of CodeMirror extensions plus the
425
- * toolbar items they contribute. Later modules win: a host's rules are applied
426
- * after the built-ins, so it can deliberately override a construct.
427
- */
428
- declare function mergeExtensions(modules: readonly MarkdownExtension[]): ComposedExtension;
429
- /**
430
- * @deprecated Renamed to {@link mergeExtensions}. "compose" reads as the app
431
- * this package was extracted from rather than as the verb; the editor is meant
432
- * for more hosts than that one. Kept as an alias so the rename is not breaking.
433
- */
434
- declare const composeExtensions: typeof mergeExtensions;
435
-
436
- declare const highlightExtension: MarkdownExtension;
437
-
438
- declare const footnoteExtension: MarkdownExtension;
439
-
440
- declare const mathExtension: MarkdownExtension;
441
-
442
- declare const mermaidExtension: MarkdownExtension;
443
-
444
- /**
445
- * A FACTORY, not a const: each composition gets its own editing surface (the
446
- * one-active-edit state), so two mounted editors can never share a cell edit.
447
- */
448
- declare function tableExtension(): MarkdownExtension;
449
-
450
- declare const wikilinkExtension: MarkdownExtension;
451
-
452
- type CodeMirrorEditorMode = "wysiwyg" | "source";
453
- /** A non-empty editor selection, in document byte offsets. */
454
- interface EditorSelectionSnapshot {
455
- range: SourceRange;
456
- text: string;
457
- }
458
- interface CodeMirrorMarkdownEditorProps {
459
- mode?: CodeMirrorEditorMode;
460
- onChange: (value: string, changes: DocumentTextChange[]) => void;
461
- value: string;
462
- workspaceRoot?: string;
463
- filePath?: string;
464
- linkTargets?: ReadonlySet<string>;
465
- onNavigateToLink?: (path: string) => void;
466
- /**
467
- * Extension modules contributed by the host, merged AFTER the built-ins so a
468
- * host can deliberately override a construct (the merger warns when a node
469
- * rule is redefined).
470
- *
471
- * Read when an editor state is built — on mount, and on the swaps that
472
- * rebuild one — not on every render, so passing a fresh array each time costs
473
- * nothing and cannot remount the editor. Changing it mid-session therefore
474
- * takes effect at the next rebuild.
475
- *
476
- * Applies in BOTH modes: a module's node rules simply go unread while the
477
- * decoration painter is off, but its keymaps and plain CodeMirror extensions
478
- * are not markdown-rendering concerns and should not be silently dropped in
479
- * source mode.
480
- */
481
- extensions?: readonly MarkdownExtension[];
482
- /** Host-rendered toolbar. `contributions` carries the toolbar items the
483
- * extension modules asked for; the host decides whether and how to render
484
- * them alongside its own. */
485
- toolbar?: (ctx: {
486
- view: EditorView;
487
- contributions: readonly ToolbarContribution[];
488
- }) => ReactNode;
489
- /**
490
- * Host-rendered actions for the current text selection (e.g. a comment / ask
491
- * bubble). Called with the live selection (or `null` when collapsed) and a
492
- * `dismiss` that collapses the selection back to a caret. Omit for none.
493
- */
494
- selectionActions?: (ctx: {
495
- selection: EditorSelectionSnapshot | null;
496
- dismiss: () => void;
497
- }) => ReactNode;
498
- /**
499
- * Map a markdown image `src` to a loadable URL. Default: render the reference
500
- * as-is. A desktop host maps workspace-relative paths onto its asset protocol.
501
- */
502
- resolveImageSrc?: ResolveImageSrc;
503
- /**
504
- * Persist a pasted/dropped image's bytes at a workspace-relative path.
505
- * Default: omitted ⇒ the image is inlined as a `data:` URL.
506
- */
507
- saveImageBytes?: SaveImageBytes;
508
- /**
509
- * Open a clicked external link. Default: a new browser tab. A desktop host
510
- * overrides this to leave the app's webview.
511
- */
512
- onOpenExternalUrl?: OpenExternalUrl;
513
- /**
514
- * Comment on a selected table row/column — wired to the table context menu's
515
- * "Comment on this row / column". The host opens its comment composer at the
516
- * given anchor, seeded with the excerpt. Default: omitted ⇒ no such menu items.
517
- */
518
- onCommentOnExcerpt?: CommentOnExcerpt;
519
- /**
520
- * Render a markdown selection to HTML for the clipboard, so a copy pastes
521
- * formatted into Google Docs / Slack / Word (the markdown source always
522
- * rides along as text/plain). Default: omitted ⇒ plain-only copies.
523
- */
524
- renderClipboardHtml?: RenderClipboardHtml;
525
- /**
526
- * Called once, right after a tab-switch content swap commits and paints.
527
- * Used by the host for latency instrumentation; no-op by default.
528
- */
529
- onAfterContentSwap?: () => void;
530
- /**
531
- * Receives a synchronous `flush()` that pulls the editor's live (debounce-
532
- * lagged) content into the last `onChange` immediately — the host calls it
533
- * before persisting. `null` is passed on unmount. Lets a host avoid writing
534
- * stale buffers on Cmd+S / tab close.
535
- */
536
- onFlushReady?: (flush: (() => void) | null) => void;
537
- }
538
- declare function CodeMirrorMarkdownEditorInner({ mode, onChange, value, workspaceRoot, filePath, linkTargets, onNavigateToLink, extensions: hostExtensions, toolbar, selectionActions, resolveImageSrc, saveImageBytes, onOpenExternalUrl, onCommentOnExcerpt, renderClipboardHtml, onAfterContentSwap, onFlushReady, }: CodeMirrorMarkdownEditorProps): react.JSX.Element;
539
- /**
540
- * Memoised export — same reason as the Tiptap editor. AppShell
541
- * re-renders on every chat-thread token; without memoisation each
542
- * token would blow through the editor's render path.
543
- */
544
- declare const CodeMirrorMarkdownEditor: react.MemoExoticComponent<typeof CodeMirrorMarkdownEditorInner>;
545
-
546
- declare const formatCommands: {
547
- toggleBold: Command;
548
- toggleItalic: Command;
549
- toggleInlineCode: Command;
550
- };
551
-
552
- declare const blockCommands: {
553
- toggleHeading1: Command;
554
- toggleHeading2: Command;
555
- toggleHeading3: Command;
556
- toggleBulletList: Command;
557
- toggleOrderedList: Command;
558
- toggleTaskList: Command;
559
- toggleBlockquote: Command;
560
- toggleCodeBlock: Command;
561
- insertTable: Command;
562
- };
563
-
564
- /**
565
- * Editor-update fan-out that survives `view.setState`.
566
- *
567
- * Reactive chrome (toolbar pressed-states, the selection-actions bubble)
568
- * needs a callback on every selection/doc change. Injecting an
569
- * `EditorView.updateListener` with `StateEffect.appendConfig` only patches
570
- * the CURRENT state's configuration — the next `view.setState` (tab switch,
571
- * file reload) builds a fresh state from the base extensions and the
572
- * listener silently dies, freezing the chrome at the previous document's
573
- * context.
574
- *
575
- * The bus lives IN the base extensions, so every created state carries it,
576
- * while subscriptions key on the `EditorView` — the object that is stable
577
- * across state swaps.
578
- */
579
-
580
- /**
581
- * Subscribe to every update of `view`, across all its future states.
582
- * Returns the unsubscribe function — call it in the effect cleanup.
583
- */
584
- declare function onEditorUpdate(view: EditorView, fn: (update: ViewUpdate) => void): () => void;
585
-
586
- /**
587
- * Mermaid rendering, decoupled from CodeMirror — shared by the editor widget,
588
- * the document export (which ships the SVG to the backend), and the clipboard
589
- * (which needs a PNG, since Google Docs/Word drop SVG on paste).
590
- *
591
- * The mermaid library is heavy (~2 MB minified), so it loads lazily on the
592
- * first diagram — bundled with the app, never fetched at runtime, so diagrams
593
- * work fully offline. Render results are cached by source text; PNGs are
594
- * rasterised once per diagram in the background (see {@link warmMermaidPng})
595
- * so the SYNCHRONOUS copy event can embed them from cache.
596
- */
597
- type MermaidRenderResult = {
598
- ok: true;
599
- svg: string;
600
- } | {
601
- ok: false;
602
- message: string;
603
- };
604
- /** Whether a fence info string denotes a rendered mermaid diagram — the tag
605
- * alone, any casing, no trailing meta ("mermaid title=x" is source, not a
606
- * diagram). The one definition shared by the editor plugin, the export's SVG
607
- * collector, and the clipboard, so every surface classifies identically. */
608
- declare function isMermaidFenceInfo(info: string): boolean;
609
- /** Render a mermaid diagram source to SVG, memoised by source. Never rejects —
610
- * a parse error resolves to `{ ok: false, message }`. */
611
- declare function renderMermaidToSvg(source: string): Promise<MermaidRenderResult>;
612
- /** The cached PNG data URI for a diagram source, if it has been rasterised. */
613
- declare function getCachedMermaidPng(source: string): string | null;
614
- /** Render + rasterise a diagram in the background so a LATER (synchronous)
615
- * clipboard copy can embed it from cache. Fire-and-forget: failures leave the
616
- * cache empty and the copy degrades to the source block. */
617
- declare function warmMermaidPng(source: string): Promise<void>;
618
-
619
- /**
620
- * Synchronous fence highlighting for the clipboard (#149).
621
- *
622
- * A copy event writes `text/html` synchronously, so highlighting must not
623
- * await anything. The trick: the grammars are the SAME `@codemirror/language-data`
624
- * singletons the editor's nested fence parse loads — any fence visible in the
625
- * editor has its grammar warm, so highlighting the copied code is a sync parse.
626
- * A cold grammar (copy from a doc whose fence never rendered) kicks the load
627
- * and returns null: THIS copy ships plain, the next one is highlighted.
628
- *
629
- * Output is inline-styled spans (the palette from
630
- * [codePalette](./codePalette.ts), same colors as the editor) — pasted HTML
631
- * carries no stylesheet, so classes would be dead weight in Docs/Word.
632
- */
633
- interface HighlightedSpan {
634
- text: string;
635
- /** Inline CSS for the span; absent for unstyled text (incl. line breaks). */
636
- style?: string;
637
- }
638
- /** Highlight `code` as `lang` into inline-styled spans, or null when no
639
- * grammar matches or the grammar isn't loaded yet (the load is kicked so a
640
- * later copy succeeds). Never throws — a parser hiccup falls back to null. */
641
- declare function highlightFenceSpans(lang: string, code: string): HighlightedSpan[] | null;
642
-
643
- /**
644
- * Image-insertion pipeline. Used by both paste-from-clipboard and
645
- * drag-and-drop. Both produce a `Blob`; this module turns the blob
646
- * into a markdown-reference-able path:
647
- *
648
- * * When a `saveBytes` writer is injected (a desktop host): writes
649
- * the bytes to `images/<timestamp>-<hash>.<ext>` and returns the
650
- * relative path. The markdown reference is portable across
651
- * machines because it's a real on-disk file.
652
- * * Otherwise (plain browser, or the write fails): falls back to a
653
- * data URL embedded directly in the markdown. The markdown file
654
- * bloats but the image stays visible through page reload without
655
- * needing a binary file API.
656
- *
657
- * The writer is injected rather than imported so this module stays
658
- * environment-agnostic — the editor reads it off a CM6 facet
659
- * ({@link saveImageBytesFacet}) the host wires up.
660
- *
661
- * Returned `markdownReference` is what the caller drops into
662
- * `![alt](…)`. `warning` is set in the data-URL fallback case so
663
- * the caller can surface a note to the user.
664
- */
665
- interface ImageInsertOptions {
666
- blob: Blob;
667
- /**
668
- * Persist the bytes at a workspace-relative path. `null`/omitted ⇒
669
- * inline as a data URL (browser fallback).
670
- */
671
- saveBytes?: ((relPath: string, bytes: Uint8Array) => Promise<void>) | null;
672
- /**
673
- * Alt text the user typed (currently always synthesized as
674
- * "pasted-image" or "dropped-image"; in phase 3d the inline
675
- * rename UI lets the user edit it post-insert).
676
- */
677
- alt?: string;
678
- }
679
- interface ImageInsertResult {
680
- markdownReference: string;
681
- alt: string;
682
- warning?: string;
683
- }
684
- /**
685
- * Save the blob and return the markdown reference. Errors are
686
- * structured (the caller decides whether to retry with a fallback
687
- * or surface a notification).
688
- */
689
- declare function insertImageBlob(opts: ImageInsertOptions): Promise<ImageInsertResult>;
690
- /**
691
- * Build a markdown image insertion string from the result. Keeps
692
- * the call site (handlePaste / handleDrop) tidy.
693
- */
694
- declare function buildImageMarkdown(result: ImageInsertResult): string;
695
- /**
696
- * Scan a DataTransferItemList for image blobs. Returns every
697
- * image found, in order. Empty array when nothing matches —
698
- * caller treats that as "fall through to text paste".
699
- */
700
- declare function extractImageBlobs(items: DataTransferItemList | null | undefined): Blob[];
701
- /**
702
- * Scan a FileList (drag-and-drop's `dataTransfer.files`) for
703
- * image files. Drag-drop and paste use different shapes; this
704
- * keeps the two paths symmetrical at the call site.
705
- */
706
- declare function extractImageFiles(files: FileList | null | undefined): File[];
707
-
708
- declare const imageInsertHandlers: _codemirror_state.Extension;
709
- /**
710
- * Open the browser's native file picker, then run the picked files
711
- * through the same insert pipeline. Called by the toolbar's Image
712
- * button.
713
- */
714
- declare function pickImageFileForCaret(view: EditorView): void;
715
-
716
- interface ShowMenuArgs {
717
- x: number;
718
- y: number;
719
- view: EditorView;
720
- alt: string;
721
- rawSrc: string;
722
- sourceFrom: number;
723
- sourceTo: number;
724
- }
725
- declare function showImageActionMenu(args: ShowMenuArgs): void;
726
-
727
- /**
728
- * The "edit this image's alt text" custom-event contract — a plain constant and
729
- * type with NO runtime CodeMirror dependency (the `EditorView` reference is
730
- * `import type`, erased at build). The lazy-loaded editor dispatches this event;
731
- * the host shell listens for it. Keeping the contract here means a host can
732
- * import the event name without pulling the whole editor into its initial
733
- * bundle (it previously came from `imageActionMenu`, which imports CodeMirror).
734
- */
735
- declare const IMAGE_EDIT_ALT_EVENT = "ai-editor:edit-image-alt";
736
- interface ImageEditAltEventDetail {
737
- view: EditorView;
738
- sourceFrom: number;
739
- sourceTo: number;
740
- currentAlt: string;
741
- rawSrc: string;
742
- }
743
-
744
- /**
745
- * YAML frontmatter parsing + serialization.
746
- *
747
- * Convention: `--- yaml ---` block at the very top of a markdown
748
- * file (before any other content). Format:
749
- *
750
- * ---
751
- * status: draft
752
- * tags:
753
- * - application
754
- * - fellowship
755
- * ---
756
- *
757
- * # Real content starts here
758
- *
759
- * This module separates the YAML chunk from the prose chunk so
760
- * the WYSIWYG editor can render only the prose (no raw `key:
761
- * value` lines bleeding into the user's writing surface) while a
762
- * separate properties UI shows / edits the frontmatter.
763
- *
764
- * Round-trip rules:
765
- * - If a file has no frontmatter on disk, we MUST NOT add one
766
- * on save just because the properties panel exists.
767
- * - If a file has frontmatter, we serialize it using the same
768
- * keys/order the user wrote (best effort — yaml lib preserves
769
- * scalar formatting but not always blank lines / comments).
770
- * - The fence marker is always exactly `---` on its own line.
771
- * Some Obsidian users prefer `+++` (TOML) — out of scope for
772
- * v1; we round-trip those as body content unchanged.
773
- */
774
- /**
775
- * The frontmatter value type. Each entry is whatever YAML can
776
- * decode to — strings, numbers, booleans, arrays, nested objects.
777
- * The properties UI handles primitives + flat arrays cleanly;
778
- * nested objects fall back to a raw YAML editor.
779
- */
780
- type FrontmatterValue = string | number | boolean | null | FrontmatterValue[] | {
781
- [key: string]: FrontmatterValue;
782
- };
783
- type Frontmatter = Record<string, FrontmatterValue>;
784
- interface MarkdownDocument {
785
- /** Parsed YAML key/values. `null` means "no frontmatter block present". */
786
- frontmatter: Frontmatter | null;
787
- /** The prose portion — everything after the closing `---`. */
788
- body: string;
789
- }
790
- /**
791
- * Split a markdown string into its frontmatter + body. Tolerant
792
- * of:
793
- * - No frontmatter at all → `frontmatter: null, body: input`
794
- * - Malformed YAML → `frontmatter: null, body: input` (we treat
795
- * the whole thing as prose rather than show parse errors)
796
- * - Empty frontmatter block (`---\n---`) → `frontmatter: {}`
797
- */
798
- declare function parseFrontmatter(markdown: string): MarkdownDocument;
799
- /**
800
- * Recombine frontmatter + body into a markdown string. Inverse
801
- * of `parseFrontmatter` for legal inputs.
802
- *
803
- * - `frontmatter: null` → just the body, no `---` fences added
804
- * - `frontmatter: {}` → no fences either (an empty frontmatter
805
- * block is semantically the same as "no frontmatter" and we
806
- * prefer the cleaner shape on save)
807
- * - Otherwise → `---\n<yaml>\n---\n<body>`
808
- */
809
- declare function serializeMarkdown(doc: MarkdownDocument): string;
810
- /**
811
- * Helper: update a single frontmatter field in a markdown string
812
- * without touching the body. Used by the Properties UI when the
813
- * user edits one value at a time.
814
- *
815
- * If the file had no frontmatter, this adds one with just the
816
- * one field. If the value is `null` and the key exists, removes
817
- * the key (and removes the whole frontmatter block if it becomes
818
- * empty).
819
- */
820
- declare function setFrontmatterField(markdown: string, key: string, value: FrontmatterValue | null): string;
821
-
822
- /**
823
- * Wikilink (`[[target]]` / `[[target|label]]`) parsing + target resolution.
824
- *
825
- * The canonical rule lives in the `workspace-index` crate
826
- * (`wikilink_target_and_label` / `resolve_document_target` / `path_stem_matches`
827
- * / `slug_key`) — that's what builds the backlink graph. This is the
828
- * **client-side mirror** used to navigate a *clicked* wikilink, so the editor
829
- * and chat agree with the sidebar's backlinks. Keep the two in sync; if the
830
- * crate's rule changes, change it here too.
831
- *
832
- * Difference from the crate: an unresolved target returns `null` (we only
833
- * navigate to files that exist), whereas the crate keeps a would-be path for
834
- * the graph edge.
835
- */
836
- /** Split a wikilink body into its target and display label. */
837
- declare function parseWikilinkBody(body: string): {
838
- target: string;
839
- label: string;
840
- };
841
- /** Resolve a wikilink target to an existing workspace file path, or `null`. */
842
- declare function resolveWikilinkTarget(rawTarget: string, options: {
843
- fromPath?: string;
844
- knownPaths: ReadonlySet<string>;
845
- }): string | null;
846
-
847
- /**
848
- * Resolve a markdown link href to a navigation target.
849
- *
850
- * A link in a document (or an agent's chat reply) is either:
851
- * - **external** — anything with a URI scheme (`https:`, `mailto:`, …) or a
852
- * protocol-relative `//host`; opened in the browser, and
853
- * - **internal** — a workspace-relative path that resolves to a file the
854
- * workspace actually contains; opened in a tab.
855
- *
856
- * This is pure path resolution (normalize `.`/`..`, reject escaping the vault
857
- * root, membership-check against the known files) — it is **not** the index's
858
- * link parser. The index already resolves links into `graphEdges`; this just
859
- * decides where a *clicked* href points so the UI can navigate. An href that
860
- * looks internal but matches no known file returns `null` (a broken link, not
861
- * something to navigate to).
862
- */
863
- type ResolvedWorkspaceLink = {
864
- kind: "internal";
865
- path: string;
866
- } | {
867
- kind: "external";
868
- href: string;
869
- };
870
- interface ResolveWorkspaceLinkOptions {
871
- /** Workspace-relative path of the document the link lives in. Relative hrefs
872
- * resolve against this file's directory. Omitted ⇒ resolve from the vault
873
- * root (used for agent chat replies, which emit root-relative paths). */
874
- fromPath?: string;
875
- /** Every workspace-relative file path, for membership checks. */
876
- knownPaths: ReadonlySet<string>;
877
- }
878
- declare function resolveWorkspaceLink(href: string, options: ResolveWorkspaceLinkOptions): ResolvedWorkspaceLink | null;
879
-
880
- export { type CaretContextSnapshot, type CodeMirrorEditorMode, CodeMirrorMarkdownEditor, type CodeMirrorMarkdownEditorProps, type ComposedExtension, type DocumentTextChange, type EditorSelectionSnapshot, type Frontmatter, type FrontmatterValue, type HighlightedSpan, IMAGE_EDIT_ALT_EVENT, type ImageEditAltEventDetail, type ImageInsertOptions, type ImageInsertResult, type ImageResolveContext, type InlineScanMatch, type InlineScanRule, type MarkdownDocument, type MarkdownExtension, type MermaidRenderResult, type NodeContext, type NodeRule, type NodeRules, type OpenExternalUrl, type Paint, type ResolveImageSrc, type ResolveWorkspaceLinkOptions, type ResolvedWorkspaceLink, type SaveImageBytes, type SourceRange, type ToolbarContribution, blockCommands, buildImageMarkdown, composeExtensions, computeFileDir, defaultResolveImageSrc, dirnamePath, editorBaseTheme, escapeAttr, escapeText, extractImageBlobs, extractImageFiles, footnoteExtension, formatCommands, getCachedMermaidPng, hasUriScheme, headingLine, hideAlways, highlightExtension, highlightFenceSpans, imageInsertHandlers, inlineScanRulesFacet, insertImageBlob, isAbsolutePath, isMermaidFenceInfo, joinPath, line, mark, markdownDecorationsPlugin, mathExtension, mergeExtensions, mermaidExtension, nodeRulesFacet, onEditorUpdate, parseFrontmatter, parseWikilinkBody, pickImageFileForCaret, raw, renderMermaidToSvg, resolveWikilinkTarget, resolveWorkspaceLink, scanInline, serializeMarkdown, setFrontmatterField, showImageActionMenu, structural, tableExtension, treeAt, warmMermaidPng, wikilinkExtension };
1
+ export { CodeMirrorEditorMode, CodeMirrorMarkdownEditor, CodeMirrorMarkdownEditorProps, EditorSelectionSnapshot } from './codemirror/CodeMirrorMarkdownEditor.js';
2
+ export { DocumentTextChange, SourceRange } from './types.js';
3
+ export { NodeContext, NodeRule, NodeRules, Paint, headingLine, hideAlways, line, mark, nodeRulesFacet, raw, structural } from './codemirror/core/paint.js';
4
+ export { InlineScanMatch, InlineScanRule, inlineScanRulesFacet, scanInline } from './codemirror/core/inlineScan.js';
5
+ export { escapeAttr, escapeText } from './codemirror/core/htmlEscape.js';
6
+ export { treeAt } from './codemirror/core/treeAt.js';
7
+ export { markdownDecorationsPlugin } from './codemirror/core/plugin.js';
8
+ export { editorBaseTheme } from './codemirror/core/editorTheme.js';
9
+ export { OpenExternalUrl, ResolveImageSrc, SaveImageBytes } from './codemirror/core/hostFacets.js';
10
+ export { formatCommands } from './codemirror/format/formatCommands.js';
11
+ export { blockCommands } from './codemirror/format/blockCommands.js';
12
+ export { onEditorUpdate } from './codemirror/updateBus.js';
13
+ export { CaretContextSnapshot, MarkdownExtension, ToolbarContribution } from './codemirror/extensions/types.js';
14
+ export { ComposedExtension, composeExtensions, mergeExtensions } from './codemirror/extensions/loader.js';
15
+ export { highlightExtension } from './codemirror/extensions/highlightExtension.js';
16
+ export { footnoteExtension } from './codemirror/extensions/footnoteExtension.js';
17
+ export { mathExtension } from './codemirror/extensions/mathExtension.js';
18
+ export { mermaidExtension } from './codemirror/extensions/mermaidExtension.js';
19
+ export { tableExtension } from './codemirror/extensions/tableExtension.js';
20
+ export { wikilinkExtension } from './codemirror/extensions/wikilinkExtension.js';
21
+ export { MermaidRenderResult, getCachedMermaidPng, isMermaidFenceInfo, renderMermaidToSvg, warmMermaidPng } from './codemirror/mermaid/mermaidRender.js';
22
+ export { HighlightedSpan, highlightFenceSpans } from './codemirror/code/highlightFence.js';
23
+ export { ImageInsertOptions, ImageInsertResult, buildImageMarkdown, extractImageBlobs, extractImageFiles, insertImageBlob } from './imageInsert.js';
24
+ export { ImageResolveContext, computeFileDir, defaultResolveImageSrc, dirnamePath, hasUriScheme, isAbsolutePath, joinPath } from './imageSrcResolver.js';
25
+ export { imageInsertHandlers, pickImageFileForCaret } from './codemirror/image/imageInsertHandlers.js';
26
+ export { showImageActionMenu } from './codemirror/image/imageActionMenu.js';
27
+ export { IMAGE_EDIT_ALT_EVENT, ImageEditAltEventDetail } from './codemirror/image/imageEditEvent.js';
28
+ export { Frontmatter, FrontmatterValue, MarkdownDocument, parseFrontmatter, serializeMarkdown, setFrontmatterField } from './frontmatter.js';
29
+ export { parseWikilinkBody, resolveWikilinkTarget } from './links/wikilink.js';
30
+ export { ResolveWorkspaceLinkOptions, ResolvedWorkspaceLink, resolveWorkspaceLink } from './links/workspaceLink.js';
31
+ import 'react';
32
+ import '@codemirror/view';
33
+ import './codemirror/clipboard/copyRich.js';
34
+ import '@codemirror/state';
35
+ import '@codemirror/language';