@voithos-labs/aragonite 0.10.1

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 (900) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +365 -0
  3. package/THIRD-PARTY-NOTICES.md +102 -0
  4. package/dist/a11y-strings.d.ts +46 -0
  5. package/dist/a11y-strings.js +62 -0
  6. package/dist/action-contracts.d.ts +301 -0
  7. package/dist/action-contracts.js +5 -0
  8. package/dist/active-editor.d.ts +16 -0
  9. package/dist/active-editor.js +67 -0
  10. package/dist/ambient/ambient-cursor.d.ts +41 -0
  11. package/dist/ambient/ambient-cursor.js +120 -0
  12. package/dist/ambient/ambient-dom.d.ts +9 -0
  13. package/dist/ambient/ambient-dom.js +102 -0
  14. package/dist/assert.d.ts +6 -0
  15. package/dist/assert.js +17 -0
  16. package/dist/block-component.d.ts +274 -0
  17. package/dist/block-component.js +43 -0
  18. package/dist/block-id.d.ts +14 -0
  19. package/dist/block-id.js +34 -0
  20. package/dist/bounded-memo.d.ts +14 -0
  21. package/dist/bounded-memo.js +32 -0
  22. package/dist/components/BlockDragHandle.svelte +66 -0
  23. package/dist/components/BlockDragHandle.svelte.d.ts +18 -0
  24. package/dist/components/BlockHost.svelte +328 -0
  25. package/dist/components/BlockHost.svelte.d.ts +15 -0
  26. package/dist/components/BlockList.svelte +114 -0
  27. package/dist/components/BlockList.svelte.d.ts +16 -0
  28. package/dist/components/DecorationOverlay.svelte +156 -0
  29. package/dist/components/DecorationOverlay.svelte.d.ts +14 -0
  30. package/dist/components/Editor.svelte +1849 -0
  31. package/dist/components/Editor.svelte.d.ts +49 -0
  32. package/dist/components/GapCaret.svelte +226 -0
  33. package/dist/components/GapCaret.svelte.d.ts +9 -0
  34. package/dist/components/SearchBar.svelte +243 -0
  35. package/dist/components/SearchBar.svelte.d.ts +7 -0
  36. package/dist/components/SelectionOverlay.svelte +171 -0
  37. package/dist/components/SelectionOverlay.svelte.d.ts +14 -0
  38. package/dist/components/block-content-selector.d.ts +12 -0
  39. package/dist/components/block-content-selector.js +12 -0
  40. package/dist/components/blocks/BlockquoteBlock.svelte +32 -0
  41. package/dist/components/blocks/BlockquoteBlock.svelte.d.ts +11 -0
  42. package/dist/components/blocks/ThematicBreakBlock.svelte +156 -0
  43. package/dist/components/blocks/ThematicBreakBlock.svelte.d.ts +17 -0
  44. package/dist/components/blocks/code/CodeBlock.svelte +726 -0
  45. package/dist/components/blocks/code/CodeBlock.svelte.d.ts +23 -0
  46. package/dist/components/blocks/code/CodeLanguageChip.svelte +127 -0
  47. package/dist/components/blocks/code/CodeLanguageChip.svelte.d.ts +14 -0
  48. package/dist/components/blocks/code/code-beforeinput.d.ts +30 -0
  49. package/dist/components/blocks/code/code-beforeinput.js +40 -0
  50. package/dist/components/blocks/code/code-bootstrap.d.ts +8 -0
  51. package/dist/components/blocks/code/code-bootstrap.js +54 -0
  52. package/dist/components/blocks/code/code-editing.d.ts +28 -0
  53. package/dist/components/blocks/code/code-editing.js +79 -0
  54. package/dist/components/blocks/code/code-enter.d.ts +22 -0
  55. package/dist/components/blocks/code/code-enter.js +19 -0
  56. package/dist/components/blocks/code/code-fence-boundary.d.ts +77 -0
  57. package/dist/components/blocks/code/code-fence-boundary.js +169 -0
  58. package/dist/components/blocks/code/code-fence-exit.d.ts +24 -0
  59. package/dist/components/blocks/code/code-fence-exit.js +36 -0
  60. package/dist/components/blocks/code/code-indent.d.ts +14 -0
  61. package/dist/components/blocks/code/code-indent.js +87 -0
  62. package/dist/components/blocks/code/code-languages.d.ts +15 -0
  63. package/dist/components/blocks/code/code-languages.js +30 -0
  64. package/dist/components/blocks/code/code-paste-surface.d.ts +6 -0
  65. package/dist/components/blocks/code/code-paste-surface.js +29 -0
  66. package/dist/components/blocks/code/code-paste.d.ts +24 -0
  67. package/dist/components/blocks/code/code-paste.js +21 -0
  68. package/dist/components/blocks/code/code-renderer.d.ts +18 -0
  69. package/dist/components/blocks/code/code-renderer.js +249 -0
  70. package/dist/components/blocks/directive/DirectiveContainerBlock.svelte +51 -0
  71. package/dist/components/blocks/directive/DirectiveContainerBlock.svelte.d.ts +11 -0
  72. package/dist/components/blocks/directive/activate-directives.d.ts +7 -0
  73. package/dist/components/blocks/directive/activate-directives.js +23 -0
  74. package/dist/components/blocks/editable-leaf.d.ts +126 -0
  75. package/dist/components/blocks/editable-leaf.js +410 -0
  76. package/dist/components/blocks/editable-surface.d.ts +209 -0
  77. package/dist/components/blocks/editable-surface.js +331 -0
  78. package/dist/components/blocks/list/ListBlock.svelte +162 -0
  79. package/dist/components/blocks/list/ListBlock.svelte.d.ts +11 -0
  80. package/dist/components/blocks/list/ListItemBlock.svelte +324 -0
  81. package/dist/components/blocks/list/ListItemBlock.svelte.d.ts +14 -0
  82. package/dist/components/blocks/list/task-checkbox.d.ts +3 -0
  83. package/dist/components/blocks/list/task-checkbox.js +33 -0
  84. package/dist/components/blocks/plain-text-backend.d.ts +21 -0
  85. package/dist/components/blocks/plain-text-backend.js +47 -0
  86. package/dist/components/blocks/surface-wiring.svelte.d.ts +18 -0
  87. package/dist/components/blocks/surface-wiring.svelte.js +68 -0
  88. package/dist/components/blocks/table/TableActionMenu.svelte +267 -0
  89. package/dist/components/blocks/table/TableActionMenu.svelte.d.ts +15 -0
  90. package/dist/components/blocks/table/TableBlock.svelte +765 -0
  91. package/dist/components/blocks/table/TableBlock.svelte.d.ts +30 -0
  92. package/dist/components/blocks/table/TableCellBlock.svelte +1075 -0
  93. package/dist/components/blocks/table/TableCellBlock.svelte.d.ts +30 -0
  94. package/dist/components/blocks/table/TableGrip.svelte +91 -0
  95. package/dist/components/blocks/table/TableGrip.svelte.d.ts +8 -0
  96. package/dist/components/blocks/table/TableRowBlock.svelte +233 -0
  97. package/dist/components/blocks/table/TableRowBlock.svelte.d.ts +34 -0
  98. package/dist/components/blocks/table/cell-clipboard.d.ts +23 -0
  99. package/dist/components/blocks/table/cell-clipboard.js +34 -0
  100. package/dist/components/blocks/table/cell-keydown-plan.d.ts +37 -0
  101. package/dist/components/blocks/table/cell-keydown-plan.js +66 -0
  102. package/dist/components/blocks/table/cell-pointer.d.ts +58 -0
  103. package/dist/components/blocks/table/cell-pointer.js +153 -0
  104. package/dist/components/blocks/table/cell-render.d.ts +51 -0
  105. package/dist/components/blocks/table/cell-render.js +98 -0
  106. package/dist/components/blocks/table/cell-table-commands.d.ts +12 -0
  107. package/dist/components/blocks/table/cell-table-commands.js +21 -0
  108. package/dist/components/blocks/table/cell-x-mapping.d.ts +6 -0
  109. package/dist/components/blocks/table/cell-x-mapping.js +16 -0
  110. package/dist/components/blocks/table/selected-cells.d.ts +19 -0
  111. package/dist/components/blocks/table/selected-cells.js +35 -0
  112. package/dist/components/blocks/table/table-caret-at-point.d.ts +8 -0
  113. package/dist/components/blocks/table/table-caret-at-point.js +35 -0
  114. package/dist/components/blocks/table/table-cell-paste.d.ts +16 -0
  115. package/dist/components/blocks/table/table-cell-paste.js +75 -0
  116. package/dist/components/blocks/table/table-drag-hit-test.d.ts +5 -0
  117. package/dist/components/blocks/table/table-drag-hit-test.js +20 -0
  118. package/dist/components/blocks/table/table-drop-target.d.ts +1 -0
  119. package/dist/components/blocks/table/table-drop-target.js +16 -0
  120. package/dist/components/blocks/table/table-menu-model.d.ts +52 -0
  121. package/dist/components/blocks/table/table-menu-model.js +78 -0
  122. package/dist/components/blocks/table/table-navigation.d.ts +8 -0
  123. package/dist/components/blocks/table/table-navigation.js +22 -0
  124. package/dist/components/blocks/table/table-reorder-drag.d.ts +78 -0
  125. package/dist/components/blocks/table/table-reorder-drag.js +97 -0
  126. package/dist/components/blocks/text/TextEditableBlock.svelte +1012 -0
  127. package/dist/components/blocks/text/TextEditableBlock.svelte.d.ts +33 -0
  128. package/dist/components/blocks/text/click-snap-guard.d.ts +8 -0
  129. package/dist/components/blocks/text/click-snap-guard.js +19 -0
  130. package/dist/components/blocks/text/composition-seat.d.ts +50 -0
  131. package/dist/components/blocks/text/composition-seat.js +65 -0
  132. package/dist/components/blocks/text/construct-edge-delete.d.ts +47 -0
  133. package/dist/components/blocks/text/construct-edge-delete.js +164 -0
  134. package/dist/components/blocks/text/construct-reveal.d.ts +39 -0
  135. package/dist/components/blocks/text/construct-reveal.js +164 -0
  136. package/dist/components/blocks/text/edge-policy-dispatch.d.ts +91 -0
  137. package/dist/components/blocks/text/edge-policy-dispatch.js +457 -0
  138. package/dist/components/blocks/text/edge-seat.d.ts +42 -0
  139. package/dist/components/blocks/text/edge-seat.js +197 -0
  140. package/dist/components/blocks/text/hidden-suffix.d.ts +10 -0
  141. package/dist/components/blocks/text/hidden-suffix.js +15 -0
  142. package/dist/components/blocks/text/link-at-point.d.ts +33 -0
  143. package/dist/components/blocks/text/link-at-point.js +47 -0
  144. package/dist/components/blocks/text/link-source-bytes.d.ts +37 -0
  145. package/dist/components/blocks/text/link-source-bytes.js +161 -0
  146. package/dist/components/blocks/text/live-join-seam.d.ts +15 -0
  147. package/dist/components/blocks/text/live-join-seam.js +327 -0
  148. package/dist/components/blocks/text/live-selection-edit.d.ts +68 -0
  149. package/dist/components/blocks/text/live-selection-edit.js +120 -0
  150. package/dist/components/blocks/text/live-split-rebalance.d.ts +56 -0
  151. package/dist/components/blocks/text/live-split-rebalance.js +239 -0
  152. package/dist/components/blocks/text/marker-completion.d.ts +18 -0
  153. package/dist/components/blocks/text/marker-completion.js +29 -0
  154. package/dist/components/blocks/text/pending-mark-insert.d.ts +37 -0
  155. package/dist/components/blocks/text/pending-mark-insert.js +188 -0
  156. package/dist/components/blocks/text/screen-diff.d.ts +20 -0
  157. package/dist/components/blocks/text/screen-diff.js +39 -0
  158. package/dist/components/blocks/text/text-clipboard.d.ts +70 -0
  159. package/dist/components/blocks/text/text-clipboard.js +131 -0
  160. package/dist/components/blocks/text/text-keydown.d.ts +39 -0
  161. package/dist/components/blocks/text/text-keydown.js +80 -0
  162. package/dist/components/blocks/text/text-render.d.ts +67 -0
  163. package/dist/components/blocks/text/text-render.js +215 -0
  164. package/dist/components/blocks/text/widget-adjacency.d.ts +30 -0
  165. package/dist/components/blocks/text/widget-adjacency.js +68 -0
  166. package/dist/components/blocks/text/widget-interaction.d.ts +90 -0
  167. package/dist/components/blocks/text/widget-interaction.js +591 -0
  168. package/dist/components/blocks/widget-portal.d.ts +54 -0
  169. package/dist/components/blocks/widget-portal.js +136 -0
  170. package/dist/components/built-in-blocks.d.ts +7 -0
  171. package/dist/components/built-in-blocks.js +77 -0
  172. package/dist/components/editor-root-clipboard.d.ts +29 -0
  173. package/dist/components/editor-root-clipboard.js +105 -0
  174. package/dist/components/editor-root-keydown.d.ts +47 -0
  175. package/dist/components/editor-root-keydown.js +88 -0
  176. package/dist/components/editor-root-listeners.d.ts +44 -0
  177. package/dist/components/editor-root-listeners.js +112 -0
  178. package/dist/components/image/ImageOverlayHost.svelte +115 -0
  179. package/dist/components/image/ImageOverlayHost.svelte.d.ts +20 -0
  180. package/dist/components/image/ImageProperties.svelte +153 -0
  181. package/dist/components/image/ImageProperties.svelte.d.ts +14 -0
  182. package/dist/components/image/ImageResizeHandles.svelte +188 -0
  183. package/dist/components/image/ImageResizeHandles.svelte.d.ts +10 -0
  184. package/dist/components/image/image-edit-commit.d.ts +38 -0
  185. package/dist/components/image/image-edit-commit.js +159 -0
  186. package/dist/components/image/image-resize.d.ts +11 -0
  187. package/dist/components/image/image-resize.js +38 -0
  188. package/dist/components/image/image-source-bytes.d.ts +15 -0
  189. package/dist/components/image/image-source-bytes.js +73 -0
  190. package/dist/components/image/image-widget-editing.d.ts +7 -0
  191. package/dist/components/image/image-widget-editing.js +41 -0
  192. package/dist/components/image/widget-dom.d.ts +11 -0
  193. package/dist/components/image/widget-dom.js +110 -0
  194. package/dist/components/image/widget-selection-state.svelte.d.ts +18 -0
  195. package/dist/components/image/widget-selection-state.svelte.js +26 -0
  196. package/dist/components/link-card/LinkCard.svelte +190 -0
  197. package/dist/components/link-card/LinkCard.svelte.d.ts +18 -0
  198. package/dist/components/link-card/LinkCardHost.svelte +181 -0
  199. package/dist/components/link-card/LinkCardHost.svelte.d.ts +25 -0
  200. package/dist/components/link-card/link-card-commit.d.ts +50 -0
  201. package/dist/components/link-card/link-card-commit.js +134 -0
  202. package/dist/components/link-card/link-card-entry.d.ts +39 -0
  203. package/dist/components/link-card/link-card-entry.js +51 -0
  204. package/dist/components/link-card/link-card-state.svelte.d.ts +44 -0
  205. package/dist/components/link-card/link-card-state.svelte.js +46 -0
  206. package/dist/components/lrd-map-gate.d.ts +18 -0
  207. package/dist/components/lrd-map-gate.js +22 -0
  208. package/dist/components/paste-image-arm.d.ts +29 -0
  209. package/dist/components/paste-image-arm.js +61 -0
  210. package/dist/components/portal.d.ts +11 -0
  211. package/dist/components/portal.js +29 -0
  212. package/dist/core/directive/activate.d.ts +8 -0
  213. package/dist/core/directive/activate.js +25 -0
  214. package/dist/core/directive/container-opener.d.ts +7 -0
  215. package/dist/core/directive/container-opener.js +162 -0
  216. package/dist/core/directive/grammar.d.ts +50 -0
  217. package/dist/core/directive/grammar.js +88 -0
  218. package/dist/core/directive/kinds.d.ts +31 -0
  219. package/dist/core/directive/kinds.js +137 -0
  220. package/dist/core/directive/registry.d.ts +39 -0
  221. package/dist/core/directive/registry.js +49 -0
  222. package/dist/core/directive/text-recognizer.d.ts +8 -0
  223. package/dist/core/directive/text-recognizer.js +87 -0
  224. package/dist/core/escapable.d.ts +6 -0
  225. package/dist/core/escapable.js +6 -0
  226. package/dist/core/inline/backticks.d.ts +16 -0
  227. package/dist/core/inline/backticks.js +62 -0
  228. package/dist/core/inline/character-refs.d.ts +7 -0
  229. package/dist/core/inline/character-refs.js +70 -0
  230. package/dist/core/inline/destination-bytes.d.ts +7 -0
  231. package/dist/core/inline/destination-bytes.js +14 -0
  232. package/dist/core/inline/entity-widget.d.ts +11 -0
  233. package/dist/core/inline/entity-widget.js +21 -0
  234. package/dist/core/inline/format-toggle.d.ts +50 -0
  235. package/dist/core/inline/format-toggle.js +533 -0
  236. package/dist/core/inline/html-entities.d.ts +8 -0
  237. package/dist/core/inline/html-entities.js +2134 -0
  238. package/dist/core/inline/html-tag-grammar.d.ts +16 -0
  239. package/dist/core/inline/html-tag-grammar.js +58 -0
  240. package/dist/core/inline/image-dimensions.d.ts +6 -0
  241. package/dist/core/inline/image-dimensions.js +42 -0
  242. package/dist/core/inline/index.d.ts +42 -0
  243. package/dist/core/inline/index.js +77 -0
  244. package/dist/core/inline/inline-cache.d.ts +20 -0
  245. package/dist/core/inline/inline-cache.js +28 -0
  246. package/dist/core/inline/inline-widgets.d.ts +124 -0
  247. package/dist/core/inline/inline-widgets.js +131 -0
  248. package/dist/core/inline/link-reference-resolver.d.ts +21 -0
  249. package/dist/core/inline/link-reference-resolver.js +46 -0
  250. package/dist/core/inline/raw-html-widget.d.ts +10 -0
  251. package/dist/core/inline/raw-html-widget.js +22 -0
  252. package/dist/core/inline/scan/autolinks.d.ts +23 -0
  253. package/dist/core/inline/scan/autolinks.js +354 -0
  254. package/dist/core/inline/scan/brackets.d.ts +11 -0
  255. package/dist/core/inline/scan/brackets.js +284 -0
  256. package/dist/core/inline/scan/code-spans.d.ts +7 -0
  257. package/dist/core/inline/scan/code-spans.js +27 -0
  258. package/dist/core/inline/scan/emphasis.d.ts +10 -0
  259. package/dist/core/inline/scan/emphasis.js +276 -0
  260. package/dist/core/inline/scan/index.d.ts +7 -0
  261. package/dist/core/inline/scan/index.js +176 -0
  262. package/dist/core/inline/scan/plugin-syntax.d.ts +62 -0
  263. package/dist/core/inline/scan/plugin-syntax.js +150 -0
  264. package/dist/core/inline/scan/scan-state.d.ts +47 -0
  265. package/dist/core/inline/scan/scan-state.js +48 -0
  266. package/dist/core/inline/scan/simple-nodes.d.ts +14 -0
  267. package/dist/core/inline/scan/simple-nodes.js +53 -0
  268. package/dist/core/inline/scan/url.d.ts +12 -0
  269. package/dist/core/inline/scan/url.js +82 -0
  270. package/dist/core/inline/transparency.d.ts +8 -0
  271. package/dist/core/inline/transparency.js +39 -0
  272. package/dist/core/inline/visibility.d.ts +81 -0
  273. package/dist/core/inline/visibility.js +144 -0
  274. package/dist/core/inline/walk.d.ts +14 -0
  275. package/dist/core/inline/walk.js +29 -0
  276. package/dist/core/inline-render.d.ts +48 -0
  277. package/dist/core/inline-render.js +322 -0
  278. package/dist/core/lines.d.ts +44 -0
  279. package/dist/core/lines.js +91 -0
  280. package/dist/core/node-views.d.ts +22 -0
  281. package/dist/core/node-views.js +8 -0
  282. package/dist/core/nodes.d.ts +297 -0
  283. package/dist/core/nodes.js +83 -0
  284. package/dist/core/parser.d.ts +68 -0
  285. package/dist/core/parser.js +189 -0
  286. package/dist/core/parsers/blockquote.d.ts +17 -0
  287. package/dist/core/parsers/blockquote.js +69 -0
  288. package/dist/core/parsers/built-in-openers.d.ts +8 -0
  289. package/dist/core/parsers/built-in-openers.js +124 -0
  290. package/dist/core/parsers/fence-syntax.d.ts +24 -0
  291. package/dist/core/parsers/fence-syntax.js +44 -0
  292. package/dist/core/parsers/fenced-code.d.ts +7 -0
  293. package/dist/core/parsers/fenced-code.js +29 -0
  294. package/dist/core/parsers/heading.d.ts +3 -0
  295. package/dist/core/parsers/heading.js +6 -0
  296. package/dist/core/parsers/html-block.d.ts +17 -0
  297. package/dist/core/parsers/html-block.js +94 -0
  298. package/dist/core/parsers/indented-code.d.ts +4 -0
  299. package/dist/core/parsers/indented-code.js +41 -0
  300. package/dist/core/parsers/link-reference.d.ts +7 -0
  301. package/dist/core/parsers/link-reference.js +152 -0
  302. package/dist/core/parsers/list.d.ts +19 -0
  303. package/dist/core/parsers/list.js +133 -0
  304. package/dist/core/parsers/paragraph.d.ts +10 -0
  305. package/dist/core/parsers/paragraph.js +42 -0
  306. package/dist/core/parsers/table-completion.d.ts +13 -0
  307. package/dist/core/parsers/table-completion.js +48 -0
  308. package/dist/core/parsers/table.d.ts +18 -0
  309. package/dist/core/parsers/table.js +110 -0
  310. package/dist/core/parsers/thematic-break.d.ts +1 -0
  311. package/dist/core/parsers/thematic-break.js +19 -0
  312. package/dist/core/serializer.d.ts +15 -0
  313. package/dist/core/serializer.js +11 -0
  314. package/dist/core/terminator-escalation.d.ts +8 -0
  315. package/dist/core/terminator-escalation.js +18 -0
  316. package/dist/core/url-policy.d.ts +14 -0
  317. package/dist/core/url-policy.js +44 -0
  318. package/dist/cursor/content-offsets.d.ts +29 -0
  319. package/dist/cursor/content-offsets.js +151 -0
  320. package/dist/cursor/coordinate-spaces.d.ts +65 -0
  321. package/dist/cursor/coordinate-spaces.js +66 -0
  322. package/dist/cursor/dom-walk.d.ts +18 -0
  323. package/dist/cursor/dom-walk.js +31 -0
  324. package/dist/cursor/edge-affinity.d.ts +44 -0
  325. package/dist/cursor/edge-affinity.js +60 -0
  326. package/dist/cursor/focused-caret.d.ts +10 -0
  327. package/dist/cursor/focused-caret.js +24 -0
  328. package/dist/cursor/height-model.d.ts +24 -0
  329. package/dist/cursor/height-model.js +72 -0
  330. package/dist/cursor/height-oracle.d.ts +24 -0
  331. package/dist/cursor/height-oracle.js +94 -0
  332. package/dist/cursor/overlay-rects.d.ts +8 -0
  333. package/dist/cursor/overlay-rects.js +19 -0
  334. package/dist/cursor/overlay-remeasure.d.ts +17 -0
  335. package/dist/cursor/overlay-remeasure.js +31 -0
  336. package/dist/cursor/pending-marks.d.ts +24 -0
  337. package/dist/cursor/pending-marks.js +36 -0
  338. package/dist/cursor/point-offset.d.ts +21 -0
  339. package/dist/cursor/point-offset.js +48 -0
  340. package/dist/cursor/reveal-anchor.d.ts +30 -0
  341. package/dist/cursor/reveal-anchor.js +31 -0
  342. package/dist/cursor/reveal-source.d.ts +35 -0
  343. package/dist/cursor/reveal-source.js +51 -0
  344. package/dist/cursor/scroll-ancestors.d.ts +28 -0
  345. package/dist/cursor/scroll-ancestors.js +89 -0
  346. package/dist/cursor/scrollport.d.ts +20 -0
  347. package/dist/cursor/scrollport.js +41 -0
  348. package/dist/cursor/sticky-column.d.ts +35 -0
  349. package/dist/cursor/sticky-column.js +64 -0
  350. package/dist/cursor/sticky-measure.d.ts +16 -0
  351. package/dist/cursor/sticky-measure.js +97 -0
  352. package/dist/cursor/typography-estimates.d.ts +21 -0
  353. package/dist/cursor/typography-estimates.js +21 -0
  354. package/dist/cursor/visual-lines.d.ts +25 -0
  355. package/dist/cursor/visual-lines.js +125 -0
  356. package/dist/cursor/widget-offset.d.ts +132 -0
  357. package/dist/cursor/widget-offset.js +543 -0
  358. package/dist/debug/diagnostics-report.d.ts +17 -0
  359. package/dist/debug/diagnostics-report.js +25 -0
  360. package/dist/debug/dump-tree.d.ts +6 -0
  361. package/dist/debug/dump-tree.js +114 -0
  362. package/dist/debug/inspect.d.ts +19 -0
  363. package/dist/debug/inspect.js +116 -0
  364. package/dist/debug/interaction-trace.d.ts +39 -0
  365. package/dist/debug/interaction-trace.js +105 -0
  366. package/dist/debug/operations-log.d.ts +14 -0
  367. package/dist/debug/operations-log.js +30 -0
  368. package/dist/decorations/buckets.d.ts +40 -0
  369. package/dist/decorations/buckets.js +87 -0
  370. package/dist/decorations/decoration-state.svelte.d.ts +20 -0
  371. package/dist/decorations/decoration-state.svelte.js +195 -0
  372. package/dist/decorations/island-dom.d.ts +35 -0
  373. package/dist/decorations/island-dom.js +148 -0
  374. package/dist/decorations/reserved-attrs.d.ts +12 -0
  375. package/dist/decorations/reserved-attrs.js +47 -0
  376. package/dist/decorations/types.d.ts +68 -0
  377. package/dist/decorations/types.js +5 -0
  378. package/dist/decorations/widget-dom.d.ts +15 -0
  379. package/dist/decorations/widget-dom.js +35 -0
  380. package/dist/dev-warn.d.ts +13 -0
  381. package/dist/dev-warn.js +28 -0
  382. package/dist/editor-actions/ancestry-folds.d.ts +32 -0
  383. package/dist/editor-actions/ancestry-folds.js +106 -0
  384. package/dist/editor-actions/block-edit-core.d.ts +29 -0
  385. package/dist/editor-actions/block-edit-core.js +277 -0
  386. package/dist/editor-actions/block-edit-scope.d.ts +79 -0
  387. package/dist/editor-actions/block-edit-scope.js +76 -0
  388. package/dist/editor-actions/block-edit.d.ts +8 -0
  389. package/dist/editor-actions/block-edit.js +111 -0
  390. package/dist/editor-actions/commit/history.d.ts +9 -0
  391. package/dist/editor-actions/commit/history.js +77 -0
  392. package/dist/editor-actions/commit/text-batch.d.ts +34 -0
  393. package/dist/editor-actions/commit/text-batch.js +61 -0
  394. package/dist/editor-actions/commit/undo-controller.d.ts +7 -0
  395. package/dist/editor-actions/commit/undo-controller.js +570 -0
  396. package/dist/editor-actions/container-block-component.d.ts +85 -0
  397. package/dist/editor-actions/container-block-component.js +228 -0
  398. package/dist/editor-actions/container-edit.d.ts +7 -0
  399. package/dist/editor-actions/container-edit.js +49 -0
  400. package/dist/editor-actions/container-exit-overrides.d.ts +16 -0
  401. package/dist/editor-actions/container-exit-overrides.js +38 -0
  402. package/dist/editor-actions/deps.d.ts +60 -0
  403. package/dist/editor-actions/deps.js +1 -0
  404. package/dist/editor-actions/enter-completion.d.ts +25 -0
  405. package/dist/editor-actions/enter-completion.js +76 -0
  406. package/dist/editor-actions/focus/focus-dispatch.d.ts +36 -0
  407. package/dist/editor-actions/focus/focus-dispatch.js +106 -0
  408. package/dist/editor-actions/focus/focus-landing.d.ts +7 -0
  409. package/dist/editor-actions/focus/focus-landing.js +39 -0
  410. package/dist/editor-actions/focus/focus.d.ts +7 -0
  411. package/dist/editor-actions/focus/focus.js +74 -0
  412. package/dist/editor-actions/index.d.ts +15 -0
  413. package/dist/editor-actions/index.js +19 -0
  414. package/dist/editor-actions/inline-range-commit.d.ts +20 -0
  415. package/dist/editor-actions/inline-range-commit.js +63 -0
  416. package/dist/editor-actions/list-context.d.ts +25 -0
  417. package/dist/editor-actions/list-context.js +285 -0
  418. package/dist/editor-actions/list-overrides.d.ts +13 -0
  419. package/dist/editor-actions/list-overrides.js +26 -0
  420. package/dist/editor-actions/merge-fallback.d.ts +19 -0
  421. package/dist/editor-actions/merge-fallback.js +27 -0
  422. package/dist/editor-actions/nested/nested-actions.d.ts +65 -0
  423. package/dist/editor-actions/nested/nested-actions.js +59 -0
  424. package/dist/editor-actions/nested/nested-block-edit.d.ts +10 -0
  425. package/dist/editor-actions/nested/nested-block-edit.js +181 -0
  426. package/dist/editor-actions/nested/nested-focus.d.ts +9 -0
  427. package/dist/editor-actions/nested/nested-focus.js +30 -0
  428. package/dist/editor-actions/paste-coordinator.d.ts +4 -0
  429. package/dist/editor-actions/paste-coordinator.js +20 -0
  430. package/dist/editor-actions/plugin/chrome-leaf.d.ts +25 -0
  431. package/dist/editor-actions/plugin/chrome-leaf.js +80 -0
  432. package/dist/editor-actions/plugin/container.d.ts +137 -0
  433. package/dist/editor-actions/plugin/container.js +351 -0
  434. package/dist/editor-actions/plugin/directive-container.d.ts +13 -0
  435. package/dist/editor-actions/plugin/directive-container.js +31 -0
  436. package/dist/editor-actions/reorder-action.d.ts +17 -0
  437. package/dist/editor-actions/reorder-action.js +104 -0
  438. package/dist/editor-actions/reorder-drag.d.ts +34 -0
  439. package/dist/editor-actions/reorder-drag.js +152 -0
  440. package/dist/editor-actions/replacement-focus.d.ts +27 -0
  441. package/dist/editor-actions/replacement-focus.js +60 -0
  442. package/dist/editor-actions/search-replace.d.ts +6 -0
  443. package/dist/editor-actions/search-replace.js +145 -0
  444. package/dist/editor-actions/table-context.d.ts +34 -0
  445. package/dist/editor-actions/table-context.js +292 -0
  446. package/dist/editor-actions/unwrap-strategies.d.ts +14 -0
  447. package/dist/editor-actions/unwrap-strategies.js +131 -0
  448. package/dist/editor-actions/whole-block-focus-surface.d.ts +51 -0
  449. package/dist/editor-actions/whole-block-focus-surface.js +171 -0
  450. package/dist/editor-events.d.ts +89 -0
  451. package/dist/editor-events.js +96 -0
  452. package/dist/editor-keys.d.ts +197 -0
  453. package/dist/editor-keys.js +40 -0
  454. package/dist/editor-props.d.ts +164 -0
  455. package/dist/editor-props.js +1 -0
  456. package/dist/editor-rects.d.ts +58 -0
  457. package/dist/editor-rects.js +114 -0
  458. package/dist/env.d.ts +12 -0
  459. package/dist/env.js +20 -0
  460. package/dist/index.d.ts +27 -0
  461. package/dist/index.js +19 -0
  462. package/dist/invariants/commit-paths.d.ts +10 -0
  463. package/dist/invariants/commit-paths.js +25 -0
  464. package/dist/invariants/commit-scope.d.ts +9 -0
  465. package/dist/invariants/commit-scope.js +16 -0
  466. package/dist/invariants/context-keys.d.ts +7 -0
  467. package/dist/invariants/context-keys.js +14 -0
  468. package/dist/invariants/descriptor.d.ts +10 -0
  469. package/dist/invariants/descriptor.js +24 -0
  470. package/dist/invariants/inline-transitions.d.ts +23 -0
  471. package/dist/invariants/inline-transitions.js +52 -0
  472. package/dist/invariants/install.d.ts +36 -0
  473. package/dist/invariants/install.js +66 -0
  474. package/dist/invariants/landable-caret.d.ts +12 -0
  475. package/dist/invariants/landable-caret.js +31 -0
  476. package/dist/invariants/marker-css-parity.d.ts +10 -0
  477. package/dist/invariants/marker-css-parity.js +87 -0
  478. package/dist/invariants/node-shape.d.ts +44 -0
  479. package/dist/invariants/node-shape.js +258 -0
  480. package/dist/invariants/registry.d.ts +126 -0
  481. package/dist/invariants/registry.js +349 -0
  482. package/dist/invariants/render-fidelity.d.ts +8 -0
  483. package/dist/invariants/render-fidelity.js +33 -0
  484. package/dist/invariants/selection-endpoints.d.ts +19 -0
  485. package/dist/invariants/selection-endpoints.js +78 -0
  486. package/dist/invariants/single-node-sink.d.ts +9 -0
  487. package/dist/invariants/single-node-sink.js +16 -0
  488. package/dist/invariants/snapshot-integrity.d.ts +17 -0
  489. package/dist/invariants/snapshot-integrity.js +24 -0
  490. package/dist/invariants/split-landing.d.ts +8 -0
  491. package/dist/invariants/split-landing.js +15 -0
  492. package/dist/invariants/structural-descriptor.d.ts +21 -0
  493. package/dist/invariants/structural-descriptor.js +50 -0
  494. package/dist/perf/instruments.d.ts +49 -0
  495. package/dist/perf/instruments.js +154 -0
  496. package/dist/perf/use-mount-gauge.svelte.d.ts +1 -0
  497. package/dist/perf/use-mount-gauge.svelte.js +15 -0
  498. package/dist/plugin.d.ts +102 -0
  499. package/dist/plugin.js +156 -0
  500. package/dist/plugins/admonitions/AdmonitionBlock.svelte +144 -0
  501. package/dist/plugins/admonitions/AdmonitionBlock.svelte.d.ts +11 -0
  502. package/dist/plugins/admonitions/admonition-kind.d.ts +8 -0
  503. package/dist/plugins/admonitions/admonition-kind.js +97 -0
  504. package/dist/plugins/admonitions/convert-document.d.ts +11 -0
  505. package/dist/plugins/admonitions/convert-document.js +39 -0
  506. package/dist/plugins/admonitions/gh-alert.d.ts +13 -0
  507. package/dist/plugins/admonitions/gh-alert.js +83 -0
  508. package/dist/plugins/admonitions/github-alert-kind.d.ts +12 -0
  509. package/dist/plugins/admonitions/github-alert-kind.js +125 -0
  510. package/dist/plugins/admonitions/index.d.ts +6 -0
  511. package/dist/plugins/admonitions/index.js +8 -0
  512. package/dist/plugins/admonitions/kinds.d.ts +26 -0
  513. package/dist/plugins/admonitions/kinds.js +18 -0
  514. package/dist/plugins/admonitions/register.d.ts +7 -0
  515. package/dist/plugins/admonitions/register.js +12 -0
  516. package/dist/plugins/details/DetailsBlock.svelte +129 -0
  517. package/dist/plugins/details/DetailsBlock.svelte.d.ts +11 -0
  518. package/dist/plugins/details/details-disclosure.svelte.d.ts +17 -0
  519. package/dist/plugins/details/details-disclosure.svelte.js +24 -0
  520. package/dist/plugins/details/details-kind.d.ts +25 -0
  521. package/dist/plugins/details/details-kind.js +237 -0
  522. package/dist/plugins/details/index.d.ts +2 -0
  523. package/dist/plugins/details/index.js +2 -0
  524. package/dist/plugins/details/register.d.ts +6 -0
  525. package/dist/plugins/details/register.js +15 -0
  526. package/dist/plugins/emoji/emoji-plugin.d.ts +2 -0
  527. package/dist/plugins/emoji/emoji-plugin.js +10 -0
  528. package/dist/plugins/emoji/emoji-recognizer.d.ts +18 -0
  529. package/dist/plugins/emoji/emoji-recognizer.js +63 -0
  530. package/dist/plugins/emoji/emoji-table.d.ts +1 -0
  531. package/dist/plugins/emoji/emoji-table.js +1919 -0
  532. package/dist/plugins/emoji/index.d.ts +3 -0
  533. package/dist/plugins/emoji/index.js +4 -0
  534. package/dist/plugins/footnotes/FootnoteDefinition.svelte +103 -0
  535. package/dist/plugins/footnotes/FootnoteDefinition.svelte.d.ts +13 -0
  536. package/dist/plugins/footnotes/FootnoteReference.svelte +50 -0
  537. package/dist/plugins/footnotes/FootnoteReference.svelte.d.ts +4 -0
  538. package/dist/plugins/footnotes/constants.d.ts +2 -0
  539. package/dist/plugins/footnotes/constants.js +4 -0
  540. package/dist/plugins/footnotes/footnote-definition.d.ts +14 -0
  541. package/dist/plugins/footnotes/footnote-definition.js +147 -0
  542. package/dist/plugins/footnotes/footnote-lookup.d.ts +9 -0
  543. package/dist/plugins/footnotes/footnote-lookup.js +33 -0
  544. package/dist/plugins/footnotes/footnote-numbering.d.ts +23 -0
  545. package/dist/plugins/footnotes/footnote-numbering.js +78 -0
  546. package/dist/plugins/footnotes/footnote-reference.d.ts +7 -0
  547. package/dist/plugins/footnotes/footnote-reference.js +54 -0
  548. package/dist/plugins/footnotes/footnotes-plugin.d.ts +7 -0
  549. package/dist/plugins/footnotes/footnotes-plugin.js +17 -0
  550. package/dist/plugins/footnotes/index.d.ts +5 -0
  551. package/dist/plugins/footnotes/index.js +6 -0
  552. package/dist/plugins/highlight-occurrences/highlight-occurrences-plugin.d.ts +17 -0
  553. package/dist/plugins/highlight-occurrences/highlight-occurrences-plugin.js +31 -0
  554. package/dist/plugins/highlight-occurrences/index.d.ts +1 -0
  555. package/dist/plugins/highlight-occurrences/index.js +1 -0
  556. package/dist/plugins/highlight-occurrences/occurrence-source.d.ts +26 -0
  557. package/dist/plugins/highlight-occurrences/occurrence-source.js +54 -0
  558. package/dist/plugins/highlight-occurrences/occurrences.d.ts +33 -0
  559. package/dist/plugins/highlight-occurrences/occurrences.js +108 -0
  560. package/dist/plugins/latex/BlockMath.svelte +119 -0
  561. package/dist/plugins/latex/BlockMath.svelte.d.ts +21 -0
  562. package/dist/plugins/latex/MathInline.svelte +28 -0
  563. package/dist/plugins/latex/MathInline.svelte.d.ts +4 -0
  564. package/dist/plugins/latex/index.d.ts +3 -0
  565. package/dist/plugins/latex/index.js +4 -0
  566. package/dist/plugins/latex/latex-kind.d.ts +17 -0
  567. package/dist/plugins/latex/latex-kind.js +224 -0
  568. package/dist/plugins/latex/math-completion.d.ts +10 -0
  569. package/dist/plugins/latex/math-completion.js +19 -0
  570. package/dist/plugins/latex/math-renderer.d.ts +26 -0
  571. package/dist/plugins/latex/math-renderer.js +42 -0
  572. package/dist/plugins/latex/register.d.ts +10 -0
  573. package/dist/plugins/latex/register.js +23 -0
  574. package/dist/plugins/latex/renderer.d.ts +13 -0
  575. package/dist/plugins/latex/renderer.js +34 -0
  576. package/dist/plugins/mermaid/MermaidBlock.svelte +572 -0
  577. package/dist/plugins/mermaid/MermaidBlock.svelte.d.ts +11 -0
  578. package/dist/plugins/mermaid/index.d.ts +3 -0
  579. package/dist/plugins/mermaid/index.js +3 -0
  580. package/dist/plugins/mermaid/mermaid-kind.d.ts +38 -0
  581. package/dist/plugins/mermaid/mermaid-kind.js +176 -0
  582. package/dist/plugins/mermaid/mermaid-renderer.d.ts +28 -0
  583. package/dist/plugins/mermaid/mermaid-renderer.js +35 -0
  584. package/dist/plugins/mermaid/register.d.ts +10 -0
  585. package/dist/plugins/mermaid/register.js +20 -0
  586. package/dist/plugins/mermaid/renderer.d.ts +11 -0
  587. package/dist/plugins/mermaid/renderer.js +53 -0
  588. package/dist/plugins/parrot/ParrotBlock.svelte +342 -0
  589. package/dist/plugins/parrot/ParrotBlock.svelte.d.ts +21 -0
  590. package/dist/plugins/parrot/index.d.ts +1 -0
  591. package/dist/plugins/parrot/index.js +2 -0
  592. package/dist/plugins/parrot/parrot-plugin.d.ts +3 -0
  593. package/dist/plugins/parrot/parrot-plugin.js +49 -0
  594. package/dist/plugins/toc/TocBlock.svelte +218 -0
  595. package/dist/plugins/toc/TocBlock.svelte.d.ts +24 -0
  596. package/dist/plugins/toc/heading-outline.d.ts +28 -0
  597. package/dist/plugins/toc/heading-outline.js +65 -0
  598. package/dist/plugins/toc/index.d.ts +2 -0
  599. package/dist/plugins/toc/index.js +2 -0
  600. package/dist/plugins/toc/navigation-queue.d.ts +12 -0
  601. package/dist/plugins/toc/navigation-queue.js +21 -0
  602. package/dist/plugins/toc/toc-plugin.d.ts +16 -0
  603. package/dist/plugins/toc/toc-plugin.js +71 -0
  604. package/dist/presentation-mode.d.ts +32 -0
  605. package/dist/presentation-mode.js +50 -0
  606. package/dist/reactivity/block-list-state.svelte.d.ts +22 -0
  607. package/dist/reactivity/block-list-state.svelte.js +46 -0
  608. package/dist/reactivity/block-window.svelte.d.ts +41 -0
  609. package/dist/reactivity/block-window.svelte.js +93 -0
  610. package/dist/reactivity/content-version.svelte.d.ts +14 -0
  611. package/dist/reactivity/content-version.svelte.js +16 -0
  612. package/dist/reactivity/list-windowing.svelte.d.ts +100 -0
  613. package/dist/reactivity/list-windowing.svelte.js +402 -0
  614. package/dist/reactivity/measure-batch.d.ts +15 -0
  615. package/dist/reactivity/measure-batch.js +18 -0
  616. package/dist/reactivity/publish-ref.svelte.d.ts +54 -0
  617. package/dist/reactivity/publish-ref.svelte.js +128 -0
  618. package/dist/reactivity/scope-geometry.d.ts +18 -0
  619. package/dist/reactivity/scope-geometry.js +29 -0
  620. package/dist/reactivity/state-registry.d.ts +10 -0
  621. package/dist/reactivity/state-registry.js +44 -0
  622. package/dist/reactivity/use-container-windowing.svelte.d.ts +35 -0
  623. package/dist/reactivity/use-container-windowing.svelte.js +95 -0
  624. package/dist/reactivity/window-slice.d.ts +11 -0
  625. package/dist/reactivity/window-slice.js +9 -0
  626. package/dist/scan-index.d.ts +11 -0
  627. package/dist/scan-index.js +27 -0
  628. package/dist/schema/block-commands.d.ts +105 -0
  629. package/dist/schema/block-commands.js +179 -0
  630. package/dist/schema/block-completions.d.ts +33 -0
  631. package/dist/schema/block-completions.js +49 -0
  632. package/dist/schema/block-component-registry.d.ts +33 -0
  633. package/dist/schema/block-component-registry.js +33 -0
  634. package/dist/schema/block-kind-descriptor.d.ts +281 -0
  635. package/dist/schema/block-kind-descriptor.js +187 -0
  636. package/dist/schema/block-openers.d.ts +94 -0
  637. package/dist/schema/block-openers.js +150 -0
  638. package/dist/schema/built-in-descriptors.d.ts +8 -0
  639. package/dist/schema/built-in-descriptors.js +560 -0
  640. package/dist/schema/child-spans.d.ts +25 -0
  641. package/dist/schema/child-spans.js +161 -0
  642. package/dist/schema/closure.d.ts +39 -0
  643. package/dist/schema/closure.js +55 -0
  644. package/dist/schema/command-id.d.ts +20 -0
  645. package/dist/schema/command-id.js +42 -0
  646. package/dist/schema/commands.d.ts +147 -0
  647. package/dist/schema/commands.js +294 -0
  648. package/dist/schema/container-raw.d.ts +21 -0
  649. package/dist/schema/container-raw.js +43 -0
  650. package/dist/schema/container-rebuilders.d.ts +32 -0
  651. package/dist/schema/container-rebuilders.js +95 -0
  652. package/dist/schema/define-plugin-block.d.ts +15 -0
  653. package/dist/schema/define-plugin-block.js +18 -0
  654. package/dist/schema/fenced-code-raw.d.ts +43 -0
  655. package/dist/schema/fenced-code-raw.js +220 -0
  656. package/dist/schema/global-commands.d.ts +11 -0
  657. package/dist/schema/global-commands.js +40 -0
  658. package/dist/schema/inline-construct-policy.d.ts +131 -0
  659. package/dist/schema/inline-construct-policy.js +96 -0
  660. package/dist/schema/keybinding-overrides.d.ts +39 -0
  661. package/dist/schema/keybinding-overrides.js +43 -0
  662. package/dist/schema/keybindings.d.ts +36 -0
  663. package/dist/schema/keybindings.js +75 -0
  664. package/dist/schema/merge-rules.d.ts +28 -0
  665. package/dist/schema/merge-rules.js +57 -0
  666. package/dist/schema/opener-priorities.d.ts +16 -0
  667. package/dist/schema/opener-priorities.js +16 -0
  668. package/dist/schema/operations.d.ts +110 -0
  669. package/dist/schema/operations.js +6 -0
  670. package/dist/schema/plugin-activation.d.ts +13 -0
  671. package/dist/schema/plugin-activation.js +18 -0
  672. package/dist/schema/plugin-editor-context.d.ts +33 -0
  673. package/dist/schema/plugin-editor-context.js +65 -0
  674. package/dist/schema/plugin-install.d.ts +58 -0
  675. package/dist/schema/plugin-install.js +132 -0
  676. package/dist/schema/plugin-kind.d.ts +21 -0
  677. package/dist/schema/plugin-kind.js +86 -0
  678. package/dist/schema/plugin-name.d.ts +1 -0
  679. package/dist/schema/plugin-name.js +7 -0
  680. package/dist/schema/register-once.d.ts +9 -0
  681. package/dist/schema/register-once.js +35 -0
  682. package/dist/schema/registration-checks.d.ts +32 -0
  683. package/dist/schema/registration-checks.js +122 -0
  684. package/dist/schema/registration-pending.d.ts +28 -0
  685. package/dist/schema/registration-pending.js +48 -0
  686. package/dist/schema/registry-reset.d.ts +7 -0
  687. package/dist/schema/registry-reset.js +30 -0
  688. package/dist/schema/registry-view.d.ts +30 -0
  689. package/dist/schema/registry-view.js +39 -0
  690. package/dist/schema/reserved-chords.d.ts +35 -0
  691. package/dist/schema/reserved-chords.js +313 -0
  692. package/dist/schema/reserved-chrome.d.ts +23 -0
  693. package/dist/schema/reserved-chrome.js +33 -0
  694. package/dist/schema/table-cell-raw.d.ts +14 -0
  695. package/dist/schema/table-cell-raw.js +30 -0
  696. package/dist/schema/whole-block-unit.d.ts +8 -0
  697. package/dist/schema/whole-block-unit.js +12 -0
  698. package/dist/search/document-scan.d.ts +22 -0
  699. package/dist/search/document-scan.js +39 -0
  700. package/dist/search/matcher.d.ts +31 -0
  701. package/dist/search/matcher.js +70 -0
  702. package/dist/search/regex-executor.d.ts +41 -0
  703. package/dist/search/regex-executor.js +165 -0
  704. package/dist/search/replace.d.ts +15 -0
  705. package/dist/search/replace.js +29 -0
  706. package/dist/search/search-state.svelte.d.ts +59 -0
  707. package/dist/search/search-state.svelte.js +231 -0
  708. package/dist/selection/autoscroll.d.ts +26 -0
  709. package/dist/selection/autoscroll.js +91 -0
  710. package/dist/selection/block-hit-test.d.ts +37 -0
  711. package/dist/selection/block-hit-test.js +59 -0
  712. package/dist/selection/caret-doors.d.ts +20 -0
  713. package/dist/selection/caret-doors.js +44 -0
  714. package/dist/selection/caret-restore.d.ts +15 -0
  715. package/dist/selection/caret-restore.js +32 -0
  716. package/dist/selection/char-endpoint-snap.d.ts +15 -0
  717. package/dist/selection/char-endpoint-snap.js +39 -0
  718. package/dist/selection/clipboard-text.d.ts +13 -0
  719. package/dist/selection/clipboard-text.js +314 -0
  720. package/dist/selection/cross-block/clipboard.d.ts +14 -0
  721. package/dist/selection/cross-block/clipboard.js +20 -0
  722. package/dist/selection/cross-block/dispatch.d.ts +78 -0
  723. package/dist/selection/cross-block/dispatch.js +57 -0
  724. package/dist/selection/cross-block/format-range.d.ts +38 -0
  725. package/dist/selection/cross-block/format-range.js +193 -0
  726. package/dist/selection/cross-block/format-toggle.d.ts +27 -0
  727. package/dist/selection/cross-block/format-toggle.js +109 -0
  728. package/dist/selection/cross-block/keydown.d.ts +11 -0
  729. package/dist/selection/cross-block/keydown.js +339 -0
  730. package/dist/selection/cross-block/ops.d.ts +56 -0
  731. package/dist/selection/cross-block/ops.js +210 -0
  732. package/dist/selection/cross-block/paste.d.ts +8 -0
  733. package/dist/selection/cross-block/paste.js +156 -0
  734. package/dist/selection/cross-block/pointer.d.ts +19 -0
  735. package/dist/selection/cross-block/pointer.js +80 -0
  736. package/dist/selection/cross-block/type-replace.d.ts +10 -0
  737. package/dist/selection/cross-block/type-replace.js +129 -0
  738. package/dist/selection/dead-space-caret.d.ts +39 -0
  739. package/dist/selection/dead-space-caret.js +173 -0
  740. package/dist/selection/drag-pointer.d.ts +22 -0
  741. package/dist/selection/drag-pointer.js +89 -0
  742. package/dist/selection/gap-caret.d.ts +47 -0
  743. package/dist/selection/gap-caret.js +72 -0
  744. package/dist/selection/keyboard-extend.d.ts +43 -0
  745. package/dist/selection/keyboard-extend.js +257 -0
  746. package/dist/selection/native-bridge.d.ts +47 -0
  747. package/dist/selection/native-bridge.js +204 -0
  748. package/dist/selection/nearest-block.d.ts +43 -0
  749. package/dist/selection/nearest-block.js +73 -0
  750. package/dist/selection/path-lookup.d.ts +32 -0
  751. package/dist/selection/path-lookup.js +132 -0
  752. package/dist/selection/path-math.d.ts +35 -0
  753. package/dist/selection/path-math.js +90 -0
  754. package/dist/selection/pointer-session.d.ts +43 -0
  755. package/dist/selection/pointer-session.js +111 -0
  756. package/dist/selection/primitives.d.ts +75 -0
  757. package/dist/selection/primitives.js +91 -0
  758. package/dist/selection/range-delete-ceremony.d.ts +85 -0
  759. package/dist/selection/range-delete-ceremony.js +197 -0
  760. package/dist/selection/range-delete-chrome.d.ts +39 -0
  761. package/dist/selection/range-delete-chrome.js +105 -0
  762. package/dist/selection/range-delete-table-coverage.d.ts +28 -0
  763. package/dist/selection/range-delete-table-coverage.js +168 -0
  764. package/dist/selection/range-delete-table.d.ts +16 -0
  765. package/dist/selection/range-delete-table.js +347 -0
  766. package/dist/selection/range-delete.d.ts +33 -0
  767. package/dist/selection/range-delete.js +121 -0
  768. package/dist/selection/selection-description.d.ts +7 -0
  769. package/dist/selection/selection-description.js +18 -0
  770. package/dist/selection/selection-restore.d.ts +46 -0
  771. package/dist/selection/selection-restore.js +66 -0
  772. package/dist/selection/selection-state.svelte.d.ts +72 -0
  773. package/dist/selection/selection-state.svelte.js +247 -0
  774. package/dist/selection/shared-keydown.d.ts +61 -0
  775. package/dist/selection/shared-keydown.js +150 -0
  776. package/dist/selection/table-endpoint-snap.d.ts +55 -0
  777. package/dist/selection/table-endpoint-snap.js +143 -0
  778. package/dist/selection/table-rect-extend.d.ts +23 -0
  779. package/dist/selection/table-rect-extend.js +46 -0
  780. package/dist/selection/widget-range-paint.d.ts +12 -0
  781. package/dist/selection/widget-range-paint.js +44 -0
  782. package/dist/styles/editor-theme.css +151 -0
  783. package/dist/styles/editor.css +585 -0
  784. package/dist/testing/conformance-core.d.ts +45 -0
  785. package/dist/testing/conformance-core.js +105 -0
  786. package/dist/testing/container-conformance.d.ts +137 -0
  787. package/dist/testing/container-conformance.js +533 -0
  788. package/dist/testing/headless-actions.d.ts +37 -0
  789. package/dist/testing/headless-actions.js +118 -0
  790. package/dist/testing/inline-conformance.d.ts +50 -0
  791. package/dist/testing/inline-conformance.js +442 -0
  792. package/dist/testing/kind-conformance.d.ts +54 -0
  793. package/dist/testing/kind-conformance.js +325 -0
  794. package/dist/testing/mount-dom-stubs.d.ts +8 -0
  795. package/dist/testing/mount-dom-stubs.js +19 -0
  796. package/dist/testing/parse-convergence.d.ts +14 -0
  797. package/dist/testing/parse-convergence.js +81 -0
  798. package/dist/testing.d.ts +20 -0
  799. package/dist/testing.js +61 -0
  800. package/dist/tree-operations/blockquote.d.ts +18 -0
  801. package/dist/tree-operations/blockquote.js +59 -0
  802. package/dist/tree-operations/children.d.ts +17 -0
  803. package/dist/tree-operations/children.js +56 -0
  804. package/dist/tree-operations/cleanup.d.ts +10 -0
  805. package/dist/tree-operations/cleanup.js +25 -0
  806. package/dist/tree-operations/clone.d.ts +5 -0
  807. package/dist/tree-operations/clone.js +43 -0
  808. package/dist/tree-operations/container-lift.d.ts +9 -0
  809. package/dist/tree-operations/container-lift.js +29 -0
  810. package/dist/tree-operations/index.d.ts +16 -0
  811. package/dist/tree-operations/index.js +14 -0
  812. package/dist/tree-operations/list/empty-check.d.ts +7 -0
  813. package/dist/tree-operations/list/empty-check.js +19 -0
  814. package/dist/tree-operations/list/exit-replacement.d.ts +13 -0
  815. package/dist/tree-operations/list/exit-replacement.js +49 -0
  816. package/dist/tree-operations/list/item-partition.d.ts +13 -0
  817. package/dist/tree-operations/list/item-partition.js +33 -0
  818. package/dist/tree-operations/list/list-builders.d.ts +44 -0
  819. package/dist/tree-operations/list/list-builders.js +129 -0
  820. package/dist/tree-operations/list/ordered-markers.d.ts +36 -0
  821. package/dist/tree-operations/list/ordered-markers.js +114 -0
  822. package/dist/tree-operations/list/reconcile-task.d.ts +12 -0
  823. package/dist/tree-operations/list/reconcile-task.js +47 -0
  824. package/dist/tree-operations/list/sublist-separator.d.ts +13 -0
  825. package/dist/tree-operations/list/sublist-separator.js +34 -0
  826. package/dist/tree-operations/list/terminator.d.ts +17 -0
  827. package/dist/tree-operations/list/terminator.js +60 -0
  828. package/dist/tree-operations/list/unwrap-merge.d.ts +29 -0
  829. package/dist/tree-operations/list/unwrap-merge.js +202 -0
  830. package/dist/tree-operations/node-ops.d.ts +296 -0
  831. package/dist/tree-operations/node-ops.js +1428 -0
  832. package/dist/tree-operations/parse-block.d.ts +3 -0
  833. package/dist/tree-operations/parse-block.js +8 -0
  834. package/dist/tree-operations/paste/apply.d.ts +12 -0
  835. package/dist/tree-operations/paste/apply.js +75 -0
  836. package/dist/tree-operations/paste/body-write.d.ts +19 -0
  837. package/dist/tree-operations/paste/body-write.js +53 -0
  838. package/dist/tree-operations/paste/container-match.d.ts +32 -0
  839. package/dist/tree-operations/paste/container-match.js +238 -0
  840. package/dist/tree-operations/paste/container-paste.d.ts +10 -0
  841. package/dist/tree-operations/paste/container-paste.js +27 -0
  842. package/dist/tree-operations/paste/dispatch.d.ts +61 -0
  843. package/dist/tree-operations/paste/dispatch.js +138 -0
  844. package/dist/tree-operations/paste/find-enclosing-list.d.ts +8 -0
  845. package/dist/tree-operations/paste/find-enclosing-list.js +30 -0
  846. package/dist/tree-operations/paste/focus-target.d.ts +27 -0
  847. package/dist/tree-operations/paste/focus-target.js +40 -0
  848. package/dist/tree-operations/paste/hooks.d.ts +17 -0
  849. package/dist/tree-operations/paste/hooks.js +80 -0
  850. package/dist/tree-operations/paste/list-absorb.d.ts +29 -0
  851. package/dist/tree-operations/paste/list-absorb.js +106 -0
  852. package/dist/tree-operations/paste/list-break-out.d.ts +42 -0
  853. package/dist/tree-operations/paste/list-break-out.js +136 -0
  854. package/dist/tree-operations/paste/parent-scope.d.ts +17 -0
  855. package/dist/tree-operations/paste/parent-scope.js +35 -0
  856. package/dist/tree-operations/paste/paste-deps.d.ts +20 -0
  857. package/dist/tree-operations/paste/paste-deps.js +6 -0
  858. package/dist/tree-operations/paste/paste-replacement.d.ts +8 -0
  859. package/dist/tree-operations/paste/paste-replacement.js +60 -0
  860. package/dist/tree-operations/paste/paste-transforms.d.ts +25 -0
  861. package/dist/tree-operations/paste/paste-transforms.js +72 -0
  862. package/dist/tree-operations/paste/replace-block-at-parent.d.ts +29 -0
  863. package/dist/tree-operations/paste/replace-block-at-parent.js +75 -0
  864. package/dist/tree-operations/paste/strategy.d.ts +9 -0
  865. package/dist/tree-operations/paste/strategy.js +20 -0
  866. package/dist/tree-operations/paste/table-slice.d.ts +10 -0
  867. package/dist/tree-operations/paste/table-slice.js +39 -0
  868. package/dist/tree-operations/paste-surfaces.d.ts +61 -0
  869. package/dist/tree-operations/paste-surfaces.js +15 -0
  870. package/dist/tree-operations/path-mutate.d.ts +12 -0
  871. package/dist/tree-operations/path-mutate.js +20 -0
  872. package/dist/tree-operations/reorder-unit.d.ts +17 -0
  873. package/dist/tree-operations/reorder-unit.js +37 -0
  874. package/dist/tree-operations/reorder.d.ts +13 -0
  875. package/dist/tree-operations/reorder.js +57 -0
  876. package/dist/tree-operations/sharing.d.ts +18 -0
  877. package/dist/tree-operations/sharing.js +14 -0
  878. package/dist/tree-operations/splice-many.d.ts +9 -0
  879. package/dist/tree-operations/splice-many.js +22 -0
  880. package/dist/tree-operations/structural-change.d.ts +65 -0
  881. package/dist/tree-operations/structural-change.js +117 -0
  882. package/dist/tree-operations/sub-table-copy.d.ts +6 -0
  883. package/dist/tree-operations/sub-table-copy.js +43 -0
  884. package/dist/tree-operations/table-mutations.d.ts +17 -0
  885. package/dist/tree-operations/table-mutations.js +101 -0
  886. package/dist/tree-operations/unshare.d.ts +101 -0
  887. package/dist/tree-operations/unshare.js +248 -0
  888. package/dist/undo/manager.d.ts +2 -0
  889. package/dist/undo/manager.js +50 -0
  890. package/dist/undo/types.d.ts +44 -0
  891. package/dist/undo/types.js +7 -0
  892. package/docs/guide/consumer-guide.md +1098 -0
  893. package/docs/guide/directives.md +223 -0
  894. package/docs/guide/plugin-api.md +329 -0
  895. package/docs/guide/plugin-guide/conspiracy.gif +0 -0
  896. package/docs/guide/plugin-guide/parrot-frames.md +209 -0
  897. package/docs/guide/plugin-guide/parrot.gif +0 -0
  898. package/docs/guide/plugin-guide.md +1693 -0
  899. package/docs/guide/plugin-testing.md +463 -0
  900. package/package.json +238 -0
