@notectl/core 1.0.8 → 1.6.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 (269) hide show
  1. package/dist/chunks/{AttrRegistry-D-przlzb.mjs → AttrRegistry-I-VdmRnN.mjs} +2 -2
  2. package/dist/chunks/{AttrRegistry-D-przlzb.mjs.map → AttrRegistry-I-VdmRnN.mjs.map} +1 -1
  3. package/dist/chunks/CaretNavigation-CAJXoaae.mjs +311 -0
  4. package/dist/chunks/CaretNavigation-CAJXoaae.mjs.map +1 -0
  5. package/dist/chunks/ColorNames-BdsHwA2f.mjs +59 -0
  6. package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +1 -0
  7. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +125 -0
  8. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +1 -0
  9. package/dist/chunks/Commands-CicwYoTQ.mjs +286 -0
  10. package/dist/chunks/Commands-CicwYoTQ.mjs.map +1 -0
  11. package/dist/chunks/{Document-CI3iCwEP.mjs → Document-CuwE73FF.mjs} +35 -22
  12. package/dist/chunks/{Document-CI3iCwEP.mjs.map → Document-CuwE73FF.mjs.map} +1 -1
  13. package/dist/chunks/HTMLUtils-DTqQzcKR.mjs +35 -0
  14. package/dist/chunks/HTMLUtils-DTqQzcKR.mjs.map +1 -0
  15. package/dist/chunks/MarkCommands-CC37WA7Z.mjs +94 -0
  16. package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +1 -0
  17. package/dist/chunks/NavigationUtils-CyW0Vo8A.mjs +47 -0
  18. package/dist/chunks/NavigationUtils-CyW0Vo8A.mjs.map +1 -0
  19. package/dist/chunks/{NodeResolver-D68ZLXti.mjs → NodeResolver-B-wzthAQ.mjs} +2 -2
  20. package/dist/chunks/{NodeResolver-D68ZLXti.mjs.map → NodeResolver-B-wzthAQ.mjs.map} +1 -1
  21. package/dist/chunks/Platform-S_xqIqcM.mjs +26 -0
  22. package/dist/chunks/Platform-S_xqIqcM.mjs.map +1 -0
  23. package/dist/chunks/Selection-DmFDwiPJ.mjs +52 -0
  24. package/dist/chunks/Selection-DmFDwiPJ.mjs.map +1 -0
  25. package/dist/chunks/ToolbarItem-BpZggUGo.mjs +8 -0
  26. package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -0
  27. package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs +818 -0
  28. package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +1 -0
  29. package/dist/chunks/index--z_Txzej.mjs +467 -0
  30. package/dist/chunks/index--z_Txzej.mjs.map +1 -0
  31. package/dist/chunks/{index-o6hDR07y.mjs → index-83QoUENW.mjs} +25 -20
  32. package/dist/chunks/index-83QoUENW.mjs.map +1 -0
  33. package/dist/chunks/{index-CT3HGdQt.mjs → index-B0UFAfyb.mjs} +13 -13
  34. package/dist/chunks/{index-CT3HGdQt.mjs.map → index-B0UFAfyb.mjs.map} +1 -1
  35. package/dist/chunks/{index-C2GQoHot.mjs → index-BDMP86F4.mjs} +40 -40
  36. package/dist/chunks/{index-C2GQoHot.mjs.map → index-BDMP86F4.mjs.map} +1 -1
  37. package/dist/chunks/{index-Bsp4LC5t.mjs → index-BWXkaC2Z.mjs} +36 -36
  38. package/dist/chunks/index-BWXkaC2Z.mjs.map +1 -0
  39. package/dist/chunks/{index-C-YWHOcC.mjs → index-BigJ0z6n.mjs} +22 -22
  40. package/dist/chunks/{index-C-YWHOcC.mjs.map → index-BigJ0z6n.mjs.map} +1 -1
  41. package/dist/chunks/{index-uTnc9y7M.mjs → index-CPjf45-o.mjs} +28 -28
  42. package/dist/chunks/index-CPjf45-o.mjs.map +1 -0
  43. package/dist/chunks/{index-BAk1EG1x.mjs → index-CPyHuEzh.mjs} +106 -106
  44. package/dist/chunks/index-CPyHuEzh.mjs.map +1 -0
  45. package/dist/chunks/{index-Ct0ivLhO.mjs → index-D4GKlc-A.mjs} +256 -259
  46. package/dist/chunks/index-D4GKlc-A.mjs.map +1 -0
  47. package/dist/chunks/{index-BRYzYOYC.mjs → index-D67mP19g.mjs} +29 -29
  48. package/dist/chunks/index-D67mP19g.mjs.map +1 -0
  49. package/dist/chunks/index-D8tbbW97.mjs +73 -0
  50. package/dist/chunks/index-D8tbbW97.mjs.map +1 -0
  51. package/dist/chunks/{index-DC1EK22F.mjs → index-DIAXWwgJ.mjs} +24 -19
  52. package/dist/chunks/index-DIAXWwgJ.mjs.map +1 -0
  53. package/dist/chunks/{index-BSFLNveF.mjs → index-DQryjfJs.mjs} +352 -341
  54. package/dist/chunks/index-DQryjfJs.mjs.map +1 -0
  55. package/dist/chunks/index-DRZwd-1W.mjs +187 -0
  56. package/dist/chunks/index-DRZwd-1W.mjs.map +1 -0
  57. package/dist/chunks/{index-BYgspns5.mjs → index-DUC1X43Z.mjs} +54 -54
  58. package/dist/chunks/index-DUC1X43Z.mjs.map +1 -0
  59. package/dist/chunks/{index-CxiWyUho.mjs → index-DipAT_Q9.mjs} +31 -31
  60. package/dist/chunks/index-DipAT_Q9.mjs.map +1 -0
  61. package/dist/chunks/{index-D3CQWJiw.mjs → index-tBDVaSjG.mjs} +81 -61
  62. package/dist/chunks/index-tBDVaSjG.mjs.map +1 -0
  63. package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -1
  64. package/dist/commands/Commands.d.ts +13 -45
  65. package/dist/commands/Commands.d.ts.map +1 -1
  66. package/dist/commands/DeleteCommands.d.ts +15 -0
  67. package/dist/commands/DeleteCommands.d.ts.map +1 -0
  68. package/dist/commands/GapCursorCommands.d.ts +24 -0
  69. package/dist/commands/GapCursorCommands.d.ts.map +1 -0
  70. package/dist/commands/MarkCommands.d.ts +19 -0
  71. package/dist/commands/MarkCommands.d.ts.map +1 -0
  72. package/dist/commands/MovementCommands.d.ts +27 -0
  73. package/dist/commands/MovementCommands.d.ts.map +1 -0
  74. package/dist/commands/NodeSelectionCommands.d.ts +24 -0
  75. package/dist/commands/NodeSelectionCommands.d.ts.map +1 -0
  76. package/dist/commands/PasteCommand.d.ts.map +1 -1
  77. package/dist/commands/WordBoundary.d.ts +12 -0
  78. package/dist/commands/WordBoundary.d.ts.map +1 -0
  79. package/dist/editor/DocumentSerializer.d.ts.map +1 -1
  80. package/dist/editor/NotectlEditor.d.ts +34 -6
  81. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  82. package/dist/editor/styles/list.d.ts +2 -0
  83. package/dist/editor/styles/list.d.ts.map +1 -1
  84. package/dist/editor/styles/toolbar.d.ts +1 -1
  85. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  86. package/dist/index.d.ts +31 -10
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/input/ClipboardHandler.d.ts +2 -0
  89. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  90. package/dist/input/CompositionTracker.d.ts +14 -0
  91. package/dist/input/CompositionTracker.d.ts.map +1 -0
  92. package/dist/input/FileHandlerRegistry.d.ts +16 -0
  93. package/dist/input/FileHandlerRegistry.d.ts.map +1 -0
  94. package/dist/input/InputHandler.d.ts +8 -4
  95. package/dist/input/InputHandler.d.ts.map +1 -1
  96. package/dist/input/InputRuleRegistry.d.ts +9 -0
  97. package/dist/input/InputRuleRegistry.d.ts.map +1 -0
  98. package/dist/input/KeyboardHandler.d.ts +22 -5
  99. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  100. package/dist/input/Keymap.d.ts +11 -0
  101. package/dist/input/Keymap.d.ts.map +1 -1
  102. package/dist/input/KeymapRegistry.d.ts +19 -0
  103. package/dist/input/KeymapRegistry.d.ts.map +1 -0
  104. package/dist/input/LegacyHTMLNormalizer.d.ts +18 -0
  105. package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -0
  106. package/dist/input/PasteHandler.d.ts +7 -0
  107. package/dist/input/PasteHandler.d.ts.map +1 -1
  108. package/dist/model/Document.d.ts +8 -0
  109. package/dist/model/Document.d.ts.map +1 -1
  110. package/dist/model/GraphemeUtils.d.ts +20 -0
  111. package/dist/model/GraphemeUtils.d.ts.map +1 -0
  112. package/dist/model/HTMLParser.d.ts +13 -0
  113. package/dist/model/HTMLParser.d.ts.map +1 -1
  114. package/dist/model/HTMLUtils.d.ts +6 -1
  115. package/dist/model/HTMLUtils.d.ts.map +1 -1
  116. package/dist/model/NavigationUtils.d.ts +16 -0
  117. package/dist/model/NavigationUtils.d.ts.map +1 -0
  118. package/dist/model/SchemaRegistry.d.ts +0 -39
  119. package/dist/model/SchemaRegistry.d.ts.map +1 -1
  120. package/dist/model/Selection.d.ts +14 -3
  121. package/dist/model/Selection.d.ts.map +1 -1
  122. package/dist/notectl-core.mjs +2831 -2420
  123. package/dist/notectl-core.mjs.map +1 -1
  124. package/dist/notectl-core.umd.js +3616 -2013
  125. package/dist/notectl-core.umd.js.map +1 -1
  126. package/dist/plugins/Plugin.d.ts +34 -5
  127. package/dist/plugins/Plugin.d.ts.map +1 -1
  128. package/dist/plugins/PluginManager.d.ts +31 -1
  129. package/dist/plugins/PluginManager.d.ts.map +1 -1
  130. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
  131. package/dist/plugins/alignment.mjs +1 -1
  132. package/dist/plugins/blockquote.mjs +1 -1
  133. package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts +35 -0
  134. package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts.map +1 -0
  135. package/dist/plugins/caret-navigation/index.d.ts +2 -0
  136. package/dist/plugins/caret-navigation/index.d.ts.map +1 -0
  137. package/dist/plugins/caret-navigation.mjs +5 -0
  138. package/dist/plugins/caret-navigation.mjs.map +1 -0
  139. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -1
  140. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
  141. package/dist/plugins/code-block.mjs +1 -1
  142. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  143. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
  144. package/dist/plugins/font-size.mjs +1 -1
  145. package/dist/plugins/font.mjs +1 -1
  146. package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts +15 -0
  147. package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -0
  148. package/dist/plugins/gap-cursor/index.d.ts +2 -0
  149. package/dist/plugins/gap-cursor/index.d.ts.map +1 -0
  150. package/dist/plugins/gap-cursor.mjs +65 -0
  151. package/dist/plugins/gap-cursor.mjs.map +1 -0
  152. package/dist/plugins/hard-break.mjs +1 -1
  153. package/dist/plugins/heading/BlockTypePickerRegistry.d.ts +9 -0
  154. package/dist/plugins/heading/BlockTypePickerRegistry.d.ts.map +1 -0
  155. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +14 -0
  156. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -0
  157. package/dist/plugins/heading/HeadingCommands.d.ts +5 -0
  158. package/dist/plugins/heading/HeadingCommands.d.ts.map +1 -0
  159. package/dist/plugins/heading/HeadingInputRules.d.ts +5 -0
  160. package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -0
  161. package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts +5 -0
  162. package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -0
  163. package/dist/plugins/heading/HeadingPlugin.d.ts +1 -41
  164. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
  165. package/dist/plugins/heading.mjs +1 -1
  166. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  167. package/dist/plugins/highlight.mjs +1 -1
  168. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
  169. package/dist/plugins/horizontal-rule.mjs +1 -1
  170. package/dist/plugins/image/ImageCommands.d.ts.map +1 -1
  171. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  172. package/dist/plugins/image.mjs +1 -1
  173. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  174. package/dist/plugins/link.mjs +1 -1
  175. package/dist/plugins/list/ListPlugin.d.ts +9 -0
  176. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  177. package/dist/plugins/list.mjs +1 -1
  178. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
  179. package/dist/plugins/print/PrintTypes.d.ts +5 -1
  180. package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
  181. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
  182. package/dist/plugins/shared/ColorValidation.d.ts +7 -0
  183. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
  184. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
  185. package/dist/plugins/strikethrough.mjs +1 -1
  186. package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
  187. package/dist/plugins/super-sub.mjs +1 -1
  188. package/dist/plugins/table/TableCommands.d.ts.map +1 -1
  189. package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
  190. package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
  191. package/dist/plugins/table.mjs +1 -1
  192. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  193. package/dist/plugins/text-color.mjs +1 -1
  194. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
  195. package/dist/plugins/text-formatting.mjs +1 -1
  196. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
  197. package/dist/plugins/toolbar/ToolbarLocale.d.ts +1 -0
  198. package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -1
  199. package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts +23 -0
  200. package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts.map +1 -0
  201. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +56 -0
  202. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -0
  203. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +17 -0
  204. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  205. package/dist/plugins/toolbar/ToolbarRegistry.d.ts +12 -0
  206. package/dist/plugins/toolbar/ToolbarRegistry.d.ts.map +1 -0
  207. package/dist/plugins/toolbar.mjs +2 -2
  208. package/dist/state/EditorState.d.ts.map +1 -1
  209. package/dist/state/History.d.ts.map +1 -1
  210. package/dist/state/ReadonlyGuard.d.ts +6 -0
  211. package/dist/state/ReadonlyGuard.d.ts.map +1 -0
  212. package/dist/state/SelectionTransactions.d.ts +10 -0
  213. package/dist/state/SelectionTransactions.d.ts.map +1 -0
  214. package/dist/state/Transaction.d.ts +4 -0
  215. package/dist/state/Transaction.d.ts.map +1 -1
  216. package/dist/test/TestUtils.d.ts +23 -0
  217. package/dist/test/TestUtils.d.ts.map +1 -1
  218. package/dist/view/CaretNavigation.d.ts +48 -0
  219. package/dist/view/CaretNavigation.d.ts.map +1 -0
  220. package/dist/view/CursorWrapper.d.ts +19 -0
  221. package/dist/view/CursorWrapper.d.ts.map +1 -0
  222. package/dist/view/DomPointUtils.d.ts +20 -0
  223. package/dist/view/DomPointUtils.d.ts.map +1 -0
  224. package/dist/view/EditorView.d.ts +45 -0
  225. package/dist/view/EditorView.d.ts.map +1 -1
  226. package/dist/view/MarkRendering.d.ts +7 -0
  227. package/dist/view/MarkRendering.d.ts.map +1 -0
  228. package/dist/view/NodeViewRegistry.d.ts +9 -0
  229. package/dist/view/NodeViewRegistry.d.ts.map +1 -0
  230. package/dist/view/Platform.d.ts +29 -0
  231. package/dist/view/Platform.d.ts.map +1 -0
  232. package/dist/view/Reconciler.d.ts +4 -0
  233. package/dist/view/Reconciler.d.ts.map +1 -1
  234. package/dist/view/SelectionSync.d.ts +2 -0
  235. package/dist/view/SelectionSync.d.ts.map +1 -1
  236. package/dist/view/ViewMovementCommands.d.ts +40 -0
  237. package/dist/view/ViewMovementCommands.d.ts.map +1 -0
  238. package/package.json +10 -2
  239. package/dist/chunks/ColorNames-iaWsSZx1.mjs +0 -35
  240. package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +0 -1
  241. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +0 -140
  242. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +0 -1
  243. package/dist/chunks/Commands-CSpSwGXv.mjs +0 -461
  244. package/dist/chunks/Commands-CSpSwGXv.mjs.map +0 -1
  245. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +0 -7
  246. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +0 -1
  247. package/dist/chunks/Selection-D5ZjXoB7.mjs +0 -44
  248. package/dist/chunks/Selection-D5ZjXoB7.mjs.map +0 -1
  249. package/dist/chunks/ToolbarItem-ugDymuXi.mjs +0 -7
  250. package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +0 -1
  251. package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs +0 -368
  252. package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +0 -1
  253. package/dist/chunks/index-BAk1EG1x.mjs.map +0 -1
  254. package/dist/chunks/index-BRYzYOYC.mjs.map +0 -1
  255. package/dist/chunks/index-BSFLNveF.mjs.map +0 -1
  256. package/dist/chunks/index-BYgspns5.mjs.map +0 -1
  257. package/dist/chunks/index-B_3qDrUN.mjs +0 -64
  258. package/dist/chunks/index-B_3qDrUN.mjs.map +0 -1
  259. package/dist/chunks/index-Bsp4LC5t.mjs.map +0 -1
  260. package/dist/chunks/index-Ct0ivLhO.mjs.map +0 -1
  261. package/dist/chunks/index-CxiWyUho.mjs.map +0 -1
  262. package/dist/chunks/index-D3CQWJiw.mjs.map +0 -1
  263. package/dist/chunks/index-DC1EK22F.mjs.map +0 -1
  264. package/dist/chunks/index-Dh76rR13.mjs +0 -196
  265. package/dist/chunks/index-Dh76rR13.mjs.map +0 -1
  266. package/dist/chunks/index-o6hDR07y.mjs.map +0 -1
  267. package/dist/chunks/index-uTnc9y7M.mjs.map +0 -1
  268. package/dist/input/SourceNormalizer.d.ts +0 -7
  269. package/dist/input/SourceNormalizer.d.ts.map +0 -1
