@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
@@ -1,140 +0,0 @@
1
- import { n as t } from "./ToolbarKeyboardNav-B32OMv8r.mjs";
2
- import { f as e } from "./Commands-CSpSwGXv.mjs";
3
- import { i as o } from "./AttrRegistry-D-przlzb.mjs";
4
- import { e as n, h as r } from "./Document-CI3iCwEP.mjs";
5
- import { i as s, a as c, s as a } from "./Selection-D5ZjXoB7.mjs";
6
- import { m as l } from "./TypeBrands-C09nE2qO.mjs";
7
- import { g as i, i as d } from "./ColorNames-iaWsSZx1.mjs";
8
- const p = '\n/* Color Picker Popup */\n.notectl-color-picker {\n padding: 8px;\n min-width: 240px;\n}\n\n.notectl-color-picker__default {\n display: block;\n width: 100%;\n padding: 6px 12px;\n margin-bottom: 8px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n cursor: pointer;\n font-size: 13px;\n color: var(--notectl-fg);\n text-align: center;\n}\n\n.notectl-color-picker__default:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-color-picker__grid {\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n gap: 3px;\n}\n\n.notectl-color-picker__grid [role="row"] {\n display: contents;\n}\n\n.notectl-color-picker__swatch {\n width: 22px;\n height: 22px;\n border: 1px solid transparent;\n border-radius: 3px;\n padding: 0;\n cursor: pointer;\n transition: transform 0.1s;\n}\n\n.notectl-color-picker__swatch:hover,\n.notectl-color-picker__swatch:focus-visible {\n transform: scale(1.25);\n z-index: 1;\n}\n\n.notectl-color-picker__swatch:focus-visible {\n outline: 2px solid var(--notectl-focus-ring);\n outline-offset: 1px;\n}\n\n.notectl-color-picker__swatch--active {\n border: 2px solid var(--notectl-primary-fg);\n border-radius: 3px;\n}\n\n.notectl-toolbar-btn--textColor .notectl-toolbar-btn__color-indicator {\n display: block;\n width: 16px;\n height: 3px;\n margin-top: 1px;\n border-radius: 1px;\n}\n';
9
- function u(t2, e2) {
10
- const r2 = t2.selection;
11
- if (s(r2)) return null;
12
- if (c(r2)) {
13
- if (t2.storedMarks) {
14
- const n2 = t2.storedMarks.find((t3) => t3.type === e2);
15
- return n2 && o(n2, e2) ? n2.attrs.color ?? null : null;
16
- }
17
- const s2 = t2.getBlock(r2.anchor.blockId);
18
- if (!s2) return null;
19
- const c2 = n(s2, r2.anchor.offset).find((t3) => t3.type === e2);
20
- return c2 && o(c2, e2) ? c2.attrs.color ?? null : null;
21
- }
22
- const a2 = t2.getBlock(r2.anchor.blockId);
23
- if (!a2) return null;
24
- const l2 = n(a2, r2.anchor.offset).find((t3) => t3.type === e2);
25
- return l2 && o(l2, e2) ? l2.attrs.color ?? null : null;
26
- }
27
- function f(t2, e2) {
28
- return null !== u(t2, e2);
29
- }
30
- function m(t2, o2, r2, i2) {
31
- const d2 = o2.selection;
32
- if (s(d2)) return false;
33
- const p2 = l(r2);
34
- if (c(d2)) {
35
- const e2 = o2.getBlock(d2.anchor.blockId);
36
- if (!e2) return false;
37
- const s2 = [...(o2.storedMarks ?? n(e2, d2.anchor.offset)).filter((t3) => t3.type !== r2), { type: p2, attrs: { color: i2 } }], c2 = o2.transaction("command").setStoredMarks(s2, o2.storedMarks).setSelection(d2).build();
38
- return t2.dispatch(c2), true;
39
- }
40
- const u2 = a(d2, o2.getBlockOrder()), f2 = o2.transaction("command"), m2 = { type: p2, attrs: { color: i2 } };
41
- return e(o2, u2, (t3, e2, o3) => {
42
- f2.removeMark(t3, e2, o3, { type: p2 }), f2.addMark(t3, e2, o3, m2);
43
- }), f2.setSelection(d2), t2.dispatch(f2.build()), true;
44
- }
45
- function k(t2, o2, i2) {
46
- const d2 = o2.selection;
47
- if (s(d2)) return false;
48
- const p2 = l(i2);
49
- if (c(d2)) {
50
- const e2 = o2.getBlock(d2.anchor.blockId);
51
- if (!e2) return false;
52
- const s2 = o2.storedMarks ?? n(e2, d2.anchor.offset);
53
- if (!r(s2, p2)) return false;
54
- const c2 = s2.filter((t3) => t3.type !== i2), a2 = o2.transaction("command").setStoredMarks(c2, o2.storedMarks).setSelection(d2).build();
55
- return t2.dispatch(a2), true;
56
- }
57
- const u2 = a(d2, o2.getBlockOrder()), f2 = o2.transaction("command");
58
- return e(o2, u2, (t3, e2, o3) => {
59
- f2.removeMark(t3, e2, o3, { type: p2 });
60
- }), f2.setSelection(d2), t2.dispatch(f2.build()), true;
61
- }
62
- const b = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]), h = /* @__PURE__ */ new Set(["Home", "End"]);
63
- function g(e2, o2, n2) {
64
- e2.classList.add("notectl-color-picker");
65
- const r2 = u(o2.getState(), n2.markType), s2 = n2.columns || 10, c2 = n2.colors.length, a2 = Math.ceil(c2 / s2), l2 = document.createElement("button");
66
- l2.type = "button", l2.className = "notectl-color-picker__default", l2.textContent = n2.resetLabel, l2.addEventListener("mousedown", (t2) => {
67
- t2.preventDefault(), t2.stopPropagation(), o2.executeCommand(n2.resetCommand), n2.onClose();
68
- }), l2.addEventListener("keydown", (t2) => {
69
- "Escape" === t2.key && (t2.preventDefault(), n2.onClose());
70
- }), e2.appendChild(l2);
71
- const p2 = document.createElement("div");
72
- p2.className = "notectl-color-picker__grid", p2.setAttribute("role", "grid"), p2.setAttribute("aria-label", `${n2.ariaLabelPrefix} color picker`);
73
- const f2 = [];
74
- let k2 = 0;
75
- for (let t2 = 0; t2 < a2; t2++) {
76
- const e3 = document.createElement("div");
77
- e3.setAttribute("role", "row");
78
- for (let a3 = 0; a3 < s2; a3++) {
79
- const l3 = t2 * s2 + a3;
80
- if (l3 >= c2) break;
81
- const p3 = n2.colors[l3], u2 = i(p3), b2 = !!r2 && r2.toLowerCase() === p3.toLowerCase(), h2 = document.createElement("button");
82
- h2.type = "button", h2.className = "notectl-color-picker__swatch", h2.setAttribute("role", "gridcell"), h2.setAttribute("aria-label", `${n2.ariaLabelPrefix} ${u2}`), h2.setAttribute("aria-selected", String(b2)), h2.dataset.index = String(l3), h2.style.backgroundColor = p3, h2.title = p3, d(p3) && (h2.style.border = "1px solid #d0d0d0"), b2 && (h2.classList.add("notectl-color-picker__swatch--active"), k2 = l3), h2.addEventListener("mousedown", (t3) => {
83
- t3.preventDefault(), t3.stopPropagation(), m(o2, o2.getState(), n2.markType, p3), n2.onClose();
84
- }), f2.push(h2), e3.appendChild(h2);
85
- }
86
- p2.appendChild(e3);
87
- }
88
- x(f2, k2), p2.addEventListener("keydown", (e3) => {
89
- if ("Escape" === e3.key) return e3.preventDefault(), void n2.onClose();
90
- if ("Enter" === e3.key || " " === e3.key) {
91
- e3.preventDefault();
92
- const t2 = e3.target.dataset.index;
93
- if (void 0 !== t2) {
94
- const e4 = n2.colors[Number(t2)];
95
- e4 && (m(o2, o2.getState(), n2.markType, e4), n2.onClose());
96
- }
97
- return;
98
- }
99
- if (b.has(e3.key)) {
100
- e3.preventDefault();
101
- const o3 = Math.floor(k2 / s2) + 1, n3 = k2 % s2 + 1, r3 = a2, l3 = s2, [i2, d2] = t(o3, n3, r3, l3, e3.key);
102
- let p3 = (i2 - 1) * s2 + (d2 - 1);
103
- return p3 >= c2 && (p3 = c2 - 1), k2 = p3, x(f2, k2), void f2[k2]?.focus();
104
- }
105
- if (h.has(e3.key)) {
106
- e3.preventDefault();
107
- const t2 = Math.floor(k2 / s2) * s2, o3 = Math.min(t2 + s2 - 1, c2 - 1);
108
- k2 = "Home" === e3.key ? t2 : o3, x(f2, k2), f2[k2]?.focus();
109
- }
110
- }), e2.appendChild(p2);
111
- }
112
- function x(t2, e2) {
113
- for (let o2 = 0; o2 < t2.length; o2++) {
114
- const n2 = t2[o2];
115
- n2 && n2.setAttribute("tabindex", o2 === e2 ? "0" : "-1");
116
- }
117
- }
118
- const v = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
119
- function y(t2, e2, o2) {
120
- if (!t2 || 0 === t2.length) return e2;
121
- const n2 = t2.filter((t3) => {
122
- return e3 = t3, !v.test(e3);
123
- var e3;
124
- });
125
- if (n2.length > 0) throw new Error(`${o2}: invalid hex color(s): ${n2.join(", ")}. Expected format: #RGB or #RRGGBB.`);
126
- const r2 = /* @__PURE__ */ new Set(), s2 = [];
127
- for (const e3 of t2) {
128
- const t3 = e3.toLowerCase();
129
- r2.has(t3) || (r2.add(t3), s2.push(t3));
130
- }
131
- return s2;
132
- }
133
- export {
134
- p as C,
135
- k as a,
136
- g as b,
137
- f as i,
138
- y as r
139
- };
140
- //# sourceMappingURL=ColorValidation-Dyy4Bye8.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorValidation-Dyy4Bye8.mjs","sources":["../../src/editor/styles/color-picker.ts","../../src/plugins/shared/ColorMarkOperations.ts","../../src/plugins/shared/ColorPickerPopup.ts","../../src/plugins/shared/ColorValidation.ts"],"sourcesContent":["/** Color picker popup styles (text-color + highlight plugins). */\nexport const COLOR_PICKER_CSS = `\n/* Color Picker Popup */\n.notectl-color-picker {\n\tpadding: 8px;\n\tmin-width: 240px;\n}\n\n.notectl-color-picker__default {\n\tdisplay: block;\n\twidth: 100%;\n\tpadding: 6px 12px;\n\tmargin-bottom: 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-bg);\n\tcursor: pointer;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg);\n\ttext-align: center;\n}\n\n.notectl-color-picker__default:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-color-picker__grid {\n\tdisplay: grid;\n\tgrid-template-columns: repeat(10, 1fr);\n\tgap: 3px;\n}\n\n.notectl-color-picker__grid [role=\"row\"] {\n\tdisplay: contents;\n}\n\n.notectl-color-picker__swatch {\n\twidth: 22px;\n\theight: 22px;\n\tborder: 1px solid transparent;\n\tborder-radius: 3px;\n\tpadding: 0;\n\tcursor: pointer;\n\ttransition: transform 0.1s;\n}\n\n.notectl-color-picker__swatch:hover,\n.notectl-color-picker__swatch:focus-visible {\n\ttransform: scale(1.25);\n\tz-index: 1;\n}\n\n.notectl-color-picker__swatch:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: 1px;\n}\n\n.notectl-color-picker__swatch--active {\n\tborder: 2px solid var(--notectl-primary-fg);\n\tborder-radius: 3px;\n}\n\n.notectl-toolbar-btn--textColor .notectl-toolbar-btn__color-indicator {\n\tdisplay: block;\n\twidth: 16px;\n\theight: 3px;\n\tmargin-top: 1px;\n\tborder-radius: 1px;\n}\n`;\n","/**\n * Shared color mark operations for color-based mark plugins.\n * All functions are parameterized by mark type name so they work\n * identically for TextColor, Highlight, or any future color mark.\n */\n\nimport { forEachBlockInRange } from '../../commands/Commands.js';\nimport { type MarkAttrRegistry, isMarkOfType } from '../../model/AttrRegistry.js';\nimport { getBlockMarksAtOffset, hasMark } from '../../model/Document.js';\nimport { isCollapsed, isNodeSelection, selectionRange } from '../../model/Selection.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { MarkTypeName } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\n\n/** Color mark type names that have `{ color: string }` attrs. */\ntype ColorMarkType = {\n\t[K in keyof MarkAttrRegistry]: MarkAttrRegistry[K] extends { color: string } ? K : never;\n}[keyof MarkAttrRegistry];\n\n/**\n * Returns the active color value for the given mark type at the current\n * selection, or `null` if the mark is not present.\n */\nexport function getActiveColor(state: EditorState, markTypeName: ColorMarkType): string | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return null;\n\n\tif (isCollapsed(sel)) {\n\t\tif (state.storedMarks) {\n\t\t\tconst mark = state.storedMarks.find((m) => m.type === markTypeName);\n\t\t\treturn mark && isMarkOfType(mark, markTypeName) ? (mark.attrs.color ?? null) : null;\n\t\t}\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return null;\n\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\tconst mark = marks.find((m) => m.type === markTypeName);\n\t\treturn mark && isMarkOfType(mark, markTypeName) ? (mark.attrs.color ?? null) : null;\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\tconst mark = marks.find((m) => m.type === markTypeName);\n\treturn mark && isMarkOfType(mark, markTypeName) ? (mark.attrs.color ?? null) : null;\n}\n\n/** Returns `true` when the given color mark is active at the current selection. */\nexport function isColorMarkActive(state: EditorState, markTypeName: ColorMarkType): boolean {\n\treturn getActiveColor(state, markTypeName) !== null;\n}\n\n/**\n * Applies the given color to the selection. For collapsed selections,\n * sets stored marks. For range selections, removes then re-adds the mark.\n */\nexport function applyColorMark(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tmarkTypeName: ColorMarkType,\n\tcolor: string,\n): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tconst typeName: MarkTypeName = markType(markTypeName);\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return false;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tconst withoutMark = currentMarks.filter((m) => m.type !== markTypeName);\n\t\tconst newMarks = [...withoutMark, { type: typeName, attrs: { color } }];\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\tconst mark = { type: typeName, attrs: { color } };\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tbuilder.removeMark(blockId, from, to, { type: typeName });\n\t\tbuilder.addMark(blockId, from, to, mark);\n\t});\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/**\n * Removes the given color mark from the selection.\n * Returns `false` when the mark was not present.\n */\nexport function removeColorMark(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tmarkTypeName: ColorMarkType,\n): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tconst typeName: MarkTypeName = markType(markTypeName);\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return false;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tif (!hasMark(currentMarks, typeName)) return false;\n\n\t\tconst newMarks = currentMarks.filter((m) => m.type !== markTypeName);\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tbuilder.removeMark(blockId, from, to, { type: typeName });\n\t});\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n","/**\n * Shared color picker popup rendering with WAI-ARIA grid keyboard navigation.\n * Used by TextColorPlugin and HighlightPlugin.\n */\n\nimport type { MarkAttrRegistry } from '../../model/AttrRegistry.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { navigateGrid } from '../toolbar/ToolbarKeyboardNav.js';\nimport { applyColorMark, getActiveColor } from './ColorMarkOperations.js';\nimport { getColorName, isLightColor } from './ColorNames.js';\n\n/** Color mark type names that have `{ color: string }` attrs. */\ntype ColorMarkType = {\n\t[K in keyof MarkAttrRegistry]: MarkAttrRegistry[K] extends { color: string } ? K : never;\n}[keyof MarkAttrRegistry];\n\n/** Configuration for `renderColorPickerPopup`. */\nexport interface ColorPickerConfig {\n\treadonly markType: ColorMarkType;\n\treadonly colors: readonly string[];\n\treadonly columns: number;\n\treadonly resetLabel: string;\n\treadonly resetCommand: string;\n\treadonly ariaLabelPrefix: string;\n\treadonly onClose: () => void;\n}\n\nconst GRID_NAV_KEYS = new Set(['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']);\nconst GRID_HOME_END_KEYS = new Set(['Home', 'End']);\nconst LIGHT_COLOR_BORDER = '1px solid #d0d0d0';\nconst COLUMNS = 10;\n\n/**\n * Renders an accessible color picker popup into `container`.\n *\n * Features:\n * - WAI-ARIA `role=\"grid\"` with row/gridcell structure\n * - Arrow key navigation (wraps around, clamps on partial last row)\n * - Enter/Space selects color and closes popup\n * - Escape closes popup\n * - Roving tabindex on swatches\n */\nexport function renderColorPickerPopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: ColorPickerConfig,\n): void {\n\tcontainer.classList.add('notectl-color-picker');\n\n\tconst state = context.getState();\n\tconst activeColor: string | null = getActiveColor(state, config.markType);\n\tconst columns: number = config.columns || COLUMNS;\n\tconst totalSwatches: number = config.colors.length;\n\tconst totalRows: number = Math.ceil(totalSwatches / columns);\n\n\t// --- Reset button ---\n\tconst resetBtn: HTMLButtonElement = document.createElement('button');\n\tresetBtn.type = 'button';\n\tresetBtn.className = 'notectl-color-picker__default';\n\tresetBtn.textContent = config.resetLabel;\n\tresetBtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t\tcontext.executeCommand(config.resetCommand);\n\t\tconfig.onClose();\n\t});\n\tresetBtn.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.onClose();\n\t\t}\n\t});\n\tcontainer.appendChild(resetBtn);\n\n\t// --- Color grid ---\n\tconst grid: HTMLDivElement = document.createElement('div');\n\tgrid.className = 'notectl-color-picker__grid';\n\tgrid.setAttribute('role', 'grid');\n\tgrid.setAttribute('aria-label', `${config.ariaLabelPrefix} color picker`);\n\n\tconst swatches: HTMLButtonElement[] = [];\n\tlet focusedIndex = 0;\n\n\t// Build rows for ARIA structure\n\tfor (let rowIdx = 0; rowIdx < totalRows; rowIdx++) {\n\t\tconst row: HTMLDivElement = document.createElement('div');\n\t\trow.setAttribute('role', 'row');\n\n\t\tfor (let colIdx = 0; colIdx < columns; colIdx++) {\n\t\t\tconst swatchIdx: number = rowIdx * columns + colIdx;\n\t\t\tif (swatchIdx >= totalSwatches) break;\n\n\t\t\tconst color: string = config.colors[swatchIdx] as string;\n\t\t\tconst colorName: string = getColorName(color);\n\t\t\tconst isActive: boolean = !!activeColor && activeColor.toLowerCase() === color.toLowerCase();\n\n\t\t\tconst swatch: HTMLButtonElement = document.createElement('button');\n\t\t\tswatch.type = 'button';\n\t\t\tswatch.className = 'notectl-color-picker__swatch';\n\t\t\tswatch.setAttribute('role', 'gridcell');\n\t\t\tswatch.setAttribute('aria-label', `${config.ariaLabelPrefix} ${colorName}`);\n\t\t\tswatch.setAttribute('aria-selected', String(isActive));\n\t\t\tswatch.dataset.index = String(swatchIdx);\n\t\t\tswatch.style.backgroundColor = color;\n\t\t\tswatch.title = color;\n\n\t\t\tif (isLightColor(color)) {\n\t\t\t\tswatch.style.border = LIGHT_COLOR_BORDER;\n\t\t\t}\n\n\t\t\tif (isActive) {\n\t\t\t\tswatch.classList.add('notectl-color-picker__swatch--active');\n\t\t\t\tfocusedIndex = swatchIdx;\n\t\t\t}\n\n\t\t\t// Mouse handler\n\t\t\tswatch.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tapplyColorMark(context, context.getState(), config.markType, color);\n\t\t\t\tconfig.onClose();\n\t\t\t});\n\n\t\t\tswatches.push(swatch);\n\t\t\trow.appendChild(swatch);\n\t\t}\n\n\t\tgrid.appendChild(row);\n\t}\n\n\t// Apply initial roving tabindex\n\tapplySwatchTabindex(swatches, focusedIndex);\n\n\t// --- Keyboard navigation (delegated on the grid) ---\n\tgrid.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.onClose();\n\t\t\treturn;\n\t\t}\n\n\t\tif (e.key === 'Enter' || e.key === ' ') {\n\t\t\te.preventDefault();\n\t\t\tconst target = e.target as HTMLElement;\n\t\t\tconst idx: string | undefined = target.dataset.index;\n\t\t\tif (idx !== undefined) {\n\t\t\t\tconst color: string | undefined = config.colors[Number(idx)];\n\t\t\t\tif (color) {\n\t\t\t\t\tapplyColorMark(context, context.getState(), config.markType, color);\n\t\t\t\t\tconfig.onClose();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (GRID_NAV_KEYS.has(e.key)) {\n\t\t\te.preventDefault();\n\t\t\tconst currentRow: number = Math.floor(focusedIndex / columns) + 1;\n\t\t\tconst currentCol: number = (focusedIndex % columns) + 1;\n\n\t\t\tconst maxRows: number = totalRows;\n\t\t\tconst maxCols: number = columns;\n\n\t\t\tconst [newRow, newCol] = navigateGrid(\n\t\t\t\tcurrentRow,\n\t\t\t\tcurrentCol,\n\t\t\t\tmaxRows,\n\t\t\t\tmaxCols,\n\t\t\t\te.key as 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight',\n\t\t\t);\n\n\t\t\t// Convert back to 0-based index and clamp to valid range\n\t\t\tlet newIdx: number = (newRow - 1) * columns + (newCol - 1);\n\t\t\tif (newIdx >= totalSwatches) {\n\t\t\t\tnewIdx = totalSwatches - 1;\n\t\t\t}\n\n\t\t\tfocusedIndex = newIdx;\n\t\t\tapplySwatchTabindex(swatches, focusedIndex);\n\t\t\tswatches[focusedIndex]?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Home/End — jump to first/last swatch in current row\n\t\tif (GRID_HOME_END_KEYS.has(e.key)) {\n\t\t\te.preventDefault();\n\t\t\tconst currentRow: number = Math.floor(focusedIndex / columns);\n\t\t\tconst rowStart: number = currentRow * columns;\n\t\t\tconst rowEnd: number = Math.min(rowStart + columns - 1, totalSwatches - 1);\n\n\t\t\tfocusedIndex = e.key === 'Home' ? rowStart : rowEnd;\n\t\t\tapplySwatchTabindex(swatches, focusedIndex);\n\t\t\tswatches[focusedIndex]?.focus();\n\t\t}\n\t});\n\n\tcontainer.appendChild(grid);\n}\n\n/** Sets `tabindex=\"0\"` on the focused swatch, `-1` on all others. */\nfunction applySwatchTabindex(swatches: readonly HTMLButtonElement[], focusedIndex: number): void {\n\tfor (let i = 0; i < swatches.length; i++) {\n\t\tconst swatch = swatches[i];\n\t\tif (swatch) {\n\t\t\tswatch.setAttribute('tabindex', i === focusedIndex ? '0' : '-1');\n\t\t}\n\t}\n}\n","/**\n * Shared color validation and normalization utilities\n * for color-based mark plugins (TextColor, Highlight).\n */\n\nconst HEX_COLOR_PATTERN: RegExp = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\n\n/** Returns `true` when the value is a valid `#RGB` or `#RRGGBB` hex color. */\nexport function isValidHexColor(value: string): boolean {\n\treturn HEX_COLOR_PATTERN.test(value);\n}\n\n/**\n * Validates, deduplicates, and normalizes a user-supplied color list.\n * Returns `fallbackPalette` when no custom colors are provided.\n *\n * @throws {Error} if any value is not a valid hex color code.\n */\nexport function resolveColors(\n\tcolors: readonly string[] | undefined,\n\tfallbackPalette: readonly string[],\n\tpluginName: string,\n): readonly string[] {\n\tif (!colors || colors.length === 0) return fallbackPalette;\n\n\tconst invalid: string[] = colors.filter((c) => !isValidHexColor(c));\n\tif (invalid.length > 0) {\n\t\tthrow new Error(\n\t\t\t`${pluginName}: invalid hex color(s): ${invalid.join(', ')}. Expected format: #RGB or #RRGGBB.`,\n\t\t);\n\t}\n\n\tconst seen: Set<string> = new Set();\n\tconst unique: string[] = [];\n\tfor (const color of colors) {\n\t\tconst normalized: string = color.toLowerCase();\n\t\tif (!seen.has(normalized)) {\n\t\t\tseen.add(normalized);\n\t\t\tunique.push(normalized);\n\t\t}\n\t}\n\treturn unique;\n}\n"],"names":["COLOR_PICKER_CSS","getActiveColor","state","markTypeName","sel","selection","isNodeSelection","isCollapsed","storedMarks","mark","find","m","type","isMarkOfType","attrs","color","block","getBlock","anchor","blockId","getBlockMarksAtOffset","offset","isColorMarkActive","applyColorMark","context","typeName","markType","anchorBlock","newMarks","filter","tr","transaction","setStoredMarks","setSelection","build","dispatch","range","selectionRange","getBlockOrder","builder","forEachBlockInRange","from","to","removeMark","addMark","removeColorMark","currentMarks","hasMark","GRID_NAV_KEYS","Set","GRID_HOME_END_KEYS","renderColorPickerPopup","container","config","classList","add","activeColor","getState","columns","totalSwatches","colors","length","totalRows","Math","ceil","resetBtn","document","createElement","className","textContent","resetLabel","addEventListener","e","preventDefault","stopPropagation","executeCommand","resetCommand","onClose","key","appendChild","grid","setAttribute","ariaLabelPrefix","swatches","focusedIndex","rowIdx","row","colIdx","swatchIdx","colorName","getColorName","isActive","toLowerCase","swatch","String","dataset","index","style","backgroundColor","title","isLightColor","border","push","applySwatchTabindex","idx","target","Number","has","currentRow","floor","currentCol","maxRows","maxCols","newRow","newCol","navigateGrid","newIdx","focus","rowStart","rowEnd","min","i","HEX_COLOR_PATTERN","resolveColors","fallbackPalette","pluginName","invalid","c","value","test","Error","join","seen","unique","normalized"],"mappings":";;;;;;;AACO,MAAMA,IAAmB;ACuBzB,SAASC,EAAeC,IAAoBC,IAAAA;AAClD,QAAMC,KAAMF,GAAMG;AAClB,MAAIC,EAAgBF,IAAM,QAAO;AAEjC,MAAIG,EAAYH,EAAAA,GAAM;AACrB,QAAIF,GAAMM,aAAa;AACtB,YAAMC,KAAOP,GAAMM,YAAYE,KAAMC,CAAAA,OAAMA,GAAEC,SAAST,EAAAA;AACtD,aAAOM,MAAQI,EAAaJ,IAAMN,MAAiBM,GAAKK,MAAMC,SAAS,OAAQ;AAAA,IAChF;AACA,UAAMC,KAAQd,GAAMe,SAASb,GAAIc,OAAOC;AACxC,QAAA,CAAKH,GAAO,QAAO;AACnB,UACMP,KADQW,EAAsBJ,IAAOZ,GAAIc,OAAOG,MAAAA,EACnCX,KAAMC,CAAAA,OAAMA,GAAEC,SAAST;AAC1C,WAAOM,MAAQI,EAAaJ,IAAMN,EAAAA,IAA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ACAgE,IACAC,IAAAA;AAEA,MAAA,CAAKjE,MAA4B,MAAlBA,GAAOC,OAAc,QAAO+D;AAE3C,QAAME,KAAoBlE,GAAO/B,OAAQkG,CAAAA;AAAM,WAjBhBC,KAiBiCD,KAhBzDL,EAAkBO,KAAKD;AADxB,QAAyBA;AAAAA,EAAAA,CAAAA;AAkB/B,MAAIF,GAAQjE,SAAS,EACpB,OAAM,IAAIqE,MACT,GAAGL,EAAAA,2BAAqCC,GAAQK,KAAK;AAIvD,QAAMC,yBAAwBnF,OACxBoF,KAAmB,CAAA;AACzB,aAAWtH,MAAS6C,IAAQ;AAC3B,UAAM0E,KAAqBvH,GAAM6E,YAAAA;AAC5BwC,IAAAA,GAAKzB,IAAI2B,EAAAA,MACbF,GAAK7E,IAAI+E,EAAAA,GACTD,GAAO/B,KAAKgC,EAAAA;AAAAA,EAEd;AACA,SAAOD;AACR;"}
@@ -1,461 +0,0 @@
1
- import { g as t, b as n, c as e, d as o, a as r, h as c, e as i, f as s, j as l, k as f, l as u } from "./Document-CI3iCwEP.mjs";
2
- import { f as d } from "./NodeResolver-D68ZLXti.mjs";
3
- import { i as a, a as k, c as h, s as b, b as g, d as m } from "./Selection-D5ZjXoB7.mjs";
4
- import { m as p, i as I } from "./TypeBrands-C09nE2qO.mjs";
5
- function B() {
6
- return { nodeTypes: ["paragraph"], markTypes: ["bold", "italic", "underline"], getNodeSpec: () => {
7
- } };
8
- }
9
- function S(t2) {
10
- return { nodeTypes: t2.getNodeTypes(), markTypes: t2.getMarkTypes(), getNodeSpec: (n2) => t2.getNodeSpec(n2) };
11
- }
12
- function x(t2, n2) {
13
- return t2.markTypes.includes(n2);
14
- }
15
- function O(t2, n2) {
16
- return t2.nodeTypes.includes(n2);
17
- }
18
- const T = { bold: true, italic: true, underline: true };
19
- function N(t2, n2) {
20
- const e2 = t2.getBlock(n2);
21
- if (!e2) return false;
22
- const o2 = t2.schema.getNodeSpec;
23
- return !!o2 && true === o2(e2.type)?.isVoid;
24
- }
25
- function y(c2, i2) {
26
- const s2 = d(c2.doc, i2.nodeId);
27
- if (!s2) return null;
28
- const l2 = s2.length > 1 ? s2.slice(0, -1) : [], f2 = 0 === l2.length ? c2.doc.children : (() => {
29
- const t2 = c2.getBlock(l2[l2.length - 1]);
30
- return t2 ? t2.children : [];
31
- })(), u2 = f2.findIndex((t2) => "id" in t2 && t2.id === i2.nodeId);
32
- if (u2 < 0) return null;
33
- const a2 = c2.transaction("input");
34
- if (1 === f2.length && 0 === l2.length) {
35
- const t2 = n();
36
- return a2.insertNode(l2, 0, e("paragraph", [o("")], t2)), a2.removeNode(l2, 1), a2.setSelection(h(t2, 0)), a2.build();
37
- }
38
- a2.removeNode(l2, u2);
39
- const k2 = f2[u2 - 1];
40
- if (k2 && r(k2)) {
41
- const n2 = (function(t2) {
42
- let n3 = t2;
43
- for (; ; ) {
44
- let t3;
45
- for (let e2 = n3.children.length - 1; e2 >= 0; e2--) {
46
- const o2 = n3.children[e2];
47
- if (o2 && r(o2)) {
48
- t3 = o2;
49
- break;
50
- }
51
- }
52
- if (!t3) return n3.id;
53
- n3 = t3;
54
- }
55
- })(k2);
56
- if (n2) {
57
- const e2 = c2.getBlock(n2), o2 = e2 ? t(e2) : 0;
58
- a2.setSelection(h(n2, o2));
59
- }
60
- } else {
61
- const t2 = f2[u2 + 1];
62
- if (t2 && r(t2)) {
63
- const n2 = (function(t3) {
64
- let n3 = t3;
65
- for (; ; ) {
66
- const t4 = n3.children.find((t5) => r(t5));
67
- if (!t4) return n3.id;
68
- n3 = t4;
69
- }
70
- })(t2);
71
- n2 && a2.setSelection(h(n2, 0));
72
- }
73
- }
74
- return a2.build();
75
- }
76
- function A(n2, e2, o2) {
77
- const r2 = n2.getBlockOrder(), c2 = r2.indexOf(e2.from.blockId), i2 = r2.indexOf(e2.to.blockId);
78
- for (let s2 = c2; s2 <= i2; s2++) {
79
- const l2 = r2[s2];
80
- if (!l2) continue;
81
- const f2 = n2.getBlock(l2);
82
- if (!f2) continue;
83
- const u2 = s2 === c2 ? e2.from.offset : 0, d2 = s2 === i2 ? e2.to.offset : t(f2);
84
- u2 !== d2 && o2(l2, u2, d2);
85
- }
86
- }
87
- function M(t2, n2, e2 = T) {
88
- if ((function(t3, n3) {
89
- const e3 = t3;
90
- return "bold" === e3 ? !n3.bold : "italic" === e3 ? !n3.italic : "underline" === e3 && !n3.underline;
91
- })(n2, e2)) return null;
92
- if (!x(t2.schema, n2)) return null;
93
- if (a(t2.selection)) return null;
94
- const o2 = { type: n2 }, r2 = t2.selection;
95
- if (k(r2)) {
96
- const e3 = t2.getBlock(r2.anchor.blockId);
97
- if (!e3) return null;
98
- const s3 = t2.storedMarks ?? i(e3, r2.anchor.offset), l3 = c(s3, n2) ? s3.filter((t3) => t3.type !== n2) : [...s3, o2];
99
- return t2.transaction("command").setStoredMarks(l3, t2.storedMarks).setSelection(r2).build();
100
- }
101
- const s2 = b(r2, t2.getBlockOrder()), l2 = t2.transaction("command"), f2 = j(t2, n2);
102
- return A(t2, s2, (t3, n3, e3) => {
103
- f2 ? l2.removeMark(t3, n3, e3, o2) : l2.addMark(t3, n3, e3, o2);
104
- }), l2.setSelection(r2), l2.build();
105
- }
106
- function j(n2, e2) {
107
- const o2 = n2.selection;
108
- if (a(o2)) return false;
109
- const r2 = n2.getBlockOrder(), c2 = b(o2, r2), i2 = r2.indexOf(c2.from.blockId), s2 = r2.indexOf(c2.to.blockId);
110
- for (let o3 = i2; o3 <= s2; o3++) {
111
- const l2 = r2[o3];
112
- if (!l2) continue;
113
- const f2 = n2.getBlock(l2);
114
- if (!f2) continue;
115
- const u2 = t(f2);
116
- if (!v(f2, o3 === i2 ? c2.from.offset : 0, o3 === s2 ? c2.to.offset : u2, e2)) return false;
117
- }
118
- return true;
119
- }
120
- function v(t2, n2, e2, o2) {
121
- if (n2 === e2) return false;
122
- let r2 = 0;
123
- for (const i2 of l(t2)) if (f(i2)) {
124
- const t3 = r2 + i2.text.length;
125
- if (t3 > n2 && r2 < e2 && !c(i2.marks, o2)) return false;
126
- r2 = t3;
127
- } else r2 += 1;
128
- return true;
129
- }
130
- function P(t2, n2) {
131
- return M(t2, p("bold"), n2);
132
- }
133
- function w(t2, n2) {
134
- return M(t2, p("italic"), n2);
135
- }
136
- function q(t2, n2) {
137
- return M(t2, p("underline"), n2);
138
- }
139
- function z(t2, r2, c2 = "input") {
140
- const s2 = t2.selection;
141
- if (a(s2)) return (function(t3, r3, c3, i2) {
142
- const s3 = d(t3.doc, r3.nodeId), l3 = s3 && s3.length > 1 ? s3.slice(0, -1) : [], f3 = 0 === l3.length ? t3.doc.children : (() => {
143
- const n2 = t3.getBlock(l3[l3.length - 1]);
144
- return n2 ? n2.children : [];
145
- })(), u3 = f3.findIndex((t4) => "id" in t4 && t4.id === r3.nodeId), a2 = n(), k2 = t3.transaction(i2), b2 = u3 >= 0 ? u3 + 1 : f3.length;
146
- return k2.insertNode(l3, b2, e("paragraph", [o("")], a2)), k2.insertText(a2, 0, c3, []), k2.setSelection(h(a2, c3.length)), k2.build();
147
- })(t2, s2, r2, c2);
148
- const l2 = t2.transaction(c2), f2 = (function(t3) {
149
- if (t3.storedMarks) return t3.storedMarks;
150
- if (a(t3.selection)) return [];
151
- const n2 = t3.getBlock(t3.selection.anchor.blockId);
152
- return n2 ? i(n2, t3.selection.anchor.offset) : [];
153
- })(t2);
154
- k(s2) || Y(t2, l2);
155
- const u2 = k(s2) ? null : b(s2, t2.getBlockOrder()), g2 = u2 ? u2.from.blockId : s2.anchor.blockId, m2 = u2 ? u2.from.offset : s2.anchor.offset;
156
- return l2.insertText(g2, m2, r2, f2), l2.setSelection(h(g2, m2 + r2.length)), l2.build();
157
- }
158
- function D(t2) {
159
- if (a(t2.selection)) return y(t2, t2.selection);
160
- if (k(t2.selection)) return null;
161
- const n2 = t2.transaction("input");
162
- Y(t2, n2);
163
- const e2 = b(t2.selection, t2.getBlockOrder());
164
- return n2.setSelection(h(e2.from.blockId, e2.from.offset)), n2.build();
165
- }
166
- function R(t2) {
167
- const n2 = t2.selection;
168
- if (a(n2)) return y(t2, n2);
169
- if (!k(n2)) return D(t2);
170
- const e2 = t2.getBlock(n2.anchor.blockId);
171
- return e2 ? n2.anchor.offset > 0 ? t2.transaction("input").deleteTextAt(e2.id, n2.anchor.offset - 1, n2.anchor.offset).setSelection(h(e2.id, n2.anchor.offset - 1)).build() : Q(t2) : null;
172
- }
173
- function V(n2) {
174
- const e2 = n2.selection;
175
- if (a(e2)) return y(n2, e2);
176
- if (!k(e2)) return D(n2);
177
- const o2 = n2.getBlock(e2.anchor.blockId);
178
- if (!o2) return null;
179
- const r2 = t(o2);
180
- return e2.anchor.offset < r2 ? n2.transaction("input").deleteTextAt(o2.id, e2.anchor.offset, e2.anchor.offset + 1).setSelection(h(o2.id, e2.anchor.offset)).build() : U(n2);
181
- }
182
- function _(t2) {
183
- const n2 = t2.selection;
184
- if (a(n2)) return y(t2, n2);
185
- if (!k(n2)) return D(t2);
186
- const e2 = t2.getBlock(n2.anchor.blockId);
187
- if (!e2) return null;
188
- if (0 === n2.anchor.offset) return Q(t2);
189
- const o2 = (function(t3, n3) {
190
- let e3 = n3 - 1;
191
- for (; e3 >= 0; ) {
192
- const n4 = u(t3, e3);
193
- if (!n4 || "inline" === n4.kind) break;
194
- if (!/\s/.test(n4.char)) break;
195
- e3--;
196
- }
197
- if (e3 >= 0) {
198
- const n4 = u(t3, e3);
199
- if ("inline" === n4?.kind) return e3;
200
- }
201
- for (; e3 >= 0; ) {
202
- const n4 = u(t3, e3);
203
- if (!n4 || "inline" === n4.kind) break;
204
- if (/\s/.test(n4.char)) break;
205
- e3--;
206
- }
207
- return e3 + 1;
208
- })(e2, n2.anchor.offset);
209
- return t2.transaction("input").deleteTextAt(e2.id, o2, n2.anchor.offset).setSelection(h(e2.id, o2)).build();
210
- }
211
- function C(n2) {
212
- const e2 = n2.selection;
213
- if (a(e2)) return y(n2, e2);
214
- if (!k(e2)) return D(n2);
215
- const o2 = n2.getBlock(e2.anchor.blockId);
216
- if (!o2) return null;
217
- const r2 = t(o2);
218
- if (e2.anchor.offset === r2) return U(n2);
219
- const c2 = (function(n3, e3) {
220
- const o3 = t(n3);
221
- let r3 = e3;
222
- for (; r3 < o3; ) {
223
- const t2 = u(n3, r3);
224
- if (!t2 || "inline" === t2.kind) break;
225
- if (/\s/.test(t2.char)) break;
226
- r3++;
227
- }
228
- if (r3 === e3 && r3 < o3) {
229
- const t2 = u(n3, r3);
230
- if ("inline" === t2?.kind) return r3 + 1;
231
- }
232
- for (; r3 < o3; ) {
233
- const t2 = u(n3, r3);
234
- if (!t2 || "inline" === t2.kind) break;
235
- if (!/\s/.test(t2.char)) break;
236
- r3++;
237
- }
238
- return r3;
239
- })(o2, e2.anchor.offset);
240
- return n2.transaction("input").deleteTextAt(o2.id, e2.anchor.offset, c2).setSelection(h(o2.id, e2.anchor.offset)).build();
241
- }
242
- function E(t2) {
243
- const n2 = t2.selection;
244
- if (a(n2)) return y(t2, n2);
245
- if (!k(n2)) return D(t2);
246
- const e2 = t2.getBlock(n2.anchor.blockId);
247
- return e2 ? 0 === n2.anchor.offset ? Q(t2) : t2.transaction("input").deleteTextAt(e2.id, 0, n2.anchor.offset).setSelection(h(e2.id, 0)).build() : null;
248
- }
249
- function F(n2) {
250
- const e2 = n2.selection;
251
- if (a(e2)) return y(n2, e2);
252
- if (!k(e2)) return D(n2);
253
- const o2 = n2.getBlock(e2.anchor.blockId);
254
- if (!o2) return null;
255
- const r2 = t(o2);
256
- return e2.anchor.offset === r2 ? U(n2) : n2.transaction("input").deleteTextAt(o2.id, e2.anchor.offset, r2).setSelection(h(o2.id, e2.anchor.offset)).build();
257
- }
258
- function G(t2) {
259
- const r2 = t2.selection;
260
- if (a(r2)) return (function(t3, r3) {
261
- const c3 = d(t3.doc, r3.nodeId);
262
- if (!c3) return null;
263
- const i3 = c3.length > 1 ? c3.slice(0, -1) : [], s3 = (0 === i3.length ? t3.doc.children : (() => {
264
- const n2 = t3.getBlock(i3[i3.length - 1]);
265
- return n2 ? n2.children : [];
266
- })()).findIndex((t4) => "id" in t4 && t4.id === r3.nodeId);
267
- if (s3 < 0) return null;
268
- const l3 = n(), f2 = t3.transaction("input");
269
- return f2.insertNode(i3, s3 + 1, e("paragraph", [o("")], l3)), f2.setSelection(h(l3, 0)), f2.build();
270
- })(t2, r2);
271
- const c2 = t2.transaction("input");
272
- k(r2) || Y(t2, c2);
273
- const i2 = k(r2) ? r2.anchor.blockId : b(r2, t2.getBlockOrder()).from.blockId, s2 = k(r2) ? r2.anchor.offset : b(r2, t2.getBlockOrder()).from.offset, l2 = n();
274
- return c2.splitBlock(i2, s2, l2), c2.setSelection(h(l2, 0)), c2.build();
275
- }
276
- function H(t2) {
277
- const n2 = t2.selection;
278
- if (a(n2)) return null;
279
- const e2 = t2.transaction("input");
280
- k(n2) || Y(t2, e2);
281
- const o2 = k(n2) ? null : b(n2, t2.getBlockOrder()), r2 = o2 ? o2.from.blockId : n2.anchor.blockId, c2 = o2 ? o2.from.offset : n2.anchor.offset, i2 = s(I("hard_break"));
282
- return e2.insertInlineNode(r2, c2, i2), e2.setSelection(h(r2, c2 + 1)), e2.build();
283
- }
284
- function J(t2, n2, e2) {
285
- const o2 = t2.getNodePath(n2), r2 = t2.getNodePath(e2);
286
- if (!o2 || !r2) return false;
287
- if (o2.length !== r2.length) return false;
288
- for (let t3 = 0; t3 < o2.length - 1; t3++) if (o2[t3] !== r2[t3]) return false;
289
- return true;
290
- }
291
- function K(t2, n2) {
292
- const e2 = t2.schema.getNodeSpec;
293
- if (!e2) return false;
294
- const o2 = t2.getNodePath(n2);
295
- if (!o2 || o2.length <= 1) return false;
296
- for (let n3 = 0; n3 < o2.length - 1; n3++) {
297
- const r2 = o2[n3];
298
- if (!r2) continue;
299
- const c2 = t2.getBlock(r2);
300
- if (!c2) continue;
301
- const i2 = e2(c2.type);
302
- if (i2?.isolating) return true;
303
- }
304
- return false;
305
- }
306
- function L(t2, n2) {
307
- const e2 = t2.schema.getNodeSpec;
308
- if (!e2) return false;
309
- const o2 = t2.getBlock(n2);
310
- return !!o2 && true === e2(o2.type)?.isolating;
311
- }
312
- function Q(n2) {
313
- const e2 = n2.selection;
314
- if (a(e2)) return null;
315
- const o2 = n2.getBlockOrder(), r2 = o2.indexOf(e2.anchor.blockId);
316
- if (r2 <= 0) return null;
317
- const c2 = o2[r2 - 1];
318
- if (!c2) return null;
319
- if (L(n2, e2.anchor.blockId) || L(n2, c2)) return null;
320
- if (!J(n2, e2.anchor.blockId, c2) && K(n2, e2.anchor.blockId)) return null;
321
- if (N(n2, c2)) {
322
- const t2 = d(n2.doc, c2) ?? [];
323
- return n2.transaction("input").setSelection(g(c2, t2)).build();
324
- }
325
- const i2 = n2.getBlock(c2);
326
- if (!i2) return null;
327
- const s2 = t(i2);
328
- return n2.transaction("input").mergeBlocksAt(c2, e2.anchor.blockId).setSelection(h(c2, s2)).build();
329
- }
330
- function U(t2) {
331
- const n2 = t2.selection;
332
- if (a(n2)) return null;
333
- const e2 = t2.getBlockOrder(), o2 = e2.indexOf(n2.anchor.blockId);
334
- if (o2 >= e2.length - 1) return null;
335
- const r2 = e2[o2 + 1];
336
- if (!r2) return null;
337
- if (L(t2, n2.anchor.blockId) || L(t2, r2)) return null;
338
- if (!J(t2, n2.anchor.blockId, r2) && K(t2, n2.anchor.blockId)) return null;
339
- if (N(t2, r2)) {
340
- const n3 = d(t2.doc, r2) ?? [];
341
- return t2.transaction("input").setSelection(g(r2, n3)).build();
342
- }
343
- return t2.transaction("input").mergeBlocksAt(n2.anchor.blockId, r2).setSelection(h(n2.anchor.blockId, n2.anchor.offset)).build();
344
- }
345
- function W(n2) {
346
- const e2 = n2.doc.children, o2 = e2[0], r2 = e2[e2.length - 1];
347
- if (!o2 || !r2) return n2.transaction("command").setSelection(n2.selection).build();
348
- const c2 = t(r2);
349
- return n2.transaction("command").setSelection(m({ blockId: o2.id, offset: 0 }, { blockId: r2.id, offset: c2 })).build();
350
- }
351
- function X(t2, n2) {
352
- const e2 = t2.selection;
353
- if (a(e2)) return false;
354
- if (k(e2)) {
355
- if (t2.storedMarks) return c(t2.storedMarks, n2);
356
- const o2 = t2.getBlock(e2.anchor.blockId);
357
- if (!o2) return false;
358
- const r2 = i(o2, e2.anchor.offset);
359
- return c(r2, n2);
360
- }
361
- return j(t2, n2);
362
- }
363
- function Y(n2, e2) {
364
- if (a(n2.selection)) return;
365
- const o2 = n2.getBlockOrder(), r2 = b(n2.selection, o2), c2 = o2.indexOf(r2.from.blockId), i2 = o2.indexOf(r2.to.blockId);
366
- if (c2 === i2) e2.deleteTextAt(r2.from.blockId, r2.from.offset, r2.to.offset);
367
- else {
368
- const s2 = n2.getBlock(r2.from.blockId);
369
- if (!s2) return;
370
- const l2 = t(s2);
371
- r2.from.offset < l2 && e2.deleteTextAt(r2.from.blockId, r2.from.offset, l2), r2.to.offset > 0 && e2.deleteTextAt(r2.to.blockId, 0, r2.to.offset);
372
- for (let s3 = c2 + 1; s3 < i2; s3++) {
373
- const c3 = o2[s3];
374
- if (!c3) continue;
375
- const i3 = n2.getBlock(c3);
376
- if (!i3) continue;
377
- const l3 = t(i3);
378
- l3 > 0 && e2.deleteTextAt(c3, 0, l3), e2.mergeBlocksAt(r2.from.blockId, c3);
379
- }
380
- e2.mergeBlocksAt(r2.from.blockId, r2.to.blockId);
381
- }
382
- }
383
- function Z(n2, e2) {
384
- const o2 = n2.selection, r2 = n2.getBlockOrder();
385
- if (a(o2)) {
386
- const c3 = r2.indexOf(o2.nodeId);
387
- if ("left" === e2 || "up" === e2) {
388
- if (c3 > 0) {
389
- const e3 = r2[c3 - 1];
390
- if (!e3) return null;
391
- if (N(n2, e3)) {
392
- const t2 = d(n2.doc, e3) ?? [];
393
- return n2.transaction("input").setSelection(g(e3, t2)).build();
394
- }
395
- const o3 = n2.getBlock(e3), i3 = o3 ? t(o3) : 0;
396
- return n2.transaction("input").setSelection(h(e3, i3)).build();
397
- }
398
- return null;
399
- }
400
- if (c3 < r2.length - 1) {
401
- const t2 = r2[c3 + 1];
402
- if (!t2) return null;
403
- if (N(n2, t2)) {
404
- const e3 = d(n2.doc, t2) ?? [];
405
- return n2.transaction("input").setSelection(g(t2, e3)).build();
406
- }
407
- return n2.transaction("input").setSelection(h(t2, 0)).build();
408
- }
409
- return null;
410
- }
411
- if (!k(o2)) return null;
412
- const c2 = r2.indexOf(o2.anchor.blockId), i2 = n2.getBlock(o2.anchor.blockId);
413
- if (!i2) return null;
414
- const s2 = t(i2);
415
- if (("right" === e2 || "down" === e2) && o2.anchor.offset === s2 && c2 < r2.length - 1) {
416
- const t2 = r2[c2 + 1];
417
- if (t2 && N(n2, t2)) {
418
- const e3 = d(n2.doc, t2) ?? [];
419
- return n2.transaction("input").setSelection(g(t2, e3)).build();
420
- }
421
- }
422
- if (("left" === e2 || "up" === e2) && 0 === o2.anchor.offset && c2 > 0) {
423
- const t2 = r2[c2 - 1];
424
- if (t2 && N(n2, t2)) {
425
- const e3 = d(n2.doc, t2) ?? [];
426
- return n2.transaction("input").setSelection(g(t2, e3)).build();
427
- }
428
- }
429
- return null;
430
- }
431
- export {
432
- M as A,
433
- q as B,
434
- y as a,
435
- G as b,
436
- D as c,
437
- B as d,
438
- R as e,
439
- A as f,
440
- F as g,
441
- E as h,
442
- z as i,
443
- C as j,
444
- _ as k,
445
- V as l,
446
- H as m,
447
- Z as n,
448
- Y as o,
449
- x as p,
450
- O as q,
451
- S as r,
452
- W as s,
453
- X as t,
454
- K as u,
455
- N as v,
456
- Q as w,
457
- J as x,
458
- P as y,
459
- w as z
460
- };
461
- //# sourceMappingURL=Commands-CSpSwGXv.mjs.map