phormat 0.0.5

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 (489) hide show
  1. package/README.md +102 -0
  2. package/dist/assets/example-test.svelte +228 -0
  3. package/dist/debug/JsonDebug.svelte +19 -0
  4. package/dist/debug/JsonDebug.svelte.d.ts +6 -0
  5. package/dist/debug/JsonDebugNode.svelte +138 -0
  6. package/dist/debug/JsonDebugNode.svelte.d.ts +11 -0
  7. package/dist/demo/documentLifecycle.d.ts +57 -0
  8. package/dist/demo/documentLifecycle.js +196 -0
  9. package/dist/demo/index.d.ts +2 -0
  10. package/dist/demo/index.js +2 -0
  11. package/dist/editor/BlockEditor.svelte +112 -0
  12. package/dist/editor/BlockEditor.svelte.d.ts +7 -0
  13. package/dist/editor/BlockRow.svelte +76 -0
  14. package/dist/editor/BlockRow.svelte.d.ts +20 -0
  15. package/dist/editor/Editor.svelte +103 -0
  16. package/dist/editor/Editor.svelte.d.ts +7 -0
  17. package/dist/editor/MarkdownEditor.svelte.d.ts +160 -0
  18. package/dist/editor/MarkdownEditor.svelte.js +1119 -0
  19. package/dist/editor/NestedRowChrome.svelte +160 -0
  20. package/dist/editor/NestedRowChrome.svelte.d.ts +20 -0
  21. package/dist/editor/PhormatEditor.svelte +206 -0
  22. package/dist/editor/PhormatEditor.svelte.d.ts +26 -0
  23. package/dist/editor/RawMarkdownPanel.svelte +39 -0
  24. package/dist/editor/RawMarkdownPanel.svelte.d.ts +6 -0
  25. package/dist/editor/block-specs/BlockSpecMissing.svelte +12 -0
  26. package/dist/editor/block-specs/BlockSpecMissing.svelte.d.ts +7 -0
  27. package/dist/editor/block-specs/blockquote/BlockquoteRenderer.svelte +32 -0
  28. package/dist/editor/block-specs/blockquote/BlockquoteRenderer.svelte.d.ts +21 -0
  29. package/dist/editor/block-specs/blockquote/commands.d.ts +2 -0
  30. package/dist/editor/block-specs/blockquote/commands.js +65 -0
  31. package/dist/editor/block-specs/blockquote/index.d.ts +6 -0
  32. package/dist/editor/block-specs/blockquote/index.js +5 -0
  33. package/dist/editor/block-specs/blockquote/inlineSecondPass.d.ts +6 -0
  34. package/dist/editor/block-specs/blockquote/inlineSecondPass.js +35 -0
  35. package/dist/editor/block-specs/blockquote/parse.d.ts +16 -0
  36. package/dist/editor/block-specs/blockquote/parse.js +188 -0
  37. package/dist/editor/block-specs/blockquote/reconcile.d.ts +2 -0
  38. package/dist/editor/block-specs/blockquote/reconcile.js +9 -0
  39. package/dist/editor/block-specs/blockquote/serialize.d.ts +6 -0
  40. package/dist/editor/block-specs/blockquote/serialize.js +55 -0
  41. package/dist/editor/block-specs/blockquote/types.d.ts +20 -0
  42. package/dist/editor/block-specs/blockquote/types.js +1 -0
  43. package/dist/editor/block-specs/blockquoteSpec.d.ts +4 -0
  44. package/dist/editor/block-specs/blockquoteSpec.js +37 -0
  45. package/dist/editor/block-specs/callout/CalloutRenderer.svelte +38 -0
  46. package/dist/editor/block-specs/callout/CalloutRenderer.svelte.d.ts +21 -0
  47. package/dist/editor/block-specs/callout/CalloutTypeIcon.svelte +14 -0
  48. package/dist/editor/block-specs/callout/CalloutTypeIcon.svelte.d.ts +7 -0
  49. package/dist/editor/block-specs/callout/commands.d.ts +2 -0
  50. package/dist/editor/block-specs/callout/commands.js +65 -0
  51. package/dist/editor/block-specs/callout/icons.d.ts +10 -0
  52. package/dist/editor/block-specs/callout/icons.js +52 -0
  53. package/dist/editor/block-specs/callout/index.d.ts +9 -0
  54. package/dist/editor/block-specs/callout/index.js +7 -0
  55. package/dist/editor/block-specs/callout/inlineSecondPass.d.ts +6 -0
  56. package/dist/editor/block-specs/callout/inlineSecondPass.js +9 -0
  57. package/dist/editor/block-specs/callout/parse.d.ts +9 -0
  58. package/dist/editor/block-specs/callout/parse.js +83 -0
  59. package/dist/editor/block-specs/callout/parseBody.d.ts +6 -0
  60. package/dist/editor/block-specs/callout/parseBody.js +290 -0
  61. package/dist/editor/block-specs/callout/reconcile.d.ts +2 -0
  62. package/dist/editor/block-specs/callout/reconcile.js +8 -0
  63. package/dist/editor/block-specs/callout/serialize.d.ts +5 -0
  64. package/dist/editor/block-specs/callout/serialize.js +65 -0
  65. package/dist/editor/block-specs/callout/types.d.ts +7 -0
  66. package/dist/editor/block-specs/callout/types.js +1 -0
  67. package/dist/editor/block-specs/calloutSpec.d.ts +2 -0
  68. package/dist/editor/block-specs/calloutSpec.js +23 -0
  69. package/dist/editor/block-specs/codeFence/CodeFenceRenderer.svelte +18 -0
  70. package/dist/editor/block-specs/codeFence/CodeFenceRenderer.svelte.d.ts +21 -0
  71. package/dist/editor/block-specs/codeFence/commands.d.ts +2 -0
  72. package/dist/editor/block-specs/codeFence/commands.js +1 -0
  73. package/dist/editor/block-specs/codeFence/index.d.ts +5 -0
  74. package/dist/editor/block-specs/codeFence/index.js +4 -0
  75. package/dist/editor/block-specs/codeFence/inlineSecondPass.d.ts +3 -0
  76. package/dist/editor/block-specs/codeFence/inlineSecondPass.js +5 -0
  77. package/dist/editor/block-specs/codeFence/reconcile.d.ts +2 -0
  78. package/dist/editor/block-specs/codeFence/reconcile.js +5 -0
  79. package/dist/editor/block-specs/codeFence/serialize.d.ts +2 -0
  80. package/dist/editor/block-specs/codeFence/serialize.js +8 -0
  81. package/dist/editor/block-specs/codeFence/types.d.ts +6 -0
  82. package/dist/editor/block-specs/codeFence/types.js +1 -0
  83. package/dist/editor/block-specs/codeFenceSpec.d.ts +2 -0
  84. package/dist/editor/block-specs/codeFenceSpec.js +23 -0
  85. package/dist/editor/block-specs/columns/ColumnsRenderer.svelte +18 -0
  86. package/dist/editor/block-specs/columns/ColumnsRenderer.svelte.d.ts +21 -0
  87. package/dist/editor/block-specs/columns/EditableColumns.svelte +16 -0
  88. package/dist/editor/block-specs/columns/EditableColumns.svelte.d.ts +4 -0
  89. package/dist/editor/block-specs/columns/commands.d.ts +2 -0
  90. package/dist/editor/block-specs/columns/commands.js +1 -0
  91. package/dist/editor/block-specs/columns/index.d.ts +6 -0
  92. package/dist/editor/block-specs/columns/index.js +5 -0
  93. package/dist/editor/block-specs/columns/inlineSecondPass.d.ts +3 -0
  94. package/dist/editor/block-specs/columns/inlineSecondPass.js +5 -0
  95. package/dist/editor/block-specs/columns/parse.d.ts +20 -0
  96. package/dist/editor/block-specs/columns/parse.js +111 -0
  97. package/dist/editor/block-specs/columns/reconcile.d.ts +2 -0
  98. package/dist/editor/block-specs/columns/reconcile.js +6 -0
  99. package/dist/editor/block-specs/columns/serialize.d.ts +2 -0
  100. package/dist/editor/block-specs/columns/serialize.js +16 -0
  101. package/dist/editor/block-specs/columns/types.d.ts +4 -0
  102. package/dist/editor/block-specs/columns/types.js +1 -0
  103. package/dist/editor/block-specs/columnsSpec.d.ts +2 -0
  104. package/dist/editor/block-specs/columnsSpec.js +24 -0
  105. package/dist/editor/block-specs/heading/HeaderRenderer.svelte +30 -0
  106. package/dist/editor/block-specs/heading/HeaderRenderer.svelte.d.ts +21 -0
  107. package/dist/editor/block-specs/heading/commands.d.ts +2 -0
  108. package/dist/editor/block-specs/heading/commands.js +41 -0
  109. package/dist/editor/block-specs/heading/edit.d.ts +10 -0
  110. package/dist/editor/block-specs/heading/edit.js +33 -0
  111. package/dist/editor/block-specs/heading/index.d.ts +7 -0
  112. package/dist/editor/block-specs/heading/index.js +6 -0
  113. package/dist/editor/block-specs/heading/inlineSecondPass.d.ts +4 -0
  114. package/dist/editor/block-specs/heading/inlineSecondPass.js +20 -0
  115. package/dist/editor/block-specs/heading/parse.d.ts +5 -0
  116. package/dist/editor/block-specs/heading/parse.js +18 -0
  117. package/dist/editor/block-specs/heading/reconcile.d.ts +2 -0
  118. package/dist/editor/block-specs/heading/reconcile.js +8 -0
  119. package/dist/editor/block-specs/heading/serialize.d.ts +2 -0
  120. package/dist/editor/block-specs/heading/serialize.js +9 -0
  121. package/dist/editor/block-specs/heading/types.d.ts +5 -0
  122. package/dist/editor/block-specs/heading/types.js +1 -0
  123. package/dist/editor/block-specs/headingSpec.d.ts +2 -0
  124. package/dist/editor/block-specs/headingSpec.js +28 -0
  125. package/dist/editor/block-specs/horizontalRule/HorizontalRuleRenderer.svelte +15 -0
  126. package/dist/editor/block-specs/horizontalRule/HorizontalRuleRenderer.svelte.d.ts +21 -0
  127. package/dist/editor/block-specs/horizontalRule/commands.d.ts +2 -0
  128. package/dist/editor/block-specs/horizontalRule/commands.js +1 -0
  129. package/dist/editor/block-specs/horizontalRule/index.d.ts +6 -0
  130. package/dist/editor/block-specs/horizontalRule/index.js +5 -0
  131. package/dist/editor/block-specs/horizontalRule/inlineSecondPass.d.ts +3 -0
  132. package/dist/editor/block-specs/horizontalRule/inlineSecondPass.js +5 -0
  133. package/dist/editor/block-specs/horizontalRule/parse.d.ts +2 -0
  134. package/dist/editor/block-specs/horizontalRule/parse.js +15 -0
  135. package/dist/editor/block-specs/horizontalRule/reconcile.d.ts +2 -0
  136. package/dist/editor/block-specs/horizontalRule/reconcile.js +5 -0
  137. package/dist/editor/block-specs/horizontalRule/serialize.d.ts +2 -0
  138. package/dist/editor/block-specs/horizontalRule/serialize.js +3 -0
  139. package/dist/editor/block-specs/horizontalRule/types.d.ts +3 -0
  140. package/dist/editor/block-specs/horizontalRule/types.js +1 -0
  141. package/dist/editor/block-specs/horizontalRuleSpec.d.ts +2 -0
  142. package/dist/editor/block-specs/horizontalRuleSpec.js +24 -0
  143. package/dist/editor/block-specs/list/ListRenderer.svelte +70 -0
  144. package/dist/editor/block-specs/list/ListRenderer.svelte.d.ts +21 -0
  145. package/dist/editor/block-specs/list/commands.d.ts +2 -0
  146. package/dist/editor/block-specs/list/commands.js +65 -0
  147. package/dist/editor/block-specs/list/index.d.ts +6 -0
  148. package/dist/editor/block-specs/list/index.js +5 -0
  149. package/dist/editor/block-specs/list/inlineSecondPass.d.ts +6 -0
  150. package/dist/editor/block-specs/list/inlineSecondPass.js +78 -0
  151. package/dist/editor/block-specs/list/parse.d.ts +11 -0
  152. package/dist/editor/block-specs/list/parse.js +312 -0
  153. package/dist/editor/block-specs/list/reconcile.d.ts +2 -0
  154. package/dist/editor/block-specs/list/reconcile.js +6 -0
  155. package/dist/editor/block-specs/list/serialize.d.ts +4 -0
  156. package/dist/editor/block-specs/list/serialize.js +83 -0
  157. package/dist/editor/block-specs/list/types.d.ts +27 -0
  158. package/dist/editor/block-specs/list/types.js +1 -0
  159. package/dist/editor/block-specs/listSpec.d.ts +4 -0
  160. package/dist/editor/block-specs/listSpec.js +24 -0
  161. package/dist/editor/block-specs/paragraph/ParagraphRenderer.svelte +22 -0
  162. package/dist/editor/block-specs/paragraph/ParagraphRenderer.svelte.d.ts +21 -0
  163. package/dist/editor/block-specs/paragraph/commands.d.ts +2 -0
  164. package/dist/editor/block-specs/paragraph/commands.js +41 -0
  165. package/dist/editor/block-specs/paragraph/edit.d.ts +10 -0
  166. package/dist/editor/block-specs/paragraph/edit.js +69 -0
  167. package/dist/editor/block-specs/paragraph/index.d.ts +7 -0
  168. package/dist/editor/block-specs/paragraph/index.js +6 -0
  169. package/dist/editor/block-specs/paragraph/inlineSecondPass.d.ts +3 -0
  170. package/dist/editor/block-specs/paragraph/inlineSecondPass.js +25 -0
  171. package/dist/editor/block-specs/paragraph/parse.d.ts +9 -0
  172. package/dist/editor/block-specs/paragraph/parse.js +76 -0
  173. package/dist/editor/block-specs/paragraph/reconcile.d.ts +2 -0
  174. package/dist/editor/block-specs/paragraph/reconcile.js +9 -0
  175. package/dist/editor/block-specs/paragraph/serialize.d.ts +4 -0
  176. package/dist/editor/block-specs/paragraph/serialize.js +39 -0
  177. package/dist/editor/block-specs/paragraph/types.d.ts +10 -0
  178. package/dist/editor/block-specs/paragraph/types.js +1 -0
  179. package/dist/editor/block-specs/paragraphSpec.d.ts +2 -0
  180. package/dist/editor/block-specs/paragraphSpec.js +24 -0
  181. package/dist/editor/block-specs/registry.d.ts +10 -0
  182. package/dist/editor/block-specs/registry.js +34 -0
  183. package/dist/editor/block-specs/table/TableRenderer.svelte +53 -0
  184. package/dist/editor/block-specs/table/TableRenderer.svelte.d.ts +21 -0
  185. package/dist/editor/block-specs/table/commands.d.ts +2 -0
  186. package/dist/editor/block-specs/table/commands.js +1 -0
  187. package/dist/editor/block-specs/table/edit.d.ts +10 -0
  188. package/dist/editor/block-specs/table/edit.js +127 -0
  189. package/dist/editor/block-specs/table/editCommands.d.ts +18 -0
  190. package/dist/editor/block-specs/table/editCommands.js +87 -0
  191. package/dist/editor/block-specs/table/index.d.ts +8 -0
  192. package/dist/editor/block-specs/table/index.js +6 -0
  193. package/dist/editor/block-specs/table/inlineSecondPass.d.ts +3 -0
  194. package/dist/editor/block-specs/table/inlineSecondPass.js +22 -0
  195. package/dist/editor/block-specs/table/parse.d.ts +17 -0
  196. package/dist/editor/block-specs/table/parse.js +181 -0
  197. package/dist/editor/block-specs/table/reconcile.d.ts +2 -0
  198. package/dist/editor/block-specs/table/reconcile.js +6 -0
  199. package/dist/editor/block-specs/table/serialize.d.ts +3 -0
  200. package/dist/editor/block-specs/table/serialize.js +32 -0
  201. package/dist/editor/block-specs/table/types.d.ts +11 -0
  202. package/dist/editor/block-specs/table/types.js +1 -0
  203. package/dist/editor/block-specs/tableSpec.d.ts +2 -0
  204. package/dist/editor/block-specs/tableSpec.js +25 -0
  205. package/dist/editor/block-specs/toc/EditableToc.svelte +16 -0
  206. package/dist/editor/block-specs/toc/EditableToc.svelte.d.ts +4 -0
  207. package/dist/editor/block-specs/toc/TocRenderer.svelte +22 -0
  208. package/dist/editor/block-specs/toc/TocRenderer.svelte.d.ts +21 -0
  209. package/dist/editor/block-specs/toc/commands.d.ts +2 -0
  210. package/dist/editor/block-specs/toc/commands.js +1 -0
  211. package/dist/editor/block-specs/toc/index.d.ts +6 -0
  212. package/dist/editor/block-specs/toc/index.js +5 -0
  213. package/dist/editor/block-specs/toc/inlineSecondPass.d.ts +3 -0
  214. package/dist/editor/block-specs/toc/inlineSecondPass.js +5 -0
  215. package/dist/editor/block-specs/toc/parse.d.ts +10 -0
  216. package/dist/editor/block-specs/toc/parse.js +43 -0
  217. package/dist/editor/block-specs/toc/reconcile.d.ts +2 -0
  218. package/dist/editor/block-specs/toc/reconcile.js +5 -0
  219. package/dist/editor/block-specs/toc/serialize.d.ts +2 -0
  220. package/dist/editor/block-specs/toc/serialize.js +6 -0
  221. package/dist/editor/block-specs/toc/types.d.ts +8 -0
  222. package/dist/editor/block-specs/toc/types.js +1 -0
  223. package/dist/editor/block-specs/tocSpec.d.ts +2 -0
  224. package/dist/editor/block-specs/tocSpec.js +24 -0
  225. package/dist/editor/block-specs/toggle/ToggleRenderer.svelte +19 -0
  226. package/dist/editor/block-specs/toggle/ToggleRenderer.svelte.d.ts +21 -0
  227. package/dist/editor/block-specs/toggle/commands.d.ts +2 -0
  228. package/dist/editor/block-specs/toggle/commands.js +1 -0
  229. package/dist/editor/block-specs/toggle/index.d.ts +7 -0
  230. package/dist/editor/block-specs/toggle/index.js +5 -0
  231. package/dist/editor/block-specs/toggle/inlineSecondPass.d.ts +3 -0
  232. package/dist/editor/block-specs/toggle/inlineSecondPass.js +5 -0
  233. package/dist/editor/block-specs/toggle/parse.d.ts +9 -0
  234. package/dist/editor/block-specs/toggle/parse.js +78 -0
  235. package/dist/editor/block-specs/toggle/reconcile.d.ts +2 -0
  236. package/dist/editor/block-specs/toggle/reconcile.js +6 -0
  237. package/dist/editor/block-specs/toggle/serialize.d.ts +4 -0
  238. package/dist/editor/block-specs/toggle/serialize.js +13 -0
  239. package/dist/editor/block-specs/toggle/types.d.ts +5 -0
  240. package/dist/editor/block-specs/toggle/types.js +1 -0
  241. package/dist/editor/block-specs/toggleSpec.d.ts +2 -0
  242. package/dist/editor/block-specs/toggleSpec.js +24 -0
  243. package/dist/editor/block-specs/types.d.ts +26 -0
  244. package/dist/editor/block-specs/types.js +1 -0
  245. package/dist/editor/blocks/EditableBlockquote.svelte +52 -0
  246. package/dist/editor/blocks/EditableBlockquote.svelte.d.ts +10 -0
  247. package/dist/editor/blocks/EditableBlockquoteNodes.svelte +134 -0
  248. package/dist/editor/blocks/EditableBlockquoteNodes.svelte.d.ts +14 -0
  249. package/dist/editor/blocks/EditableBlockquoteParagraph.svelte +44 -0
  250. package/dist/editor/blocks/EditableBlockquoteParagraph.svelte.d.ts +12 -0
  251. package/dist/editor/blocks/EditableCallout.svelte +182 -0
  252. package/dist/editor/blocks/EditableCallout.svelte.d.ts +11 -0
  253. package/dist/editor/blocks/EditableCalloutListItemRow.svelte +169 -0
  254. package/dist/editor/blocks/EditableCalloutListItemRow.svelte.d.ts +15 -0
  255. package/dist/editor/blocks/EditableCalloutNodes.svelte +91 -0
  256. package/dist/editor/blocks/EditableCalloutNodes.svelte.d.ts +13 -0
  257. package/dist/editor/blocks/EditableCalloutParagraph.svelte +39 -0
  258. package/dist/editor/blocks/EditableCalloutParagraph.svelte.d.ts +12 -0
  259. package/dist/editor/blocks/EditableCodeBlock.svelte +43 -0
  260. package/dist/editor/blocks/EditableCodeBlock.svelte.d.ts +10 -0
  261. package/dist/editor/blocks/EditableHeading.svelte +161 -0
  262. package/dist/editor/blocks/EditableHeading.svelte.d.ts +10 -0
  263. package/dist/editor/blocks/EditableHorizontalRule.svelte +20 -0
  264. package/dist/editor/blocks/EditableHorizontalRule.svelte.d.ts +10 -0
  265. package/dist/editor/blocks/EditableInlineSurface.svelte +423 -0
  266. package/dist/editor/blocks/EditableInlineSurface.svelte.d.ts +26 -0
  267. package/dist/editor/blocks/EditableList.svelte +77 -0
  268. package/dist/editor/blocks/EditableList.svelte.d.ts +17 -0
  269. package/dist/editor/blocks/EditableListItemRow.svelte +231 -0
  270. package/dist/editor/blocks/EditableListItemRow.svelte.d.ts +19 -0
  271. package/dist/editor/blocks/EditableParagraph.svelte +208 -0
  272. package/dist/editor/blocks/EditableParagraph.svelte.d.ts +10 -0
  273. package/dist/editor/blocks/EditableParagraphNodes.svelte +89 -0
  274. package/dist/editor/blocks/EditableParagraphNodes.svelte.d.ts +15 -0
  275. package/dist/editor/blocks/EditableTable.svelte +83 -0
  276. package/dist/editor/blocks/EditableTable.svelte.d.ts +10 -0
  277. package/dist/editor/blocks/EditableTableCell.svelte +89 -0
  278. package/dist/editor/blocks/EditableTableCell.svelte.d.ts +15 -0
  279. package/dist/editor/blocks/EditableToggle.svelte +94 -0
  280. package/dist/editor/blocks/EditableToggle.svelte.d.ts +10 -0
  281. package/dist/editor/commandMenu.d.ts +18 -0
  282. package/dist/editor/commandMenu.js +83 -0
  283. package/dist/editor/commandRegistry.d.ts +48 -0
  284. package/dist/editor/commandRegistry.js +133 -0
  285. package/dist/editor/context/assetBaseUrl.d.ts +6 -0
  286. package/dist/editor/context/assetBaseUrl.js +20 -0
  287. package/dist/editor/dom/editorHistoryKeydown.d.ts +6 -0
  288. package/dist/editor/dom/editorHistoryKeydown.js +31 -0
  289. package/dist/editor/dom/plainEnterKeydown.d.ts +12 -0
  290. package/dist/editor/dom/plainEnterKeydown.js +53 -0
  291. package/dist/editor/dom/plaintextCaret.d.ts +12 -0
  292. package/dist/editor/dom/plaintextCaret.js +61 -0
  293. package/dist/editor/dom/syncDocumentSelectionFocus.d.ts +17 -0
  294. package/dist/editor/dom/syncDocumentSelectionFocus.js +56 -0
  295. package/dist/editor/draftPersistence.d.ts +27 -0
  296. package/dist/editor/draftPersistence.js +83 -0
  297. package/dist/editor/editorHistoryHandle.d.ts +16 -0
  298. package/dist/editor/editorHistoryHandle.js +22 -0
  299. package/dist/editor/inlineChrome/InlineChromeCoordinator.svelte +174 -0
  300. package/dist/editor/inlineChrome/InlineChromeCoordinator.svelte.d.ts +8 -0
  301. package/dist/editor/inlineChrome/InlineFormattingToolbar.svelte +181 -0
  302. package/dist/editor/inlineChrome/InlineFormattingToolbar.svelte.d.ts +3 -0
  303. package/dist/editor/inlineChrome/inlineChromeActions.d.ts +17 -0
  304. package/dist/editor/inlineChrome/inlineChromeActions.js +148 -0
  305. package/dist/editor/inlineChrome/inlineChromeState.svelte.d.ts +23 -0
  306. package/dist/editor/inlineChrome/inlineChromeState.svelte.js +21 -0
  307. package/dist/editor/inlineChrome/inlineToolbarIcons.d.ts +14 -0
  308. package/dist/editor/inlineChrome/inlineToolbarIcons.js +14 -0
  309. package/dist/editor/inlineChrome/inlineWrapActive.d.ts +3 -0
  310. package/dist/editor/inlineChrome/inlineWrapActive.js +19 -0
  311. package/dist/editor/inlineChrome/selectionRect.d.ts +2 -0
  312. package/dist/editor/inlineChrome/selectionRect.js +23 -0
  313. package/dist/editor/model/blockEditCommands.d.ts +73 -0
  314. package/dist/editor/model/blockEditCommands.js +719 -0
  315. package/dist/editor/model/blockTree.d.ts +39 -0
  316. package/dist/editor/model/blockTree.js +185 -0
  317. package/dist/editor/model/blockTreeDrop.d.ts +9 -0
  318. package/dist/editor/model/blockTreeDrop.js +295 -0
  319. package/dist/editor/model/blockTreeMutations.d.ts +10 -0
  320. package/dist/editor/model/blockTreeMutations.js +68 -0
  321. package/dist/editor/model/calloutEditCommands.d.ts +39 -0
  322. package/dist/editor/model/calloutEditCommands.js +305 -0
  323. package/dist/editor/model/documentSelection.d.ts +8 -0
  324. package/dist/editor/model/documentSelection.js +56 -0
  325. package/dist/editor/model/documentSelectionFromSource.d.ts +3 -0
  326. package/dist/editor/model/documentSelectionFromSource.js +45 -0
  327. package/dist/editor/model/documentToRenderBlocks.d.ts +3 -0
  328. package/dist/editor/model/documentToRenderBlocks.js +13 -0
  329. package/dist/editor/model/editorPipeline.bench.d.ts +1 -0
  330. package/dist/editor/model/editorPipeline.bench.js +27 -0
  331. package/dist/editor/model/editorTransactions.d.ts +20 -0
  332. package/dist/editor/model/editorTransactions.js +68 -0
  333. package/dist/editor/model/emptyParagraph.d.ts +11 -0
  334. package/dist/editor/model/emptyParagraph.js +25 -0
  335. package/dist/editor/model/enterCommands.d.ts +16 -0
  336. package/dist/editor/model/enterCommands.js +288 -0
  337. package/dist/editor/model/extensionSyntaxWarnings.d.ts +29 -0
  338. package/dist/editor/model/extensionSyntaxWarnings.js +122 -0
  339. package/dist/editor/model/findBlockAtSourceOffset.d.ts +3 -0
  340. package/dist/editor/model/findBlockAtSourceOffset.js +20 -0
  341. package/dist/editor/model/fixtures/serialization-fidelity/reorder-gaps.svelte +4 -0
  342. package/dist/editor/model/focusOutcome.d.ts +25 -0
  343. package/dist/editor/model/focusOutcome.js +1 -0
  344. package/dist/editor/model/incrementalReparse.d.ts +16 -0
  345. package/dist/editor/model/incrementalReparse.js +111 -0
  346. package/dist/editor/model/index.d.ts +22 -0
  347. package/dist/editor/model/index.js +19 -0
  348. package/dist/editor/model/inlineDraftCommit.d.ts +17 -0
  349. package/dist/editor/model/inlineDraftCommit.js +187 -0
  350. package/dist/editor/model/inlineDraftMerge.d.ts +8 -0
  351. package/dist/editor/model/inlineDraftMerge.js +81 -0
  352. package/dist/editor/model/inlineEditCommands.d.ts +28 -0
  353. package/dist/editor/model/inlineEditCommands.js +581 -0
  354. package/dist/editor/model/inlinePlain.d.ts +3 -0
  355. package/dist/editor/model/inlinePlain.js +28 -0
  356. package/dist/editor/model/inlineSecondPass.d.ts +4 -0
  357. package/dist/editor/model/inlineSecondPass.js +47 -0
  358. package/dist/editor/model/line-utils.d.ts +14 -0
  359. package/dist/editor/model/line-utils.js +38 -0
  360. package/dist/editor/model/listEditCommands.d.ts +56 -0
  361. package/dist/editor/model/listEditCommands.js +299 -0
  362. package/dist/editor/model/nestedContainerTransactions.d.ts +36 -0
  363. package/dist/editor/model/nestedContainerTransactions.js +336 -0
  364. package/dist/editor/model/parseMarkdownDocument.d.ts +2 -0
  365. package/dist/editor/model/parseMarkdownDocument.js +324 -0
  366. package/dist/editor/model/quoteEditCommands.d.ts +39 -0
  367. package/dist/editor/model/quoteEditCommands.js +323 -0
  368. package/dist/editor/model/reconcileBlockIds.d.ts +9 -0
  369. package/dist/editor/model/reconcileBlockIds.js +297 -0
  370. package/dist/editor/model/reparseOptions.d.ts +12 -0
  371. package/dist/editor/model/reparseOptions.js +1 -0
  372. package/dist/editor/model/resolveEnterPlainSnapshot.d.ts +6 -0
  373. package/dist/editor/model/resolveEnterPlainSnapshot.js +23 -0
  374. package/dist/editor/model/richInlines.d.ts +16 -0
  375. package/dist/editor/model/richInlines.js +494 -0
  376. package/dist/editor/model/serializeInlineNodes.d.ts +3 -0
  377. package/dist/editor/model/serializeInlineNodes.js +45 -0
  378. package/dist/editor/model/serializeMarkdownDocument.d.ts +30 -0
  379. package/dist/editor/model/serializeMarkdownDocument.js +150 -0
  380. package/dist/editor/model/structureParseWarnings.d.ts +10 -0
  381. package/dist/editor/model/structureParseWarnings.js +60 -0
  382. package/dist/editor/model/syntheticInlineRanges.d.ts +3 -0
  383. package/dist/editor/model/syntheticInlineRanges.js +36 -0
  384. package/dist/editor/model/types.d.ts +185 -0
  385. package/dist/editor/model/types.js +26 -0
  386. package/dist/editor/plugins/autolinks/AutolinkRenderer.svelte +20 -0
  387. package/dist/editor/plugins/autolinks/AutolinkRenderer.svelte.d.ts +21 -0
  388. package/dist/editor/plugins/autolinks/index.d.ts +2 -0
  389. package/dist/editor/plugins/autolinks/index.js +4 -0
  390. package/dist/editor/plugins/autolinks/parse-autolinks.d.ts +2 -0
  391. package/dist/editor/plugins/autolinks/parse-autolinks.js +68 -0
  392. package/dist/editor/plugins/autolinks/types.d.ts +6 -0
  393. package/dist/editor/plugins/autolinks/types.js +1 -0
  394. package/dist/editor/plugins/emphasis/EmphasisRenderer.svelte +15 -0
  395. package/dist/editor/plugins/emphasis/EmphasisRenderer.svelte.d.ts +21 -0
  396. package/dist/editor/plugins/emphasis/index.d.ts +2 -0
  397. package/dist/editor/plugins/emphasis/index.js +4 -0
  398. package/dist/editor/plugins/emphasis/parse-emphasis.d.ts +2 -0
  399. package/dist/editor/plugins/emphasis/parse-emphasis.js +188 -0
  400. package/dist/editor/plugins/emphasis/types.d.ts +24 -0
  401. package/dist/editor/plugins/emphasis/types.js +1 -0
  402. package/dist/editor/plugins/escaping/EscapingRenderer.svelte +18 -0
  403. package/dist/editor/plugins/escaping/EscapingRenderer.svelte.d.ts +21 -0
  404. package/dist/editor/plugins/escaping/index.d.ts +2 -0
  405. package/dist/editor/plugins/escaping/index.js +4 -0
  406. package/dist/editor/plugins/escaping/parse-escaping.d.ts +6 -0
  407. package/dist/editor/plugins/escaping/parse-escaping.js +26 -0
  408. package/dist/editor/plugins/escaping/types.d.ts +10 -0
  409. package/dist/editor/plugins/escaping/types.js +1 -0
  410. package/dist/editor/plugins/extended-task-list/ExtendedTaskListRenderer.svelte +25 -0
  411. package/dist/editor/plugins/extended-task-list/ExtendedTaskListRenderer.svelte.d.ts +21 -0
  412. package/dist/editor/plugins/extended-task-list/index.d.ts +2 -0
  413. package/dist/editor/plugins/extended-task-list/index.js +4 -0
  414. package/dist/editor/plugins/extended-task-list/parse-extended-task-list.d.ts +2 -0
  415. package/dist/editor/plugins/extended-task-list/parse-extended-task-list.js +35 -0
  416. package/dist/editor/plugins/extended-task-list/types.d.ts +6 -0
  417. package/dist/editor/plugins/extended-task-list/types.js +1 -0
  418. package/dist/editor/plugins/highlight/HighlightRenderer.svelte +16 -0
  419. package/dist/editor/plugins/highlight/HighlightRenderer.svelte.d.ts +21 -0
  420. package/dist/editor/plugins/highlight/index.d.ts +2 -0
  421. package/dist/editor/plugins/highlight/index.js +4 -0
  422. package/dist/editor/plugins/highlight/parse-highlights.d.ts +4 -0
  423. package/dist/editor/plugins/highlight/parse-highlights.js +49 -0
  424. package/dist/editor/plugins/highlight/types.d.ts +6 -0
  425. package/dist/editor/plugins/highlight/types.js +1 -0
  426. package/dist/editor/plugins/index.d.ts +1 -0
  427. package/dist/editor/plugins/index.js +1 -0
  428. package/dist/editor/plugins/links-images/LinksImagesRenderer.svelte +53 -0
  429. package/dist/editor/plugins/links-images/LinksImagesRenderer.svelte.d.ts +21 -0
  430. package/dist/editor/plugins/links-images/index.d.ts +2 -0
  431. package/dist/editor/plugins/links-images/index.js +4 -0
  432. package/dist/editor/plugins/links-images/parse-image-layout.d.ts +28 -0
  433. package/dist/editor/plugins/links-images/parse-image-layout.js +147 -0
  434. package/dist/editor/plugins/links-images/parse-links-images.d.ts +25 -0
  435. package/dist/editor/plugins/links-images/parse-links-images.js +236 -0
  436. package/dist/editor/plugins/links-images/resolve-asset-url.d.ts +5 -0
  437. package/dist/editor/plugins/links-images/resolve-asset-url.js +21 -0
  438. package/dist/editor/plugins/links-images/types.d.ts +11 -0
  439. package/dist/editor/plugins/links-images/types.js +1 -0
  440. package/dist/editor/plugins/mention/MentionRenderer.svelte +18 -0
  441. package/dist/editor/plugins/mention/MentionRenderer.svelte.d.ts +21 -0
  442. package/dist/editor/plugins/mention/index.d.ts +2 -0
  443. package/dist/editor/plugins/mention/index.js +4 -0
  444. package/dist/editor/plugins/mention/parse-mentions.d.ts +2 -0
  445. package/dist/editor/plugins/mention/parse-mentions.js +54 -0
  446. package/dist/editor/plugins/mention/types.d.ts +14 -0
  447. package/dist/editor/plugins/mention/types.js +1 -0
  448. package/dist/editor/plugins/raw-text/RawTextRenderer.svelte +19 -0
  449. package/dist/editor/plugins/raw-text/RawTextRenderer.svelte.d.ts +21 -0
  450. package/dist/editor/plugins/raw-text/index.d.ts +2 -0
  451. package/dist/editor/plugins/raw-text/index.js +4 -0
  452. package/dist/editor/plugins/raw-text/types.d.ts +4 -0
  453. package/dist/editor/plugins/raw-text/types.js +1 -0
  454. package/dist/editor/plugins/shared/InlineNodes.svelte +113 -0
  455. package/dist/editor/plugins/shared/InlineNodes.svelte.d.ts +21 -0
  456. package/dist/editor/plugins/shared/InlineNodesEdit.svelte +78 -0
  457. package/dist/editor/plugins/shared/InlineNodesEdit.svelte.d.ts +21 -0
  458. package/dist/editor/plugins/strikethrough/StrikethroughRenderer.svelte +9 -0
  459. package/dist/editor/plugins/strikethrough/StrikethroughRenderer.svelte.d.ts +21 -0
  460. package/dist/editor/plugins/strikethrough/index.d.ts +2 -0
  461. package/dist/editor/plugins/strikethrough/index.js +4 -0
  462. package/dist/editor/plugins/strikethrough/parse-strikethrough.d.ts +3 -0
  463. package/dist/editor/plugins/strikethrough/parse-strikethrough.js +38 -0
  464. package/dist/editor/plugins/strikethrough/types.d.ts +4 -0
  465. package/dist/editor/plugins/strikethrough/types.js +1 -0
  466. package/dist/editor/plugins/synced-block/SyncedBlockRenderer.svelte +16 -0
  467. package/dist/editor/plugins/synced-block/SyncedBlockRenderer.svelte.d.ts +21 -0
  468. package/dist/editor/plugins/synced-block/index.d.ts +2 -0
  469. package/dist/editor/plugins/synced-block/index.js +4 -0
  470. package/dist/editor/plugins/synced-block/parse-synced-blocks.d.ts +2 -0
  471. package/dist/editor/plugins/synced-block/parse-synced-blocks.js +15 -0
  472. package/dist/editor/plugins/synced-block/types.d.ts +4 -0
  473. package/dist/editor/plugins/synced-block/types.js +1 -0
  474. package/dist/editor/plugins/types.d.ts +19 -0
  475. package/dist/editor/plugins/types.js +1 -0
  476. package/dist/editor/plugins/wiki-link/WikiLinkRenderer.svelte +15 -0
  477. package/dist/editor/plugins/wiki-link/WikiLinkRenderer.svelte.d.ts +21 -0
  478. package/dist/editor/plugins/wiki-link/index.d.ts +2 -0
  479. package/dist/editor/plugins/wiki-link/index.js +4 -0
  480. package/dist/editor/plugins/wiki-link/parse-wiki-links.d.ts +2 -0
  481. package/dist/editor/plugins/wiki-link/parse-wiki-links.js +30 -0
  482. package/dist/editor/plugins/wiki-link/types.d.ts +8 -0
  483. package/dist/editor/plugins/wiki-link/types.js +1 -0
  484. package/dist/editor/taskCheckboxStates.d.ts +5 -0
  485. package/dist/editor/taskCheckboxStates.js +28 -0
  486. package/dist/index.d.ts +6 -0
  487. package/dist/index.js +9 -0
  488. package/dist/styles/index.css +6 -0
  489. package/package.json +84 -0