@@ -0,0 +1,467 @@
1
+ import { l as n, b as t, v as o, p as e } from "./Document-CuwE73FF.mjs";
2
+ import { c as r, i } from "./NavigationUtils-CyW0Vo8A.mjs";
3
+ import { i as l, a as c, b as a } from "./Selection-DmFDwiPJ.mjs";
4
+ import { i as s, m as f, j as u, g as d, r as h, c as k } from "./CaretNavigation-CAJXoaae.mjs";
5
+ import { m } from "./TypeBrands-C09nE2qO.mjs";
6
+ import { b as w } from "./MarkCommands-CC37WA7Z.mjs";
7
+ import { i as b, g } from "./Platform-S_xqIqcM.mjs";
8
+ const I = "undefined" != typeof Intl && "Segmenter" in Intl ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
9
+ function v(n2, t2) {
10
+ if (t2 >= n2.length || 0 === n2.length) return 0;
11
+ if (I) {
12
+ for (const o2 of I.segment(n2)) if (o2.index >= t2) return o2.segment.length;
13
+ return 0;
14
+ }
15
+ return 1;
16
+ }
17
+ function x(n2, t2) {
18
+ if (t2 <= 0 || 0 === n2.length) return 0;
19
+ if (I) {
20
+ let o2 = 1;
21
+ for (const e2 of I.segment(n2)) {
22
+ if (e2.index + e2.segment.length >= t2) {
23
+ o2 = e2.segment.length;
24
+ break;
25
+ }
26
+ o2 = e2.segment.length;
27
+ }
28
+ return o2;
29
+ }
30
+ return 1;
31
+ }
32
+ function y(t2, o2) {
33
+ let e2 = o2 - 1;
34
+ for (; e2 >= 0; ) {
35
+ const o3 = n(t2, e2);
36
+ if (!o3 || "inline" === o3.kind) break;
37
+ if (!/\s/.test(o3.char)) break;
38
+ e2--;
39
+ }
40
+ if (e2 >= 0) {
41
+ const o3 = n(t2, e2);
42
+ if ("inline" === o3?.kind) return e2;
43
+ }
44
+ for (; e2 >= 0; ) {
45
+ const o3 = n(t2, e2);
46
+ if (!o3 || "inline" === o3.kind) break;
47
+ if (/\s/.test(o3.char)) break;
48
+ e2--;
49
+ }
50
+ return e2 + 1;
51
+ }
52
+ function B(o2, e2) {
53
+ const r2 = t(o2);
54
+ let i2 = e2;
55
+ for (; i2 < r2; ) {
56
+ const t2 = n(o2, i2);
57
+ if (!t2 || "inline" === t2.kind) break;
58
+ if (/\s/.test(t2.char)) break;
59
+ i2++;
60
+ }
61
+ if (i2 === e2 && i2 < r2) {
62
+ const t2 = n(o2, i2);
63
+ if ("inline" === t2?.kind) return i2 + 1;
64
+ }
65
+ for (; i2 < r2; ) {
66
+ const t2 = n(o2, i2);
67
+ if (!t2 || "inline" === t2.kind) break;
68
+ if (!/\s/.test(t2.char)) break;
69
+ i2++;
70
+ }
71
+ return i2;
72
+ }
73
+ function p(n2) {
74
+ const t2 = n2.selection;
75
+ return l(t2) || c(t2) ? null : { blockId: t2.head.blockId, offset: t2.head.offset };
76
+ }
77
+ function A(n2, t2, o2) {
78
+ const e2 = n2.getBlockOrder(), r2 = e2.indexOf(t2);
79
+ if (r2 < 0) return null;
80
+ const i2 = "forward" === o2 ? r2 + 1 : r2 - 1;
81
+ return i2 < 0 || i2 >= e2.length ? null : e2[i2] ?? null;
82
+ }
83
+ function C(s2) {
84
+ const d2 = s2.selection;
85
+ if (l(d2) || c(d2)) return null;
86
+ if (!a(d2)) return f(s2, d2.head.blockId, d2.head.offset);
87
+ const h2 = d2.anchor.blockId, k2 = s2.getBlock(h2);
88
+ if (!k2) return null;
89
+ const m2 = d2.anchor.offset;
90
+ if (m2 < t(k2)) {
91
+ const t2 = n(k2, m2);
92
+ if ("inline" === t2?.kind) return f(s2, h2, m2 + 1);
93
+ const r2 = v(e(k2), o(k2, m2)) || 1;
94
+ return f(s2, h2, m2 + r2);
95
+ }
96
+ const w2 = A(s2, h2, "forward");
97
+ return w2 && r(s2, h2, w2) ? i(s2, w2) ? u(s2, w2) : f(s2, w2, 0) : null;
98
+ }
99
+ function M(s2) {
100
+ const d2 = s2.selection;
101
+ if (l(d2) || c(d2)) return null;
102
+ if (!a(d2)) return f(s2, d2.head.blockId, d2.head.offset);
103
+ const h2 = d2.anchor.blockId, k2 = s2.getBlock(h2);
104
+ if (!k2) return null;
105
+ const m2 = d2.anchor.offset;
106
+ if (m2 > 0) {
107
+ const t2 = n(k2, m2 - 1);
108
+ if ("inline" === t2?.kind) return f(s2, h2, m2 - 1);
109
+ const r2 = x(e(k2), o(k2, m2)) || 1;
110
+ return f(s2, h2, m2 - r2);
111
+ }
112
+ const w2 = A(s2, h2, "backward");
113
+ if (!w2) return null;
114
+ if (!r(s2, h2, w2)) return null;
115
+ if (i(s2, w2)) return u(s2, w2);
116
+ const b2 = s2.getBlock(w2);
117
+ return b2 ? f(s2, w2, t(b2)) : null;
118
+ }
119
+ function S(n2) {
120
+ const t2 = n2.selection;
121
+ if (l(t2) || c(t2)) return null;
122
+ const o2 = a(t2) ? t2.anchor.blockId : t2.head.blockId;
123
+ return 0 === (a(t2) ? t2.anchor.offset : t2.head.offset) ? null : f(n2, o2, 0);
124
+ }
125
+ function E(n2) {
126
+ const o2 = n2.selection;
127
+ if (l(o2) || c(o2)) return null;
128
+ const e2 = a(o2) ? o2.anchor.blockId : o2.head.blockId, r2 = n2.getBlock(e2);
129
+ if (!r2) return null;
130
+ const i2 = t(r2);
131
+ return (a(o2) ? o2.anchor.offset : o2.head.offset) === i2 ? null : f(n2, e2, i2);
132
+ }
133
+ function T(n2) {
134
+ const t2 = n2.selection;
135
+ if (l(t2) || c(t2)) return null;
136
+ const o2 = n2.getBlockOrder()[0];
137
+ return o2 ? i(n2, o2) ? u(n2, o2) : f(n2, o2, 0) : null;
138
+ }
139
+ function V(n2) {
140
+ const o2 = n2.selection;
141
+ if (l(o2) || c(o2)) return null;
142
+ const e2 = n2.getBlockOrder(), r2 = e2[e2.length - 1];
143
+ if (!r2) return null;
144
+ if (i(n2, r2)) return u(n2, r2);
145
+ const a2 = n2.getBlock(r2);
146
+ return a2 ? f(n2, r2, t(a2)) : null;
147
+ }
148
+ function O(i2) {
149
+ const a2 = p(i2);
150
+ if (!a2) return null;
151
+ const f2 = i2.selection;
152
+ if (l(f2) || c(f2)) return null;
153
+ const u2 = i2.getBlock(a2.blockId);
154
+ if (!u2) return null;
155
+ const d2 = t(u2);
156
+ if (a2.offset < d2) {
157
+ const t2 = n(u2, a2.offset), r2 = "inline" === t2?.kind ? 1 : v(e(u2), o(u2, a2.offset)) || 1;
158
+ return s(i2, f2.anchor.blockId, f2.anchor.offset, a2.blockId, a2.offset + r2);
159
+ }
160
+ const h2 = A(i2, a2.blockId, "forward");
161
+ return h2 && r(i2, a2.blockId, h2) ? s(i2, f2.anchor.blockId, f2.anchor.offset, h2, 0) : null;
162
+ }
163
+ function L(i2) {
164
+ const a2 = p(i2);
165
+ if (!a2) return null;
166
+ const f2 = i2.selection;
167
+ if (l(f2) || c(f2)) return null;
168
+ if (a2.offset > 0) {
169
+ const t2 = i2.getBlock(a2.blockId);
170
+ if (!t2) return null;
171
+ const r2 = n(t2, a2.offset - 1), l2 = "inline" === r2?.kind ? 1 : x(e(t2), o(t2, a2.offset)) || 1;
172
+ return s(i2, f2.anchor.blockId, f2.anchor.offset, a2.blockId, a2.offset - l2);
173
+ }
174
+ const u2 = A(i2, a2.blockId, "backward");
175
+ if (!u2) return null;
176
+ if (!r(i2, a2.blockId, u2)) return null;
177
+ const d2 = i2.getBlock(u2);
178
+ return d2 ? s(i2, f2.anchor.blockId, f2.anchor.offset, u2, t(d2)) : null;
179
+ }
180
+ function H(n2) {
181
+ const t2 = p(n2);
182
+ if (!t2) return null;
183
+ const o2 = n2.selection;
184
+ return l(o2) || c(o2) || 0 === t2.offset ? null : s(n2, o2.anchor.blockId, o2.anchor.offset, t2.blockId, 0);
185
+ }
186
+ function D(n2) {
187
+ const o2 = p(n2);
188
+ if (!o2) return null;
189
+ const e2 = n2.selection;
190
+ if (l(e2) || c(e2)) return null;
191
+ const r2 = n2.getBlock(o2.blockId);
192
+ if (!r2) return null;
193
+ const i2 = t(r2);
194
+ return o2.offset === i2 ? null : s(n2, e2.anchor.blockId, e2.anchor.offset, o2.blockId, i2);
195
+ }
196
+ function j(n2) {
197
+ const t2 = n2.selection;
198
+ if (l(t2) || c(t2)) return null;
199
+ const o2 = n2.getBlockOrder()[0];
200
+ return o2 ? t2.head.blockId === o2 && 0 === t2.head.offset ? null : s(n2, t2.anchor.blockId, t2.anchor.offset, o2, 0) : null;
201
+ }
202
+ function R(n2) {
203
+ const o2 = n2.selection;
204
+ if (l(o2) || c(o2)) return null;
205
+ const e2 = n2.getBlockOrder(), r2 = e2[e2.length - 1];
206
+ if (!r2) return null;
207
+ const i2 = n2.getBlock(r2);
208
+ if (!i2) return null;
209
+ const a2 = t(i2);
210
+ return o2.head.blockId === r2 && o2.head.offset === a2 ? null : s(n2, o2.anchor.blockId, o2.anchor.offset, r2, a2);
211
+ }
212
+ function z(o2, e2, a2, s2) {
213
+ const k2 = e2.selection;
214
+ if (l(k2) || c(k2)) return null;
215
+ const m2 = d(o2);
216
+ if (!m2?.modify) return $(e2, a2, s2);
217
+ const w2 = m2.anchorNode, b2 = m2.anchorOffset, g2 = m2.focusNode, I2 = m2.focusOffset;
218
+ if (!w2 || !g2) return $(e2, a2, s2);
219
+ try {
220
+ m2.modify("move", a2, s2);
221
+ const l2 = h(o2);
222
+ if (!l2) return null;
223
+ const c2 = l2.anchor.blockId, d2 = k2.anchor.blockId;
224
+ if (c2 !== d2 && !r(e2, d2, c2)) return null;
225
+ let w3 = l2.anchor.offset;
226
+ const b3 = e2.getBlock(c2);
227
+ if (b3) {
228
+ const o3 = n(b3, w3);
229
+ "inline" === o3?.kind && "forward" === a2 && (w3 = Math.min(w3 + 1, t(b3)));
230
+ }
231
+ return i(e2, c2) ? u(e2, c2) : f(e2, c2, w3);
232
+ } finally {
233
+ try {
234
+ m2.setBaseAndExtent(w2, b2, g2, I2);
235
+ } catch {
236
+ }
237
+ }
238
+ }
239
+ function N(o2, e2, i2, a2) {
240
+ const f2 = e2.selection;
241
+ if (l(f2) || c(f2)) return null;
242
+ const u2 = d(o2);
243
+ if (!u2?.modify) return U(e2, i2, a2);
244
+ const k2 = u2.anchorNode, m2 = u2.anchorOffset, w2 = u2.focusNode, b2 = u2.focusOffset;
245
+ if (!k2 || !w2) return U(e2, i2, a2);
246
+ try {
247
+ u2.modify("extend", i2, a2);
248
+ const l2 = h(o2);
249
+ if (!l2) return null;
250
+ const c2 = f2.head.blockId, d2 = l2.head.blockId;
251
+ if (d2 !== c2 && !r(e2, c2, d2)) return null;
252
+ let k3 = l2.head.offset;
253
+ const m3 = e2.getBlock(l2.head.blockId);
254
+ if (m3) {
255
+ const o3 = n(m3, k3);
256
+ "inline" === o3?.kind && "forward" === i2 && (k3 = Math.min(k3 + 1, t(m3)));
257
+ }
258
+ return s(e2, f2.anchor.blockId, f2.anchor.offset, l2.head.blockId, k3);
259
+ } finally {
260
+ try {
261
+ u2.setBaseAndExtent(k2, m2, w2, b2);
262
+ } catch {
263
+ }
264
+ }
265
+ }
266
+ function $(n2, o2, e2) {
267
+ return "word" === e2 ? (function(n3, o3) {
268
+ const e3 = n3.selection;
269
+ if (l(e3) || c(e3)) return null;
270
+ const s2 = a(e3) ? e3.anchor.blockId : e3.head.blockId, d2 = a(e3) ? e3.anchor.offset : e3.head.offset, h2 = n3.getBlock(s2);
271
+ if (!h2) return null;
272
+ const k2 = "forward" === o3 ? B(h2, d2) : y(h2, d2);
273
+ return k2 === d2 ? (function(n4, o4, e4) {
274
+ const l2 = n4.getBlockOrder(), c2 = l2.indexOf(o4), a2 = "forward" === e4 ? c2 + 1 : c2 - 1;
275
+ if (a2 < 0 || a2 >= l2.length) return null;
276
+ const s3 = l2[a2];
277
+ if (!s3) return null;
278
+ if (!r(n4, o4, s3)) return null;
279
+ if (i(n4, s3)) return u(n4, s3);
280
+ const d3 = n4.getBlock(s3);
281
+ if (!d3) return null;
282
+ const h3 = "forward" === e4 ? 0 : t(d3);
283
+ return f(n4, s3, h3);
284
+ })(n3, s2, o3) : f(n3, s2, k2);
285
+ })(n2, o2) : "lineboundary" === e2 ? "forward" === o2 ? E(n2) : S(n2) : k(n2, "forward" === o2 ? "down" : "up");
286
+ }
287
+ function U(n2, o2, e2) {
288
+ const a2 = n2.selection;
289
+ if (l(a2) || c(a2)) return null;
290
+ const f2 = a2.head, u2 = n2.getBlock(f2.blockId);
291
+ if (!u2) return null;
292
+ let d2 = f2.offset;
293
+ if ("word" === e2) d2 = "forward" === o2 ? B(u2, f2.offset) : y(u2, f2.offset);
294
+ else {
295
+ if ("lineboundary" !== e2) {
296
+ const e3 = n2.getBlockOrder(), l2 = e3.indexOf(f2.blockId), c2 = "forward" === o2 ? l2 + 1 : l2 - 1;
297
+ if (c2 < 0 || c2 >= e3.length) return null;
298
+ const u3 = e3[c2];
299
+ if (!u3) return null;
300
+ if (!r(n2, f2.blockId, u3)) return null;
301
+ if (i(n2, u3)) return null;
302
+ const d3 = n2.getBlock(u3);
303
+ if (!d3) return null;
304
+ const h2 = "forward" === o2 ? 0 : t(d3);
305
+ return s(n2, a2.anchor.blockId, a2.anchor.offset, u3, h2);
306
+ }
307
+ d2 = "forward" === o2 ? t(u2) : 0;
308
+ }
309
+ return s(n2, a2.anchor.blockId, a2.anchor.offset, f2.blockId, d2);
310
+ }
311
+ function q(n2, t2) {
312
+ return z(n2, t2, "forward", "word");
313
+ }
314
+ function _(n2, t2) {
315
+ return z(n2, t2, "backward", "word");
316
+ }
317
+ function P(n2, t2) {
318
+ return z(n2, t2, "backward", "lineboundary");
319
+ }
320
+ function F(n2, t2) {
321
+ return z(n2, t2, "forward", "lineboundary");
322
+ }
323
+ function G(n2, t2) {
324
+ return z(n2, t2, "backward", "line");
325
+ }
326
+ function K(n2, t2) {
327
+ return z(n2, t2, "forward", "line");
328
+ }
329
+ function Q(n2, t2) {
330
+ return N(n2, t2, "forward", "word");
331
+ }
332
+ function J(n2, t2) {
333
+ return N(n2, t2, "backward", "word");
334
+ }
335
+ function W(n2, t2) {
336
+ return N(n2, t2, "backward", "lineboundary");
337
+ }
338
+ function X(n2, t2) {
339
+ return N(n2, t2, "forward", "lineboundary");
340
+ }
341
+ function Y(n2, t2) {
342
+ return N(n2, t2, "backward", "line");
343
+ }
344
+ function Z(n2, t2) {
345
+ return N(n2, t2, "forward", "line");
346
+ }
347
+ const nn = { paragraph: "Paragraph", heading: "Heading", code_block: "Code Block", blockquote: "Block Quote", list_item: "List Item", horizontal_rule: "Horizontal Rule", image: "Image", table: "Table" };
348
+ function tn(n2, t2) {
349
+ return "heading" === n2 && t2?.level ? `Heading ${t2.level}` : nn[n2] ?? n2;
350
+ }
351
+ function on(n2, t2, o2) {
352
+ if ("undo" === o2.metadata.historyDirection) return "Undo";
353
+ if ("redo" === o2.metadata.historyDirection) return "Redo";
354
+ for (const n3 of o2.steps) if ("setBlockType" === n3.type) return tn(n3.nodeType, n3.attrs);
355
+ for (const o3 of t2.schema.markTypes) {
356
+ const e2 = m(o3), r2 = w(n2, e2), i2 = w(t2, e2);
357
+ if (r2 !== i2) return `${o3} ${i2 ? "on" : "off"}`;
358
+ }
359
+ return null;
360
+ }
361
+ const en = { "word:forward": q, "word:backward": _, "lineboundary:forward": F, "lineboundary:backward": P, "line:forward": K, "line:backward": G }, rn = { "word:forward": Q, "word:backward": J, "lineboundary:forward": X, "lineboundary:backward": W, "line:forward": Z, "line:backward": Y };
362
+ class ln {
363
+ id = "caret-navigation";
364
+ name = "Caret Navigation";
365
+ priority = 4;
366
+ context = null;
367
+ lastAnnouncedBlockId = null;
368
+ announceTimer = null;
369
+ announce = null;
370
+ init(n2) {
371
+ this.context = n2, this.announce = (t3) => n2.announce(t3);
372
+ const t2 = b(), o2 = { "Shift-ArrowRight": () => this.extendCharacterVisual("right"), "Shift-ArrowLeft": () => this.extendCharacterVisual("left"), "Shift-ArrowUp": () => this.viewExtendCommand("backward", "line"), "Shift-ArrowDown": () => this.viewExtendCommand("forward", "line"), ...t2 ? { "Alt-ArrowRight": () => this.viewMoveVisual("right", "word"), "Alt-ArrowLeft": () => this.viewMoveVisual("left", "word"), "Shift-Alt-ArrowRight": () => this.viewExtendVisual("right", "word"), "Shift-Alt-ArrowLeft": () => this.viewExtendVisual("left", "word") } : { "Mod-ArrowRight": () => this.viewMoveVisual("right", "word"), "Mod-ArrowLeft": () => this.viewMoveVisual("left", "word"), "Mod-Shift-ArrowRight": () => this.viewExtendVisual("right", "word"), "Mod-Shift-ArrowLeft": () => this.viewExtendVisual("left", "word") }, ...t2 ? { "Mod-ArrowLeft": () => this.viewMoveVisual("left", "lineboundary"), "Mod-ArrowRight": () => this.viewMoveVisual("right", "lineboundary"), "Mod-Shift-ArrowLeft": () => this.viewExtendVisual("left", "lineboundary"), "Mod-Shift-ArrowRight": () => this.viewExtendVisual("right", "lineboundary") } : { Home: () => this.viewMoveCommand("backward", "lineboundary"), End: () => this.viewMoveCommand("forward", "lineboundary"), "Shift-Home": () => this.viewExtendCommand("backward", "lineboundary"), "Shift-End": () => this.viewExtendCommand("forward", "lineboundary") }, ...t2 ? { "Mod-ArrowUp": () => this.modelCommand(T), "Mod-ArrowDown": () => this.modelCommand(V), "Mod-Shift-ArrowUp": () => this.modelCommand(j), "Mod-Shift-ArrowDown": () => this.modelCommand(R) } : { "Mod-Home": () => this.modelCommand(T), "Mod-End": () => this.modelCommand(V), "Mod-Shift-Home": () => this.modelCommand(j), "Mod-Shift-End": () => this.modelCommand(R) } };
373
+ n2.registerKeymap(o2, { priority: "navigation" });
374
+ }
375
+ onStateChange(n2, t2, o2) {
376
+ const e2 = t2.selection;
377
+ if (!a(e2) || l(e2) || c(e2)) return null !== this.announceTimer && (clearTimeout(this.announceTimer), this.announceTimer = null), void (this.lastAnnouncedBlockId = null);
378
+ const r2 = e2.anchor.blockId;
379
+ r2 !== this.lastAnnouncedBlockId && (null !== this.lastAnnouncedBlockId ? (this.lastAnnouncedBlockId = r2, null !== this.announceTimer && clearTimeout(this.announceTimer), this.announceTimer = setTimeout(() => {
380
+ if (this.announceTimer = null, this.context?.hasAnnouncement()) return;
381
+ const n3 = t2.getBlock(r2);
382
+ if (!n3) return;
383
+ const o3 = tn(n3.type, n3.attrs);
384
+ this.announce?.(o3);
385
+ }, 150)) : this.lastAnnouncedBlockId = r2);
386
+ }
387
+ destroy() {
388
+ null !== this.announceTimer && clearTimeout(this.announceTimer), this.announceTimer = null, this.announce = null, this.context = null;
389
+ }
390
+ modelCommand(n2) {
391
+ if (!this.context) return false;
392
+ const t2 = n2(this.context.getState());
393
+ return !!t2 && (this.context.dispatch(t2), true);
394
+ }
395
+ extendCharacterVisual(n2) {
396
+ if (!this.context) return false;
397
+ const t2 = this.context.getState(), o2 = "forward" === this.resolveLogicalHorizontalDirection(t2, n2) ? O(t2) : L(t2);
398
+ return !!o2 && (this.context.dispatch(o2), true);
399
+ }
400
+ viewMoveCommand(n2, t2) {
401
+ return this.dispatchViewCommand(en, n2, t2);
402
+ }
403
+ viewMoveVisual(n2, t2) {
404
+ if (!this.context) return false;
405
+ const o2 = this.resolveLogicalHorizontalDirection(this.context.getState(), n2);
406
+ return this.viewMoveCommand(o2, t2);
407
+ }
408
+ viewExtendCommand(n2, t2) {
409
+ return this.dispatchViewCommand(rn, n2, t2);
410
+ }
411
+ dispatchViewCommand(n2, t2, o2) {
412
+ if (!this.context) return false;
413
+ const e2 = n2[`${o2}:${t2}`];
414
+ if (!e2) return false;
415
+ const r2 = e2(this.context.getContainer(), this.context.getState());
416
+ return !!r2 && (this.context.dispatch(r2), true);
417
+ }
418
+ viewExtendVisual(n2, t2) {
419
+ if (!this.context) return false;
420
+ const o2 = this.resolveLogicalHorizontalDirection(this.context.getState(), n2);
421
+ return this.viewExtendCommand(o2, t2);
422
+ }
423
+ resolveLogicalHorizontalDirection(n2, t2) {
424
+ const o2 = n2.selection;
425
+ if (l(o2) || c(o2)) return "left" === t2 ? "backward" : "forward";
426
+ const e2 = this.context?.getContainer();
427
+ if (!e2) return "left" === t2 ? "backward" : "forward";
428
+ const r2 = e2.querySelector(`[data-block-id="${o2.head.blockId}"]`);
429
+ return r2 instanceof HTMLElement && "rtl" === g(r2) ? "left" === t2 ? "forward" : "backward" : "left" === t2 ? "backward" : "forward";
430
+ }
431
+ }
432
+ export {
433
+ _ as A,
434
+ q as B,
435
+ ln as C,
436
+ v as D,
437
+ x as E,
438
+ N as F,
439
+ z as G,
440
+ y as a,
441
+ on as b,
442
+ O as c,
443
+ Z as d,
444
+ L as e,
445
+ B as f,
446
+ Y as g,
447
+ D as h,
448
+ H as i,
449
+ R as j,
450
+ j as k,
451
+ X as l,
452
+ W as m,
453
+ J as n,
454
+ Q as o,
455
+ tn as p,
456
+ M as q,
457
+ C as r,
458
+ K as s,
459
+ G as t,
460
+ E as u,
461
+ S as v,
462
+ V as w,
463
+ T as x,
464
+ F as y,
465
+ P as z
466
+ };
467
+ //# sourceMappingURL=index--z_Txzej.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index--z_Txzej.mjs","sources":["../../src/model/GraphemeUtils.ts","../../src/commands/WordBoundary.ts","../../src/commands/MovementCommands.ts","../../src/view/ViewMovementCommands.ts","../../src/editor/Announcer.ts","../../src/plugins/caret-navigation/CaretNavigationPlugin.ts"],"sourcesContent":["/**\n * Grapheme-cluster utilities for correct character navigation.\n *\n * Uses `Intl.Segmenter` (with `granularity: 'grapheme'`) to correctly\n * handle multi-code-unit characters such as emoji, ZWJ sequences, and\n * combining characters. Falls back to +1/-1 when `Intl.Segmenter` is\n * not available.\n */\n\nconst SEGMENTER_SUPPORTED: boolean = typeof Intl !== 'undefined' && 'Segmenter' in Intl;\nconst SEGMENTER: Intl.Segmenter | null = SEGMENTER_SUPPORTED\n\t? new Intl.Segmenter(undefined, { granularity: 'grapheme' })\n\t: null;\n\n/**\n * Returns the number of UTF-16 code units in the next grapheme cluster\n * starting at `offset`. Returns 0 if `offset` is at or past the end.\n */\nexport function nextGraphemeSize(text: string, offset: number): number {\n\tif (offset >= text.length || text.length === 0) return 0;\n\n\tif (SEGMENTER) {\n\t\tfor (const segment of SEGMENTER.segment(text)) {\n\t\t\tif (segment.index >= offset) {\n\t\t\t\treturn segment.segment.length;\n\t\t\t}\n\t\t}\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}\n\n/**\n * Returns the number of UTF-16 code units in the grapheme cluster\n * immediately before `offset`. Returns 0 if `offset` is 0 or the\n * string is empty.\n */\nexport function prevGraphemeSize(text: string, offset: number): number {\n\tif (offset <= 0 || text.length === 0) return 0;\n\n\tif (SEGMENTER) {\n\t\tlet lastSize = 1;\n\t\tfor (const segment of SEGMENTER.segment(text)) {\n\t\t\tif (segment.index + segment.segment.length >= offset) {\n\t\t\t\tlastSize = segment.segment.length;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlastSize = segment.segment.length;\n\t\t}\n\t\treturn lastSize;\n\t}\n\n\treturn 1;\n}\n","/**\n * Word boundary detection for delete-word and word-movement commands.\n * InlineNodes act as word boundaries.\n */\n\nimport { type BlockNode, getBlockLength, getContentAtOffset } from '../model/Document.js';\n\n/**\n * Finds the word boundary backward from the given offset.\n * InlineNodes act as word boundaries.\n */\nexport function findWordBoundaryBackward(block: BlockNode, offset: number): number {\n\tlet pos = offset - 1;\n\t// Skip trailing whitespace\n\twhile (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (!/\\s/.test(content.char)) break;\n\t\tpos--;\n\t}\n\t// If at InlineNode, delete just it (treat as word boundary)\n\tif (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (content?.kind === 'inline') return pos;\n\t}\n\t// Skip word characters until whitespace or InlineNode\n\twhile (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (/\\s/.test(content.char)) break;\n\t\tpos--;\n\t}\n\treturn pos + 1;\n}\n\n/**\n * Finds the word boundary forward from the given offset.\n * InlineNodes act as word boundaries.\n */\nexport function findWordBoundaryForward(block: BlockNode, offset: number): number {\n\tconst len = getBlockLength(block);\n\tlet pos = offset;\n\t// Skip word characters first\n\twhile (pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (/\\s/.test(content.char)) break;\n\t\tpos++;\n\t}\n\t// If at InlineNode and haven't moved, delete just the InlineNode\n\tif (pos === offset && pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (content?.kind === 'inline') return pos + 1;\n\t}\n\t// Skip trailing whitespace\n\twhile (pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (!/\\s/.test(content.char)) break;\n\t\tpos++;\n\t}\n\treturn pos;\n}\n","/**\n * Model-based movement commands for programmatic cursor navigation.\n *\n * All functions are pure: they take an EditorState and return a Transaction\n * or `null` (when the movement is not applicable). None touch the DOM.\n *\n * Move commands produce a collapsed cursor. Extend commands keep the anchor\n * and move the head, producing a range selection. All clear storedMarks.\n */\n\nimport {\n\tblockOffsetToTextOffset,\n\tgetBlockLength,\n\tgetBlockText,\n\tgetContentAtOffset,\n} from '../model/Document.js';\nimport { nextGraphemeSize, prevGraphemeSize } from '../model/GraphemeUtils.js';\nimport { canCrossBlockBoundary, isVoidBlock } from '../model/NavigationUtils.js';\nimport { isCollapsed, isGapCursor, isNodeSelection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { extendTx, moveTx, nodeSelTx } from '../state/SelectionTransactions.js';\nimport type { Transaction } from '../state/Transaction.js';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Resolves the effective head position from any text selection. */\nfunction resolveHead(state: EditorState): { blockId: BlockId; offset: number } | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\treturn { blockId: sel.head.blockId, offset: sel.head.offset };\n}\n\n/** Returns the adjacent block ID in the given direction, or `null`. */\nfunction adjacentBlockId(\n\tstate: EditorState,\n\tcurrentBlockId: BlockId,\n\tdirection: 'forward' | 'backward',\n): BlockId | null {\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst idx: number = blockOrder.indexOf(currentBlockId);\n\tif (idx < 0) return null;\n\tconst targetIdx: number = direction === 'forward' ? idx + 1 : idx - 1;\n\tif (targetIdx < 0 || targetIdx >= blockOrder.length) return null;\n\treturn blockOrder[targetIdx] ?? null;\n}\n\n// ---------------------------------------------------------------------------\n// Character Movement\n// ---------------------------------------------------------------------------\n\n/** Moves the cursor one character forward, skipping InlineNodes atomically. */\nexport function moveCharacterForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\t// If range selection, collapse to head\n\tif (!isCollapsed(sel)) {\n\t\treturn moveTx(state, sel.head.blockId, sel.head.offset);\n\t}\n\n\tconst blockId: BlockId = sel.anchor.blockId;\n\tconst block = state.getBlock(blockId);\n\tif (!block) return null;\n\n\tconst offset: number = sel.anchor.offset;\n\tconst blockLen: number = getBlockLength(block);\n\n\tif (offset < blockLen) {\n\t\t// InlineNode: skip atomically (+1)\n\t\tconst content = getContentAtOffset(block, offset);\n\t\tif (content?.kind === 'inline') {\n\t\t\treturn moveTx(state, blockId, offset + 1);\n\t\t}\n\t\t// Text: advance by one grapheme cluster\n\t\tconst text: string = getBlockText(block);\n\t\tconst textOffset: number = blockOffsetToTextOffset(block, offset);\n\t\tconst step: number = nextGraphemeSize(text, textOffset) || 1;\n\t\treturn moveTx(state, blockId, offset + step);\n\t}\n\n\t// At block end → cross-block\n\tconst nextId: BlockId | null = adjacentBlockId(state, blockId, 'forward');\n\tif (!nextId) return null;\n\tif (!canCrossBlockBoundary(state, blockId, nextId)) return null;\n\n\tif (isVoidBlock(state, nextId)) return nodeSelTx(state, nextId);\n\n\treturn moveTx(state, nextId, 0);\n}\n\n/** Moves the cursor one character backward, skipping InlineNodes atomically. */\nexport function moveCharacterBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\t// If range selection, collapse to head\n\tif (!isCollapsed(sel)) {\n\t\treturn moveTx(state, sel.head.blockId, sel.head.offset);\n\t}\n\n\tconst blockId: BlockId = sel.anchor.blockId;\n\tconst block = state.getBlock(blockId);\n\tif (!block) return null;\n\n\tconst offset: number = sel.anchor.offset;\n\n\tif (offset > 0) {\n\t\t// InlineNode: skip atomically (-1)\n\t\tconst content = getContentAtOffset(block, offset - 1);\n\t\tif (content?.kind === 'inline') {\n\t\t\treturn moveTx(state, blockId, offset - 1);\n\t\t}\n\t\t// Text: retreat by one grapheme cluster\n\t\tconst text: string = getBlockText(block);\n\t\tconst textOffset: number = blockOffsetToTextOffset(block, offset);\n\t\tconst step: number = prevGraphemeSize(text, textOffset) || 1;\n\t\treturn moveTx(state, blockId, offset - step);\n\t}\n\n\t// At block start → cross-block\n\tconst prevId: BlockId | null = adjacentBlockId(state, blockId, 'backward');\n\tif (!prevId) return null;\n\tif (!canCrossBlockBoundary(state, blockId, prevId)) return null;\n\n\tif (isVoidBlock(state, prevId)) return nodeSelTx(state, prevId);\n\n\tconst prevBlock = state.getBlock(prevId);\n\tif (!prevBlock) return null;\n\treturn moveTx(state, prevId, getBlockLength(prevBlock));\n}\n\n// ---------------------------------------------------------------------------\n// Block Boundary Movement\n// ---------------------------------------------------------------------------\n\n/** Moves the cursor to the start of the current block. */\nexport function moveToBlockStart(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst blockId: BlockId = isCollapsed(sel) ? sel.anchor.blockId : sel.head.blockId;\n\tconst offset: number = isCollapsed(sel) ? sel.anchor.offset : sel.head.offset;\n\n\tif (offset === 0) return null;\n\treturn moveTx(state, blockId, 0);\n}\n\n/** Moves the cursor to the end of the current block. */\nexport function moveToBlockEnd(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst blockId: BlockId = isCollapsed(sel) ? sel.anchor.blockId : sel.head.blockId;\n\tconst block = state.getBlock(blockId);\n\tif (!block) return null;\n\n\tconst blockLen: number = getBlockLength(block);\n\tconst offset: number = isCollapsed(sel) ? sel.anchor.offset : sel.head.offset;\n\n\tif (offset === blockLen) return null;\n\treturn moveTx(state, blockId, blockLen);\n}\n\n// ---------------------------------------------------------------------------\n// Document Boundary Movement\n// ---------------------------------------------------------------------------\n\n/** Moves the cursor to the beginning of the document. */\nexport function moveToDocumentStart(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst firstId: BlockId | undefined = blockOrder[0];\n\tif (!firstId) return null;\n\n\tif (isVoidBlock(state, firstId)) return nodeSelTx(state, firstId);\n\n\treturn moveTx(state, firstId, 0);\n}\n\n/** Moves the cursor to the end of the document. */\nexport function moveToDocumentEnd(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst lastId: BlockId | undefined = blockOrder[blockOrder.length - 1];\n\tif (!lastId) return null;\n\n\tif (isVoidBlock(state, lastId)) return nodeSelTx(state, lastId);\n\n\tconst lastBlock = state.getBlock(lastId);\n\tif (!lastBlock) return null;\n\treturn moveTx(state, lastId, getBlockLength(lastBlock));\n}\n\n// ---------------------------------------------------------------------------\n// Extend (Selection Extension) Commands\n// ---------------------------------------------------------------------------\n\n/** Extends the selection one character forward. */\nexport function extendCharacterForward(state: EditorState): Transaction | null {\n\tconst head = resolveHead(state);\n\tif (!head) return null;\n\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst block = state.getBlock(head.blockId);\n\tif (!block) return null;\n\n\tconst blockLen: number = getBlockLength(block);\n\n\tif (head.offset < blockLen) {\n\t\tconst content = getContentAtOffset(block, head.offset);\n\t\tconst step: number =\n\t\t\tcontent?.kind === 'inline'\n\t\t\t\t? 1\n\t\t\t\t: nextGraphemeSize(getBlockText(block), blockOffsetToTextOffset(block, head.offset)) || 1;\n\t\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, head.blockId, head.offset + step);\n\t}\n\n\t// Cross-block\n\tconst nextId: BlockId | null = adjacentBlockId(state, head.blockId, 'forward');\n\tif (!nextId) return null;\n\tif (!canCrossBlockBoundary(state, head.blockId, nextId)) return null;\n\n\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, nextId, 0);\n}\n\n/** Extends the selection one character backward. */\nexport function extendCharacterBackward(state: EditorState): Transaction | null {\n\tconst head = resolveHead(state);\n\tif (!head) return null;\n\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tif (head.offset > 0) {\n\t\tconst block = state.getBlock(head.blockId);\n\t\tif (!block) return null;\n\t\tconst content = getContentAtOffset(block, head.offset - 1);\n\t\tconst step: number =\n\t\t\tcontent?.kind === 'inline'\n\t\t\t\t? 1\n\t\t\t\t: prevGraphemeSize(getBlockText(block), blockOffsetToTextOffset(block, head.offset)) || 1;\n\t\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, head.blockId, head.offset - step);\n\t}\n\n\t// Cross-block\n\tconst prevId: BlockId | null = adjacentBlockId(state, head.blockId, 'backward');\n\tif (!prevId) return null;\n\tif (!canCrossBlockBoundary(state, head.blockId, prevId)) return null;\n\n\tconst prevBlock = state.getBlock(prevId);\n\tif (!prevBlock) return null;\n\n\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, prevId, getBlockLength(prevBlock));\n}\n\n/** Extends the selection to the start of the current block. */\nexport function extendToBlockStart(state: EditorState): Transaction | null {\n\tconst head = resolveHead(state);\n\tif (!head) return null;\n\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tif (head.offset === 0) return null;\n\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, head.blockId, 0);\n}\n\n/** Extends the selection to the end of the current block. */\nexport function extendToBlockEnd(state: EditorState): Transaction | null {\n\tconst head = resolveHead(state);\n\tif (!head) return null;\n\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst block = state.getBlock(head.blockId);\n\tif (!block) return null;\n\n\tconst blockLen: number = getBlockLength(block);\n\tif (head.offset === blockLen) return null;\n\n\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, head.blockId, blockLen);\n}\n\n/** Extends the selection to the start of the document. */\nexport function extendToDocumentStart(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst firstId: BlockId | undefined = blockOrder[0];\n\tif (!firstId) return null;\n\n\t// No-op if head is already at document start\n\tif (sel.head.blockId === firstId && sel.head.offset === 0) return null;\n\n\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, firstId, 0);\n}\n\n/** Extends the selection to the end of the document. */\nexport function extendToDocumentEnd(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst lastId: BlockId | undefined = blockOrder[blockOrder.length - 1];\n\tif (!lastId) return null;\n\n\tconst lastBlock = state.getBlock(lastId);\n\tif (!lastBlock) return null;\n\n\tconst lastBlockLen: number = getBlockLength(lastBlock);\n\n\t// No-op if head is already at document end\n\tif (sel.head.blockId === lastId && sel.head.offset === lastBlockLen) return null;\n\n\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, lastId, lastBlockLen);\n}\n","/**\n * View-based movement commands that use the browser's `Selection.modify()` API\n * for word, line-boundary, and line granularity movement.\n *\n * Falls back to model-based commands when `Selection.modify` is unavailable\n * (e.g. in happy-dom test environments).\n */\n\nimport { findWordBoundaryBackward, findWordBoundaryForward } from '../commands/Commands.js';\nimport { moveToBlockEnd, moveToBlockStart } from '../commands/MovementCommands.js';\nimport { getBlockLength, getContentAtOffset } from '../model/Document.js';\nimport { canCrossBlockBoundary, isVoidBlock } from '../model/NavigationUtils.js';\nimport { isCollapsed, isGapCursor, isNodeSelection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { extendTx, moveTx, nodeSelTx } from '../state/SelectionTransactions.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { navigateAcrossBlocks } from './CaretNavigation.js';\nimport { getSelection, readSelectionFromDOM } from './SelectionSync.js';\n\ntype Direction = 'forward' | 'backward';\ntype Granularity = 'word' | 'lineboundary' | 'line';\n\n// ---------------------------------------------------------------------------\n// Core view movement\n// ---------------------------------------------------------------------------\n\n/**\n * Moves the cursor using `Selection.modify('move', direction, granularity)`.\n * Falls back to model-based movement when the API is unavailable.\n */\nexport function viewMove(\n\tcontainer: HTMLElement,\n\tstate: EditorState,\n\tdirection: Direction,\n\tgranularity: Granularity,\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst domSel: globalThis.Selection | null = getSelection(container);\n\tif (!domSel?.modify) {\n\t\treturn fallbackMove(state, direction, granularity);\n\t}\n\n\t// Save original DOM selection\n\tconst origAnchor: Node | null = domSel.anchorNode;\n\tconst origAnchorOff: number = domSel.anchorOffset;\n\tconst origFocus: Node | null = domSel.focusNode;\n\tconst origFocusOff: number = domSel.focusOffset;\n\tif (!origAnchor || !origFocus) return fallbackMove(state, direction, granularity);\n\n\ttry {\n\t\tdomSel.modify('move', direction, granularity);\n\n\t\tconst newSel = readSelectionFromDOM(container);\n\t\tif (!newSel) return null;\n\n\t\tconst newBlockId: BlockId = newSel.anchor.blockId;\n\t\tconst oldBlockId: BlockId = sel.anchor.blockId;\n\n\t\t// Validate isolating boundary crossing\n\t\tif (newBlockId !== oldBlockId && !canCrossBlockBoundary(state, oldBlockId, newBlockId)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet newOffset: number = newSel.anchor.offset;\n\n\t\t// InlineNode boundary correction\n\t\tconst block = state.getBlock(newBlockId);\n\t\tif (block) {\n\t\t\tconst content = getContentAtOffset(block, newOffset);\n\t\t\tif (content?.kind === 'inline') {\n\t\t\t\t// Prefer landing after the InlineNode when moving forward\n\t\t\t\tif (direction === 'forward') {\n\t\t\t\t\tnewOffset = Math.min(newOffset + 1, getBlockLength(block));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Void block → NodeSelection\n\t\tif (isVoidBlock(state, newBlockId)) return nodeSelTx(state, newBlockId);\n\n\t\treturn moveTx(state, newBlockId, newOffset);\n\t} finally {\n\t\t// Restore original DOM selection (dispatch cycle will set the correct one)\n\t\ttry {\n\t\t\tdomSel.setBaseAndExtent(origAnchor, origAnchorOff, origFocus, origFocusOff);\n\t\t} catch {\n\t\t\t// Restore may fail if DOM changed\n\t\t}\n\t}\n}\n\n/**\n * Extends the selection using `Selection.modify('extend', direction, granularity)`.\n * Falls back to model-based extension when the API is unavailable.\n */\nexport function viewExtend(\n\tcontainer: HTMLElement,\n\tstate: EditorState,\n\tdirection: Direction,\n\tgranularity: Granularity,\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst domSel: globalThis.Selection | null = getSelection(container);\n\tif (!domSel?.modify) {\n\t\treturn fallbackExtend(state, direction, granularity);\n\t}\n\n\tconst origAnchor: Node | null = domSel.anchorNode;\n\tconst origAnchorOff: number = domSel.anchorOffset;\n\tconst origFocus: Node | null = domSel.focusNode;\n\tconst origFocusOff: number = domSel.focusOffset;\n\tif (!origAnchor || !origFocus) return fallbackExtend(state, direction, granularity);\n\n\ttry {\n\t\tdomSel.modify('extend', direction, granularity);\n\n\t\tconst newSel = readSelectionFromDOM(container);\n\t\tif (!newSel) return null;\n\n\t\t// Validate isolating boundary crossing for head\n\t\tconst oldHeadBlockId: BlockId = sel.head.blockId;\n\t\tconst newHeadBlockId: BlockId = newSel.head.blockId;\n\n\t\tif (\n\t\t\tnewHeadBlockId !== oldHeadBlockId &&\n\t\t\t!canCrossBlockBoundary(state, oldHeadBlockId, newHeadBlockId)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet newHeadOffset: number = newSel.head.offset;\n\n\t\t// InlineNode boundary correction for head position\n\t\tconst headBlock = state.getBlock(newSel.head.blockId);\n\t\tif (headBlock) {\n\t\t\tconst content = getContentAtOffset(headBlock, newHeadOffset);\n\t\t\tif (content?.kind === 'inline') {\n\t\t\t\tif (direction === 'forward') {\n\t\t\t\t\tnewHeadOffset = Math.min(newHeadOffset + 1, getBlockLength(headBlock));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn extendTx(\n\t\t\tstate,\n\t\t\tsel.anchor.blockId,\n\t\t\tsel.anchor.offset,\n\t\t\tnewSel.head.blockId,\n\t\t\tnewHeadOffset,\n\t\t);\n\t} finally {\n\t\ttry {\n\t\t\tdomSel.setBaseAndExtent(origAnchor, origAnchorOff, origFocus, origFocusOff);\n\t\t} catch {\n\t\t\t// Restore may fail\n\t\t}\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Fallback (model-based) when Selection.modify is unavailable\n// ---------------------------------------------------------------------------\n\nfunction fallbackMove(\n\tstate: EditorState,\n\tdirection: Direction,\n\tgranularity: Granularity,\n): Transaction | null {\n\tif (granularity === 'word') {\n\t\treturn fallbackWordMove(state, direction);\n\t}\n\tif (granularity === 'lineboundary') {\n\t\treturn direction === 'forward' ? moveToBlockEnd(state) : moveToBlockStart(state);\n\t}\n\t// granularity === 'line' → cross-block\n\tconst caretDir = direction === 'forward' ? 'down' : 'up';\n\treturn navigateAcrossBlocks(state, caretDir);\n}\n\nfunction fallbackExtend(\n\tstate: EditorState,\n\tdirection: Direction,\n\tgranularity: Granularity,\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst head = sel.head;\n\tconst block = state.getBlock(head.blockId);\n\tif (!block) return null;\n\n\tlet newOffset: number = head.offset;\n\n\tif (granularity === 'word') {\n\t\tnewOffset =\n\t\t\tdirection === 'forward'\n\t\t\t\t? findWordBoundaryForward(block, head.offset)\n\t\t\t\t: findWordBoundaryBackward(block, head.offset);\n\t} else if (granularity === 'lineboundary') {\n\t\tnewOffset = direction === 'forward' ? getBlockLength(block) : 0;\n\t} else {\n\t\t// line: extend to next block boundary\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(head.blockId);\n\t\tconst targetIdx: number = direction === 'forward' ? idx + 1 : idx - 1;\n\n\t\tif (targetIdx < 0 || targetIdx >= blockOrder.length) return null;\n\n\t\tconst targetId: BlockId | undefined = blockOrder[targetIdx];\n\t\tif (!targetId) return null;\n\t\tif (!canCrossBlockBoundary(state, head.blockId, targetId)) return null;\n\n\t\tif (isVoidBlock(state, targetId)) {\n\t\t\t// Cannot extend a text selection into a void block\n\t\t\treturn null;\n\t\t}\n\n\t\tconst targetBlock = state.getBlock(targetId);\n\t\tif (!targetBlock) return null;\n\n\t\tconst targetOffset: number = direction === 'forward' ? 0 : getBlockLength(targetBlock);\n\t\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, targetId, targetOffset);\n\t}\n\n\treturn extendTx(state, sel.anchor.blockId, sel.anchor.offset, head.blockId, newOffset);\n}\n\nfunction fallbackWordMove(state: EditorState, direction: Direction): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst blockId: BlockId = isCollapsed(sel) ? sel.anchor.blockId : sel.head.blockId;\n\tconst offset: number = isCollapsed(sel) ? sel.anchor.offset : sel.head.offset;\n\tconst block = state.getBlock(blockId);\n\tif (!block) return null;\n\n\tconst newOffset: number =\n\t\tdirection === 'forward'\n\t\t\t? findWordBoundaryForward(block, offset)\n\t\t\t: findWordBoundaryBackward(block, offset);\n\n\tif (newOffset === offset) {\n\t\t// At block boundary — try crossing blocks\n\t\treturn fallbackCrossBlock(state, blockId, direction);\n\t}\n\n\treturn moveTx(state, blockId, newOffset);\n}\n\n/**\n * Crosses a block boundary from `blockId` in the given direction.\n * Checks `canCrossBlockBoundary` and handles void blocks (→ NodeSelection).\n */\nfunction fallbackCrossBlock(\n\tstate: EditorState,\n\tblockId: BlockId,\n\tdirection: Direction,\n): Transaction | null {\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst idx: number = blockOrder.indexOf(blockId);\n\tconst targetIdx: number = direction === 'forward' ? idx + 1 : idx - 1;\n\n\tif (targetIdx < 0 || targetIdx >= blockOrder.length) return null;\n\n\tconst targetId: BlockId | undefined = blockOrder[targetIdx];\n\tif (!targetId) return null;\n\tif (!canCrossBlockBoundary(state, blockId, targetId)) return null;\n\n\tif (isVoidBlock(state, targetId)) return nodeSelTx(state, targetId);\n\n\tconst targetBlock = state.getBlock(targetId);\n\tif (!targetBlock) return null;\n\n\tconst targetOffset: number = direction === 'forward' ? 0 : getBlockLength(targetBlock);\n\treturn moveTx(state, targetId, targetOffset);\n}\n\n// ---------------------------------------------------------------------------\n// Convenience wrappers\n// ---------------------------------------------------------------------------\n\n/** Moves the cursor one word forward. */\nexport function moveWordForward(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewMove(container, state, 'forward', 'word');\n}\n\n/** Moves the cursor one word backward. */\nexport function moveWordBackward(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewMove(container, state, 'backward', 'word');\n}\n\n/** Moves the cursor to the start of the line (visual). */\nexport function moveToLineStart(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewMove(container, state, 'backward', 'lineboundary');\n}\n\n/** Moves the cursor to the end of the line (visual). */\nexport function moveToLineEnd(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewMove(container, state, 'forward', 'lineboundary');\n}\n\n/** Moves the cursor one visual line up. */\nexport function moveLineUp(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewMove(container, state, 'backward', 'line');\n}\n\n/** Moves the cursor one visual line down. */\nexport function moveLineDown(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewMove(container, state, 'forward', 'line');\n}\n\n/** Extends the selection one word forward. */\nexport function extendWordForward(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewExtend(container, state, 'forward', 'word');\n}\n\n/** Extends the selection one word backward. */\nexport function extendWordBackward(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewExtend(container, state, 'backward', 'word');\n}\n\n/** Extends the selection to the start of the line. */\nexport function extendToLineStart(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewExtend(container, state, 'backward', 'lineboundary');\n}\n\n/** Extends the selection to the end of the line. */\nexport function extendToLineEnd(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewExtend(container, state, 'forward', 'lineboundary');\n}\n\n/** Extends the selection one visual line up. */\nexport function extendLineUp(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewExtend(container, state, 'backward', 'line');\n}\n\n/** Extends the selection one visual line down. */\nexport function extendLineDown(container: HTMLElement, state: EditorState): Transaction | null {\n\treturn viewExtend(container, state, 'forward', 'line');\n}\n","/**\n * Announcer: builds screen-reader announcement text for editor state changes.\n * Pure functions — no DOM mutation. The caller applies the result to a live region.\n */\n\nimport { isMarkActive } from '../commands/Commands.js';\nimport { markType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\n\nconst BLOCK_TYPE_LABELS: Record<string, string> = {\n\tparagraph: 'Paragraph',\n\theading: 'Heading',\n\tcode_block: 'Code Block',\n\tblockquote: 'Block Quote',\n\tlist_item: 'List Item',\n\thorizontal_rule: 'Horizontal Rule',\n\timage: 'Image',\n\ttable: 'Table',\n};\n\n/** Returns a human-readable label for a block type (used in screen reader announcements). */\nexport function getBlockTypeLabel(typeName: string, attrs?: Record<string, unknown>): string {\n\tif (typeName === 'heading' && attrs?.level) {\n\t\treturn `Heading ${attrs.level}`;\n\t}\n\treturn BLOCK_TYPE_LABELS[typeName] ?? typeName;\n}\n\n/**\n * Derives an announcement string from a state transition.\n * Returns `null` when no announcement is warranted.\n *\n * Priority order: undo/redo > block-type change > mark toggle.\n */\nexport function buildAnnouncement(\n\toldState: EditorState,\n\tnewState: EditorState,\n\ttr: Transaction,\n): string | null {\n\t// Priority 1: Undo/Redo\n\tif (tr.metadata.historyDirection === 'undo') return 'Undo';\n\tif (tr.metadata.historyDirection === 'redo') return 'Redo';\n\n\t// Priority 2: Block type changes\n\tfor (const step of tr.steps) {\n\t\tif (step.type === 'setBlockType') {\n\t\t\treturn getBlockTypeLabel(step.nodeType, step.attrs);\n\t\t}\n\t}\n\n\t// Priority 3: Mark changes\n\tfor (const mt of newState.schema.markTypes) {\n\t\tconst branded = markType(mt);\n\t\tconst wasActive: boolean = isMarkActive(oldState, branded);\n\t\tconst nowActive: boolean = isMarkActive(newState, branded);\n\t\tif (wasActive !== nowActive) {\n\t\t\treturn `${mt} ${nowActive ? 'on' : 'off'}`;\n\t\t}\n\t}\n\n\treturn null;\n}\n","/**\n * CaretNavigationPlugin: registers platform-aware keymaps for all\n * programmatic movement commands (character, word, line, document).\n *\n * Movement priorities use 'navigation' to match GapCursorPlugin.\n * Also announces block-type changes to screen readers on cross-block navigation.\n */\n\nimport {\n\textendCharacterBackward,\n\textendCharacterForward,\n\textendToDocumentEnd,\n\textendToDocumentStart,\n\tmoveToDocumentEnd,\n\tmoveToDocumentStart,\n} from '../../commands/MovementCommands.js';\nimport { getBlockTypeLabel } from '../../editor/Announcer.js';\nimport { isCollapsed, isGapCursor, isNodeSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport { getTextDirection, isMac } from '../../view/Platform.js';\nimport {\n\textendLineDown,\n\textendLineUp,\n\textendToLineEnd,\n\textendToLineStart,\n\textendWordBackward,\n\textendWordForward,\n\tmoveLineDown,\n\tmoveLineUp,\n\tmoveToLineEnd,\n\tmoveToLineStart,\n\tmoveWordBackward,\n\tmoveWordForward,\n} from '../../view/ViewMovementCommands.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\n\ntype ViewCommandFn = (container: HTMLElement, state: EditorState) => Transaction | null;\ntype ViewCommandKey = `${'word' | 'lineboundary' | 'line'}:${'forward' | 'backward'}`;\ntype ViewCommandLookup = Readonly<Record<ViewCommandKey, ViewCommandFn>>;\n\nconst VIEW_MOVE_FNS: ViewCommandLookup = {\n\t'word:forward': moveWordForward,\n\t'word:backward': moveWordBackward,\n\t'lineboundary:forward': moveToLineEnd,\n\t'lineboundary:backward': moveToLineStart,\n\t'line:forward': moveLineDown,\n\t'line:backward': moveLineUp,\n};\n\nconst VIEW_EXTEND_FNS: ViewCommandLookup = {\n\t'word:forward': extendWordForward,\n\t'word:backward': extendWordBackward,\n\t'lineboundary:forward': extendToLineEnd,\n\t'lineboundary:backward': extendToLineStart,\n\t'line:forward': extendLineDown,\n\t'line:backward': extendLineUp,\n};\n\n/** Debounce delay for block-type announcements (ms). */\nconst ANNOUNCE_DEBOUNCE_MS = 150;\n\nexport class CaretNavigationPlugin implements Plugin {\n\treadonly id = 'caret-navigation';\n\treadonly name = 'Caret Navigation';\n\treadonly priority = 4;\n\n\tprivate context: PluginContext | null = null;\n\tprivate lastAnnouncedBlockId: BlockId | null = null;\n\tprivate announceTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate announce: ((text: string) => void) | null = null;\n\n\tinit(context: PluginContext): void {\n\t\tthis.context = context;\n\t\tthis.announce = (text: string) => context.announce(text);\n\t\tconst mac: boolean = isMac();\n\n\t\tconst keymap: Record<string, () => boolean> = {\n\t\t\t// --- Character movement (no modifier) ---\n\t\t\t// Handled natively by browser for basic cases, but Shift+Arrow\n\t\t\t// needs programmatic extend to correctly clear storedMarks.\n\n\t\t\t// --- Character extend ---\n\t\t\t'Shift-ArrowRight': () => this.extendCharacterVisual('right'),\n\t\t\t'Shift-ArrowLeft': () => this.extendCharacterVisual('left'),\n\n\t\t\t// --- Line extend ---\n\t\t\t'Shift-ArrowUp': () => this.viewExtendCommand('backward', 'line'),\n\t\t\t'Shift-ArrowDown': () => this.viewExtendCommand('forward', 'line'),\n\n\t\t\t// --- Word movement (platform-aware) ---\n\t\t\t...(mac\n\t\t\t\t? {\n\t\t\t\t\t\t'Alt-ArrowRight': () => this.viewMoveVisual('right', 'word'),\n\t\t\t\t\t\t'Alt-ArrowLeft': () => this.viewMoveVisual('left', 'word'),\n\t\t\t\t\t\t'Shift-Alt-ArrowRight': () => this.viewExtendVisual('right', 'word'),\n\t\t\t\t\t\t'Shift-Alt-ArrowLeft': () => this.viewExtendVisual('left', 'word'),\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\t'Mod-ArrowRight': () => this.viewMoveVisual('right', 'word'),\n\t\t\t\t\t\t'Mod-ArrowLeft': () => this.viewMoveVisual('left', 'word'),\n\t\t\t\t\t\t'Mod-Shift-ArrowRight': () => this.viewExtendVisual('right', 'word'),\n\t\t\t\t\t\t'Mod-Shift-ArrowLeft': () => this.viewExtendVisual('left', 'word'),\n\t\t\t\t\t}),\n\n\t\t\t// --- Line boundary movement (platform-aware) ---\n\t\t\t...(mac\n\t\t\t\t? {\n\t\t\t\t\t\t'Mod-ArrowLeft': () => this.viewMoveVisual('left', 'lineboundary'),\n\t\t\t\t\t\t'Mod-ArrowRight': () => this.viewMoveVisual('right', 'lineboundary'),\n\t\t\t\t\t\t'Mod-Shift-ArrowLeft': () => this.viewExtendVisual('left', 'lineboundary'),\n\t\t\t\t\t\t'Mod-Shift-ArrowRight': () => this.viewExtendVisual('right', 'lineboundary'),\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tHome: () => this.viewMoveCommand('backward', 'lineboundary'),\n\t\t\t\t\t\tEnd: () => this.viewMoveCommand('forward', 'lineboundary'),\n\t\t\t\t\t\t'Shift-Home': () => this.viewExtendCommand('backward', 'lineboundary'),\n\t\t\t\t\t\t'Shift-End': () => this.viewExtendCommand('forward', 'lineboundary'),\n\t\t\t\t\t}),\n\n\t\t\t// --- Document boundary movement (platform-aware) ---\n\t\t\t...(mac\n\t\t\t\t? {\n\t\t\t\t\t\t'Mod-ArrowUp': () => this.modelCommand(moveToDocumentStart),\n\t\t\t\t\t\t'Mod-ArrowDown': () => this.modelCommand(moveToDocumentEnd),\n\t\t\t\t\t\t'Mod-Shift-ArrowUp': () => this.modelCommand(extendToDocumentStart),\n\t\t\t\t\t\t'Mod-Shift-ArrowDown': () => this.modelCommand(extendToDocumentEnd),\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\t'Mod-Home': () => this.modelCommand(moveToDocumentStart),\n\t\t\t\t\t\t'Mod-End': () => this.modelCommand(moveToDocumentEnd),\n\t\t\t\t\t\t'Mod-Shift-Home': () => this.modelCommand(extendToDocumentStart),\n\t\t\t\t\t\t'Mod-Shift-End': () => this.modelCommand(extendToDocumentEnd),\n\t\t\t\t\t}),\n\t\t};\n\n\t\tcontext.registerKeymap(keymap, { priority: 'navigation' });\n\t}\n\n\t/** Announces block-type on cross-block cursor movement (debounced). */\n\tonStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tconst newSel = newState.selection;\n\n\t\t// Only announce for collapsed text selections\n\t\tif (!isCollapsed(newSel) || isNodeSelection(newSel) || isGapCursor(newSel)) {\n\t\t\tif (this.announceTimer !== null) {\n\t\t\t\tclearTimeout(this.announceTimer);\n\t\t\t\tthis.announceTimer = null;\n\t\t\t}\n\t\t\tthis.lastAnnouncedBlockId = null;\n\t\t\treturn;\n\t\t}\n\n\t\tconst newBlockId: BlockId = newSel.anchor.blockId;\n\t\tif (newBlockId === this.lastAnnouncedBlockId) return;\n\n\t\t// First observed block (initial focus) — remember but don't announce\n\t\tif (this.lastAnnouncedBlockId === null) {\n\t\t\tthis.lastAnnouncedBlockId = newBlockId;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lastAnnouncedBlockId = newBlockId;\n\n\t\t// Debounce rapid navigation\n\t\tif (this.announceTimer !== null) clearTimeout(this.announceTimer);\n\t\tthis.announceTimer = setTimeout(() => {\n\t\t\tthis.announceTimer = null;\n\t\t\t// Skip if another plugin already announced (e.g. CodeBlockPlugin's \"Left code block\")\n\t\t\tif (this.context?.hasAnnouncement()) return;\n\t\t\tconst block = newState.getBlock(newBlockId);\n\t\t\tif (!block) return;\n\t\t\tconst label: string = getBlockTypeLabel(\n\t\t\t\tblock.type,\n\t\t\t\tblock.attrs as Record<string, unknown> | undefined,\n\t\t\t);\n\t\t\tthis.announce?.(label);\n\t\t}, ANNOUNCE_DEBOUNCE_MS);\n\t}\n\n\tdestroy(): void {\n\t\tif (this.announceTimer !== null) clearTimeout(this.announceTimer);\n\t\tthis.announceTimer = null;\n\t\tthis.announce = null;\n\t\tthis.context = null;\n\t}\n\n\t/** Dispatches a model-based movement command (no DOM needed). */\n\tprivate modelCommand(fn: (state: EditorState) => Transaction | null): boolean {\n\t\tif (!this.context) return false;\n\t\tconst tr: Transaction | null = fn(this.context.getState());\n\t\tif (tr) {\n\t\t\tthis.context.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/** Extends selection by one character based on visual left/right intent. */\n\tprivate extendCharacterVisual(visual: 'left' | 'right'): boolean {\n\t\tif (!this.context) return false;\n\t\tconst state: EditorState = this.context.getState();\n\t\tconst dir: 'forward' | 'backward' = this.resolveLogicalHorizontalDirection(state, visual);\n\t\tconst tr: Transaction | null =\n\t\t\tdir === 'forward' ? extendCharacterForward(state) : extendCharacterBackward(state);\n\t\tif (tr) {\n\t\t\tthis.context.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/** Dispatches a view-based movement command (uses container + Selection.modify). */\n\tprivate viewMoveCommand(\n\t\tdirection: 'forward' | 'backward',\n\t\tgranularity: 'word' | 'lineboundary' | 'line',\n\t): boolean {\n\t\treturn this.dispatchViewCommand(VIEW_MOVE_FNS, direction, granularity);\n\t}\n\n\t/** Dispatches a view-based move command with visual direction mapping for RTL. */\n\tprivate viewMoveVisual(visual: 'left' | 'right', granularity: 'word' | 'lineboundary'): boolean {\n\t\tif (!this.context) return false;\n\t\tconst dir: 'forward' | 'backward' = this.resolveLogicalHorizontalDirection(\n\t\t\tthis.context.getState(),\n\t\t\tvisual,\n\t\t);\n\t\treturn this.viewMoveCommand(dir, granularity);\n\t}\n\n\t/** Dispatches a view-based extend command. */\n\tprivate viewExtendCommand(\n\t\tdirection: 'forward' | 'backward',\n\t\tgranularity: 'word' | 'lineboundary' | 'line',\n\t): boolean {\n\t\treturn this.dispatchViewCommand(VIEW_EXTEND_FNS, direction, granularity);\n\t}\n\n\tprivate dispatchViewCommand(\n\t\tlookup: ViewCommandLookup,\n\t\tdirection: 'forward' | 'backward',\n\t\tgranularity: 'word' | 'lineboundary' | 'line',\n\t): boolean {\n\t\tif (!this.context) return false;\n\t\tconst fn: ViewCommandFn | undefined = lookup[`${granularity}:${direction}`];\n\t\tif (!fn) return false;\n\t\tconst tr: Transaction | null = fn(this.context.getContainer(), this.context.getState());\n\t\tif (tr) {\n\t\t\tthis.context.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/** Dispatches a view-based extend command with visual direction mapping for RTL. */\n\tprivate viewExtendVisual(\n\t\tvisual: 'left' | 'right',\n\t\tgranularity: 'word' | 'lineboundary',\n\t): boolean {\n\t\tif (!this.context) return false;\n\t\tconst dir: 'forward' | 'backward' = this.resolveLogicalHorizontalDirection(\n\t\t\tthis.context.getState(),\n\t\t\tvisual,\n\t\t);\n\t\treturn this.viewExtendCommand(dir, granularity);\n\t}\n\n\t/**\n\t * Resolves logical movement direction from visual left/right intent.\n\t * In RTL blocks, visual directions are mirrored in offset space.\n\t */\n\tprivate resolveLogicalHorizontalDirection(\n\t\tstate: EditorState,\n\t\tvisual: 'left' | 'right',\n\t): 'forward' | 'backward' {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel) || isGapCursor(sel)) {\n\t\t\treturn visual === 'left' ? 'backward' : 'forward';\n\t\t}\n\t\tconst container: HTMLElement | undefined = this.context?.getContainer();\n\t\tif (!container) return visual === 'left' ? 'backward' : 'forward';\n\t\tconst blockEl: Element | null = container.querySelector(\n\t\t\t`[data-block-id=\"${sel.head.blockId}\"]`,\n\t\t);\n\t\tconst isRtl: boolean = blockEl instanceof HTMLElement && getTextDirection(blockEl) === 'rtl';\n\t\tif (!isRtl) return visual === 'left' ? 'backward' : 'forward';\n\t\treturn visual === 'left' ? 'forward' : 'backward';\n\t}\n}\n"],"names":["SEGMENTER","Intl","Segmenter","granularity","nextGraphemeSize","text","offset","length","segment","index","prevGraphemeSize","lastSize","findWordBoundaryBackward","block","pos","content","getContentAtOffset","kind","test","char","findWordBoundaryForward","len","getBlockLength","resolveHead","state","sel","selection","isNodeSelection","isGapCursor","blockId","head","adjacentBlockId","currentBlockId","direction","blockOrder","getBlockOrder","idx","indexOf","targetIdx","moveCharacterForward","isCollapsed","moveTx","anchor","getBlock","step","getBlockText","blockOffsetToTextOffset","nextId","canCrossBlockBoundary","isVoidBlock","nodeSelTx","moveCharacterBackward","prevId","prevBlock","moveToBlockStart","moveToBlockEnd","blockLen","moveToDocumentStart","firstId","moveToDocumentEnd","lastId","lastBlock","extendCharacterForward","extendTx","extendCharacterBackward","extendToBlockStart","extendToBlockEnd","extendToDocumentStart","extendToDocumentEnd","lastBlockLen","viewMove","container","domSel","getSelection","modify","fallbackMove","origAnchor","anchorNode","origAnchorOff","anchorOffset","origFocus","focusNode","origFocusOff","focusOffset","newSel","readSelectionFromDOM","newBlockId","oldBlockId","newOffset","Math","min","setBaseAndExtent","viewExtend","fallbackExtend","oldHeadBlockId","newHeadBlockId","newHeadOffset","headBlock","targetId","targetBlock","targetOffset","navigateAcrossBlocks","moveWordForward","moveWordBackward","moveToLineStart","moveToLineEnd","moveLineUp","moveLineDown","extendWordForward","extendWordBackward","extendToLineStart","extendToLineEnd","extendLineUp","extendLineDown","BLOCK_TYPE_LABELS","paragraph","heading","code_block","blockquote","list_item","horizontal_rule","image","table","getBlockTypeLabel","typeName","attrs","level","buildAnnouncement","oldState","newState","tr","metadata","historyDirection","steps","type","nodeType","mt","schema","markTypes","branded","markType","wasActive","isMarkActive","nowActive","VIEW_MOVE_FNS","VIEW_EXTEND_FNS","CaretNavigationPlugin","id","name","priority","context","lastAnnouncedBlockId","announceTimer","announce","this","mac","isMac","keymap","extendCharacterVisual","viewExtendCommand","viewMoveVisual","viewExtendVisual","Home","viewMoveCommand","End","modelCommand","registerKeymap","_oldState","_tr","clearTimeout","setTimeout","hasAnnouncement","label","destroy","fn","getState","dispatch","visual","resolveLogicalHorizontalDirection","dispatchViewCommand","dir","lookup","getContainer","blockEl","querySelector","HTMLElement","getTextDirection"],"mappings":";;;;;;;AASA,MACMA,IAD+C,eAAA,OAATC,QAAwB,eAAeA,OAEhF,IAAIA,KAAKC,UAAAA,QAAqB,EAAEC,aAAa,WAAA,CAAA,IAC7C;AAMI,SAASC,EAAiBC,IAAcC,IAAAA;AAC9C,MAAIA,MAAUD,GAAKE,UAA0B,MAAhBF,GAAKE,OAAc,QAAO;AAEvD,MAAIP,GAAW;AACd,eAAWQ,MAAWR,EAAUQ,QAAQH,EAAAA,EACvC,KAAIG,GAAQC,SAASH,GACpB,QAAOE,GAAQA,QAAQD;AAGzB,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAOO,SAASG,EAAiBL,IAAcC,IAAAA;AAC9C,MAAIA,MAAU,KAAqB,MAAhBD,GAAKE,OAAc,QAAO;AAE7C,MAAIP,GAAW;AACd,QAAIW,KAAW;AACf,eAAWH,MAAWR,EAAUQ,QAAQH,KAAO;AAC9C,UAAIG,GAAQC,QAAQD,GAAQA,QAAQD,UAAUD,IAAQ;AACrDK,QAAAA,KAAWH,GAAQA,QAAQD;AAC3B;AAAA,MACD;AACAI,MAAAA,KAAWH,GAAQA,QAAQD;AAAAA,IAC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