@@ -0,0 +1,1012 @@
1
+ <script lang="ts">
2
+ import { getContext, tick, untrack } from 'svelte';
3
+ import { CURSOR_START, type AmbientPrefix, type BlockComponent } from '../../../block-component';
4
+ import type { DocumentView, NodeView } from '../../../core/node-views';
5
+ import type { EditorRects } from '../../../editor-rects';
6
+ import { enterLinkCardAtCaret, linkCardTargetAt } from '../../link-card/link-card-entry';
7
+ import {
8
+ EDITOR_DOC_KEY,
9
+ EDITOR_POLICIES_KEY,
10
+ EDITOR_SERVICES_KEY,
11
+ LIST_CONTEXT_KEY,
12
+ type EditorDoc,
13
+ type EditorPolicies,
14
+ type EditorServices
15
+ } from '../../../editor-keys';
16
+ import type { IndexedDecoration } from '../../../decorations/buckets';
17
+ import type { ReplaceDecoration, WidgetDecoration } from '../../../decorations/types';
18
+ import { getContentRange, isProseKind } from '../../../core/inline';
19
+ import { devWarn } from '../../../dev-warn';
20
+ import { resolvedInlineContent } from '../../../core/inline/inline-cache';
21
+ import type { LinkReferenceResolver } from '../../../core/inline/link-reference-resolver';
22
+ import { isInlineWidget } from '../../../core/inline/inline-widgets';
23
+ import { trimTrailingLineEnding, trailingLineEnding } from '../../../core/lines';
24
+ import { hasSelection as hasSelectionHelper } from '../../../cursor/content-offsets';
25
+ import { FALLBACK_CONTENT_WIDTH } from '../../../cursor/typography-estimates';
26
+ import {
27
+ createInlineFormatActiveMemo,
28
+ toggleInlineFormat
29
+ } from '../../../core/inline/format-toggle';
30
+ import {
31
+ inlineMarkForCommand,
32
+ type InlineMarkKind
33
+ } from '../../../schema/inline-construct-policy';
34
+ import {
35
+ cycleHeading,
36
+ demoteToParagraph,
37
+ insertHardBreak,
38
+ insertLiteralTab,
39
+ type TextEditResult
40
+ } from './text-keydown';
41
+ import { tryGetBlockKindDescriptor } from '../../../schema/block-kind-descriptor';
42
+ import { blockNodeAt } from '../../../tree-operations/node-ops';
43
+ import { createTextClipboard } from './text-clipboard';
44
+ import { createTextRender } from './text-render';
45
+ import { createWidgetInteraction } from './widget-interaction';
46
+ import { createEdgePolicyDispatch } from './edge-policy-dispatch';
47
+ import { hidesStructuralSuffix } from './hidden-suffix';
48
+ import { applyLiveRangeEdit, resolveSelectionEdit } from './live-selection-edit';
49
+ import { createCompositionSeat } from './composition-seat';
50
+ import { createConstructReveal } from './construct-reveal';
51
+ import { assertInvariant } from '../../../assert';
52
+ import { paintsFocusedMarkers } from '../../../presentation-mode';
53
+ import { widgetElByStart } from './widget-adjacency';
54
+ import {
55
+ caretLandableBounds,
56
+ handleSharedKeydown,
57
+ handleSharedBeforeInput
58
+ } from '../../../selection/shared-keydown';
59
+ import { createEditableSurface, consumePendingRestore } from '../editable-surface';
60
+ import { wireSurfaceContexts, useParkFocusOnUnmount } from '../surface-wiring.svelte';
61
+ import {
62
+ domTextOffsetAtNode,
63
+ landableStartAbutsIsland,
64
+ rawTextOfNode,
65
+ createRangeAtDomTextOffsets,
66
+ revealsNoMarkers,
67
+ screenVisibilityOf,
68
+ selectionFocusWalkOffset
69
+ } from '../../../cursor/widget-offset';
70
+ import { ambientSpanOf } from '../../../ambient/ambient-dom';
71
+ import {
72
+ asRawOffset,
73
+ toClampedRawOffset,
74
+ toDomTextOffset
75
+ } from '../../../cursor/coordinate-spaces';
76
+ import { createAmbientCursorIO } from '../../../ambient/ambient-cursor';
77
+ import { type CommandId } from '../../../schema/commands';
78
+ import { reorderRunCommand } from '../../../editor-actions/reorder-action';
79
+ import {
80
+ perfEnabled,
81
+ recordBlockRender,
82
+ markKeystrokeStart,
83
+ markKeystrokeSettle
84
+ } from '../../../perf/instruments';
85
+ import {
86
+ tracePendingCursorSet,
87
+ tracePendingCursorConsume
88
+ } from '../../../debug/interaction-trace';
89
+
90
+ let {
91
+ node,
92
+ index,
93
+ myPath = [],
94
+ blockClass = 'paragraph-block',
95
+ ambientPrefix = '',
96
+ rects
97
+ }: {
98
+ node: NodeView;
99
+ index: number;
100
+ myPath?: number[];
101
+ blockClass?: string;
102
+ ambientPrefix?: AmbientPrefix;
103
+ // Accepted for BlockComponentProps parity: this surface reads the doc from the
104
+ // document facet, and binding would shadow the global `document`.
105
+ document?: DocumentView;
106
+ // The surface itself navigates through the editor; this is forwarded to inline
107
+ // widgets whose own gesture jumps elsewhere in the document.
108
+ rects?: EditorRects;
109
+ } = $props();
110
+
111
+ const ambientPrefixText = $derived(
112
+ typeof ambientPrefix === 'string' ? ambientPrefix : ambientPrefix.text
113
+ );
114
+
115
+ const wiring = wireSurfaceContexts();
116
+ const {
117
+ blockEdit,
118
+ focusActions,
119
+ controller,
120
+ pasteCoordinator,
121
+ stickyColumn,
122
+ edgeAffinity,
123
+ selection,
124
+ getDoc,
125
+ getEditorRoot,
126
+ grammar,
127
+ activePlugins,
128
+ events: editorEvents,
129
+ linkRef
130
+ } = wiring.deps;
131
+ // Present inside a list item, whose ListItemBlock owns Tab-as-indent.
132
+ const listContext = getContext(LIST_CONTEXT_KEY);
133
+ const {
134
+ reorder,
135
+ pendingMarks,
136
+ widgetSelection,
137
+ linkCard,
138
+ decorations: decorationEngine
139
+ } = getContext<EditorServices>(EDITOR_SERVICES_KEY);
140
+ const {
141
+ resolveImageUrl,
142
+ resolveLinkUrl,
143
+ imageLoadPolicy,
144
+ brokenImageUrls: brokenUrlCache,
145
+ presentationMode: getPresentationMode,
146
+ theme: getTheme,
147
+ onPasteImage
148
+ } = getContext<EditorPolicies>(EDITOR_POLICIES_KEY);
149
+ const { contentVersion: getContentVersion } = getContext<EditorDoc>(EDITOR_DOC_KEY);
150
+ const presentationMode = $derived(getPresentationMode?.() ?? 'source');
151
+ const readOnly = $derived(presentationMode === 'reading');
152
+
153
+ /** The card's query for this surface, the cell's shape: `range` is the live selection at both
154
+ * the chord's arm and the pressed read, since prose owns no wrap policy of its own. */
155
+ const linkCardQuery = (contentEl: HTMLElement, range: { start: number; end: number } | null) => ({
156
+ contentEl,
157
+ block: node,
158
+ path: myPath,
159
+ linkRef,
160
+ mode: presentationMode,
161
+ selection: range,
162
+ crossBlockRange: selection.isCrossBlock
163
+ });
164
+ const enterLinkCard = () => {
165
+ if (el) {
166
+ enterLinkCardAtCaret({
167
+ ...linkCardQuery(el, cursor.getRawSelection()),
168
+ card: linkCard
169
+ });
170
+ }
171
+ };
172
+ // A constant fallback keeps an empty island set out of the render key.
173
+ const NO_ISLANDS: IndexedDecoration<WidgetDecoration | ReplaceDecoration>[] = [];
174
+ let el: HTMLDivElement | undefined = $state();
175
+ let composing = $state(false);
176
+ // A revealed widget source is ephemeral DOM, so onInput and IME compositionend skip
177
+ // the per-keystroke CST commit and the block commits once on reveal exit.
178
+ let revealing = $state(false);
179
+ /** Cursor offset to restore after the next $effect render. Null = don't touch cursor. */
180
+ let pendingCursorOffset = $state<number | null>(null);
181
+ // Captured before each edit; keydown fires before the DOM changes.
182
+ let preEditOffset = 0;
183
+ // Survives the click→keydown gap when Chromium clears the caret at CE=false-adjacent
184
+ // positions. Reactive so the snap-caret overlay sees changes.
185
+ let lastSnapTargetOffset = $state<number | null>(null);
186
+
187
+ // One funnel for every pending-cursor write, tagged so the interaction trace names
188
+ // which gesture set the restore; the render effect owns the consume half.
189
+ function setPendingCursorOffset(offset: number | null, source: string): void {
190
+ tracePendingCursorSet(source, offset);
191
+ pendingCursorOffset = offset;
192
+ }
193
+
194
+ const ambientLength = $derived(ambientPrefixText.length);
195
+
196
+ const cursor = createAmbientCursorIO({
197
+ getEl: () => el ?? null,
198
+ getAmbientLength: () => ambientLength,
199
+ getSnapTarget: () => lastSnapTargetOffset
200
+ });
201
+
202
+ const editableSurface = createEditableSurface({
203
+ ...wiring.deps,
204
+ getEl: () => el ?? null,
205
+ getAmbientLength: () => ambientLength,
206
+ isInputSuppressed: () => revealing,
207
+ backend: {
208
+ getRaw: () => cursor.getRaw(),
209
+ setRaw: (offset) => cursor.setRaw(offset),
210
+ buildRange: (start, end) =>
211
+ createRangeAtDomTextOffsets(
212
+ el!,
213
+ toDomTextOffset(start, ambientLength),
214
+ toDomTextOffset(end, ambientLength)
215
+ )
216
+ },
217
+ getMyPath: () => myPath,
218
+ getIndex: () => index,
219
+ getComposing: () => composing,
220
+ setComposing: (value) => {
221
+ composing = value;
222
+ },
223
+ getPreEditOffset: () => preEditOffset,
224
+ setPreEditOffset: (offset) => {
225
+ preEditOffset = offset;
226
+ },
227
+ setPendingCursor: (offset) => setPendingCursorOffset(offset, 'surface'),
228
+ getPresentationMode: () => presentationMode,
229
+ getFocusOffset: () => (el ? selectionFocusWalkOffset(el, ambientLength) : null),
230
+ getTextLen: () => liveDisplayLength(),
231
+ readText: () => readRawText(),
232
+ relocateComposedText: (after, composedAt) => compositionSeat.relocate(after, composedAt),
233
+ commitInput: (text, preEdit, saved) => {
234
+ const committed = text + trailingLineEnding(node.raw);
235
+ void blockEdit.updateBlockContent(index, committed, preEdit, saved);
236
+ // An enclosing container may rewrite these bytes on the way in, so the caret
237
+ // restore reads the image of the write, not the offset the keystroke produced.
238
+ return blockEdit.mapCommittedOffset?.(committed, saved);
239
+ },
240
+ inputPrelude: () => {
241
+ markKeystrokeStart();
242
+ lastSnapTargetOffset = null;
243
+ }
244
+ });
245
+
246
+ const crossBlock = editableSurface.crossBlock;
247
+ const sharedCtx = editableSurface.sharedCtx;
248
+
249
+ const widgetInteraction = createWidgetInteraction({
250
+ get node() {
251
+ return node;
252
+ },
253
+ get index() {
254
+ return index;
255
+ },
256
+ get myPath() {
257
+ return myPath;
258
+ },
259
+ getEl: () => el ?? null,
260
+ getAmbientLength: () => ambientLength,
261
+ getEditorContentWidth: () => getEditorRoot()?.clientWidth ?? FALLBACK_CONTENT_WIDTH,
262
+ cursor,
263
+ widgetSelection,
264
+ blockEdit,
265
+ focusActions,
266
+ setSnapTarget: (offset) => {
267
+ lastSnapTargetOffset = offset;
268
+ },
269
+ setPendingCursor: (offset) => setPendingCursorOffset(offset, 'widget'),
270
+ readRawText: () => readRawText(),
271
+ setRevealing: (value) => {
272
+ revealing = value;
273
+ },
274
+ isCrossBlock: () => selection.isCrossBlock,
275
+ getPresentationMode: () => presentationMode,
276
+ get linkRef() {
277
+ return linkRef;
278
+ }
279
+ });
280
+
281
+ // After widgetInteraction, whose fold seam a clipboard mutation runs before it
282
+ // touches the CST.
283
+ const clipboardHandlers = createTextClipboard({
284
+ get node() {
285
+ return node;
286
+ },
287
+ get index() {
288
+ return index;
289
+ },
290
+ get myPath() {
291
+ return myPath;
292
+ },
293
+ cursor,
294
+ caret: editableSurface.caret,
295
+ crossBlock,
296
+ selection,
297
+ stickyColumn,
298
+ edgeAffinity,
299
+ blockEdit,
300
+ pasteCoordinator,
301
+ grammar,
302
+ activePlugins,
303
+ getDoc,
304
+ widgetSelection,
305
+ events: editorEvents,
306
+ onPasteImage,
307
+ setPendingCursor: (offset) => setPendingCursorOffset(offset, 'clipboard'),
308
+ isReadOnly: () => readOnly,
309
+ foldRevealBeforeMutation: () => widgetInteraction.foldRevealBeforeMutation(),
310
+ isRevealing: () => widgetInteraction.isRevealing(),
311
+ getPresentationMode: () => presentationMode,
312
+ getAmbientPrefix: () => ambientPrefixText,
313
+ readRevealedText: () => readRawText(),
314
+ get linkRef() {
315
+ return linkRef;
316
+ }
317
+ });
318
+
319
+ // preview-inline's marker reveal: CSS class flips only, no keys intercepted.
320
+ const constructReveal = createConstructReveal({
321
+ get node() {
322
+ return node;
323
+ },
324
+ get linkRef() {
325
+ return linkRef;
326
+ },
327
+ getEl: () => el ?? null,
328
+ getAmbientLength: () => ambientLength,
329
+ getPresentationMode: () => presentationMode,
330
+ isCrossBlock: () => selection.isCrossBlock
331
+ });
332
+
333
+ // The one caret-edge dispatch (G4.12); entry execution stays at
334
+ // `widgetInteraction.enterWidget`.
335
+ const edgeDispatch = createEdgePolicyDispatch({
336
+ get node() {
337
+ return node;
338
+ },
339
+ get index() {
340
+ return index;
341
+ },
342
+ get containerParent() {
343
+ return blockNodeAt(getDoc(), myPath.slice(0, -1));
344
+ },
345
+ get linkRef() {
346
+ return linkRef;
347
+ },
348
+ getEl: () => el ?? null,
349
+ getAmbientLength: () => ambientLength,
350
+ getAmbientPrefix: () => ambientPrefixText,
351
+ hasIslands: () =>
352
+ decorationEngine ? decorationEngine.islandsForPath(myPath).length > 0 : false,
353
+ getRawSelection: () => cursor.getRawSelection(),
354
+ blockEdit,
355
+ setPendingCursor: (offset, source) => setPendingCursorOffset(offset, source),
356
+ setSnapTarget: (offset) => {
357
+ lastSnapTargetOffset = offset;
358
+ },
359
+ isRevealing: () => widgetInteraction.isRevealing(),
360
+ enterWidget: (widget, fromTrailingEdge) =>
361
+ widgetInteraction.enterWidget(widget, fromTrailingEdge),
362
+ isReading: () => readOnly,
363
+ getEdgeAffinity: () => edgeAffinity.get(),
364
+ pendingMarks,
365
+ installedAs: 'block'
366
+ });
367
+
368
+ // The same seat the keydown dispatch takes, for the one insertion a keydown cannot reach.
369
+ const compositionSeat = createCompositionSeat({
370
+ getDisplayText: () => getDisplayText(),
371
+ getInlines: () => resolvedInlineContent(node, linkRef),
372
+ getAffinity: () => edgeAffinity.get(),
373
+ getScreen: () => screenVisibilityOf(el ?? null),
374
+ consumePendingMarks: () => pendingMarks.consume(),
375
+ restorePendingMarks: (marks) => pendingMarks.restore(marks),
376
+ getRawSelection: () => cursor.getRawSelection(),
377
+ // The same join seam `handleLiveSelectionEdit` takes, in the display bytes the seat's
378
+ // contract returns (commitInput re-appends the trailing line ending).
379
+ resolveRangeEdit: (range, typed) => {
380
+ const edit = resolveSelectionEdit(
381
+ node,
382
+ range,
383
+ typed,
384
+ presentationMode,
385
+ linkRef,
386
+ ambientPrefixText
387
+ );
388
+ return edit && { raw: trimTrailingLineEnding(edit.raw), caret: edit.caret };
389
+ }
390
+ });
391
+
392
+ const textRender = createTextRender({
393
+ get el() {
394
+ return el ?? null;
395
+ },
396
+ get node() {
397
+ return node;
398
+ },
399
+ get ambientPrefix() {
400
+ return ambientPrefix;
401
+ },
402
+ get ambientPrefixText() {
403
+ return ambientPrefixText;
404
+ },
405
+ getDisplayText: () => getDisplayText(),
406
+ resolveImageUrl,
407
+ resolveLinkUrl,
408
+ get imageLoadPolicy() {
409
+ return imageLoadPolicy();
410
+ },
411
+ get presentationMode() {
412
+ return presentationMode;
413
+ },
414
+ getTheme,
415
+ getDocument: () => getDoc(),
416
+ getContentVersion,
417
+ navigateTo: (path) => rects?.navigateTo(path) ?? Promise.resolve(false),
418
+ get linkResolver(): LinkReferenceResolver | undefined {
419
+ return linkRef?.current;
420
+ },
421
+ get linkStamp(): string {
422
+ return String(linkRef?.epoch ?? 0);
423
+ },
424
+ get islands() {
425
+ return decorationEngine ? decorationEngine.islandsForPath(myPath) : NO_ISLANDS;
426
+ },
427
+ brokenUrlCache,
428
+ reportRenderError: (error) =>
429
+ editorEvents?.emit('error', { origin: 'render', error, context: { path: myPath } })
430
+ });
431
+
432
+ $effect(() => () => textRender.dispose());
433
+
434
+ // ── BlockComponent interface ────────────────────────────────────────
435
+
436
+ export const editable = true;
437
+ export const focusable = true;
438
+
439
+ export const focus = editableSurface.surface.focus;
440
+ export const parkCaret = editableSurface.surface.parkCaret;
441
+ export const focusAtColumn = editableSurface.surface.focusAtColumn;
442
+ export const getCursorOffset = editableSurface.surface.getCursorOffset;
443
+ export const getSelectedText = editableSurface.surface.getSelectedText;
444
+ export const setSelection = editableSurface.surface.setSelection;
445
+ export const measurePartialRects = editableSurface.surface.measurePartialRects;
446
+
447
+ export function isVerticallyTransparent(): boolean {
448
+ return widgetInteraction.isVerticallyTransparent();
449
+ }
450
+
451
+ export function enterEdgeWidget(side: 'start' | 'end'): boolean {
452
+ return widgetInteraction.enterEdgeWidget(side);
453
+ }
454
+
455
+ export const claimRootClipboard = clipboardHandlers.claimRootClipboard;
456
+ export const insertMarkdown = clipboardHandlers.insertMarkdown;
457
+
458
+ export function snapCaretToPoint(clientX: number, clientY: number): void {
459
+ widgetInteraction.snapClickToWidgetEdge(clientX, clientY);
460
+ }
461
+
462
+ /** The display length the CARET walks — the DOM's while a reveal is open, since the
463
+ * CST hasn't seen that edit. Against a stale `node.raw`, an edited reveal at the
464
+ * block's end traps the caret: no press reads as "at the boundary". */
465
+ function liveDisplayLength(): number {
466
+ return widgetInteraction.isRevealing() ? readRawText().length : getDisplayText().length;
467
+ }
468
+
469
+ /** The offsets a caret can reach here, from the one home the arrow exits already read: a mode
470
+ * that paints no marker puts the block's own bytes out of reach, so every block-edge gate
471
+ * moves in to what the DOM can land rather than testing 0 / length. */
472
+ function caretBounds(): { start: number; end: number } {
473
+ return el ? caretLandableBounds(sharedCtx, el) : { start: 0, end: liveDisplayLength() };
474
+ }
475
+
476
+ /** The structural bytes this press gives up before any merge — a declared kind's, in a mode
477
+ * that paints none of them. Null everywhere else, and the cascade takes the press. */
478
+ function demoteBeforeMerge(offset: number): TextEditResult | null {
479
+ if (!el || !revealsNoMarkers(el)) return null;
480
+ if (tryGetBlockKindDescriptor(node.kind)?.contentStartBackspace !== 'demote-first') return null;
481
+ return demoteToParagraph(node.raw, getContentRange(node), offset);
482
+ }
483
+
484
+ /** One arm per command this block owns, split so the reveal fold sits between the
485
+ * halves: `applies` reads only the DOM and survives a fold, `perform` reads `node.raw`
486
+ * and is valid only after one. `offset`/`selected` are closed over: the fold moves them. */
487
+ function blockCommand(
488
+ id: CommandId,
489
+ arg: unknown,
490
+ offset: number,
491
+ selected: { start: number; end: number } | null
492
+ ): { applies: () => boolean; perform: () => void } | null {
493
+ const always = (perform: () => void) => ({ applies: () => true, perform });
494
+ switch (id) {
495
+ case 'block.split':
496
+ return always(() => blockEdit.splitBlock(index, offset));
497
+ case 'chrome.descendToBody':
498
+ return always(() => blockEdit.descendToBody(index));
499
+ case 'block.hardBreak':
500
+ return always(() => {
501
+ const { newRaw, caretOffset } = insertHardBreak(node.raw, offset);
502
+ blockEdit.updateBlockContent(index, newRaw, offset);
503
+ setPendingCursorOffset(caretOffset, 'hard-break');
504
+ });
505
+ case 'block.insertTab':
506
+ return {
507
+ // Inside a list item Tab is the list's indent, so decline and let it bubble.
508
+ applies: () => !listContext,
509
+ // A literal tab, because the browser default moves focus out of the editor.
510
+ perform: () => {
511
+ const { newRaw, caretOffset } = insertLiteralTab(node.raw, offset);
512
+ blockEdit.updateBlockContent(index, newRaw, offset);
513
+ setPendingCursorOffset(caretOffset, 'insert-tab');
514
+ }
515
+ };
516
+ case 'block.mergePrev':
517
+ return {
518
+ // At-or-before, not equal: a caret door can still park on an offset the walk
519
+ // canonicalizes forward, and a strict test would make the press a dead key there.
520
+ applies: () => offset <= caretBounds().start && !hasSelectionHelper(),
521
+ perform: () => {
522
+ const demoted = demoteBeforeMerge(offset);
523
+ if (!demoted) return void blockEdit.mergeWithPrevious(index);
524
+ // A command is not typing: the demote is its own undo step, so one Ctrl+Z puts
525
+ // the heading back whole rather than unwinding the burst around it.
526
+ controller.isolateUndoEntry(() =>
527
+ blockEdit.updateBlockContent(index, demoted.newRaw, offset, demoted.caretOffset)
528
+ );
529
+ setPendingCursorOffset(demoted.caretOffset, 'demote');
530
+ }
531
+ };
532
+ case 'block.mergeNext':
533
+ return {
534
+ // A block whose own structure sits AFTER its content cannot absorb the next one
535
+ // without surfacing it (live-mode.md § 4.5). The keydown dispatch consumes that press; this is
536
+ // the same rule for the callers that never pass through it.
537
+ applies: () =>
538
+ offset >= caretBounds().end &&
539
+ !hasSelectionHelper() &&
540
+ !hidesStructuralSuffix(el ?? null, node, liveDisplayLength()),
541
+ perform: () => void blockEdit.mergeWithNext(index)
542
+ };
543
+ case 'link.openCard':
544
+ // Consumed wherever the keymap binds it, entry or not: `reservedChords()` reports
545
+ // Mod+K as the editor's, and handing an unentered press back fires the browser
546
+ // default the host was told not to expect (Ctrl+K kills to end of line here).
547
+ return always(enterLinkCard);
548
+ case 'heading.cycle':
549
+ return {
550
+ // A heading marks PROSE. The raw-editable kinds bind this keymap too, and there
551
+ // an ATX prefix is content: it would destroy a link reference definition.
552
+ applies: () => isProseKind(node.kind),
553
+ perform: () => {
554
+ // `arg` is untrusted `unknown` from the widened keybinding channel: an
555
+ // out-of-range value would throw a RangeError inside `repeat`, so fall
556
+ // back to the strip behavior.
557
+ const level = typeof arg === 'number' && arg >= 0 && arg <= 6 ? arg : 0;
558
+ const cycled = cycleHeading(node.raw, getContentRange(node), level, offset);
559
+ if (!cycled) return;
560
+ blockEdit.updateBlockContent(index, cycled.newRaw, offset, cycled.caretOffset);
561
+ setPendingCursorOffset(cycled.caretOffset, 'heading-cycle');
562
+ }
563
+ };
564
+ case 'block.moveUp':
565
+ case 'block.moveDown':
566
+ // Through `always`, not a bare opener line: every perform here rides the reveal fold.
567
+ return always(() => void reorderRunCommand(id, reorder, () => myPath));
568
+ default: {
569
+ // The format chords are rows, not arms: a construct that declares a mark names the
570
+ // command that toggles it, so a new markable kind costs a row here and nothing else.
571
+ const marked = inlineMarkForCommand(id);
572
+ return marked === null
573
+ ? null
574
+ : always(() => toggleFormat(marked.kind, selected ?? { start: offset, end: offset }));
575
+ }
576
+ }
577
+ }
578
+
579
+ export function runCommand(id: CommandId, arg?: unknown): boolean {
580
+ // Read live: cross-block dispatch arrives with no preceding onKeyDown, so
581
+ // `preEditOffset` would be stale here.
582
+ const offset = cursor.getRaw() ?? 0;
583
+ const command = blockCommand(id, arg, offset, cursor.getRawSelection());
584
+ if (!command || !command.applies()) return false;
585
+ if (!widgetInteraction.isRevealing()) {
586
+ performBlockCommand(id, command.perform);
587
+ return true;
588
+ }
589
+ // A live reveal holds this block's bytes in ephemeral DOM, so every `perform` would
590
+ // splice the pre-reveal source: fold, settle, then act. The fold is handed the user's
591
+ // offset, valid because the committed text IS the DOM text it was measured against.
592
+ const fold = widgetInteraction.foldRevealBeforeMutation(offset);
593
+ void (fold?.settled ?? tick()).then(() => performBlockCommand(id, command.perform));
594
+ return true;
595
+ }
596
+
597
+ // A toolbar asks once per button on every selection change, so the buttons share the parse.
598
+ const formatActive = createInlineFormatActiveMemo();
599
+
600
+ // The pressed-state read: the same display, content and selection the toggle itself takes,
601
+ // and for the card the same construct its own entry resolves.
602
+ export function isCommandActive(id: CommandId): boolean {
603
+ const marked = inlineMarkForCommand(id);
604
+ if (!marked) {
605
+ // Both surfaces spell the id, as their run arms do: a registry for one command is premature.
606
+ if (id !== 'link.openCard' || !el) return false;
607
+ return linkCardTargetAt(linkCardQuery(el, cursor.getRawSelection())) !== null;
608
+ }
609
+ const caret = cursor.getRaw() ?? 0;
610
+ const selection = cursor.getRawSelection() ?? { start: caret, end: caret };
611
+ return formatActive(
612
+ { display: getDisplayText(), content: getContentRange(node), selection },
613
+ marked.kind
614
+ );
615
+ }
616
+
617
+ // No arm reached through here mutates while a reveal is open (G1.26): a fire means a
618
+ // `runCommand` branch that skipped the fold. It guards the arms, not every entry path.
619
+ // TODO(#35): funnel the fold at every mutation entry path, not just the command arms.
620
+ function performBlockCommand(id: CommandId, perform: () => void): void {
621
+ assertInvariant('reveal-transition', () =>
622
+ widgetInteraction.isRevealing()
623
+ ? { code: 'command-during-reveal', message: `${id} mutated the block with a reveal open` }
624
+ : null
625
+ );
626
+ perform();
627
+ }
628
+
629
+ void ({
630
+ editable,
631
+ focusable,
632
+ focus,
633
+ parkCaret,
634
+ getCursorOffset,
635
+ focusAtColumn,
636
+ isVerticallyTransparent,
637
+ enterEdgeWidget,
638
+ claimRootClipboard,
639
+ insertMarkdown,
640
+ snapCaretToPoint,
641
+ runCommand
642
+ } satisfies BlockComponent);
643
+
644
+ // ── Content sync ──────────────────────────────────────────────────────
645
+
646
+ function getDisplayText(): string {
647
+ return trimTrailingLineEnding(node.raw);
648
+ }
649
+
650
+ $effect(() => {
651
+ if (ambientPrefixText && !isProseKind(node.kind)) {
652
+ devWarn(
653
+ 'TextEditableBlock',
654
+ `ambientPrefix is prose-only; non-prose kind ${node.kind} received a non-empty ambient prefix, so the ambient marker will not render correctly`
655
+ );
656
+ }
657
+
658
+ const t0 = perfEnabled() ? performance.now() : 0;
659
+ // With a pending restore armed, the consume below overwrites the selection, so the
660
+ // render's own caret walk would be dead work.
661
+ textRender.render({
662
+ forceRebuild: pendingCursorOffset !== null,
663
+ carryCaret: pendingCursorOffset === null
664
+ });
665
+ if (perfEnabled()) recordBlockRender(performance.now() - t0, myPath);
666
+
667
+ if (pendingCursorOffset !== null) {
668
+ // Only while this block still owns focus: a blur-commit also arms a pending
669
+ // offset, and restoring would yank the selection back into the blurred block.
670
+ // The clear runs regardless, so a skipped restore is dropped, never re-armed.
671
+ const applied = consumePendingRestore(el ?? null, pendingCursorOffset, (offset) =>
672
+ cursor.setRaw(asRawOffset(offset))
673
+ );
674
+ tracePendingCursorConsume(pendingCursorOffset, applied);
675
+ pendingCursorOffset = null;
676
+ }
677
+ // A rebuild mints fresh spans with no reveal class, so re-apply before paint or
678
+ // typing inside a revealed construct folds for one frame per keystroke. Untracked,
679
+ // because the caret chain must never join this effect's dependencies.
680
+ untrack(() => {
681
+ if (!composing) constructReveal.update(true);
682
+ });
683
+ markKeystrokeSettle();
684
+ });
685
+
686
+ useParkFocusOnUnmount(() => el ?? null, getEditorRoot);
687
+
688
+ // Asymmetric: clears only. The synthetic indicator is click-intent, armed nowhere but
689
+ // `snapClickToWidgetEdge`, so a caret reaching a boundary by other means never sets it.
690
+ function clearSnapTargetIfMoved(root: HTMLElement): void {
691
+ if (lastSnapTargetOffset === null) return;
692
+ const sel = window.getSelection();
693
+ if (!sel || sel.rangeCount === 0) return;
694
+ const range = sel.getRangeAt(0);
695
+ if (!root.contains(range.startContainer)) {
696
+ lastSnapTargetOffset = null;
697
+ return;
698
+ }
699
+ const content = domTextOffsetAtNode(root, range.startContainer, range.startOffset);
700
+ const off = toClampedRawOffset(content, ambientLength);
701
+ if (off !== lastSnapTargetOffset) lastSnapTargetOffset = null;
702
+ }
703
+
704
+ // One listener drives the block's whole selection cadence. The snap clearer runs even
705
+ // during composition — an IME caret move still invalidates a click-intent snap — while
706
+ // the reveal machines are composition-gated like onInput.
707
+ $effect(() => {
708
+ const root = el;
709
+ if (!root) return;
710
+ const handler = () => {
711
+ clearSnapTargetIfMoved(root);
712
+ if (composing) return;
713
+ widgetInteraction.foldRevealIfSelectionEscaped();
714
+ constructReveal.update();
715
+ };
716
+ document.addEventListener('selectionchange', handler);
717
+ return () => document.removeEventListener('selectionchange', handler);
718
+ });
719
+
720
+ $effect(() => {
721
+ if (!el) return;
722
+ for (const w of el.querySelectorAll('.md-snap-after, .md-snap-before')) {
723
+ w.classList.remove('md-snap-after', 'md-snap-before');
724
+ }
725
+ // The synthetic caret stands in for one Chromium renders unreliably beside a
726
+ // contenteditable=false island, and "unreliably" cuts both ways — nothing can ask
727
+ // whether it painted, so darkening the native one is the only guarantee available.
728
+ el.classList.remove('md-snap-caret-active');
729
+ if (lastSnapTargetOffset === null) return;
730
+ const off = lastSnapTargetOffset;
731
+ for (const inline of resolvedInlineContent(node, linkRef)) {
732
+ if (!isInlineWidget(inline, node.raw)) continue;
733
+ if (inline.end !== off && inline.start !== off) continue;
734
+ const widget = widgetElByStart(el, inline.start);
735
+ if (widget) {
736
+ widget.classList.add(inline.end === off ? 'md-snap-after' : 'md-snap-before');
737
+ el.classList.add('md-snap-caret-active');
738
+ }
739
+ return;
740
+ }
741
+ });
742
+
743
+ // ── Event Handlers ──────────────────────────────────────────────────
744
+
745
+ const onInput = editableSurface.onInput;
746
+
747
+ // Walk children rather than reading textContent, so stray text nodes Chromium inserts
748
+ // around the marker span don't pollute the raw.
749
+ function readRawText(): string {
750
+ if (!el) return '';
751
+ const ambient = ambientLength > 0 ? ambientSpanOf(el) : null;
752
+ let out = '';
753
+ for (const child of Array.from(el.childNodes)) {
754
+ if (child === ambient) continue;
755
+ out += rawTextOfNode(child, node.raw);
756
+ }
757
+ return out;
758
+ }
759
+
760
+ // Captured before the surface's own handler: its cross-block half clears the affinity, and
761
+ // the first mid-composition `input` re-arms it to the typed side.
762
+ function onCompositionStart(): void {
763
+ compositionSeat.noteStart();
764
+ editableSurface.onCompositionStart();
765
+ }
766
+
767
+ function onCompositionEnd(): void {
768
+ editableSurface.onCompositionEnd();
769
+ compositionSeat.noteEnd();
770
+ }
771
+
772
+ async function onKeyDown(e: KeyboardEvent): Promise<void> {
773
+ if (composing || editableSurface.isDetached()) return;
774
+
775
+ preEditOffset = cursor.getRaw() ?? 0;
776
+
777
+ // Reveal-only backstop, before any default runs: rapid arrows outrun the async
778
+ // selectionchange reveal, and a step against folded markers skips their bytes.
779
+ constructReveal.prepareForKeydown(e);
780
+
781
+ // Escape cancels a revealed source back to rendered; every other key edits the
782
+ // source natively or reaches the command seam below, which folds before mutating.
783
+ if ((await widgetInteraction.handleRevealingKeydown(e)) || editableSurface.isDetached()) return;
784
+
785
+ // Before handleSharedKeydown: selecting cleared the native range, so the shared
786
+ // ArrowLeft boundary branch would read offset 0 and move focus to a block that
787
+ // isn't there.
788
+ if ((await widgetInteraction.handleSelectedWidgetKeydown(e)) || editableSurface.isDetached())
789
+ return;
790
+
791
+ // The native default, with user-select:none on the widget, collapses the selection
792
+ // instead of stepping past it.
793
+ if (widgetInteraction.handleShiftArrowIntoWidget(e)) return;
794
+
795
+ if ((await handleSharedKeydown(e, sharedCtx)) || editableSurface.isDetached()) return;
796
+
797
+ // Every caret-edge construct routes through this one dispatch, keeping native
798
+ // contenteditable from corrupting the atomic bytes each stands for.
799
+ if (edgeDispatch.handleKeydown(e, cursor.getRaw())) return;
800
+
801
+ // Native Home lands at DOM 0, before the marker span — or past a leading island no text
802
+ // node fronts; the user wants the block's start. Through the sentinel door,
803
+ // not a raw-0 DOM write: the landable clamp applies.
804
+ if (
805
+ e.key === 'Home' &&
806
+ !e.shiftKey &&
807
+ el &&
808
+ (ambientLength > 0 || landableStartAbutsIsland(el))
809
+ ) {
810
+ e.preventDefault();
811
+ focus(CURSOR_START);
812
+ return;
813
+ }
814
+
815
+ if (wiring.dispatchChord(e, { kind: node.kind, runCommand })) return;
816
+ }
817
+
818
+ /**
819
+ * A native ranged edit inside ONE block, in a mode that paints no delimiter: the engine would
820
+ * write the runs the range crossed literally, so the edit goes through the join seam instead.
821
+ * Declines wherever that seam has nothing to clean, leaving the engine its grapheme and IME
822
+ * behavior.
823
+ */
824
+ function handleLiveSelectionEdit(e: InputEvent): boolean {
825
+ return applyLiveRangeEdit(
826
+ e,
827
+ node,
828
+ cursor,
829
+ presentationMode,
830
+ linkRef,
831
+ ambientPrefixText,
832
+ widgetInteraction.isRevealing,
833
+ (edit) => {
834
+ void blockEdit.updateBlockContent(index, edit.raw, edit.range.start, edit.caret);
835
+ setPendingCursorOffset(edit.caret, 'live-selection-edit');
836
+ }
837
+ );
838
+ }
839
+
840
+ async function onBeforeInput(e: InputEvent): Promise<void> {
841
+ if (await handleSharedBeforeInput(e, sharedCtx)) return;
842
+ if (handleLiveSelectionEdit(e)) return;
843
+ // Soft-keyboard/IME insertLineBreak slipped past onKeyDown — swallow; Shift+Enter there owns hard breaks.
844
+ if (e.inputType === 'insertLineBreak') {
845
+ e.preventDefault();
846
+ return;
847
+ }
848
+ }
849
+
850
+ // A click past a widget drops the caret outside the contenteditable, with no text-node
851
+ // anchor, so onClick snaps to the nearest widget edge from this point. Y is
852
+ // load-bearing: a column-aligned click on another visual line must not reveal.
853
+ let lastClickClientX: number | null = null;
854
+ let lastClickClientY: number | null = null;
855
+
856
+ function onPointerDown(e: PointerEvent): void {
857
+ if (crossBlock.handlePointerDown(e)) return;
858
+ lastClickClientX = e.clientX;
859
+ lastClickClientY = e.clientY;
860
+ lastSnapTargetOffset = null;
861
+ // A press on a reveal-source widget is an owned gesture: suppressing the browser's
862
+ // caret default leaves the reveal as the only selection writer until it places.
863
+ if (widgetInteraction.isPointOnRevealWidget(e.clientX, e.clientY)) e.preventDefault();
864
+ }
865
+
866
+ function onBlur(e: FocusEvent): void {
867
+ if (el && e.relatedTarget && el.contains(e.relatedTarget as Node)) return;
868
+ // Persist a revealed source edit before the caret is gone.
869
+ widgetInteraction.commitRevealOnBlur();
870
+ lastSnapTargetOffset = null;
871
+ }
872
+
873
+ function onClick(e: MouseEvent): void {
874
+ // An inline widget's own handler runs first, and a jump it starts can unmount this
875
+ // surface before the click reaches it; nothing below addresses a block that is gone.
876
+ if (!el) return;
877
+ const x = lastClickClientX;
878
+ const y = lastClickClientY;
879
+ lastClickClientX = null;
880
+ lastClickClientY = null;
881
+ cursor.clampOutOfAmbient();
882
+ widgetInteraction.snapClickToWidgetEdge(x, y, {
883
+ modified: e.ctrlKey || e.metaKey,
884
+ clickCount: e.detail
885
+ });
886
+ }
887
+
888
+ // ── Formatting shortcuts ────────────────────────────────────────────
889
+
890
+ // `range` is what the COMMAND read before it ran, and must not be re-read: a fold on
891
+ // the way in parks a caret that collapses the live selection, so the chord would find
892
+ // nothing to toggle. A collapsed range is the caret contract, not a bail.
893
+ function toggleFormat(format: InlineMarkKind, range: { start: number; end: number }): void {
894
+ if (!el) return;
895
+
896
+ // A surface painting no delimiter would hold the byte-pair strategy's abandoned `****` as
897
+ // invisible garbage the user can see the effect of but not explain: pend the mark and let
898
+ // the next insertion carry it instead (live-mode.md § 4.3). The preview rungs reveal the
899
+ // block the caret is in, so they show the pair and take the byte path.
900
+ if (!paintsFocusedMarkers(presentationMode) && range.start === range.end) {
901
+ // The insertion that spends the mark starts its own undo entry, so it is never
902
+ // folded into the burst the chord interrupted.
903
+ controller.flushDebouncedCheckpoint();
904
+ pendingMarks.toggle(format);
905
+ return;
906
+ }
907
+
908
+ const toggled = toggleInlineFormat(
909
+ { display: getDisplayText(), content: getContentRange(node), selection: range },
910
+ format,
911
+ presentationMode
912
+ );
913
+ if (!toggled) return;
914
+ const { newDisplay, newSelStart, newSelEnd } = toggled;
915
+
916
+ // A command is not typing: the toggle's bytes are their own undo step in every mode.
917
+ controller.isolateUndoEntry(() =>
918
+ blockEdit.updateBlockContent(index, newDisplay + trailingLineEnding(node.raw), newSelStart)
919
+ );
920
+
921
+ tick().then(() => {
922
+ setSelection(newSelStart, newSelEnd);
923
+ });
924
+ }
925
+ </script>
926
+
927
+ <!-- Reading mode flips contenteditable off, killing the whole browser-edit-path class
928
+ structurally. tabindex/role are independent, so focus and arrow traversal stay. -->
929
+ <div
930
+ bind:this={el}
931
+ tabindex="0"
932
+ class="text-editable-block {blockClass}"
933
+ contenteditable={readOnly ? 'false' : 'true'}
934
+ aria-readonly={readOnly ? 'true' : undefined}
935
+ role="textbox"
936
+ style:text-indent={ambientPrefixText ? `-${ambientLength}ch` : null}
937
+ style:padding-left={ambientPrefixText ? `${ambientLength}ch` : null}
938
+ oninput={onInput}
939
+ onkeydown={onKeyDown}
940
+ onbeforeinput={onBeforeInput}
941
+ oncopy={clipboardHandlers.onCopy}
942
+ oncut={clipboardHandlers.onCut}
943
+ onpaste={clipboardHandlers.onPaste}
944
+ onpointerdown={onPointerDown}
945
+ onclick={onClick}
946
+ onblur={onBlur}
947
+ oncompositionstart={onCompositionStart}
948
+ oncompositionend={onCompositionEnd}
949
+ ></div>
950
+
951
+ <style>
952
+ .text-editable-block {
953
+ outline: none;
954
+ padding: 2px 0;
955
+ white-space: pre-wrap;
956
+ word-wrap: break-word;
957
+ min-height: 1.4em;
958
+ width: 100%;
959
+ }
960
+
961
+ .text-editable-block.heading-1 {
962
+ font-size: 2em;
963
+ font-weight: bold;
964
+ line-height: 1.2;
965
+ }
966
+ .text-editable-block.heading-2 {
967
+ font-size: 1.5em;
968
+ font-weight: bold;
969
+ line-height: 1.3;
970
+ }
971
+ .text-editable-block.heading-3 {
972
+ font-size: 1.25em;
973
+ font-weight: bold;
974
+ }
975
+ .text-editable-block.heading-4 {
976
+ font-size: 1.1em;
977
+ font-weight: bold;
978
+ }
979
+ .text-editable-block.heading-5 {
980
+ font-size: 1em;
981
+ font-weight: bold;
982
+ }
983
+ .text-editable-block.heading-6 {
984
+ font-size: 0.9em;
985
+ font-weight: bold;
986
+ }
987
+
988
+ .text-editable-block.raw-block {
989
+ font-family: var(--font-editor, ui-monospace, monospace);
990
+ font-size: 0.9em;
991
+ opacity: 0.85;
992
+ }
993
+
994
+ .text-editable-block :global(.md-marker) {
995
+ opacity: var(--syntax-marker-dim, 0.65);
996
+ font-weight: normal;
997
+ font-style: normal;
998
+ }
999
+
1000
+ .text-editable-block :global(.inline-code-content) {
1001
+ font-family: var(--font-editor, ui-monospace, monospace);
1002
+ font-size: 0.9em;
1003
+ background: var(--color-bg-secondary, rgba(128, 128, 128, 0.12));
1004
+ border-radius: 3px;
1005
+ padding: 1px 4px;
1006
+ }
1007
+
1008
+ .text-editable-block :global(.md-autolink) {
1009
+ color: var(--syntax-url, var(--color-accent, #567b67));
1010
+ text-decoration: underline;
1011
+ }
1012
+ </style>