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,61 @@
1
+ /**
2
+ * Map DOM Selection inside a `contenteditable="plaintext-only"` root to plain-text offsets.
3
+ * Indices are UTF-16 code units, aligned with {@link EditorSelection} and {@link DOMString}.
4
+ */
5
+ export function plainOffsets(root) {
6
+ const sel = getSelection();
7
+ if (!sel?.rangeCount) {
8
+ const len = root.textContent?.length ?? 0;
9
+ return { start: len, end: len };
10
+ }
11
+ const range = sel.getRangeAt(0);
12
+ if (!root.contains(range.startContainer)) {
13
+ const len = root.textContent?.length ?? 0;
14
+ return { start: len, end: len };
15
+ }
16
+ const toOffset = (container, offset) => {
17
+ const r = document.createRange();
18
+ r.selectNodeContents(root);
19
+ r.setEnd(container, offset);
20
+ return r.toString().length;
21
+ };
22
+ return {
23
+ start: toOffset(range.startContainer, range.startOffset),
24
+ end: toOffset(range.endContainer, range.endOffset)
25
+ };
26
+ }
27
+ /** Move caret to a plain offset inside `root` (collapsed selection). */
28
+ export function setCaretPlainOffset(root, offset) {
29
+ const sel = getSelection();
30
+ if (!sel)
31
+ return;
32
+ const max = root.textContent?.length ?? 0;
33
+ const o = Math.max(0, Math.min(offset, max));
34
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
35
+ let remaining = o;
36
+ let node = walker.nextNode();
37
+ while (node) {
38
+ const len = node.textContent?.length ?? 0;
39
+ if (remaining <= len) {
40
+ const range = document.createRange();
41
+ range.setStart(node, remaining);
42
+ range.collapse(true);
43
+ sel.removeAllRanges();
44
+ sel.addRange(range);
45
+ return;
46
+ }
47
+ remaining -= len;
48
+ node = walker.nextNode();
49
+ }
50
+ const range = document.createRange();
51
+ range.selectNodeContents(root);
52
+ range.collapse(false);
53
+ sel.removeAllRanges();
54
+ sel.addRange(range);
55
+ }
56
+ /** True when `offset` is the start of a logical line in `plain` (after `\n` or at 0). */
57
+ export function offsetAtLineStart(plain, offset) {
58
+ const lastNl = plain.lastIndexOf('\n', offset - 1);
59
+ const lineStart = lastNl === -1 ? 0 : lastNl + 1;
60
+ return offset === lineStart;
61
+ }
@@ -0,0 +1,17 @@
1
+ import type { DocumentSelection, TableCellAddress } from '../model/types';
2
+ export type DocumentSelectionFocusBinding = {
3
+ blockId: string;
4
+ tableCell?: TableCellAddress;
5
+ getNode: () => HTMLElement | null;
6
+ isFocused: () => boolean;
7
+ setFocused: (focused: boolean) => void;
8
+ getDisplayPlain: () => string;
9
+ setLocalPlain: (plain: string) => void;
10
+ /** When set, resync styled inline DOM instead of `textContent`. */
11
+ resyncDom?: () => void;
12
+ setCaret: (node: HTMLElement, offset: number) => void;
13
+ documentSelection: DocumentSelection | null;
14
+ takePendingFocus: (blockId: string, tableCell?: TableCellAddress) => boolean;
15
+ };
16
+ /** Apply post-split focus and resync source blocks when selection moves away. */
17
+ export declare function syncDocumentSelectionFocus(binding: DocumentSelectionFocusBinding): void;
@@ -0,0 +1,56 @@
1
+ import { tick } from 'svelte';
2
+ function tableCellMatches(a, b) {
3
+ if (!a && !b)
4
+ return true;
5
+ if (!a || !b)
6
+ return false;
7
+ return a.row === b.row && a.col === b.col;
8
+ }
9
+ /** Apply post-split focus and resync source blocks when selection moves away. */
10
+ export function syncDocumentSelectionFocus(binding) {
11
+ const sel = binding.documentSelection;
12
+ const node = binding.getNode();
13
+ if (!node || !sel?.plain)
14
+ return;
15
+ const plain = binding.getDisplayPlain();
16
+ if (sel.blockId === binding.blockId) {
17
+ if (!tableCellMatches(sel.tableCell, binding.tableCell)) {
18
+ // Table cells share one block id. A selection in another cell should not
19
+ // resync this cell's draft; doing so creates a focus/selection update loop.
20
+ return;
21
+ }
22
+ if (binding.takePendingFocus(binding.blockId, binding.tableCell)) {
23
+ binding.setFocused(true);
24
+ binding.setLocalPlain(plain);
25
+ if (binding.resyncDom)
26
+ binding.resyncDom();
27
+ else if (node.textContent !== plain)
28
+ node.textContent = plain;
29
+ if (document.activeElement !== node)
30
+ node.focus();
31
+ void tick().then(() => {
32
+ const target = binding.getNode();
33
+ if (!target)
34
+ return;
35
+ if (document.activeElement !== target)
36
+ target.focus();
37
+ binding.setCaret(target, sel.plain.end);
38
+ });
39
+ return;
40
+ }
41
+ if (plain.length > 0 && (node.textContent ?? '') === '' && !binding.resyncDom) {
42
+ // Post-split target: model has body text before the surface received input.
43
+ binding.setLocalPlain(plain);
44
+ node.textContent = plain;
45
+ binding.setCaret(node, sel.plain.end);
46
+ }
47
+ return;
48
+ }
49
+ if (binding.isFocused() && document.activeElement === node && sel.blockId !== binding.blockId) {
50
+ binding.setLocalPlain(plain);
51
+ if (binding.resyncDom)
52
+ binding.resyncDom();
53
+ else if (node.textContent !== plain)
54
+ node.textContent = plain;
55
+ }
56
+ }
@@ -0,0 +1,27 @@
1
+ /** Best-effort identity for browser-only reopen (same physical file as last session under typical OS metadata). Not a path or cryptographic id. */
2
+ export declare function fileFingerprint(file: Pick<File, 'name' | 'size' | 'lastModified'>): string;
3
+ export declare function draftKeyUntitled(): string;
4
+ export declare function draftKeyForFileFingerprint(fingerprint: string): string;
5
+ /** Pre–Phase 4 keys used only the display file name. */
6
+ export declare function legacyDraftKeyForFileName(fileName: string): string;
7
+ export type StoredDraft = {
8
+ source: string;
9
+ savedAt: number;
10
+ fileName?: string | null;
11
+ fingerprint?: string | null;
12
+ };
13
+ export type SaveDraftMeta = {
14
+ fileName?: string | null;
15
+ fingerprint?: string | null;
16
+ /** When migrating or preserving an existing timestamp */
17
+ savedAt?: number;
18
+ };
19
+ export declare function saveDraft(key: string, source: string, meta?: SaveDraftMeta): void;
20
+ export declare function loadDraft(key: string): StoredDraft | null;
21
+ export declare function clearDraft(key: string): void;
22
+ /**
23
+ * Prefer fingerprint key; if empty, migrate legacy `md-editor-draft:<fileName>` into the fingerprint key.
24
+ */
25
+ export declare function loadDraftForFileWithLegacy(fingerprint: string, fileName: string): StoredDraft | null;
26
+ /** @deprecated Use {@link draftKeyUntitled} or {@link draftKeyForFileFingerprint} with {@link fileFingerprint}. */
27
+ export declare function draftStorageKey(fileName: string | null): string;
@@ -0,0 +1,83 @@
1
+ const PREFIX = 'md-editor-draft:';
2
+ /** Best-effort identity for browser-only reopen (same physical file as last session under typical OS metadata). Not a path or cryptographic id. */
3
+ export function fileFingerprint(file) {
4
+ return `${file.name}\u001f${file.size}\u001f${file.lastModified}`;
5
+ }
6
+ export function draftKeyUntitled() {
7
+ return `${PREFIX}untitled`;
8
+ }
9
+ export function draftKeyForFileFingerprint(fingerprint) {
10
+ return `${PREFIX}file:${encodeURIComponent(fingerprint)}`;
11
+ }
12
+ /** Pre–Phase 4 keys used only the display file name. */
13
+ export function legacyDraftKeyForFileName(fileName) {
14
+ return `${PREFIX}${fileName}`;
15
+ }
16
+ export function saveDraft(key, source, meta) {
17
+ if (typeof localStorage === 'undefined')
18
+ return;
19
+ try {
20
+ const payload = {
21
+ source,
22
+ savedAt: meta?.savedAt ?? Date.now()
23
+ };
24
+ if (meta?.fileName !== undefined)
25
+ payload.fileName = meta.fileName;
26
+ if (meta?.fingerprint !== undefined)
27
+ payload.fingerprint = meta.fingerprint;
28
+ localStorage.setItem(key, JSON.stringify(payload));
29
+ }
30
+ catch {
31
+ /* quota / private mode */
32
+ }
33
+ }
34
+ export function loadDraft(key) {
35
+ if (typeof localStorage === 'undefined')
36
+ return null;
37
+ try {
38
+ const raw = localStorage.getItem(key);
39
+ if (!raw)
40
+ return null;
41
+ const v = JSON.parse(raw);
42
+ if (typeof v?.source !== 'string' || typeof v?.savedAt !== 'number')
43
+ return null;
44
+ return v;
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ }
50
+ export function clearDraft(key) {
51
+ if (typeof localStorage === 'undefined')
52
+ return;
53
+ try {
54
+ localStorage.removeItem(key);
55
+ }
56
+ catch {
57
+ /* ignore */
58
+ }
59
+ }
60
+ /**
61
+ * Prefer fingerprint key; if empty, migrate legacy `md-editor-draft:<fileName>` into the fingerprint key.
62
+ */
63
+ export function loadDraftForFileWithLegacy(fingerprint, fileName) {
64
+ const newKey = draftKeyForFileFingerprint(fingerprint);
65
+ const existing = loadDraft(newKey);
66
+ if (existing)
67
+ return existing;
68
+ const legacyKey = legacyDraftKeyForFileName(fileName);
69
+ const legacy = loadDraft(legacyKey);
70
+ if (!legacy)
71
+ return null;
72
+ saveDraft(newKey, legacy.source, {
73
+ fileName,
74
+ fingerprint,
75
+ savedAt: legacy.savedAt
76
+ });
77
+ clearDraft(legacyKey);
78
+ return loadDraft(newKey);
79
+ }
80
+ /** @deprecated Use {@link draftKeyUntitled} or {@link draftKeyForFileFingerprint} with {@link fileFingerprint}. */
81
+ export function draftStorageKey(fileName) {
82
+ return fileName ? legacyDraftKeyForFileName(fileName) : draftKeyUntitled();
83
+ }
@@ -0,0 +1,16 @@
1
+ /** Narrow embedder surface for in-session undo/redo (matches Phials {@link EditorHistoryHandle}). */
2
+ export interface EditorHistoryHandle {
3
+ undo: () => boolean;
4
+ redo: () => boolean;
5
+ canUndo: boolean;
6
+ canRedo: boolean;
7
+ }
8
+ export type EditorHistoryHandleWithSync = EditorHistoryHandle & {
9
+ sync: () => void;
10
+ };
11
+ export declare function createEditorHistoryHandle(deps: {
12
+ undo: () => boolean;
13
+ redo: () => boolean;
14
+ getCanUndo: () => boolean;
15
+ getCanRedo: () => boolean;
16
+ }): EditorHistoryHandleWithSync;
@@ -0,0 +1,22 @@
1
+ export function createEditorHistoryHandle(deps) {
2
+ const handle = {
3
+ canUndo: false,
4
+ canRedo: false,
5
+ undo() {
6
+ const ok = deps.undo();
7
+ handle.sync();
8
+ return ok;
9
+ },
10
+ redo() {
11
+ const ok = deps.redo();
12
+ handle.sync();
13
+ return ok;
14
+ },
15
+ sync() {
16
+ handle.canUndo = deps.getCanUndo();
17
+ handle.canRedo = deps.getCanRedo();
18
+ }
19
+ };
20
+ handle.sync();
21
+ return handle;
22
+ }
@@ -0,0 +1,174 @@
1
+ <script lang="ts">
2
+ import { getPopoverManager } from 'phoundry-ui';
3
+ import type { MarkdownEditor } from '../MarkdownEditor.svelte';
4
+ import { findBlockLocation } from '../model/blockTree';
5
+ import { selectionBoundingRect } from './selectionRect';
6
+ import { inlineChromeState } from './inlineChromeState.svelte';
7
+ import { resolveLinkHoverFromElement } from './inlineChromeActions';
8
+
9
+ let { editor, root }: { editor: MarkdownEditor; root: HTMLElement } = $props();
10
+
11
+ const popover = getPopoverManager();
12
+ const chrome = inlineChromeState;
13
+
14
+ let linkHideTimer: ReturnType<typeof setTimeout> | null = null;
15
+ let suppressLinkHover = $state(false);
16
+
17
+ $effect(() => {
18
+ chrome.editor = editor;
19
+ });
20
+
21
+ function closeChrome() {
22
+ popover.close();
23
+ chrome.reset();
24
+ }
25
+
26
+ function openSelectionToolbar() {
27
+ const sel = editor.documentSelection;
28
+ if (!sel?.plain || sel.plain.start === sel.plain.end) {
29
+ closeChrome();
30
+ return;
31
+ }
32
+ const rect = selectionBoundingRect();
33
+ if (!rect) {
34
+ closeChrome();
35
+ return;
36
+ }
37
+ const loc = findBlockLocation(editor.document.blocks, sel.blockId);
38
+ if (!loc) {
39
+ closeChrome();
40
+ return;
41
+ }
42
+ const block = loc.block;
43
+ if (block.type !== 'paragraph' && block.type !== 'heading') {
44
+ closeChrome();
45
+ return;
46
+ }
47
+
48
+ chrome.mode = 'selection';
49
+ chrome.panel = 'root';
50
+ chrome.blockId = sel.blockId;
51
+ chrome.plainStart = sel.plain.start;
52
+ chrome.plainEnd = sel.plain.end;
53
+ chrome.linkHover = null;
54
+
55
+ popover.open({
56
+ anchor: rect,
57
+ placement: 'top',
58
+ ariaLabel: 'Text formatting',
59
+ onClose: () => chrome.reset()
60
+ });
61
+ }
62
+
63
+ function openLinkHover(target: ReturnType<typeof resolveLinkHoverFromElement> & { element: HTMLElement }) {
64
+ if (!target || suppressLinkHover) return;
65
+ const sel = editor.documentSelection;
66
+ if (sel?.plain && sel.plain.start !== sel.plain.end) return;
67
+
68
+ chrome.mode = 'link-hover';
69
+ chrome.panel = 'link-edit';
70
+ chrome.blockId = target.blockId;
71
+ chrome.plainStart = target.plainStart;
72
+ chrome.plainEnd = target.plainEnd;
73
+ chrome.linkHover = {
74
+ blockId: target.blockId,
75
+ plainStart: target.plainStart,
76
+ plainEnd: target.plainEnd,
77
+ href: target.href,
78
+ element: target.element
79
+ };
80
+ chrome.linkDraftHref = target.href;
81
+
82
+ popover.open({
83
+ anchor: target.element,
84
+ placement: 'top',
85
+ ariaLabel: 'Link',
86
+ onClose: () => chrome.reset()
87
+ });
88
+ }
89
+
90
+ $effect(() => {
91
+ const sel = editor.documentSelection;
92
+ if (chrome.mode === 'link-hover') return;
93
+ if (!sel?.plain || sel.plain.start === sel.plain.end) {
94
+ if (chrome.mode === 'selection') closeChrome();
95
+ return;
96
+ }
97
+ queueMicrotask(() => {
98
+ if (chrome.mode !== 'link-hover') openSelectionToolbar();
99
+ });
100
+ });
101
+
102
+ function onPointerOver(e: PointerEvent) {
103
+ const t = e.target;
104
+ if (!(t instanceof HTMLElement)) return;
105
+ const linkMeta = resolveLinkHoverFromElement(t);
106
+ if (!linkMeta) return;
107
+ if (linkHideTimer) {
108
+ clearTimeout(linkHideTimer);
109
+ linkHideTimer = null;
110
+ }
111
+ const sel = editor.documentSelection;
112
+ if (sel?.plain && sel.plain.start !== sel.plain.end) return;
113
+ openLinkHover({ ...linkMeta, element: t.closest('[data-md-inline-link]') as HTMLElement });
114
+ }
115
+
116
+ function clearLinkHideTimer() {
117
+ if (linkHideTimer) {
118
+ clearTimeout(linkHideTimer);
119
+ linkHideTimer = null;
120
+ }
121
+ }
122
+
123
+ function pointInRect(x: number, y: number, rect: DOMRect | DOMRectReadOnly): boolean {
124
+ return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
125
+ }
126
+
127
+ function onPointerMove(e: PointerEvent) {
128
+ if (chrome.mode !== 'link-hover') return;
129
+ const link = chrome.linkHover?.element;
130
+ const floating = document.querySelector('[role="dialog"][aria-label="Link"]');
131
+ const overLink = link ? pointInRect(e.clientX, e.clientY, link.getBoundingClientRect()) : false;
132
+ const overPopover =
133
+ floating instanceof HTMLElement
134
+ ? pointInRect(e.clientX, e.clientY, floating.getBoundingClientRect())
135
+ : false;
136
+ if (overLink || overPopover) {
137
+ clearLinkHideTimer();
138
+ return;
139
+ }
140
+ if (linkHideTimer) return;
141
+ linkHideTimer = setTimeout(() => {
142
+ if (chrome.mode === 'link-hover') closeChrome();
143
+ }, 120);
144
+ }
145
+
146
+ function onScrollCapture() {
147
+ if (chrome.mode === 'selection') {
148
+ popover.bumpTick();
149
+ const rect = selectionBoundingRect();
150
+ if (!rect) closeChrome();
151
+ return;
152
+ }
153
+ if (chrome.mode === 'link-hover') closeChrome();
154
+ }
155
+
156
+ $effect(() => {
157
+ if (!root) return;
158
+ root.addEventListener('pointerover', onPointerOver, true);
159
+ window.addEventListener('pointermove', onPointerMove, true);
160
+ window.addEventListener('scroll', onScrollCapture, true);
161
+ return () => {
162
+ root.removeEventListener('pointerover', onPointerOver, true);
163
+ window.removeEventListener('pointermove', onPointerMove, true);
164
+ window.removeEventListener('scroll', onScrollCapture, true);
165
+ if (linkHideTimer) clearTimeout(linkHideTimer);
166
+ };
167
+ });
168
+
169
+ $effect(() => {
170
+ if (!popover.state && chrome.mode !== 'closed') {
171
+ chrome.reset();
172
+ }
173
+ });
174
+ </script>
@@ -0,0 +1,8 @@
1
+ import type { MarkdownEditor } from '../MarkdownEditor.svelte';
2
+ type $$ComponentProps = {
3
+ editor: MarkdownEditor;
4
+ root: HTMLElement;
5
+ };
6
+ declare const InlineChromeCoordinator: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type InlineChromeCoordinator = ReturnType<typeof InlineChromeCoordinator>;
8
+ export default InlineChromeCoordinator;
@@ -0,0 +1,181 @@
1
+ <script lang="ts">
2
+ import Icon from '@iconify/svelte';
3
+ import { Button, TextInput } from 'phoundry-ui';
4
+ import { getPopoverManager } from 'phoundry-ui';
5
+ import type { InlineWrapKind } from '../model/inlineEditCommands';
6
+ import { inlineToolbarIcons } from './inlineToolbarIcons';
7
+ import { inlineChromeState } from './inlineChromeState.svelte';
8
+ import { activeWrapKindsForRange } from './inlineWrapActive';
9
+ import {
10
+ applyLinkHrefFromChrome,
11
+ applyUnlinkFromChrome,
12
+ applyWrapFromChrome,
13
+ currentInlinesForChrome,
14
+ headingCommandsForChrome,
15
+ runTurnIntoCommand
16
+ } from './inlineChromeActions';
17
+
18
+ const chrome = inlineChromeState;
19
+ const popover = getPopoverManager();
20
+
21
+ const wrapKinds: { kind: InlineWrapKind; icon: string; label: string }[] = [
22
+ { kind: 'strong', icon: inlineToolbarIcons.bold, label: 'Bold' },
23
+ { kind: 'emphasis', icon: inlineToolbarIcons.italic, label: 'Italic' },
24
+ { kind: 'code', icon: inlineToolbarIcons.code, label: 'Code' },
25
+ { kind: 'strikethrough', icon: inlineToolbarIcons.strikethrough, label: 'Strikethrough' },
26
+ { kind: 'highlight', icon: inlineToolbarIcons.highlight, label: 'Highlight' }
27
+ ];
28
+
29
+ const activeKinds = $derived.by(() => {
30
+ if (chrome.mode !== 'selection' || !chrome.blockId) return new Set<InlineWrapKind>();
31
+ const nodes = currentInlinesForChrome();
32
+ return activeWrapKindsForRange(nodes, chrome.plainStart, chrome.plainEnd);
33
+ });
34
+
35
+ const headingCommands = $derived(headingCommandsForChrome());
36
+
37
+ function stopMouseDown(e: MouseEvent) {
38
+ if (chrome.panel !== 'link-edit') e.preventDefault();
39
+ }
40
+
41
+ function onWrap(kind: InlineWrapKind) {
42
+ if (kind === 'link') {
43
+ chrome.panel = 'link-edit';
44
+ chrome.linkDraftHref = activeKinds.has('link') ? '' : 'https://';
45
+ return;
46
+ }
47
+ applyWrapFromChrome(kind);
48
+ }
49
+
50
+ function commitLink() {
51
+ applyLinkHrefFromChrome(chrome.linkDraftHref);
52
+ if (chrome.mode === 'selection') {
53
+ chrome.panel = 'root';
54
+ } else {
55
+ popover.close();
56
+ }
57
+ }
58
+
59
+ function onHeadingPick(commandId: string) {
60
+ runTurnIntoCommand(commandId);
61
+ popover.close();
62
+ }
63
+
64
+ function openExternal() {
65
+ const href = chrome.linkDraftHref.trim();
66
+ if (href) window.open(href, '_blank', 'noopener,noreferrer');
67
+ }
68
+ </script>
69
+
70
+ {#if popover.state}
71
+ <div
72
+ role="toolbar"
73
+ tabindex="-1"
74
+ aria-label="Text formatting"
75
+ class="flex flex-col gap-1 rounded-lg border border-border-muted bg-surface-base p-1 shadow-lg"
76
+ onmousedown={stopMouseDown}
77
+ >
78
+ {#if chrome.mode === 'link-hover' || chrome.panel === 'link-edit'}
79
+ <div class="flex min-w-56 flex-col gap-1.5 p-1">
80
+ {#if chrome.mode === 'selection' && chrome.panel === 'link-edit'}
81
+ <button
82
+ type="button"
83
+ class="flex items-center gap-1 px-1 text-xs text-txt-secondary hover:text-txt-primary"
84
+ onclick={() => (chrome.panel = 'root')}
85
+ >
86
+ <Icon icon={inlineToolbarIcons.chevronLeft} width={14} height={14} />
87
+ Back
88
+ </button>
89
+ {/if}
90
+ <form
91
+ class="contents"
92
+ onsubmit={(e) => {
93
+ e.preventDefault();
94
+ commitLink();
95
+ }}
96
+ >
97
+ <TextInput
98
+ size="sm"
99
+ type="url"
100
+ placeholder="https://"
101
+ bind:value={chrome.linkDraftHref}
102
+ />
103
+ </form>
104
+ <div class="flex gap-1">
105
+ <Button size="sm" onclick={commitLink}>Apply</Button>
106
+ <Button
107
+ size="sm"
108
+ variant="ghost"
109
+ icon={inlineToolbarIcons.externalLink}
110
+ iconOnly
111
+ title="Open link"
112
+ onclick={openExternal}
113
+ />
114
+ <Button
115
+ size="sm"
116
+ variant="ghost"
117
+ icon={inlineToolbarIcons.unlink}
118
+ iconOnly
119
+ title="Remove link"
120
+ onclick={() => {
121
+ applyUnlinkFromChrome();
122
+ popover.close();
123
+ }}
124
+ />
125
+ </div>
126
+ </div>
127
+ {:else if chrome.panel === 'heading'}
128
+ <div class="flex min-w-40 flex-col gap-0.5 p-1">
129
+ <button
130
+ type="button"
131
+ class="flex items-center gap-1 px-2 py-1 text-xs text-txt-secondary hover:text-txt-primary"
132
+ onclick={() => (chrome.panel = 'root')}
133
+ >
134
+ <Icon icon={inlineToolbarIcons.chevronLeft} width={14} height={14} />
135
+ Back
136
+ </button>
137
+ {#each headingCommands as cmd (cmd.id)}
138
+ <button
139
+ type="button"
140
+ class="rounded px-2 py-1.5 text-left text-xs text-txt-primary hover:bg-surface-raised"
141
+ onclick={() => onHeadingPick(cmd.id)}
142
+ >
143
+ {cmd.label}
144
+ </button>
145
+ {/each}
146
+ </div>
147
+ {:else}
148
+ <div class="flex items-center gap-0.5">
149
+ {#each wrapKinds as { kind, icon, label } (kind)}
150
+ <Button
151
+ size="sm"
152
+ variant="ghost"
153
+ {icon}
154
+ iconOnly
155
+ title={label}
156
+ active={activeKinds.has(kind)}
157
+ onclick={() => onWrap(kind)}
158
+ />
159
+ {/each}
160
+ <Button
161
+ size="sm"
162
+ variant="ghost"
163
+ icon={inlineToolbarIcons.link}
164
+ iconOnly
165
+ title="Link"
166
+ active={activeKinds.has('link')}
167
+ onclick={() => onWrap('link')}
168
+ />
169
+ <div class="mx-0.5 h-5 w-px bg-border-muted"></div>
170
+ <Button
171
+ size="sm"
172
+ variant="ghost"
173
+ icon={inlineToolbarIcons.heading}
174
+ iconOnly
175
+ title="Turn into"
176
+ onclick={() => (chrome.panel = 'heading')}
177
+ />
178
+ </div>
179
+ {/if}
180
+ </div>
181
+ {/if}
@@ -0,0 +1,3 @@
1
+ declare const InlineFormattingToolbar: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type InlineFormattingToolbar = ReturnType<typeof InlineFormattingToolbar>;
3
+ export default InlineFormattingToolbar;
@@ -0,0 +1,17 @@
1
+ import type { InlineWrapKind } from '../model/inlineEditCommands';
2
+ import type { InlineNode } from '../model/types';
3
+ import type { MarkdownEditor } from '../MarkdownEditor.svelte';
4
+ import { type EditorCommandContext } from '../commandRegistry';
5
+ export declare function commandContextForBlockId(editor: MarkdownEditor, blockId: string): EditorCommandContext | null;
6
+ export declare function applyWrapFromChrome(kind: InlineWrapKind, linkHref?: string): void;
7
+ export declare function applyUnlinkFromChrome(): void;
8
+ export declare function runTurnIntoCommand(commandId: string): void;
9
+ export declare function headingCommandsForChrome(): import("../commandRegistry").EditorCommand[];
10
+ export declare function resolveLinkHoverFromElement(el: HTMLElement): {
11
+ blockId: string;
12
+ plainStart: number;
13
+ plainEnd: number;
14
+ href: string;
15
+ } | null;
16
+ export declare function applyLinkHrefFromChrome(href: string): void;
17
+ export declare function currentInlinesForChrome(): InlineNode[];