@@ -0,0 +1,150 @@
1
+ import { serializeBlockquoteBlock } from '../block-specs/blockquote';
2
+ import { serializeCalloutBlock } from '../block-specs/callout';
3
+ import { serializeCodeFenceBlock } from '../block-specs/codeFence';
4
+ import { serializeColumnsBlock } from '../block-specs/columns';
5
+ import { serializeHeadingBlock } from '../block-specs/heading';
6
+ import { serializeHorizontalRuleBlock } from '../block-specs/horizontalRule';
7
+ import { serializeListItem, serializeListRegion } from '../block-specs/list';
8
+ import { serializeParagraphBlock } from '../block-specs/paragraph';
9
+ import { serializeTableBlock } from '../block-specs/table';
10
+ import { serializeTocBlock } from '../block-specs/toc';
11
+ import { serializeToggleBlock } from '../block-specs/toggle';
12
+ /**
13
+ * Canonical Markdown emitted when a block is dirty or unknown (no faithful slice).
14
+ *
15
+ * - **Paragraph**: soft breaks as ` \\n`, hard breaks as `\\n`; see {@link serializeParagraphData}.
16
+ * - **Headings**: `#` × level + space + body; inline nodes preferred over plain `data.text`.
17
+ * - **Lists**: unordered `-`; ordered `n.`; tasks `- [x]` / `n. [x]` with marker chars from list-item
18
+ * data when set; nested child blocks indented with four spaces per level.
19
+ * - **Blockquote**: every line prefixed with `> `, or bare `>` for blank inner lines.
20
+ * - **Tables**: `| a | b |` rows; delimiter cells `:---`, `:---:`, `---:`, or `---` per column alignment.
21
+ * - **Callouts**: `> [!type] title` then `> body` / `>` for blank body lines.
22
+ * - **Toggles**: `+++ title`, body, closing `+++`.
23
+ * - **Columns**: `||| column head`, column lines, closing `|||`.
24
+ * - **Horizontal rule**: `---`; **TOC**: `::toc`.
25
+ */
26
+ export { serializeParagraphData } from '../block-specs/paragraph';
27
+ /** Serialize a single block to Markdown (no surrounding blank lines). Unknown types fall back to the original source slice when provided. */
28
+ export function serializeEditorBlock(block, source) {
29
+ switch (block.type) {
30
+ case 'codeFence':
31
+ return serializeCodeFenceBlock(block);
32
+ case 'heading':
33
+ return serializeHeadingBlock(block);
34
+ case 'horizontalRule':
35
+ return serializeHorizontalRuleBlock(block);
36
+ case 'blockquote':
37
+ return serializeBlockquoteBlock(block, (child) => serializeEditorBlock(child, source), source);
38
+ case 'listItem':
39
+ return serializeListItem(block, source);
40
+ case 'paragraph':
41
+ return serializeParagraphBlock(block);
42
+ case 'table':
43
+ return serializeTableBlock(block);
44
+ case 'callout':
45
+ return serializeCalloutBlock(block);
46
+ case 'toggle':
47
+ return serializeToggleBlock(block);
48
+ case 'columns':
49
+ return serializeColumnsBlock(block);
50
+ case 'toc':
51
+ return serializeTocBlock(block);
52
+ default:
53
+ if (source !== undefined && block.sourceRange.start >= 0 && !block.sourceRange.synthetic) {
54
+ return source.slice(block.sourceRange.start, block.sourceRange.end);
55
+ }
56
+ return '';
57
+ }
58
+ }
59
+ /** Serialize a contiguous slice of top-level blocks (list runs, paragraphs, etc.). */
60
+ export function serializeTopLevelBlockSpan(blocks, start, end, source) {
61
+ const parts = [];
62
+ let i = start;
63
+ while (i < end) {
64
+ const block = blocks[i];
65
+ if (block.type === 'listItem') {
66
+ let j = i;
67
+ while (j < end && blocks[j].type === 'listItem')
68
+ j++;
69
+ parts.push(serializeListRegion(blocks.slice(i, j), source));
70
+ i = j;
71
+ }
72
+ else {
73
+ parts.push(serializeEditorBlock(block, source));
74
+ i++;
75
+ }
76
+ }
77
+ return parts.join('\n\n');
78
+ }
79
+ export function serializeMarkdownDocument(doc) {
80
+ if (doc.blocks.length === 0)
81
+ return '';
82
+ const parts = [];
83
+ let i = 0;
84
+ while (i < doc.blocks.length) {
85
+ const block = doc.blocks[i];
86
+ if (block.type === 'listItem') {
87
+ const end = i;
88
+ let j = i;
89
+ while (j < doc.blocks.length && doc.blocks[j].type === 'listItem')
90
+ j++;
91
+ parts.push(serializeListRegion(doc.blocks.slice(i, j), doc.source));
92
+ i = j;
93
+ continue;
94
+ }
95
+ parts.push(serializeEditorBlock(block, doc.source));
96
+ i++;
97
+ }
98
+ return parts.join('\n\n');
99
+ }
100
+ /** When joining blocks without concrete source offsets (e.g. synthetic rows). */
101
+ const DEFAULT_GAP_NON_PRISTINE = '\n\n';
102
+ function emitTopLevelFromSourceSlice(block, dirtyTopLevelIds) {
103
+ return (!dirtyTopLevelIds.has(block.id) && block.sourceRange.start >= 0 && !block.sourceRange.synthetic);
104
+ }
105
+ function topLevelSourceAnchored(block) {
106
+ return !block.sourceRange.synthetic && block.sourceRange.start >= 0;
107
+ }
108
+ /** Gap bytes between adjacent top-level blocks in {@link EditorDocument.source}. */
109
+ function gapBetweenTopLevelBlocks(source, left, right, leftSerializedBody) {
110
+ if (topLevelSourceAnchored(left) &&
111
+ topLevelSourceAnchored(right) &&
112
+ left.sourceRange.end <= right.sourceRange.start) {
113
+ return source.slice(left.sourceRange.end, right.sourceRange.start);
114
+ }
115
+ return leftSerializedBody.endsWith('\n') ? '\n' : DEFAULT_GAP_NON_PRISTINE;
116
+ }
117
+ /**
118
+ * Serialize the document while preserving author bytes for unchanged top-level blocks.
119
+ * Unchanged blocks emit original source slices; prefix, suffix, and inter-block gaps copy
120
+ * `doc.source` whenever adjacent blocks have concrete UTF-16 ranges (including when only one
121
+ * side is pristine). Synthetic blocks or missing ranges fall back to {@link DEFAULT_GAP_NON_PRISTINE}.
122
+ *
123
+ * **Formatting policy** for dirty / non-slice blocks: see file-level doc comment above.
124
+ */
125
+ export function serializeMarkdownDocumentPreserving(doc, dirtyTopLevelIds) {
126
+ const { source, blocks } = doc;
127
+ if (blocks.length === 0)
128
+ return source;
129
+ const bodies = blocks.map((b) => emitTopLevelFromSourceSlice(b, dirtyTopLevelIds)
130
+ ? source.slice(b.sourceRange.start, b.sourceRange.end)
131
+ : serializeEditorBlock(b, source));
132
+ let out = '';
133
+ const first = blocks[0];
134
+ if (topLevelSourceAnchored(first)) {
135
+ out += source.slice(0, first.sourceRange.start);
136
+ }
137
+ for (let i = 0; i < blocks.length; i++) {
138
+ out += bodies[i];
139
+ if (i < blocks.length - 1) {
140
+ const left = blocks[i];
141
+ const right = blocks[i + 1];
142
+ out += gapBetweenTopLevelBlocks(source, left, right, bodies[i]);
143
+ }
144
+ }
145
+ const last = blocks[blocks.length - 1];
146
+ if (topLevelSourceAnchored(last)) {
147
+ out += source.slice(last.sourceRange.end, source.length);
148
+ }
149
+ return out;
150
+ }
@@ -0,0 +1,10 @@
1
+ import type { LineRow } from './line-utils';
2
+ /** Any map keyed by fence open line (value unused). */
3
+ type FenceLineMap = Map<number, unknown>;
4
+ /** Toggle opened with `+++ title` but no closing `+++`, or body interrupted by a fence. */
5
+ export declare function collectToggleStructureWarnings(rows: LineRow[], fenceAtOpenLine: FenceLineMap): string[];
6
+ /**
7
+ * When a line has GFM-table-like pipes but {@link tryParseTableAt} would fail, explain why.
8
+ */
9
+ export declare function explainTableParseFailure(i: number, rows: LineRow[], _fenceAtOpenLine: FenceLineMap): string | null;
10
+ export {};
@@ -0,0 +1,60 @@
1
+ import { parseDelimiterCell, splitTableRow } from '../block-specs/table/parse';
2
+ const TOGGLE_OPEN = /^\s*\+\+\+\s+(.+)$/;
3
+ const TOGGLE_CLOSE = /^\s*\+\+\+\s*$/;
4
+ /** Toggle opened with `+++ title` but no closing `+++`, or body interrupted by a fence. */
5
+ export function collectToggleStructureWarnings(rows, fenceAtOpenLine) {
6
+ const warns = [];
7
+ for (let i = 0; i < rows.length; i++) {
8
+ if (fenceAtOpenLine.has(i))
9
+ continue;
10
+ if (!TOGGLE_OPEN.test(rows[i].line))
11
+ continue;
12
+ let j = i + 1;
13
+ let closed = false;
14
+ while (j < rows.length) {
15
+ if (TOGGLE_CLOSE.test(rows[j].line)) {
16
+ closed = true;
17
+ break;
18
+ }
19
+ if (fenceAtOpenLine.has(j)) {
20
+ warns.push(`Line ${i + 1}: toggle body interrupted by a fenced code block before a closing +++ line.`);
21
+ break;
22
+ }
23
+ j++;
24
+ }
25
+ if (!closed && j >= rows.length) {
26
+ warns.push(`Line ${i + 1}: toggle opened with +++ but no closing +++ line before end of file.`);
27
+ }
28
+ }
29
+ return warns;
30
+ }
31
+ function pipeRowLooksLikeTableHeader(i, rows, fenceAtOpenLine) {
32
+ if (fenceAtOpenLine.has(i))
33
+ return false;
34
+ const line = rows[i]?.line ?? '';
35
+ if (!line.includes('|'))
36
+ return false;
37
+ return splitTableRow(line).length > 0;
38
+ }
39
+ /**
40
+ * When a line has GFM-table-like pipes but {@link tryParseTableAt} would fail, explain why.
41
+ */
42
+ export function explainTableParseFailure(i, rows, _fenceAtOpenLine) {
43
+ if (!pipeRowLooksLikeTableHeader(i, rows, _fenceAtOpenLine))
44
+ return null;
45
+ const headerCells = splitTableRow(rows[i].line);
46
+ if (i + 1 >= rows.length) {
47
+ return `Line ${i + 1}: pipe row looks like a table header, but there is no following delimiter row.`;
48
+ }
49
+ const delimCells = splitTableRow(rows[i + 1].line);
50
+ if (delimCells.length !== headerCells.length) {
51
+ return `Line ${i + 1}: table header has ${headerCells.length} column(s) but line ${i + 2} has ${delimCells.length} cell(s); not parsed as a GFM table.`;
52
+ }
53
+ for (let k = 0; k < delimCells.length; k++) {
54
+ if (parseDelimiterCell(delimCells[k]) === undefined) {
55
+ const raw = delimCells[k]?.trim() ?? '';
56
+ return `Line ${i + 2}: column ${k + 1} delimiter "${raw}" is not valid GFM table syntax; table not recognized.`;
57
+ }
58
+ }
59
+ return `Line ${i + 1}: could not parse as a GFM table.`;
60
+ }
@@ -0,0 +1,3 @@
1
+ import type { InlineNode } from './types';
2
+ /** Blockquote bodies use a detached substring context; ranges are not absolute document offsets. */
3
+ export declare function withSyntheticRanges(nodes: InlineNode[]): InlineNode[];
@@ -0,0 +1,36 @@
1
+ function syntheticInlineRange() {
2
+ return { start: -1, end: -1, startLine: -1, endLine: -1, synthetic: true };
3
+ }
4
+ /** Blockquote bodies use a detached substring context; ranges are not absolute document offsets. */
5
+ export function withSyntheticRanges(nodes) {
6
+ function walk(n) {
7
+ const sr = syntheticInlineRange();
8
+ switch (n.type) {
9
+ case 'text':
10
+ case 'code':
11
+ case 'autolink':
12
+ case 'wikiLink':
13
+ case 'mention':
14
+ return { ...n, sourceRange: sr };
15
+ case 'link':
16
+ case 'image':
17
+ return {
18
+ ...n,
19
+ sourceRange: sr,
20
+ children: n.children.map(walk)
21
+ };
22
+ case 'emphasis':
23
+ case 'strong':
24
+ case 'strikethrough':
25
+ case 'highlight':
26
+ return {
27
+ ...n,
28
+ sourceRange: sr,
29
+ children: n.children.map(walk)
30
+ };
31
+ default:
32
+ return n;
33
+ }
34
+ }
35
+ return nodes.map(walk);
36
+ }
@@ -0,0 +1,185 @@
1
+ import type { TableCellAlign } from '../block-specs/table/types';
2
+ /**
3
+ * Character offsets into `EditorDocument.source` (0-based, end exclusive).
4
+ */
5
+ export type SourceRange = {
6
+ start: number;
7
+ end: number;
8
+ startLine: number;
9
+ endLine: number;
10
+ /**
11
+ * Generated blocks (TOC, etc.) do not map to one contiguous author slice.
12
+ * Convention: `start === end === -1` with line metadata (see ADR).
13
+ */
14
+ synthetic?: boolean;
15
+ };
16
+ export type InlineTextNode = {
17
+ type: 'text';
18
+ text: string;
19
+ sourceRange: SourceRange;
20
+ };
21
+ export type InlineEmphasisNode = {
22
+ type: 'emphasis';
23
+ children: InlineNode[];
24
+ sourceRange: SourceRange;
25
+ };
26
+ export type InlineStrongNode = {
27
+ type: 'strong';
28
+ children: InlineNode[];
29
+ sourceRange: SourceRange;
30
+ };
31
+ export type InlineCodeNode = {
32
+ type: 'code';
33
+ text: string;
34
+ sourceRange: SourceRange;
35
+ };
36
+ /** Checkbox semantics on unordered task list items (`- [ ]`, `- [x]`, `- [/]`, `- [>]`, …). */
37
+ export type TaskCheckboxState = 'todo' | 'done' | 'in_progress' | 'deferred' | 'other';
38
+ export type InlineLinkNode = {
39
+ type: 'link';
40
+ children: InlineNode[];
41
+ href: string | null;
42
+ title: string | null;
43
+ sourceRange: SourceRange;
44
+ };
45
+ export type ImageFloatAlign = 'left' | 'center' | 'right';
46
+ export type InlineImageNode = {
47
+ type: 'image';
48
+ children: InlineNode[];
49
+ href: string | null;
50
+ title: string | null;
51
+ /** Pixel width, `'full'` for `|-1`, or `null` for unsuffixed default thumbnail. */
52
+ displayWidth?: number | 'full' | null;
53
+ /** Block-on-own-line alignment when width is less than container; `null` for width-only inline default. */
54
+ floatAlign?: ImageFloatAlign | null;
55
+ sourceRange: SourceRange;
56
+ };
57
+ export type InlineStrikethroughNode = {
58
+ type: 'strikethrough';
59
+ children: InlineNode[];
60
+ sourceRange: SourceRange;
61
+ };
62
+ export type InlineHighlightNode = {
63
+ type: 'highlight';
64
+ /** When using `==color:text==`; otherwise null for plain `==text==`. */
65
+ color: string | null;
66
+ children: InlineNode[];
67
+ sourceRange: SourceRange;
68
+ };
69
+ export type InlineAutolinkNode = {
70
+ type: 'autolink';
71
+ href: string;
72
+ sourceRange: SourceRange;
73
+ };
74
+ export type InlineWikiLinkNode = {
75
+ type: 'wikiLink';
76
+ target: string;
77
+ label: string;
78
+ sourceRange: SourceRange;
79
+ };
80
+ export type InlineMentionNode = {
81
+ type: 'mention';
82
+ kind: 'user' | 'page';
83
+ name: string;
84
+ sourceRange: SourceRange;
85
+ };
86
+ export type InlineNode = InlineTextNode | InlineEmphasisNode | InlineStrongNode | InlineCodeNode | InlineLinkNode | InlineImageNode | InlineStrikethroughNode | InlineHighlightNode | InlineAutolinkNode | InlineWikiLinkNode | InlineMentionNode;
87
+ export type EditorBlockType = 'heading' | 'paragraph' | 'codeFence' | 'listItem' | 'blockquote' | 'horizontalRule' | 'table' | 'callout' | 'toggle' | 'columns' | 'toc';
88
+ /** Populated by `applyInlineSecondPass` for table cells. */
89
+ export type TableBlockData = {
90
+ headers: string[];
91
+ aligns: TableCellAlign[];
92
+ rows: string[][];
93
+ /** Source line of the header row (metadata for reconciliation / render). */
94
+ startLineIndex?: number;
95
+ headerInlines?: InlineNode[][];
96
+ rowInlines?: InlineNode[][][];
97
+ };
98
+ /** Canonical `data` for `listItem` blocks; nested items and loose content live under {@link EditorBlock.children}. */
99
+ export type ListItemBlockData = {
100
+ ordered: boolean;
101
+ ordinalValue?: number;
102
+ /** Marker indent in tab-stop columns (matches `parseListLine` output). */
103
+ indentColumns: number;
104
+ /** Set for unordered task items (`- [ ] item`, …). */
105
+ task?: TaskCheckboxState;
106
+ /** Raw marker when `task === 'other'` (single character inside brackets). */
107
+ taskMarkerChar?: string;
108
+ };
109
+ /** Canonical `data` for `blockquote` blocks; first-line body uses {@link EditorBlock.inlines}. */
110
+ export type BlockquoteBlockData = Record<string, never>;
111
+ export type EditorBlock = {
112
+ id: string;
113
+ type: EditorBlockType;
114
+ sourceRange: SourceRange;
115
+ data: unknown;
116
+ inlines?: InlineNode[];
117
+ /** Canonical nested model: list items, blockquote contents, etc. */
118
+ children?: EditorBlock[];
119
+ };
120
+ export type EditorDocument = {
121
+ source: string;
122
+ fileName: string | null;
123
+ blocks: EditorBlock[];
124
+ /** Recoverable parse issues (does not block editing). */
125
+ parseWarnings?: string[];
126
+ };
127
+ /** Character slice in **Markdown source** (UTF-16 code units, end exclusive). */
128
+ export type SourceSliceRange = {
129
+ start: number;
130
+ end: number;
131
+ };
132
+ /** Indices into nested {@link EditorBlock.children} from a top-level block downward. */
133
+ export type BlockPath = readonly number[];
134
+ /** Plain-text offsets within an editable surface (paragraph body, heading body, list item row). */
135
+ export type PlainTextRange = {
136
+ start: number;
137
+ end: number;
138
+ };
139
+ /** Focused cell within a {@link TableBlockData} grid (`row === -1` → header). */
140
+ export type TableCellAddress = {
141
+ row: number;
142
+ col: number;
143
+ };
144
+ /**
145
+ * Caret/selection addressed by the leaf editable block's stable id — survives reparse when ids reconcile.
146
+ * When `plain` is set, offsets are within that block's editable plain surface.
147
+ * For `table` blocks, {@link tableCell} identifies the active cell.
148
+ */
149
+ export type DocumentSelection = {
150
+ blockId: string;
151
+ plain?: PlainTextRange;
152
+ tableCell?: TableCellAddress;
153
+ };
154
+ /** One source mutation step inside an {@link EditorTransaction}. */
155
+ export type EditorOperation = {
156
+ type: 'replaceSlice';
157
+ range: SourceSliceRange;
158
+ text: string;
159
+ };
160
+ /** One user-visible edit: ordered source-slice ops plus post-apply caret. Undo/redo still snapshots source. */
161
+ export type EditorTransaction = {
162
+ id: string;
163
+ operations: EditorOperation[];
164
+ /** Source-offset caret after apply; UI will adopt {@link DocumentSelection} incrementally. */
165
+ selection: EditorSelection;
166
+ };
167
+ /** Character offsets into `EditorDocument.source` (UTF-16 indices, matching DOM Selection). */
168
+ export type EditorSelection = {
169
+ anchor: number;
170
+ focus: number;
171
+ };
172
+ /** One undo/redo snapshot: canonical source + caret after the edit that created this snapshot’s successor. */
173
+ export type EditorHistorySnapshot = {
174
+ source: string;
175
+ selection: EditorSelection;
176
+ /** Leaf-block caret at push time; null when only source-offset caret was known. */
177
+ documentSelection: DocumentSelection | null;
178
+ };
179
+ export declare function stableBlockId(type: string, range: SourceRange): string;
180
+ export declare function normalizeSelectionRange(sel: EditorSelection): {
181
+ start: number;
182
+ end: number;
183
+ };
184
+ export declare function clampSelection(sel: EditorSelection, sourceLength: number): EditorSelection;
185
+ export declare function syntheticRange(startLine: number, endLine: number): SourceRange;
@@ -0,0 +1,26 @@
1
+ export function stableBlockId(type, range) {
2
+ if (range.synthetic) {
3
+ return `${type}:syn:${range.startLine}:${range.endLine}`;
4
+ }
5
+ return `${type}:${range.start}:${range.end}`;
6
+ }
7
+ export function normalizeSelectionRange(sel) {
8
+ const a = sel.anchor;
9
+ const f = sel.focus;
10
+ return a <= f ? { start: a, end: f } : { start: f, end: a };
11
+ }
12
+ export function clampSelection(sel, sourceLength) {
13
+ const lo = 0;
14
+ const hi = Math.max(0, sourceLength);
15
+ const clamp = (n) => Math.min(Math.max(n, lo), hi);
16
+ return { anchor: clamp(sel.anchor), focus: clamp(sel.focus) };
17
+ }
18
+ export function syntheticRange(startLine, endLine) {
19
+ return {
20
+ start: -1,
21
+ end: -1,
22
+ startLine,
23
+ endLine,
24
+ synthetic: true
25
+ };
26
+ }
@@ -0,0 +1,20 @@
1
+ <script module lang="ts">
2
+ import type { AutolinkBlock } from './types';
3
+
4
+ export { autolinkRenderer };
5
+ </script>
6
+
7
+ <!-- eslint-disable svelte/no-navigation-without-resolve -- MD autolinks are arbitrary URLs, not app routes -->
8
+
9
+ {#snippet autolinkRenderer(block: AutolinkBlock)}
10
+ <p class="mb-4 text-sm text-txt-primary">
11
+ <a
12
+ href={block.url}
13
+ class="font-medium break-all text-accent-primary underline decoration-accent-primary/50 underline-offset-2 hover:text-accent-secondary"
14
+ target="_blank"
15
+ rel="noopener noreferrer"
16
+ >
17
+ {block.url}
18
+ </a>
19
+ </p>
20
+ {/snippet}
@@ -0,0 +1,21 @@
1
+ import type { AutolinkBlock } from './types';
2
+ declare const autolinkRenderer: (block: AutolinkBlock) => ReturnType<import("svelte").Snippet>;
3
+ export { autolinkRenderer };
4
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
5
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
+ $$bindings?: Bindings;
7
+ } & Exports;
8
+ (internal: unknown, props: {
9
+ $$events?: Events;
10
+ $$slots?: Slots;
11
+ }): Exports & {
12
+ $set?: any;
13
+ $on?: any;
14
+ };
15
+ z_$$bindings?: Bindings;
16
+ }
17
+ declare const AutolinkRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type AutolinkRenderer = InstanceType<typeof AutolinkRenderer>;
21
+ export default AutolinkRenderer;
@@ -0,0 +1,2 @@
1
+ import type { BlockRenderAdapter } from '../types';
2
+ export declare const autolinksPlugin: BlockRenderAdapter;
@@ -0,0 +1,4 @@
1
+ export const autolinksPlugin = {
2
+ id: 'autolinks',
3
+ name: 'Autolinks (GFM)'
4
+ };
@@ -0,0 +1,2 @@
1
+ import type { AutolinkBlock } from './types';
2
+ export declare function parseAutolinks(source: string): AutolinkBlock[];
@@ -0,0 +1,68 @@
1
+ /** Angle-bracket GFM autolinks: `<https://…>` (http/https, case-insensitive scheme). */
2
+ const ANGLE_AUTOLINK = /<(https?:\/\/[^>\s]+)>/gi;
3
+ /** Bare `http://` / `https://` token; trim trailing punctuation per GFM-style heuristics. */
4
+ const BARE_AUTOLINK = /\bhttps?:\/\/[^\s<]+/gi;
5
+ function spansOverlap(a, b) {
6
+ return !(a.end <= b.start || a.start >= b.end);
7
+ }
8
+ /** Strip trailing `.,;:!?` and unmatched closing parens from a bare URL match. */
9
+ function trimBareAutolinkSuffix(raw) {
10
+ let u = raw;
11
+ while (u.length > 0) {
12
+ const last = u[u.length - 1];
13
+ if ('.,;:!?'.includes(last)) {
14
+ u = u.slice(0, -1);
15
+ continue;
16
+ }
17
+ if (last === ')') {
18
+ const opens = (u.match(/\(/g) ?? []).length;
19
+ const closes = (u.match(/\)/g) ?? []).length;
20
+ if (closes > opens) {
21
+ u = u.slice(0, -1);
22
+ continue;
23
+ }
24
+ }
25
+ break;
26
+ }
27
+ return u;
28
+ }
29
+ export function parseAutolinks(source) {
30
+ const lines = source.split(/\r?\n/);
31
+ const out = [];
32
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
33
+ const line = lines[lineIndex];
34
+ const angleSpans = [];
35
+ let m;
36
+ ANGLE_AUTOLINK.lastIndex = 0;
37
+ while ((m = ANGLE_AUTOLINK.exec(line)) !== null) {
38
+ const start = m.index;
39
+ const end = start + m[0].length;
40
+ angleSpans.push({ start, end });
41
+ out.push({
42
+ kind: 'angle',
43
+ url: m[1],
44
+ lineIndex,
45
+ column: start
46
+ });
47
+ }
48
+ BARE_AUTOLINK.lastIndex = 0;
49
+ while ((m = BARE_AUTOLINK.exec(line)) !== null) {
50
+ const start = m.index;
51
+ const end = start + m[0].length;
52
+ const rawSpan = { start, end };
53
+ if (angleSpans.some((s) => spansOverlap(rawSpan, s)))
54
+ continue;
55
+ const trimmed = trimBareAutolinkSuffix(m[0]);
56
+ if (trimmed.length === 0)
57
+ continue;
58
+ out.push({
59
+ kind: 'bare',
60
+ url: trimmed,
61
+ lineIndex,
62
+ column: start
63
+ });
64
+ }
65
+ }
66
+ out.sort((a, b) => a.lineIndex - b.lineIndex || a.column - b.column);
67
+ return out;
68
+ }
@@ -0,0 +1,6 @@
1
+ export type AutolinkBlock = {
2
+ url: string;
3
+ lineIndex: number;
4
+ column: number;
5
+ kind: 'angle' | 'bare';
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ <script module lang="ts">
2
+ import type { EmphasisBlock } from './types';
3
+
4
+ export { emphasisRenderer };
5
+ </script>
6
+
7
+ {#snippet emphasisRenderer(block: EmphasisBlock)}
8
+ <p class="mb-4 text-sm text-txt-primary" data-kind={block.kind} data-offset={block.startOffset}>
9
+ {#if block.kind === 'emphasis'}
10
+ <em class="text-txt-primary italic">{block.text}</em>
11
+ {:else}
12
+ <strong class="font-semibold text-txt-primary">{block.text}</strong>
13
+ {/if}
14
+ </p>
15
+ {/snippet}
@@ -0,0 +1,21 @@
1
+ import type { EmphasisBlock } from './types';
2
+ declare const emphasisRenderer: (block: EmphasisBlock) => ReturnType<import("svelte").Snippet>;
3
+ export { emphasisRenderer };
4
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
5
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
+ $$bindings?: Bindings;
7
+ } & Exports;
8
+ (internal: unknown, props: {
9
+ $$events?: Events;
10
+ $$slots?: Slots;
11
+ }): Exports & {
12
+ $set?: any;
13
+ $on?: any;
14
+ };
15
+ z_$$bindings?: Bindings;
16
+ }
17
+ declare const EmphasisRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type EmphasisRenderer = InstanceType<typeof EmphasisRenderer>;
21
+ export default EmphasisRenderer;
@@ -0,0 +1,2 @@
1
+ import type { BlockRenderAdapter } from '../types';
2
+ export declare const emphasisPlugin: BlockRenderAdapter;
@@ -0,0 +1,4 @@
1
+ export const emphasisPlugin = {
2
+ id: 'emphasis',
3
+ name: 'Emphasis'
4
+ };
@@ -0,0 +1,2 @@
1
+ import type { EmphasisBlock } from './types';
2
+ export declare function parseEmphasis(source: string): EmphasisBlock[];