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,581 @@
1
+ import { inlineNodesToPlainText } from './inlinePlain';
2
+ export function syntheticInlineSourceRange() {
3
+ return { start: -1, end: -1, startLine: -1, endLine: -1, synthetic: true };
4
+ }
5
+ export function inlineTextNode(text) {
6
+ return { type: 'text', text, sourceRange: syntheticInlineSourceRange() };
7
+ }
8
+ export function nodePlainLength(n) {
9
+ switch (n.type) {
10
+ case 'text':
11
+ case 'code':
12
+ return n.text.length;
13
+ case 'autolink':
14
+ return n.href.length;
15
+ case 'wikiLink':
16
+ return n.label.length;
17
+ case 'mention':
18
+ return n.kind === 'page' ? `@[${n.name}]`.length : `@${n.name}`.length;
19
+ default:
20
+ return inlineNodesToPlainText(n.children).length;
21
+ }
22
+ }
23
+ function normalizeAdjacentTextNodes(nodes) {
24
+ const out = [];
25
+ for (const n of nodes) {
26
+ const last = out[out.length - 1];
27
+ if (n.type === 'text' && last?.type === 'text') {
28
+ last.text += n.text;
29
+ continue;
30
+ }
31
+ out.push(n);
32
+ }
33
+ return out;
34
+ }
35
+ function isInlineWrapMark(n) {
36
+ switch (n.type) {
37
+ case 'strong':
38
+ case 'emphasis':
39
+ case 'strikethrough':
40
+ case 'highlight':
41
+ case 'code':
42
+ return true;
43
+ default:
44
+ return false;
45
+ }
46
+ }
47
+ function canMergeWrapMarks(a, b) {
48
+ if (a.type !== b.type)
49
+ return false;
50
+ switch (a.type) {
51
+ case 'code':
52
+ case 'strong':
53
+ case 'emphasis':
54
+ case 'strikethrough':
55
+ return true;
56
+ case 'highlight':
57
+ if (b.type !== 'highlight')
58
+ return false;
59
+ return a.color === b.color;
60
+ default:
61
+ return false;
62
+ }
63
+ }
64
+ function mergeWrapMarkPair(a, b) {
65
+ const sr = syntheticInlineSourceRange();
66
+ if (a.type === 'code' && b.type === 'code') {
67
+ return { type: 'code', text: a.text + b.text, sourceRange: sr };
68
+ }
69
+ if ('children' in a && 'children' in b) {
70
+ return {
71
+ ...a,
72
+ children: coalesceAdjacentWrapMarks(normalizeAdjacentTextNodes([...a.children, ...b.children])),
73
+ sourceRange: sr
74
+ };
75
+ }
76
+ return a;
77
+ }
78
+ function coalesceChildrenInWrapMarks(nodes) {
79
+ return nodes.map((n) => {
80
+ if (n.type === 'emphasis' ||
81
+ n.type === 'strong' ||
82
+ n.type === 'strikethrough' ||
83
+ n.type === 'highlight' ||
84
+ n.type === 'link' ||
85
+ n.type === 'image') {
86
+ return {
87
+ ...n,
88
+ children: coalesceAdjacentWrapMarks(n.children)
89
+ };
90
+ }
91
+ return n;
92
+ });
93
+ }
94
+ /** Merge adjacent same-type wrap marks; drop empty wraps after range edits. */
95
+ function coalesceAdjacentWrapMarks(nodes) {
96
+ const withMergedChildren = coalesceChildrenInWrapMarks(normalizeAdjacentTextNodes(nodes));
97
+ const out = [];
98
+ for (const n of withMergedChildren) {
99
+ const last = out[out.length - 1];
100
+ if (last && canMergeWrapMarks(last, n)) {
101
+ out[out.length - 1] = mergeWrapMarkPair(last, n);
102
+ continue;
103
+ }
104
+ out.push(n);
105
+ }
106
+ return pruneEmptyWrapMarks(out);
107
+ }
108
+ function pruneEmptyWrapMarks(nodes) {
109
+ const out = [];
110
+ for (const n of nodes) {
111
+ let node = n;
112
+ if (n.type === 'emphasis' ||
113
+ n.type === 'strong' ||
114
+ n.type === 'strikethrough' ||
115
+ n.type === 'highlight' ||
116
+ n.type === 'link' ||
117
+ n.type === 'image') {
118
+ node = { ...n, children: pruneEmptyWrapMarks(n.children) };
119
+ }
120
+ if (isInlineWrapMark(node) && nodePlainLength(node) === 0)
121
+ continue;
122
+ out.push(node);
123
+ }
124
+ return out;
125
+ }
126
+ function nodeMatchesWrapKind(n, kind) {
127
+ return n.type === kind;
128
+ }
129
+ function inlineNodeRangeFullyCoveredByKind(n, start, end, offset, kind, inherited = false) {
130
+ const len = nodePlainLength(n);
131
+ const nodeStart = offset;
132
+ const nodeEnd = offset + len;
133
+ if (end <= nodeStart || start >= nodeEnd)
134
+ return true;
135
+ const active = inherited || nodeMatchesWrapKind(n, kind);
136
+ if (n.type === 'code')
137
+ return active;
138
+ if (n.type === 'emphasis' ||
139
+ n.type === 'strong' ||
140
+ n.type === 'link' ||
141
+ n.type === 'image' ||
142
+ n.type === 'strikethrough' ||
143
+ n.type === 'highlight') {
144
+ let o = nodeStart;
145
+ for (const ch of n.children) {
146
+ if (!inlineNodeRangeFullyCoveredByKind(ch, start, end, o, kind, active))
147
+ return false;
148
+ o += nodePlainLength(ch);
149
+ }
150
+ return true;
151
+ }
152
+ return active;
153
+ }
154
+ export function inlineRangeFullyCoveredByKind(nodes, start, end, kind) {
155
+ const a = Math.min(start, end);
156
+ const b = Math.max(start, end);
157
+ if (a === b)
158
+ return false;
159
+ let o = 0;
160
+ for (const n of nodes) {
161
+ if (!inlineNodeRangeFullyCoveredByKind(n, a, b, o, kind))
162
+ return false;
163
+ o += nodePlainLength(n);
164
+ }
165
+ return true;
166
+ }
167
+ function unwrapKindFromNodes(nodes, kind) {
168
+ const out = [];
169
+ for (const n of nodes) {
170
+ if (n.type === 'code') {
171
+ if (kind === 'code')
172
+ out.push(inlineTextNode(n.text));
173
+ else
174
+ out.push(cloneInlineNodeDeep(n));
175
+ continue;
176
+ }
177
+ if (n.type === 'emphasis' ||
178
+ n.type === 'strong' ||
179
+ n.type === 'link' ||
180
+ n.type === 'image' ||
181
+ n.type === 'strikethrough' ||
182
+ n.type === 'highlight') {
183
+ const children = unwrapKindFromNodes(n.children, kind);
184
+ if (nodeMatchesWrapKind(n, kind)) {
185
+ out.push(...children);
186
+ }
187
+ else {
188
+ out.push({ ...n, children, sourceRange: syntheticInlineSourceRange() });
189
+ }
190
+ continue;
191
+ }
192
+ out.push(cloneInlineNodeDeep(n));
193
+ }
194
+ return coalesceAdjacentWrapMarks(out);
195
+ }
196
+ export function cloneInlineNodeDeep(n) {
197
+ const sr = syntheticInlineSourceRange();
198
+ switch (n.type) {
199
+ case 'text':
200
+ case 'code':
201
+ case 'autolink':
202
+ case 'wikiLink':
203
+ case 'mention':
204
+ return { ...n, sourceRange: sr };
205
+ case 'link':
206
+ case 'image':
207
+ return {
208
+ ...n,
209
+ sourceRange: sr,
210
+ children: n.children.map(cloneInlineNodeDeep)
211
+ };
212
+ case 'emphasis':
213
+ case 'strong':
214
+ case 'strikethrough':
215
+ case 'highlight':
216
+ return {
217
+ ...n,
218
+ sourceRange: sr,
219
+ children: n.children.map(cloneInlineNodeDeep)
220
+ };
221
+ default:
222
+ return n;
223
+ }
224
+ }
225
+ function splitNodeAtPlainOffset(n, offset) {
226
+ if (offset <= 0)
227
+ return { left: [], right: [cloneInlineNodeDeep(n)] };
228
+ const len = nodePlainLength(n);
229
+ if (offset >= len)
230
+ return { left: [cloneInlineNodeDeep(n)], right: [] };
231
+ if (n.type === 'text') {
232
+ return {
233
+ left: n.text.slice(0, offset) ? [inlineTextNode(n.text.slice(0, offset))] : [],
234
+ right: n.text.slice(offset) ? [inlineTextNode(n.text.slice(offset))] : []
235
+ };
236
+ }
237
+ if (n.type === 'code') {
238
+ const sr = syntheticInlineSourceRange();
239
+ return {
240
+ left: n.text.slice(0, offset)
241
+ ? [{ type: 'code', text: n.text.slice(0, offset), sourceRange: sr }]
242
+ : [],
243
+ right: n.text.slice(offset)
244
+ ? [{ type: 'code', text: n.text.slice(offset), sourceRange: sr }]
245
+ : []
246
+ };
247
+ }
248
+ if (n.type === 'autolink') {
249
+ const href = n.href;
250
+ const sr = syntheticInlineSourceRange();
251
+ return {
252
+ left: href.slice(0, offset)
253
+ ? [{ type: 'autolink', href: href.slice(0, offset), sourceRange: sr }]
254
+ : [],
255
+ right: href.slice(offset)
256
+ ? [{ type: 'autolink', href: href.slice(offset), sourceRange: sr }]
257
+ : []
258
+ };
259
+ }
260
+ if (n.type === 'wikiLink') {
261
+ const label = n.label;
262
+ const sr = syntheticInlineSourceRange();
263
+ return {
264
+ left: label.slice(0, offset)
265
+ ? [{ type: 'wikiLink', label: label.slice(0, offset), target: n.target, sourceRange: sr }]
266
+ : [],
267
+ right: label.slice(offset)
268
+ ? [{ type: 'wikiLink', label: label.slice(offset), target: n.target, sourceRange: sr }]
269
+ : []
270
+ };
271
+ }
272
+ if (n.type === 'mention') {
273
+ const plain = n.kind === 'page' ? `@[${n.name}]` : `@${n.name}`;
274
+ const leftS = plain.slice(0, offset);
275
+ const rightS = plain.slice(offset);
276
+ return {
277
+ left: leftS ? [inlineTextNode(leftS)] : [],
278
+ right: rightS ? [inlineTextNode(rightS)] : []
279
+ };
280
+ }
281
+ if (n.type === 'emphasis' ||
282
+ n.type === 'strong' ||
283
+ n.type === 'link' ||
284
+ n.type === 'image' ||
285
+ n.type === 'strikethrough' ||
286
+ n.type === 'highlight') {
287
+ const split = splitInlineNodesAtPlainOffset(n.children, offset);
288
+ const wrap = (side) => {
289
+ if (side.length === 0)
290
+ return [];
291
+ const cloned = {
292
+ ...n,
293
+ children: side,
294
+ sourceRange: syntheticInlineSourceRange()
295
+ };
296
+ return [cloned];
297
+ };
298
+ return { left: wrap(split.left), right: wrap(split.right) };
299
+ }
300
+ const _never = n;
301
+ return _never;
302
+ }
303
+ /** Split `nodes` into plain-offset prefix / suffix at `offset` (0-based into concatenated plain text). */
304
+ export function splitInlineNodesAtPlainOffset(nodes, offset) {
305
+ if (offset <= 0)
306
+ return { left: [], right: normalizeAdjacentTextNodes(nodes.map(cloneInlineNodeDeep)) };
307
+ let remaining = offset;
308
+ const left = [];
309
+ for (let i = 0; i < nodes.length; i++) {
310
+ const n = nodes[i];
311
+ const len = nodePlainLength(n);
312
+ if (remaining > len) {
313
+ left.push(cloneInlineNodeDeep(n));
314
+ remaining -= len;
315
+ continue;
316
+ }
317
+ if (remaining === len) {
318
+ left.push(cloneInlineNodeDeep(n));
319
+ return {
320
+ left: normalizeAdjacentTextNodes(left),
321
+ right: normalizeAdjacentTextNodes(nodes.slice(i + 1).map(cloneInlineNodeDeep))
322
+ };
323
+ }
324
+ const { left: ln, right: rn } = splitNodeAtPlainOffset(cloneInlineNodeDeep(n), remaining);
325
+ left.push(...ln);
326
+ return {
327
+ left: normalizeAdjacentTextNodes(left),
328
+ right: normalizeAdjacentTextNodes([...rn, ...nodes.slice(i + 1).map(cloneInlineNodeDeep)])
329
+ };
330
+ }
331
+ return { left: normalizeAdjacentTextNodes(left), right: [] };
332
+ }
333
+ function wrapMidNormalized(mid, kind, linkHref) {
334
+ const sr = syntheticInlineSourceRange();
335
+ if (kind === 'code') {
336
+ const t = inlineNodesToPlainText(mid);
337
+ return [{ type: 'code', text: t, sourceRange: sr }];
338
+ }
339
+ const children = mid.length ? mid : [inlineTextNode('')];
340
+ switch (kind) {
341
+ case 'strong':
342
+ return [{ type: 'strong', children, sourceRange: sr }];
343
+ case 'emphasis':
344
+ return [{ type: 'emphasis', children, sourceRange: sr }];
345
+ case 'strikethrough':
346
+ return [{ type: 'strikethrough', children, sourceRange: sr }];
347
+ case 'highlight':
348
+ return [{ type: 'highlight', color: null, children, sourceRange: sr }];
349
+ case 'link':
350
+ return [
351
+ {
352
+ type: 'link',
353
+ href: linkHref ?? '',
354
+ title: null,
355
+ children,
356
+ sourceRange: sr
357
+ }
358
+ ];
359
+ default:
360
+ return children;
361
+ }
362
+ }
363
+ export function wrapInlineSelection(nodes, start, end, kind, linkHref) {
364
+ const a = Math.min(start, end);
365
+ const b = Math.max(start, end);
366
+ const s1 = splitInlineNodesAtPlainOffset(nodes, a);
367
+ const s2 = splitInlineNodesAtPlainOffset(s1.right, b - a);
368
+ const mid = s2.left;
369
+ const replacement = inlineRangeFullyCoveredByKind(nodes, a, b, kind)
370
+ ? unwrapKindFromNodes(mid, kind)
371
+ : wrapMidNormalized(mid, kind, linkHref);
372
+ return coalesceAdjacentWrapMarks([...s1.left, ...replacement, ...s2.right]);
373
+ }
374
+ function singleCharPlainDelta(oldPlain, newPlain) {
375
+ if (oldPlain === newPlain)
376
+ return null;
377
+ if (newPlain.length === oldPlain.length + 1) {
378
+ let i = 0;
379
+ const minLen = oldPlain.length;
380
+ while (i < minLen && oldPlain[i] === newPlain[i])
381
+ i++;
382
+ return { type: 'insert', pos: i, ch: newPlain[i] };
383
+ }
384
+ if (newPlain.length === oldPlain.length - 1) {
385
+ let i = 0;
386
+ const minLen = newPlain.length;
387
+ while (i < minLen && oldPlain[i] === newPlain[i])
388
+ i++;
389
+ if (oldPlain.slice(i + 1) === newPlain.slice(i))
390
+ return { type: 'delete', pos: i };
391
+ }
392
+ return null;
393
+ }
394
+ function insertCharAtPlainInNodes(nodes, pos, ch) {
395
+ if (pos < 0)
396
+ return null;
397
+ let o = 0;
398
+ for (let i = 0; i < nodes.length; i++) {
399
+ const n = nodes[i];
400
+ const len = nodePlainLength(n);
401
+ if (pos < o + len) {
402
+ const inner = pos - o;
403
+ const rep = insertCharIntoNode(cloneInlineNodeDeep(n), inner, ch);
404
+ if (!rep)
405
+ return null;
406
+ return [
407
+ ...nodes.slice(0, i).map(cloneInlineNodeDeep),
408
+ rep,
409
+ ...nodes.slice(i + 1).map(cloneInlineNodeDeep)
410
+ ];
411
+ }
412
+ if (pos === o + len) {
413
+ if (i + 1 < nodes.length) {
414
+ const rep = insertCharIntoNode(cloneInlineNodeDeep(nodes[i + 1]), 0, ch);
415
+ if (!rep)
416
+ return null;
417
+ return [
418
+ ...nodes.slice(0, i + 1).map(cloneInlineNodeDeep),
419
+ rep,
420
+ ...nodes.slice(i + 2).map(cloneInlineNodeDeep)
421
+ ];
422
+ }
423
+ const rep = insertCharIntoNode(cloneInlineNodeDeep(n), len, ch);
424
+ if (!rep)
425
+ return null;
426
+ return [
427
+ ...nodes.slice(0, i).map(cloneInlineNodeDeep),
428
+ rep,
429
+ ...nodes.slice(i + 1).map(cloneInlineNodeDeep)
430
+ ];
431
+ }
432
+ o += len;
433
+ }
434
+ if (pos === o)
435
+ return [...nodes.map(cloneInlineNodeDeep), inlineTextNode(ch)];
436
+ return null;
437
+ }
438
+ function insertCharIntoNode(n, offset, ch) {
439
+ if (n.type === 'text') {
440
+ const t = n.text.slice(0, offset) + ch + n.text.slice(offset);
441
+ return inlineTextNode(t);
442
+ }
443
+ if (n.type === 'code') {
444
+ const t = n.text.slice(0, offset) + ch + n.text.slice(offset);
445
+ return { type: 'code', text: t, sourceRange: syntheticInlineSourceRange() };
446
+ }
447
+ if ('children' in n && n.children) {
448
+ const inner = insertCharAtPlainInNodes(n.children, offset, ch);
449
+ if (!inner)
450
+ return null;
451
+ return { ...n, children: inner, sourceRange: syntheticInlineSourceRange() };
452
+ }
453
+ return null;
454
+ }
455
+ function deleteCharAtPlainInNodes(nodes, pos) {
456
+ if (pos < 0)
457
+ return null;
458
+ let o = 0;
459
+ for (let i = 0; i < nodes.length; i++) {
460
+ const n = nodes[i];
461
+ const len = nodePlainLength(n);
462
+ if (pos < o + len) {
463
+ const inner = pos - o;
464
+ const rep = deleteCharFromNode(cloneInlineNodeDeep(n), inner);
465
+ if (!rep)
466
+ return null;
467
+ const rest = [
468
+ ...nodes.slice(0, i).map(cloneInlineNodeDeep),
469
+ ...rep,
470
+ ...nodes.slice(i + 1).map(cloneInlineNodeDeep)
471
+ ];
472
+ return normalizeAdjacentTextNodes(rest);
473
+ }
474
+ o += len;
475
+ }
476
+ return null;
477
+ }
478
+ function deleteCharFromNode(n, offset) {
479
+ if (n.type === 'text') {
480
+ if (offset < 0 || offset >= n.text.length)
481
+ return null;
482
+ const t = n.text.slice(0, offset) + n.text.slice(offset + 1);
483
+ return t ? [inlineTextNode(t)] : [];
484
+ }
485
+ if (n.type === 'code') {
486
+ if (offset < 0 || offset >= n.text.length)
487
+ return null;
488
+ const t = n.text.slice(0, offset) + n.text.slice(offset + 1);
489
+ return t ? [{ type: 'code', text: t, sourceRange: syntheticInlineSourceRange() }] : [];
490
+ }
491
+ if ('children' in n && n.children) {
492
+ const inner = deleteCharAtPlainInNodes(n.children, offset);
493
+ if (!inner)
494
+ return null;
495
+ if (inner.length === 0)
496
+ return [];
497
+ return [{ ...n, children: inner, sourceRange: syntheticInlineSourceRange() }];
498
+ }
499
+ return null;
500
+ }
501
+ /** Returns updated nodes when `newPlain` differs by a single insert/delete; otherwise `null`. */
502
+ export function mergePlainTypingIntoInlines(nodes, newPlain) {
503
+ const oldPlain = inlineNodesToPlainText(nodes);
504
+ const delta = singleCharPlainDelta(oldPlain, newPlain);
505
+ if (!delta)
506
+ return null;
507
+ if (delta.type === 'insert') {
508
+ return insertCharAtPlainInNodes(nodes, delta.pos, delta.ch);
509
+ }
510
+ return deleteCharAtPlainInNodes(nodes, delta.pos);
511
+ }
512
+ export function isInlineAtom(n) {
513
+ switch (n.type) {
514
+ case 'link':
515
+ case 'image':
516
+ case 'autolink':
517
+ case 'wikiLink':
518
+ case 'mention':
519
+ return true;
520
+ default:
521
+ return false;
522
+ }
523
+ }
524
+ /** Clone block `inlines` for a session draft, or seed from display plain. */
525
+ export function draftInlinesFromBlock(inlines, displayPlain) {
526
+ const inlinePlain = inlines?.length ? inlineNodesToPlainText(inlines) : '';
527
+ if (displayPlain.length > 0) {
528
+ if (inlinePlain === displayPlain && inlines?.length) {
529
+ return inlines.map(cloneInlineNodeDeep);
530
+ }
531
+ return [inlineTextNode(displayPlain)];
532
+ }
533
+ // Empty editor buffer — ignore demotion materialization space in model inlines.
534
+ if (inlinePlain === ' ')
535
+ return [];
536
+ if (inlines?.length)
537
+ return inlines.map(cloneInlineNodeDeep);
538
+ return [];
539
+ }
540
+ /** Remove plain-text range `[start, end)` from inline AST. */
541
+ export function deletePlainRange(nodes, start, end) {
542
+ const a = Math.min(start, end);
543
+ const b = Math.max(start, end);
544
+ if (a === b)
545
+ return nodes.map(cloneInlineNodeDeep);
546
+ const s1 = splitInlineNodesAtPlainOffset(nodes, a);
547
+ const s2 = splitInlineNodesAtPlainOffset(s1.right, b - a);
548
+ return coalesceAdjacentWrapMarks([...s1.left, ...s2.right]);
549
+ }
550
+ export function deleteCharBefore(nodes, pos) {
551
+ if (pos <= 0)
552
+ return null;
553
+ return deletePlainRange(nodes, pos - 1, pos);
554
+ }
555
+ export function deleteCharAfter(nodes, pos) {
556
+ const len = inlineNodesToPlainText(nodes).length;
557
+ if (pos >= len)
558
+ return null;
559
+ return deletePlainRange(nodes, pos, pos + 1);
560
+ }
561
+ /** Insert plain text at offset; optionally strip newlines (heading single-line). */
562
+ export function insertTextAtPlainOffset(nodes, pos, text, options = {}) {
563
+ let insert = text;
564
+ if (options.stripNewlines)
565
+ insert = insert.replace(/\n/g, '');
566
+ if (!insert)
567
+ return nodes.map(cloneInlineNodeDeep);
568
+ const s = splitInlineNodesAtPlainOffset(nodes, pos);
569
+ return normalizeAdjacentTextNodes([...s.left, inlineTextNode(insert), ...s.right]);
570
+ }
571
+ /** Apply a controlled-input delta; falls back to plain flattening when merge fails. */
572
+ export function applyControlledPlainEdit(nodes, oldPlain, newPlain) {
573
+ if (oldPlain === newPlain)
574
+ return nodes.map(cloneInlineNodeDeep);
575
+ const merged = mergePlainTypingIntoInlines(nodes, newPlain);
576
+ if (merged)
577
+ return merged;
578
+ if (newPlain.length === 0)
579
+ return [];
580
+ return [inlineTextNode(newPlain)];
581
+ }
@@ -0,0 +1,3 @@
1
+ import type { InlineNode } from './types';
2
+ /** Plain-text rendering of inline AST (matches identity fingerprint / editor display). */
3
+ export declare function inlineNodesToPlainText(inlines: InlineNode[] | undefined): string;
@@ -0,0 +1,28 @@
1
+ /** Plain-text rendering of inline AST (matches identity fingerprint / editor display). */
2
+ export function inlineNodesToPlainText(inlines) {
3
+ if (!inlines || inlines.length === 0)
4
+ return '';
5
+ const parts = [];
6
+ for (const n of inlines) {
7
+ switch (n.type) {
8
+ case 'text':
9
+ case 'code':
10
+ parts.push(n.text);
11
+ break;
12
+ case 'autolink':
13
+ parts.push(n.href);
14
+ break;
15
+ case 'wikiLink':
16
+ parts.push(n.label);
17
+ break;
18
+ case 'mention':
19
+ parts.push(n.kind === 'page' ? `@[${n.name}]` : `@${n.name}`);
20
+ break;
21
+ default:
22
+ if ('children' in n && n.children)
23
+ parts.push(inlineNodesToPlainText(n.children));
24
+ break;
25
+ }
26
+ }
27
+ return parts.join('');
28
+ }
@@ -0,0 +1,4 @@
1
+ import type { EditorDocument } from './types';
2
+ export declare function applyInlineSecondPass(doc: EditorDocument): EditorDocument;
3
+ /** **Scoped inline reparse** — annotate only selected top-level block indices. */
4
+ export declare function applyInlineSecondPassToBlockIndices(doc: EditorDocument, blockIndices: readonly number[]): EditorDocument;
@@ -0,0 +1,47 @@
1
+ import { getBlockSpec } from '../block-specs/registry';
2
+ import { applyBlockquoteInlineSecondPass } from '../block-specs/blockquote/inlineSecondPass';
3
+ import { applyCalloutInlineSecondPass } from '../block-specs/callout/inlineSecondPass';
4
+ import { applyHeadingInlineSecondPass } from '../block-specs/heading/inlineSecondPass';
5
+ import { applyListItemInlineSecondPass } from '../block-specs/list/inlineSecondPass';
6
+ import { applyParagraphInlineSecondPass } from '../block-specs/paragraph/inlineSecondPass';
7
+ import { createRichInlineContext } from './richInlines';
8
+ import { splitLinesWithOffsets } from './line-utils';
9
+ function annotateBlock(block, source, rows, ctx, insideBlockquote) {
10
+ if (block.type === 'heading') {
11
+ return applyHeadingInlineSecondPass(block, source, rows, ctx);
12
+ }
13
+ if (block.type === 'paragraph') {
14
+ return applyParagraphInlineSecondPass(block, source, insideBlockquote, ctx);
15
+ }
16
+ if (block.type === 'listItem') {
17
+ return applyListItemInlineSecondPass(block, source, rows, ctx, insideBlockquote, annotateBlock);
18
+ }
19
+ if (block.type === 'blockquote') {
20
+ return applyBlockquoteInlineSecondPass(block, source, rows, ctx, annotateBlock);
21
+ }
22
+ if (block.type === 'callout') {
23
+ return applyCalloutInlineSecondPass(block, source, rows, ctx, annotateBlock);
24
+ }
25
+ const spec = getBlockSpec(block.type);
26
+ if (spec) {
27
+ return spec.applyInlineSecondPass(block, source, insideBlockquote, ctx);
28
+ }
29
+ console.error(`applyInlineSecondPass: missing BlockSpec for type "${block.type}"`);
30
+ return block;
31
+ }
32
+ export function applyInlineSecondPass(doc) {
33
+ const rows = splitLinesWithOffsets(doc.source);
34
+ const ctx = createRichInlineContext(doc.source);
35
+ const blocks = doc.blocks.map((b) => annotateBlock(b, doc.source, rows, ctx, false));
36
+ return { ...doc, blocks };
37
+ }
38
+ /** **Scoped inline reparse** — annotate only selected top-level block indices. */
39
+ export function applyInlineSecondPassToBlockIndices(doc, blockIndices) {
40
+ if (blockIndices.length === 0)
41
+ return doc;
42
+ const rows = splitLinesWithOffsets(doc.source);
43
+ const ctx = createRichInlineContext(doc.source);
44
+ const indexSet = new Set(blockIndices);
45
+ const blocks = doc.blocks.map((b, i) => indexSet.has(i) ? annotateBlock(b, doc.source, rows, ctx, false) : b);
46
+ return { ...doc, blocks };
47
+ }
@@ -0,0 +1,14 @@
1
+ export type LineRow = {
2
+ line: string;
3
+ start: number;
4
+ end: number;
5
+ };
6
+ /** Split into lines with start/end indices in the original string (handles `\r`, `\r\n`, `\n`). */
7
+ export declare function splitLinesWithOffsets(source: string): LineRow[];
8
+ /** Line and character totals for editor chrome; uses the same line split as the parser. */
9
+ export declare function sourceLineAndCharacterCount(source: string): {
10
+ lineCount: number;
11
+ characterCount: number;
12
+ };
13
+ /** Index just after the line's trailing `\r` / `\n` (or `source.length`). */
14
+ export declare function afterLineTerminator(source: string, row: LineRow): number;