@notectl/core 1.0.8 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{AttrRegistry-D-przlzb.mjs → AttrRegistry-I-VdmRnN.mjs} +2 -2
- package/dist/chunks/{AttrRegistry-D-przlzb.mjs.map → AttrRegistry-I-VdmRnN.mjs.map} +1 -1
- package/dist/chunks/CaretNavigation-CAJXoaae.mjs +311 -0
- package/dist/chunks/CaretNavigation-CAJXoaae.mjs.map +1 -0
- package/dist/chunks/ColorNames-BdsHwA2f.mjs +59 -0
- package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +1 -0
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +125 -0
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +1 -0
- package/dist/chunks/Commands-CicwYoTQ.mjs +286 -0
- package/dist/chunks/Commands-CicwYoTQ.mjs.map +1 -0
- package/dist/chunks/{Document-CI3iCwEP.mjs → Document-CuwE73FF.mjs} +35 -22
- package/dist/chunks/{Document-CI3iCwEP.mjs.map → Document-CuwE73FF.mjs.map} +1 -1
- package/dist/chunks/HTMLUtils-DTqQzcKR.mjs +35 -0
- package/dist/chunks/HTMLUtils-DTqQzcKR.mjs.map +1 -0
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs +94 -0
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +1 -0
- package/dist/chunks/NavigationUtils-CyW0Vo8A.mjs +47 -0
- package/dist/chunks/NavigationUtils-CyW0Vo8A.mjs.map +1 -0
- package/dist/chunks/{NodeResolver-D68ZLXti.mjs → NodeResolver-B-wzthAQ.mjs} +2 -2
- package/dist/chunks/{NodeResolver-D68ZLXti.mjs.map → NodeResolver-B-wzthAQ.mjs.map} +1 -1
- package/dist/chunks/Platform-S_xqIqcM.mjs +26 -0
- package/dist/chunks/Platform-S_xqIqcM.mjs.map +1 -0
- package/dist/chunks/Selection-DmFDwiPJ.mjs +52 -0
- package/dist/chunks/Selection-DmFDwiPJ.mjs.map +1 -0
- package/dist/chunks/ToolbarItem-BpZggUGo.mjs +8 -0
- package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -0
- package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs +818 -0
- package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +1 -0
- package/dist/chunks/index--z_Txzej.mjs +467 -0
- package/dist/chunks/index--z_Txzej.mjs.map +1 -0
- package/dist/chunks/{index-o6hDR07y.mjs → index-83QoUENW.mjs} +25 -20
- package/dist/chunks/index-83QoUENW.mjs.map +1 -0
- package/dist/chunks/{index-CT3HGdQt.mjs → index-B0UFAfyb.mjs} +13 -13
- package/dist/chunks/{index-CT3HGdQt.mjs.map → index-B0UFAfyb.mjs.map} +1 -1
- package/dist/chunks/{index-C2GQoHot.mjs → index-BDMP86F4.mjs} +40 -40
- package/dist/chunks/{index-C2GQoHot.mjs.map → index-BDMP86F4.mjs.map} +1 -1
- package/dist/chunks/{index-Bsp4LC5t.mjs → index-BWXkaC2Z.mjs} +36 -36
- package/dist/chunks/index-BWXkaC2Z.mjs.map +1 -0
- package/dist/chunks/{index-C-YWHOcC.mjs → index-BigJ0z6n.mjs} +22 -22
- package/dist/chunks/{index-C-YWHOcC.mjs.map → index-BigJ0z6n.mjs.map} +1 -1
- package/dist/chunks/{index-uTnc9y7M.mjs → index-CPjf45-o.mjs} +28 -28
- package/dist/chunks/index-CPjf45-o.mjs.map +1 -0
- package/dist/chunks/{index-BAk1EG1x.mjs → index-CPyHuEzh.mjs} +106 -106
- package/dist/chunks/index-CPyHuEzh.mjs.map +1 -0
- package/dist/chunks/{index-Ct0ivLhO.mjs → index-D4GKlc-A.mjs} +256 -259
- package/dist/chunks/index-D4GKlc-A.mjs.map +1 -0
- package/dist/chunks/{index-BRYzYOYC.mjs → index-D67mP19g.mjs} +29 -29
- package/dist/chunks/index-D67mP19g.mjs.map +1 -0
- package/dist/chunks/index-D8tbbW97.mjs +73 -0
- package/dist/chunks/index-D8tbbW97.mjs.map +1 -0
- package/dist/chunks/{index-DC1EK22F.mjs → index-DIAXWwgJ.mjs} +24 -19
- package/dist/chunks/index-DIAXWwgJ.mjs.map +1 -0
- package/dist/chunks/{index-BSFLNveF.mjs → index-DQryjfJs.mjs} +352 -341
- package/dist/chunks/index-DQryjfJs.mjs.map +1 -0
- package/dist/chunks/index-DRZwd-1W.mjs +187 -0
- package/dist/chunks/index-DRZwd-1W.mjs.map +1 -0
- package/dist/chunks/{index-BYgspns5.mjs → index-DUC1X43Z.mjs} +54 -54
- package/dist/chunks/index-DUC1X43Z.mjs.map +1 -0
- package/dist/chunks/{index-CxiWyUho.mjs → index-DipAT_Q9.mjs} +31 -31
- package/dist/chunks/index-DipAT_Q9.mjs.map +1 -0
- package/dist/chunks/{index-D3CQWJiw.mjs → index-tBDVaSjG.mjs} +81 -61
- package/dist/chunks/index-tBDVaSjG.mjs.map +1 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -1
- package/dist/commands/Commands.d.ts +13 -45
- package/dist/commands/Commands.d.ts.map +1 -1
- package/dist/commands/DeleteCommands.d.ts +15 -0
- package/dist/commands/DeleteCommands.d.ts.map +1 -0
- package/dist/commands/GapCursorCommands.d.ts +24 -0
- package/dist/commands/GapCursorCommands.d.ts.map +1 -0
- package/dist/commands/MarkCommands.d.ts +19 -0
- package/dist/commands/MarkCommands.d.ts.map +1 -0
- package/dist/commands/MovementCommands.d.ts +27 -0
- package/dist/commands/MovementCommands.d.ts.map +1 -0
- package/dist/commands/NodeSelectionCommands.d.ts +24 -0
- package/dist/commands/NodeSelectionCommands.d.ts.map +1 -0
- package/dist/commands/PasteCommand.d.ts.map +1 -1
- package/dist/commands/WordBoundary.d.ts +12 -0
- package/dist/commands/WordBoundary.d.ts.map +1 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +34 -6
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/styles/list.d.ts +2 -0
- package/dist/editor/styles/list.d.ts.map +1 -1
- package/dist/editor/styles/toolbar.d.ts +1 -1
- package/dist/editor/styles/toolbar.d.ts.map +1 -1
- package/dist/index.d.ts +31 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +2 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/CompositionTracker.d.ts +14 -0
- package/dist/input/CompositionTracker.d.ts.map +1 -0
- package/dist/input/FileHandlerRegistry.d.ts +16 -0
- package/dist/input/FileHandlerRegistry.d.ts.map +1 -0
- package/dist/input/InputHandler.d.ts +8 -4
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/InputRuleRegistry.d.ts +9 -0
- package/dist/input/InputRuleRegistry.d.ts.map +1 -0
- package/dist/input/KeyboardHandler.d.ts +22 -5
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/Keymap.d.ts +11 -0
- package/dist/input/Keymap.d.ts.map +1 -1
- package/dist/input/KeymapRegistry.d.ts +19 -0
- package/dist/input/KeymapRegistry.d.ts.map +1 -0
- package/dist/input/LegacyHTMLNormalizer.d.ts +18 -0
- package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +7 -0
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/model/Document.d.ts +8 -0
- package/dist/model/Document.d.ts.map +1 -1
- package/dist/model/GraphemeUtils.d.ts +20 -0
- package/dist/model/GraphemeUtils.d.ts.map +1 -0
- package/dist/model/HTMLParser.d.ts +13 -0
- package/dist/model/HTMLParser.d.ts.map +1 -1
- package/dist/model/HTMLUtils.d.ts +6 -1
- package/dist/model/HTMLUtils.d.ts.map +1 -1
- package/dist/model/NavigationUtils.d.ts +16 -0
- package/dist/model/NavigationUtils.d.ts.map +1 -0
- package/dist/model/SchemaRegistry.d.ts +0 -39
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/model/Selection.d.ts +14 -3
- package/dist/model/Selection.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2831 -2420
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +3616 -2013
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/Plugin.d.ts +34 -5
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +31 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts +35 -0
- package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts.map +1 -0
- package/dist/plugins/caret-navigation/index.d.ts +2 -0
- package/dist/plugins/caret-navigation/index.d.ts.map +1 -0
- package/dist/plugins/caret-navigation.mjs +5 -0
- package/dist/plugins/caret-navigation.mjs.map +1 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts +15 -0
- package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -0
- package/dist/plugins/gap-cursor/index.d.ts +2 -0
- package/dist/plugins/gap-cursor/index.d.ts.map +1 -0
- package/dist/plugins/gap-cursor.mjs +65 -0
- package/dist/plugins/gap-cursor.mjs.map +1 -0
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/BlockTypePickerRegistry.d.ts +9 -0
- package/dist/plugins/heading/BlockTypePickerRegistry.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +14 -0
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingCommands.d.ts +5 -0
- package/dist/plugins/heading/HeadingCommands.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts +5 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts +5 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +1 -41
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImageCommands.d.ts.map +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/ListPlugin.d.ts +9 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
- package/dist/plugins/print/PrintTypes.d.ts +5 -1
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
- package/dist/plugins/shared/ColorValidation.d.ts +7 -0
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts +1 -0
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts +23 -0
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +56 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +17 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarRegistry.d.ts +12 -0
- package/dist/plugins/toolbar/ToolbarRegistry.d.ts.map +1 -0
- package/dist/plugins/toolbar.mjs +2 -2
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/state/History.d.ts.map +1 -1
- package/dist/state/ReadonlyGuard.d.ts +6 -0
- package/dist/state/ReadonlyGuard.d.ts.map +1 -0
- package/dist/state/SelectionTransactions.d.ts +10 -0
- package/dist/state/SelectionTransactions.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +4 -0
- package/dist/state/Transaction.d.ts.map +1 -1
- package/dist/test/TestUtils.d.ts +23 -0
- package/dist/test/TestUtils.d.ts.map +1 -1
- package/dist/view/CaretNavigation.d.ts +48 -0
- package/dist/view/CaretNavigation.d.ts.map +1 -0
- package/dist/view/CursorWrapper.d.ts +19 -0
- package/dist/view/CursorWrapper.d.ts.map +1 -0
- package/dist/view/DomPointUtils.d.ts +20 -0
- package/dist/view/DomPointUtils.d.ts.map +1 -0
- package/dist/view/EditorView.d.ts +45 -0
- package/dist/view/EditorView.d.ts.map +1 -1
- package/dist/view/MarkRendering.d.ts +7 -0
- package/dist/view/MarkRendering.d.ts.map +1 -0
- package/dist/view/NodeViewRegistry.d.ts +9 -0
- package/dist/view/NodeViewRegistry.d.ts.map +1 -0
- package/dist/view/Platform.d.ts +29 -0
- package/dist/view/Platform.d.ts.map +1 -0
- package/dist/view/Reconciler.d.ts +4 -0
- package/dist/view/Reconciler.d.ts.map +1 -1
- package/dist/view/SelectionSync.d.ts +2 -0
- package/dist/view/SelectionSync.d.ts.map +1 -1
- package/dist/view/ViewMovementCommands.d.ts +40 -0
- package/dist/view/ViewMovementCommands.d.ts.map +1 -0
- package/package.json +10 -2
- package/dist/chunks/ColorNames-iaWsSZx1.mjs +0 -35
- package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +0 -1
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +0 -140
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +0 -1
- package/dist/chunks/Commands-CSpSwGXv.mjs +0 -461
- package/dist/chunks/Commands-CSpSwGXv.mjs.map +0 -1
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +0 -7
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +0 -1
- package/dist/chunks/Selection-D5ZjXoB7.mjs +0 -44
- package/dist/chunks/Selection-D5ZjXoB7.mjs.map +0 -1
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs +0 -7
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs +0 -368
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +0 -1
- package/dist/chunks/index-BAk1EG1x.mjs.map +0 -1
- package/dist/chunks/index-BRYzYOYC.mjs.map +0 -1
- package/dist/chunks/index-BSFLNveF.mjs.map +0 -1
- package/dist/chunks/index-BYgspns5.mjs.map +0 -1
- package/dist/chunks/index-B_3qDrUN.mjs +0 -64
- package/dist/chunks/index-B_3qDrUN.mjs.map +0 -1
- package/dist/chunks/index-Bsp4LC5t.mjs.map +0 -1
- package/dist/chunks/index-Ct0ivLhO.mjs.map +0 -1
- package/dist/chunks/index-CxiWyUho.mjs.map +0 -1
- package/dist/chunks/index-D3CQWJiw.mjs.map +0 -1
- package/dist/chunks/index-DC1EK22F.mjs.map +0 -1
- package/dist/chunks/index-Dh76rR13.mjs +0 -196
- package/dist/chunks/index-Dh76rR13.mjs.map +0 -1
- package/dist/chunks/index-o6hDR07y.mjs.map +0 -1
- package/dist/chunks/index-uTnc9y7M.mjs.map +0 -1
- package/dist/input/SourceNormalizer.d.ts +0 -7
- package/dist/input/SourceNormalizer.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Commands-CSpSwGXv.mjs","sources":["../../src/model/Schema.ts","../../src/commands/Commands.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 * Editor commands for formatting, text manipulation, and history.\n */\n\nimport {\n\ttype BlockNode,\n\ttype Mark,\n\ttype MarkType,\n\tcreateBlockNode,\n\tcreateInlineNode,\n\tcreateTextNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetBlockMarksAtOffset,\n\tgetContentAtOffset,\n\tgetInlineChildren,\n\thasMark,\n\tisBlockNode,\n\tisTextNode,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport { isMarkAllowed } from '../model/Schema.js';\nimport type { NodeSelection, SelectionRange } from '../model/Selection.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n\tisCollapsed,\n\tisNodeSelection,\n\tselectionRange,\n} from '../model/Selection.js';\nimport { type BlockId, inlineType, markType as mkType } 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';\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// --- Void Block Helpers ---\n\n/** Returns true if the block with the given ID is a void block (e.g. image, HR). */\nexport function isVoidBlock(state: EditorState, bid: BlockId): boolean {\n\tconst block = state.getBlock(bid);\n\tif (!block) return false;\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\treturn getNodeSpec(block.type)?.isVoid === true;\n}\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\t// Determine parent path (all elements except the last)\n\tconst parentPath: BlockId[] = path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\n\t// Determine index among siblings\n\tconst siblings =\n\t\tparentPath.length === 0\n\t\t\t? state.doc.children\n\t\t\t: (() => {\n\t\t\t\t\tconst parent = state.getBlock(parentPath[parentPath.length - 1] as BlockId);\n\t\t\t\t\treturn parent ? parent.children : [];\n\t\t\t\t})();\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(\n\t\t\tparentPath,\n\t\t\t0,\n\t\t\tcreateBlockNode(\n\t\t\t\t'paragraph' as import('../model/TypeBrands.js').NodeTypeName,\n\t\t\t\t[createTextNode('')],\n\t\t\t\tnewId,\n\t\t\t),\n\t\t);\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\nfunction 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\nfunction 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// --- 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// --- Mark Commands ---\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)) 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\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)) 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\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// --- 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\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 (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/** Handles backspace key. */\nexport function deleteBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tif (sel.anchor.offset > 0) {\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.deleteTextAt(block.id, sel.anchor.offset - 1, sel.anchor.offset)\n\t\t\t.setSelection(createCollapsedSelection(block.id, sel.anchor.offset - 1))\n\t\t\t.build();\n\t}\n\n\t// At start of block — merge with previous\n\treturn mergeBlockBackward(state);\n}\n\n/** Handles delete key. */\nexport function deleteForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tconst blockLen = getBlockLength(block);\n\n\tif (sel.anchor.offset < blockLen) {\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.deleteTextAt(block.id, sel.anchor.offset, sel.anchor.offset + 1)\n\t\t\t.setSelection(createCollapsedSelection(block.id, sel.anchor.offset))\n\t\t\t.build();\n\t}\n\n\t// At end of block — merge with next\n\treturn mergeBlockForward(state);\n}\n\n/** Handles Ctrl+Backspace: delete word backward. */\nexport function deleteWordBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tif (sel.anchor.offset === 0) {\n\t\treturn mergeBlockBackward(state);\n\t}\n\n\tconst wordStart = findWordBoundaryBackward(block, sel.anchor.offset);\n\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, wordStart, sel.anchor.offset)\n\t\t.setSelection(createCollapsedSelection(block.id, wordStart))\n\t\t.build();\n}\n\n/** Handles Ctrl+Delete: delete word forward. */\nexport function deleteWordForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tconst blockLen = getBlockLength(block);\n\tif (sel.anchor.offset === blockLen) {\n\t\treturn mergeBlockForward(state);\n\t}\n\n\tconst wordEnd = findWordBoundaryForward(block, sel.anchor.offset);\n\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, sel.anchor.offset, wordEnd)\n\t\t.setSelection(createCollapsedSelection(block.id, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Handles Cmd+Backspace: delete to start of line/block. */\nexport function deleteSoftLineBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tif (sel.anchor.offset === 0) {\n\t\treturn mergeBlockBackward(state);\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, 0, sel.anchor.offset)\n\t\t.setSelection(createCollapsedSelection(block.id, 0))\n\t\t.build();\n}\n\n/** Handles Cmd+Delete: delete to end of line/block. */\nexport function deleteSoftLineForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tconst blockLen = getBlockLength(block);\n\tif (sel.anchor.offset === blockLen) {\n\t\treturn mergeBlockForward(state);\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, sel.anchor.offset, blockLen)\n\t\t.setSelection(createCollapsedSelection(block.id, sel.anchor.offset))\n\t\t.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\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)) 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/** Checks whether two blocks share the same parent in the document tree. */\nexport function sharesParent(state: EditorState, blockIdA: BlockId, blockIdB: BlockId): boolean {\n\tconst pathA = state.getNodePath(blockIdA);\n\tconst pathB = state.getNodePath(blockIdB);\n\tif (!pathA || !pathB) return false;\n\tif (pathA.length !== pathB.length) return false;\n\t// Compare parent paths (all but last element)\n\tfor (let i = 0; i < pathA.length - 1; i++) {\n\t\tif (pathA[i] !== pathB[i]) return false;\n\t}\n\treturn true;\n}\n\n/** Checks whether a block is inside an isolating node (e.g. table_cell). */\nexport function isInsideIsolating(state: EditorState, blockId: BlockId): boolean {\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\tconst path = state.getNodePath(blockId);\n\tif (!path || path.length <= 1) return false;\n\n\t// Check ancestors (not the block itself)\n\tfor (let i = 0; i < path.length - 1; i++) {\n\t\tconst ancestorId = path[i];\n\t\tif (!ancestorId) continue;\n\t\tconst ancestor = state.getBlock(ancestorId);\n\t\tif (!ancestor) continue;\n\t\tconst spec = getNodeSpec(ancestor.type);\n\t\tif (spec?.isolating) return true;\n\t}\n\treturn false;\n}\n\nfunction isIsolatingBlock(state: EditorState, blockId: BlockId): boolean {\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\tconst block = state.getBlock(blockId);\n\tif (!block) return false;\n\treturn getNodeSpec(block.type)?.isolating === true;\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)) 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 */\nfunction mergeBlockForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(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// --- Check Commands ---\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)) 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// --- Internal Helpers ---\n\nfunction resolveActiveMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\tif (isNodeSelection(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)) 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\n/**\n * Finds the word boundary backward from the given offset.\n * InlineNodes act as word boundaries.\n */\nfunction findWordBoundaryBackward(block: BlockNode, offset: number): number {\n\tlet pos = offset - 1;\n\t// Skip trailing whitespace\n\twhile (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (!/\\s/.test(content.char)) break;\n\t\tpos--;\n\t}\n\t// If at InlineNode, delete just it (treat as word boundary)\n\tif (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (content?.kind === 'inline') return pos;\n\t}\n\t// Skip word characters until whitespace or InlineNode\n\twhile (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (/\\s/.test(content.char)) break;\n\t\tpos--;\n\t}\n\treturn pos + 1;\n}\n\n/**\n * Finds the word boundary forward from the given offset.\n * InlineNodes act as word boundaries.\n */\nfunction findWordBoundaryForward(block: BlockNode, offset: number): number {\n\tconst len = getBlockLength(block);\n\tlet pos = offset;\n\t// Skip word characters first\n\twhile (pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (/\\s/.test(content.char)) break;\n\t\tpos++;\n\t}\n\t// If at InlineNode and haven't moved, delete just the InlineNode\n\tif (pos === offset && pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (content?.kind === 'inline') return pos + 1;\n\t}\n\t// Skip trailing whitespace\n\twhile (pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (!/\\s/.test(content.char)) break;\n\t\tpos++;\n\t}\n\treturn pos;\n}\n\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\n/** Inserts a new paragraph after a NodeSelection-targeted void block. */\nfunction 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\n\tconst siblings =\n\t\tparentPath.length === 0\n\t\t\t? state.doc.children\n\t\t\t: (() => {\n\t\t\t\t\tconst parent = state.getBlock(parentPath[parentPath.length - 1] as BlockId);\n\t\t\t\t\treturn parent ? parent.children : [];\n\t\t\t\t})();\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(\n\t\tparentPath,\n\t\tindex + 1,\n\t\tcreateBlockNode(\n\t\t\t'paragraph' as import('../model/TypeBrands.js').NodeTypeName,\n\t\t\t[createTextNode('')],\n\t\t\tnewId,\n\t\t),\n\t);\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. */\nfunction 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\n\tconst siblings =\n\t\tparentPath.length === 0\n\t\t\t? state.doc.children\n\t\t\t: (() => {\n\t\t\t\t\tconst parent = state.getBlock(parentPath[parentPath.length - 1] as BlockId);\n\t\t\t\t\treturn parent ? parent.children : [];\n\t\t\t\t})();\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(\n\t\tparentPath,\n\t\tinsertIdx,\n\t\tcreateBlockNode(\n\t\t\t'paragraph' as import('../model/TypeBrands.js').NodeTypeName,\n\t\t\t[createTextNode('')],\n\t\t\tnewId,\n\t\t),\n\t);\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\tconst nodeIdx = blockOrder.indexOf(sel.nodeId);\n\t\tif (direction === 'left' || direction === 'up') {\n\t\t\t// Move to end of previous block\n\t\t\tif (nodeIdx > 0) {\n\t\t\t\tconst prevId = blockOrder[nodeIdx - 1];\n\t\t\t\tif (!prevId) return null;\n\t\t\t\tif (isVoidBlock(state, prevId)) {\n\t\t\t\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\t\t\t\treturn state\n\t\t\t\t\t\t.transaction('input')\n\t\t\t\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t\t\t\t.build();\n\t\t\t\t}\n\t\t\t\tconst prevBlock = state.getBlock(prevId);\n\t\t\t\tconst prevLen = prevBlock ? getBlockLength(prevBlock) : 0;\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.setSelection(createCollapsedSelection(prevId, prevLen))\n\t\t\t\t\t.build();\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t// right or down\n\t\tif (nodeIdx < blockOrder.length - 1) {\n\t\t\tconst nextId = blockOrder[nodeIdx + 1];\n\t\t\tif (!nextId) return null;\n\t\t\tif (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\treturn state.transaction('input').setSelection(createCollapsedSelection(nextId, 0)).build();\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Text selection: check if navigating into a void block\n\tif (!isCollapsed(sel)) return null;\n\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"],"names":["defaultSchema","nodeTypes","markTypes","getNodeSpec","schemaFromRegistry","registry","getNodeTypes","getMarkTypes","type","isMarkAllowed","schema","markType","includes","isNodeTypeAllowed","nodeType","defaultFeatures","bold","italic","underline","isVoidBlock","state","bid","block","getBlock","isVoid","deleteNodeSelection","sel","path","findNodePath","doc","nodeId","parentPath","length","slice","siblings","children","parent","index","findIndex","c","id","builder","transaction","newId","generateBlockId","insertNode","createBlockNode","createTextNode","removeNode","setSelection","createCollapsedSelection","build","prevSibling","isBlockNode","prevLeafId","node","current","lastBlockChild","i","child","prevLeaf","prevLen","getBlockLength","nextSibling","nextLeafId","firstBlockChild","find","forEachBlockInRange","range","callback","blockOrder","getBlockOrder","fromIdx","indexOf","from","blockId","toIdx","to","offset","toggleMark","features","key","isNodeSelection","selection","mark","isCollapsed","anchorBlock","anchor","currentMarks","storedMarks","getBlockMarksAtOffset","newMarks","hasMark","filter","m","setStoredMarks","selectionRange","shouldRemove","isMarkActiveInRange","removeMark","addMark","blockLen","isMarkActiveInBlock","pos","getInlineChildren","isTextNode","childEnd","text","marks","toggleBold","mkType","toggleItalic","toggleUnderline","insertTextCommand","origin","insertIdx","insertText","addDeleteSelectionSteps","insertBlockId","insertOffset","deleteSelectionCommand","deleteBackward","deleteTextAt","mergeBlockBackward","deleteForward","mergeBlockForward","deleteWordBackward","wordStart","content","getContentAtOffset","kind","test","char","deleteWordForward","wordEnd","len","deleteSoftLineBackward","deleteSoftLineForward","splitBlockCommand","newBlockId","splitBlock","insertHardBreakCommand","hardBreak","createInlineNode","inlineType","insertInlineNode","sharesParent","blockIdA","blockIdB","pathA","getNodePath","pathB","isInsideIsolating","ancestorId","ancestor","spec","isolating","isIsolatingBlock","blockIdx","prevBlockId","createNodeSelection","prevBlock","mergeBlocksAt","nextBlockId","selectAll","blocks","firstBlock","lastBlock","lastBlockLen","createSelection","isMarkActive","firstLen","midBlockId","midBlock","midLen","navigateArrowIntoVoid","direction","nodeIdx","prevId","nextId"],"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;AAClC,SAAO,EACNJ,WAAWI,GAASC,gBACpBJ,WAAWG,GAASE,aAAAA,GACpBJ,aAAcK,CAAAA,OAAiBH,GAASF,YAAYK,EAAAA,EAAAA;AAEtD;AAGO,SAASC,EAAcC,IAAgBC,IAAAA;AAC7C,SAAOD,GAAOR,UAAUU,SAASD,EAAAA;AAClC;AAGO,SAASE,EAAkBH,IAAgBI,IAAAA;AACjD,SAAOJ,GAAOT,UAAUW,SAASE,EAAAA;AAClC;ACGA,MAAMC,IAAiC,EAAEC,MAAAA,MAAYC,cAAcC,WAAAA,KAAW;AAKvE,SAASC,EAAYC,IAAoBC,IAAAA;AAC/C,QAAMC,KAAQF,GAAMG,SAASF,EAAAA;AAC7B,MAAA,CAAKC,GAAO;AACZ,QAAMnB,KAAciB,GAAMV,OAAOP;AACjC,SAAA,CAAA,CAAKA,MAAAA,SACEA,GAAYmB,GAAMd,IAAAA,GAAOgB;AACjC;AAMO,SAASC,EAAoBL,IAAoBM,IAAAA;AACvD,QAAMC,KAAOC,EAAaR,GAAMS,KAAKH,GAAII;AACzC,MAAA,CAAKH,GAAM,QAAO;AAGlB,QAAMI,KAAwBJ,GAAKK,SAAS,IAAKL,GAAKM,MAAM,GAAA,EAAG,IAAoB,CAAA,GAG7EC,KACiB,MAAtBH,GAAWC,SACRZ,GAAMS,IAAIM;AAEV,UAAMC,KAAShB,GAAMG,SAASQ,GAAWA,GAAWC,SAAS;AAC7D,WAAOI,K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AAI6D,OAAOZ,OAAAA,GACzCrD,KAAQF,GAAMG,SAASG,GAAI6D,OAAOZ;AACxC,MAAA,CAAKrD,GAAO,QAAO;AACnB,QAAM+E,KAAWvC,EAAexC,EAAAA;AAEhC,OAAkB,YAAd0J,MAAuC,WAAdA,OACxBtJ,GAAI6D,OAAOT,WAAWuB,MAAYyD,KAAWxF,GAAWtC,SAAS,GAAG;AACvE,UAAMmJ,KAAS7G,GAAWwF,KAAW,CAAA;AACrC,QAAIqB,MAAUhK,EAAYC,IAAO+J,EAAAA,GAAS;AACzC,YAAMxJ,KAAOC,EAAaR,GAAMS,KAAKsJ,EAAAA,KAAW;AAChD,aAAO/J,GACLsB,YAAY,OAAA,EACZO,aAAa+G,EAAoBmB,IAAQxJ,EAAAA,CAAAA,EACzCwB,MAAAA;AAAAA,IACH;AAAA,EACD;AAGD,OAAkB,WAAd6H,MAAsC,SAAdA,OACD,MAAtBtJ,GAAI6D,OAAOT,UAAgBgF,KAAW,GAAG;AAC5C,UAAMoB,KAAS5G,GAAWwF,KAAW,CAAA;AACrC,QAAIoB,MAAU/J,EAAYC,IAAO8J,EAAAA,GAAS;AACzC,YAAMvJ,KAAOC,EAAaR,GAAMS,KAAKqJ,OAAW,CAAA;AAChD,aAAO9J,GACLsB,YAAY,SACZO,aAAa+G,EAAoBkB,IAAQvJ,EAAAA,CAAAA,EACzCwB;IACH;AAAA,EACD;AAGD,SAAO;AACR;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HTMLUtils-0wvCRvJc.mjs","sources":["../../src/model/HTMLUtils.ts"],"sourcesContent":["/**\n * HTML string escaping utilities shared across serialization and parsing.\n */\n\n/** Escapes special HTML characters in text content. */\nexport function escapeHTML(text: string): string {\n\treturn text\n\t\t.replace(/&/g, '&')\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>')\n\t\t.replace(/\"/g, '"');\n}\n"],"names":["escapeHTML","text","replace"],"mappings":"AAKO,SAASA,EAAWC,IAAAA;AAC1B,SAAOA,GACLC,QAAQ,MAAM,OAAA,EACdA,QAAQ,MAAM,MAAA,EACdA,QAAQ,MAAM,MAAA,EACdA,QAAQ,MAAM;AACjB;"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
function o(o2, n2) {
|
|
2
|
-
return { type: "node", nodeId: o2, path: n2 };
|
|
3
|
-
}
|
|
4
|
-
function n(o2) {
|
|
5
|
-
return "type" in o2 && "node" === o2.type;
|
|
6
|
-
}
|
|
7
|
-
function e(o2) {
|
|
8
|
-
return !n(o2);
|
|
9
|
-
}
|
|
10
|
-
function t(o2, t2) {
|
|
11
|
-
return n(o2) && n(t2) ? o2.nodeId === t2.nodeId : !(!e(o2) || !e(t2)) && o2.anchor.blockId === t2.anchor.blockId && o2.anchor.offset === t2.anchor.offset && o2.head.blockId === t2.head.blockId && o2.head.offset === t2.head.offset;
|
|
12
|
-
}
|
|
13
|
-
function a(o2, n2, e2) {
|
|
14
|
-
return e2 ? { blockId: o2, offset: n2, path: e2 } : { blockId: o2, offset: n2 };
|
|
15
|
-
}
|
|
16
|
-
function c(o2, n2) {
|
|
17
|
-
return { anchor: o2, head: n2 };
|
|
18
|
-
}
|
|
19
|
-
function d(o2, n2) {
|
|
20
|
-
const e2 = { blockId: o2, offset: n2 };
|
|
21
|
-
return { anchor: e2, head: e2 };
|
|
22
|
-
}
|
|
23
|
-
function f(o2) {
|
|
24
|
-
return !n(o2) && o2.anchor.blockId === o2.head.blockId && o2.anchor.offset === o2.head.offset;
|
|
25
|
-
}
|
|
26
|
-
function r(o2, e2) {
|
|
27
|
-
return !!n(o2) || (o2.anchor.blockId === o2.head.blockId ? o2.anchor.offset <= o2.head.offset : !e2 || e2.indexOf(o2.anchor.blockId) <= e2.indexOf(o2.head.blockId));
|
|
28
|
-
}
|
|
29
|
-
function h(o2, n2) {
|
|
30
|
-
return r(o2, n2) ? { from: o2.anchor, to: o2.head } : { from: o2.head, to: o2.anchor };
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
f as a,
|
|
34
|
-
o as b,
|
|
35
|
-
d as c,
|
|
36
|
-
c as d,
|
|
37
|
-
a as e,
|
|
38
|
-
e as f,
|
|
39
|
-
t as g,
|
|
40
|
-
r as h,
|
|
41
|
-
n as i,
|
|
42
|
-
h as s
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=Selection-D5ZjXoB7.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Selection-D5ZjXoB7.mjs","sources":["../../src/model/Selection.ts"],"sourcesContent":["/**\n * Selection model for the Notectl editor.\n * A selection is defined by an anchor and head position within the document.\n */\n\nimport type { BlockId } from './TypeBrands.js';\n\nexport interface Position {\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n\t/** Path from root block to leaf block (optional, for nested structures). */\n\treadonly path?: readonly BlockId[];\n}\n\nexport interface Selection {\n\treadonly anchor: Position;\n\treadonly head: Position;\n}\n\nexport interface SelectionRange {\n\treadonly from: Position;\n\treadonly to: Position;\n}\n\n/** A selection that selects an entire node (e.g. void blocks, table selection). */\nexport interface NodeSelection {\n\treadonly type: 'node';\n\treadonly nodeId: BlockId;\n\treadonly path: readonly BlockId[];\n}\n\n/** Union type representing either a text selection or a node selection. */\nexport type EditorSelection = Selection | NodeSelection;\n\n/** Creates a NodeSelection for the given block. */\nexport function createNodeSelection(nodeId: BlockId, path: readonly BlockId[]): NodeSelection {\n\treturn { type: 'node', nodeId, path };\n}\n\n/** Type guard: returns true if the selection is a NodeSelection. */\nexport function isNodeSelection(sel: EditorSelection): sel is NodeSelection {\n\treturn 'type' in sel && sel.type === 'node';\n}\n\n/** Type guard: returns true if the selection is a text Selection. */\nexport function isTextSelection(sel: EditorSelection): sel is Selection {\n\treturn !isNodeSelection(sel);\n}\n\n/** Compares two EditorSelections for equality. */\nexport function selectionsEqual(a: EditorSelection, b: EditorSelection): boolean {\n\tif (isNodeSelection(a) && isNodeSelection(b)) {\n\t\treturn a.nodeId === b.nodeId;\n\t}\n\tif (isTextSelection(a) && isTextSelection(b)) {\n\t\treturn (\n\t\t\ta.anchor.blockId === b.anchor.blockId &&\n\t\t\ta.anchor.offset === b.anchor.offset &&\n\t\t\ta.head.blockId === b.head.blockId &&\n\t\t\ta.head.offset === b.head.offset\n\t\t);\n\t}\n\treturn false;\n}\n\n/** Creates a Position, optionally with a path. */\nexport function createPosition(\n\tblockId: BlockId,\n\toffset: number,\n\tpath?: readonly BlockId[],\n): Position {\n\treturn path ? { blockId, offset, path } : { blockId, offset };\n}\n\n/** Creates a selection with distinct anchor and head. */\nexport function createSelection(anchor: Position, head: Position): Selection {\n\treturn { anchor, head };\n}\n\n/** Creates a collapsed selection (cursor) at the given position. */\nexport function createCollapsedSelection(blockId: BlockId, offset: number): Selection {\n\tconst pos: Position = { blockId, offset };\n\treturn { anchor: pos, head: pos };\n}\n\n/** Returns true if the selection is collapsed (cursor with no range). NodeSelection is never collapsed. */\nexport function isCollapsed(sel: EditorSelection): boolean {\n\tif (isNodeSelection(sel)) return false;\n\treturn sel.anchor.blockId === sel.head.blockId && sel.anchor.offset === sel.head.offset;\n}\n\n/**\n * Returns true if the selection direction is forward (anchor before head).\n * When anchor and head are in the same block, compares offsets.\n * Cross-block ordering uses document order (not determinable here — caller provides block order).\n * For NodeSelection, always returns true.\n */\nexport function isForward(sel: EditorSelection, blockOrder?: readonly BlockId[]): boolean {\n\tif (isNodeSelection(sel)) return true;\n\tif (sel.anchor.blockId === sel.head.blockId) {\n\t\treturn sel.anchor.offset <= sel.head.offset;\n\t}\n\tif (blockOrder) {\n\t\tconst anchorIdx = blockOrder.indexOf(sel.anchor.blockId);\n\t\tconst headIdx = blockOrder.indexOf(sel.head.blockId);\n\t\treturn anchorIdx <= headIdx;\n\t}\n\treturn true;\n}\n\n/**\n * Returns a normalized range where `from` is always before `to`.\n * Throws for NodeSelection — use isNodeSelection() guard first.\n */\nexport function selectionRange(sel: Selection, blockOrder?: readonly BlockId[]): SelectionRange {\n\tif (isForward(sel, blockOrder)) {\n\t\treturn { from: sel.anchor, to: sel.head };\n\t}\n\treturn { from: sel.head, to: sel.anchor };\n}\n"],"names":["createNodeSelection","nodeId","path","type","isNodeSelection","sel","isTextSelection","selectionsEqual","a","b","anchor","blockId","offset","head","createPosition","createSelection","createCollapsedSelection","pos","isCollapsed","isForward","blockOrder","indexOf","selectionRange","from","to"],"mappings":"AAmCO,SAASA,EAAoBC,IAAiBC,IAAAA;AACpD,SAAO,EAAEC,MAAM,QAAQF,YAAQC,MAAAA,GAAAA;AAChC;AAGO,SAASE,EAAgBC,IAAAA;AAC/B,SAAO,UAAUA,MAAoB,WAAbA,GAAIF;AAC7B;AAGO,SAASG,EAAgBD;AAC/B,SAAA,CAAQD,EAAgBC;AACzB;AAGO,SAASE,EAAgBC,IAAoBC,IAAAA;AACnD,SAAIL,EAAgBI,EAAAA,KAAMJ,EAAgBK,EAAAA,IAClCD,GAAEP,WAAWQ,GAAER,SAAAA,EAAAA,CAEnBK,EAAgBE,EAAAA,KAAAA,CAAMF,EAAgBG,QAExCD,GAAEE,OAAOC,YAAYF,GAAEC,OAAOC,WAC9BH,GAAEE,OAAOE,WAAWH,GAAEC,OAAOE,UAC7BJ,GAAEK,KAAKF,YAAYF,GAAEI,KAAKF,WAC1BH,GAAEK,KAAKD,WAAWH,GAAEI,KAAKD;AAI5B;AAGO,SAASE,EACfH,IACAC,IACAV;AAEA,SAAOA,KAAO,EAAES,SAAAA,IAASC,QAAAA,IAAQV,aAAS,EAAES,SAAAA,IAASC;AACtD;AAGO,SAASG,EAAgBL,IAAkBG,IAAAA;AACjD,SAAO,EAAEH,QAAAA,IAAQG,MAAAA,GAAAA;AAClB;AAGO,SAASG,EAAyBL,IAAkBC,IAAAA;AAC1D,QAAMK,KAAgB,EAAEN,SAAAA,IAASC;AACjC,SAAO,EAAEF,QAAQO,IAAKJ,MAAMI;AAC7B;AAGO,SAASC,EAAYb,IAAAA;AAC3B,SAAA,CAAID,EAAgBC,EAAAA,KACbA,GAAIK,OAAOC,YAAYN,GAAIQ,KAAKF,WAAWN,GAAIK,OAAOE,WAAWP,GAAIQ,KAAKD;AAClF;AAQO,SAASO,EAAUd,IAAsBe;AAC/C,SAAA,CAAA,CAAIhB,EAAgBC,QAChBA,GAAIK,OAAOC,YAAYN,GAAIQ,KAAKF,UAC5BN,GAAIK,OAAOE,UAAUP,GAAIQ,KAAKD,UAElCQ,MACeA,GAAWC,QAAQhB,GAAIK,OAAOC,YAChCS,GAAWC,QAAQhB,GAAIQ,KAAKF,OAAAA;AAI9C;AAMO,SAASW,EAAejB,IAAgBe,IAAAA;AAC9C,SAAID,EAAUd,IAAKe,EAAAA,IACX,EAAEG,MAAMlB,GAAIK,QAAQc,IAAInB,GAAIQ,SAE7B,EAAEU,MAAMlB,GAAIQ,MAAMW,IAAInB,GAAIK,OAAAA;AAClC;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
function e(e2) {
|
|
2
|
-
return "undefined" != typeof navigator && /Mac|iPhone|iPad|iPod/.test(navigator.platform) ? e2.replace(/Mod/g, "⌘").replace(/Shift/g, "⇧").replace(/Alt/g, "⌥").replace(/-/g, "") : e2.replace(/Mod/g, "Ctrl").replace(/-/g, "+");
|
|
3
|
-
}
|
|
4
|
-
export {
|
|
5
|
-
e as f
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=ToolbarItem-ugDymuXi.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarItem-ugDymuXi.mjs","sources":["../../src/plugins/toolbar/ToolbarItem.ts"],"sourcesContent":["/**\n * ToolbarItem: describes a toolbar button registered by a plugin.\n */\n\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\n\nexport interface GridPickerConfig {\n\treadonly maxRows: number;\n\treadonly maxCols: number;\n\tonSelect(rows: number, cols: number): void;\n}\n\nexport interface DropdownConfig {\n\treadonly items: readonly { label: string; command: string; icon?: string }[];\n}\n\nexport type ToolbarGroup = 'format' | 'block' | 'insert' | (string & {});\nexport type PopupType = 'gridPicker' | 'dropdown' | 'custom';\n\ninterface ToolbarItemBase {\n\treadonly id: string;\n\t/** Grouping key: 'format' | 'insert' | 'block' or custom. */\n\treadonly group: ToolbarGroup;\n\t/** Icon content: inline SVG markup or plain text. Rendered via innerHTML. */\n\treadonly icon: string;\n\treadonly label: string;\n\t/** Tooltip shown on hover, e.g. \"Bold (Ctrl+B)\". Falls back to label. */\n\treadonly tooltip?: string;\n\t/** Command name to execute on click. */\n\treadonly command: string;\n\t/**\n\t * Lower priority renders further left.\n\t * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.\n\t */\n\treadonly priority?: number;\n\t/**\n\t * When true, a visual separator is rendered after this item.\n\t * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.\n\t */\n\treadonly separatorAfter?: boolean;\n\tisActive?(state: EditorState): boolean;\n\tisEnabled?(state: EditorState): boolean;\n}\n\ninterface ToolbarItemNoPopup extends ToolbarItemBase {\n\treadonly popupType?: undefined;\n}\n\ninterface ToolbarItemGridPicker extends ToolbarItemBase {\n\treadonly popupType: 'gridPicker';\n\treadonly popupConfig: GridPickerConfig;\n}\n\ninterface ToolbarItemDropdown extends ToolbarItemBase {\n\treadonly popupType: 'dropdown';\n\treadonly popupConfig: DropdownConfig;\n}\n\ninterface ToolbarItemCustomPopup extends ToolbarItemBase {\n\treadonly popupType: 'custom';\n\trenderPopup(container: HTMLElement, context: PluginContext, onClose: () => void): void;\n}\n\nexport type ToolbarItem =\n\t| ToolbarItemNoPopup\n\t| ToolbarItemGridPicker\n\t| ToolbarItemDropdown\n\t| ToolbarItemCustomPopup;\n\n/**\n * Formats a keymap binding string into a human-readable shortcut,\n * using platform-appropriate modifier symbols (⌘ on Mac, Ctrl on others).\n *\n * @example formatShortcut('Mod-B') → \"Ctrl+B\" or \"⌘B\"\n * @example formatShortcut('Mod-Shift-X') → \"Ctrl+Shift+X\" or \"⌘⇧X\"\n */\nexport function formatShortcut(binding: string): string {\n\tconst isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.platform);\n\tif (isMac) {\n\t\treturn binding\n\t\t\t.replace(/Mod/g, '⌘')\n\t\t\t.replace(/Shift/g, '⇧')\n\t\t\t.replace(/Alt/g, '⌥')\n\t\t\t.replace(/-/g, '');\n\t}\n\treturn binding.replace(/Mod/g, 'Ctrl').replace(/-/g, '+');\n}\n"],"names":["formatShortcut","binding","navigator","test","platform","replace"],"mappings":"AA6EO,SAASA,EAAeC,IAAAA;AAE9B,SADmC,eAAA,OAAdC,aAA6B,uBAAuBC,KAAKD,UAAUE,QAAAA,IAEhFH,GACLI,QAAQ,QAAQ,GAAA,EAChBA,QAAQ,UAAU,GAAA,EAClBA,QAAQ,QAAQ,GAAA,EAChBA,QAAQ,MAAM,EAAA,IAEVJ,GAAQI,QAAQ,QAAQ,MAAA,EAAQA,QAAQ,MAAM;AACtD;"}
|
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import { S as t, r as e } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
2
|
-
import { f as n, n as o, a as i, b as r, c as s, d as l } from "./ToolbarKeyboardNav-B32OMv8r.mjs";
|
|
3
|
-
const a = { formattingOptionsAria: "Formatting options" }, c = { en: a, de: { formattingOptionsAria: "Formatierungsoptionen" }, es: { formattingOptionsAria: "Opciones de formato" }, fr: { formattingOptionsAria: "Options de mise en forme" }, zh: { formattingOptionsAria: "格式选项" }, ru: { formattingOptionsAria: "Параметры форматирования" }, ar: { formattingOptionsAria: "خيارات التنسيق" }, hi: { formattingOptionsAria: "फ़ॉर्मेटिंग विकल्प" } };
|
|
4
|
-
function d(t2, e2, n2) {
|
|
5
|
-
const o2 = t2.querySelectorAll(".notectl-grid-picker__cell");
|
|
6
|
-
for (const t3 of o2) {
|
|
7
|
-
const o3 = Number(t3.getAttribute("data-row")), i2 = Number(t3.getAttribute("data-col"));
|
|
8
|
-
t3.classList.toggle("notectl-grid-picker__cell--highlighted", o3 <= e2 && i2 <= n2);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function p() {
|
|
12
|
-
const t2 = document.createElement("span");
|
|
13
|
-
return t2.className = "notectl-toolbar-separator", t2.setAttribute("role", "separator"), t2;
|
|
14
|
-
}
|
|
15
|
-
class u {
|
|
16
|
-
activePopup = null;
|
|
17
|
-
activePopupButton = null;
|
|
18
|
-
closePopupHandler = null;
|
|
19
|
-
getActiveElement;
|
|
20
|
-
constructor(t2) {
|
|
21
|
-
this.getActiveElement = t2;
|
|
22
|
-
}
|
|
23
|
-
isOpen() {
|
|
24
|
-
return null !== this.activePopup;
|
|
25
|
-
}
|
|
26
|
-
toggle(t2, e2, n2) {
|
|
27
|
-
if (this.activePopup) return void this.close();
|
|
28
|
-
const o2 = document.createElement("div");
|
|
29
|
-
switch (o2.className = "notectl-toolbar-popup", e2.popupType) {
|
|
30
|
-
case "gridPicker":
|
|
31
|
-
!(function(t3, e3, n3) {
|
|
32
|
-
t3.className += " notectl-grid-picker";
|
|
33
|
-
const o3 = document.createElement("div");
|
|
34
|
-
o3.className = "notectl-grid-picker__grid", o3.setAttribute("role", "grid"), o3.style.display = "grid", o3.style.gridTemplateColumns = `repeat(${e3.maxCols}, 1fr)`, o3.style.gap = "2px", o3.style.padding = "8px";
|
|
35
|
-
const i2 = document.createElement("div");
|
|
36
|
-
i2.className = "notectl-grid-picker__label", i2.textContent = "1 x 1", i2.style.textAlign = "center", i2.style.padding = "4px", i2.style.fontSize = "12px", i2.setAttribute("aria-live", "polite");
|
|
37
|
-
for (let t4 = 1; t4 <= e3.maxRows; t4++) for (let r2 = 1; r2 <= e3.maxCols; r2++) {
|
|
38
|
-
const s2 = document.createElement("div");
|
|
39
|
-
s2.className = "notectl-grid-picker__cell", s2.setAttribute("role", "gridcell"), s2.setAttribute("tabindex", "-1"), s2.setAttribute("aria-label", `${t4} x ${r2}`), s2.style.width = "20px", s2.style.height = "20px", s2.style.border = "1px solid #ccc", s2.style.cursor = "pointer", s2.setAttribute("data-row", String(t4)), s2.setAttribute("data-col", String(r2)), s2.addEventListener("mouseenter", () => {
|
|
40
|
-
d(o3, t4, r2), i2.textContent = `${t4} x ${r2}`;
|
|
41
|
-
}), s2.addEventListener("mousedown", (o4) => {
|
|
42
|
-
o4.preventDefault(), o4.stopPropagation(), e3.onSelect(t4, r2), n3();
|
|
43
|
-
}), s2.addEventListener("click", () => {
|
|
44
|
-
e3.onSelect(t4, r2), n3();
|
|
45
|
-
}), o3.appendChild(s2);
|
|
46
|
-
}
|
|
47
|
-
t3.appendChild(o3), t3.appendChild(i2);
|
|
48
|
-
})(o2, e2.popupConfig, () => this.close());
|
|
49
|
-
break;
|
|
50
|
-
case "dropdown":
|
|
51
|
-
!(function(t3, e3, n3, o3) {
|
|
52
|
-
t3.classList.add("notectl-dropdown"), t3.setAttribute("role", "menu");
|
|
53
|
-
for (const i2 of e3.items) {
|
|
54
|
-
const e4 = document.createElement("button");
|
|
55
|
-
if (e4.type = "button", e4.className = "notectl-dropdown__item", e4.setAttribute("role", "menuitem"), e4.setAttribute("tabindex", "-1"), i2.icon) {
|
|
56
|
-
const t4 = document.createElement("span");
|
|
57
|
-
t4.className = "notectl-dropdown__item-icon", t4.innerHTML = i2.icon, e4.appendChild(t4);
|
|
58
|
-
}
|
|
59
|
-
const r2 = document.createElement("span");
|
|
60
|
-
r2.className = "notectl-dropdown__item-label", r2.textContent = i2.label, e4.appendChild(r2), e4.addEventListener("mousedown", (t4) => {
|
|
61
|
-
t4.preventDefault(), t4.stopPropagation(), n3(i2.command), o3();
|
|
62
|
-
}), e4.addEventListener("click", () => {
|
|
63
|
-
n3(i2.command), o3();
|
|
64
|
-
}), t3.appendChild(e4);
|
|
65
|
-
}
|
|
66
|
-
})(o2, e2.popupConfig, (t3) => n2.executeCommand(t3), () => this.close());
|
|
67
|
-
break;
|
|
68
|
-
case "custom":
|
|
69
|
-
e2.renderPopup(o2, n2, () => this.close());
|
|
70
|
-
}
|
|
71
|
-
this.positionAndAppend(o2, t2), this.activePopup = o2, this.activePopupButton = t2, t2.classList.add("notectl-toolbar-btn--popup-open"), t2.setAttribute("aria-expanded", "true"), this.focusFirstItem(o2), o2.addEventListener("keydown", (t3) => this.handlePopupKeydown(t3)), this.closePopupHandler = (e3) => {
|
|
72
|
-
const n3 = e3.target;
|
|
73
|
-
n3 instanceof Node && !o2.contains(n3) && n3 !== t2 && this.close();
|
|
74
|
-
}, setTimeout(() => {
|
|
75
|
-
this.closePopupHandler && document.addEventListener("mousedown", this.closePopupHandler);
|
|
76
|
-
}, 0);
|
|
77
|
-
}
|
|
78
|
-
close() {
|
|
79
|
-
this.activePopupButton && (this.activePopupButton.classList.remove("notectl-toolbar-btn--popup-open"), this.activePopupButton.setAttribute("aria-expanded", "false"), this.activePopupButton = null), this.activePopup && (this.activePopup.remove(), this.activePopup = null), this.closePopupHandler && (document.removeEventListener("mousedown", this.closePopupHandler), this.closePopupHandler = null);
|
|
80
|
-
}
|
|
81
|
-
closeAndRestoreFocus() {
|
|
82
|
-
const t2 = this.activePopupButton;
|
|
83
|
-
this.close(), t2?.focus();
|
|
84
|
-
}
|
|
85
|
-
destroy() {
|
|
86
|
-
this.close();
|
|
87
|
-
}
|
|
88
|
-
positionAndAppend(t2, e2) {
|
|
89
|
-
const n2 = e2.getBoundingClientRect();
|
|
90
|
-
t2.style.position = "fixed", t2.style.top = `${n2.bottom + 2}px`, t2.style.left = `${n2.left}px`, t2.style.zIndex = "10000";
|
|
91
|
-
const o2 = e2.getRootNode();
|
|
92
|
-
o2 instanceof ShadowRoot ? o2.appendChild(t2) : document.body.appendChild(t2);
|
|
93
|
-
}
|
|
94
|
-
focusFirstItem(t2) {
|
|
95
|
-
requestAnimationFrame(() => {
|
|
96
|
-
const e2 = t2.querySelector('[role="menuitem"]') ?? t2.querySelector(".notectl-grid-picker__cell") ?? t2.querySelector("button");
|
|
97
|
-
e2?.focus();
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
handlePopupKeydown(t2) {
|
|
101
|
-
if (!this.activePopup) return;
|
|
102
|
-
if ("Escape" === t2.key) return t2.preventDefault(), t2.stopPropagation(), void this.closeAndRestoreFocus();
|
|
103
|
-
if ("Tab" === t2.key) return t2.preventDefault(), void this.closeAndRestoreFocus();
|
|
104
|
-
const e2 = this.activePopup.querySelectorAll('[role="menuitem"]');
|
|
105
|
-
e2.length > 0 ? this.handleDropdownKeydown(t2, e2) : null !== this.activePopup.querySelector(".notectl-grid-picker__cell") ? this.handleGridKeydown(t2) : this.handleCustomPopupKeydown(t2);
|
|
106
|
-
}
|
|
107
|
-
handleDropdownKeydown(t2, e2) {
|
|
108
|
-
const o2 = Array.from(e2), i2 = o2.indexOf(this.getActiveElement());
|
|
109
|
-
switch (t2.key) {
|
|
110
|
-
case "ArrowDown": {
|
|
111
|
-
t2.preventDefault();
|
|
112
|
-
const e3 = n(o2, i2, 1);
|
|
113
|
-
o2[e3]?.focus();
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
case "ArrowUp": {
|
|
117
|
-
t2.preventDefault();
|
|
118
|
-
const e3 = n(o2, i2, -1);
|
|
119
|
-
o2[e3]?.focus();
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
case "Enter":
|
|
123
|
-
case " ": {
|
|
124
|
-
t2.preventDefault();
|
|
125
|
-
const e3 = o2[i2];
|
|
126
|
-
e3 && e3.click();
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
handleGridKeydown(t2) {
|
|
132
|
-
const e2 = this.getActiveElement(), n2 = Number(e2?.getAttribute("data-row") ?? 1), i2 = Number(e2?.getAttribute("data-col") ?? 1), r2 = this.activePopup?.querySelector(".notectl-grid-picker__grid") ?? null;
|
|
133
|
-
if (!r2) return;
|
|
134
|
-
const s2 = r2.querySelector(".notectl-grid-picker__cell:last-child"), l2 = Number(s2?.getAttribute("data-col") ?? 1), a2 = Number(s2?.getAttribute("data-row") ?? 1);
|
|
135
|
-
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t2.key)) {
|
|
136
|
-
t2.preventDefault();
|
|
137
|
-
const [e3, s3] = o(n2, i2, a2, l2, t2.key), c2 = r2.querySelector(`.notectl-grid-picker__cell[data-row="${e3}"][data-col="${s3}"]`);
|
|
138
|
-
c2?.focus(), d(r2, e3, s3);
|
|
139
|
-
const p2 = this.activePopup?.querySelector(".notectl-grid-picker__label") ?? null;
|
|
140
|
-
p2 && (p2.textContent = `${e3} x ${s3}`);
|
|
141
|
-
}
|
|
142
|
-
"Enter" !== t2.key && " " !== t2.key || (t2.preventDefault(), e2?.click());
|
|
143
|
-
}
|
|
144
|
-
handleCustomPopupKeydown(t2) {
|
|
145
|
-
if (!this.activePopup) return;
|
|
146
|
-
const e2 = Array.from(this.activePopup.querySelectorAll("button"));
|
|
147
|
-
if (0 === e2.length) return;
|
|
148
|
-
const o2 = this.getActiveElement(), i2 = e2.indexOf(o2);
|
|
149
|
-
switch (t2.key) {
|
|
150
|
-
case "ArrowDown": {
|
|
151
|
-
t2.preventDefault();
|
|
152
|
-
const o3 = n(e2, i2, 1);
|
|
153
|
-
e2[o3]?.focus();
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
case "ArrowUp": {
|
|
157
|
-
t2.preventDefault();
|
|
158
|
-
const o3 = n(e2, i2, -1);
|
|
159
|
-
e2[o3]?.focus();
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
case "Enter":
|
|
163
|
-
case " ":
|
|
164
|
-
t2.preventDefault(), o2 && o2.dispatchEvent(new MouseEvent("mousedown", { bubbles: true, cancelable: true }));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
class h {
|
|
169
|
-
element;
|
|
170
|
-
timer = null;
|
|
171
|
-
target = null;
|
|
172
|
-
isPopupActive;
|
|
173
|
-
static TOOLTIP_ID = "notectl-toolbar-tooltip";
|
|
174
|
-
constructor(t2) {
|
|
175
|
-
this.isPopupActive = t2, this.element = document.createElement("div"), this.element.className = "notectl-toolbar-tooltip", this.element.id = h.TOOLTIP_ID, this.element.setAttribute("role", "tooltip"), this.element.style.display = "none";
|
|
176
|
-
}
|
|
177
|
-
show(t2) {
|
|
178
|
-
if (this.hide(), this.isPopupActive() || t2.disabled) return;
|
|
179
|
-
const e2 = t2.getAttribute("data-tooltip");
|
|
180
|
-
e2 && (this.target = t2, this.timer = setTimeout(() => {
|
|
181
|
-
if (this.isPopupActive()) return;
|
|
182
|
-
this.element.textContent = e2, this.element.style.display = "";
|
|
183
|
-
const n2 = t2.getRootNode();
|
|
184
|
-
n2 instanceof ShadowRoot && !this.element.parentNode ? n2.appendChild(this.element) : n2 instanceof ShadowRoot || this.element.parentNode || document.body.appendChild(this.element), t2.setAttribute("aria-describedby", h.TOOLTIP_ID);
|
|
185
|
-
const o2 = t2.getBoundingClientRect();
|
|
186
|
-
this.element.style.position = "fixed", this.element.style.top = `${o2.bottom + 6}px`, this.element.style.left = `${o2.left + o2.width / 2}px`, this.element.style.transform = "translateX(-50%)";
|
|
187
|
-
}, 500));
|
|
188
|
-
}
|
|
189
|
-
hide() {
|
|
190
|
-
this.timer && (clearTimeout(this.timer), this.timer = null), this.target && (this.target.removeAttribute("aria-describedby"), this.target = null), this.element.style.display = "none";
|
|
191
|
-
}
|
|
192
|
-
destroy() {
|
|
193
|
-
this.hide(), this.element.remove();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const m = new t("toolbar");
|
|
197
|
-
class b {
|
|
198
|
-
id = "toolbar";
|
|
199
|
-
name = "Toolbar";
|
|
200
|
-
priority = 10;
|
|
201
|
-
context = null;
|
|
202
|
-
toolbarElement = null;
|
|
203
|
-
buttons = [];
|
|
204
|
-
hiddenItems = /* @__PURE__ */ new Set();
|
|
205
|
-
layoutConfig;
|
|
206
|
-
focusedIndex = 0;
|
|
207
|
-
tooltip = null;
|
|
208
|
-
popupController = null;
|
|
209
|
-
locale;
|
|
210
|
-
constructor(t2) {
|
|
211
|
-
this.layoutConfig = t2 ?? null;
|
|
212
|
-
}
|
|
213
|
-
init(t2) {
|
|
214
|
-
this.locale = e(c, t2), t2.registerStyleSheet("\n/* Toolbar */\n.notectl-plugin-container--top {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n border-bottom: 1px solid var(--notectl-border);\n background: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n min-height: 40px;\n}\n\n.notectl-toolbar {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 2px;\n padding: 4px 8px;\n}\n\n.notectl-toolbar-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n border: 1px solid transparent;\n border-radius: 4px;\n background: transparent;\n cursor: pointer;\n color: var(--notectl-fg);\n font-size: 14px;\n line-height: 1;\n padding: 0;\n transition: background 0.1s, border-color 0.1s;\n}\n\n.notectl-toolbar-btn:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-border);\n}\n\n.notectl-toolbar-btn--active {\n background: var(--notectl-active-bg);\n border-color: var(--notectl-primary-muted);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-toolbar-btn:focus-visible {\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n outline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.notectl-toolbar-btn:disabled:hover {\n background: transparent;\n border-color: transparent;\n}\n\n.notectl-toolbar-btn__icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n display: block;\n width: 18px;\n height: 18px;\n fill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n position: fixed;\n padding: 4px 8px;\n border-radius: 4px;\n background: var(--notectl-tooltip-bg);\n color: var(--notectl-tooltip-fg);\n font-size: 11px;\n font-weight: 500;\n white-space: nowrap;\n pointer-events: none;\n z-index: 10001;\n line-height: 1.4;\n letter-spacing: 0.01em;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n display: inline-block;\n width: 1px;\n height: 20px;\n background: var(--notectl-border);\n margin: 0 4px;\n vertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px var(--notectl-shadow);\n overflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n outline: 2px solid var(--notectl-focus-ring);\n outline-offset: -1px;\n}\n\n.notectl-grid-picker__cell--highlighted {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n}\n\n/* Dropdown */\n.notectl-dropdown {\n min-width: 160px;\n padding: 4px 0;\n}\n\n.notectl-dropdown__item {\n display: flex;\n align-items: center;\n width: 100%;\n padding: 8px 12px;\n text-align: left;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n line-height: 1.4;\n font-family: inherit;\n white-space: nowrap;\n}\n\n.notectl-dropdown__item:hover,\n.notectl-dropdown__item:focus-visible {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-dropdown__item:focus-visible {\n outline: none;\n}\n\n.notectl-dropdown__item-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n font-weight: 600;\n color: var(--notectl-fg-muted);\n flex-shrink: 0;\n}\n\n.notectl-dropdown__item-label {\n flex: 1;\n}\n"), this.context = t2, this.popupController = new u(() => this.getActiveElement()), this.tooltip = new h(() => this.popupController?.isOpen() ?? false), t2.registerService(m, { refresh: () => this.updateButtonStates(t2.getState()), closePopup: () => this.popupController?.close() }), this.createToolbarElement();
|
|
215
|
-
}
|
|
216
|
-
onReady() {
|
|
217
|
-
this.renderItems();
|
|
218
|
-
}
|
|
219
|
-
destroy() {
|
|
220
|
-
this.popupController?.destroy(), this.popupController = null, this.tooltip?.destroy(), this.tooltip = null, this.toolbarElement && (this.toolbarElement.remove(), this.toolbarElement = null), this.buttons = [], this.context = null;
|
|
221
|
-
}
|
|
222
|
-
onStateChange(t2, e2, n2) {
|
|
223
|
-
this.updateButtonStates(e2);
|
|
224
|
-
}
|
|
225
|
-
onConfigure(t2) {
|
|
226
|
-
for (const [e2, n2] of Object.entries(t2)) false === n2 ? this.hiddenItems.add(e2) : this.hiddenItems.delete(e2);
|
|
227
|
-
this.renderItems();
|
|
228
|
-
}
|
|
229
|
-
createToolbarElement() {
|
|
230
|
-
if (!this.context) return;
|
|
231
|
-
this.toolbarElement && this.toolbarElement.remove(), this.buttons = [];
|
|
232
|
-
const t2 = this.context.getPluginContainer("top");
|
|
233
|
-
this.toolbarElement = document.createElement("div"), this.toolbarElement.setAttribute("role", "toolbar"), this.toolbarElement.setAttribute("aria-label", this.locale.formattingOptionsAria), this.toolbarElement.setAttribute("data-notectl-no-print", ""), this.toolbarElement.className = "notectl-toolbar", this.toolbarElement.addEventListener("keydown", (t3) => this.handleToolbarKeydown(t3)), t2.appendChild(this.toolbarElement);
|
|
234
|
-
}
|
|
235
|
-
renderItems() {
|
|
236
|
-
if (this.context && this.toolbarElement) {
|
|
237
|
-
for (const t2 of this.buttons) t2.element.remove();
|
|
238
|
-
this.buttons = [];
|
|
239
|
-
for (const t2 of this.toolbarElement.querySelectorAll(".notectl-toolbar-separator")) t2.remove();
|
|
240
|
-
this.layoutConfig ? this.renderItemsByLayout() : this.renderItemsByPriority(), this.buttons.length > 0 && !this.toolbarElement.parentElement && this.context.getPluginContainer("top").appendChild(this.toolbarElement), this.initRovingTabindex(), this.updateButtonStates(this.context.getState());
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
initRovingTabindex() {
|
|
244
|
-
const t2 = this.buttons.map((t3) => t3.element), e2 = i(t2);
|
|
245
|
-
this.focusedIndex = e2 >= 0 ? e2 : 0, r(t2, this.focusedIndex);
|
|
246
|
-
}
|
|
247
|
-
setRovingFocus(t2) {
|
|
248
|
-
if (t2 < 0 || t2 >= this.buttons.length) return;
|
|
249
|
-
this.focusedIndex = t2;
|
|
250
|
-
const e2 = this.buttons.map((t3) => t3.element);
|
|
251
|
-
r(e2, t2), e2[t2]?.focus();
|
|
252
|
-
}
|
|
253
|
-
getActiveElement() {
|
|
254
|
-
const t2 = this.toolbarElement?.getRootNode();
|
|
255
|
-
return t2 instanceof ShadowRoot ? t2.activeElement : document.activeElement;
|
|
256
|
-
}
|
|
257
|
-
syncFocusedIndex() {
|
|
258
|
-
const t2 = this.getActiveElement(), e2 = this.buttons.findIndex((e3) => e3.element === t2);
|
|
259
|
-
e2 >= 0 && (this.focusedIndex = e2);
|
|
260
|
-
}
|
|
261
|
-
handleToolbarKeydown(t2) {
|
|
262
|
-
const e2 = this.buttons.map((t3) => t3.element);
|
|
263
|
-
if (0 !== e2.length) switch (this.syncFocusedIndex(), t2.key) {
|
|
264
|
-
case "ArrowRight": {
|
|
265
|
-
t2.preventDefault();
|
|
266
|
-
const n2 = l(e2, this.focusedIndex, 1);
|
|
267
|
-
this.setRovingFocus(n2);
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
case "ArrowLeft": {
|
|
271
|
-
t2.preventDefault();
|
|
272
|
-
const n2 = l(e2, this.focusedIndex, -1);
|
|
273
|
-
this.setRovingFocus(n2);
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
case "Home": {
|
|
277
|
-
t2.preventDefault();
|
|
278
|
-
const n2 = i(e2);
|
|
279
|
-
n2 >= 0 && this.setRovingFocus(n2);
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
case "End": {
|
|
283
|
-
t2.preventDefault();
|
|
284
|
-
const n2 = s(e2);
|
|
285
|
-
n2 >= 0 && this.setRovingFocus(n2);
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
case "Enter":
|
|
289
|
-
case " ": {
|
|
290
|
-
t2.preventDefault();
|
|
291
|
-
const e3 = this.buttons[this.focusedIndex];
|
|
292
|
-
e3 && this.activateButton(e3.element, e3.item);
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
activateButton(t2, e2) {
|
|
298
|
-
this.tooltip?.hide(), e2.popupType && this.context ? this.popupController?.toggle(t2, e2, this.context) : this.context?.executeCommand(e2.command);
|
|
299
|
-
}
|
|
300
|
-
renderItemsByLayout() {
|
|
301
|
-
if (!this.context || !this.toolbarElement || !this.layoutConfig) return;
|
|
302
|
-
const t2 = this.context.getSchemaRegistry();
|
|
303
|
-
let e2 = true;
|
|
304
|
-
for (const n2 of this.layoutConfig.groups) {
|
|
305
|
-
const o2 = [];
|
|
306
|
-
for (const e3 of n2) {
|
|
307
|
-
const n3 = t2.getToolbarItemsByPlugin(e3).filter((t3) => !this.hiddenItems.has(t3.id));
|
|
308
|
-
n3.sort((t3, e4) => (t3.priority ?? 100) - (e4.priority ?? 100)), o2.push(...n3);
|
|
309
|
-
}
|
|
310
|
-
if (0 !== o2.length) {
|
|
311
|
-
e2 || this.toolbarElement.appendChild(p()), e2 = false;
|
|
312
|
-
for (const t3 of o2) {
|
|
313
|
-
const e3 = this.createButton(t3);
|
|
314
|
-
this.toolbarElement.appendChild(e3.element), this.buttons.push(e3);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
0 === this.buttons.length && this.toolbarElement.remove();
|
|
319
|
-
}
|
|
320
|
-
renderItemsByPriority() {
|
|
321
|
-
if (!this.context || !this.toolbarElement) return;
|
|
322
|
-
const t2 = this.context.getSchemaRegistry().getToolbarItems().filter((t3) => !this.hiddenItems.has(t3.id));
|
|
323
|
-
if (0 === t2.length) return void this.toolbarElement.remove();
|
|
324
|
-
const e2 = [...t2].sort((t3, e3) => (t3.priority ?? 100) - (e3.priority ?? 100));
|
|
325
|
-
if (e2.some((t3) => t3.separatorAfter)) for (let t3 = 0; t3 < e2.length; t3++) {
|
|
326
|
-
const n2 = e2[t3];
|
|
327
|
-
if (!n2) continue;
|
|
328
|
-
const o2 = this.createButton(n2);
|
|
329
|
-
this.toolbarElement.appendChild(o2.element), this.buttons.push(o2), n2.separatorAfter && t3 < e2.length - 1 && this.toolbarElement.appendChild(p());
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
const t3 = /* @__PURE__ */ new Map();
|
|
333
|
-
for (const n3 of e2) {
|
|
334
|
-
const e3 = t3.get(n3.group) ?? [];
|
|
335
|
-
e3.push(n3), t3.set(n3.group, e3);
|
|
336
|
-
}
|
|
337
|
-
let n2 = true;
|
|
338
|
-
for (const [, e3] of t3) {
|
|
339
|
-
n2 || this.toolbarElement.appendChild(p()), n2 = false;
|
|
340
|
-
for (const t4 of e3) {
|
|
341
|
-
const e4 = this.createButton(t4);
|
|
342
|
-
this.toolbarElement.appendChild(e4.element), this.buttons.push(e4);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
createButton(t2) {
|
|
348
|
-
const e2 = document.createElement("button");
|
|
349
|
-
e2.type = "button", e2.className = `notectl-toolbar-btn notectl-toolbar-btn--${t2.id}`, e2.setAttribute("aria-pressed", "false"), e2.setAttribute("aria-label", t2.label), e2.setAttribute("data-toolbar-item", t2.id), e2.setAttribute("data-tooltip", t2.tooltip ?? t2.label), t2.popupType && (e2.setAttribute("aria-haspopup", "true"), e2.setAttribute("aria-expanded", "false"));
|
|
350
|
-
const n2 = document.createElement("span");
|
|
351
|
-
return n2.className = "notectl-toolbar-btn__icon", n2.innerHTML = t2.icon, e2.appendChild(n2), e2.addEventListener("mousedown", (n3) => {
|
|
352
|
-
n3.preventDefault(), this.activateButton(e2, t2);
|
|
353
|
-
}), e2.addEventListener("mouseenter", () => this.tooltip?.show(e2)), e2.addEventListener("mouseleave", () => this.tooltip?.hide()), e2.addEventListener("focus", () => this.tooltip?.show(e2)), e2.addEventListener("blur", () => this.tooltip?.hide()), { element: e2, item: t2 };
|
|
354
|
-
}
|
|
355
|
-
updateButtonStates(t2) {
|
|
356
|
-
for (const e2 of this.buttons) {
|
|
357
|
-
const n2 = e2.item.isActive?.(t2) ?? false, o2 = e2.item.isEnabled?.(t2) ?? true;
|
|
358
|
-
e2.element.setAttribute("aria-pressed", String(n2)), e2.element.classList.toggle("notectl-toolbar-btn--active", n2), e2.element.disabled = !o2, o2 ? e2.element.removeAttribute("aria-disabled") : e2.element.setAttribute("aria-disabled", "true");
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
export {
|
|
363
|
-
b as T,
|
|
364
|
-
m as a,
|
|
365
|
-
c as b,
|
|
366
|
-
a as c
|
|
367
|
-
};
|
|
368
|
-
//# sourceMappingURL=ToolbarPlugin-DY2xaJiu.mjs.map
|