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,53 @@
1
+ <script module lang="ts">
2
+ import { inlineNodesSnippet } from '../../plugins/shared/InlineNodes.svelte';
3
+ import type { TableBlock, TableCellAlign } from './types';
4
+
5
+ const alignClass: Record<NonNullable<TableCellAlign>, string> = {
6
+ left: 'text-left',
7
+ center: 'text-center',
8
+ right: 'text-right'
9
+ };
10
+
11
+ function cellAlignClass(a: TableCellAlign): string {
12
+ return a ? alignClass[a] : 'text-left';
13
+ }
14
+
15
+ export { tableRenderer };
16
+ </script>
17
+
18
+ {#snippet tableRenderer(block: TableBlock)}
19
+ <div class="mb-4 overflow-x-auto">
20
+ <table
21
+ class="w-full min-w-[16rem] border-collapse border-b border-border-emphasis text-sm text-txt-primary"
22
+ >
23
+ <thead>
24
+ <tr class="border-b border-border-emphasis">
25
+ {#each block.headers as header, hIdx (hIdx)}
26
+ <th class="px-3 py-2 font-semibold {cellAlignClass(block.aligns[hIdx] ?? null)}">
27
+ {#if block.headerInlines?.[hIdx]?.length}
28
+ {@render inlineNodesSnippet(block.headerInlines[hIdx])}
29
+ {:else}
30
+ {header}
31
+ {/if}
32
+ </th>
33
+ {/each}
34
+ </tr>
35
+ </thead>
36
+ <tbody>
37
+ {#each block.rows as row, rIdx (rIdx)}
38
+ <tr class="border-t border-border-default/60">
39
+ {#each row as cell, cIdx (cIdx)}
40
+ <td class="px-3 py-2 {cellAlignClass(block.aligns[cIdx] ?? null)}">
41
+ {#if block.rowInlines?.[rIdx]?.[cIdx]?.length}
42
+ {@render inlineNodesSnippet(block.rowInlines[rIdx][cIdx])}
43
+ {:else}
44
+ {cell}
45
+ {/if}
46
+ </td>
47
+ {/each}
48
+ </tr>
49
+ {/each}
50
+ </tbody>
51
+ </table>
52
+ </div>
53
+ {/snippet}
@@ -0,0 +1,21 @@
1
+ import type { TableBlock } from './types';
2
+ declare const tableRenderer: (block: TableBlock) => ReturnType<import("svelte").Snippet>;
3
+ export { tableRenderer };
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 TableRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type TableRenderer = InstanceType<typeof TableRenderer>;
21
+ export default TableRenderer;
@@ -0,0 +1,2 @@
1
+ import type { EditorCommand } from '../../commandRegistry';
2
+ export declare const tableCommands: EditorCommand[];
@@ -0,0 +1 @@
1
+ export const tableCommands = [];
@@ -0,0 +1,10 @@
1
+ import type { InlineNode, TableBlockData, TableCellAddress } from '../../model/types';
2
+ import type { TableBlock } from './types';
3
+ export declare function tableBlockDataToRenderModel(d: TableBlockData): TableBlock;
4
+ export declare function defaultTableBlockData(): TableBlockData;
5
+ export declare function tableCellDisplayPlain(data: TableBlockData, row: number, col: number): string;
6
+ export declare function tableCellModelInlines(data: TableBlockData, row: number, col: number): InlineNode[] | undefined;
7
+ export declare function setTableCellInlines(data: TableBlockData, row: number, col: number, inlines: InlineNode[]): TableBlockData;
8
+ export declare function appendTableRow(data: TableBlockData): TableBlockData;
9
+ export declare function appendTableColumn(data: TableBlockData): TableBlockData;
10
+ export declare function navigateTableCell(data: TableBlockData, row: number, col: number, direction: 'next' | 'prev' | 'down' | 'up'): TableCellAddress | null;
@@ -0,0 +1,127 @@
1
+ import { cloneInlineNodeDeep } from '../../model/inlineEditCommands';
2
+ import { inlineNodesToPlainText } from '../../model/inlinePlain';
3
+ export function tableBlockDataToRenderModel(d) {
4
+ return {
5
+ lineIndex: d.startLineIndex ?? 0,
6
+ headers: d.headers,
7
+ aligns: d.aligns,
8
+ rows: d.rows,
9
+ headerInlines: d.headerInlines,
10
+ rowInlines: d.rowInlines
11
+ };
12
+ }
13
+ export function defaultTableBlockData() {
14
+ return {
15
+ headers: ['', ''],
16
+ aligns: [null, null],
17
+ rows: []
18
+ };
19
+ }
20
+ export function tableCellDisplayPlain(data, row, col) {
21
+ if (row === -1) {
22
+ const inlines = data.headerInlines?.[col];
23
+ if (inlines?.length)
24
+ return inlineNodesToPlainText(inlines);
25
+ return data.headers[col] ?? '';
26
+ }
27
+ const inlines = data.rowInlines?.[row]?.[col];
28
+ if (inlines?.length)
29
+ return inlineNodesToPlainText(inlines);
30
+ return data.rows[row]?.[col] ?? '';
31
+ }
32
+ export function tableCellModelInlines(data, row, col) {
33
+ if (row === -1)
34
+ return data.headerInlines?.[col];
35
+ return data.rowInlines?.[row]?.[col];
36
+ }
37
+ export function setTableCellInlines(data, row, col, inlines) {
38
+ const plain = inlineNodesToPlainText(inlines);
39
+ const cloned = inlines.map(cloneInlineNodeDeep);
40
+ const next = {
41
+ ...data,
42
+ headers: [...data.headers],
43
+ aligns: [...data.aligns],
44
+ rows: data.rows.map((r) => [...r]),
45
+ headerInlines: data.headerInlines?.map((rowInlines) => rowInlines.map(cloneInlineNodeDeep)),
46
+ rowInlines: data.rowInlines?.map((bodyRow) => bodyRow.map((cellInlines) => cellInlines.map(cloneInlineNodeDeep)))
47
+ };
48
+ if (row === -1) {
49
+ next.headers[col] = plain;
50
+ const headerInlines = [...(next.headerInlines ?? [])];
51
+ while (headerInlines.length < next.headers.length)
52
+ headerInlines.push([]);
53
+ headerInlines[col] = cloned;
54
+ next.headerInlines = headerInlines;
55
+ return next;
56
+ }
57
+ while (next.rows.length <= row) {
58
+ next.rows.push(new Array(next.headers.length).fill(''));
59
+ }
60
+ next.rows[row][col] = plain;
61
+ const rowInlines = [...(next.rowInlines ?? [])];
62
+ while (rowInlines.length <= row) {
63
+ rowInlines.push([]);
64
+ }
65
+ const cellRow = [...(rowInlines[row] ?? new Array(next.headers.length).fill(undefined))];
66
+ while (cellRow.length < next.headers.length)
67
+ cellRow.push([]);
68
+ cellRow[col] = cloned;
69
+ rowInlines[row] = cellRow;
70
+ next.rowInlines = rowInlines;
71
+ return next;
72
+ }
73
+ export function appendTableRow(data) {
74
+ const cols = data.headers.length;
75
+ return {
76
+ ...data,
77
+ rows: [...data.rows, new Array(cols).fill('')]
78
+ };
79
+ }
80
+ export function appendTableColumn(data) {
81
+ return {
82
+ ...data,
83
+ headers: [...data.headers, ''],
84
+ aligns: [...data.aligns, null],
85
+ rows: data.rows.map((row) => [...row, ''])
86
+ };
87
+ }
88
+ export function navigateTableCell(data, row, col, direction) {
89
+ const cols = data.headers.length;
90
+ const bodyRows = data.rows.length;
91
+ if (direction === 'next') {
92
+ if (col + 1 < cols)
93
+ return { row, col: col + 1 };
94
+ if (row === -1) {
95
+ if (bodyRows > 0)
96
+ return { row: 0, col: 0 };
97
+ return null;
98
+ }
99
+ if (row + 1 < bodyRows)
100
+ return { row: row + 1, col: 0 };
101
+ return null;
102
+ }
103
+ if (direction === 'prev') {
104
+ if (col > 0)
105
+ return { row, col: col - 1 };
106
+ if (row === 0)
107
+ return { row: -1, col: cols - 1 };
108
+ if (row > 0)
109
+ return { row: row - 1, col: cols - 1 };
110
+ return null;
111
+ }
112
+ if (direction === 'down') {
113
+ if (row === -1) {
114
+ if (bodyRows > 0)
115
+ return { row: 0, col };
116
+ return null;
117
+ }
118
+ if (row + 1 < bodyRows)
119
+ return { row: row + 1, col };
120
+ return null;
121
+ }
122
+ if (row === 0)
123
+ return { row: -1, col };
124
+ if (row > 0)
125
+ return { row: row - 1, col };
126
+ return null;
127
+ }
@@ -0,0 +1,18 @@
1
+ import { type SourceEditOk, type SourceEditResult } from '../../model/blockEditCommands';
2
+ import type { EditorDocument, InlineNode, TableCellAddress } from '../../model/types';
3
+ import { navigateTableCell } from './edit';
4
+ /** Persist one cell's draft inlines to Markdown source (whole-table reserialize). */
5
+ export declare function commitTableCellInlineDraft(source: string, doc: EditorDocument, blockIndex: number, row: number, col: number, inlines: InlineNode[], _plainCaret: number): SourceEditResult;
6
+ export declare function appendTableRowInDocument(source: string, doc: EditorDocument, blockIndex: number): SourceEditResult | (SourceEditOk & {
7
+ focusCell: TableCellAddress;
8
+ });
9
+ export declare function appendTableColumnInDocument(source: string, doc: EditorDocument, blockIndex: number): SourceEditResult | (SourceEditOk & {
10
+ focusCell: TableCellAddress;
11
+ });
12
+ export declare function navigateTableCellInDocument(source: string, doc: EditorDocument, blockIndex: number, from: TableCellAddress, to: TableCellAddress, inlines: InlineNode[], plainCaret: number): SourceEditResult | (SourceEditOk & {
13
+ focusCell: TableCellAddress;
14
+ focusPlain: number;
15
+ });
16
+ export { navigateTableCell };
17
+ export declare function convertBlockToTable(source: string, doc: EditorDocument, blockIndex: number): SourceEditResult;
18
+ export declare function cloneTableCellInlines(inlines: InlineNode[]): InlineNode[];
@@ -0,0 +1,87 @@
1
+ import { replaceBlockSourceRange } from '../../model/blockEditCommands';
2
+ import { cloneInlineNodeDeep } from '../../model/inlineEditCommands';
3
+ import { inlineNodesToPlainText } from '../../model/inlinePlain';
4
+ import { clampSelection } from '../../model/types';
5
+ import { appendTableColumn, appendTableRow, defaultTableBlockData, navigateTableCell, setTableCellInlines, tableCellDisplayPlain } from './edit';
6
+ import { serializeTableData } from './serialize';
7
+ function replaceTableBlock(source, blockIndex, doc, data) {
8
+ const block = doc.blocks[blockIndex];
9
+ if (!block || block.type !== 'table')
10
+ return { ok: false, error: 'Invalid table block.' };
11
+ if (block.sourceRange.synthetic || block.sourceRange.start < 0) {
12
+ return { ok: false, error: 'Block is not editable.' };
13
+ }
14
+ const replacement = serializeTableData(data);
15
+ const newSource = replaceBlockSourceRange(source, block.sourceRange.start, block.sourceRange.end, replacement);
16
+ const anchor = block.sourceRange.start;
17
+ return {
18
+ ok: true,
19
+ source: newSource,
20
+ selection: clampSelection({ anchor, focus: anchor }, newSource.length)
21
+ };
22
+ }
23
+ /** Persist one cell's draft inlines to Markdown source (whole-table reserialize). */
24
+ export function commitTableCellInlineDraft(source, doc, blockIndex, row, col, inlines, _plainCaret) {
25
+ void _plainCaret;
26
+ const block = doc.blocks[blockIndex];
27
+ if (!block || block.type !== 'table')
28
+ return { ok: false, error: 'Invalid table block.' };
29
+ const data = setTableCellInlines(block.data, row, col, inlines);
30
+ return replaceTableBlock(source, blockIndex, doc, data);
31
+ }
32
+ export function appendTableRowInDocument(source, doc, blockIndex) {
33
+ const block = doc.blocks[blockIndex];
34
+ if (!block || block.type !== 'table')
35
+ return { ok: false, error: 'Invalid table block.' };
36
+ const data = appendTableRow(block.data);
37
+ const result = replaceTableBlock(source, blockIndex, doc, data);
38
+ if (!result.ok)
39
+ return result;
40
+ const lastRow = data.rows.length - 1;
41
+ return { ...result, focusCell: { row: lastRow, col: 0 } };
42
+ }
43
+ export function appendTableColumnInDocument(source, doc, blockIndex) {
44
+ const block = doc.blocks[blockIndex];
45
+ if (!block || block.type !== 'table')
46
+ return { ok: false, error: 'Invalid table block.' };
47
+ const data = appendTableColumn(block.data);
48
+ const result = replaceTableBlock(source, blockIndex, doc, data);
49
+ if (!result.ok)
50
+ return result;
51
+ return { ...result, focusCell: { row: -1, col: data.headers.length - 1 } };
52
+ }
53
+ export function navigateTableCellInDocument(source, doc, blockIndex, from, to, inlines, plainCaret) {
54
+ const block = doc.blocks[blockIndex];
55
+ if (!block || block.type !== 'table')
56
+ return { ok: false, error: 'Invalid table block.' };
57
+ const data = block.data;
58
+ const targetPlain = tableCellDisplayPlain(data, to.row, to.col);
59
+ const focusPlain = Math.min(plainCaret, targetPlain.length);
60
+ const commit = commitTableCellInlineDraft(source, doc, blockIndex, from.row, from.col, inlines, plainCaret);
61
+ if (!commit.ok)
62
+ return commit;
63
+ return { ...commit, focusCell: to, focusPlain };
64
+ }
65
+ export { navigateTableCell };
66
+ export function convertBlockToTable(source, doc, blockIndex) {
67
+ const block = doc.blocks[blockIndex];
68
+ if (!block)
69
+ return { ok: false, error: 'Block not found.' };
70
+ if (block.type !== 'paragraph' && block.type !== 'heading') {
71
+ return { ok: false, error: 'Block type cannot convert to table.' };
72
+ }
73
+ if (block.sourceRange.synthetic || block.sourceRange.start < 0) {
74
+ return { ok: false, error: 'Block is not editable.' };
75
+ }
76
+ const replacement = serializeTableData(defaultTableBlockData());
77
+ const newSource = replaceBlockSourceRange(source, block.sourceRange.start, block.sourceRange.end, replacement);
78
+ const anchor = block.sourceRange.start;
79
+ return {
80
+ ok: true,
81
+ source: newSource,
82
+ selection: clampSelection({ anchor, focus: anchor }, newSource.length)
83
+ };
84
+ }
85
+ export function cloneTableCellInlines(inlines) {
86
+ return inlines.map(cloneInlineNodeDeep);
87
+ }
@@ -0,0 +1,8 @@
1
+ export { tableCommands } from './commands';
2
+ export { tableBlockDataToRenderModel } from './edit';
3
+ export { applyTableInlineSecondPass } from './inlineSecondPass';
4
+ export { couldContinueTableRow, couldStartTableAt, parseDelimiterCell, parseTables, padRow, splitTableRow, tryParseTableAt } from './parse';
5
+ export type { FenceAtOpenLine } from './parse';
6
+ export { tableReconcileFingerprint } from './reconcile';
7
+ export { serializeTableBlock, serializeTableData } from './serialize';
8
+ export type { TableBlock, TableCellAlign } from './types';
@@ -0,0 +1,6 @@
1
+ export { tableCommands } from './commands';
2
+ export { tableBlockDataToRenderModel } from './edit';
3
+ export { applyTableInlineSecondPass } from './inlineSecondPass';
4
+ export { couldContinueTableRow, couldStartTableAt, parseDelimiterCell, parseTables, padRow, splitTableRow, tryParseTableAt } from './parse';
5
+ export { tableReconcileFingerprint } from './reconcile';
6
+ export { serializeTableBlock, serializeTableData } from './serialize';
@@ -0,0 +1,3 @@
1
+ import { type RichInlineContext } from '../../model/richInlines';
2
+ import type { EditorBlock } from '../../model/types';
3
+ export declare function applyTableInlineSecondPass(block: EditorBlock, _source: string, _insideBlockquote: boolean, _ctx: RichInlineContext): EditorBlock;
@@ -0,0 +1,22 @@
1
+ import { buildRichInlinesForRange, createRichInlineContext } from '../../model/richInlines';
2
+ function parseCellInlines(text) {
3
+ const ctx = createRichInlineContext(text);
4
+ return buildRichInlinesForRange(text, 0, text.length, ctx);
5
+ }
6
+ export function applyTableInlineSecondPass(block, _source, _insideBlockquote, _ctx) {
7
+ void _insideBlockquote;
8
+ void _ctx;
9
+ if (block.type !== 'table')
10
+ return block;
11
+ const data = block.data;
12
+ const headerInlines = data.headers.map((header) => parseCellInlines(header));
13
+ const rowInlines = data.rows.map((row) => row.map((cell) => parseCellInlines(cell)));
14
+ return {
15
+ ...block,
16
+ data: {
17
+ ...data,
18
+ headerInlines,
19
+ rowInlines
20
+ }
21
+ };
22
+ }
@@ -0,0 +1,17 @@
1
+ import { type LineRow } from '../../model/line-utils';
2
+ import type { EditorBlock } from '../../model/types';
3
+ import type { TableCellAlign } from './types';
4
+ export declare function splitTableRow(line: string): string[];
5
+ /** Escape literal `|` for GFM table cell source (table-only v1). */
6
+ export declare function escapeTableCellPipes(cell: string): string;
7
+ /** Returns `undefined` if the cell is not a valid GFM delimiter cell. */
8
+ export declare function parseDelimiterCell(cell: string): TableCellAlign | undefined;
9
+ export declare function padRow(cells: string[], columnCount: number): string[];
10
+ export declare function couldContinueTableRow(line: string): boolean;
11
+ export declare function parseTables(source: string): import('./types').TableBlock[];
12
+ export type FenceAtOpenLine = ReadonlyMap<number, unknown>;
13
+ export declare function couldStartTableAt(i: number, rows: LineRow[], fenceAtOpenLine: FenceAtOpenLine): boolean;
14
+ export declare function tryParseTableAt(i: number, rows: LineRow[], source: string, fenceAtOpenLine: FenceAtOpenLine): {
15
+ nextLine: number;
16
+ block: EditorBlock;
17
+ } | null;
@@ -0,0 +1,181 @@
1
+ import { afterLineTerminator } from '../../model/line-utils';
2
+ import { stableBlockId } from '../../model/types';
3
+ export function splitTableRow(line) {
4
+ const t = line.trim();
5
+ if (!t.includes('|'))
6
+ return [];
7
+ const parts = [];
8
+ let cur = '';
9
+ for (let i = 0; i < t.length; i++) {
10
+ const c = t[i];
11
+ if (c === '\\' && i + 1 < t.length) {
12
+ cur += c + t[i + 1];
13
+ i++;
14
+ continue;
15
+ }
16
+ if (c === '|') {
17
+ parts.push(cur);
18
+ cur = '';
19
+ continue;
20
+ }
21
+ cur += c;
22
+ }
23
+ parts.push(cur);
24
+ let start = 0;
25
+ let end = parts.length;
26
+ if (t.startsWith('|'))
27
+ start = 1;
28
+ if (t.endsWith('|'))
29
+ end = parts.length - 1;
30
+ if (start >= end)
31
+ return [];
32
+ return parts.slice(start, end).map((c) => c.trim());
33
+ }
34
+ /** Escape literal `|` for GFM table cell source (table-only v1). */
35
+ export function escapeTableCellPipes(cell) {
36
+ let out = '';
37
+ for (let i = 0; i < cell.length; i++) {
38
+ const c = cell[i];
39
+ if (c === '|' && (i === 0 || cell[i - 1] !== '\\')) {
40
+ out += '\\|';
41
+ }
42
+ else {
43
+ out += c;
44
+ }
45
+ }
46
+ return out;
47
+ }
48
+ /** Returns `undefined` if the cell is not a valid GFM delimiter cell. */
49
+ export function parseDelimiterCell(cell) {
50
+ const s = cell.trim();
51
+ if (/^:-{3,}:$/.test(s))
52
+ return 'center';
53
+ if (/^:-{3,}$/.test(s))
54
+ return 'left';
55
+ if (/^-{3,}:$/.test(s))
56
+ return 'right';
57
+ if (/^-{3,}$/.test(s))
58
+ return null;
59
+ return undefined;
60
+ }
61
+ export function padRow(cells, columnCount) {
62
+ const row = cells.slice(0, columnCount);
63
+ while (row.length < columnCount)
64
+ row.push('');
65
+ return row;
66
+ }
67
+ export function couldContinueTableRow(line) {
68
+ const t = line.trim();
69
+ if (t.length === 0)
70
+ return false;
71
+ return t.includes('|');
72
+ }
73
+ export function parseTables(source) {
74
+ const lines = source.split(/\r?\n/);
75
+ const out = [];
76
+ let i = 0;
77
+ while (i < lines.length) {
78
+ const headerCells = splitTableRow(lines[i]);
79
+ if (headerCells.length === 0 ||
80
+ i + 1 >= lines.length ||
81
+ splitTableRow(lines[i + 1]).length !== headerCells.length) {
82
+ i++;
83
+ continue;
84
+ }
85
+ const delimCells = splitTableRow(lines[i + 1]);
86
+ const aligns = [];
87
+ let delimOk = true;
88
+ for (const c of delimCells) {
89
+ const a = parseDelimiterCell(c);
90
+ if (a === undefined) {
91
+ delimOk = false;
92
+ break;
93
+ }
94
+ aligns.push(a);
95
+ }
96
+ if (!delimOk || aligns.length !== headerCells.length) {
97
+ i++;
98
+ continue;
99
+ }
100
+ const columnCount = headerCells.length;
101
+ const rows = [];
102
+ let j = i + 2;
103
+ while (j < lines.length && couldContinueTableRow(lines[j])) {
104
+ rows.push(padRow(splitTableRow(lines[j]), columnCount));
105
+ j++;
106
+ }
107
+ out.push({
108
+ lineIndex: i,
109
+ headers: headerCells,
110
+ aligns,
111
+ rows
112
+ });
113
+ i = j;
114
+ }
115
+ return out;
116
+ }
117
+ export function couldStartTableAt(i, rows, fenceAtOpenLine) {
118
+ if (fenceAtOpenLine.has(i))
119
+ return false;
120
+ const headerCells = splitTableRow(rows[i].line);
121
+ if (headerCells.length === 0 || i + 1 >= rows.length)
122
+ return false;
123
+ if (splitTableRow(rows[i + 1].line).length !== headerCells.length)
124
+ return false;
125
+ const delimCells = splitTableRow(rows[i + 1].line);
126
+ for (const c of delimCells) {
127
+ if (parseDelimiterCell(c) === undefined)
128
+ return false;
129
+ }
130
+ return delimCells.length === headerCells.length;
131
+ }
132
+ export function tryParseTableAt(i, rows, source, fenceAtOpenLine) {
133
+ if (fenceAtOpenLine.has(i))
134
+ return null;
135
+ const headerCells = splitTableRow(rows[i].line);
136
+ if (headerCells.length === 0 || i + 1 >= rows.length)
137
+ return null;
138
+ if (splitTableRow(rows[i + 1].line).length !== headerCells.length)
139
+ return null;
140
+ const delimCells = splitTableRow(rows[i + 1].line);
141
+ const aligns = [];
142
+ for (const c of delimCells) {
143
+ const a = parseDelimiterCell(c);
144
+ if (a === undefined)
145
+ return null;
146
+ aligns.push(a);
147
+ }
148
+ if (aligns.length !== headerCells.length)
149
+ return null;
150
+ const columnCount = headerCells.length;
151
+ let j = i + 2;
152
+ const bodyRows = [];
153
+ while (j < rows.length && couldContinueTableRow(rows[j].line)) {
154
+ if (fenceAtOpenLine.has(j))
155
+ break;
156
+ bodyRows.push(padRow(splitTableRow(rows[j].line), columnCount));
157
+ j++;
158
+ }
159
+ const endLine = j - 1;
160
+ const sourceRange = {
161
+ start: rows[i].start,
162
+ end: afterLineTerminator(source, rows[endLine]),
163
+ startLine: i,
164
+ endLine
165
+ };
166
+ const data = {
167
+ headers: headerCells,
168
+ aligns,
169
+ rows: bodyRows,
170
+ startLineIndex: i
171
+ };
172
+ return {
173
+ nextLine: j,
174
+ block: {
175
+ type: 'table',
176
+ id: stableBlockId('table', sourceRange),
177
+ sourceRange,
178
+ data
179
+ }
180
+ };
181
+ }
@@ -0,0 +1,2 @@
1
+ import type { EditorBlock } from '../../model/types';
2
+ export declare function tableReconcileFingerprint(block: EditorBlock): string;
@@ -0,0 +1,6 @@
1
+ export function tableReconcileFingerprint(block) {
2
+ if (block.type !== 'table')
3
+ return '';
4
+ const d = block.data;
5
+ return `table:${d.headers.join('|')}:${d.rows.map((r) => r.join('|')).join(';')}`;
6
+ }
@@ -0,0 +1,3 @@
1
+ import type { EditorBlock, TableBlockData } from '../../model/types';
2
+ export declare function serializeTableData(d: TableBlockData): string;
3
+ export declare function serializeTableBlock(block: EditorBlock): string;
@@ -0,0 +1,32 @@
1
+ import { serializeInlineNodes } from '../../model/serializeInlineNodes';
2
+ import { escapeTableCellPipes } from './parse';
3
+ function serializeTableCellText(text) {
4
+ return escapeTableCellPipes(text);
5
+ }
6
+ function delimCell(a) {
7
+ if (a === 'center')
8
+ return ':---:';
9
+ if (a === 'right')
10
+ return '---:';
11
+ if (a === 'left')
12
+ return ':---';
13
+ return '---';
14
+ }
15
+ function serializeTableRow(cells) {
16
+ return '| ' + cells.join(' | ') + ' |';
17
+ }
18
+ export function serializeTableData(d) {
19
+ const headers = d.headers.map((h, i) => serializeTableCellText(d.headerInlines?.[i]?.length ? serializeInlineNodes(d.headerInlines[i]) : h));
20
+ const rows = d.rows.map((row, ri) => row.map((cell, ci) => serializeTableCellText(d.rowInlines?.[ri]?.[ci]?.length ? serializeInlineNodes(d.rowInlines[ri][ci]) : cell)));
21
+ const lines = [serializeTableRow(headers), '| ' + d.aligns.map(delimCell).join(' | ') + ' |'];
22
+ for (const row of rows) {
23
+ lines.push(serializeTableRow(row));
24
+ }
25
+ return lines.join('\n');
26
+ }
27
+ export function serializeTableBlock(block) {
28
+ if (block.type !== 'table') {
29
+ throw new Error('serializeTableBlock expects a table block');
30
+ }
31
+ return serializeTableData(block.data);
32
+ }
@@ -0,0 +1,11 @@
1
+ import type { InlineNode } from '../../model/types';
2
+ /** `null` means default (no explicit alignment). */
3
+ export type TableCellAlign = 'left' | 'center' | 'right' | null;
4
+ export type TableBlock = {
5
+ lineIndex: number;
6
+ headers: string[];
7
+ aligns: TableCellAlign[];
8
+ rows: string[][];
9
+ headerInlines?: InlineNode[][];
10
+ rowInlines?: InlineNode[][][];
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { BlockSpec } from './types';
2
+ export declare const tableSpec: BlockSpec;
@@ -0,0 +1,25 @@
1
+ import EditableTable from '../blocks/EditableTable.svelte';
2
+ import { tableCommands } from './table/commands';
3
+ import { tableBlockDataToRenderModel } from './table/edit';
4
+ import { applyTableInlineSecondPass } from './table/inlineSecondPass';
5
+ import { couldContinueTableRow, couldStartTableAt, parseTables, tryParseTableAt } from './table/parse';
6
+ import { tableReconcileFingerprint } from './table/reconcile';
7
+ import { serializeTableBlock } from './table/serialize';
8
+ import { tableRenderer } from './table/TableRenderer.svelte';
9
+ export const tableSpec = {
10
+ type: 'table',
11
+ id: 'tables',
12
+ render: tableRenderer,
13
+ editComponent: EditableTable,
14
+ parse: { couldContinueTableRow, couldStartTableAt, parseTables, tryParseTableAt },
15
+ serialize: serializeTableBlock,
16
+ applyInlineSecondPass: applyTableInlineSecondPass,
17
+ reconcileFingerprint: tableReconcileFingerprint,
18
+ commands: tableCommands,
19
+ toRenderBlock: (block) => ({
20
+ id: block.id,
21
+ pluginId: 'tables',
22
+ data: tableBlockDataToRenderModel(block.data),
23
+ render: tableRenderer
24
+ })
25
+ };