@notectl/core 1.6.1 → 1.7.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 (201) hide show
  1. package/README.md +2 -2
  2. package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs → AttrRegistry-Ci0qAvtS.mjs} +2 -2
  3. package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs.map → AttrRegistry-Ci0qAvtS.mjs.map} +1 -1
  4. package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs +58 -0
  5. package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs.map +1 -0
  6. package/dist/chunks/{CaretNavigation-CAJXoaae.mjs → CaretNavigation-qLfeL0So.mjs} +56 -56
  7. package/dist/chunks/{CaretNavigation-CAJXoaae.mjs.map → CaretNavigation-qLfeL0So.mjs.map} +1 -1
  8. package/dist/chunks/ColorGrid-BBkN0AOb.mjs +80 -0
  9. package/dist/chunks/ColorGrid-BBkN0AOb.mjs.map +1 -0
  10. package/dist/chunks/ColorPickerPopup-D3ysvOH-.mjs +37 -0
  11. package/dist/chunks/ColorPickerPopup-D3ysvOH-.mjs.map +1 -0
  12. package/dist/chunks/ColorValidation-CV4f1wu6.mjs +39 -0
  13. package/dist/chunks/ColorValidation-CV4f1wu6.mjs.map +1 -0
  14. package/dist/chunks/{Document-CuwE73FF.mjs → Document-DfZ1NOjs.mjs} +15 -15
  15. package/dist/chunks/{Document-CuwE73FF.mjs.map → Document-DfZ1NOjs.mjs.map} +1 -1
  16. package/dist/chunks/MarkCommands-uybmkw9l.mjs +94 -0
  17. package/dist/chunks/MarkCommands-uybmkw9l.mjs.map +1 -0
  18. package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs → NavigationUtils-Cspt2ZrK.mjs} +3 -3
  19. package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs.map → NavigationUtils-Cspt2ZrK.mjs.map} +1 -1
  20. package/dist/chunks/{NodeResolver-B-wzthAQ.mjs → NodeResolver-CzLmmrph.mjs} +2 -2
  21. package/dist/chunks/{NodeResolver-B-wzthAQ.mjs.map → NodeResolver-CzLmmrph.mjs.map} +1 -1
  22. package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs +30 -0
  23. package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs.map +1 -0
  24. package/dist/chunks/RangeIterator-Bye0UtbY.mjs +16 -0
  25. package/dist/chunks/RangeIterator-Bye0UtbY.mjs.map +1 -0
  26. package/dist/chunks/{Selection-DmFDwiPJ.mjs → Selection-BRTab5hO.mjs} +7 -7
  27. package/dist/chunks/{Selection-DmFDwiPJ.mjs.map → Selection-BRTab5hO.mjs.map} +1 -1
  28. package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -1
  29. package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs → ToolbarKeyboardNav-DhpL8zNV.mjs} +3 -3
  30. package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs.map → ToolbarKeyboardNav-DhpL8zNV.mjs.map} +1 -1
  31. package/dist/chunks/{ToolbarPlugin-B6JETWaw.mjs → ToolbarPlugin-B7oJRzpl.mjs} +339 -127
  32. package/dist/chunks/ToolbarPlugin-B7oJRzpl.mjs.map +1 -0
  33. package/dist/chunks/{index-CPyHuEzh.mjs → index-Bt_d4IqB.mjs} +12 -12
  34. package/dist/chunks/{index-CPyHuEzh.mjs.map → index-Bt_d4IqB.mjs.map} +1 -1
  35. package/dist/chunks/{index-BigJ0z6n.mjs → index-CFJFD4lF.mjs} +8 -8
  36. package/dist/chunks/{index-BigJ0z6n.mjs.map → index-CFJFD4lF.mjs.map} +1 -1
  37. package/dist/chunks/{index-D67mP19g.mjs → index-CFPP456m.mjs} +13 -13
  38. package/dist/chunks/{index-D67mP19g.mjs.map → index-CFPP456m.mjs.map} +1 -1
  39. package/dist/chunks/{index-DQryjfJs.mjs → index-CH1r7DL-.mjs} +259 -300
  40. package/dist/chunks/index-CH1r7DL-.mjs.map +1 -0
  41. package/dist/chunks/{index-tBDVaSjG.mjs → index-CfyS_pgH.mjs} +28 -21
  42. package/dist/chunks/index-CfyS_pgH.mjs.map +1 -0
  43. package/dist/chunks/{index-DIAXWwgJ.mjs → index-Ckzqtn5D.mjs} +17 -14
  44. package/dist/chunks/{index-DIAXWwgJ.mjs.map → index-Ckzqtn5D.mjs.map} +1 -1
  45. package/dist/chunks/{index-BDMP86F4.mjs → index-CrKz_IEn.mjs} +35 -35
  46. package/dist/chunks/{index-BDMP86F4.mjs.map → index-CrKz_IEn.mjs.map} +1 -1
  47. package/dist/chunks/{index-B0UFAfyb.mjs → index-DGKQhSAl.mjs} +5 -5
  48. package/dist/chunks/{index-B0UFAfyb.mjs.map → index-DGKQhSAl.mjs.map} +1 -1
  49. package/dist/chunks/{index-83QoUENW.mjs → index-DIvHQtE2.mjs} +12 -9
  50. package/dist/chunks/{index-83QoUENW.mjs.map → index-DIvHQtE2.mjs.map} +1 -1
  51. package/dist/chunks/index-DayTn6Re.mjs +166 -0
  52. package/dist/chunks/index-DayTn6Re.mjs.map +1 -0
  53. package/dist/chunks/index-Deag_lVi.mjs +121 -0
  54. package/dist/chunks/index-Deag_lVi.mjs.map +1 -0
  55. package/dist/chunks/{index--z_Txzej.mjs → index-DmuuFS5D.mjs} +6 -6
  56. package/dist/chunks/{index--z_Txzej.mjs.map → index-DmuuFS5D.mjs.map} +1 -1
  57. package/dist/chunks/{index-DRZwd-1W.mjs → index-DoCvDkfj.mjs} +79 -96
  58. package/dist/chunks/index-DoCvDkfj.mjs.map +1 -0
  59. package/dist/chunks/index-DuRNETFv.mjs +296 -0
  60. package/dist/chunks/index-DuRNETFv.mjs.map +1 -0
  61. package/dist/chunks/{index-CPjf45-o.mjs → index-Dum8yE_t.mjs} +14 -14
  62. package/dist/chunks/{index-CPjf45-o.mjs.map → index-Dum8yE_t.mjs.map} +1 -1
  63. package/dist/chunks/{index-BWXkaC2Z.mjs → index-Dy6SllXW.mjs} +53 -65
  64. package/dist/chunks/index-Dy6SllXW.mjs.map +1 -0
  65. package/dist/chunks/{index-D8tbbW97.mjs → index-E7OgN7hM.mjs} +2 -2
  66. package/dist/chunks/{index-D8tbbW97.mjs.map → index-E7OgN7hM.mjs.map} +1 -1
  67. package/dist/chunks/{index-D4GKlc-A.mjs → index-yhz2qeeh.mjs} +224 -222
  68. package/dist/chunks/index-yhz2qeeh.mjs.map +1 -0
  69. package/dist/commands/AttributedMarkCommands.d.ts +46 -0
  70. package/dist/commands/AttributedMarkCommands.d.ts.map +1 -0
  71. package/dist/commands/CommandHelpers.d.ts +21 -0
  72. package/dist/commands/CommandHelpers.d.ts.map +1 -0
  73. package/dist/commands/Commands.d.ts +2 -8
  74. package/dist/commands/Commands.d.ts.map +1 -1
  75. package/dist/commands/DeleteCommands.d.ts.map +1 -1
  76. package/dist/commands/GapCursorCommands.d.ts.map +1 -1
  77. package/dist/commands/NodeSelectionCommands.d.ts.map +1 -1
  78. package/dist/commands/PasteCommand.d.ts.map +1 -1
  79. package/dist/commands/RangeIterator.d.ts +10 -0
  80. package/dist/commands/RangeIterator.d.ts.map +1 -0
  81. package/dist/editor/DocumentParser.d.ts.map +1 -1
  82. package/dist/editor/DocumentSerializer.d.ts +2 -0
  83. package/dist/editor/DocumentSerializer.d.ts.map +1 -1
  84. package/dist/editor/MarkSerializer.d.ts +11 -0
  85. package/dist/editor/MarkSerializer.d.ts.map +1 -0
  86. package/dist/editor/NotectlEditor.d.ts +6 -3
  87. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  88. package/dist/editor/PaperLayoutController.d.ts +2 -0
  89. package/dist/editor/PaperLayoutController.d.ts.map +1 -1
  90. package/dist/editor/styles/font-select.d.ts +1 -1
  91. package/dist/editor/styles/font-select.d.ts.map +1 -1
  92. package/dist/editor/styles/font-size-select.d.ts +1 -1
  93. package/dist/editor/styles/font-size-select.d.ts.map +1 -1
  94. package/dist/editor/styles/heading-select.d.ts +1 -1
  95. package/dist/editor/styles/heading-select.d.ts.map +1 -1
  96. package/dist/editor/styles/toolbar.d.ts +1 -1
  97. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  98. package/dist/index.d.ts +11 -2
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/input/ClipboardHandler.d.ts +0 -2
  101. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  102. package/dist/model/MarkSpec.d.ts +6 -0
  103. package/dist/model/MarkSpec.d.ts.map +1 -1
  104. package/dist/notectl-core.mjs +2245 -2085
  105. package/dist/notectl-core.mjs.map +1 -1
  106. package/dist/notectl-core.umd.js +5568 -5345
  107. package/dist/notectl-core.umd.js.map +1 -1
  108. package/dist/plugins/PluginManager.d.ts +2 -0
  109. package/dist/plugins/PluginManager.d.ts.map +1 -1
  110. package/dist/plugins/alignment.mjs +3 -3
  111. package/dist/plugins/blockquote.mjs +2 -2
  112. package/dist/plugins/caret-navigation.mjs +1 -1
  113. package/dist/plugins/code-block.mjs +3 -3
  114. package/dist/plugins/font/FontPlugin.d.ts +0 -6
  115. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  116. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
  117. package/dist/plugins/font-size/FontSizePlugin.d.ts +0 -5
  118. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  119. package/dist/plugins/font-size.mjs +2 -2
  120. package/dist/plugins/font.mjs +2 -2
  121. package/dist/plugins/gap-cursor.mjs +7 -7
  122. package/dist/plugins/hard-break.mjs +2 -25
  123. package/dist/plugins/hard-break.mjs.map +1 -1
  124. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +1 -7
  125. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -1
  126. package/dist/plugins/heading/HeadingPlugin.d.ts +0 -6
  127. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
  128. package/dist/plugins/heading.mjs +2 -2
  129. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  130. package/dist/plugins/highlight.mjs +2 -2
  131. package/dist/plugins/horizontal-rule.mjs +2 -2
  132. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  133. package/dist/plugins/image.mjs +3 -3
  134. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  135. package/dist/plugins/link.mjs +2 -2
  136. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  137. package/dist/plugins/list.mjs +2 -2
  138. package/dist/plugins/shared/ColorGrid.d.ts +25 -0
  139. package/dist/plugins/shared/ColorGrid.d.ts.map +1 -0
  140. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
  141. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
  142. package/dist/plugins/shared/ColorValidation.d.ts +13 -2
  143. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
  144. package/dist/plugins/shared/PopupKeyboardPatterns.d.ts +43 -0
  145. package/dist/plugins/shared/PopupKeyboardPatterns.d.ts.map +1 -0
  146. package/dist/plugins/shared/PopupManager.d.ts +45 -0
  147. package/dist/plugins/shared/PopupManager.d.ts.map +1 -0
  148. package/dist/plugins/shared/PopupPositioning.d.ts +21 -0
  149. package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -0
  150. package/dist/plugins/strikethrough.mjs +2 -2
  151. package/dist/plugins/super-sub.mjs +2 -2
  152. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
  153. package/dist/plugins/table/TableContextMenu.d.ts +2 -1
  154. package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
  155. package/dist/plugins/table.mjs +10 -10
  156. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  157. package/dist/plugins/text-color.mjs +2 -2
  158. package/dist/plugins/text-formatting.mjs +1 -1
  159. package/dist/plugins/toolbar/ToolbarItem.d.ts +11 -2
  160. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
  161. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +5 -1
  162. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
  163. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
  164. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  165. package/dist/plugins/toolbar/ToolbarPopupController.d.ts +9 -1
  166. package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
  167. package/dist/plugins/toolbar/index.d.ts +1 -1
  168. package/dist/plugins/toolbar/index.d.ts.map +1 -1
  169. package/dist/plugins/toolbar.mjs +1 -1
  170. package/dist/presets/FullPreset.d.ts +16 -0
  171. package/dist/presets/FullPreset.d.ts.map +1 -0
  172. package/dist/presets/MinimalPreset.d.ts +7 -0
  173. package/dist/presets/MinimalPreset.d.ts.map +1 -0
  174. package/dist/presets/PresetTypes.d.ts +50 -0
  175. package/dist/presets/PresetTypes.d.ts.map +1 -0
  176. package/dist/state/BlockTreeOps.d.ts +21 -0
  177. package/dist/state/BlockTreeOps.d.ts.map +1 -0
  178. package/dist/state/InlineContentOps.d.ts +37 -0
  179. package/dist/state/InlineContentOps.d.ts.map +1 -0
  180. package/dist/state/StepApplication.d.ts.map +1 -1
  181. package/dist/test/PluginTestUtils.d.ts +4 -0
  182. package/dist/test/PluginTestUtils.d.ts.map +1 -1
  183. package/package.json +2 -2
  184. package/dist/chunks/ColorNames-BdsHwA2f.mjs +0 -59
  185. package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +0 -1
  186. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +0 -125
  187. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +0 -1
  188. package/dist/chunks/Commands-CicwYoTQ.mjs +0 -286
  189. package/dist/chunks/Commands-CicwYoTQ.mjs.map +0 -1
  190. package/dist/chunks/MarkCommands-CC37WA7Z.mjs +0 -94
  191. package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +0 -1
  192. package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +0 -1
  193. package/dist/chunks/index-BWXkaC2Z.mjs.map +0 -1
  194. package/dist/chunks/index-D4GKlc-A.mjs.map +0 -1
  195. package/dist/chunks/index-DQryjfJs.mjs.map +0 -1
  196. package/dist/chunks/index-DRZwd-1W.mjs.map +0 -1
  197. package/dist/chunks/index-DUC1X43Z.mjs +0 -209
  198. package/dist/chunks/index-DUC1X43Z.mjs.map +0 -1
  199. package/dist/chunks/index-DipAT_Q9.mjs +0 -191
  200. package/dist/chunks/index-DipAT_Q9.mjs.map +0 -1
  201. package/dist/chunks/index-tBDVaSjG.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorNames-BdsHwA2f.mjs","sources":["../../src/plugins/shared/ColorValidation.ts","../../src/plugins/shared/ColorNames.ts"],"sourcesContent":["/**\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// --- CSS Color Validation (broad format support for paste / API input) ---\n\n/** Matches `rgb(r, g, b)` and `rgba(r, g, b, a)` with integer or percentage values. */\nconst RGB_PATTERN: RegExp =\n\t/^rgba?\\(\\s*(\\d{1,3}%?\\s*,\\s*){2}\\d{1,3}%?(\\s*,\\s*(0|1|0?\\.\\d+))?\\s*\\)$/;\n\n/** Matches `hsl(h, s%, l%)` and `hsla(h, s%, l%, a)`. */\nconst HSL_PATTERN: RegExp =\n\t/^hsla?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}%\\s*,\\s*\\d{1,3}%(\\s*,\\s*(0|1|0?\\.\\d+))?\\s*\\)$/;\n\n/**\n * Complete set of CSS Level 4 named colors (including `transparent`).\n * Used as an allowlist — unknown names are rejected.\n */\nconst CSS_NAMED_COLORS: ReadonlySet<string> = new Set([\n\t'aliceblue',\n\t'antiquewhite',\n\t'aqua',\n\t'aquamarine',\n\t'azure',\n\t'beige',\n\t'bisque',\n\t'black',\n\t'blanchedalmond',\n\t'blue',\n\t'blueviolet',\n\t'brown',\n\t'burlywood',\n\t'cadetblue',\n\t'chartreuse',\n\t'chocolate',\n\t'coral',\n\t'cornflowerblue',\n\t'cornsilk',\n\t'crimson',\n\t'cyan',\n\t'darkblue',\n\t'darkcyan',\n\t'darkgoldenrod',\n\t'darkgray',\n\t'darkgreen',\n\t'darkgrey',\n\t'darkkhaki',\n\t'darkmagenta',\n\t'darkolivegreen',\n\t'darkorange',\n\t'darkorchid',\n\t'darkred',\n\t'darksalmon',\n\t'darkseagreen',\n\t'darkslateblue',\n\t'darkslategray',\n\t'darkslategrey',\n\t'darkturquoise',\n\t'darkviolet',\n\t'deeppink',\n\t'deepskyblue',\n\t'dimgray',\n\t'dimgrey',\n\t'dodgerblue',\n\t'firebrick',\n\t'floralwhite',\n\t'forestgreen',\n\t'fuchsia',\n\t'gainsboro',\n\t'ghostwhite',\n\t'gold',\n\t'goldenrod',\n\t'gray',\n\t'green',\n\t'greenyellow',\n\t'grey',\n\t'honeydew',\n\t'hotpink',\n\t'indianred',\n\t'indigo',\n\t'ivory',\n\t'khaki',\n\t'lavender',\n\t'lavenderblush',\n\t'lawngreen',\n\t'lemonchiffon',\n\t'lightblue',\n\t'lightcoral',\n\t'lightcyan',\n\t'lightgoldenrodyellow',\n\t'lightgray',\n\t'lightgreen',\n\t'lightgrey',\n\t'lightpink',\n\t'lightsalmon',\n\t'lightseagreen',\n\t'lightskyblue',\n\t'lightslategray',\n\t'lightslategrey',\n\t'lightsteelblue',\n\t'lightyellow',\n\t'lime',\n\t'limegreen',\n\t'linen',\n\t'magenta',\n\t'maroon',\n\t'mediumaquamarine',\n\t'mediumblue',\n\t'mediumorchid',\n\t'mediumpurple',\n\t'mediumseagreen',\n\t'mediumslateblue',\n\t'mediumspringgreen',\n\t'mediumturquoise',\n\t'mediumvioletred',\n\t'midnightblue',\n\t'mintcream',\n\t'mistyrose',\n\t'moccasin',\n\t'navajowhite',\n\t'navy',\n\t'oldlace',\n\t'olive',\n\t'olivedrab',\n\t'orange',\n\t'orangered',\n\t'orchid',\n\t'palegoldenrod',\n\t'palegreen',\n\t'paleturquoise',\n\t'palevioletred',\n\t'papayawhip',\n\t'peachpuff',\n\t'peru',\n\t'pink',\n\t'plum',\n\t'powderblue',\n\t'purple',\n\t'rebeccapurple',\n\t'red',\n\t'rosybrown',\n\t'royalblue',\n\t'saddlebrown',\n\t'salmon',\n\t'sandybrown',\n\t'seagreen',\n\t'seashell',\n\t'sienna',\n\t'silver',\n\t'skyblue',\n\t'slateblue',\n\t'slategray',\n\t'slategrey',\n\t'snow',\n\t'springgreen',\n\t'steelblue',\n\t'tan',\n\t'teal',\n\t'thistle',\n\t'tomato',\n\t'transparent',\n\t'turquoise',\n\t'violet',\n\t'wheat',\n\t'white',\n\t'whitesmoke',\n\t'yellow',\n\t'yellowgreen',\n]);\n\n/**\n * Returns `true` when `value` is a safe CSS color value.\n * Accepts hex (`#RGB`, `#RRGGBB`), `rgb()`, `rgba()`, `hsl()`, `hsla()`,\n * and CSS named colors. Rejects anything else — defense against CSS injection\n * via manipulated color values in `style` attributes.\n */\nexport function isValidCSSColor(value: string): boolean {\n\tif (!value) return false;\n\tconst trimmed: string = value.trim().toLowerCase();\n\tif (!trimmed) return false;\n\n\treturn (\n\t\tHEX_COLOR_PATTERN.test(trimmed) ||\n\t\tRGB_PATTERN.test(trimmed) ||\n\t\tHSL_PATTERN.test(trimmed) ||\n\t\tCSS_NAMED_COLORS.has(trimmed)\n\t);\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","/**\n * Human-readable color name lookup for accessibility.\n *\n * Provides descriptive names for color swatches so screen readers\n * announce \"Red\" instead of \"#ff0000\". Covers all default palette\n * colors with a fallback algorithm for custom hex values.\n */\n\n// ---------------------------------------------------------------------------\n// Static name map — covers every default palette color\n// ---------------------------------------------------------------------------\n\nconst COLOR_NAME_MAP: ReadonlyMap<string, string> = new Map([\n\t// ── TextColor palette (70 colors) ──────────────────────────────────────\n\n\t// Row 1 — Grays\n\t['#000000', 'Black'],\n\t['#434343', 'Dark Gray 4'],\n\t['#666666', 'Dark Gray 3'],\n\t['#999999', 'Dark Gray 2'],\n\t['#b7b7b7', 'Dark Gray 1'],\n\t['#cccccc', 'Light Gray 3'],\n\t['#d9d9d9', 'Light Gray 2'],\n\t['#efefef', 'Light Gray 1'],\n\t['#f3f3f3', 'Near White'],\n\t['#ffffff', 'White'],\n\n\t// Row 2 — Vivid\n\t['#980000', 'Dark Red Berry'],\n\t['#ff0000', 'Red'],\n\t['#ff9900', 'Orange'],\n\t['#ffff00', 'Yellow'],\n\t['#00ff00', 'Green'],\n\t['#00ffff', 'Cyan'],\n\t['#4a86e8', 'Cornflower Blue'],\n\t['#0000ff', 'Blue'],\n\t['#9900ff', 'Purple'],\n\t['#ff00ff', 'Magenta'],\n\n\t// Row 3 — Light 3 (lightest tint)\n\t['#e6b8af', 'Light Red Berry 3'],\n\t['#f4cccc', 'Light Red 3'],\n\t['#fce5cd', 'Light Orange 3'],\n\t['#fff2cc', 'Light Yellow 3'],\n\t['#d9ead3', 'Light Green 3'],\n\t['#d0e0e3', 'Light Cyan 3'],\n\t['#c9daf8', 'Light Cornflower Blue 3'],\n\t['#cfe2f3', 'Light Blue 3'],\n\t['#d9d2e9', 'Light Purple 3'],\n\t['#ead1dc', 'Light Magenta 3'],\n\n\t// Row 4 — Light 2\n\t['#dd7e6b', 'Light Red Berry 2'],\n\t['#ea9999', 'Light Red 2'],\n\t['#f9cb9c', 'Light Orange 2'],\n\t['#ffe599', 'Light Yellow 2'],\n\t['#b6d7a8', 'Light Green 2'],\n\t['#a2c4c9', 'Light Cyan 2'],\n\t['#a4c2f4', 'Light Cornflower Blue 2'],\n\t['#9fc5e8', 'Light Blue 2'],\n\t['#b4a7d6', 'Light Purple 2'],\n\t['#d5a6bd', 'Light Magenta 2'],\n\n\t// Row 5 — Light 1\n\t['#cc4125', 'Light Red Berry 1'],\n\t['#e06666', 'Light Red 1'],\n\t['#f6b26b', 'Light Orange 1'],\n\t['#ffd966', 'Light Yellow 1'],\n\t['#93c47d', 'Light Green 1'],\n\t['#76a5af', 'Light Cyan 1'],\n\t['#6d9eeb', 'Light Cornflower Blue 1'],\n\t['#6fa8dc', 'Light Blue 1'],\n\t['#8e7cc3', 'Light Purple 1'],\n\t['#c27ba0', 'Light Magenta 1'],\n\n\t// Row 6 — Dark 1\n\t['#a61c00', 'Dark Red Berry 1'],\n\t['#cc0000', 'Dark Red 1'],\n\t['#e69138', 'Dark Orange 1'],\n\t['#f1c232', 'Dark Yellow 1'],\n\t['#6aa84f', 'Dark Green 1'],\n\t['#45818e', 'Dark Cyan 1'],\n\t['#3c78d8', 'Dark Cornflower Blue 1'],\n\t['#3d85c6', 'Dark Blue 1'],\n\t['#674ea7', 'Dark Purple 1'],\n\t['#a64d79', 'Dark Magenta 1'],\n\n\t// Row 7 — Dark 2\n\t['#85200c', 'Dark Red Berry 2'],\n\t['#990000', 'Dark Red 2'],\n\t['#b45f06', 'Dark Orange 2'],\n\t['#bf9000', 'Dark Yellow 2'],\n\t['#38761d', 'Dark Green 2'],\n\t['#134f5c', 'Dark Cyan 2'],\n\t['#1155cc', 'Dark Cornflower Blue 2'],\n\t['#0b5394', 'Dark Blue 2'],\n\t['#351c75', 'Dark Purple 2'],\n\t['#741b47', 'Dark Magenta 2'],\n\n\t// ── Highlight palette (50 colors, minus duplicates) ────────────────────\n\n\t// Row 1 — Classic highlighter (bright, vivid)\n\t['#fff176', 'Bright Yellow'],\n\t['#aed581', 'Light Green'],\n\t['#4dd0e1', 'Bright Cyan'],\n\t['#64b5f6', 'Sky Blue'],\n\t['#ce93d8', 'Lavender'],\n\t['#f48fb1', 'Pink'],\n\t['#ffab91', 'Peach'],\n\t['#ff8a65', 'Coral'],\n\t['#e6ee9c', 'Lime'],\n\t['#80cbc4', 'Teal'],\n\n\t// Row 2 — Light pastels\n\t['#fff9c4', 'Pale Yellow'],\n\t['#dcedc8', 'Pale Green'],\n\t['#e0f7fa', 'Pale Cyan'],\n\t['#e3f2fd', 'Pale Blue'],\n\t['#f3e5f5', 'Pale Purple'],\n\t['#fce4ec', 'Pale Pink'],\n\t['#fff3e0', 'Pale Orange'],\n\t['#fbe9e7', 'Pale Red'],\n\t['#f9fbe7', 'Pale Lime'],\n\t['#e0f2f1', 'Pale Teal'],\n\n\t// Row 3 — Medium pastels\n\t['#fff59d', 'Soft Yellow'],\n\t['#c5e1a5', 'Soft Green'],\n\t['#80deea', 'Soft Cyan'],\n\t['#90caf9', 'Soft Blue'],\n\t['#e1bee7', 'Soft Purple'],\n\t['#f8bbd0', 'Soft Pink'],\n\t['#ffcc80', 'Soft Orange'],\n\t// #ffab91 duplicate → Peach (already mapped)\n\t// #e6ee9c duplicate → Lime (already mapped)\n\t['#a5d6a7', 'Mint'],\n\n\t// Row 4 — Bold pastels\n\t['#ffee58', 'Vivid Yellow'],\n\t['#9ccc65', 'Vivid Green'],\n\t['#26c6da', 'Vivid Cyan'],\n\t['#42a5f5', 'Vivid Blue'],\n\t['#ab47bc', 'Vivid Purple'],\n\t['#ec407a', 'Vivid Pink'],\n\t['#ffa726', 'Vivid Orange'],\n\t['#ff7043', 'Red Orange'],\n\t['#d4e157', 'Vivid Lime'],\n\t['#66bb6a', 'Emerald'],\n\n\t// Row 5 — Grays and neutral highlights\n\t// #ffffff duplicate → White (already mapped)\n\t['#fafafa', 'Almost White'],\n\t['#f5f5f5', 'Lightest Gray'],\n\t['#eeeeee', 'Very Light Gray'],\n\t['#e0e0e0', 'Silver'],\n\t['#bdbdbd', 'Medium Gray'],\n\t['#e8eaf6', 'Lavender Gray'],\n\t['#efebe9', 'Warm Gray'],\n\t['#eceff1', 'Cool Gray'],\n\t// #fafafa duplicate → Almost White (already mapped)\n]);\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Returns a human-readable name for a hex color.\n *\n * Checks the static map first, then falls back to a computed\n * description based on hue, saturation, and lightness.\n */\nexport function getColorName(hex: string): string {\n\tconst name: string | undefined = COLOR_NAME_MAP.get(hex.toLowerCase());\n\tif (name) return name;\n\treturn describeColor(hex);\n}\n\n/**\n * Determines whether a color is light enough to need a visible\n * border when rendered on a white background (WCAG 1.4.11).\n *\n * Uses a contrast-ratio threshold of 3:1 against white.\n */\nexport function isLightColor(hex: string): boolean {\n\tconst luminance: number = relativeLuminance(hex);\n\t// Contrast ratio against white: (1.05) / (L + 0.05) < 3\n\t// ⟹ L > 1.05/3 − 0.05 = 0.3\n\tconst LIGHT_THRESHOLD = 0.3;\n\treturn luminance > LIGHT_THRESHOLD;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/** Expands `#RGB` to `#RRGGBB` and lowercases. */\nfunction normalizeHex(hex: string): string {\n\tconst h: string = hex.toLowerCase();\n\tif (h.length === 4) {\n\t\treturn `#${h[1]}${h[1]}${h[2]}${h[2]}${h[3]}${h[3]}`;\n\t}\n\treturn h;\n}\n\n/** Applies sRGB linearization to a single channel value (0–1). */\nfunction linearize(channel: number): number {\n\treturn channel <= 0.03928 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;\n}\n\n/** Computes WCAG relative luminance from a hex color. */\nfunction relativeLuminance(hex: string): number {\n\tconst normalized: string = normalizeHex(hex);\n\tconst r: number = linearize(Number.parseInt(normalized.slice(1, 3), 16) / 255);\n\tconst g: number = linearize(Number.parseInt(normalized.slice(3, 5), 16) / 255);\n\tconst b: number = linearize(Number.parseInt(normalized.slice(5, 7), 16) / 255);\n\treturn 0.2126 * r + 0.7152 * g + 0.0722 * b;\n}\n\n/** Hue boundary table: upper bound (degrees) → name. */\nconst HUE_NAMES: readonly (readonly [number, string])[] = [\n\t[15, 'Red'],\n\t[45, 'Orange'],\n\t[65, 'Yellow'],\n\t[150, 'Green'],\n\t[190, 'Cyan'],\n\t[250, 'Blue'],\n\t[290, 'Purple'],\n\t[330, 'Pink'],\n\t[361, 'Red'],\n];\n\n/**\n * Generates a descriptive name from a hex color using HSL analysis.\n * Produces names like \"Dark Blue\", \"Light Green\", or \"Gray\".\n */\nfunction describeColor(hex: string): string {\n\tconst normalized: string = normalizeHex(hex);\n\tconst rRaw: number = Number.parseInt(normalized.slice(1, 3), 16) / 255;\n\tconst gRaw: number = Number.parseInt(normalized.slice(3, 5), 16) / 255;\n\tconst bRaw: number = Number.parseInt(normalized.slice(5, 7), 16) / 255;\n\n\tconst max: number = Math.max(rRaw, gRaw, bRaw);\n\tconst min: number = Math.min(rRaw, gRaw, bRaw);\n\tconst lightness: number = (max + min) / 2;\n\tconst delta: number = max - min;\n\n\t// Achromatic\n\tif (delta < 0.05) {\n\t\tif (lightness < 0.15) return 'Black';\n\t\tif (lightness < 0.35) return 'Dark Gray';\n\t\tif (lightness < 0.65) return 'Gray';\n\t\tif (lightness < 0.85) return 'Light Gray';\n\t\treturn 'Near White';\n\t}\n\n\t// Compute hue in degrees\n\tlet hue = 0;\n\tif (max === rRaw) {\n\t\thue = ((gRaw - bRaw) / delta + (gRaw < bRaw ? 6 : 0)) * 60;\n\t} else if (max === gRaw) {\n\t\thue = ((bRaw - rRaw) / delta + 2) * 60;\n\t} else {\n\t\thue = ((rRaw - gRaw) / delta + 4) * 60;\n\t}\n\n\t// Look up hue name\n\tlet hueName = 'Red';\n\tfor (const [threshold, name] of HUE_NAMES) {\n\t\tif (hue < threshold) {\n\t\t\thueName = name;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Lightness modifier\n\tif (lightness < 0.25) return `Very Dark ${hueName}`;\n\tif (lightness < 0.4) return `Dark ${hueName}`;\n\tif (lightness > 0.8) return `Very Light ${hueName}`;\n\tif (lightness > 0.65) return `Light ${hueName}`;\n\treturn hueName;\n}\n"],"names":["HEX_COLOR_PATTERN","isValidHexColor","value","test","RGB_PATTERN","HSL_PATTERN","CSS_NAMED_COLORS","Set","isValidCSSColor","trimmed","trim","toLowerCase","has","resolveColors","colors","fallbackPalette","pluginName","length","invalid","filter","c","Error","join","seen","unique","color","normalized","add","push","COLOR_NAME_MAP","Map","getColorName","hex","get","normalizeHex","rRaw","Number","parseInt","slice","gRaw","bRaw","max","Math","min","lightness","delta","hue","hueName","threshold","name","HUE_NAMES","isLightColor","luminance","linearize","h","channel"],"mappings":"AAKA,MAAMA,IAA4B;AAG3B,SAASC,EAAgBC;AAC/B,SAAOF,EAAkBG,KAAKD,EAAAA;AAC/B;AAKA,MAAME,IACL,0EAGKC,IACL,iFAMKC,wBAA4CC,IAAI,CACrD,aACA,gBACA,QACA,cACA,SACA,SACA,UACA,SACA,kBACA,QACA,cACA,SACA,aACA,aACA,cACA,aACA,SACA,kBACA,YACA,WACA,QACA,YACA,YACA,iBACA,YACA,aACA,YACA,aACA,eACA,kBACA,cACA,cACA,WACA,cACA,gBACA,iBACA,iBACA,iBACA,iBACA,cACA,YACA,eACA,WACA,WACA,cACA,aACA,eACA,eACA,WACA,aACA,cACA,QACA,aACA,QACA,SACA,eACA,QACA,YACA,WACA,aACA,UACA,SACA,SACA,YACA,iBACA,aACA,gBACA,aACA,cACA,aACA,wBACA,aACA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CH,KAAY,OAAa,SAASG,EAAAA,KAC/BA;AAAAA,EACR,GA1GsBf,EAAAA;AACtB;AAQO,SAASmB,EAAanB,IAAAA;AAC5B,QAAMoB,MA0BP,SAA2BpB;AAC1B,UAAMN,KAAqBQ,EAAaF,EAAAA;AAIxC,WAAO,SAHWqB,EAAUjB,OAAOC,SAASX,GAAWY,MAAM,GAAG,IAAI,EAAA,IAAM,GAAA,IAGtD,SAFFe,EAAUjB,OAAOC,SAASX,GAAWY,MAAM,GAAG,CAAA,GAAI,EAAA,IAAM,GAAA,IAEzC,SADfe,EAAUjB,OAAOC,SAASX,GAAWY,MAAM,GAAG,CAAA,GAAI,MAAM,GAAA;AAAA,EAE3E,GAhC6CN,EAAAA;AAI5C,SAAOoB,KADiB;AAEzB;AAOA,SAASlB,EAAaF,IAAAA;AACrB,QAAMsB,KAAYtB,GAAIrB,YAAAA;AACtB,SAAiB,MAAb2C,GAAErC,SACE,IAAIqC,GAAE,CAAA,CAAA,GAAKA,GAAE,CAAA,CAAA,GAAKA,GAAE,CAAA,CAAA,GAAKA,GAAE,KAAKA,GAAE,CAAA,CAAA,GAAKA,GAAE,CAAA,CAAA,KAE1CA;AACR;AAGA,SAASD,EAAUE,IAAAA;AAClB,SAAOA,MAAW,UAAUA,KAAU,UAAUA,KAAU,SAAS,UAAU;AAC9E;AAYA,MAAML,IAAoD,CACzD,CAAC,IAAI,KAAA,GACL,CAAC,IAAI,QAAA,GACL,CAAC,IAAI,QAAA,GACL,CAAC,KAAK,UACN,CAAC,KAAK,MAAA,GACN,CAAC,KAAK,MAAA,GACN,CAAC,KAAK,QAAA,GACN,CAAC,KAAK,MAAA,GACN,CAAC,KAAK,KAAA,CAAA;"}
@@ -1,125 +0,0 @@
1
- import { n as t } from "./ToolbarKeyboardNav-B32OMv8r.mjs";
2
- import { f as e } from "./Commands-CicwYoTQ.mjs";
3
- import { i as o } from "./AttrRegistry-I-VdmRnN.mjs";
4
- import { g as n, h as r } from "./Document-CuwE73FF.mjs";
5
- import { i as a, a as c, b as s, s as l } from "./Selection-DmFDwiPJ.mjs";
6
- import { m as i } from "./TypeBrands-C09nE2qO.mjs";
7
- import { i as d, g as p, a as u } from "./ColorNames-BdsHwA2f.mjs";
8
- const f = '\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 m(t2, e2) {
10
- const r2 = t2.selection;
11
- if (a(r2) || c(r2)) return null;
12
- if (s(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 a2 = t2.getBlock(r2.anchor.blockId);
18
- if (!a2) return null;
19
- const c2 = n(a2, r2.anchor.offset).find((t3) => t3.type === e2);
20
- return c2 && o(c2, e2) ? c2.attrs.color ?? null : null;
21
- }
22
- const l2 = t2.getBlock(r2.anchor.blockId);
23
- if (!l2) return null;
24
- const i2 = n(l2, r2.anchor.offset).find((t3) => t3.type === e2);
25
- return i2 && o(i2, e2) ? i2.attrs.color ?? null : null;
26
- }
27
- function k(t2, e2) {
28
- return null !== m(t2, e2);
29
- }
30
- function b(t2, o2, r2, p2) {
31
- if (!d(p2)) return false;
32
- const u2 = o2.selection;
33
- if (a(u2) || c(u2)) return false;
34
- const f2 = i(r2);
35
- if (s(u2)) {
36
- const e2 = o2.getBlock(u2.anchor.blockId);
37
- if (!e2) return false;
38
- const a2 = [...(o2.storedMarks ?? n(e2, u2.anchor.offset)).filter((t3) => t3.type !== r2), { type: f2, attrs: { color: p2 } }], c2 = o2.transaction("command").setStoredMarks(a2, o2.storedMarks).setSelection(u2).build();
39
- return t2.dispatch(c2), true;
40
- }
41
- const m2 = l(u2, o2.getBlockOrder()), k2 = o2.transaction("command"), b2 = { type: f2, attrs: { color: p2 } };
42
- return e(o2, m2, (t3, e2, o3) => {
43
- k2.removeMark(t3, e2, o3, { type: f2 }), k2.addMark(t3, e2, o3, b2);
44
- }), k2.setSelection(u2), t2.dispatch(k2.build()), true;
45
- }
46
- function h(t2, o2, d2) {
47
- const p2 = o2.selection;
48
- if (a(p2) || c(p2)) return false;
49
- const u2 = i(d2);
50
- if (s(p2)) {
51
- const e2 = o2.getBlock(p2.anchor.blockId);
52
- if (!e2) return false;
53
- const a2 = o2.storedMarks ?? n(e2, p2.anchor.offset);
54
- if (!r(a2, u2)) return false;
55
- const c2 = a2.filter((t3) => t3.type !== d2), s2 = o2.transaction("command").setStoredMarks(c2, o2.storedMarks).setSelection(p2).build();
56
- return t2.dispatch(s2), true;
57
- }
58
- const f2 = l(p2, o2.getBlockOrder()), m2 = o2.transaction("command");
59
- return e(o2, f2, (t3, e2, o3) => {
60
- m2.removeMark(t3, e2, o3, { type: u2 });
61
- }), m2.setSelection(p2), t2.dispatch(m2.build()), true;
62
- }
63
- const g = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]), y = /* @__PURE__ */ new Set(["Home", "End"]);
64
- function x(e2, o2, n2) {
65
- e2.classList.add("notectl-color-picker");
66
- const r2 = m(o2.getState(), n2.markType), a2 = n2.columns || 10, c2 = n2.colors.length, s2 = Math.ceil(c2 / a2), l2 = document.createElement("button");
67
- l2.type = "button", l2.className = "notectl-color-picker__default", l2.textContent = n2.resetLabel, l2.addEventListener("mousedown", (t2) => {
68
- t2.preventDefault(), t2.stopPropagation(), o2.executeCommand(n2.resetCommand), n2.onClose();
69
- }), l2.addEventListener("keydown", (t2) => {
70
- "Escape" === t2.key && (t2.preventDefault(), n2.onClose());
71
- }), e2.appendChild(l2);
72
- const i2 = document.createElement("div");
73
- i2.className = "notectl-color-picker__grid", i2.setAttribute("role", "grid"), i2.setAttribute("aria-label", `${n2.ariaLabelPrefix} color picker`);
74
- const d2 = [];
75
- let f2 = 0;
76
- for (let t2 = 0; t2 < s2; t2++) {
77
- const e3 = document.createElement("div");
78
- e3.setAttribute("role", "row");
79
- for (let s3 = 0; s3 < a2; s3++) {
80
- const l3 = t2 * a2 + s3;
81
- if (l3 >= c2) break;
82
- const i3 = n2.colors[l3], m2 = p(i3), k2 = !!r2 && r2.toLowerCase() === i3.toLowerCase(), h2 = document.createElement("button");
83
- h2.type = "button", h2.className = "notectl-color-picker__swatch", h2.setAttribute("role", "gridcell"), h2.setAttribute("aria-label", `${n2.ariaLabelPrefix} ${m2}`), h2.setAttribute("aria-selected", String(k2)), h2.dataset.index = String(l3), h2.style.backgroundColor = i3, h2.title = i3, u(i3) && (h2.style.border = "1px solid #d0d0d0"), k2 && (h2.classList.add("notectl-color-picker__swatch--active"), f2 = l3), h2.addEventListener("mousedown", (t3) => {
84
- t3.preventDefault(), t3.stopPropagation(), b(o2, o2.getState(), n2.markType, i3), n2.onClose();
85
- }), d2.push(h2), e3.appendChild(h2);
86
- }
87
- i2.appendChild(e3);
88
- }
89
- v(d2, f2), i2.addEventListener("keydown", (e3) => {
90
- if ("Escape" === e3.key) return e3.preventDefault(), void n2.onClose();
91
- if ("Enter" === e3.key || " " === e3.key) {
92
- e3.preventDefault();
93
- const t2 = e3.target.dataset.index;
94
- if (void 0 !== t2) {
95
- const e4 = n2.colors[Number(t2)];
96
- e4 && (b(o2, o2.getState(), n2.markType, e4), n2.onClose());
97
- }
98
- return;
99
- }
100
- if (g.has(e3.key)) {
101
- e3.preventDefault();
102
- const o3 = Math.floor(f2 / a2) + 1, n3 = f2 % a2 + 1, r3 = s2, l3 = a2, [i3, p2] = t(o3, n3, r3, l3, e3.key);
103
- let u2 = (i3 - 1) * a2 + (p2 - 1);
104
- return u2 >= c2 && (u2 = c2 - 1), f2 = u2, v(d2, f2), void d2[f2]?.focus();
105
- }
106
- if (y.has(e3.key)) {
107
- e3.preventDefault();
108
- const t2 = Math.floor(f2 / a2) * a2, o3 = Math.min(t2 + a2 - 1, c2 - 1);
109
- f2 = "Home" === e3.key ? t2 : o3, v(d2, f2), d2[f2]?.focus();
110
- }
111
- }), e2.appendChild(i2);
112
- }
113
- function v(t2, e2) {
114
- for (let o2 = 0; o2 < t2.length; o2++) {
115
- const n2 = t2[o2];
116
- n2 && n2.setAttribute("tabindex", o2 === e2 ? "0" : "-1");
117
- }
118
- }
119
- export {
120
- f as C,
121
- x as a,
122
- k as i,
123
- h as r
124
- };
125
- //# sourceMappingURL=ColorPickerPopup-xL8ZUfpB.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorPickerPopup-xL8ZUfpB.mjs","sources":["../../src/editor/styles/color-picker.ts","../../src/plugins/shared/ColorMarkOperations.ts","../../src/plugins/shared/ColorPickerPopup.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 {\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n\tselectionRange,\n} 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';\nimport { isValidCSSColor } from './ColorValidation.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) || isGapCursor(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\tif (!isValidCSSColor(color)) return false;\n\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(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) || isGapCursor(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"],"names":["COLOR_PICKER_CSS","getActiveColor","state","markTypeName","sel","selection","isNodeSelection","isGapCursor","isCollapsed","storedMarks","mark","find","m","type","isMarkOfType","attrs","color","block","getBlock","anchor","blockId","getBlockMarksAtOffset","offset","isColorMarkActive","applyColorMark","context","isValidCSSColor","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"],"mappings":";;;;;;;AACO,MAAMA,IAAmB;AC6BzB,SAASC,EAAeC,IAAoBC;AAClD,QAAMC,KAAMF,GAAMG;AAClB,MAAIC,EAAgBF,EAAAA,KAAQG,EAAYH,IAAM,QAAO;AAErD,MAAII,EAAYJ,EAAAA,GAAM;AACrB,QAAIF,GAAMO,aAAa;AACtB,YAAMC,KAAOR,GAAMO,YAAYE,KAAMC,CAAAA,OAAMA,GAAEC,SAASV;AACtD,aAAOO,MAAQI,EAAaJ,IAAMP,EAAAA,IAAiBO,GAAKK,MAAMC,SAAS,OAAQ;AAAA,IAChF;AACA,UAAMC,KAAQf,GAAMgB,SAASd,GAAIe,OAAOC,OAAAA;AACxC,SAAKH,GAAO,QAAO;AACnB,UACMP,KADQW,EAAsBJ,IAAOb,GAAIe,OAAOG,MAAAA,EACnCX,KAAMC,CAAAA,OAAMA,GAAEC,SAASV;AAC1C,WAA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AAoBpB,IAAwCC,IAAAA;AACpE,WAASqC,KAAI,GAAGA,KAAItC,GAAStB,QAAQ4D,MAAK;AACzC,UAAM5B,KAASV,GAASsC,EAAAA;AACpB5B,IAAAA,MACHA,GAAOZ,aAAa,YAAYwC,OAAMrC,KAAe,MAAM;EAE7D;AACD;"}
@@ -1,286 +0,0 @@
1
- import { e as n, a as t, b as e, f as o, j as c, k as r, g as i } from "./Document-CuwE73FF.mjs";
2
- import { i as l, a as s, s as u, b as f } from "./NavigationUtils-CyW0Vo8A.mjs";
3
- import { f as d } from "./NodeResolver-B-wzthAQ.mjs";
4
- import { c as a, i as b, a as k, b as h, d as I, e as g, s as m, f as p } from "./Selection-DmFDwiPJ.mjs";
5
- import { n as S, i as B } from "./TypeBrands-C09nE2qO.mjs";
6
- function x(o2, c2) {
7
- const r2 = d(o2.doc, c2.nodeId);
8
- if (!r2) return null;
9
- const i2 = r2.length > 1 ? r2.slice(0, -1) : [], l2 = N(o2, i2), s2 = l2.findIndex((n2) => "id" in n2 && n2.id === c2.nodeId);
10
- if (s2 < 0) return null;
11
- const u2 = o2.transaction("input");
12
- if (1 === l2.length && 0 === i2.length) {
13
- const t2 = n();
14
- return u2.insertNode(i2, 0, A(t2)), u2.removeNode(i2, 1), u2.setSelection(a(t2, 0)), u2.build();
15
- }
16
- u2.removeNode(i2, s2);
17
- const f2 = l2[s2 - 1];
18
- if (f2 && t(f2)) {
19
- const n2 = (function(n3) {
20
- let e2 = n3;
21
- for (; ; ) {
22
- let n4;
23
- for (let o3 = e2.children.length - 1; o3 >= 0; o3--) {
24
- const c3 = e2.children[o3];
25
- if (c3 && t(c3)) {
26
- n4 = c3;
27
- break;
28
- }
29
- }
30
- if (!n4) return e2.id;
31
- e2 = n4;
32
- }
33
- })(f2);
34
- if (n2) {
35
- const t2 = o2.getBlock(n2), c3 = t2 ? e(t2) : 0;
36
- u2.setSelection(a(n2, c3));
37
- }
38
- } else {
39
- const n2 = l2[s2 + 1];
40
- if (n2 && t(n2)) {
41
- const e2 = (function(n3) {
42
- let e3 = n3;
43
- for (; ; ) {
44
- const n4 = e3.children.find((n5) => t(n5));
45
- if (!n4) return e3.id;
46
- e3 = n4;
47
- }
48
- })(n2);
49
- e2 && u2.setSelection(a(e2, 0));
50
- }
51
- }
52
- return u2.build();
53
- }
54
- function O(n2, t2) {
55
- const o2 = n2.selection, c2 = n2.getBlockOrder();
56
- return b(o2) ? (function(n3, t3, o3, c3) {
57
- const r2 = c3.indexOf(t3.nodeId), i2 = d(n3.doc, t3.nodeId) ?? [];
58
- if ("left" === o3 || "up" === o3) {
59
- if (r2 > 0) {
60
- const o4 = c3[r2 - 1];
61
- if (!o4) return null;
62
- if (l(n3, o4)) return n3.transaction("input").setSelection(I(t3.nodeId, "before", i2)).build();
63
- const s2 = n3.getBlock(o4), u2 = s2 ? e(s2) : 0;
64
- return n3.transaction("input").setSelection(a(o4, u2)).build();
65
- }
66
- return n3.transaction("input").setSelection(I(t3.nodeId, "before", i2)).build();
67
- }
68
- if (r2 < c3.length - 1) {
69
- const e2 = c3[r2 + 1];
70
- return e2 ? l(n3, e2) ? n3.transaction("input").setSelection(I(t3.nodeId, "after", i2)).build() : n3.transaction("input").setSelection(a(e2, 0)).build() : null;
71
- }
72
- return n3.transaction("input").setSelection(I(t3.nodeId, "after", i2)).build();
73
- })(n2, o2, t2, c2) : k(o2) ? null : h(o2) ? (function(n3, t3, o3, c3) {
74
- const r2 = c3.indexOf(t3.anchor.blockId), i2 = n3.getBlock(t3.anchor.blockId);
75
- if (!i2) return null;
76
- const s2 = e(i2);
77
- if (("right" === o3 || "down" === o3) && t3.anchor.offset === s2 && r2 < c3.length - 1) {
78
- const t4 = c3[r2 + 1];
79
- if (t4 && l(n3, t4)) {
80
- const e2 = d(n3.doc, t4) ?? [];
81
- return n3.transaction("input").setSelection(g(t4, e2)).build();
82
- }
83
- }
84
- if (("left" === o3 || "up" === o3) && 0 === t3.anchor.offset && r2 > 0) {
85
- const t4 = c3[r2 - 1];
86
- if (t4 && l(n3, t4)) {
87
- const e2 = d(n3.doc, t4) ?? [];
88
- return n3.transaction("input").setSelection(g(t4, e2)).build();
89
- }
90
- }
91
- return null;
92
- })(n2, o2, t2, c2) : null;
93
- }
94
- function N(n2, t2) {
95
- if (0 === t2.length) return n2.doc.children;
96
- const e2 = n2.getBlock(t2[t2.length - 1]);
97
- return e2 ? e2.children : [];
98
- }
99
- function A(n2) {
100
- return o(S("paragraph"), [c("")], n2);
101
- }
102
- function T(n2, t2) {
103
- if ("after" === t2.side) return v(n2, t2);
104
- const o2 = n2.getBlockOrder(), c2 = o2.indexOf(t2.blockId);
105
- if (c2 <= 0) return null;
106
- const r2 = o2[c2 - 1];
107
- if (!r2) return null;
108
- if (l(n2, r2)) {
109
- const t3 = d(n2.doc, r2) ?? [];
110
- return n2.transaction("input").setSelection(g(r2, t3)).build();
111
- }
112
- const i2 = n2.getBlock(r2);
113
- if (!i2) return null;
114
- const s2 = e(i2);
115
- return n2.transaction("input").setSelection(a(r2, s2)).build();
116
- }
117
- function j(n2, t2) {
118
- if ("before" === t2.side) return v(n2, t2);
119
- const e2 = n2.getBlockOrder(), o2 = e2.indexOf(t2.blockId);
120
- if (o2 >= e2.length - 1) return null;
121
- const c2 = e2[o2 + 1];
122
- if (!c2) return null;
123
- if (l(n2, c2)) {
124
- const t3 = d(n2.doc, c2) ?? [];
125
- return n2.transaction("input").setSelection(g(c2, t3)).build();
126
- }
127
- return n2.transaction("input").setSelection(a(c2, 0)).build();
128
- }
129
- function v(n2, t2) {
130
- const e2 = d(n2.doc, t2.blockId) ?? [];
131
- return x(n2, g(t2.blockId, e2));
132
- }
133
- function M(n2, t2) {
134
- if (0 === t2.length) return n2.doc.children;
135
- const e2 = n2.getBlock(t2[t2.length - 1]);
136
- return e2 ? e2.children : [];
137
- }
138
- function w(n2) {
139
- return o(S("paragraph"), [c("")], n2);
140
- }
141
- function y(n2, t2, o2) {
142
- const c2 = n2.getBlockOrder(), r2 = c2.indexOf(t2.from.blockId), i2 = c2.indexOf(t2.to.blockId);
143
- for (let l2 = r2; l2 <= i2; l2++) {
144
- const s2 = c2[l2];
145
- if (!s2) continue;
146
- const u2 = n2.getBlock(s2);
147
- if (!u2) continue;
148
- const f2 = l2 === r2 ? t2.from.offset : 0, d2 = l2 === i2 ? t2.to.offset : e(u2);
149
- f2 !== d2 && o2(s2, f2, d2);
150
- }
151
- }
152
- function D(t2, e2, o2 = "input") {
153
- const c2 = t2.selection;
154
- if (b(c2)) return (function(t3, e3, o3, c3) {
155
- const r3 = d(t3.doc, e3.nodeId), i2 = r3 && r3.length > 1 ? r3.slice(0, -1) : [], l3 = N(t3, i2), s3 = l3.findIndex((n2) => "id" in n2 && n2.id === e3.nodeId), u3 = n(), f3 = t3.transaction(c3), b2 = s3 >= 0 ? s3 + 1 : l3.length;
156
- return f3.insertNode(i2, b2, A(u3)), f3.insertText(u3, 0, o3, []), f3.setSelection(a(u3, o3.length)), f3.build();
157
- })(t2, c2, e2, o2);
158
- if (k(c2)) return (function(t3, e3, o3, c3) {
159
- const r3 = d(t3.doc, e3.blockId), i2 = r3 && r3.length > 1 ? r3.slice(0, -1) : [], l3 = M(t3, i2), s3 = l3.findIndex((n2) => "id" in n2 && n2.id === e3.blockId), u3 = "before" === e3.side ? Math.max(s3, 0) : s3 >= 0 ? s3 + 1 : l3.length, f3 = n(), b2 = t3.transaction(c3);
160
- return b2.insertNode(i2, u3, w(f3)), b2.insertText(f3, 0, o3, []), b2.setSelection(a(f3, o3.length)), b2.build();
161
- })(t2, c2, e2, o2);
162
- const r2 = t2.transaction(o2), l2 = (function(n2) {
163
- if (n2.storedMarks) return n2.storedMarks;
164
- if (b(n2.selection) || k(n2.selection)) return [];
165
- const t3 = n2.getBlock(n2.selection.anchor.blockId);
166
- return t3 ? i(t3, n2.selection.anchor.offset) : [];
167
- })(t2);
168
- h(c2) || E(t2, r2);
169
- const s2 = h(c2) ? null : m(c2, t2.getBlockOrder()), u2 = s2 ? s2.from.blockId : c2.anchor.blockId, f2 = s2 ? s2.from.offset : c2.anchor.offset;
170
- return r2.insertText(u2, f2, e2, l2), r2.setSelection(a(u2, f2 + e2.length)), r2.build();
171
- }
172
- function R(n2) {
173
- if (b(n2.selection)) return x(n2, n2.selection);
174
- if (k(n2.selection)) return null;
175
- if (h(n2.selection)) return null;
176
- const t2 = n2.transaction("input");
177
- E(n2, t2);
178
- const e2 = m(n2.selection, n2.getBlockOrder());
179
- return t2.setSelection(a(e2.from.blockId, e2.from.offset)), t2.build();
180
- }
181
- function U(t2) {
182
- const e2 = t2.selection;
183
- if (b(e2)) return (function(t3, e3) {
184
- const o3 = d(t3.doc, e3.nodeId);
185
- if (!o3) return null;
186
- const c3 = o3.length > 1 ? o3.slice(0, -1) : [], r3 = N(t3, c3).findIndex((n2) => "id" in n2 && n2.id === e3.nodeId);
187
- if (r3 < 0) return null;
188
- const i3 = n(), l2 = t3.transaction("input");
189
- return l2.insertNode(c3, r3 + 1, A(i3)), l2.setSelection(a(i3, 0)), l2.build();
190
- })(t2, e2);
191
- if (k(e2)) return (function(t3, e3) {
192
- const o3 = d(t3.doc, e3.blockId);
193
- if (!o3) return null;
194
- const c3 = o3.length > 1 ? o3.slice(0, -1) : [], r3 = M(t3, c3).findIndex((n2) => "id" in n2 && n2.id === e3.blockId);
195
- if (r3 < 0) return null;
196
- const i3 = "before" === e3.side ? r3 : r3 + 1, l2 = n(), s2 = t3.transaction("input");
197
- return s2.insertNode(c3, i3, w(l2)), s2.setSelection(a(l2, 0)), s2.build();
198
- })(t2, e2);
199
- const o2 = t2.transaction("input");
200
- h(e2) || E(t2, o2);
201
- const c2 = h(e2) ? e2.anchor.blockId : m(e2, t2.getBlockOrder()).from.blockId, r2 = h(e2) ? e2.anchor.offset : m(e2, t2.getBlockOrder()).from.offset, i2 = n();
202
- return o2.splitBlock(c2, r2, i2), o2.setSelection(a(i2, 0)), o2.build();
203
- }
204
- function _(n2) {
205
- const t2 = n2.selection;
206
- if (b(t2) || k(t2)) return null;
207
- const e2 = n2.transaction("input");
208
- h(t2) || E(n2, e2);
209
- const o2 = h(t2) ? null : m(t2, n2.getBlockOrder()), c2 = o2 ? o2.from.blockId : t2.anchor.blockId, i2 = o2 ? o2.from.offset : t2.anchor.offset, l2 = r(B("hard_break"));
210
- return e2.insertInlineNode(c2, i2, l2), e2.setSelection(a(c2, i2 + 1)), e2.build();
211
- }
212
- function q(n2) {
213
- const t2 = n2.selection;
214
- if (b(t2) || k(t2)) return null;
215
- const o2 = n2.getBlockOrder(), c2 = o2.indexOf(t2.anchor.blockId);
216
- if (c2 <= 0) return null;
217
- const r2 = o2[c2 - 1];
218
- if (!r2) return null;
219
- if (s(n2, t2.anchor.blockId) || s(n2, r2)) return null;
220
- if (!u(n2, t2.anchor.blockId, r2) && f(n2, t2.anchor.blockId)) return null;
221
- if (l(n2, r2)) {
222
- const t3 = d(n2.doc, r2) ?? [];
223
- return n2.transaction("input").setSelection(g(r2, t3)).build();
224
- }
225
- const i2 = n2.getBlock(r2);
226
- if (!i2) return null;
227
- const h2 = e(i2);
228
- return n2.transaction("input").mergeBlocksAt(r2, t2.anchor.blockId).setSelection(a(r2, h2)).build();
229
- }
230
- function z(n2) {
231
- const t2 = n2.selection;
232
- if (b(t2) || k(t2)) return null;
233
- const e2 = n2.getBlockOrder(), o2 = e2.indexOf(t2.anchor.blockId);
234
- if (o2 >= e2.length - 1) return null;
235
- const c2 = e2[o2 + 1];
236
- if (!c2) return null;
237
- if (s(n2, t2.anchor.blockId) || s(n2, c2)) return null;
238
- if (!u(n2, t2.anchor.blockId, c2) && f(n2, t2.anchor.blockId)) return null;
239
- if (l(n2, c2)) {
240
- const t3 = d(n2.doc, c2) ?? [];
241
- return n2.transaction("input").setSelection(g(c2, t3)).build();
242
- }
243
- return n2.transaction("input").mergeBlocksAt(t2.anchor.blockId, c2).setSelection(a(t2.anchor.blockId, t2.anchor.offset)).build();
244
- }
245
- function C(n2) {
246
- const t2 = n2.doc.children, o2 = t2[0], c2 = t2[t2.length - 1];
247
- if (!o2 || !c2) return n2.transaction("command").setSelection(n2.selection).build();
248
- const r2 = e(c2);
249
- return n2.transaction("command").setSelection(p({ blockId: o2.id, offset: 0 }, { blockId: c2.id, offset: r2 })).build();
250
- }
251
- function E(n2, t2) {
252
- if (b(n2.selection) || k(n2.selection)) return;
253
- const o2 = n2.getBlockOrder(), c2 = m(n2.selection, o2), r2 = o2.indexOf(c2.from.blockId), i2 = o2.indexOf(c2.to.blockId);
254
- if (r2 === i2) t2.deleteTextAt(c2.from.blockId, c2.from.offset, c2.to.offset);
255
- else {
256
- const l2 = n2.getBlock(c2.from.blockId);
257
- if (!l2) return;
258
- const s2 = e(l2);
259
- c2.from.offset < s2 && t2.deleteTextAt(c2.from.blockId, c2.from.offset, s2), c2.to.offset > 0 && t2.deleteTextAt(c2.to.blockId, 0, c2.to.offset);
260
- for (let l3 = r2 + 1; l3 < i2; l3++) {
261
- const r3 = o2[l3];
262
- if (!r3) continue;
263
- const i3 = n2.getBlock(r3);
264
- if (!i3) continue;
265
- const s3 = e(i3);
266
- s3 > 0 && t2.deleteTextAt(r3, 0, s3), t2.mergeBlocksAt(c2.from.blockId, r3);
267
- }
268
- t2.mergeBlocksAt(c2.from.blockId, c2.to.blockId);
269
- }
270
- }
271
- export {
272
- R as a,
273
- z as b,
274
- U as c,
275
- x as d,
276
- T as e,
277
- y as f,
278
- j as g,
279
- _ as h,
280
- D as i,
281
- E as j,
282
- q as m,
283
- O as n,
284
- C as s
285
- };
286
- //# sourceMappingURL=Commands-CicwYoTQ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Commands-CicwYoTQ.mjs","sources":["../../src/commands/NodeSelectionCommands.ts","../../src/commands/GapCursorCommands.ts","../../src/commands/Commands.ts"],"sourcesContent":["/**\n * Commands for NodeSelection: deleting void blocks, inserting paragraphs\n * after void blocks, and navigating arrow keys into/out of void blocks.\n */\n\nimport {\n\ttype BlockNode,\n\tcreateBlockNode,\n\tcreateTextNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tisBlockNode,\n} from '../model/Document.js';\nimport { isVoidBlock } from '../model/NavigationUtils.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { NodeSelection } from '../model/Selection.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateGapCursor,\n\tcreateNodeSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../model/Selection.js';\nimport { type BlockId, nodeType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\n\n/**\n * Deletes the void block targeted by a NodeSelection and places cursor\n * on the adjacent block. If it's the only block, replaces with empty paragraph.\n */\nexport function deleteNodeSelection(state: EditorState, sel: NodeSelection): Transaction | null {\n\tconst path = findNodePath(state.doc, sel.nodeId);\n\tif (!path) return null;\n\n\tconst parentPath: BlockId[] = path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\tconst siblings = getSiblings(state, parentPath);\n\n\tconst index: number = siblings.findIndex((c) => 'id' in c && c.id === sel.nodeId);\n\tif (index < 0) return null;\n\n\tconst builder = state.transaction('input');\n\n\t// If this is the only block in the document, insert empty paragraph first\n\tif (siblings.length === 1 && parentPath.length === 0) {\n\t\tconst newId = generateBlockId();\n\t\tbuilder.insertNode(parentPath, 0, createEmptyParagraph(newId));\n\t\tbuilder.removeNode(parentPath, 1);\n\t\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\t\treturn builder.build();\n\t}\n\n\tbuilder.removeNode(parentPath, index);\n\n\t// Find where to place cursor: prefer previous sibling leaf, else next sibling leaf.\n\tconst prevSibling = siblings[index - 1];\n\tif (prevSibling && isBlockNode(prevSibling)) {\n\t\tconst prevLeafId = findLastLeafBlockId(prevSibling);\n\t\tif (prevLeafId) {\n\t\t\tconst prevLeaf = state.getBlock(prevLeafId);\n\t\t\tconst prevLen = prevLeaf ? getBlockLength(prevLeaf) : 0;\n\t\t\tbuilder.setSelection(createCollapsedSelection(prevLeafId, prevLen));\n\t\t}\n\t} else {\n\t\tconst nextSibling = siblings[index + 1];\n\t\tif (nextSibling && isBlockNode(nextSibling)) {\n\t\t\tconst nextLeafId = findFirstLeafBlockId(nextSibling);\n\t\t\tif (nextLeafId) {\n\t\t\t\tbuilder.setSelection(createCollapsedSelection(nextLeafId, 0));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn builder.build();\n}\n\n/** Inserts a new paragraph after a NodeSelection-targeted void block. */\nexport function insertParagraphAfterNodeSelection(\n\tstate: EditorState,\n\tsel: NodeSelection,\n): Transaction | null {\n\tconst path = findNodePath(state.doc, sel.nodeId);\n\tif (!path) return null;\n\n\tconst parentPath: BlockId[] = path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\tconst siblings = getSiblings(state, parentPath);\n\n\tconst index: number = siblings.findIndex((c) => 'id' in c && c.id === sel.nodeId);\n\tif (index < 0) return null;\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tbuilder.insertNode(parentPath, index + 1, createEmptyParagraph(newId));\n\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\treturn builder.build();\n}\n\n/** Inserts text in a new paragraph after a NodeSelection-targeted void block. */\nexport function insertTextAfterNodeSelection(\n\tstate: EditorState,\n\tsel: NodeSelection,\n\ttext: string,\n\torigin: 'input' | 'paste',\n): Transaction {\n\tconst path = findNodePath(state.doc, sel.nodeId);\n\tconst parentPath: BlockId[] = path && path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\tconst siblings = getSiblings(state, parentPath);\n\n\tconst index: number = siblings.findIndex((c) => 'id' in c && c.id === sel.nodeId);\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction(origin);\n\n\tconst insertIdx = index >= 0 ? index + 1 : siblings.length;\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.insertText(newId, 0, text, []);\n\tbuilder.setSelection(createCollapsedSelection(newId, text.length));\n\treturn builder.build();\n}\n\n/**\n * Navigates arrow keys into/out of void blocks.\n * Returns a transaction if navigation should create a NodeSelection, or null.\n */\nexport function navigateArrowIntoVoid(\n\tstate: EditorState,\n\tdirection: 'left' | 'right' | 'up' | 'down',\n): Transaction | null {\n\tconst sel = state.selection;\n\tconst blockOrder = state.getBlockOrder();\n\n\t// If currently on a NodeSelection, navigate away from it\n\tif (isNodeSelection(sel)) {\n\t\treturn navigateAwayFromNodeSelection(state, sel, direction, blockOrder);\n\t}\n\n\t// GapCursor is handled by navigateFromGapCursor in CaretNavigation\n\tif (isGapCursor(sel)) return null;\n\n\t// Text selection: check if navigating into a void block\n\tif (!isCollapsed(sel)) return null;\n\n\treturn navigateIntoVoid(state, sel, direction, blockOrder);\n}\n\n/** Finds the first leaf (deepest-first-child) block ID in a subtree. */\nexport function findFirstLeafBlockId(node: BlockNode): BlockId {\n\tlet current: BlockNode = node;\n\twhile (true) {\n\t\tconst firstBlockChild = current.children.find((child): child is BlockNode =>\n\t\t\tisBlockNode(child),\n\t\t);\n\t\tif (!firstBlockChild) return current.id;\n\t\tcurrent = firstBlockChild;\n\t}\n}\n\n/** Finds the last leaf (deepest-last-child) block ID in a subtree. */\nexport function findLastLeafBlockId(node: BlockNode): BlockId {\n\tlet current: BlockNode = node;\n\twhile (true) {\n\t\tlet lastBlockChild: BlockNode | undefined;\n\t\tfor (let i = current.children.length - 1; i >= 0; i--) {\n\t\t\tconst child = current.children[i];\n\t\t\tif (child && isBlockNode(child)) {\n\t\t\t\tlastBlockChild = child;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!lastBlockChild) return current.id;\n\t\tcurrent = lastBlockChild;\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/** Resolves siblings for a given parent path. */\nfunction getSiblings(\n\tstate: EditorState,\n\tparentPath: readonly BlockId[],\n): readonly (\n\t| BlockNode\n\t| import('../model/Document.js').TextNode\n\t| import('../model/Document.js').InlineNode\n)[] {\n\tif (parentPath.length === 0) return state.doc.children;\n\tconst parent = state.getBlock(parentPath[parentPath.length - 1] as BlockId);\n\treturn parent ? parent.children : [];\n}\n\n/** Creates an empty paragraph block node. */\nfunction createEmptyParagraph(id: BlockId): BlockNode {\n\treturn createBlockNode(nodeType('paragraph'), [createTextNode('')], id);\n}\n\n/** Handles navigation away from a NodeSelection (arrow keys while void is selected). */\nfunction navigateAwayFromNodeSelection(\n\tstate: EditorState,\n\tsel: NodeSelection,\n\tdirection: 'left' | 'right' | 'up' | 'down',\n\tblockOrder: readonly BlockId[],\n): Transaction | null {\n\tconst nodeIdx = blockOrder.indexOf(sel.nodeId);\n\tconst nodePath = (findNodePath(state.doc, sel.nodeId) ?? []) as BlockId[];\n\n\tif (direction === 'left' || direction === 'up') {\n\t\tif (nodeIdx > 0) {\n\t\t\tconst prevId = blockOrder[nodeIdx - 1];\n\t\t\tif (!prevId) return null;\n\t\t\tif (isVoidBlock(state, prevId)) {\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.setSelection(createGapCursor(sel.nodeId, 'before', nodePath))\n\t\t\t\t\t.build();\n\t\t\t}\n\t\t\tconst prevBlock = state.getBlock(prevId);\n\t\t\tconst prevLen = prevBlock ? getBlockLength(prevBlock) : 0;\n\t\t\treturn state\n\t\t\t\t.transaction('input')\n\t\t\t\t.setSelection(createCollapsedSelection(prevId, prevLen))\n\t\t\t\t.build();\n\t\t}\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createGapCursor(sel.nodeId, 'before', nodePath))\n\t\t\t.build();\n\t}\n\n\t// right or down\n\tif (nodeIdx < blockOrder.length - 1) {\n\t\tconst nextId = blockOrder[nodeIdx + 1];\n\t\tif (!nextId) return null;\n\t\tif (isVoidBlock(state, nextId)) {\n\t\t\treturn state\n\t\t\t\t.transaction('input')\n\t\t\t\t.setSelection(createGapCursor(sel.nodeId, 'after', nodePath))\n\t\t\t\t.build();\n\t\t}\n\t\treturn state.transaction('input').setSelection(createCollapsedSelection(nextId, 0)).build();\n\t}\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createGapCursor(sel.nodeId, 'after', nodePath))\n\t\t.build();\n}\n\n/** Handles text selection navigating into an adjacent void block. */\nfunction navigateIntoVoid(\n\tstate: EditorState,\n\tsel: { readonly anchor: { readonly blockId: BlockId; readonly offset: number } },\n\tdirection: 'left' | 'right' | 'up' | 'down',\n\tblockOrder: readonly BlockId[],\n): Transaction | null {\n\tconst blockIdx = blockOrder.indexOf(sel.anchor.blockId);\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tconst blockLen = getBlockLength(block);\n\n\tif (direction === 'right' || direction === 'down') {\n\t\tif (sel.anchor.offset === blockLen && blockIdx < blockOrder.length - 1) {\n\t\t\tconst nextId = blockOrder[blockIdx + 1];\n\t\t\tif (nextId && isVoidBlock(state, nextId)) {\n\t\t\t\tconst path = findNodePath(state.doc, nextId) ?? [];\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.setSelection(createNodeSelection(nextId, path as BlockId[]))\n\t\t\t\t\t.build();\n\t\t\t}\n\t\t}\n\t}\n\n\tif (direction === 'left' || direction === 'up') {\n\t\tif (sel.anchor.offset === 0 && blockIdx > 0) {\n\t\t\tconst prevId = blockOrder[blockIdx - 1];\n\t\t\tif (prevId && isVoidBlock(state, prevId)) {\n\t\t\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t\t\t.build();\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n","/**\n * Commands for GapCursor: deleting void blocks adjacent to gap cursors\n * and inserting paragraphs at gap positions.\n */\n\nimport {\n\tcreateBlockNode,\n\tcreateTextNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n} from '../model/Document.js';\nimport type { BlockNode } from '../model/Document.js';\nimport { isVoidBlock } from '../model/NavigationUtils.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { GapCursorSelection, NodeSelection } from '../model/Selection.js';\nimport { createCollapsedSelection, createNodeSelection } from '../model/Selection.js';\nimport { type BlockId, nodeType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { deleteNodeSelection } from './NodeSelectionCommands.js';\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Backspace.\n *\n * - `side === 'after'` → void block is behind the cursor → delete it.\n * - `side === 'before'` → void block is ahead → navigate backward (to previous block).\n * - At document start with `side === 'before'` → `null` (no-op).\n */\nexport function deleteBackwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'after') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'before': navigate to previous block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx <= 0) return null;\n\n\tconst prevId: BlockId | undefined = blockOrder[blockIdx - 1];\n\tif (!prevId) return null;\n\n\tif (isVoidBlock(state, prevId)) {\n\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\tconst prevBlock = state.getBlock(prevId);\n\tif (!prevBlock) return null;\n\tconst prevLen: number = getBlockLength(prevBlock);\n\treturn state.transaction('input').setSelection(createCollapsedSelection(prevId, prevLen)).build();\n}\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Delete.\n *\n * - `side === 'before'` → void block is ahead of the cursor → delete it.\n * - `side === 'after'` → void block is behind → navigate forward (to next block).\n * - At document end with `side === 'after'` → `null` (no-op).\n */\nexport function deleteForwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'before') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'after': navigate to next block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx >= blockOrder.length - 1) return null;\n\n\tconst nextId: BlockId | undefined = blockOrder[blockIdx + 1];\n\tif (!nextId) return null;\n\n\tif (isVoidBlock(state, nextId)) {\n\t\tconst path = findNodePath(state.doc, nextId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(nextId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\treturn state.transaction('input').setSelection(createCollapsedSelection(nextId, 0)).build();\n}\n\n/** Deletes the void block that the GapCursor is adjacent to, delegating to deleteNodeSelection. */\nfunction deleteVoidAtGap(state: EditorState, sel: GapCursorSelection): Transaction | null {\n\tconst path = (findNodePath(state.doc, sel.blockId) ?? []) as BlockId[];\n\tconst nodeSel: NodeSelection = createNodeSelection(sel.blockId, path);\n\treturn deleteNodeSelection(state, nodeSel);\n}\n\n/** Inserts a new paragraph at a GapCursor position (before or after the void block). */\nexport function insertParagraphAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tconst path = findNodePath(state.doc, sel.blockId);\n\tif (!path) return null;\n\n\tconst parentPath: BlockId[] = path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\tconst siblings = getSiblings(state, parentPath);\n\n\tconst index: number = siblings.findIndex((c) => 'id' in c && c.id === sel.blockId);\n\tif (index < 0) return null;\n\n\tconst insertIdx: number = sel.side === 'before' ? index : index + 1;\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\treturn builder.build();\n}\n\n/** Inserts text in a new paragraph at a GapCursor position. */\nexport function insertTextAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n\ttext: string,\n\torigin: 'input' | 'paste',\n): Transaction {\n\tconst path = findNodePath(state.doc, sel.blockId);\n\tconst parentPath: BlockId[] = path && path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\tconst siblings = getSiblings(state, parentPath);\n\n\tconst index: number = siblings.findIndex((c) => 'id' in c && c.id === sel.blockId);\n\tconst insertIdx: number =\n\t\tsel.side === 'before' ? Math.max(index, 0) : index >= 0 ? index + 1 : siblings.length;\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction(origin);\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.insertText(newId, 0, text, []);\n\tbuilder.setSelection(createCollapsedSelection(newId, text.length));\n\treturn builder.build();\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/** Resolves siblings for a given parent path. */\nfunction getSiblings(\n\tstate: EditorState,\n\tparentPath: readonly BlockId[],\n): readonly (\n\t| BlockNode\n\t| import('../model/Document.js').TextNode\n\t| import('../model/Document.js').InlineNode\n)[] {\n\tif (parentPath.length === 0) return state.doc.children;\n\tconst parent = state.getBlock(parentPath[parentPath.length - 1] as BlockId);\n\treturn parent ? parent.children : [];\n}\n\n/** Creates an empty paragraph block node. */\nfunction createEmptyParagraph(id: BlockId): import('../model/Document.js').BlockNode {\n\treturn createBlockNode(nodeType('paragraph'), [createTextNode('')], id);\n}\n","/**\n * Core editor commands and barrel re-exports from submodules.\n *\n * This module contains text insertion, block splitting, block merging,\n * selection deletion, and select-all. Mark, delete, gap-cursor, node-selection,\n * and word-boundary commands are re-exported from their respective modules.\n */\n\nimport {\n\ttype Mark,\n\tcreateInlineNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetBlockMarksAtOffset,\n} from '../model/Document.js';\nimport {\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../model/NavigationUtils.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { SelectionRange } from '../model/Selection.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n\tselectionRange,\n} from '../model/Selection.js';\nimport { type BlockId, inlineType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { insertParagraphAtGap, insertTextAtGap } from './GapCursorCommands.js';\nimport {\n\tdeleteNodeSelection,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n} from './NodeSelectionCommands.js';\n\n// --- Re-exports from submodules ---\n\nexport {\n\tcanCrossBlockBoundary,\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../model/NavigationUtils.js';\n\nexport type { FeatureConfig } from './MarkCommands.js';\nexport {\n\tisMarkActive,\n\ttoggleBold,\n\ttoggleItalic,\n\ttoggleMark,\n\ttoggleUnderline,\n} from './MarkCommands.js';\n\nexport {\n\tdeleteBackward,\n\tdeleteForward,\n\tdeleteSoftLineBackward,\n\tdeleteSoftLineForward,\n\tdeleteWordBackward,\n\tdeleteWordForward,\n} from './DeleteCommands.js';\n\nexport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n\tnavigateArrowIntoVoid,\n} from './NodeSelectionCommands.js';\n\nexport {\n\tdeleteBackwardAtGap,\n\tdeleteForwardAtGap,\n\tinsertParagraphAtGap,\n\tinsertTextAtGap,\n} from './GapCursorCommands.js';\n\nexport {\n\tfindWordBoundaryBackward,\n\tfindWordBoundaryForward,\n} from './WordBoundary.js';\n\n// --- Range Iteration ---\n\n/**\n * Iterates over each block in the given selection range, invoking the callback\n * with the block ID, per-block start offset, and per-block end offset.\n * Blocks where `from === to` are skipped automatically.\n */\nexport function forEachBlockInRange(\n\tstate: EditorState,\n\trange: SelectionRange,\n\tcallback: (blockId: BlockId, from: number, to: number) => void,\n): void {\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst fromIdx: number = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx: number = blockOrder.indexOf(range.to.blockId);\n\n\tfor (let i: number = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId: BlockId | undefined = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\n\t\tconst from: number = i === fromIdx ? range.from.offset : 0;\n\t\tconst to: number = i === toIdx ? range.to.offset : getBlockLength(block);\n\n\t\tif (from === to) continue;\n\t\tcallback(blockId, from, to);\n\t}\n}\n\n// --- Text Commands ---\n\n/** Inserts text at the current selection, replacing any selected range. */\nexport function insertTextCommand(\n\tstate: EditorState,\n\ttext: string,\n\torigin: 'input' | 'paste' = 'input',\n): Transaction {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert paragraph after void block with the text\n\tif (isNodeSelection(sel)) {\n\t\treturn insertTextAfterNodeSelection(state, sel, text, origin);\n\t}\n\n\t// GapCursor: insert paragraph at the gap position with the text\n\tif (isGapCursor(sel)) {\n\t\treturn insertTextAtGap(state, sel, text, origin);\n\t}\n\n\tconst builder = state.transaction(origin);\n\tconst marks = resolveActiveMarks(state);\n\n\tif (!isCollapsed(sel)) {\n\t\taddDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst range = isCollapsed(sel) ? null : selectionRange(sel, state.getBlockOrder());\n\tconst insertBlockId = range ? range.from.blockId : sel.anchor.blockId;\n\tconst insertOffset = range ? range.from.offset : sel.anchor.offset;\n\n\tbuilder.insertText(insertBlockId, insertOffset, text, marks);\n\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + text.length));\n\n\treturn builder.build();\n}\n\n/** Deletes the current selection. */\nexport function deleteSelectionCommand(state: EditorState): Transaction | null {\n\tif (isNodeSelection(state.selection)) {\n\t\treturn deleteNodeSelection(state, state.selection);\n\t}\n\tif (isGapCursor(state.selection)) return null;\n\tif (isCollapsed(state.selection)) return null;\n\n\tconst builder = state.transaction('input');\n\taddDeleteSelectionSteps(state, builder);\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\tbuilder.setSelection(createCollapsedSelection(range.from.blockId, range.from.offset));\n\n\treturn builder.build();\n}\n\n/** Splits the current block at the cursor position (Enter key). */\nexport function splitBlockCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert empty paragraph after the void block\n\tif (isNodeSelection(sel)) {\n\t\treturn insertParagraphAfterNodeSelection(state, sel);\n\t}\n\n\t// GapCursor: insert empty paragraph at the gap position\n\tif (isGapCursor(sel)) {\n\t\treturn insertParagraphAtGap(state, sel);\n\t}\n\n\tconst builder = state.transaction('input');\n\n\tif (!isCollapsed(sel)) {\n\t\taddDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst blockId = isCollapsed(sel)\n\t\t? sel.anchor.blockId\n\t\t: selectionRange(sel, state.getBlockOrder()).from.blockId;\n\tconst offset = isCollapsed(sel)\n\t\t? sel.anchor.offset\n\t\t: selectionRange(sel, state.getBlockOrder()).from.offset;\n\n\tconst newBlockId = generateBlockId();\n\n\t// splitBlock operates at the same level in the tree — the StepApplication\n\t// handles this correctly because it looks up the block by ID recursively.\n\tbuilder.splitBlock(blockId, offset, newBlockId);\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\n/** Inserts a hard line break (InlineNode) at the current cursor position. */\nexport function insertHardBreakCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst builder = state.transaction('input');\n\n\tif (!isCollapsed(sel)) {\n\t\taddDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst range = isCollapsed(sel) ? null : selectionRange(sel, state.getBlockOrder());\n\tconst insertBlockId: BlockId = range ? range.from.blockId : sel.anchor.blockId;\n\tconst insertOffset: number = range ? range.from.offset : sel.anchor.offset;\n\n\tconst hardBreak = createInlineNode(inlineType('hard_break'));\n\tbuilder.insertInlineNode(insertBlockId, insertOffset, hardBreak);\n\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + 1));\n\n\treturn builder.build();\n}\n\n/**\n * Merges the current block with the previous block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\tconst blockOrder = state.getBlockOrder();\n\tconst blockIdx = blockOrder.indexOf(sel.anchor.blockId);\n\n\tif (blockIdx <= 0) return null;\n\n\tconst prevBlockId = blockOrder[blockIdx - 1];\n\tif (!prevBlockId) return null;\n\n\t// Never merge isolating blocks directly (e.g. table cells).\n\tif (isIsolatingBlock(state, sel.anchor.blockId) || isIsolatingBlock(state, prevBlockId)) {\n\t\treturn null;\n\t}\n\n\t// Prevent merge across isolating boundaries\n\tif (!sharesParent(state, sel.anchor.blockId, prevBlockId)) {\n\t\tif (isInsideIsolating(state, sel.anchor.blockId)) return null;\n\t}\n\n\t// If previous block is void, select it instead of merging\n\tif (isVoidBlock(state, prevBlockId)) {\n\t\tconst path = findNodePath(state.doc, prevBlockId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(prevBlockId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\tconst prevBlock = state.getBlock(prevBlockId);\n\tif (!prevBlock) return null;\n\tconst prevLen = getBlockLength(prevBlock);\n\n\treturn state\n\t\t.transaction('input')\n\t\t.mergeBlocksAt(prevBlockId, sel.anchor.blockId)\n\t\t.setSelection(createCollapsedSelection(prevBlockId, prevLen))\n\t\t.build();\n}\n\n/**\n * Merges the next block into the current block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\tconst blockOrder = state.getBlockOrder();\n\tconst blockIdx = blockOrder.indexOf(sel.anchor.blockId);\n\n\tif (blockIdx >= blockOrder.length - 1) return null;\n\n\tconst nextBlockId = blockOrder[blockIdx + 1];\n\tif (!nextBlockId) return null;\n\n\t// Never merge isolating blocks directly (e.g. table cells).\n\tif (isIsolatingBlock(state, sel.anchor.blockId) || isIsolatingBlock(state, nextBlockId)) {\n\t\treturn null;\n\t}\n\n\t// Prevent merge across isolating boundaries\n\tif (!sharesParent(state, sel.anchor.blockId, nextBlockId)) {\n\t\tif (isInsideIsolating(state, sel.anchor.blockId)) return null;\n\t}\n\n\t// If next block is void, select it instead of merging\n\tif (isVoidBlock(state, nextBlockId)) {\n\t\tconst path = findNodePath(state.doc, nextBlockId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(nextBlockId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.mergeBlocksAt(sel.anchor.blockId, nextBlockId)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Selects all content in the editor. */\nexport function selectAll(state: EditorState): Transaction {\n\tconst blocks = state.doc.children;\n\tconst firstBlock = blocks[0];\n\tconst lastBlock = blocks[blocks.length - 1];\n\tif (!firstBlock || !lastBlock)\n\t\treturn state.transaction('command').setSelection(state.selection).build();\n\tconst lastBlockLen = getBlockLength(lastBlock);\n\n\treturn state\n\t\t.transaction('command')\n\t\t.setSelection(\n\t\t\tcreateSelection(\n\t\t\t\t{ blockId: firstBlock.id, offset: 0 },\n\t\t\t\t{ blockId: lastBlock.id, offset: lastBlockLen },\n\t\t\t),\n\t\t)\n\t\t.build();\n}\n\n// --- Internal Helpers ---\n\nfunction resolveActiveMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return [];\n\n\tconst block = state.getBlock(state.selection.anchor.blockId);\n\tif (!block) return [];\n\n\treturn getBlockMarksAtOffset(block, state.selection.anchor.offset);\n}\n\nexport function addDeleteSelectionSteps(state: EditorState, builder: TransactionBuilder): void {\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(state.selection, blockOrder);\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tif (fromIdx === toIdx) {\n\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, range.to.offset);\n\t} else {\n\t\tconst firstBlock = state.getBlock(range.from.blockId);\n\t\tif (!firstBlock) return;\n\t\tconst firstLen = getBlockLength(firstBlock);\n\n\t\t// Delete from the end of first block\n\t\tif (range.from.offset < firstLen) {\n\t\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, firstLen);\n\t\t}\n\n\t\t// Delete from start of last block\n\t\tif (range.to.offset > 0) {\n\t\t\tbuilder.deleteTextAt(range.to.blockId, 0, range.to.offset);\n\t\t}\n\n\t\t// Delete middle blocks entirely and merge last into first\n\t\tfor (let i = fromIdx + 1; i < toIdx; i++) {\n\t\t\tconst midBlockId = blockOrder[i];\n\t\t\tif (!midBlockId) continue;\n\t\t\tconst midBlock = state.getBlock(midBlockId);\n\t\t\tif (!midBlock) continue;\n\t\t\tconst midLen = getBlockLength(midBlock);\n\t\t\tif (midLen > 0) {\n\t\t\t\tbuilder.deleteTextAt(midBlockId, 0, midLen);\n\t\t\t}\n\t\t\tbuilder.mergeBlocksAt(range.from.blockId, midBlockId);\n\t\t}\n\n\t\t// Merge last block into first\n\t\tbuilder.mergeBlocksAt(range.from.blockId, range.to.blockId);\n\t}\n}\n"],"names":["deleteNodeSelection","state","sel","path","findNodePath","doc","nodeId","parentPath","length","slice","siblings","getSiblings","index","findIndex","c","id","builder","transaction","newId","generateBlockId","insertNode","createEmptyParagraph","removeNode","setSelection","createCollapsedSelection","build","prevSibling","isBlockNode","prevLeafId","node","current","lastBlockChild","i","children","child","prevLeaf","getBlock","prevLen","getBlockLength","nextSibling","nextLeafId","firstBlockChild","find","navigateArrowIntoVoid","direction","selection","blockOrder","getBlockOrder","isNodeSelection","nodeIdx","indexOf","nodePath","prevId","isVoidBlock","createGapCursor","prevBlock","nextId","isGapCursor","isCollapsed","blockIdx","anchor","blockId","block","blockLen","offset","createNodeSelection","parent","createBlockNode","nodeType","createTextNode","deleteBackwardAtGap","side","deleteVoidAtGap","deleteForwardAtGap","forEachBlockInRange","range","callback","fromIdx","from","toIdx","to","insertTextCommand","text","origin","insertIdx","insertText","Math","max","marks","storedMarks","getBlockMarksAtOffset","addDeleteSelectionSteps","selectionRange","insertBlockId","insertOffset","deleteSelectionCommand","splitBlockCommand","newBlockId","splitBlock","insertHardBreakCommand","hardBreak","createInlineNode","inlineType","insertInlineNode","mergeBlockBackward","prevBlockId","isIsolatingBlock","sharesParent","isInsideIsolating","mergeBlocksAt","mergeBlockForward","nextBlockId","selectAll","blocks","firstBlock","lastBlock","lastBlockLen","createSelection","deleteTextAt","firstLen","midBlockId","midBlock","midLen"],"mappings":";;;;;AAgCO,SAASA,EAAoBC,IAAoBC,IAAAA;AACvD,QAAMC,KAAOC,EAAaH,GAAMI,KAAKH,GAAII,MAAAA;AACzC,MAAA,CAAKH,GAAM,QAAO;AAElB,QAAMI,KAAwBJ,GAAKK,SAAS,IAAKL,GAAKM,MAAM,GAAA,EAAG,IAAoB,CAAA,GAC7EC,KAAWC,EAAYV,IAAOM,EAAAA,GAE9BK,KAAgBF,GAASG,UAAWC,CAAAA,OAAM,QAAQA,MAAKA,GAAEC,OAAOb,GAAII,MAAAA;AAC1E,MAAIM,KAAQ,EAAG,QAAO;AAEtB,QAAMI,KAAUf,GAAMgB,YAAY,OAAA;AAGlC,MAAwB,MAApBP,GAASF,UAAsC,MAAtBD,GAAWC,QAAc;AACrD,UAA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