@notectl/core 1.7.0 → 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 (195) 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-CAV2N-fF.mjs → index-Bt_d4IqB.mjs} +8 -8
  34. package/dist/chunks/{index-CAV2N-fF.mjs.map → index-Bt_d4IqB.mjs.map} +1 -1
  35. package/dist/chunks/{index-pxbbDHVH.mjs → index-CFJFD4lF.mjs} +3 -3
  36. package/dist/chunks/{index-pxbbDHVH.mjs.map → index-CFJFD4lF.mjs.map} +1 -1
  37. package/dist/chunks/{index-C0cEs7Jc.mjs → index-CFPP456m.mjs} +10 -10
  38. package/dist/chunks/{index-C0cEs7Jc.mjs.map → index-CFPP456m.mjs.map} +1 -1
  39. package/dist/chunks/{index-FlTg80Pk.mjs → index-CH1r7DL-.mjs} +257 -298
  40. package/dist/chunks/index-CH1r7DL-.mjs.map +1 -0
  41. package/dist/chunks/{index-D0s0Q8Wc.mjs → index-CfyS_pgH.mjs} +25 -18
  42. package/dist/chunks/index-CfyS_pgH.mjs.map +1 -0
  43. package/dist/chunks/{index-CflvcXSd.mjs → index-Ckzqtn5D.mjs} +17 -14
  44. package/dist/chunks/{index-CflvcXSd.mjs.map → index-Ckzqtn5D.mjs.map} +1 -1
  45. package/dist/chunks/{index-C9gc3Bws.mjs → index-CrKz_IEn.mjs} +32 -32
  46. package/dist/chunks/{index-C9gc3Bws.mjs.map → index-CrKz_IEn.mjs.map} +1 -1
  47. package/dist/chunks/{index-DMt3ojrY.mjs → index-DGKQhSAl.mjs} +2 -2
  48. package/dist/chunks/{index-DMt3ojrY.mjs.map → index-DGKQhSAl.mjs.map} +1 -1
  49. package/dist/chunks/{index-CoeD4T9-.mjs → index-DIvHQtE2.mjs} +10 -7
  50. package/dist/chunks/{index-CoeD4T9-.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-B9GkDVsx.mjs → index-DoCvDkfj.mjs} +77 -94
  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-B-NSeaM4.mjs → index-Dum8yE_t.mjs} +12 -12
  62. package/dist/chunks/{index-B-NSeaM4.mjs.map → index-Dum8yE_t.mjs.map} +1 -1
  63. package/dist/chunks/{index-CNs4QQ8l.mjs → index-Dy6SllXW.mjs} +52 -64
  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-DyIwN_67.mjs → index-yhz2qeeh.mjs} +220 -218
  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 +8 -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 +2227 -2090
  105. package/dist/notectl-core.mjs.map +1 -1
  106. package/dist/notectl-core.umd.js +2527 -2337
  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 +1 -1
  111. package/dist/plugins/blockquote.mjs +1 -1
  112. package/dist/plugins/caret-navigation.mjs +1 -1
  113. package/dist/plugins/code-block.mjs +1 -1
  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 +1 -1
  120. package/dist/plugins/font.mjs +1 -1
  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 +1 -1
  129. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  130. package/dist/plugins/highlight.mjs +1 -1
  131. package/dist/plugins/horizontal-rule.mjs +1 -1
  132. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  133. package/dist/plugins/image.mjs +1 -1
  134. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  135. package/dist/plugins/link.mjs +1 -1
  136. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  137. package/dist/plugins/list.mjs +1 -1
  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 +1 -1
  151. package/dist/plugins/super-sub.mjs +1 -1
  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 +1 -1
  156. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  157. package/dist/plugins/text-color.mjs +1 -1
  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/state/BlockTreeOps.d.ts +21 -0
  171. package/dist/state/BlockTreeOps.d.ts.map +1 -0
  172. package/dist/state/InlineContentOps.d.ts +37 -0
  173. package/dist/state/InlineContentOps.d.ts.map +1 -0
  174. package/dist/state/StepApplication.d.ts.map +1 -1
  175. package/dist/test/PluginTestUtils.d.ts +4 -0
  176. package/dist/test/PluginTestUtils.d.ts.map +1 -1
  177. package/package.json +2 -2
  178. package/dist/chunks/ColorNames-BdsHwA2f.mjs +0 -59
  179. package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +0 -1
  180. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +0 -125
  181. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +0 -1
  182. package/dist/chunks/Commands-CicwYoTQ.mjs +0 -286
  183. package/dist/chunks/Commands-CicwYoTQ.mjs.map +0 -1
  184. package/dist/chunks/MarkCommands-CC37WA7Z.mjs +0 -94
  185. package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +0 -1
  186. package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +0 -1
  187. package/dist/chunks/index-B9GkDVsx.mjs.map +0 -1
  188. package/dist/chunks/index-CKPrAOr6.mjs +0 -209
  189. package/dist/chunks/index-CKPrAOr6.mjs.map +0 -1
  190. package/dist/chunks/index-CNs4QQ8l.mjs.map +0 -1
  191. package/dist/chunks/index-D0s0Q8Wc.mjs.map +0 -1
  192. package/dist/chunks/index-DfzCof6H.mjs +0 -191
  193. package/dist/chunks/index-DfzCof6H.mjs.map +0 -1
  194. package/dist/chunks/index-DyIwN_67.mjs.map +0 -1
  195. package/dist/chunks/index-FlTg80Pk.mjs.map +0 -1
@@ -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,GAA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,GAAEM,GAAAA,GAAM;AAClCN,MAAAA,GAAEC,eAAAA;AACF,YACM6C,KADqBvD,KAAK8C,MAAMzB,KAAe1B,EAAAA,IACfA,IAChC6D,KAAiBxD,KAAKyD,IAAIF,KAAW5D,KAAU,GAAGC,KAAgB,CAAA;AAExEyB,MAAAA,KAAyB,WAAVZ,GAAEM,MAAiBwC,KAAWC,IAC7ChB,EAAoBpB,IAAUC,EAAAA,GAC9BD,GAASC,KAAeiC,MAAAA;AAAAA,IACzB;AAAA,EAAA,CAAA,GAGDjE,GAAU2B,YAAYC,EAAAA;AACvB;AAGA,SAASuB,EAAoBpB,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,MAAA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WAAWC,EAAAA,GACxC+B,KAAU/B,GAAWI,QAAQyB,GAAMG,KAAKjB,OAAAA,GACxCkB,KAAQjC,GAAWI,QAAQyB,GAAMK,GAAGnB,OAAAA;AAE1C,MAAIgB,OAAYE,GACf/D,CAAAA,GAAQsG,aAAa3C,GAAMG,KAAKjB,SAASc,GAAMG,KAAKd,QAAQW,GAAMK,GAAGhB,MAAAA;AAAAA,OAC/D;AACN,UAAMkD,KAAajH,GAAMmC,SAASuC,GAAMG,KAAKjB,OAAAA;AAC7C,QAAA,CAAKqD,GAAY;AACjB,UAAMK,KAAWjF,EAAe4E,EAAAA;AAG5BvC,IAAAA,GAAMG,KAAKd,SAASuD,MACvBvG,GAAQsG,aAAa3C,GAAMG,KAAKjB,SAASc,GAAMG,KAAKd,QAAQuD,EAAAA,GAIzD5C,GAAMK,GAAGhB,SAAS,KACrBhD,GAAQsG,aAAa3C,GAAMK,GAAGnB,SAAS,GAAGc,GAAMK,GAAGhB,MAAAA;AAIpD,aAAShC,KAAI6C,KAAU,GAAG7C,KAAI+C,IAAO/C,MAAK;AACzC,YAAMwF,KAAa1E,GAAWd,EAAAA;AAC9B,UAAA,CAAKwF,GAAY;AACjB,YAAMC,KAAWxH,GAAMmC,SAASoF,EAAAA;AAChC,WAAKC,GAAU;AACf,YAAMC,KAASpF,EAAemF,EAAAA;AAC1BC,MAAAA,KAAS,KACZ1G,GAAQsG,aAAaE,IAAY,GAAGE,EAAAA,GAErC1G,GAAQ6F,cAAclC,GAAMG,KAAKjB,SAAS2D,EAAAA;AAAAA,IAC3C;AAGAxG,IAAAA,GAAQ6F,cAAclC,GAAMG,KAAKjB,SAASc,GAAMK,GAAGnB,OAAAA;AAAAA,EACpD;AACD;"}
@@ -1,94 +0,0 @@
1
- import { h as e, g as n, b as t, c as r, d as o } from "./Document-CuwE73FF.mjs";
2
- import { i as s, a as c, b as i, s as a } from "./Selection-DmFDwiPJ.mjs";
3
- import { m as u } from "./TypeBrands-C09nE2qO.mjs";
4
- import { f } from "./Commands-CicwYoTQ.mjs";
5
- function l() {
6
- return { nodeTypes: ["paragraph"], markTypes: ["bold", "italic", "underline"], getNodeSpec: () => {
7
- } };
8
- }
9
- function d(e2) {
10
- return { nodeTypes: e2.getNodeTypes(), markTypes: e2.getMarkTypes(), getNodeSpec: (n2) => e2.getNodeSpec(n2) };
11
- }
12
- function m(e2, n2) {
13
- return e2.markTypes.includes(n2);
14
- }
15
- function k(e2, n2) {
16
- return e2.nodeTypes.includes(n2);
17
- }
18
- const p = { bold: true, italic: true, underline: true };
19
- function b(t2, r2, o2 = p) {
20
- if ((function(e2, n2) {
21
- const t3 = e2;
22
- return "bold" === t3 ? !n2.bold : "italic" === t3 ? !n2.italic : "underline" === t3 && !n2.underline;
23
- })(r2, o2)) return null;
24
- if (!m(t2.schema, r2)) return null;
25
- if (s(t2.selection) || c(t2.selection)) return null;
26
- const u2 = { type: r2 }, l2 = t2.selection;
27
- if (i(l2)) {
28
- const o3 = t2.getBlock(l2.anchor.blockId);
29
- if (!o3) return null;
30
- const s2 = t2.storedMarks ?? n(o3, l2.anchor.offset), c2 = e(s2, r2) ? s2.filter((e2) => e2.type !== r2) : [...s2, u2];
31
- return t2.transaction("command").setStoredMarks(c2, t2.storedMarks).setSelection(l2).build();
32
- }
33
- const d2 = a(l2, t2.getBlockOrder()), k2 = t2.transaction("command"), b2 = M(t2, r2);
34
- return f(t2, d2, (e2, n2, t3) => {
35
- b2 ? k2.removeMark(e2, n2, t3, u2) : k2.addMark(e2, n2, t3, u2);
36
- }), k2.setSelection(l2), k2.build();
37
- }
38
- function g(e2, n2) {
39
- return b(e2, u("bold"), n2);
40
- }
41
- function y(e2, n2) {
42
- return b(e2, u("italic"), n2);
43
- }
44
- function T(e2, n2) {
45
- return b(e2, u("underline"), n2);
46
- }
47
- function h(t2, r2) {
48
- const o2 = t2.selection;
49
- if (s(o2) || c(o2)) return false;
50
- if (i(o2)) {
51
- if (t2.storedMarks) return e(t2.storedMarks, r2);
52
- const s2 = t2.getBlock(o2.anchor.blockId);
53
- if (!s2) return false;
54
- const c2 = n(s2, o2.anchor.offset);
55
- return e(c2, r2);
56
- }
57
- return M(t2, r2);
58
- }
59
- function M(e2, n2) {
60
- const r2 = e2.selection;
61
- if (s(r2) || c(r2)) return false;
62
- const o2 = e2.getBlockOrder(), i2 = a(r2, o2), u2 = o2.indexOf(i2.from.blockId), f2 = o2.indexOf(i2.to.blockId);
63
- for (let r3 = u2; r3 <= f2; r3++) {
64
- const s2 = o2[r3];
65
- if (!s2) continue;
66
- const c2 = e2.getBlock(s2);
67
- if (!c2) continue;
68
- const a2 = t(c2);
69
- if (!S(c2, r3 === u2 ? i2.from.offset : 0, r3 === f2 ? i2.to.offset : a2, n2)) return false;
70
- }
71
- return true;
72
- }
73
- function S(n2, t2, s2, c2) {
74
- if (t2 === s2) return false;
75
- let i2 = 0;
76
- for (const a2 of r(n2)) if (o(a2)) {
77
- const n3 = i2 + a2.text.length;
78
- if (n3 > t2 && i2 < s2 && !e(a2.marks, c2)) return false;
79
- i2 = n3;
80
- } else i2 += 1;
81
- return true;
82
- }
83
- export {
84
- k as a,
85
- h as b,
86
- y as c,
87
- l as d,
88
- b as e,
89
- T as f,
90
- m as i,
91
- d as s,
92
- g as t
93
- };
94
- //# sourceMappingURL=MarkCommands-CC37WA7Z.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkCommands-CC37WA7Z.mjs","sources":["../../src/model/Schema.ts","../../src/commands/MarkCommands.ts"],"sourcesContent":["/**\n * Schema definition for the Notectl editor.\n * Defines which node types and marks are allowed.\n */\n\nimport type { NodeSpec } from './NodeSpec.js';\nimport type { SchemaRegistry } from './SchemaRegistry.js';\n\nexport interface Schema {\n\treadonly nodeTypes: readonly string[];\n\treadonly markTypes: readonly string[];\n\t/** Looks up the full NodeSpec for a given type. Available when created via schemaFromRegistry. */\n\treadonly getNodeSpec?: (type: string) => NodeSpec | undefined;\n}\n\n/** Creates the default schema with paragraph nodes and bold/italic/underline marks. */\nexport function defaultSchema(): Schema {\n\treturn {\n\t\tnodeTypes: ['paragraph'],\n\t\tmarkTypes: ['bold', 'italic', 'underline'],\n\t\tgetNodeSpec: () => undefined,\n\t};\n}\n\n/** Derives a Schema from a SchemaRegistry's registered specs. */\nexport function schemaFromRegistry(registry: SchemaRegistry): Schema {\n\treturn {\n\t\tnodeTypes: registry.getNodeTypes(),\n\t\tmarkTypes: registry.getMarkTypes(),\n\t\tgetNodeSpec: (type: string) => registry.getNodeSpec(type),\n\t};\n}\n\n/** Checks whether the given mark type is allowed by the schema. */\nexport function isMarkAllowed(schema: Schema, markType: string): boolean {\n\treturn schema.markTypes.includes(markType);\n}\n\n/** Checks whether the given node type is allowed by the schema. */\nexport function isNodeTypeAllowed(schema: Schema, nodeType: string): boolean {\n\treturn schema.nodeTypes.includes(nodeType);\n}\n","/**\n * Mark-related commands: toggling bold/italic/underline and checking\n * whether a mark is active.\n */\n\nimport {\n\ttype BlockNode,\n\ttype Mark,\n\ttype MarkType,\n\tgetBlockLength,\n\tgetBlockMarksAtOffset,\n\tgetInlineChildren,\n\thasMark,\n\tisTextNode,\n} from '../model/Document.js';\nimport { isMarkAllowed } from '../model/Schema.js';\nimport { isCollapsed, isGapCursor, isNodeSelection, selectionRange } from '../model/Selection.js';\nimport { markType as mkType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { forEachBlockInRange } from './Commands.js';\n\n// --- Feature Configuration ---\n\nexport interface FeatureConfig {\n\treadonly bold: boolean;\n\treadonly italic: boolean;\n\treadonly underline: boolean;\n}\n\nconst defaultFeatures: FeatureConfig = { bold: true, italic: true, underline: true };\n\n/**\n * Toggles a mark on the current selection.\n * If collapsed, toggles stored marks. If range, applies/removes from text.\n */\nexport function toggleMark(\n\tstate: EditorState,\n\tmarkType: MarkType,\n\tfeatures: FeatureConfig = defaultFeatures,\n): Transaction | null {\n\tif (isFeatureGated(markType, features)) return null;\n\tif (!isMarkAllowed(state.schema, markType)) return null;\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return null;\n\n\tconst mark: Mark = { type: markType };\n\tconst sel = state.selection;\n\n\tif (isCollapsed(sel)) {\n\t\t// Toggle stored marks\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return null;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tconst hasIt = hasMark(currentMarks, markType);\n\t\tconst newMarks = hasIt\n\t\t\t? currentMarks.filter((m) => m.type !== markType)\n\t\t\t: [...currentMarks, mark];\n\n\t\treturn 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}\n\n\t// Range selection — apply/remove mark to all blocks in range\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\t// Determine if we should add or remove\n\tconst shouldRemove = isMarkActiveInRange(state, markType);\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tif (shouldRemove) {\n\t\t\tbuilder.removeMark(blockId, from, to, mark);\n\t\t} else {\n\t\t\tbuilder.addMark(blockId, from, to, mark);\n\t\t}\n\t});\n\n\tbuilder.setSelection(sel);\n\treturn builder.build();\n}\n\nexport function toggleBold(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('bold'), features);\n}\n\nexport function toggleItalic(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('italic'), features);\n}\n\nexport function toggleUnderline(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('underline'), features);\n}\n\n/** Checks if a mark is active at the current selection. */\nexport function isMarkActive(state: EditorState, markType: MarkType): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\n\tif (isCollapsed(sel)) {\n\t\tif (state.storedMarks) {\n\t\t\treturn hasMark(state.storedMarks, markType);\n\t\t}\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return false;\n\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\treturn hasMark(marks, markType);\n\t}\n\n\treturn isMarkActiveInRange(state, markType);\n}\n\n/** Checks if a mark is active across the entire selection range. */\nfunction isMarkActiveInRange(state: EditorState, markType: MarkType): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(sel, blockOrder);\n\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tfor (let i = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\t\tconst blockLen = getBlockLength(block);\n\t\tconst from = i === fromIdx ? range.from.offset : 0;\n\t\tconst to = i === toIdx ? range.to.offset : blockLen;\n\n\t\tif (!isMarkActiveInBlock(block, from, to, markType)) return false;\n\t}\n\n\treturn true;\n}\n\nfunction isMarkActiveInBlock(\n\tblock: BlockNode,\n\tfrom: number,\n\tto: number,\n\tmarkType: MarkType,\n): boolean {\n\tif (from === to) return false;\n\tlet pos = 0;\n\tfor (const child of getInlineChildren(block)) {\n\t\tif (isTextNode(child)) {\n\t\t\tconst childEnd = pos + child.text.length;\n\t\t\tif (childEnd > from && pos < to) {\n\t\t\t\tif (!hasMark(child.marks, markType)) return false;\n\t\t\t}\n\t\t\tpos = childEnd;\n\t\t} else {\n\t\t\t// InlineNode: skip (width 1, no marks)\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction isFeatureGated(type: MarkType, features: FeatureConfig): boolean {\n\tconst key = type as string;\n\tif (key === 'bold') return !features.bold;\n\tif (key === 'italic') return !features.italic;\n\tif (key === 'underline') return !features.underline;\n\treturn false;\n}\n"],"names":["defaultSchema","nodeTypes","markTypes","getNodeSpec","schemaFromRegistry","registry","getNodeTypes","getMarkTypes","type","isMarkAllowed","schema","markType","includes","isNodeTypeAllowed","nodeType","defaultFeatures","bold","italic","underline","toggleMark","state","features","key","isNodeSelection","selection","isGapCursor","mark","sel","isCollapsed","anchorBlock","getBlock","anchor","blockId","currentMarks","storedMarks","getBlockMarksAtOffset","offset","newMarks","hasMark","filter","m","transaction","setStoredMarks","setSelection","build","range","selectionRange","getBlockOrder","builder","shouldRemove","isMarkActiveInRange","forEachBlockInRange","from","to","removeMark","addMark","toggleBold","mkType","toggleItalic","toggleUnderline","isMarkActive","block","marks","blockOrder","fromIdx","indexOf","toIdx","i","blockLen","getBlockLength","isMarkActiveInBlock","pos","child","getInlineChildren","isTextNode","childEnd","text","length"],"mappings":";;;;AAgBO,SAASA,IAAAA;AACf,SAAO,EACNC,WAAW,CAAC,WAAA,GACZC,WAAW,CAAC,QAAQ,UAAU,WAAA,GAC9BC,aAAa,MAAA;AAAA,EAAA,EAAA;AAEf;AAGO,SAASC,EAAmBC,IAAAA;AAClC,SAAO,EACNJ,WAAWI,GAASC,aAAAA,GACpBJ,WAAWG,GAASE,aAAAA,GACpBJ,aAAcK,CAAAA,OAAiBH,GAASF,YAAYK,EAAAA,EAAAA;AAEtD;AAGO,SAASC,EAAcC,IAAgBC,IAAAA;AAC7C,SAAOD,GAAOR,UAAUU,SAASD;AAClC;AAGO,SAASE,EAAkBH,IAAgBI,IAAAA;AACjD,SAAOJ,GAAOT,UAAUW,SAASE,EAAAA;AAClC;ACXA,MAAMC,IAAiC,EAAEC,MAAAA,MAAYC,QAAAA,MAAcC,WAAAA,KAAW;AAMvE,SAASC,EACfC,IACAT,IACAU,KAA0BN,GAAAA;AAE1B,OAyHD,SAAwBP,IAAgBa,IAAAA;AACvC,UAAMC,KAAMd;AACZ,WAAY,WAARc,KAAAA,CAAwBD,GAASL,OACzB,aAARM,KAAAA,CAA0BD,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