@notectl/core 2.3.5 → 2.3.7

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 (79) hide show
  1. package/dist/chunks/{ColorGrid-D0vLHsG6.mjs → ColorGrid-DAs0--ty.mjs} +2 -2
  2. package/dist/chunks/{ColorGrid-D0vLHsG6.mjs.map → ColorGrid-DAs0--ty.mjs.map} +1 -1
  3. package/dist/chunks/ColorPickerPopup-CFYCCN7m.mjs +2 -0
  4. package/dist/chunks/{ColorPickerPopup-_C5JZhki.mjs.map → ColorPickerPopup-CFYCCN7m.mjs.map} +1 -1
  5. package/dist/chunks/{FontPlugin-C_ScWZ0P.mjs → FontPlugin-BySgRcF3.mjs} +2 -2
  6. package/dist/chunks/{FontPlugin-C_ScWZ0P.mjs.map → FontPlugin-BySgRcF3.mjs.map} +1 -1
  7. package/dist/chunks/{FontSizePlugin-DB_0njtC.mjs → FontSizePlugin-zJDiyhUv.mjs} +2 -2
  8. package/dist/chunks/{FontSizePlugin-DB_0njtC.mjs.map → FontSizePlugin-zJDiyhUv.mjs.map} +1 -1
  9. package/dist/chunks/HeadingPlugin-BCh12hFT.mjs +2 -0
  10. package/dist/chunks/HeadingPlugin-BCh12hFT.mjs.map +1 -0
  11. package/dist/chunks/{HighlightPlugin-B4WlZawl.mjs → HighlightPlugin-By7CWUss.mjs} +2 -2
  12. package/dist/chunks/{HighlightPlugin-B4WlZawl.mjs.map → HighlightPlugin-By7CWUss.mjs.map} +1 -1
  13. package/dist/chunks/{ImagePlugin-C5ESNNsA.mjs → ImagePlugin-C_MuvfYo.mjs} +2 -2
  14. package/dist/chunks/ImagePlugin-C_MuvfYo.mjs.map +1 -0
  15. package/dist/chunks/{LinkPlugin-BwXDGHPe.mjs → LinkPlugin-Bsmt97Kw.mjs} +2 -2
  16. package/dist/chunks/{LinkPlugin-BwXDGHPe.mjs.map → LinkPlugin-Bsmt97Kw.mjs.map} +1 -1
  17. package/dist/chunks/ListPlugin--dqEctgn.mjs +2 -0
  18. package/dist/chunks/{ListPlugin-DSFPSWQC.mjs.map → ListPlugin--dqEctgn.mjs.map} +1 -1
  19. package/dist/chunks/TablePlugin-CdXY0Px5.mjs +2 -0
  20. package/dist/chunks/TablePlugin-CdXY0Px5.mjs.map +1 -0
  21. package/dist/chunks/{TextColorPlugin-D_MhNJT6.mjs → TextColorPlugin-BLTKft_Z.mjs} +2 -2
  22. package/dist/chunks/{TextColorPlugin-D_MhNJT6.mjs.map → TextColorPlugin-BLTKft_Z.mjs.map} +1 -1
  23. package/dist/chunks/ToolbarPlugin-CMHJCdYY.mjs +2 -0
  24. package/dist/chunks/ToolbarPlugin-CMHJCdYY.mjs.map +1 -0
  25. package/dist/chunks/{full-Cshz7aTP.mjs → full-9sO5JbWG.mjs} +2 -2
  26. package/dist/chunks/{full-Cshz7aTP.mjs.map → full-9sO5JbWG.mjs.map} +1 -1
  27. package/dist/chunks/minimal-C07d5reO.mjs +2 -0
  28. package/dist/chunks/{minimal-7XqMY9kC.mjs.map → minimal-C07d5reO.mjs.map} +1 -1
  29. package/dist/chunks/register-DMdtiQ_Z.mjs +3 -0
  30. package/dist/chunks/register-DMdtiQ_Z.mjs.map +1 -0
  31. package/dist/full.mjs +1 -1
  32. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  33. package/dist/model/Keymap.d.ts +5 -2
  34. package/dist/model/Keymap.d.ts.map +1 -1
  35. package/dist/model/KeymapRegistry.d.ts +4 -1
  36. package/dist/model/KeymapRegistry.d.ts.map +1 -1
  37. package/dist/notectl-core.mjs +1 -1
  38. package/dist/notectl-core.umd.js +1 -1
  39. package/dist/notectl-core.umd.js.map +1 -1
  40. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  41. package/dist/plugins/font-size.mjs +1 -1
  42. package/dist/plugins/font.mjs +1 -1
  43. package/dist/plugins/heading.mjs +1 -1
  44. package/dist/plugins/highlight.mjs +1 -1
  45. package/dist/plugins/image.mjs +1 -1
  46. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  47. package/dist/plugins/link.mjs +1 -1
  48. package/dist/plugins/list/ListPlugin.d.ts +2 -1
  49. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  50. package/dist/plugins/list.mjs +1 -1
  51. package/dist/plugins/shared/ColorGrid.d.ts.map +1 -1
  52. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
  53. package/dist/plugins/shared.mjs +1 -1
  54. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
  55. package/dist/plugins/table.mjs +1 -1
  56. package/dist/plugins/text-color.mjs +1 -1
  57. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
  58. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +16 -0
  59. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  60. package/dist/plugins/toolbar.mjs +1 -1
  61. package/dist/presets/full.mjs +1 -1
  62. package/dist/presets/minimal.mjs +1 -1
  63. package/dist/presets.mjs +1 -1
  64. package/dist/register.mjs +1 -1
  65. package/dist/test/PluginTestUtils.d.ts +25 -0
  66. package/dist/test/PluginTestUtils.d.ts.map +1 -1
  67. package/package.json +2 -2
  68. package/dist/chunks/ColorPickerPopup-_C5JZhki.mjs +0 -2
  69. package/dist/chunks/HeadingPlugin-LK8Pg4h0.mjs +0 -2
  70. package/dist/chunks/HeadingPlugin-LK8Pg4h0.mjs.map +0 -1
  71. package/dist/chunks/ImagePlugin-C5ESNNsA.mjs.map +0 -1
  72. package/dist/chunks/ListPlugin-DSFPSWQC.mjs +0 -2
  73. package/dist/chunks/TablePlugin-C4WMYGWN.mjs +0 -2
  74. package/dist/chunks/TablePlugin-C4WMYGWN.mjs.map +0 -1
  75. package/dist/chunks/ToolbarPlugin-DdrLarMD.mjs +0 -2
  76. package/dist/chunks/ToolbarPlugin-DdrLarMD.mjs.map +0 -1
  77. package/dist/chunks/minimal-7XqMY9kC.mjs +0 -2
  78. package/dist/chunks/register-ArnJV5vu.mjs +0 -3
  79. package/dist/chunks/register-ArnJV5vu.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ListPlugin-DSFPSWQC.mjs","names":[],"sources":["../../src/editor/styles/list.ts","../../src/plugins/list/ListAttrsFactory.ts","../../src/plugins/list/ListItemContext.ts","../../src/plugins/list/ListCommands.ts","../../src/plugins/list/ListDefinitions.ts","../../src/plugins/list/ListInputRules.ts","../../src/plugins/list/ListKeyboardHandlers.ts","../../src/plugins/list/ListLocale.ts","../../src/plugins/list/ListMarker.ts","../../src/plugins/list/ListToolbarItems.ts","../../src/plugins/list/ListPlugin.ts"],"sourcesContent":["/** Width of the list marker / checkbox area in pixels. */\nexport const LIST_MARKER_WIDTH = 24;\n\n/** List styles — bullet, ordered, checklist items. */\nexport const LIST_CSS = `\n/* List Wrappers — suppress native markers, we use ::before pseudo-elements */\n.notectl-list {\n\tlist-style: none;\n\tmargin: 0;\n\tpadding: 0;\n}\n\n/* Ordered List — each <ol> wrapper resets the counter */\n.notectl-list--ordered {\n\tcounter-reset: notectl-ordered;\n}\n\n/* List Items */\n.notectl-list-item {\n\tmargin: 0;\n\tpadding: 2px 0;\n\tpadding-inline-start: ${LIST_MARKER_WIDTH}px;\n\tmin-height: 1.6em;\n\tposition: relative;\n}\n\n.notectl-list-item::before {\n\tposition: absolute;\n\tinset-inline-start: 0;\n\tdisplay: inline-block;\n\twidth: ${LIST_MARKER_WIDTH}px;\n\ttext-align: center;\n\t-webkit-user-select: none;\n\tuser-select: none;\n\tpointer-events: none;\n}\n\n/* Container items (#194): block children inherit the item's start padding.\n Trim the first/last child paragraph padding so the first text line sits on\n the marker's line and the item keeps the leaf item's vertical rhythm. */\n.notectl-list-item > p:first-of-type {\n\tpadding-top: 0;\n}\n\n.notectl-list-item > p:last-of-type {\n\tpadding-bottom: 0;\n}\n\n/* Bullet List */\n.notectl-list-item--bullet::before {\n\tcontent: '\\\\2022';\n\tcolor: var(--notectl-fg);\n}\n\n/* Ordered List — counter increment per item */\n.notectl-list-item--ordered {\n\tcounter-increment: notectl-ordered;\n}\n\n.notectl-list-item--ordered::before {\n\tcontent: counter(notectl-ordered) '.';\n\tcolor: var(--notectl-fg);\n\tfont-size: 14px;\n}\n\n/* Checklist — the marker is a real role=\"checkbox\" element (see ListMarker.ts)\n positioned over the reserved marker zone. inline-block keeps the parent's\n line-through (on checked items) from striking the glyph. */\n.notectl-checklist-marker {\n\tposition: absolute;\n\tinset-inline-start: 0;\n\tdisplay: inline-block;\n\twidth: ${LIST_MARKER_WIDTH}px;\n\ttext-align: center;\n\tfont-size: 16px;\n\tcolor: var(--notectl-fg-muted);\n\tcursor: pointer;\n\ttext-decoration: none;\n\t-webkit-user-select: none;\n\tuser-select: none;\n}\n\n.notectl-checklist-marker::before {\n\tcontent: '\\\\2610';\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] .notectl-checklist-marker {\n\tcolor: var(--notectl-success);\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] .notectl-checklist-marker::before {\n\tcontent: '\\\\2611';\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] {\n\tcolor: var(--notectl-fg-muted);\n\ttext-decoration: line-through;\n}\n`;\n","/**\n * Factory for building list item block attributes.\n * Centralizes attribute construction to avoid repetitive inline object literals.\n */\n\nimport type { BlockAttrs } from '../../model/Document.js';\nimport type { ListType } from './ListPlugin.js';\n\n/** Builds a `BlockAttrs` object for a list_item block. */\nexport function buildListItemAttrs(\n\tlistType: ListType,\n\tindent: number,\n\tchecked?: boolean,\n): BlockAttrs {\n\tif (listType === 'checklist') {\n\t\treturn { listType, indent, checked: checked ?? false };\n\t}\n\treturn { listType, indent };\n}\n","/**\n * Shared resolution helpers for container list items (#194).\n *\n * With `list_item` a hybrid leaf/container block, the caret may sit inside a\n * block child of an item. Commands and keyboard handlers resolve the owning\n * item through the ancestor chain and address structural edits through the\n * item's location (parent path + child index), mirroring the blockquote\n * container conventions.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockChildren } from '../../model/Document.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { TransactionBuilder } from '../../state/TransactionBuilder.js';\n\n/** A list item's structural address: its parent path and child index. */\nexport interface ListItemLocation {\n\treadonly item: BlockNode;\n\t/** Path from the document root to the item's parent ([] = root). */\n\treadonly parentPath: readonly BlockId[];\n\t/** The item's index among its parent's block children. */\n\treadonly index: number;\n}\n\n/**\n * Resolves the list item owning a block: the block itself when it is a\n * `list_item`, otherwise its nearest `list_item` ancestor.\n */\nexport function resolveListItem(state: EditorState, id: BlockId): BlockNode | undefined {\n\tconst block: BlockNode | undefined = state.getBlock(id);\n\tif (block?.type === 'list_item') return block;\n\tconst path: readonly BlockId[] | undefined = state.getNodePath(id);\n\tif (!path) return undefined;\n\tfor (let i = path.length - 2; i >= 0; i--) {\n\t\tconst ancestorId: BlockId | undefined = path[i];\n\t\tconst ancestor: BlockNode | undefined = ancestorId ? state.getBlock(ancestorId) : undefined;\n\t\tif (ancestor?.type === 'list_item') return ancestor;\n\t}\n\treturn undefined;\n}\n\n/** Locates a list item's structural address, or undefined if it is not found. */\nexport function locateListItem(state: EditorState, itemId: BlockId): ListItemLocation | undefined {\n\tconst item: BlockNode | undefined = state.getBlock(itemId);\n\tif (!item || item.type !== 'list_item') return undefined;\n\tconst path: readonly BlockId[] | undefined = state.getNodePath(itemId);\n\tif (!path) return undefined;\n\n\tconst parentPath: readonly BlockId[] = path.slice(0, -1);\n\tconst parentId: BlockId | undefined = parentPath[parentPath.length - 1];\n\tconst siblings: readonly BlockNode[] = parentId\n\t\t? getBlockChildren(state.getBlock(parentId) as BlockNode)\n\t\t: state.doc.children;\n\tconst index: number = siblings.findIndex((sibling) => sibling.id === itemId);\n\tif (index < 0) return undefined;\n\treturn { item, parentPath, index };\n}\n\n/**\n * Replaces a container list item with its block children in place. The\n * children keep their IDs, so a selection inside them survives the lift.\n * Leaf items must not be dissolved (their inline content is not a block);\n * convert those via `setBlockType` instead.\n */\nexport function dissolveListItem(builder: TransactionBuilder, location: ListItemLocation): void {\n\tbuilder.removeNode(location.parentPath, location.index);\n\tconst children: readonly BlockNode[] = getBlockChildren(location.item);\n\tchildren.forEach((child, offset) => {\n\t\tbuilder.insertNode(location.parentPath, location.index + offset, child);\n\t});\n}\n","/**\n * Command registration and implementations for list block types.\n * Handles toggle between list types and paragraph, indent/outdent,\n * and checklist toggle.\n */\n\nimport { forEachBlockIdInRange } from '../../commands/RangeIterator.js';\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { isLeafBlock } from '../../model/Document.js';\nimport { isTextSelection, selectionRange } from '../../model/Selection.js';\nimport { type BlockId, nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { buildListItemAttrs } from './ListAttrsFactory.js';\nimport type { ListTypeDefinition } from './ListDefinitions.js';\nimport { dissolveListItem, locateListItem, resolveListItem } from './ListItemContext.js';\nimport type { ListLocale } from './ListLocale.js';\nimport type { ListConfig, ListType } from './ListPlugin.js';\n\n/** Registers all list commands (toggleList:*, indent, outdent, toggleChecklistItem). */\nexport function registerListCommands(\n\tcontext: PluginContext,\n\tconfig: ListConfig,\n\tenabledTypes: readonly ListTypeDefinition[],\n\tlocale: ListLocale,\n): void {\n\tfor (const def of enabledTypes) {\n\t\tcontext.registerCommand(`toggleList:${def.type}`, () => {\n\t\t\treturn toggleList(context, def.type);\n\t\t});\n\t}\n\n\tcontext.registerCommand('indentListItem', () => changeIndent(context, 1, config.maxIndent));\n\n\tcontext.registerCommand('outdentListItem', () => changeIndent(context, -1, config.maxIndent));\n\n\tif (config.types.includes('checklist')) {\n\t\tconst toggleChecklistItem = (): boolean =>\n\t\t\ttoggleChecked(context, { interactiveCheckboxes: config.interactiveCheckboxes, locale });\n\n\t\tcontext.registerCommand('toggleChecklistItem', toggleChecklistItem, {\n\t\t\treadonlyAllowed: config.interactiveCheckboxes,\n\t\t});\n\n\t\t// Mod-Enter gives keyboard-only users a way to toggle a checklist item\n\t\t// (WCAG 2.1.1). The handler declines on non-checklist blocks, so it falls\n\t\t// through to other Mod-Enter bindings (e.g. code-block insert-after).\n\t\t// Registered at navigation priority so it stays reachable in read-only mode\n\t\t// when interactiveCheckboxes is enabled, matching the mouse handler.\n\t\tcontext.registerKeymap({ 'Mod-Enter': toggleChecklistItem }, { priority: 'navigation' });\n\t}\n\n\tcontext.registerKeymap({\n\t\tTab: () => changeIndent(context, 1, config.maxIndent),\n\t\t'Shift-Tab': () => changeIndent(context, -1, config.maxIndent),\n\t});\n}\n\n// --- Command Implementations ---\n\nfunction toggleList(context: PluginContext, listType: ListType): boolean {\n\tconst state: EditorState = context.getState();\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tif (sel.anchor.blockId !== sel.head.blockId) {\n\t\treturn toggleListRange(context, state, listType);\n\t}\n\treturn toggleListSingleBlock(context, state, listType);\n}\n\nfunction toggleListSingleBlock(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tlistType: ListType,\n): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return false;\n\n\t// The caret may sit inside a block child of a container item (#194):\n\t// toggling always targets the owning item, never the child.\n\tconst item: BlockNode | undefined = resolveListItem(state, sel.anchor.blockId);\n\tconst target: BlockNode = item ?? block;\n\n\tif (item && item.attrs?.listType === listType) {\n\t\tconst builder = state.transaction('command');\n\t\tif (isLeafBlock(item)) {\n\t\t\tbuilder.setBlockType(item.id, nodeType('paragraph'));\n\t\t} else {\n\t\t\t// A container item cannot become a paragraph (its children are\n\t\t\t// blocks) — dissolve it into those children instead.\n\t\t\tconst location = locateListItem(state, item.id);\n\t\t\tif (!location) return false;\n\t\t\tdissolveListItem(builder, location);\n\t\t}\n\t\tbuilder.setSelection(sel);\n\t\tcontext.dispatch(builder.build());\n\t\treturn true;\n\t}\n\n\tconst existingIndent: number = isNodeOfType(target, 'list_item') ? target.attrs.indent : 0;\n\tconst attrs = buildListItemAttrs(listType, existingIndent);\n\n\tconst tr = state\n\t\t.transaction('command')\n\t\t.setBlockType(target.id, nodeType('list_item'), attrs)\n\t\t.setSelection(sel)\n\t\t.build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\nfunction toggleListRange(context: PluginContext, state: EditorState, listType: ListType): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst toggleOff: boolean = allBlocksMatchListType(state, range, listType);\n\tconst builder = state.transaction('command');\n\n\t// Children of a container item resolve to their owning item (#194), so a\n\t// range over its paragraphs toggles the item once, not each child.\n\tconst targets: BlockNode[] = collectToggleTargets(state, range);\n\n\t// Dissolving replaces one node with several, shifting later sibling\n\t// indices — process targets back-to-front so earlier addresses stay valid.\n\tfor (let i = targets.length - 1; i >= 0; i--) {\n\t\tconst target: BlockNode | undefined = targets[i];\n\t\tif (!target) continue;\n\n\t\tif (toggleOff) {\n\t\t\tif (isLeafBlock(target)) {\n\t\t\t\tbuilder.setBlockType(target.id, nodeType('paragraph'));\n\t\t\t} else {\n\t\t\t\tconst location = locateListItem(state, target.id);\n\t\t\t\tif (location) dissolveListItem(builder, location);\n\t\t\t}\n\t\t} else {\n\t\t\tconst existingIndent: number = isNodeOfType(target, 'list_item') ? target.attrs.indent : 0;\n\t\t\tconst existingChecked: boolean =\n\t\t\t\tisNodeOfType(target, 'list_item') &&\n\t\t\t\ttarget.attrs.listType === 'checklist' &&\n\t\t\t\ttarget.attrs.checked;\n\t\t\tbuilder.setBlockType(\n\t\t\t\ttarget.id,\n\t\t\t\tnodeType('list_item'),\n\t\t\t\tbuildListItemAttrs(listType, existingIndent, existingChecked),\n\t\t\t);\n\t\t}\n\t}\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** Collects unique toggle targets: each leaf block or its owning list item. */\nfunction collectToggleTargets(\n\tstate: EditorState,\n\trange: ReturnType<typeof selectionRange>,\n): BlockNode[] {\n\tconst targets: BlockNode[] = [];\n\tconst seen = new Set<BlockId>();\n\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = state.getBlock(bid);\n\t\tif (!block) return;\n\t\tconst target: BlockNode = resolveListItem(state, bid) ?? block;\n\t\tif (seen.has(target.id)) return;\n\t\tseen.add(target.id);\n\t\ttargets.push(target);\n\t});\n\treturn targets;\n}\n\n// --- Indent / Outdent ---\n\nfunction changeIndent(context: PluginContext, delta: 1 | -1, maxIndent: number): boolean {\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tif (state.selection.anchor.blockId !== state.selection.head.blockId) {\n\t\treturn changeIndentRange(context, state, delta, maxIndent);\n\t}\n\n\tconst sel = state.selection;\n\tconst block = resolveListItem(state, sel.anchor.blockId);\n\tif (!block || !isNodeOfType(block, 'list_item')) return false;\n\n\tconst newIndent: number = block.attrs.indent + delta;\n\tif (newIndent < 0 || newIndent > maxIndent) return false;\n\n\tconst attrs = buildListItemAttrs(block.attrs.listType, newIndent, block.attrs.checked);\n\tconst tr = state\n\t\t.transaction('command')\n\t\t.setBlockType(block.id, nodeType('list_item'), attrs)\n\t\t.setSelection(sel)\n\t\t.build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\nfunction changeIndentRange(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdelta: 1 | -1,\n\tmaxIndent: number,\n): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\tlet changed = false;\n\tconst seen = new Set<BlockId>();\n\n\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = resolveListItem(state, bid);\n\t\tif (!block || !isNodeOfType(block, 'list_item')) return;\n\t\tif (seen.has(block.id)) return;\n\t\tseen.add(block.id);\n\n\t\tconst newIndent: number = block.attrs.indent + delta;\n\t\tif (newIndent < 0 || newIndent > maxIndent) return;\n\n\t\tbuilder.setBlockType(\n\t\t\tblock.id,\n\t\t\tnodeType('list_item'),\n\t\t\tbuildListItemAttrs(block.attrs.listType, newIndent, block.attrs.checked),\n\t\t);\n\t\tchanged = true;\n\t});\n\n\tif (!changed) return false;\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n// --- Checklist Toggle ---\n\n/** Options for {@link toggleChecked}. */\nexport interface ToggleCheckedOptions {\n\t/** When true, the toggle is allowed even in read-only mode. */\n\treadonly interactiveCheckboxes?: boolean;\n\t/** Specific checklist item to toggle. Defaults to the selection's block. */\n\treadonly targetId?: BlockId;\n\t/** Locale used for the screen-reader announcement of the new state. */\n\treadonly locale: ListLocale;\n}\n\n/**\n * Toggles the checked state of a checklist item and announces the new state to\n * screen readers. Exported for use in the checkbox click handler.\n */\nexport function toggleChecked(context: PluginContext, options: ToggleCheckedOptions): boolean {\n\tconst { interactiveCheckboxes, targetId, locale } = options;\n\tif (context.isReadOnly() && !interactiveCheckboxes) return false;\n\n\tconst state: EditorState = context.getState();\n\tconst bid: BlockId | null =\n\t\ttargetId ?? (!isTextSelection(state.selection) ? null : state.selection.anchor.blockId);\n\tif (!bid) return false;\n\n\tconst block = resolveListItem(state, bid);\n\tif (!block || !isNodeOfType(block, 'list_item') || block.attrs.listType !== 'checklist') {\n\t\treturn false;\n\t}\n\n\tconst nextChecked: boolean = !block.attrs.checked;\n\tconst attrs = buildListItemAttrs(block.attrs.listType, block.attrs.indent, nextChecked);\n\n\tconst builder = state\n\t\t.transaction('command')\n\t\t.setBlockType(block.id, nodeType('list_item'), attrs)\n\t\t.setSelection(state.selection);\n\tif (context.isReadOnly() && interactiveCheckboxes) builder.readonlyAllowed();\n\tcontext.dispatch(builder.build());\n\n\t// Dispatch is synchronous, but the production EditorView may reject a\n\t// transaction (read-only guard or re-entrant update). Only report/announce a\n\t// state transition that actually reached the authoritative editor state.\n\tconst applied = context.getState().getBlock(block.id);\n\tif (\n\t\t!applied ||\n\t\t!isNodeOfType(applied, 'list_item') ||\n\t\tapplied.attrs.listType !== 'checklist' ||\n\t\tapplied.attrs.checked !== nextChecked\n\t) {\n\t\treturn false;\n\t}\n\n\t// The marker is not focused while editing, so the aria-checked change alone is\n\t// not spoken — announce the new state explicitly (WCAG 4.1.3).\n\tcontext.announce(nextChecked ? locale.checkedAnnouncement : locale.uncheckedAnnouncement);\n\treturn true;\n}\n\n// --- Helpers ---\n\n/**\n * Checks whether all blocks in a range belong to list items of the given type\n * (children of container items resolve to their owning item, #194). Exported\n * for toolbar active-state detection.\n */\nexport function allBlocksMatchListType(\n\tstate: EditorState,\n\trange: ReturnType<typeof selectionRange>,\n\tlistType: ListType,\n): boolean {\n\tlet allMatch = true;\n\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = resolveListItem(state, bid);\n\t\tif (!block || block.type !== 'list_item' || block.attrs?.listType !== listType) {\n\t\t\tallMatch = false;\n\t\t}\n\t});\n\treturn allMatch;\n}\n","/**\n * List type metadata: icons, patterns, and type definitions.\n * Pure data constants shared across list plugin modules.\n */\n\nimport type { ListType } from './ListPlugin.js';\n\n// --- List Type Metadata ---\n\nexport interface ListTypeDefinition {\n\treadonly type: ListType;\n\treadonly icon: string;\n\treadonly inputPattern: RegExp;\n\treadonly inputPrefix: string;\n}\n\nconst BULLET_LIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z\"/></svg>';\nconst NUMBERED_LIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z\"/></svg>';\nconst CHECKLIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M22 7h-9v2h9V7zm0 8h-9v2h9v-2zM5.54 11L2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 11zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 19z\"/></svg>';\n\nexport const LIST_TYPE_DEFINITIONS: readonly ListTypeDefinition[] = [\n\t{\n\t\ttype: 'bullet',\n\t\ticon: BULLET_LIST_ICON,\n\t\tinputPattern: /^[-*] $/,\n\t\tinputPrefix: '- ',\n\t},\n\t{\n\t\ttype: 'ordered',\n\t\ticon: NUMBERED_LIST_ICON,\n\t\tinputPattern: /^\\d+\\. $/,\n\t\tinputPrefix: '1. ',\n\t},\n\t{\n\t\ttype: 'checklist',\n\t\ticon: CHECKLIST_ICON,\n\t\tinputPattern: /^\\[[ x]] $/,\n\t\tinputPrefix: '[ ] ',\n\t},\n];\n","/**\n * Input rule registration for list block types.\n * Converts `- `, `* `, `1. `, `[ ] `, `[x] ` at the start of a paragraph into list items.\n */\n\nimport { createCollapsedSelection, isCollapsed, isTextSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { buildListItemAttrs } from './ListAttrsFactory.js';\nimport type { ListTypeDefinition } from './ListDefinitions.js';\n\n/** Registers markdown-style input rules for configured list types. */\nexport function registerListInputRules(\n\tcontext: PluginContext,\n\tenabledTypes: readonly ListTypeDefinition[],\n): void {\n\tfor (const def of enabledTypes) {\n\t\tcontext.registerInputRule({\n\t\t\tpattern: def.inputPattern,\n\t\t\thandler: (state, match, start, _end) => {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (!isTextSelection(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\t// Inside a container list item (#194) the rule must not fire: it\n\t\t\t\t// would nest a list_item into a list_item, which the schema forbids.\n\t\t\t\tconst parent = state.getParent(sel.anchor.blockId);\n\t\t\t\tif (parent?.type === 'list_item') return null;\n\n\t\t\t\tconst matchStr = match[0] ?? '';\n\t\t\t\tconst matchLen = matchStr.length;\n\t\t\t\tconst attrs = buildListItemAttrs(def.type, 0, matchStr.includes('[x]'));\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + matchLen)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('list_item'), attrs)\n\t\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n}\n","/**\n * Keyboard handlers for list block types.\n *\n * Leaf items: Enter splits into a new item (or exits an empty item),\n * Backspace at the start converts back to a paragraph.\n *\n * Container items (#194): the caret sits inside a block child. Enter on an\n * empty trailing child exits into a new sibling item (Enter-Enter continues\n * the list); Backspace at the start of the first child dissolves the item\n * into its children — both mirroring the blockquote container conventions.\n * Everything else falls through to the default split/merge behavior.\n */\n\nimport { isEmptyParagraph } from '../../commands/BlockInsertion.js';\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockChildren, getBlockText } from '../../model/Document.js';\nimport { createBlockNode, createTextNode } from '../../model/Document.js';\nimport { createCollapsedSelection, isCollapsed, isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { buildListItemAttrs } from './ListAttrsFactory.js';\nimport { type ListItemLocation, dissolveListItem, locateListItem } from './ListItemContext.js';\n\n// --- Context Guard ---\n\ninterface ListContext {\n\treadonly state: EditorState;\n\t/** The list item owning the caret (the caret block itself for leaf items). */\n\treadonly item: BlockNode;\n\t/** The caret's block child of a container item; undefined for leaf items. */\n\treadonly child: BlockNode | undefined;\n\treadonly childIndex: number;\n\treadonly childCount: number;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection, non-collapsed selections, and carets outside\n * list items. Resolves both leaf items (caret directly inside the item) and\n * container items (caret inside a direct block child of the item).\n */\nfunction withListContext(context: PluginContext, handler: (ctx: ListContext) => boolean): boolean {\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tconst sel = state.selection;\n\tif (!isCollapsed(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === 'list_item') {\n\t\treturn handler({\n\t\t\tstate,\n\t\t\titem: block,\n\t\t\tchild: undefined,\n\t\t\tchildIndex: -1,\n\t\t\tchildCount: 0,\n\t\t\tblockId: sel.anchor.blockId,\n\t\t\toffset: sel.anchor.offset,\n\t\t});\n\t}\n\n\tconst parent: BlockNode | undefined = state.getParent(sel.anchor.blockId);\n\tif (!parent || parent.type !== 'list_item') return false;\n\tconst children: readonly BlockNode[] = getBlockChildren(parent);\n\tconst childIndex: number = children.findIndex((c) => c.id === block.id);\n\tif (childIndex < 0) return false;\n\n\treturn handler({\n\t\tstate,\n\t\titem: parent,\n\t\tchild: block,\n\t\tchildIndex,\n\t\tchildCount: children.length,\n\t\tblockId: sel.anchor.blockId,\n\t\toffset: sel.anchor.offset,\n\t});\n}\n\n/** Registers Enter and Backspace keymaps for list items. */\nexport function registerListKeymaps(context: PluginContext): void {\n\tcontext.registerKeymap({\n\t\tEnter: () => handleEnter(context),\n\t\tBackspace: () => handleBackspace(context),\n\t});\n}\n\n// --- Enter Handler ---\n\n/**\n * Handles Enter inside a list item.\n * Leaf items: empty → exit list (convert to paragraph); non-empty → split\n * into a new item of the same type.\n * Container items: an empty trailing child exits into a new sibling item;\n * a lone empty child dissolves the item. Everything else falls through to\n * the default split (which grows the item's children).\n */\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withListContext(context, (ctx) => {\n\t\tif (ctx.child) return handleEnterInContainerChild(context, ctx, ctx.child);\n\n\t\tconst text: string = getBlockText(ctx.item);\n\n\t\tif (text === '') {\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.setBlockType(ctx.blockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(ctx.state.selection)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst newBlockId = generateBlockId();\n\t\tconst listType = isNodeOfType(ctx.item, 'list_item') ? ctx.item.attrs.listType : 'bullet';\n\t\tconst indent: number = isNodeOfType(ctx.item, 'list_item') ? ctx.item.attrs.indent : 0;\n\t\tconst attrs = buildListItemAttrs(listType, indent);\n\n\t\tconst tr = ctx.state\n\t\t\t.transaction('input')\n\t\t\t.splitBlock(ctx.blockId, ctx.offset, newBlockId)\n\t\t\t.setBlockType(newBlockId, nodeType('list_item'), attrs)\n\t\t\t.setSelection(createCollapsedSelection(newBlockId, 0))\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\n/** Enter inside a container item's child: exit on an empty trailing child. */\nfunction handleEnterInContainerChild(\n\tcontext: PluginContext,\n\tctx: ListContext,\n\tchild: BlockNode,\n): boolean {\n\tif (!isEmptyParagraph(child)) return false;\n\tif (ctx.childIndex !== ctx.childCount - 1) return false;\n\n\tconst location: ListItemLocation | undefined = locateListItem(ctx.state, ctx.item.id);\n\tif (!location) return false;\n\n\tconst builder = ctx.state.transaction('input');\n\n\tif (ctx.childCount === 1) {\n\t\t// A lone empty child: the item has no content left — dissolve it and\n\t\t// keep the paragraph (same ID, so the caret stays put).\n\t\tdissolveListItem(builder, location);\n\t\tbuilder.setSelection(ctx.state.selection);\n\t\tcontext.dispatch(builder.build());\n\t\treturn true;\n\t}\n\n\t// Drop the empty trailing child and continue the list with a fresh item.\n\tconst listType = isNodeOfType(ctx.item, 'list_item') ? ctx.item.attrs.listType : 'bullet';\n\tconst indent: number = isNodeOfType(ctx.item, 'list_item') ? ctx.item.attrs.indent : 0;\n\tconst newItemId = generateBlockId();\n\tconst newItem: BlockNode = createBlockNode(\n\t\tnodeType('list_item'),\n\t\t[createTextNode('')],\n\t\tnewItemId,\n\t\tbuildListItemAttrs(listType, indent),\n\t);\n\n\tbuilder\n\t\t.removeNode([...location.parentPath, ctx.item.id], ctx.childIndex)\n\t\t.insertNode(location.parentPath, location.index + 1, newItem)\n\t\t.setSelection(createCollapsedSelection(newItemId, 0));\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n// --- Backspace Handler ---\n\n/**\n * Handles Backspace at the start of a list item.\n * Leaf items convert back to a paragraph. Container items dissolve into\n * their block children when the caret sits at the very start of the first\n * child (the un-list gesture); later children fall through to the default\n * sibling merge.\n */\nfunction handleBackspace(context: PluginContext): boolean {\n\treturn withListContext(context, (ctx) => {\n\t\tif (ctx.offset !== 0) return false;\n\n\t\tif (ctx.child) {\n\t\t\tif (ctx.childIndex !== 0) return false;\n\t\t\tconst location: ListItemLocation | undefined = locateListItem(ctx.state, ctx.item.id);\n\t\t\tif (!location) return false;\n\t\t\tconst builder = ctx.state.transaction('input');\n\t\t\tdissolveListItem(builder, location);\n\t\t\tbuilder.setSelection(ctx.state.selection);\n\t\t\tcontext.dispatch(builder.build());\n\t\t\treturn true;\n\t\t}\n\n\t\tconst tr = ctx.state\n\t\t\t.transaction('input')\n\t\t\t.setBlockType(ctx.blockId, nodeType('paragraph'))\n\t\t\t.setSelection(ctx.state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n","/**\n * Locale interface and default English locale for the ListPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface ListLocale {\n\treadonly bulletList: string;\n\treadonly numberedList: string;\n\treadonly checklist: string;\n\t/** Accessible name for the checklist item's checkbox marker (screen readers). */\n\treadonly checkboxLabel: string;\n\t/** Announced when a checklist item is toggled on. */\n\treadonly checkedAnnouncement: string;\n\t/** Announced when a checklist item is toggled off. */\n\treadonly uncheckedAnnouncement: string;\n}\n\n// --- Default English Locale ---\n\nexport const LIST_LOCALE_EN: ListLocale = {\n\tbulletList: 'Bullet List',\n\tnumberedList: 'Numbered List',\n\tchecklist: 'Checklist',\n\tcheckboxLabel: 'To-do item',\n\tcheckedAnnouncement: 'Checked',\n\tuncheckedAnnouncement: 'Unchecked',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<ListLocale> = import.meta.glob<{\n\tdefault: ListLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadListLocale(lang: string): Promise<ListLocale> {\n\treturn loadLocaleModule(localeModules, lang, LIST_LOCALE_EN);\n}\n","/**\n * Accessible checkbox marker for checklist items.\n *\n * The marker is a real `role=\"checkbox\"` element so assistive technology can\n * announce the item's checked state (WCAG 4.1.2 Name, Role, Value). It is\n * rendered `contenteditable=\"false\"` and flagged `data-widget` so the selection\n * layer treats it as zero-width view chrome, never as document content or a caret\n * position. The visible checkbox glyph is drawn in CSS.\n */\n\n/** CSS class identifying the checklist checkbox marker element. */\nexport const CHECKLIST_MARKER_CLASS = 'notectl-checklist-marker';\n\n/** Creates the accessible checkbox marker for a checklist item. */\nexport function createChecklistMarker(checked: boolean, label: string): HTMLElement {\n\tconst marker: HTMLElement = document.createElement('span');\n\tmarker.className = CHECKLIST_MARKER_CLASS;\n\tmarker.setAttribute('role', 'checkbox');\n\tmarker.setAttribute('aria-checked', String(checked));\n\tmarker.setAttribute('aria-label', label);\n\tmarker.setAttribute('contenteditable', 'false');\n\tmarker.setAttribute('data-widget', 'true');\n\treturn marker;\n}\n","/**\n * Toolbar item registration for list block types.\n * Registers bullet, ordered, and checklist toolbar buttons with active-state detection.\n */\n\nimport { isTextSelection, selectionRange } from '../../model/Selection.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { allBlocksMatchListType } from './ListCommands.js';\nimport type { ListTypeDefinition } from './ListDefinitions.js';\nimport { resolveListItem } from './ListItemContext.js';\nimport type { ListLocale } from './ListLocale.js';\nimport type { ListType } from './ListPlugin.js';\n\n/** Registers toolbar items for each enabled list type. */\nexport function registerListToolbarItems(\n\tcontext: PluginContext,\n\tenabledTypes: readonly ListTypeDefinition[],\n\tlocale: ListLocale,\n): void {\n\tfor (const def of enabledTypes) {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: `list-${def.type}`,\n\t\t\tgroup: 'block',\n\t\t\ticon: def.icon,\n\t\t\tlabel: getListLabel(def.type, locale),\n\t\t\tcommand: `toggleList:${def.type}`,\n\t\t\tisActive: (state) => isListActive(state, def.type),\n\t\t});\n\t}\n}\n\n// --- Helpers ---\n\nfunction getListLabel(type: ListType, locale: ListLocale): string {\n\tconst labels: Record<ListType, string> = {\n\t\tbullet: locale.bulletList,\n\t\tordered: locale.numberedList,\n\t\tchecklist: locale.checklist,\n\t};\n\treturn labels[type];\n}\n\nfunction isListActive(state: EditorState, listType: ListType): boolean {\n\tif (!isTextSelection(state.selection)) return false;\n\n\tif (state.selection.anchor.blockId !== state.selection.head.blockId) {\n\t\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\t\treturn allBlocksMatchListType(state, range, listType);\n\t}\n\n\t// Children of container items resolve to their owning item (#194).\n\tconst block = resolveListItem(state, state.selection.anchor.blockId);\n\treturn block?.type === 'list_item' && block.attrs?.listType === listType;\n}\n","/**\n * ListPlugin: registers ordered, unordered, and checklist block types\n * with NodeSpecs, toggle commands, indent/outdent (Tab/Shift-Tab),\n * input rules, and toolbar buttons.\n *\n * This file is a thin orchestrator — command logic, input rules, keyboard\n * handlers, and toolbar rendering are delegated to dedicated modules.\n *\n * Sibling structure is modeled flat: every item carries a `listType` and an\n * `indent` attribute, so nesting between items needs no deep tree. Item\n * content is hybrid (#194): a single-paragraph item is a leaf with inline\n * children, while a multi-block item (second paragraph, code block, quote,\n * heading) is a container whose children are blocks.\n */\n\nimport { DecorationSet, type WidgetDecoration, widget } from '../../decorations/Decoration.js';\nimport { LIST_CSS, LIST_MARKER_WIDTH } from '../../editor/styles/list.js';\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport { blockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport { createBlockElement } from '../../view/DomUtils.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { registerListCommands, toggleChecked } from './ListCommands.js';\nimport { LIST_TYPE_DEFINITIONS, type ListTypeDefinition } from './ListDefinitions.js';\nimport { registerListInputRules } from './ListInputRules.js';\nimport { registerListKeymaps } from './ListKeyboardHandlers.js';\nimport { LIST_LOCALE_EN, type ListLocale, loadListLocale } from './ListLocale.js';\nimport { CHECKLIST_MARKER_CLASS, createChecklistMarker } from './ListMarker.js';\nimport { registerListToolbarItems } from './ListToolbarItems.js';\n\n// --- Attribute Registry Augmentation ---\n\nexport type ListType = 'bullet' | 'ordered' | 'checklist';\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\tlist_item: { listType: ListType; indent: number; checked: boolean };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface ListConfig {\n\t/** Which list types to enable. Defaults to all. */\n\treadonly types: readonly ListType[];\n\t/** Maximum indent depth. Defaults to 4. */\n\treadonly maxIndent: number;\n\t/** Live Markdown shortcuts: `- `/`* ` (bullet), `1. ` (ordered), `[ ] ` (checklist). Default true. */\n\treadonly inputRule?: boolean;\n\t/**\n\t * When true, checklist checkboxes remain interactive even in read-only mode.\n\t * Defaults to false (checkboxes are fully read-only).\n\t */\n\treadonly interactiveCheckboxes?: boolean;\n\treadonly locale?: ListLocale;\n}\n\nconst DEFAULT_CONFIG: ListConfig = {\n\ttypes: ['bullet', 'ordered', 'checklist'],\n\tmaxIndent: 4,\n};\n\n// --- Plugin ---\n\nexport class ListPlugin implements Plugin {\n\treadonly id = 'list';\n\treadonly name = 'List';\n\treadonly priority = 35;\n\n\tprivate readonly config: ListConfig;\n\tprivate locale!: ListLocale;\n\tprivate context: PluginContext | null = null;\n\tprivate checkboxClickHandler: ((e: MouseEvent) => void) | null = null;\n\n\tconstructor(config?: Partial<ListConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.context = context;\n\t\tthis.locale = await resolveLocale(context, this.config.locale, LIST_LOCALE_EN, loadListLocale);\n\t\tconst enabledTypes = this.getEnabledTypes();\n\n\t\tcontext.registerStyleSheet(LIST_CSS);\n\t\tthis.registerNodeSpec(context);\n\t\tregisterListCommands(context, this.config, enabledTypes, this.locale);\n\t\tregisterListKeymaps(context);\n\t\tif (this.config.inputRule !== false) registerListInputRules(context, enabledTypes);\n\t\tregisterListToolbarItems(context, enabledTypes, this.locale);\n\t\tthis.registerCheckboxClickHandler(context);\n\t}\n\n\t/**\n\t * Leaf content rendering replaces a NodeSpec element's children, so the\n\t * checklist marker is declared as zero-width view chrome at offset zero.\n\t * Container list items retain the marker created by `toDOM`; only leaf IDs\n\t * occur in `getBlockOrder()` and therefore receive this decoration.\n\t */\n\tdecorations(state: EditorState): DecorationSet {\n\t\tconst markers: WidgetDecoration[] = [];\n\t\tfor (const id of state.getBlockOrder()) {\n\t\t\tconst block = state.getBlock(id);\n\t\t\tif (!block || !isNodeOfType(block, 'list_item') || block.attrs.listType !== 'checklist') {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst checked = block.attrs.checked;\n\t\t\tmarkers.push(\n\t\t\t\twidget(id, 0, () => createChecklistMarker(checked, this.locale.checkboxLabel), {\n\t\t\t\t\tkey: `checklist-marker:${checked}`,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\treturn DecorationSet.create(markers);\n\t}\n\n\tdestroy(): void {\n\t\tif (this.checkboxClickHandler && this.context) {\n\t\t\tconst container: HTMLElement = this.context.getContainer();\n\t\t\tcontainer.removeEventListener('mousedown', this.checkboxClickHandler);\n\t\t}\n\t\tthis.checkboxClickHandler = null;\n\t\tthis.context = null;\n\t}\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tconst checkboxLabel: string = this.locale.checkboxLabel;\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'list_item',\n\t\t\tgroup: 'block',\n\t\t\t// Hybrid content model (#194): the common single-paragraph item is a\n\t\t\t// leaf (inline text children); multi-block items are containers with\n\t\t\t// block children. Sibling nesting stays flat-with-indent, so list_item\n\t\t\t// itself is deliberately not an allowed child.\n\t\t\tcontent: {\n\t\t\t\tallow: ['text', 'paragraph', 'heading', 'code_block', 'blockquote', 'horizontal_rule'],\n\t\t\t},\n\t\t\tattrs: {\n\t\t\t\tlistType: { default: 'bullet' },\n\t\t\t\tindent: { default: 0 },\n\t\t\t\tchecked: { default: false },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst listType = node.attrs?.listType ?? 'bullet';\n\t\t\t\tconst indent = node.attrs?.indent ?? 0;\n\t\t\t\tconst checked = node.attrs?.checked ?? false;\n\n\t\t\t\tconst li = createBlockElement('li', node.id);\n\t\t\t\tli.setAttribute('role', 'listitem');\n\t\t\t\tli.setAttribute('data-list-type', listType);\n\t\t\t\tli.setAttribute('data-indent', String(indent));\n\t\t\t\tli.className = `notectl-list-item notectl-list-item--${listType}`;\n\n\t\t\t\tif (indent > 0) {\n\t\t\t\t\tsetStyleProperty(li, 'marginLeft', `${indent * LIST_MARKER_WIDTH}px`);\n\t\t\t\t}\n\n\t\t\t\tif (listType === 'checklist') {\n\t\t\t\t\t// `data-checked` drives the CSS glyph; the checked state is exposed to\n\t\t\t\t\t// assistive technology via the marker's own role=\"checkbox\", not via an\n\t\t\t\t\t// (invalid) aria-checked on the listitem. The marker is the first child\n\t\t\t\t\t// so reconciled inline content is appended after it.\n\t\t\t\t\tli.setAttribute('data-checked', String(checked));\n\t\t\t\t\tli.appendChild(createChecklistMarker(checked, checkboxLabel));\n\t\t\t\t}\n\t\t\t\tli.setAttribute('aria-level', String(indent + 1));\n\n\t\t\t\treturn li;\n\t\t\t},\n\t\t\twrapper(node) {\n\t\t\t\tconst listType = node.attrs?.listType ?? 'bullet';\n\t\t\t\tconst tag = listType === 'ordered' ? 'ol' : 'ul';\n\t\t\t\treturn {\n\t\t\t\t\ttag,\n\t\t\t\t\tkey: `list-${listType}`,\n\t\t\t\t\tclassName: `notectl-list notectl-list--${listType}`,\n\t\t\t\t\tattrs: { role: 'list' },\n\t\t\t\t};\n\t\t\t},\n\t\t\ttoHTML(node, content) {\n\t\t\t\tconst listType: string = (node.attrs?.listType as string) ?? 'bullet';\n\t\t\t\tconst checked: boolean = (node.attrs?.checked as boolean) ?? false;\n\n\t\t\t\tif (listType === 'checklist') {\n\t\t\t\t\tconst checkedAttr: string = checked ? ' checked' : '';\n\t\t\t\t\tconst ariaChecked: string = String(checked);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t`<li role=\"checkbox\" aria-checked=\"${ariaChecked}\">` +\n\t\t\t\t\t\t`<input type=\"checkbox\" disabled${checkedAttr}>` +\n\t\t\t\t\t\t`${content || '<br>'}</li>`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn `<li>${content || '<br>'}</li>`;\n\t\t\t},\n\t\t\tparseHTML: [{ tag: 'li' }],\n\t\t\tsanitize: {\n\t\t\t\ttags: ['ul', 'ol', 'li', 'input'],\n\t\t\t\tattrs: ['type', 'disabled', 'checked', 'role', 'aria-checked'],\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate registerCheckboxClickHandler(context: PluginContext): void {\n\t\tif (!this.config.types.includes('checklist')) return;\n\n\t\tthis.checkboxClickHandler = (e: MouseEvent) => {\n\t\t\tif (context.isReadOnly() && !this.config.interactiveCheckboxes) return;\n\n\t\t\tconst target: EventTarget | null = e.target;\n\t\t\tif (!(target instanceof HTMLElement)) return;\n\n\t\t\t// Toggle only when the checkbox marker itself is clicked. The marker is a\n\t\t\t// real element, so this is precise — no geometry/RTL math needed.\n\t\t\tconst marker: Element | null = target.closest(`.${CHECKLIST_MARKER_CLASS}`);\n\t\t\tif (!marker) return;\n\n\t\t\tconst li: Element | null = marker.closest('.notectl-list-item--checklist');\n\t\t\tif (!li) return;\n\n\t\t\te.preventDefault();\n\n\t\t\tconst bid: string | null = li.getAttribute('data-block-id');\n\t\t\tif (!bid) return;\n\n\t\t\ttoggleChecked(context, {\n\t\t\t\tinteractiveCheckboxes: this.config.interactiveCheckboxes,\n\t\t\t\ttargetId: blockId(bid),\n\t\t\t\tlocale: this.locale,\n\t\t\t});\n\t\t};\n\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tcontainer.addEventListener('mousedown', this.checkboxClickHandler);\n\t}\n\n\tprivate getEnabledTypes(): readonly ListTypeDefinition[] {\n\t\treturn LIST_TYPE_DEFINITIONS.filter((def) => this.config.types.includes(def.type));\n\t}\n}\n"],"mappings":"kiBCSA,SAAgB,EACf,EACA,EACA,GAEA,MAAiB,cAAb,EACI,CAAE,WAAU,SAAQ,QAAS,IAAW,GAEzC,CAAE,WAAU,SACpB,CCWA,SAAgB,EAAgB,EAAoB,GACnD,MAAM,EAA+B,EAAM,SAAS,GACp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BAAuB,KAAK,OAAO,sBACnC,SAAU,EAAQ,GAClB,OAAQ,KAAK,UAKf,EADuC,eAC7B,iBAAiB,YAAa,KAAK,sBAC9C,CAEA,eAAA,GACC,OAAO,EAAsB,OAAQ,GAAQ,KAAK,OAAO,MAAM,SAAS,EAAI,MAC7E"}
1
+ {"version":3,"file":"ListPlugin--dqEctgn.mjs","names":[],"sources":["../../src/editor/styles/list.ts","../../src/plugins/list/ListAttrsFactory.ts","../../src/plugins/list/ListItemContext.ts","../../src/plugins/list/ListCommands.ts","../../src/plugins/list/ListDefinitions.ts","../../src/plugins/list/ListInputRules.ts","../../src/plugins/list/ListKeyboardHandlers.ts","../../src/plugins/list/ListLocale.ts","../../src/plugins/list/ListMarker.ts","../../src/plugins/list/ListToolbarItems.ts","../../src/plugins/list/ListPlugin.ts"],"sourcesContent":["/** Width of the list marker / checkbox area in pixels. */\nexport const LIST_MARKER_WIDTH = 24;\n\n/** List styles — bullet, ordered, checklist items. */\nexport const LIST_CSS = `\n/* List Wrappers — suppress native markers, we use ::before pseudo-elements */\n.notectl-list {\n\tlist-style: none;\n\tmargin: 0;\n\tpadding: 0;\n}\n\n/* Ordered List — each <ol> wrapper resets the counter */\n.notectl-list--ordered {\n\tcounter-reset: notectl-ordered;\n}\n\n/* List Items */\n.notectl-list-item {\n\tmargin: 0;\n\tpadding: 2px 0;\n\tpadding-inline-start: ${LIST_MARKER_WIDTH}px;\n\tmin-height: 1.6em;\n\tposition: relative;\n}\n\n.notectl-list-item::before {\n\tposition: absolute;\n\tinset-inline-start: 0;\n\tdisplay: inline-block;\n\twidth: ${LIST_MARKER_WIDTH}px;\n\ttext-align: center;\n\t-webkit-user-select: none;\n\tuser-select: none;\n\tpointer-events: none;\n}\n\n/* Container items (#194): block children inherit the item's start padding.\n Trim the first/last child paragraph padding so the first text line sits on\n the marker's line and the item keeps the leaf item's vertical rhythm. */\n.notectl-list-item > p:first-of-type {\n\tpadding-top: 0;\n}\n\n.notectl-list-item > p:last-of-type {\n\tpadding-bottom: 0;\n}\n\n/* Bullet List */\n.notectl-list-item--bullet::before {\n\tcontent: '\\\\2022';\n\tcolor: var(--notectl-fg);\n}\n\n/* Ordered List — counter increment per item */\n.notectl-list-item--ordered {\n\tcounter-increment: notectl-ordered;\n}\n\n.notectl-list-item--ordered::before {\n\tcontent: counter(notectl-ordered) '.';\n\tcolor: var(--notectl-fg);\n\tfont-size: 14px;\n}\n\n/* Checklist — the marker is a real role=\"checkbox\" element (see ListMarker.ts)\n positioned over the reserved marker zone. inline-block keeps the parent's\n line-through (on checked items) from striking the glyph. */\n.notectl-checklist-marker {\n\tposition: absolute;\n\tinset-inline-start: 0;\n\tdisplay: inline-block;\n\twidth: ${LIST_MARKER_WIDTH}px;\n\ttext-align: center;\n\tfont-size: 16px;\n\tcolor: var(--notectl-fg-muted);\n\tcursor: pointer;\n\ttext-decoration: none;\n\t-webkit-user-select: none;\n\tuser-select: none;\n}\n\n.notectl-checklist-marker::before {\n\tcontent: '\\\\2610';\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] .notectl-checklist-marker {\n\tcolor: var(--notectl-success);\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] .notectl-checklist-marker::before {\n\tcontent: '\\\\2611';\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] {\n\tcolor: var(--notectl-fg-muted);\n\ttext-decoration: line-through;\n}\n`;\n","/**\n * Factory for building list item block attributes.\n * Centralizes attribute construction to avoid repetitive inline object literals.\n */\n\nimport type { BlockAttrs } from '../../model/Document.js';\nimport type { ListType } from './ListPlugin.js';\n\n/** Builds a `BlockAttrs` object for a list_item block. */\nexport function buildListItemAttrs(\n\tlistType: ListType,\n\tindent: number,\n\tchecked?: boolean,\n): BlockAttrs {\n\tif (listType === 'checklist') {\n\t\treturn { listType, indent, checked: checked ?? false };\n\t}\n\treturn { listType, indent };\n}\n","/**\n * Shared resolution helpers for container list items (#194).\n *\n * With `list_item` a hybrid leaf/container block, the caret may sit inside a\n * block child of an item. Commands and keyboard handlers resolve the owning\n * item through the ancestor chain and address structural edits through the\n * item's location (parent path + child index), mirroring the blockquote\n * container conventions.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockChildren } from '../../model/Document.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { TransactionBuilder } from '../../state/TransactionBuilder.js';\n\n/** A list item's structural address: its parent path and child index. */\nexport interface ListItemLocation {\n\treadonly item: BlockNode;\n\t/** Path from the document root to the item's parent ([] = root). */\n\treadonly parentPath: readonly BlockId[];\n\t/** The item's index among its parent's block children. */\n\treadonly index: number;\n}\n\n/**\n * Resolves the list item owning a block: the block itself when it is a\n * `list_item`, otherwise its nearest `list_item` ancestor.\n */\nexport function resolveListItem(state: EditorState, id: BlockId): BlockNode | undefined {\n\tconst block: BlockNode | undefined = state.getBlock(id);\n\tif (block?.type === 'list_item') return block;\n\tconst path: readonly BlockId[] | undefined = state.getNodePath(id);\n\tif (!path) return undefined;\n\tfor (let i = path.length - 2; i >= 0; i--) {\n\t\tconst ancestorId: BlockId | undefined = path[i];\n\t\tconst ancestor: BlockNode | undefined = ancestorId ? state.getBlock(ancestorId) : undefined;\n\t\tif (ancestor?.type === 'list_item') return ancestor;\n\t}\n\treturn undefined;\n}\n\n/** Locates a list item's structural address, or undefined if it is not found. */\nexport function locateListItem(state: EditorState, itemId: BlockId): ListItemLocation | undefined {\n\tconst item: BlockNode | undefined = state.getBlock(itemId);\n\tif (!item || item.type !== 'list_item') return undefined;\n\tconst path: readonly BlockId[] | undefined = state.getNodePath(itemId);\n\tif (!path) return undefined;\n\n\tconst parentPath: readonly BlockId[] = path.slice(0, -1);\n\tconst parentId: BlockId | undefined = parentPath[parentPath.length - 1];\n\tconst siblings: readonly BlockNode[] = parentId\n\t\t? getBlockChildren(state.getBlock(parentId) as BlockNode)\n\t\t: state.doc.children;\n\tconst index: number = siblings.findIndex((sibling) => sibling.id === itemId);\n\tif (index < 0) return undefined;\n\treturn { item, parentPath, index };\n}\n\n/**\n * Replaces a container list item with its block children in place. The\n * children keep their IDs, so a selection inside them survives the lift.\n * Leaf items must not be dissolved (their inline content is not a block);\n * convert those via `setBlockType` instead.\n */\nexport function dissolveListItem(builder: TransactionBuilder, location: ListItemLocation): void {\n\tbuilder.removeNode(location.parentPath, location.index);\n\tconst children: readonly BlockNode[] = getBlockChildren(location.item);\n\tchildren.forEach((child, offset) => {\n\t\tbuilder.insertNode(location.parentPath, location.index + offset, child);\n\t});\n}\n","/**\n * Command registration and implementations for list block types.\n * Handles toggle between list types and paragraph, indent/outdent,\n * and checklist toggle.\n */\n\nimport { forEachBlockIdInRange } from '../../commands/RangeIterator.js';\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { isLeafBlock } from '../../model/Document.js';\nimport { isTextSelection, selectionRange } from '../../model/Selection.js';\nimport { type BlockId, nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { buildListItemAttrs } from './ListAttrsFactory.js';\nimport type { ListTypeDefinition } from './ListDefinitions.js';\nimport { dissolveListItem, locateListItem, resolveListItem } from './ListItemContext.js';\nimport type { ListLocale } from './ListLocale.js';\nimport type { ListConfig, ListType } from './ListPlugin.js';\n\n/** Registers all list commands (toggleList:*, indent, outdent, toggleChecklistItem). */\nexport function registerListCommands(\n\tcontext: PluginContext,\n\tconfig: ListConfig,\n\tenabledTypes: readonly ListTypeDefinition[],\n\tlocale: ListLocale,\n): void {\n\tfor (const def of enabledTypes) {\n\t\tcontext.registerCommand(`toggleList:${def.type}`, () => {\n\t\t\treturn toggleList(context, def.type);\n\t\t});\n\t}\n\n\tcontext.registerCommand('indentListItem', () => changeIndent(context, 1, config.maxIndent));\n\n\tcontext.registerCommand('outdentListItem', () => changeIndent(context, -1, config.maxIndent));\n\n\tif (config.types.includes('checklist')) {\n\t\tconst toggleChecklistItem = (): boolean =>\n\t\t\ttoggleChecked(context, { interactiveCheckboxes: config.interactiveCheckboxes, locale });\n\n\t\tcontext.registerCommand('toggleChecklistItem', toggleChecklistItem, {\n\t\t\treadonlyAllowed: config.interactiveCheckboxes,\n\t\t});\n\n\t\t// Mod-Enter gives keyboard-only users a way to toggle a checklist item\n\t\t// (WCAG 2.1.1). The handler declines on non-checklist blocks, so it falls\n\t\t// through to other Mod-Enter bindings (e.g. code-block insert-after).\n\t\t// Registered at navigation priority so it stays reachable in read-only mode\n\t\t// when interactiveCheckboxes is enabled, matching the mouse handler.\n\t\tcontext.registerKeymap({ 'Mod-Enter': toggleChecklistItem }, { priority: 'navigation' });\n\t}\n\n\tcontext.registerKeymap({\n\t\tTab: () => changeIndent(context, 1, config.maxIndent),\n\t\t'Shift-Tab': () => changeIndent(context, -1, config.maxIndent),\n\t});\n}\n\n// --- Command Implementations ---\n\nfunction toggleList(context: PluginContext, listType: ListType): boolean {\n\tconst state: EditorState = context.getState();\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tif (sel.anchor.blockId !== sel.head.blockId) {\n\t\treturn toggleListRange(context, state, listType);\n\t}\n\treturn toggleListSingleBlock(context, state, listType);\n}\n\nfunction toggleListSingleBlock(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tlistType: ListType,\n): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return false;\n\n\t// The caret may sit inside a block child of a container item (#194):\n\t// toggling always targets the owning item, never the child.\n\tconst item: BlockNode | undefined = resolveListItem(state, sel.anchor.blockId);\n\tconst target: BlockNode = item ?? block;\n\n\tif (item && item.attrs?.listType === listType) {\n\t\tconst builder = state.transaction('command');\n\t\tif (isLeafBlock(item)) {\n\t\t\tbuilder.setBlockType(item.id, nodeType('paragraph'));\n\t\t} else {\n\t\t\t// A container item cannot become a paragraph (its children are\n\t\t\t// blocks) — dissolve it into those children instead.\n\t\t\tconst location = locateListItem(state, item.id);\n\t\t\tif (!location) return false;\n\t\t\tdissolveListItem(builder, location);\n\t\t}\n\t\tbuilder.setSelection(sel);\n\t\tcontext.dispatch(builder.build());\n\t\treturn true;\n\t}\n\n\tconst existingIndent: number = isNodeOfType(target, 'list_item') ? target.attrs.indent : 0;\n\tconst attrs = buildListItemAttrs(listType, existingIndent);\n\n\tconst tr = state\n\t\t.transaction('command')\n\t\t.setBlockType(target.id, nodeType('list_item'), attrs)\n\t\t.setSelection(sel)\n\t\t.build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\nfunction toggleListRange(context: PluginContext, state: EditorState, listType: ListType): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst toggleOff: boolean = allBlocksMatchListType(state, range, listType);\n\tconst builder = state.transaction('command');\n\n\t// Children of a container item resolve to their owning item (#194), so a\n\t// range over its paragraphs toggles the item once, not each child.\n\tconst targets: BlockNode[] = collectToggleTargets(state, range);\n\n\t// Dissolving replaces one node with several, shifting later sibling\n\t// indices — process targets back-to-front so earlier addresses stay valid.\n\tfor (let i = targets.length - 1; i >= 0; i--) {\n\t\tconst target: BlockNode | undefined = targets[i];\n\t\tif (!target) continue;\n\n\t\tif (toggleOff) {\n\t\t\tif (isLeafBlock(target)) {\n\t\t\t\tbuilder.setBlockType(target.id, nodeType('paragraph'));\n\t\t\t} else {\n\t\t\t\tconst location = locateListItem(state, target.id);\n\t\t\t\tif (location) dissolveListItem(builder, location);\n\t\t\t}\n\t\t} else {\n\t\t\tconst existingIndent: number = isNodeOfType(target, 'list_item') ? target.attrs.indent : 0;\n\t\t\tconst existingChecked: boolean =\n\t\t\t\tisNodeOfType(target, 'list_item') &&\n\t\t\t\ttarget.attrs.listType === 'checklist' &&\n\t\t\t\ttarget.attrs.checked;\n\t\t\tbuilder.setBlockType(\n\t\t\t\ttarget.id,\n\t\t\t\tnodeType('list_item'),\n\t\t\t\tbuildListItemAttrs(listType, existingIndent, existingChecked),\n\t\t\t);\n\t\t}\n\t}\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** Collects unique toggle targets: each leaf block or its owning list item. */\nfunction collectToggleTargets(\n\tstate: EditorState,\n\trange: ReturnType<typeof selectionRange>,\n): BlockNode[] {\n\tconst targets: BlockNode[] = [];\n\tconst seen = new Set<BlockId>();\n\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = state.getBlock(bid);\n\t\tif (!block) return;\n\t\tconst target: BlockNode = resolveListItem(state, bid) ?? block;\n\t\tif (seen.has(target.id)) return;\n\t\tseen.add(target.id);\n\t\ttargets.push(target);\n\t});\n\treturn targets;\n}\n\n// --- Indent / Outdent ---\n\nfunction changeIndent(context: PluginContext, delta: 1 | -1, maxIndent: number): boolean {\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tif (state.selection.anchor.blockId !== state.selection.head.blockId) {\n\t\treturn changeIndentRange(context, state, delta, maxIndent);\n\t}\n\n\tconst sel = state.selection;\n\tconst block = resolveListItem(state, sel.anchor.blockId);\n\tif (!block || !isNodeOfType(block, 'list_item')) return false;\n\n\tconst newIndent: number = block.attrs.indent + delta;\n\tif (newIndent < 0 || newIndent > maxIndent) return false;\n\n\tconst attrs = buildListItemAttrs(block.attrs.listType, newIndent, block.attrs.checked);\n\tconst tr = state\n\t\t.transaction('command')\n\t\t.setBlockType(block.id, nodeType('list_item'), attrs)\n\t\t.setSelection(sel)\n\t\t.build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\nfunction changeIndentRange(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdelta: 1 | -1,\n\tmaxIndent: number,\n): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\tlet changed = false;\n\tconst seen = new Set<BlockId>();\n\n\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = resolveListItem(state, bid);\n\t\tif (!block || !isNodeOfType(block, 'list_item')) return;\n\t\tif (seen.has(block.id)) return;\n\t\tseen.add(block.id);\n\n\t\tconst newIndent: number = block.attrs.indent + delta;\n\t\tif (newIndent < 0 || newIndent > maxIndent) return;\n\n\t\tbuilder.setBlockType(\n\t\t\tblock.id,\n\t\t\tnodeType('list_item'),\n\t\t\tbuildListItemAttrs(block.attrs.listType, newIndent, block.attrs.checked),\n\t\t);\n\t\tchanged = true;\n\t});\n\n\tif (!changed) return false;\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n// --- Checklist Toggle ---\n\n/** Options for {@link toggleChecked}. */\nexport interface ToggleCheckedOptions {\n\t/** When true, the toggle is allowed even in read-only mode. */\n\treadonly interactiveCheckboxes?: boolean;\n\t/** Specific checklist item to toggle. Defaults to the selection's block. */\n\treadonly targetId?: BlockId;\n\t/** Locale used for the screen-reader announcement of the new state. */\n\treadonly locale: ListLocale;\n}\n\n/**\n * Toggles the checked state of a checklist item and announces the new state to\n * screen readers. Exported for use in the checkbox click handler.\n */\nexport function toggleChecked(context: PluginContext, options: ToggleCheckedOptions): boolean {\n\tconst { interactiveCheckboxes, targetId, locale } = options;\n\tif (context.isReadOnly() && !interactiveCheckboxes) return false;\n\n\tconst state: EditorState = context.getState();\n\tconst bid: BlockId | null =\n\t\ttargetId ?? (!isTextSelection(state.selection) ? null : state.selection.anchor.blockId);\n\tif (!bid) return false;\n\n\tconst block = resolveListItem(state, bid);\n\tif (!block || !isNodeOfType(block, 'list_item') || block.attrs.listType !== 'checklist') {\n\t\treturn false;\n\t}\n\n\tconst nextChecked: boolean = !block.attrs.checked;\n\tconst attrs = buildListItemAttrs(block.attrs.listType, block.attrs.indent, nextChecked);\n\n\tconst builder = state\n\t\t.transaction('command')\n\t\t.setBlockType(block.id, nodeType('list_item'), attrs)\n\t\t.setSelection(state.selection);\n\tif (context.isReadOnly() && interactiveCheckboxes) builder.readonlyAllowed();\n\tcontext.dispatch(builder.build());\n\n\t// Dispatch is synchronous, but the production EditorView may reject a\n\t// transaction (read-only guard or re-entrant update). Only report/announce a\n\t// state transition that actually reached the authoritative editor state.\n\tconst applied = context.getState().getBlock(block.id);\n\tif (\n\t\t!applied ||\n\t\t!isNodeOfType(applied, 'list_item') ||\n\t\tapplied.attrs.listType !== 'checklist' ||\n\t\tapplied.attrs.checked !== nextChecked\n\t) {\n\t\treturn false;\n\t}\n\n\t// The marker is not focused while editing, so the aria-checked change alone is\n\t// not spoken — announce the new state explicitly (WCAG 4.1.3).\n\tcontext.announce(nextChecked ? locale.checkedAnnouncement : locale.uncheckedAnnouncement);\n\treturn true;\n}\n\n// --- Helpers ---\n\n/**\n * Checks whether all blocks in a range belong to list items of the given type\n * (children of container items resolve to their owning item, #194). Exported\n * for toolbar active-state detection.\n */\nexport function allBlocksMatchListType(\n\tstate: EditorState,\n\trange: ReturnType<typeof selectionRange>,\n\tlistType: ListType,\n): boolean {\n\tlet allMatch = true;\n\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = resolveListItem(state, bid);\n\t\tif (!block || block.type !== 'list_item' || block.attrs?.listType !== listType) {\n\t\t\tallMatch = false;\n\t\t}\n\t});\n\treturn allMatch;\n}\n","/**\n * List type metadata: icons, patterns, and type definitions.\n * Pure data constants shared across list plugin modules.\n */\n\nimport type { ListType } from './ListPlugin.js';\n\n// --- List Type Metadata ---\n\nexport interface ListTypeDefinition {\n\treadonly type: ListType;\n\treadonly icon: string;\n\treadonly inputPattern: RegExp;\n\treadonly inputPrefix: string;\n}\n\nconst BULLET_LIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z\"/></svg>';\nconst NUMBERED_LIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z\"/></svg>';\nconst CHECKLIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M22 7h-9v2h9V7zm0 8h-9v2h9v-2zM5.54 11L2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 11zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 19z\"/></svg>';\n\nexport const LIST_TYPE_DEFINITIONS: readonly ListTypeDefinition[] = [\n\t{\n\t\ttype: 'bullet',\n\t\ticon: BULLET_LIST_ICON,\n\t\tinputPattern: /^[-*] $/,\n\t\tinputPrefix: '- ',\n\t},\n\t{\n\t\ttype: 'ordered',\n\t\ticon: NUMBERED_LIST_ICON,\n\t\tinputPattern: /^\\d+\\. $/,\n\t\tinputPrefix: '1. ',\n\t},\n\t{\n\t\ttype: 'checklist',\n\t\ticon: CHECKLIST_ICON,\n\t\tinputPattern: /^\\[[ x]] $/,\n\t\tinputPrefix: '[ ] ',\n\t},\n];\n","/**\n * Input rule registration for list block types.\n * Converts `- `, `* `, `1. `, `[ ] `, `[x] ` at the start of a paragraph into list items.\n */\n\nimport { createCollapsedSelection, isCollapsed, isTextSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { buildListItemAttrs } from './ListAttrsFactory.js';\nimport type { ListTypeDefinition } from './ListDefinitions.js';\n\n/** Registers markdown-style input rules for configured list types. */\nexport function registerListInputRules(\n\tcontext: PluginContext,\n\tenabledTypes: readonly ListTypeDefinition[],\n): void {\n\tfor (const def of enabledTypes) {\n\t\tcontext.registerInputRule({\n\t\t\tpattern: def.inputPattern,\n\t\t\thandler: (state, match, start, _end) => {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (!isTextSelection(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\t// Inside a container list item (#194) the rule must not fire: it\n\t\t\t\t// would nest a list_item into a list_item, which the schema forbids.\n\t\t\t\tconst parent = state.getParent(sel.anchor.blockId);\n\t\t\t\tif (parent?.type === 'list_item') return null;\n\n\t\t\t\tconst matchStr = match[0] ?? '';\n\t\t\t\tconst matchLen = matchStr.length;\n\t\t\t\tconst attrs = buildListItemAttrs(def.type, 0, matchStr.includes('[x]'));\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + matchLen)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('list_item'), attrs)\n\t\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n}\n","/**\n * Keyboard handlers for list block types.\n *\n * Leaf items: Enter splits into a new item (or exits an empty item),\n * Backspace at the start converts back to a paragraph.\n *\n * Container items (#194): the caret sits inside a block child. Enter on an\n * empty trailing child exits into a new sibling item (Enter-Enter continues\n * the list); Backspace at the start of the first child dissolves the item\n * into its children — both mirroring the blockquote container conventions.\n * Everything else falls through to the default split/merge behavior.\n */\n\nimport { isEmptyParagraph } from '../../commands/BlockInsertion.js';\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockChildren, getBlockText } from '../../model/Document.js';\nimport { createBlockNode, createTextNode } from '../../model/Document.js';\nimport { createCollapsedSelection, isCollapsed, isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { buildListItemAttrs } from './ListAttrsFactory.js';\nimport { type ListItemLocation, dissolveListItem, locateListItem } from './ListItemContext.js';\n\n// --- Context Guard ---\n\ninterface ListContext {\n\treadonly state: EditorState;\n\t/** The list item owning the caret (the caret block itself for leaf items). */\n\treadonly item: BlockNode;\n\t/** The caret's block child of a container item; undefined for leaf items. */\n\treadonly child: BlockNode | undefined;\n\treadonly childIndex: number;\n\treadonly childCount: number;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection, non-collapsed selections, and carets outside\n * list items. Resolves both leaf items (caret directly inside the item) and\n * container items (caret inside a direct block child of the item).\n */\nfunction withListContext(context: PluginContext, handler: (ctx: ListContext) => boolean): boolean {\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tconst sel = state.selection;\n\tif (!isCollapsed(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === 'list_item') {\n\t\treturn handler({\n\t\t\tstate,\n\t\t\titem: block,\n\t\t\tchild: undefined,\n\t\t\tchildIndex: -1,\n\t\t\tchildCount: 0,\n\t\t\tblockId: sel.anchor.blockId,\n\t\t\toffset: sel.anchor.offset,\n\t\t});\n\t}\n\n\tconst parent: BlockNode | undefined = state.getParent(sel.anchor.blockId);\n\tif (!parent || parent.type !== 'list_item') return false;\n\tconst children: readonly BlockNode[] = getBlockChildren(parent);\n\tconst childIndex: number = children.findIndex((c) => c.id === block.id);\n\tif (childIndex < 0) return false;\n\n\treturn handler({\n\t\tstate,\n\t\titem: parent,\n\t\tchild: block,\n\t\tchildIndex,\n\t\tchildCount: children.length,\n\t\tblockId: sel.anchor.blockId,\n\t\toffset: sel.anchor.offset,\n\t});\n}\n\n/** Registers Enter and Backspace keymaps for list items. */\nexport function registerListKeymaps(context: PluginContext): void {\n\tcontext.registerKeymap({\n\t\tEnter: () => handleEnter(context),\n\t\tBackspace: () => handleBackspace(context),\n\t});\n}\n\n// --- Enter Handler ---\n\n/**\n * Handles Enter inside a list item.\n * Leaf items: empty → exit list (convert to paragraph); non-empty → split\n * into a new item of the same type.\n * Container items: an empty trailing child exits into a new sibling item;\n * a lone empty child dissolves the item. Everything else falls through to\n * the default split (which grows the item's children).\n */\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withListContext(context, (ctx) => {\n\t\tif (ctx.child) return handleEnterInContainerChild(context, ctx, ctx.child);\n\n\t\tconst text: string = getBlockText(ctx.item);\n\n\t\tif (text === '') {\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.setBlockType(ctx.blockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(ctx.state.selection)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst newBlockId = generateBlockId();\n\t\tconst listType = isNodeOfType(ctx.item, 'list_item') ? ctx.item.attrs.listType : 'bullet';\n\t\tconst indent: number = isNodeOfType(ctx.item, 'list_item') ? ctx.item.attrs.indent : 0;\n\t\tconst attrs = buildListItemAttrs(listType, indent);\n\n\t\tconst tr = ctx.state\n\t\t\t.transaction('input')\n\t\t\t.splitBlock(ctx.blockId, ctx.offset, newBlockId)\n\t\t\t.setBlockType(newBlockId, nodeType('list_item'), attrs)\n\t\t\t.setSelection(createCollapsedSelection(newBlockId, 0))\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\n/** Enter inside a container item's child: exit on an empty trailing child. */\nfunction handleEnterInContainerChild(\n\tcontext: PluginContext,\n\tctx: ListContext,\n\tchild: BlockNode,\n): boolean {\n\tif (!isEmptyParagraph(child)) return false;\n\tif (ctx.childIndex !== ctx.childCount - 1) return false;\n\n\tconst location: ListItemLocation | undefined = locateListItem(ctx.state, ctx.item.id);\n\tif (!location) return false;\n\n\tconst builder = ctx.state.transaction('input');\n\n\tif (ctx.childCount === 1) {\n\t\t// A lone empty child: the item has no content left — dissolve it and\n\t\t// keep the paragraph (same ID, so the caret stays put).\n\t\tdissolveListItem(builder, location);\n\t\tbuilder.setSelection(ctx.state.selection);\n\t\tcontext.dispatch(builder.build());\n\t\treturn true;\n\t}\n\n\t// Drop the empty trailing child and continue the list with a fresh item.\n\tconst listType = isNodeOfType(ctx.item, 'list_item') ? ctx.item.attrs.listType : 'bullet';\n\tconst indent: number = isNodeOfType(ctx.item, 'list_item') ? ctx.item.attrs.indent : 0;\n\tconst newItemId = generateBlockId();\n\tconst newItem: BlockNode = createBlockNode(\n\t\tnodeType('list_item'),\n\t\t[createTextNode('')],\n\t\tnewItemId,\n\t\tbuildListItemAttrs(listType, indent),\n\t);\n\n\tbuilder\n\t\t.removeNode([...location.parentPath, ctx.item.id], ctx.childIndex)\n\t\t.insertNode(location.parentPath, location.index + 1, newItem)\n\t\t.setSelection(createCollapsedSelection(newItemId, 0));\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n// --- Backspace Handler ---\n\n/**\n * Handles Backspace at the start of a list item.\n * Leaf items convert back to a paragraph. Container items dissolve into\n * their block children when the caret sits at the very start of the first\n * child (the un-list gesture); later children fall through to the default\n * sibling merge.\n */\nfunction handleBackspace(context: PluginContext): boolean {\n\treturn withListContext(context, (ctx) => {\n\t\tif (ctx.offset !== 0) return false;\n\n\t\tif (ctx.child) {\n\t\t\tif (ctx.childIndex !== 0) return false;\n\t\t\tconst location: ListItemLocation | undefined = locateListItem(ctx.state, ctx.item.id);\n\t\t\tif (!location) return false;\n\t\t\tconst builder = ctx.state.transaction('input');\n\t\t\tdissolveListItem(builder, location);\n\t\t\tbuilder.setSelection(ctx.state.selection);\n\t\t\tcontext.dispatch(builder.build());\n\t\t\treturn true;\n\t\t}\n\n\t\tconst tr = ctx.state\n\t\t\t.transaction('input')\n\t\t\t.setBlockType(ctx.blockId, nodeType('paragraph'))\n\t\t\t.setSelection(ctx.state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n","/**\n * Locale interface and default English locale for the ListPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface ListLocale {\n\treadonly bulletList: string;\n\treadonly numberedList: string;\n\treadonly checklist: string;\n\t/** Accessible name for the checklist item's checkbox marker (screen readers). */\n\treadonly checkboxLabel: string;\n\t/** Announced when a checklist item is toggled on. */\n\treadonly checkedAnnouncement: string;\n\t/** Announced when a checklist item is toggled off. */\n\treadonly uncheckedAnnouncement: string;\n}\n\n// --- Default English Locale ---\n\nexport const LIST_LOCALE_EN: ListLocale = {\n\tbulletList: 'Bullet List',\n\tnumberedList: 'Numbered List',\n\tchecklist: 'Checklist',\n\tcheckboxLabel: 'To-do item',\n\tcheckedAnnouncement: 'Checked',\n\tuncheckedAnnouncement: 'Unchecked',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<ListLocale> = import.meta.glob<{\n\tdefault: ListLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadListLocale(lang: string): Promise<ListLocale> {\n\treturn loadLocaleModule(localeModules, lang, LIST_LOCALE_EN);\n}\n","/**\n * Accessible checkbox marker for checklist items.\n *\n * The marker is a real `role=\"checkbox\"` element so assistive technology can\n * announce the item's checked state (WCAG 4.1.2 Name, Role, Value). It is\n * rendered `contenteditable=\"false\"` and flagged `data-widget` so the selection\n * layer treats it as zero-width view chrome, never as document content or a caret\n * position. The visible checkbox glyph is drawn in CSS.\n */\n\n/** CSS class identifying the checklist checkbox marker element. */\nexport const CHECKLIST_MARKER_CLASS = 'notectl-checklist-marker';\n\n/** Creates the accessible checkbox marker for a checklist item. */\nexport function createChecklistMarker(checked: boolean, label: string): HTMLElement {\n\tconst marker: HTMLElement = document.createElement('span');\n\tmarker.className = CHECKLIST_MARKER_CLASS;\n\tmarker.setAttribute('role', 'checkbox');\n\tmarker.setAttribute('aria-checked', String(checked));\n\tmarker.setAttribute('aria-label', label);\n\tmarker.setAttribute('contenteditable', 'false');\n\tmarker.setAttribute('data-widget', 'true');\n\treturn marker;\n}\n","/**\n * Toolbar item registration for list block types.\n * Registers bullet, ordered, and checklist toolbar buttons with active-state detection.\n */\n\nimport { isTextSelection, selectionRange } from '../../model/Selection.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { allBlocksMatchListType } from './ListCommands.js';\nimport type { ListTypeDefinition } from './ListDefinitions.js';\nimport { resolveListItem } from './ListItemContext.js';\nimport type { ListLocale } from './ListLocale.js';\nimport type { ListType } from './ListPlugin.js';\n\n/** Registers toolbar items for each enabled list type. */\nexport function registerListToolbarItems(\n\tcontext: PluginContext,\n\tenabledTypes: readonly ListTypeDefinition[],\n\tlocale: ListLocale,\n): void {\n\tfor (const def of enabledTypes) {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: `list-${def.type}`,\n\t\t\tgroup: 'block',\n\t\t\ticon: def.icon,\n\t\t\tlabel: getListLabel(def.type, locale),\n\t\t\tcommand: `toggleList:${def.type}`,\n\t\t\tisActive: (state) => isListActive(state, def.type),\n\t\t});\n\t}\n}\n\n// --- Helpers ---\n\nfunction getListLabel(type: ListType, locale: ListLocale): string {\n\tconst labels: Record<ListType, string> = {\n\t\tbullet: locale.bulletList,\n\t\tordered: locale.numberedList,\n\t\tchecklist: locale.checklist,\n\t};\n\treturn labels[type];\n}\n\nfunction isListActive(state: EditorState, listType: ListType): boolean {\n\tif (!isTextSelection(state.selection)) return false;\n\n\tif (state.selection.anchor.blockId !== state.selection.head.blockId) {\n\t\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\t\treturn allBlocksMatchListType(state, range, listType);\n\t}\n\n\t// Children of container items resolve to their owning item (#194).\n\tconst block = resolveListItem(state, state.selection.anchor.blockId);\n\treturn block?.type === 'list_item' && block.attrs?.listType === listType;\n}\n","/**\n * ListPlugin: registers ordered, unordered, and checklist block types\n * with NodeSpecs, toggle commands, indent/outdent (Tab/Shift-Tab),\n * input rules, and toolbar buttons.\n *\n * This file is a thin orchestrator — command logic, input rules, keyboard\n * handlers, and toolbar rendering are delegated to dedicated modules.\n *\n * Sibling structure is modeled flat: every item carries a `listType` and an\n * `indent` attribute, so nesting between items needs no deep tree. Item\n * content is hybrid (#194): a single-paragraph item is a leaf with inline\n * children, while a multi-block item (second paragraph, code block, quote,\n * heading) is a container whose children are blocks.\n */\n\nimport { DecorationSet, type WidgetDecoration, widget } from '../../decorations/Decoration.js';\nimport { LIST_CSS, LIST_MARKER_WIDTH } from '../../editor/styles/list.js';\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport { blockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport { createBlockElement } from '../../view/DomUtils.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { registerListCommands, toggleChecked } from './ListCommands.js';\nimport { LIST_TYPE_DEFINITIONS, type ListTypeDefinition } from './ListDefinitions.js';\nimport { registerListInputRules } from './ListInputRules.js';\nimport { registerListKeymaps } from './ListKeyboardHandlers.js';\nimport { LIST_LOCALE_EN, type ListLocale, loadListLocale } from './ListLocale.js';\nimport { CHECKLIST_MARKER_CLASS, createChecklistMarker } from './ListMarker.js';\nimport { registerListToolbarItems } from './ListToolbarItems.js';\n\n// --- Attribute Registry Augmentation ---\n\nexport type ListType = 'bullet' | 'ordered' | 'checklist';\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\tlist_item: { listType: ListType; indent: number; checked: boolean };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface ListConfig {\n\t/** Which list types to enable. Defaults to all. */\n\treadonly types: readonly ListType[];\n\t/** Maximum indent depth. Defaults to 4. */\n\treadonly maxIndent: number;\n\t/** Live Markdown shortcuts: `- `/`* ` (bullet), `1. ` (ordered), `[ ] ` (checklist). Default true. */\n\treadonly inputRule?: boolean;\n\t/**\n\t * When true, checklist checkboxes remain interactive even in read-only mode.\n\t * Defaults to false (checkboxes are fully read-only).\n\t */\n\treadonly interactiveCheckboxes?: boolean;\n\treadonly locale?: ListLocale;\n}\n\nconst DEFAULT_CONFIG: ListConfig = {\n\ttypes: ['bullet', 'ordered', 'checklist'],\n\tmaxIndent: 4,\n};\n\n// --- Plugin ---\n\nexport class ListPlugin implements Plugin {\n\treadonly id = 'list';\n\treadonly name = 'List';\n\treadonly priority = 35;\n\n\tprivate readonly config: ListConfig;\n\tprivate locale!: ListLocale;\n\tprivate context: PluginContext | null = null;\n\tprivate checkboxMouseDownHandler: ((e: MouseEvent) => void) | null = null;\n\tprivate checkboxClickHandler: ((e: MouseEvent) => void) | null = null;\n\n\tconstructor(config?: Partial<ListConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.context = context;\n\t\tthis.locale = await resolveLocale(context, this.config.locale, LIST_LOCALE_EN, loadListLocale);\n\t\tconst enabledTypes = this.getEnabledTypes();\n\n\t\tcontext.registerStyleSheet(LIST_CSS);\n\t\tthis.registerNodeSpec(context);\n\t\tregisterListCommands(context, this.config, enabledTypes, this.locale);\n\t\tregisterListKeymaps(context);\n\t\tif (this.config.inputRule !== false) registerListInputRules(context, enabledTypes);\n\t\tregisterListToolbarItems(context, enabledTypes, this.locale);\n\t\tthis.registerCheckboxHandlers(context);\n\t}\n\n\t/**\n\t * Leaf content rendering replaces a NodeSpec element's children, so the\n\t * checklist marker is declared as zero-width view chrome at offset zero.\n\t * Container list items retain the marker created by `toDOM`; only leaf IDs\n\t * occur in `getBlockOrder()` and therefore receive this decoration.\n\t */\n\tdecorations(state: EditorState): DecorationSet {\n\t\tconst markers: WidgetDecoration[] = [];\n\t\tfor (const id of state.getBlockOrder()) {\n\t\t\tconst block = state.getBlock(id);\n\t\t\tif (!block || !isNodeOfType(block, 'list_item') || block.attrs.listType !== 'checklist') {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst checked = block.attrs.checked;\n\t\t\tmarkers.push(\n\t\t\t\twidget(id, 0, () => createChecklistMarker(checked, this.locale.checkboxLabel), {\n\t\t\t\t\tkey: `checklist-marker:${checked}`,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\treturn DecorationSet.create(markers);\n\t}\n\n\tdestroy(): void {\n\t\tif (this.context) {\n\t\t\tconst container: HTMLElement = this.context.getContainer();\n\t\t\tif (this.checkboxMouseDownHandler) {\n\t\t\t\tcontainer.removeEventListener('mousedown', this.checkboxMouseDownHandler);\n\t\t\t}\n\t\t\tif (this.checkboxClickHandler) {\n\t\t\t\tcontainer.removeEventListener('click', this.checkboxClickHandler);\n\t\t\t}\n\t\t}\n\t\tthis.checkboxMouseDownHandler = null;\n\t\tthis.checkboxClickHandler = null;\n\t\tthis.context = null;\n\t}\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tconst checkboxLabel: string = this.locale.checkboxLabel;\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'list_item',\n\t\t\tgroup: 'block',\n\t\t\t// Hybrid content model (#194): the common single-paragraph item is a\n\t\t\t// leaf (inline text children); multi-block items are containers with\n\t\t\t// block children. Sibling nesting stays flat-with-indent, so list_item\n\t\t\t// itself is deliberately not an allowed child.\n\t\t\tcontent: {\n\t\t\t\tallow: ['text', 'paragraph', 'heading', 'code_block', 'blockquote', 'horizontal_rule'],\n\t\t\t},\n\t\t\tattrs: {\n\t\t\t\tlistType: { default: 'bullet' },\n\t\t\t\tindent: { default: 0 },\n\t\t\t\tchecked: { default: false },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst listType = node.attrs?.listType ?? 'bullet';\n\t\t\t\tconst indent = node.attrs?.indent ?? 0;\n\t\t\t\tconst checked = node.attrs?.checked ?? false;\n\n\t\t\t\tconst li = createBlockElement('li', node.id);\n\t\t\t\tli.setAttribute('role', 'listitem');\n\t\t\t\tli.setAttribute('data-list-type', listType);\n\t\t\t\tli.setAttribute('data-indent', String(indent));\n\t\t\t\tli.className = `notectl-list-item notectl-list-item--${listType}`;\n\n\t\t\t\tif (indent > 0) {\n\t\t\t\t\tsetStyleProperty(li, 'marginLeft', `${indent * LIST_MARKER_WIDTH}px`);\n\t\t\t\t}\n\n\t\t\t\tif (listType === 'checklist') {\n\t\t\t\t\t// `data-checked` drives the CSS glyph; the checked state is exposed to\n\t\t\t\t\t// assistive technology via the marker's own role=\"checkbox\", not via an\n\t\t\t\t\t// (invalid) aria-checked on the listitem. The marker is the first child\n\t\t\t\t\t// so reconciled inline content is appended after it.\n\t\t\t\t\tli.setAttribute('data-checked', String(checked));\n\t\t\t\t\tli.appendChild(createChecklistMarker(checked, checkboxLabel));\n\t\t\t\t}\n\t\t\t\tli.setAttribute('aria-level', String(indent + 1));\n\n\t\t\t\treturn li;\n\t\t\t},\n\t\t\twrapper(node) {\n\t\t\t\tconst listType = node.attrs?.listType ?? 'bullet';\n\t\t\t\tconst tag = listType === 'ordered' ? 'ol' : 'ul';\n\t\t\t\treturn {\n\t\t\t\t\ttag,\n\t\t\t\t\tkey: `list-${listType}`,\n\t\t\t\t\tclassName: `notectl-list notectl-list--${listType}`,\n\t\t\t\t\tattrs: { role: 'list' },\n\t\t\t\t};\n\t\t\t},\n\t\t\ttoHTML(node, content) {\n\t\t\t\tconst listType: string = (node.attrs?.listType as string) ?? 'bullet';\n\t\t\t\tconst checked: boolean = (node.attrs?.checked as boolean) ?? false;\n\n\t\t\t\tif (listType === 'checklist') {\n\t\t\t\t\tconst checkedAttr: string = checked ? ' checked' : '';\n\t\t\t\t\tconst ariaChecked: string = String(checked);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t`<li role=\"checkbox\" aria-checked=\"${ariaChecked}\">` +\n\t\t\t\t\t\t`<input type=\"checkbox\" disabled${checkedAttr}>` +\n\t\t\t\t\t\t`${content || '<br>'}</li>`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn `<li>${content || '<br>'}</li>`;\n\t\t\t},\n\t\t\tparseHTML: [{ tag: 'li' }],\n\t\t\tsanitize: {\n\t\t\t\ttags: ['ul', 'ol', 'li', 'input'],\n\t\t\t\tattrs: ['type', 'disabled', 'checked', 'role', 'aria-checked'],\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate registerCheckboxHandlers(context: PluginContext): void {\n\t\tif (!this.config.types.includes('checklist')) return;\n\n\t\tconst findChecklistItem = (target: EventTarget | null): Element | null => {\n\t\t\tif (!(target instanceof HTMLElement)) return null;\n\t\t\tconst marker: Element | null = target.closest(`.${CHECKLIST_MARKER_CLASS}`);\n\t\t\tif (!marker) return null;\n\t\t\treturn marker.closest('.notectl-list-item--checklist');\n\t\t};\n\n\t\tthis.checkboxMouseDownHandler = (e: MouseEvent) => {\n\t\t\tif (context.isReadOnly() && !this.config.interactiveCheckboxes) return;\n\t\t\tif (!findChecklistItem(e.target)) return;\n\t\t\te.preventDefault();\n\t\t};\n\n\t\tthis.checkboxClickHandler = (e: MouseEvent) => {\n\t\t\tif (context.isReadOnly() && !this.config.interactiveCheckboxes) return;\n\t\t\tconst li: Element | null = findChecklistItem(e.target);\n\t\t\tif (!li) return;\n\n\t\t\te.preventDefault();\n\n\t\t\tconst bid: string | null = li.getAttribute('data-block-id');\n\t\t\tif (!bid) return;\n\n\t\t\ttoggleChecked(context, {\n\t\t\t\tinteractiveCheckboxes: this.config.interactiveCheckboxes,\n\t\t\t\ttargetId: blockId(bid),\n\t\t\t\tlocale: this.locale,\n\t\t\t});\n\t\t};\n\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tcontainer.addEventListener('mousedown', this.checkboxMouseDownHandler);\n\t\tcontainer.addEventListener('click', this.checkboxClickHandler);\n\t}\n\n\tprivate getEnabledTypes(): readonly ListTypeDefinition[] {\n\t\treturn LIST_TYPE_DEFINITIONS.filter((def) => this.config.types.includes(def.type));\n\t}\n}\n"],"mappings":"kiBCSA,SAAgB,EACf,EACA,EACA,GAEA,MAAiB,cAAb,EACI,CAAE,WAAU,SAAQ,QAAS,IAAW,GAEzC,CAAE,WAAU,SACpB,CCWA,SAAgB,EAAgB,EAAoB,GACnD,MAAM,EAA+B,EAAM,SAAS,GACpD,GAAoB,cAAhB,GAAO,KAAsB,OAAO,EACxC,MAAM,EAAuC,EAAM,YAAY,GAC/D,GAAK,EACL,IAAK,IAAI,EAAI,EAAK,OAAS,EAAG,GAAK,EAAG,IAAK,CAC1C,MAAM,EAAkC,EAAK,GACvC,EAAkC,EAAa,EAAM,SAAS,QAAc,EAClF,GAAuB,cAAnB,GAAU,KAAsB,OAAO,CAC5C,CAED,CAGA,SAAgB,EAAe,EAAoB,GAClD,MAAM,EAA8B,EAAM,SAAS,GACnD,IAAK,GAAsB,cAAd,EAAK,KAAsB,OACxC,MAAM,EAAuC,EAAM,YAAY,GAC/D,IAAK,EAAM,OAEX,MAAM,EAAiC,EAAK,MAAM,GAAG,GAC/C,EAAgC,EAAW,EAAW,OAAS,GAI/D,GAHiC,EACpC,EAAiB,EAAM,SAAS,IAChC,EAAM,IAAI,UACkB,UAAW,GAAY,EAAQ,KAAO,GACrE,OAAI,EAAQ,OAAZ,EACO,CAAE,OAAM,aAAY,QAC5B,CAQA,SAAgB,EAAiB,EAA6B,GAC7D,EAAQ,WAAW,EAAS,WAAY,EAAS,OAEjD,EADwD,EAAS,MACxD,QAAA,CAAS,EAAO,KACxB,EAAQ,WAAW,EAAS,WAAY,EAAS,MAA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D,MAAiB,cAAb,EAIF,qCAF2B,OAAO,sCADP,EAAU,WAAa,MAK/C,GAAW,cAIT,OAAO,GAAW,aAC1B,EACA,UAAW,CAAC,CAAE,IAAK,OACnB,SAAU,CACT,KAAM,CAAC,KAAM,KAAM,KAAM,SACzB,MAAO,CAAC,OAAQ,WAAY,UAAW,OAAQ,kBAGlD,CAEA,wBAAA,CAAiC,GAChC,IAAK,KAAK,OAAO,MAAM,SAAS,aAAc,OAE9C,MAAM,EAAqB,IAC1B,KAAM,aAAkB,aAAc,OAAO,KAC7C,MAAM,EAAyB,EAAO,QAAQ,IAAI,KAClD,OAAK,EACE,EAAO,QAAQ,iCADF,MAIrB,KAAK,yBAA4B,IAC5B,EAAQ,eAAiB,KAAK,OAAO,uBACpC,EAAkB,EAAE,SACzB,EAAE,kBAGH,KAAK,qBAAwB,IAC5B,GAAI,EAAQ,eAAiB,KAAK,OAAO,sBAAuB,OAChE,MAAM,EAAqB,EAAkB,EAAE,QAC/C,IAAK,EAAI,OAET,EAAE,iBAEF,MAAM,EAAqB,EAAG,aAAa,iBACtC,GAEL,EAAc,EAAS,CACtB,sBAAuB,KAAK,OAAO,sBACnC,SAAU,EAAQ,GAClB,OAAQ,KAAK,UAIf,MAAM,EAAyB,EAAQ,eACvC,EAAU,iBAAiB,YAAa,KAAK,0BAC7C,EAAU,iBAAiB,QAAS,KAAK,qBAC1C,CAEA,eAAA,GACC,OAAO,EAAsB,OAAQ,GAAQ,KAAK,OAAO,MAAM,SAAS,EAAI,MAC7E"}
@@ -0,0 +1,2 @@
1
+ import{r as t}from"./HTMLUtils-B0nGyFLb.mjs";import{B as e,D as n,E as o,_ as r,h as i,j as l,k as s,p as a,r as c}from"./Document-D_2cIBJG.mjs";import{c as d,d as u,f as h,i as b,n as m,u as p}from"./Selection-DC6AOGgF.mjs";import{a as f}from"./TypeBrands-Ch9856Gb.mjs";import{_ as g,s as w}from"./BlockInsertion-O5pAFKid.mjs";import{a as x,d as v,h as C,l as y,n as S,r as R,u as z}from"./TableDimensions-BcARMxQB.mjs";import{a as I,t as k}from"./Decoration-BwhoA4MU.mjs";import{n as A}from"./TypedKeys-CA4bfw9O.mjs";import{c as E,i as P,o as L}from"./PluginHelpers-WG1Lzzh3.mjs";import{t as M}from"./EditorEventBoundary-zpYRxryo.mjs";import{c as B,o as H,s as N}from"./StyleRuntime-C0RSqKzG.mjs";import{i as $}from"./Platform-ByobkiCc.mjs";import{t as T}from"./KeyboardNav-D0my3wuy.mjs";import{i as D,n as W}from"./PopupPositioning-CIqgpqlW.mjs";import{i as O}from"./ColorValidation-B9d_umnf.mjs";import{n as _,t as j}from"./ColorGrid-DAs0--ty.mjs";function F(t,e){if(0===t.rowCount||0===t.columnCount)return null;let n={fromRow:X(Math.min(e.fromRow,e.toRow),t.rowCount),fromColumn:X(Math.min(e.fromColumn,e.toColumn),t.columnCount),toRow:X(Math.max(e.fromRow,e.toRow),t.rowCount),toColumn:X(Math.max(e.fromColumn,e.toColumn),t.columnCount)};for(;;){let e=n.fromRow,o=n.fromColumn,r=n.toRow,i=n.toColumn;for(const l of t.cellsInRange(n))e=Math.min(e,l.rowStart),o=Math.min(o,l.columnStart),r=Math.max(r,l.rowEnd-1),i=Math.max(i,l.columnEnd-1);if(e===n.fromRow&&o===n.fromColumn&&r===n.toRow&&i===n.toColumn)return n;n={fromRow:e,fromColumn:o,toRow:r,toColumn:i}}}function q(t,e=1e3){return"number"==typeof t&&Number.isFinite(t)&&Number.isInteger(t)?t<=1?1:Math.min(t,e):1}function V(t){const e="table"===t.type?n(t).filter(t=>"table_row"===t.type):[],o=Array.from({length:e.length},()=>[]),r=[],i=/* @__PURE__ */new Map;let l=0;for(let s=0;s<e.length;s++){const t=e[s];if(!t)continue;const a=n(t).filter(t=>"table_cell"===t.type);let c=0;for(let n=0;n<a.length;n++){const d=a[n];if(!d)continue;const u=q(d.attrs?.colspan),h=q(d.attrs?.rowspan),b=Math.min(h,e.length-s),m=Y(o[s]??[],c,u);if(void 0===m)continue;c=m;const p=Math.min(u,1e3-c),f={cell:d,sourceRow:t,sourceRowIndex:s,sourceCellIndex:n,rowStart:s,rowEnd:s+b,columnStart:c,columnEnd:c+p,rowSpan:b,columnSpan:p};r.push(f),i.set(d.id,f);for(let t=f.rowStart;t<f.rowEnd;t++){const e=o[t];if(e)for(let t=f.columnStart;t<f.columnEnd;t++)e[t]??=f}c=f.columnEnd,l=Math.max(l,f.columnEnd)}}return{table:t,rows:e,rowCount:e.length,columnCount:l,cells:r,cellAt(t,e){if(!(!Number.isInteger(t)||!Number.isInteger(e)||t<0||e<0))return o[t]?.[e]},cellById:t=>i.get(t),cellsInRange(t){const n=Math.max(0,Math.min(t.fromRow,t.toRow)),o=Math.min(e.length-1,Math.max(t.fromRow,t.toRow)),i=Math.max(0,Math.min(t.fromColumn,t.toColumn)),s=Math.min(l-1,Math.max(t.fromColumn,t.toColumn));return o<n||s<i?[]:r.filter(t=>t.rowStart<=o&&t.rowEnd>n&&t.columnStart<=s&&t.columnEnd>i)}}}function K(t,e){const o=/* @__PURE__ */new Set,r=/* @__PURE__ */new Set;for(const b of n(e)){r.add(b.id);for(const t of n(b))o.add(t.id)}const i=V(t),l=i.cells.filter(t=>o.has(t.cell.id));if(0===l.length)return Z(e);const s=Math.min(...l.map(t=>t.columnStart)),a=Math.max(...l.map(t=>t.columnEnd))-1,c=i.rows.map((t,e)=>r.has(t.id)?e:-1).filter(t=>t>=0);if(0===c.length)return Z(e);const d=function(t,e,o,r,i,l){let s=!1;const a=n(t).map(t=>{let a=!1;const c=n(t).map(t=>{const n=e.cellById(t.id);if(!n)return t;const s=Math.min(n.rowEnd,r+1)-Math.max(n.rowStart,o),c=Math.min(n.columnEnd,l+1)-Math.max(n.columnStart,i),d=q(t.attrs?.rowspan),u=q(t.attrs?.colspan);if(s===d&&c===u)return t;a=!0;const{colspan:h,rowspan:b,...m}=t.attrs??{},p={...m,...c>1?{colspan:c}:{},...s>1?{rowspan:s}:{}},{attrs:f,...g}=t;return Object.keys(p).length>0?{...g,attrs:p}:g});return a?(s=!0,{...t,children:c}):t});return s?{...t,children:a}:t}(e,i,Math.min(...c),Math.max(...c),s,a);for(const n of c){const t=/* @__PURE__ */new Set;for(const e of l)if(!(e.rowStart>n||e.rowEnd<=n))for(let n=e.columnStart;n<e.columnEnd;n++)t.add(n);for(let e=s;e<=a;e++)if(!t.has(e))return Z(d)}const u=t.attrs?.columnWidthsPx;if(!Array.isArray(u))return d;const h=[];for(let n=s;n<=a;n++){const t=u[n];h.push("number"==typeof t&&Number.isFinite(t)?t:null)}return h.some(t=>null!==t)?{...d,attrs:{...d.attrs??{},columnWidthsPx:Object.freeze(h)}}:Z(d)}function Z(t){if(!t.attrs||!Object.hasOwn(t.attrs,"columnWidthsPx"))return t;const{columnWidthsPx:e,...n}=t.attrs,{attrs:o,...r}=t;return{...r,...Object.keys(n).length>0?{attrs:n}:{}}}function Y(t,e,n){let o=Math.max(0,e);for(;o+n<=1e3;){let e=!0;for(let r=0;r<n;r++)if(t[o+r]){e=!1,o+=r+1;break}if(e)return o}}function X(t,e){return Number.isFinite(t)?Math.min(e-1,Math.max(0,Math.trunc(t))):0}function U(){const t=a(f("paragraph"),[r("")],o());return a(f("table_cell"),[t],o())}function G(t,e){const n=t.getNodePath(e);if(!n)return null;let o=null,r=null,i=null;for(const c of n){const e=t.getBlock(c);e&&("table"===e.type?(o=c,r=e):"table_cell"===e.type&&(i=c))}if("table_cell"===t.getBlock(e)?.type&&(i=e),!o||!r||!i)return null;const l=t.doc.children.findIndex(t=>t.id===o),s=V(r),a=s.cellById(i);return a?{tableId:o,tableIndex:l,rowId:a.sourceRow.id,rowIndex:a.rowStart,rowEnd:a.rowEnd,cellId:i,colIndex:a.columnStart,colEnd:a.columnEnd,rowspan:a.rowSpan,colspan:a.columnSpan,totalRows:s.rowCount,totalCols:s.columnCount}:null}function J(t,e,n,o){const r=t.getBlock(e);return r&&"table"===r.type?V(r).cellAt(n,o)?.cell.id??null:null}function Q(t,e){const o=t.getBlock(e);if(!o)return e;const r=n(o)[0];if(!r)return e;let i=r;for(;;){const t=n(i)[0];if(!t)return i.id;i=t}}function tt(t,e){const o=t.getBlock(e);if(!o)return e;const r=n(o),i=r[r.length-1];if(!i)return e;let l=i;for(;;){const t=n(l),e=t[t.length-1];if(!e)return l.id;l=e}}function et(t,e){const n=t.getNodePath(e);if(!n)return!1;for(const o of n)if("table"===t.getBlock(o)?.type)return!0;return!1}var nt={insertRowAbove:"Insert Row Above",insertRowBelow:"Insert Row Below",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteRow:"Delete Row",deleteColumn:"Delete Column",borderColorLabel:"Border Color...",deleteTable:"Delete Table",tableActions:"Table actions",menuKeyboardHint:"↑↓ Navigate · Enter Select · Esc Close",insertRow:"Insert row",insertColumn:"Insert column",addRow:"Add row",addColumn:"Add column",tableActionsHint:"Table actions (Right-click or Shift+F10)",contextMenuHint:"Right-click or Shift+F10 for table actions",borderColor:"Border color",sizeLabel:"Size...",sizeDialogLabel:"Table size",columnWidthLabel:"Column width (px)",rowMinimumHeightLabel:"Row minimum height (px)",automatic:"Automatic",mixed:"Mixed",apply:"Apply",cancel:"Cancel",resetColumnWidth:"Reset column width",resetRowMinimumHeight:"Reset row minimum height",resetAllSizes:"Reset all sizes",invalidDimensionRange:(t,e)=>`Enter a value from ${t} to ${e} px.`,selectRowLabel:t=>`Select row ${t+1}`,selectColumnLabel:t=>`Select column ${t+1}`,resizeColumnSeparatorLabel:t=>`Resize column ${t+1}`,resizeRowSeparatorLabel:t=>`Resize row ${t+1}`,resizeKeyboardHint:(t,e)=>`Arrow keys resize by ${t} px; hold Shift for ${e} px.`,announceColumnWidthSet:(t,e)=>`Column ${t+1} width set to ${e} px.`,announceRowMinimumHeightSet:(t,e)=>`Row ${t+1} minimum height set to ${e} px.`,announceColumnWidthReset:t=>`Column ${t+1} width reset to automatic.`,announceRowMinimumHeightReset:t=>`Row ${t+1} minimum height reset to automatic.`,announceTableSizesReset:"Table column widths and row minimum heights reset to automatic.",defaultColor:"Default",noBorders:"No borders",borderColorPicker:"Border color picker",announceBorderColorSet:t=>`Table border color set to ${t}`,announceBorderReset:"Table borders reset to default",borderSwatchLabel:t=>`Border ${t}`,announceRowInsertedAbove:"Row inserted above",announceRowInsertedBelow:"Row inserted below",announceColumnInserted:t=>`Column inserted ${t}`,announceRowDeleted:"Row deleted",announceColumnDeleted:"Column deleted",announceTableDeleted:"Table deleted",insertTable:"Insert Table",tableAriaLabel:(t,e)=>`Table with ${t} rows and ${e} columns`,tableAriaDescription:"Right-click or press Shift+F10 for table actions"},ot=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-Dg9PdDet.mjs"),"./locales/de.ts":()=>import("./de-DJ5EkXQo.mjs"),"./locales/es.ts":()=>import("./es-CEAJj7aB.mjs"),"./locales/fr.ts":()=>import("./fr-DhWQzZy3.mjs"),"./locales/hi.ts":()=>import("./hi-BsZzSMfL.mjs"),"./locales/pt.ts":()=>import("./pt-BuZ7acHF.mjs"),"./locales/ru.ts":()=>import("./ru-CsP6mLxp.mjs"),"./locales/zh.ts":()=>import("./zh-CiIyOm6U.mjs")});async function rt(t){return E(ot,t,nt)}var it=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#980000","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79","#0b5394","#38761d"];function lt(t,e,n){const o=t.getBlock(e);if(!o||"table"!==o.type)return null;const r=t.getNodePath(e);if(!r)return null;if(void 0===n){const{borderColor:e,...n}=o.attrs??{},i=n;return t.transaction("command").setNodeAttr(r,i).setSelection(t.selection).build()}const i={...o.attrs,borderColor:n};return t.transaction("command").setNodeAttr(r,i).setSelection(t.selection).build()}function st(t,e,n=nt){const o=t.getState();if(!h(o.selection))return!1;const r=G(o,o.selection.anchor.blockId);if(!r)return!1;const i=lt(o,r.tableId,e);if(!i)return!1;t.dispatch(i);const l="none"===e?"none":_(e);return t.announce(n.announceBorderColorSet(l)),!0}function at(t,e=nt){const n=t.getState();if(!h(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=lt(n,o.tableId,void 0);return!!r&&(t.dispatch(r),t.announce(e.announceBorderReset),!0)}function ct(t,e){const n=t.getBlock(e);if(n)return n.attrs?.borderColor}function dt(t,e,n,o,r=nt){t.classList.add("notectl-color-picker");const i=ct(e.getState(),n),l=document.createElement("button");l.type="button",l.className="notectl-color-picker__default",l.textContent=r.defaultColor,l.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),l.addEventListener("click",()=>{at(e,r),o()}),l.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),o())}),t.appendChild(l);const s=document.createElement("button");s.type="button",s.className="notectl-color-picker__default",s.textContent=r.noBorders,s.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),s.addEventListener("click",()=>{st(e,"none",r),o()}),s.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),o())}),t.appendChild(s),j(t,{colors:it,columns:5,ariaLabel:r.borderColorPicker,ariaLabelPrefix:"",activeColor:i??null,swatchLabel:r.borderSwatchLabel,titleAsName:!0,onSelect:t=>{st(e,t,r),o()},onClose:o})}function ut(t,e,n){const o=t.clipboardData,r=n.getSelectedRange();if(!o||!r)return!1;const i=e.getState().getBlock(r.tableId);if(!i||"table"!==i.type)return!1;const l=function(t,e){const n=V(t);if(0===n.rowCount||0===n.columnCount)return null;const o=F(n,e);if(!o)return null;const{fromRow:r,fromColumn:i,toRow:l,toColumn:s}=o,a=n.cellsInRange({fromRow:r,fromColumn:i,toRow:l,toColumn:s}),c=[],d=0===i&&s===n.columnCount-1;for(let y=r;y<=l;y++){const t=n.rows[y];if(!t)continue;const e=a.filter(t=>Math.max(t.rowStart,r)===y).sort((t,e)=>Math.max(t.columnStart,i)-Math.max(e.columnStart,i)).map(t=>{const e=Math.min(t.rowEnd,l+1)-Math.max(t.rowStart,r),n=Math.min(t.columnEnd,s+1)-Math.max(t.columnStart,i),{colspan:o,rowspan:a,...c}=t.cell.attrs??{},d={...c,...n>1?{colspan:n}:{},...e>1?{rowspan:e}:{}},{attrs:u,...h}=t.cell;return Object.keys(d).length>0?{...h,attrs:d}:h}),{htmlId:o,...u}=t;c.push({...d?t:u,children:e})}const{columnWidthsPx:u,...h}=t.attrs??{},b=t.attrs?.columnWidthsPx,m=[];if(Array.isArray(b))for(let y=i;y<=s;y++){const t=b[y];m.push("number"==typeof t&&Number.isFinite(t)?t:null)}const p={...h,...m.some(t=>null!==t)?{columnWidthsPx:Object.freeze(m)}:{}},f=d&&0===r&&l===n.rowCount-1,{attrs:g,...w}=t,{htmlId:x,...v}=w,C=f?w:v;return Object.keys(p).length>0?{...C,children:c,attrs:p}:{...C,children:c}}(i,{fromRow:r.fromRow,fromColumn:r.fromCol,toRow:r.toRow,toColumn:r.toCol});return!!l&&(t.preventDefault(),t.stopImmediatePropagation(),o.setData("text/html",C({children:[l]},e.getSchemaRegistry())),o.setData("text/plain",function(t){const e=V(t);return Array.from({length:e.rowCount},(t,n)=>Array.from({length:e.columnCount},(t,o)=>{const r=e.cellAt(n,o);return r&&r.rowStart===n&&r.columnStart===o?ht(r.cell):""}).join("\t")).join("\n")}(l)),!0)}function ht(t){return e(t)?l(t):n(t).map(ht).join("\n")}var bt=new A("tableSelection");function mt(t){return JSON.stringify({rows:t.rows.map(t=>t.id),cells:t.cells.map(t=>[t.cell.id,t.rowStart,t.rowEnd,t.columnStart,t.columnEnd])})}function pt(t,e){return{tableId:t.tableId,fromRow:Math.min(t.rowStart,e.rowIndex),fromCol:Math.min(t.colStart,e.colIndex),toRow:Math.max(t.rowEnd,e.rowEnd)-1,toCol:Math.max(t.colEnd,e.colEnd)-1}}var ft=Object.freeze({minColumnWidthPx:60,minRowHeightPx:24,maxColumnWidthPx:z,maxRowHeightPx:z,keyboardResizeStepPx:8,keyboardResizeLargeStepPx:32}),gt=new A("tableSizing");function wt(t){const e=Bt(t.minColumnWidthPx,ft.minColumnWidthPx),n=Bt(t.minRowHeightPx,ft.minRowHeightPx);return{minColumnWidthPx:e,minRowHeightPx:n,maxColumnWidthPx:Bt(t.maxColumnWidthPx,ft.maxColumnWidthPx,e),maxRowHeightPx:Bt(t.maxRowHeightPx,ft.maxRowHeightPx,n),keyboardResizeStepPx:Bt(t.keyboardResizeStepPx,ft.keyboardResizeStepPx),keyboardResizeLargeStepPx:Bt(t.keyboardResizeLargeStepPx,ft.keyboardResizeLargeStepPx)}}function xt(t,e){const n=Math.max(0,Math.trunc(e)),o=t.attrs?.columnWidthsPx,r=Array.isArray(o)?o:[];return Object.freeze(Array.from({length:n},(t,e)=>{const n=r[e];return null==n?null:Mt(n)}))}function vt(t,e){const n=Object.freeze(e.map(t=>null===t?null:Mt(t))),{columnWidthsPx:o,...r}=t??{};return n.some(t=>null!==t)?{...r,columnWidthsPx:n}:r}function Ct(t){return Mt(t.attrs?.minHeightPx)}function yt(t,e){const{minHeightPx:n,...o}=t??{};if(null===e)return o;const r=Mt(e);return null===r?o:{...o,minHeightPx:r}}function St(t){const e=t.getState(),n=t.getService(bt)?.getSelectedRange()??null;if(n)return zt(e,n.tableId,n,!0);if(!h(e.selection))return null;const o=G(e,e.selection.anchor.blockId);return o?zt(e,o.tableId,{tableId:o.tableId,fromRow:o.rowIndex,fromCol:o.colIndex,toRow:o.rowEnd-1,toCol:o.colEnd-1},!0):null}function Rt(t,e){const n=t.getBlock(e.tableId);if(!n||"table"!==n.type)return null;const o=V(n);switch(e.kind){case"cell":{if(!Ht(e.row,o.rowCount))return null;if(!Ht(e.column,o.columnCount))return null;const r=o.cellAt(e.row,e.column);return r?It(t,n,o,r.rowStart,r.rowEnd-1,r.columnStart,r.columnEnd-1):null}case"range":return zt(t,e.tableId,{tableId:e.tableId,fromRow:e.fromRow,fromCol:e.fromColumn,toRow:e.toRow,toCol:e.toColumn},!0);case"column":return Ht(e.column,o.columnCount)?{state:t,table:n,grid:o,columns:[e.column],rows:[]}:null;case"row":return Ht(e.row,o.rowCount)?{state:t,table:n,grid:o,columns:[],rows:[e.row]}:null}}function zt(t,e,n,o){const r=t.getBlock(e);if(!r||"table"!==r.type)return null;const i=V(r);if(0===i.rowCount||0===i.columnCount)return null;if(![n.fromRow,n.toRow,n.fromCol,n.toCol].every(Number.isInteger))return null;if(o&&(!Ht(n.fromRow,i.rowCount)||!Ht(n.toRow,i.rowCount)||!Ht(n.fromCol,i.columnCount)||!Ht(n.toCol,i.columnCount)))return null;const l=Nt(Math.min(n.fromRow,n.toRow),i.rowCount),s=Nt(Math.max(n.fromRow,n.toRow),i.rowCount),a=F(i,{fromRow:l,fromColumn:Nt(Math.min(n.fromCol,n.toCol),i.columnCount),toRow:s,toColumn:Nt(Math.max(n.fromCol,n.toCol),i.columnCount)});return a?It(t,r,i,a.fromRow,a.toRow,a.fromColumn,a.toColumn):null}function It(t,e,n,o,r,i,l){return{state:t,table:e,grid:n,rows:$t(o,r),columns:$t(i,l)}}function kt(t){const e=xt(t.table,t.grid.columnCount),n=t.columns.map(t=>e[t]??null),o=t.rows.map(e=>{const n=t.grid.rows[e];return n?Ct(n):null});return{columnWidthPx:Lt(n),rowMinHeightPx:Lt(o)}}function At(t,e,n,o){const r=Object.prototype.hasOwnProperty.call(n,"columnWidthPx"),i=Object.prototype.hasOwnProperty.call(n,"rowMinHeightPx");if(!r&&!i)return!1;if(r&&0===e.columns.length)return!1;if(i&&0===e.rows.length)return!1;const l=r?Pt(n.columnWidthPx,o.minColumnWidthPx,o.maxColumnWidthPx):null,s=i?Pt(n.rowMinHeightPx,o.minRowHeightPx,o.maxRowHeightPx):null;if(r&&!l||i&&!s)return!1;const a=e.state.transaction("command");let c=!1;if(l){const t=[...xt(e.table,e.grid.columnCount)];for(const n of e.columns)t[n]!==l.value&&(t[n]=l.value,c=!0);if(c){const n=e.state.getNodePath(e.table.id);if(!n)return!1;a.setNodeAttr(n,vt(e.table.attrs,t))}}if(s)for(const d of e.rows){const t=e.grid.rows[d];if(!t||Ct(t)===s.value)continue;const n=e.state.getNodePath(t.id);if(!n)return!1;a.setNodeAttr(n,yt(t.attrs,s.value)),c=!0}return!!c&&(a.setSelection(e.state.selection),t.dispatch(a.build()),!0)}function Et(t,e,n,o){return At(t,e,"columnWidthPx"===n?{columnWidthPx:"auto"}:"rowMinHeightPx"===n?{rowMinHeightPx:"auto"}:{...e.columns.length>0?{columnWidthPx:"auto"}:{},...e.rows.length>0?{rowMinHeightPx:"auto"}:{}},o)}function Pt(t,e,n){if("auto"===t)return{value:null};const o=v(t,e,n);return null===o?null:{value:o}}function Lt(t){if(0===t.length)return"unavailable";const e=t[0];return t.some(t=>t!==e)?"mixed":null==e?"auto":e}function Mt(t){return"number"!=typeof t||t<1||t>1e4?null:v(t)}function Bt(t,e,n=1){return v(t??e,n,1e4)??e}function Ht(t,e){return Number.isInteger(t)&&t>=0&&t<e}function Nt(t,e){return Math.min(e-1,Math.max(0,t))}function $t(t,e){return Array.from({length:e-t+1},(e,n)=>t+n)}function Tt(t,e,o){const r=t.getBlock(e);if(!r||"table"!==r.type)return null;const i=V(r);if(!Vt(o,i.rowCount)||0===i.columnCount)return null;const l=i.cells.filter(t=>t.rowStart<o&&t.rowEnd>o),s=t.transaction("command");for(const n of l)if(!Zt(t,s,n.cell,"rowspan",n.rowSpan+1))return null;const c=[];for(let n=0;n<i.columnCount;n++)l.some(t=>t.columnStart<=n&&t.columnEnd>n)||c.push(U());const d=a(f("table_row"),c),u=function(t,e,n){if(n>=e.rowCount)return t.children.length;const o=e.rows[n];if(!o)return t.children.length;const r=t.children.findIndex(t=>"id"in t&&t.id===o.id);return-1===r?t.children.length:r}(r,i,o);s.insertNode([e],u,d);const h=n(d)[0],b=h?n(h)[0]:void 0;return b?s.setSelection(m(b.id,0)):h&&s.setSelection(m(h.id,0)),s.build()}function Dt(t,e,o){const r=t.getBlock(e);if(!r||"table"!==r.type)return null;const i=V(r);if(!Vt(o,i.columnCount)||0===i.rowCount)return null;const l=t.transaction("command");if(Yt(r)){const n=[...xt(r,i.columnCount)];n.splice(o,0,null);const s=t.getNodePath(e);if(!s)return null;l.setNodeAttr(s,vt(r.attrs,n))}const s=i.cells.filter(t=>t.columnStart<o&&t.columnEnd>o);for(const n of s)if(!Zt(t,l,n.cell,"colspan",n.columnSpan+1))return null;let a;for(let n=0;n<i.rowCount;n++){const t=i.rows[n];if(!t)continue;if(s.some(t=>t.rowStart<=n&&t.rowEnd>n))continue;const r=U();a??=r;const c=i.cells.filter(e=>e.sourceRow.id===t.id&&e.columnEnd<=o).length;l.insertNode([e,t.id],c,r)}const c=a?n(a)[0]:void 0;return l.setSelection(c?m(c.id,0):t.selection),l.build()}function Wt(t,e,n,o=0){const r=t.getBlock(e);if(!r||"table"!==r.type)return null;const i=V(r);if(!Kt(n,i.rowCount))return null;if(i.rowCount<=1)return _t(t,e);const l=t.transaction("command"),s=i.cells.filter(t=>t.rowStart<=n&&t.rowEnd>n),a=s.filter(t=>t.rowStart===n&&t.rowSpan>1).sort((t,e)=>t.columnStart-e.columnStart);for(const u of s)if(!(u.rowSpan<=1||Zt(t,l,u.cell,"rowspan",u.rowSpan-1)))return null;if(a.length>0){const t=i.rows[n+1];if(!t)return null;const o=i.cells.filter(e=>e.sourceRow.id===t.id);let r=0;for(const n of a){const i=o.filter(t=>t.columnStart<n.columnStart).length+r;l.moveNode([e,n.sourceRow.id],n.sourceCellIndex-r,[e,t.id],i),r++}}const c=function(t,e,n){const o=e.rows[n];return o?t.children.findIndex(t=>"id"in t&&t.id===o.id):-1}(r,i,n);if(c<0)return null;l.removeNode([e],c);const d=J(t,e,n>0?n-1:1,Math.min(Math.max(0,o),i.columnCount-1));if(d){const e=Q(t,d);l.setSelection(m(e,0))}return l.build()}function Ot(t,e,n,o=0){const r=t.getBlock(e);if(!r||"table"!==r.type)return null;const i=V(r);if(!Kt(n,i.columnCount))return null;if(i.columnCount<=1)return _t(t,e);const l=t.transaction("command");if(Yt(r)){const o=[...xt(r,i.columnCount)];o.splice(n,1);const s=t.getNodePath(e);if(!s)return null;l.setNodeAttr(s,vt(r.attrs,o))}const s=i.cells.filter(t=>t.columnStart<=n&&t.columnEnd>n);for(const d of s)if(!(d.columnSpan<=1||Zt(t,l,d.cell,"colspan",d.columnSpan-1)))return null;for(const d of s.filter(t=>1===t.columnSpan).sort((t,e)=>t.sourceRowIndex!==e.sourceRowIndex?e.sourceRowIndex-t.sourceRowIndex:e.sourceCellIndex-t.sourceCellIndex))l.removeNode([e,d.sourceRow.id],d.sourceCellIndex);const a=n>0?n-1:1,c=J(t,e,Math.min(Math.max(0,o),i.rowCount-1),a);if(c){const e=Q(t,c);l.setSelection(m(e,0))}return l.build()}function _t(t,e){const n=t.doc.children.findIndex(t=>t.id===e);if(-1===n)return null;if(1===t.doc.children.length){const e=i(o());return t.transaction("command").insertNode([],0,e).removeNode([],1).setSelection(m(e.id,0)).build()}const r=t.transaction("command").removeNode([],n),l=t.doc.children[n+1];if(l){const e=g(t,l.id,"start");if(e)return r.setSelection(e),r.build()}const s=t.doc.children[n-1];if(s){const e=g(t,s.id,"end");if(e)return r.setSelection(e),r.build()}return null}function jt(t,e,r){const i=t.getState(),l=P(i);if(!l)return!1;const s=function(t,e){const n=o(),r=[];for(let i=0;i<t;i++){const t=[];for(let n=0;n<e;n++)t.push(U());r.push(a(f("table_row"),t,o()))}return a(f("table"),r,n)}(e,r),c=i.transaction("command");if(!w(i,c,l,s))return!1;const d=n(s)[0],u=d?n(d)[0]:void 0,h=u?n(u)[0]:void 0;return h?c.setSelection(m(h.id,0)):u&&c.setSelection(m(u.id,0)),t.dispatch(c.build()),!0}function Ft(t,e){const n=t.getState();if(!h(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=Tt(n,o.tableId,o.rowEnd);return!!r&&(t.dispatch(r),t.announce(e.announceRowInsertedBelow),!0)}function qt(t,e,n){const o=t.getState();if(!h(o.selection))return!1;const r=G(o,o.selection.anchor.blockId);if(!r)return!1;const i="left"===e?r.colIndex:r.colEnd,l=Dt(o,r.tableId,i);return!!l&&(t.dispatch(l),t.announce(n.announceColumnInserted(e)),!0)}function Vt(t,e){return Number.isInteger(t)&&t>=0&&t<=e}function Kt(t,e){return Number.isInteger(t)&&t>=0&&t<e}function Zt(t,e,n,o,r){const i=t.getNodePath(n.id);return!!i&&(e.setNodeAttr(i,function(t,e,n){const o={...t.attrs??{}};return delete o[e],n>1&&(o[e]=n),{...t,attrs:o}}(n,o,r).attrs??{}),!0)}function Yt(t){return Object.prototype.hasOwnProperty.call(t.attrs??{},"columnWidthsPx")}function Xt(t,e){t.registerCommand("insertTable",()=>jt(t,3,3)),t.registerCommand("addRowAbove",()=>function(t,e){const n=t.getState();if(!h(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=Tt(n,o.tableId,o.rowIndex);return!!r&&(t.dispatch(r),t.announce(e.announceRowInsertedAbove),!0)}(t,e)),t.registerCommand("addRowBelow",()=>Ft(t,e)),t.registerCommand("addColumnLeft",()=>function(t,e){return qt(t,"left",e)}(t,e)),t.registerCommand("addColumnRight",()=>function(t,e){return qt(t,"right",e)}(t,e)),t.registerCommand("deleteRow",()=>function(t,e){const n=t.getState();if(!h(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=Wt(n,o.tableId,o.rowIndex,o.colIndex);return!!r&&(t.dispatch(r),t.announce(e.announceRowDeleted),!0)}(t,e)),t.registerCommand("deleteColumn",()=>function(t,e){const n=t.getState();if(!h(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=Ot(n,o.tableId,o.colIndex,o.rowIndex);return!!r&&(t.dispatch(r),t.announce(e.announceColumnDeleted),!0)}(t,e)),t.registerCommand("selectTable",()=>function(t){const e=t.getState(),n=e.selection;if(u(n))return"table"===e.getBlock(n.nodeId)?.type;if(p(n))return!1;const o=G(e,n.anchor.blockId);if(!o)return!1;const r=e.getNodePath(o.tableId);if(!r)return!1;const i=e.transaction("command").setSelection(b(o.tableId,r)).build();return t.dispatch(i),!0}(t)),t.registerCommand("deleteTable",()=>function(t,e){const n=t.getState(),o=function(t){if(u(t.selection)){const e=t.getBlock(t.selection.nodeId);return"table"!==e?.type?null:{tableId:e.id}}if(p(t.selection))return null;const e=G(t,t.selection.anchor.blockId);return e?{tableId:e.tableId}:null}(n);if(!o)return!1;const r=_t(n,o.tableId);return!!r&&(t.dispatch(r),t.announce(e.announceTableDeleted),!0)}(t,e))}function Ut(t,e,n,o,r,i,l){const s=document.createElement("div");s.className="notectl-table-size-editor__field";const a=document.createElement("label");a.htmlFor=`notectl-table-size-${e}`,a.textContent=n;const c=document.createElement("div");c.className="notectl-table-size-editor__input-wrap";const d=document.createElement("input");d.id=a.htmlFor,d.type="number",d.inputMode="decimal",d.step="1",d.min=String(r),d.max=String(i),d.setAttribute("aria-describedby",`${d.id}-error`);const u=document.createElement("span");u.className="notectl-table-size-editor__unit",u.textContent="px",u.setAttribute("aria-hidden","true"),c.append(d,u);const h=document.createElement("div");h.id=`${d.id}-error`,h.className="notectl-table-size-editor__error",h.setAttribute("role","alert"),s.append(a,c,h),t.appendChild(s);const b={input:d,error:h,minimum:r,maximum:i,dirty:!1};return Gt(b,o,l),b}function Gt(t,e,n){t.input.disabled="unavailable"===e,t.input.value="number"==typeof e?String(e):"",t.input.placeholder="mixed"===e?n.mixed:n.automatic,t.dirty=!1,Qt(t)}function Jt(t,e){const n=t.input.value.trim(),o=Number(n);if(0===n.length||!Number.isFinite(o))return t.error.textContent=e.invalidDimensionRange(t.minimum,t.maximum),t.input.setAttribute("aria-invalid","true"),t.input.focus(),null;const r=Math.min(t.maximum,Math.max(t.minimum,o));return t.input.value=String(r),r}function Qt(t){t.error.textContent="",t.input.removeAttribute("aria-invalid")}function te(t,e=""){const n=document.createElement("button");return n.type="button",n.textContent=t,n.className=e,n}function ee(t,e,n){return e?t.resetSize(e,n):t.resetSelectionSize(n)}function ne(t,e,n,o){"columnWidthPx"!==n?"row"===e?.kind||"cell"===e?.kind?t.announce(o.announceRowMinimumHeightReset(e.row)):t.announce(o.resetRowMinimumHeight):"column"===e?.kind||"cell"===e?.kind?t.announce(o.announceColumnWidthReset(e.column)):t.announce(o.resetColumnWidth)}var oe=/* @__PURE__ */new WeakMap;function re(t){for(const e of[...oe.get(t)??[]])e()}function ie(t,e,n,o,r,i=nt,l,s={}){let a=!0,c=null,d=null;const u=document.createElement("div");u.className="notectl-table-context-menu",u.setAttribute("role","menu"),u.setAttribute("aria-label",i.tableActions),u.setAttribute("contenteditable","false"),u.setAttribute("data-notectl-no-print","");const h=[];let b=0;const m=function(t){return[{type:"item",label:t.insertRowAbove,command:"addRowAbove"},{type:"item",label:t.insertRowBelow,command:"addRowBelow"},{type:"separator"},{type:"item",label:t.insertColumnLeft,command:"addColumnLeft"},{type:"item",label:t.insertColumnRight,command:"addColumnRight"},{type:"separator"},{type:"item",label:t.deleteRow,command:"deleteRow"},{type:"item",label:t.deleteColumn,command:"deleteColumn"},{type:"separator"},{type:"submenu",label:t.borderColorLabel,id:"borderColor"},{type:"submenu",label:t.sizeLabel,id:"size"},{type:"separator"},{type:"item",label:t.deleteTable,command:"deleteTable"}]}(i);for(const z of m){if("separator"===z.type){const t=document.createElement("div");t.setAttribute("role","separator"),u.appendChild(t);continue}const t=document.createElement("button");t.type="button",t.setAttribute("role","menuitem"),t.textContent=z.label,"submenu"===z.type&&(t.dataset.submenu=z.id,t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded","false")),"item"===z.type&&(t.dataset.command=z.command),t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),t.addEventListener("click",n=>{n.stopPropagation(),"item"===z.type?(e.executeCommand(z.command),S()):"submenu"===z.type&&f(t)}),h.push(t),u.appendChild(t)}const p=document.createElement("div");function f(e){if(w(),e.setAttribute("aria-expanded","true"),l)d=l.open({anchor:e,position:"right",referenceNode:u,parent:{close:()=>S(),getElement:()=>u},onClose:()=>{d=null,c=null,x()},content:(t,n)=>{t.className="notectl-table-context-menu",t.setAttribute("contenteditable","false"),t.setAttribute("data-notectl-no-print",""),c=t,t.addEventListener("keydown",t=>{if(t.stopPropagation(),t.target instanceof HTMLInputElement)return;const o="rtl"===getComputedStyle(u).direction?"ArrowRight":"ArrowLeft";t.key===o&&(t.preventDefault(),n(),e.focus())}),g(t,e)}});else{c=document.createElement("div"),c.className="notectl-table-context-menu",c.setAttribute("contenteditable","false"),c.setAttribute("data-notectl-no-print",""),c.addEventListener("keydown",t=>{if(t.stopPropagation(),t.target instanceof HTMLInputElement)return;const n="rtl"===getComputedStyle(u).direction?"ArrowRight":"ArrowLeft";t.key===n&&(t.preventDefault(),w(),e.focus())}),g(c,e),t.appendChild(c);const n=u.getBoundingClientRect(),o="rtl"===getComputedStyle(u).direction;D(c,n,{position:"right",isRtl:o}),"size"!==e.dataset.submenu&&requestAnimationFrame(()=>{(c?.querySelector("button"))?.focus()})}}function g(t,o){"size"!==o.dataset.submenu?dt(t,e,n,S,i):function(t,e,n,o=nt){const r=e.getService?.(gt),i=wt(n.config??{}),l=r?function(t,e){return e?t.getSize(e):t.getSelectionSize()}(r,n.target):null;t.classList.add("notectl-table-size-editor"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",o.sizeDialogLabel);const s=document.createElement("div");s.className="notectl-table-size-editor__title",s.textContent=o.sizeDialogLabel,t.appendChild(s);const a=Ut(t,"column-width",o.columnWidthLabel,l?.columnWidthPx??"unavailable",i.minColumnWidthPx,i.maxColumnWidthPx,o),c=Ut(t,"row-min-height",o.rowMinimumHeightLabel,l?.rowMinHeightPx??"unavailable",i.minRowHeightPx,i.maxRowHeightPx,o),d=document.createElement("div");d.className="notectl-table-size-editor__resets";const u=te(o.resetColumnWidth,"notectl-table-size-editor__reset"),h=te(o.resetRowMinimumHeight,"notectl-table-size-editor__reset"),b=te(o.resetAllSizes,"notectl-table-size-editor__reset notectl-table-size-editor__reset--all");u.disabled=a.input.disabled,h.disabled=c.input.disabled,b.disabled=a.input.disabled&&c.input.disabled,d.append(u,h,b),t.appendChild(d);const m=document.createElement("div");m.className="notectl-table-size-editor__actions";const p=te(o.cancel),f=te(o.apply,"notectl-table-size-editor__apply");f.disabled=!r||!!e.isReadOnly?.(),m.append(p,f),t.appendChild(m),a.input.addEventListener("input",()=>{a.dirty=!0,Qt(a)}),c.input.addEventListener("input",()=>{c.dirty=!0,Qt(c)}),f.addEventListener("click",()=>{if(!r||e.isReadOnly?.())return;const t={};let i=!0;if(a.dirty){const e=Jt(a,o);null===e?i=!1:t.columnWidthPx=e}if(c.dirty){const e=Jt(c,o);null===e?i=!1:t.rowMinHeightPx=e}i&&(a.dirty||c.dirty?function(t,e,n){return e?t.setSize(e,n):t.setSelectionSize(n)}(r,n.target,t)&&(function(t,e,n,o){const r=[];"number"==typeof n.columnWidthPx&&("column"===e?.kind||"cell"===e?.kind?r.push(o.announceColumnWidthSet(e.column,n.columnWidthPx)):r.push(`${o.columnWidthLabel}: ${String(n.columnWidthPx)}`)),"number"==typeof n.rowMinHeightPx&&("row"===e?.kind||"cell"===e?.kind?r.push(o.announceRowMinimumHeightSet(e.row,n.rowMinHeightPx)):r.push(`${o.rowMinimumHeightLabel}: ${String(n.rowMinHeightPx)}`)),r.length>0&&t.announce(r.join(" "))}(e,n.target,t,o),n.onClose()):n.onClose())}),p.addEventListener("click",n.onClose),u.addEventListener("click",()=>{r&&ee(r,n.target,"columnWidthPx")&&(Gt(a,"auto",o),ne(e,n.target,"columnWidthPx",o))}),h.addEventListener("click",()=>{r&&ee(r,n.target,"rowMinHeightPx")&&(Gt(c,"auto",o),ne(e,n.target,"rowMinHeightPx",o))}),b.addEventListener("click",()=>{r&&ee(r,n.target)&&(a.input.disabled||Gt(a,"auto",o),c.input.disabled||Gt(c,"auto",o),e.announce(o.announceTableSizesReset))}),t.addEventListener("keydown",e=>{if("Escape"===e.key)return e.preventDefault(),e.stopPropagation(),void n.onClose();"Tab"===e.key&&function(t,e){const n=function(t){return Array.from(t.querySelectorAll("input, button")).filter(t=>!t.disabled)}(t),o=n[0],r=n[n.length-1];if(!o||!r)return;const i=function(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement:document.activeElement}(t),l=e.shiftKey&&(i===o||!t.contains(i)),s=!(e.shiftKey||i!==r&&t.contains(i));(l||s)&&(e.preventDefault(),(l?r:o).focus())}(t,e)}),requestAnimationFrame(()=>{([a.input,c.input].find(t=>!t.disabled)??p).focus()})}(t,e,{target:s.sizeTarget,config:s.sizingConfig,onClose:S},i)}function w(){d?(d.close(),d=null,c=null):c&&(c.remove(),c=null),x()}function x(){for(const t of h)t.dataset.submenu&&t.setAttribute("aria-expanded","false")}p.className="notectl-table-context-menu__hint",p.setAttribute("aria-hidden","true"),p.textContent=i.menuKeyboardHint,u.appendChild(p),T(h,b),u.addEventListener("keydown",t=>{switch(t.stopPropagation(),t.key){case"Escape":return t.preventDefault(),void S();case"ArrowDown":return t.preventDefault(),b=(b+1)%h.length,T(h,b),void h[b]?.focus();case"ArrowUp":return t.preventDefault(),b=(b-1+h.length)%h.length,T(h,b),void h[b]?.focus();case"ArrowRight":case"ArrowLeft":{t.preventDefault();const e="rtl"===getComputedStyle(u).direction?"ArrowLeft":"ArrowRight";if(t.key===e){const t=h[b];t?.dataset.submenu&&f(t)}else w(),h[b]?.focus();return}case"Enter":case" ":{t.preventDefault();const n=h[b];if(!n)return;return void(n.dataset.submenu?f(n):n.dataset.command&&(e.executeCommand(n.dataset.command),S()))}case"Home":return t.preventDefault(),b=0,T(h,b),void h[b]?.focus();case"End":return t.preventDefault(),b=h.length-1,T(h,b),void h[b]?.focus()}}),t.appendChild(u),D(u,o,{position:"below-start",isRtl:$(t)}),h[0]?.focus(),requestAnimationFrame(()=>{a&&h[0]&&h[0].focus()});const v=t=>{const e=t.composedPath();e.includes(u)||c&&e.includes(c)||S()};let C=null,y=!1;function S(){if(!a)return;a=!1,w(),u.remove(),null!==C&&(clearTimeout(C),C=null),y&&(document.removeEventListener("mousedown",v,!0),y=!1),oe.get(e)?.delete(S),r?.();const t=s.restoreFocusTo;t?.isConnected&&requestAnimationFrame(()=>t.focus({preventScroll:!0}))}C=setTimeout(()=>{C=null,document.addEventListener("mousedown",v,!0),y=!0},0);const R=oe.get(e)??/* @__PURE__ */new Set;return R.add(S),oe.set(e,R),{isOpen:()=>a,close:S,destroy:S}}var le=/* @__PURE__ */new WeakMap;function se(t,e){const n=t.getState();if(!h(n.selection))return!1;const o=n.selection,r=G(n,o.anchor.blockId);return!!r&&e(n,o,r)}function ae(t){return se(t,(e,n,o)=>{const r=o.tableIndex+1;if(r>=e.doc.children.length)return!1;const i=e.doc.children[r];if(!i)return!1;const l=e.transaction("command").setSelection(m(i.id,0)).build();return t.dispatch(l),!0})}function ce(t,e){if((t.getService?.(bt)?.getSelectedRange())?.tableId!==e.tableId)return{kind:"cell",tableId:e.tableId,row:e.rowIndex,column:e.colIndex}}function de(t,e,n,o){const r=t.getState().getBlock(e.tableId);if(!r||"table"!==r.type)return!1;const i=V(r).cells,l=i[i.findIndex(t=>t.cell.id===e.cellId)+n];return!!l&&(o?function(t,e,n,o){const r=t.getState(),i=J(r,e,n,o);if(!i)return!1;const l=tt(r,i),a=r.getBlock(l);if(!a)return!1;const c=s(a),d=r.transaction("command").setSelection(m(l,c)).build();return t.dispatch(d),!0}(t,e.tableId,l.rowStart,l.columnStart):ue(t,e.tableId,l.rowStart,l.columnStart))}function ue(t,e,n,o){const r=t.getState(),i=J(r,e,n,o);if(!i)return!1;const l=Q(r,i),s=r.transaction("command").setSelection(m(l,0)).build();return t.dispatch(s),!0}function he(t,e){const n=t.getState(),o=n.getNodePath(e);if(!o)return!1;const r=n.transaction("input").setSelection(b(e,o)).build();return t.dispatch(r),!0}var be='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 1v10M1 6h10" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';function me(t,e,n){const o=document.createElement("button");return o.className=t,o.innerHTML=e,o.title=n,o.type="button",o.setAttribute("aria-label",n),o.setAttribute("contenteditable","false"),o.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),o}function pe(t,e){const n=document.createElement("div");n.className=`ntbl-insert-line ntbl-insert-line--${t}`,n.setAttribute("contenteditable","false"),n.setAttribute("data-notectl-no-print","");const o=me("ntbl-insert-btn",be,e);return n.appendChild(o),n}function fe(t,e){const n=document.createElement("button");n.className=`ntbl-add-zone ${t}`,n.type="button",n.setAttribute("contenteditable","false"),n.setAttribute("aria-label",e),n.setAttribute("data-notectl-no-print",""),n.title=e;const o=document.createElement("span");return o.className="ntbl-add-icon",o.innerHTML=be,n.appendChild(o),n.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),n}function ge(t){const e=document.createElement("div");return e.className=t,e.setAttribute("contenteditable","false"),e.setAttribute("data-notectl-no-print",""),e}function we(t,e,n,o){const r=document.createElement("button");return r.type="button",r.className=`ntbl-resize-separator ntbl-resize-separator--${t}`,r.dataset.kind=t,r.dataset.index=String(e),r.setAttribute("role","separator"),r.setAttribute("aria-orientation","column"===t?"vertical":"horizontal"),r.setAttribute("aria-label",n),r.setAttribute("contenteditable","false"),r.setAttribute("data-notectl-no-print",""),r.title=`${n}. ${o}`,r}function xe(t,e){N(t,"none"===e?{backgroundColor:"transparent",border:"1px dashed rgba(128,128,128,0.4)"}:e?{backgroundColor:e,border:"1px solid rgba(0,0,0,0.15)"}:{backgroundColor:"var(--notectl-border)",border:"1px solid rgba(0,0,0,0.15)"})}function ve(t,e,n,o,r){const i=document.createElement("div");if(i.className=`ntbl-handle ${t}`,i.dataset.index=String(e),r){const t=me("ntbl-handle-select","",r.label);t.setAttribute("aria-pressed",r.selected?"true":"false"),t.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),r.onSelect(e)}),i.appendChild(t)}const l=me("ntbl-handle-delete",'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',n);return l.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),o(e)}),i.appendChild(l),i}function Ce(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return{top:n.top-o.top+e.scrollTop,left:n.left-o.left+e.scrollLeft}}function ye(t,e=0){const n=t.getBoundingClientRect(),o=Array.from(t.querySelectorAll(":scope > colgroup > col"));if(o.length>0){const t=o.map((t,e)=>{const o=t.getBoundingClientRect();return{index:e,position:o.left-n.left,width:o.width}});if(t.every(t=>t.width>0))return t}const r=o.length||e,i=n.width||t.offsetWidth;if(r<=0||i<=0)return[];const l=i/r;return Array.from({length:r},(t,e)=>({index:e,position:l*e,width:l}))}var Se={...ft,directResize:!0},Re=class{tableId;numRows;numCols;currentNode;readOnly=!1;activeRowIndex=-1;activeColIndex=-1;resizeSession=null;colBar;rowBar;colResizeBar;rowResizeBar;resizeIndicator;insertLineH;insertLineV;addRowZone;addColZone;deleteTableBtn;borderColorBtn;actionsBtn;contextHint;observer;wrapperEl;borderColorPopup=null;activeContextMenu=null;container;tableEl;getState;dispatchFn;pluginContext;locale;config;onWrapperScroll=()=>this.positionControls();onPointerMove=t=>this.moveResize(t);onPointerUp=t=>this.finishResize(t);onPointerCancel=t=>this.cancelResize(t);onDocumentKeyDown=t=>{"Escape"===t.key&&this.resizeSession&&(t.preventDefault(),t.stopPropagation(),this.cancelActiveResize())};onMouseMove=t=>{if(this.readOnly||this.resizeSession)return;const e=this.tableEl.getBoundingClientRect(),n=t.clientX-e.left,o=t.clientY-e.top;if(!(n>=-10&&n<=e.width+10&&o>=-10&&o<=e.height+10))return void this.hideInsertLines();const r=function(t,e,n,o){let r=Number.POSITIVE_INFINITY,i=null;for(const a of n){const t=Math.abs(e-a.position);t<r&&t<10&&(r=t,i=a)}let l=Number.POSITIVE_INFINITY,s=null;for(const a of o){const e=Math.abs(t-a.position);e<l&&e<10&&(l=e,s=a)}return i&&(!s||r<=l)?{type:"row",border:i}:s?{type:"col",border:s}:{type:"none",border:null}}(n,o,function(t){const e=t.querySelectorAll(":scope > tbody > tr"),n=t.getBoundingClientRect().top,o=[];for(let r=1;r<e.length;r++){const t=e[r];t&&o.push({position:Math.round(t.getBoundingClientRect().top-n),index:r})}return o}(this.tableEl),function(t,e=0){if("number"==typeof t){if(e<=1)return[];const n=t/e;return Array.from({length:e-1},(t,e)=>({position:Math.round(n*(e+1)),index:e+1}))}const n=ye(t,e);if(n.length<=1)return[];const o="rtl"===getComputedStyle(t).direction;return n.slice(0,-1).map((t,e)=>({position:Math.round(o?t.position:t.position+t.width),index:e+1}))}(this.tableEl,this.numCols));"row"===r.type&&r.border?(this.showHorizontalLine(r.border),this.hideVerticalLine()):"col"===r.type&&r.border?(this.showVerticalLine(r.border),this.hideHorizontalLine()):this.hideInsertLines()};onMouseLeave=()=>{this.hideInsertLines()};constructor(t,e,n,o,r,i,l=nt,s=Se){if(this.container=t,this.tableEl=e,this.getState=o,this.dispatchFn=r,this.pluginContext=i??null,this.locale=l,this.config={...wt(s),directResize:s.directResize??!0},this.wrapperEl=e.closest(".notectl-table-wrapper"),this.tableId=n.id,this.currentNode=n,this.numRows=V(n).rowCount,this.numCols=this.countCols(n),this.colBar=ge("ntbl-col-bar"),this.rowBar=ge("ntbl-row-bar"),this.colResizeBar=ge("ntbl-col-resize-bar"),this.rowResizeBar=ge("ntbl-row-resize-bar"),this.resizeIndicator=function(){const t=document.createElement("div");return t.className="ntbl-resize-indicator",t.setAttribute("aria-hidden","true"),t.setAttribute("contenteditable","false"),t.setAttribute("data-notectl-no-print",""),t}(),this.insertLineH=pe("horizontal",l.insertRow),this.insertLineV=pe("vertical",l.insertColumn),this.addRowZone=fe("ntbl-add-row",l.addRow),this.addColZone=fe("ntbl-add-col",l.addColumn),this.deleteTableBtn=me("ntbl-delete-table-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M9 3h6m-9 4h12M10 11v6m4-6v6m-9 3h14l-1-13H6L5 20z" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>',l.deleteTable),this.deleteTableBtn.setAttribute("data-notectl-no-print",""),i){const t=ct(o(),this.tableId);this.borderColorBtn=function(t,e){const n=me("ntbl-border-color-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M3 3h18v18H3V3zm0 6h18M3 15h18M9 3v18M15 3v18" stroke="currentColor" stroke-width="1.5"/></svg>',t);n.setAttribute("data-notectl-no-print","");const o=document.createElement("span");return o.className="ntbl-border-color-swatch",xe(o,e),n.appendChild(o),n}(l.borderColor,t),this.actionsBtn=function(t){const e=me("ntbl-actions-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg>',t);return e.setAttribute("data-notectl-no-print",""),e}(l.tableActionsHint)}else this.borderColorBtn=null,this.actionsBtn=null;t.append(this.colBar,this.rowBar,this.insertLineH,this.insertLineV,this.addRowZone,this.addColZone,this.deleteTableBtn),this.config.directResize&&t.append(this.colResizeBar,this.rowResizeBar,this.resizeIndicator),this.borderColorBtn&&t.appendChild(this.borderColorBtn),this.actionsBtn&&t.appendChild(this.actionsBtn),this.contextHint=function(t){const e=document.createElement("div");return e.className="ntbl-context-hint",e.setAttribute("aria-hidden","true"),e.setAttribute("contenteditable","false"),e.setAttribute("data-notectl-no-print",""),e.textContent=t,e}(l.contextMenuHint),t.appendChild(this.contextHint),this.rebuildColHandles(),this.rebuildRowHandles(),this.rebuildResizeSeparators(),this.bindEventListeners(),this.setReadOnly(i?.isReadOnly?.()??!1),this.observer=new ResizeObserver(()=>{this.positionControls()}),this.observer.observe(e),this.wrapperEl&&(this.observer.observe(this.wrapperEl),this.wrapperEl.addEventListener("scroll",this.onWrapperScroll,{passive:!0})),requestAnimationFrame(()=>this.positionControls())}update(t){this.tableId=t.id,this.currentNode=t;const e=V(t).rowCount,n=this.countCols(t);if(e===this.numRows&&n===this.numCols||(this.numRows=e,this.numCols=n,this.rebuildColHandles(),this.rebuildRowHandles(),this.rebuildResizeSeparators()),this.updateHandleSelectionState(),this.borderColorBtn){const e=this.borderColorBtn.querySelector(".ntbl-border-color-swatch");if(e){const n=t.attrs?.borderColor;xe(e,n)}}requestAnimationFrame(()=>this.positionControls())}setReadOnly(t){this.readOnly=t,this.container.toggleAttribute("data-notectl-table-readonly",t);const e=[this.colBar,this.rowBar,this.colResizeBar,this.rowResizeBar,this.addRowZone,this.addColZone,this.deleteTableBtn,this.insertLineH,this.insertLineV,...this.borderColorBtn?[this.borderColorBtn]:[],...this.actionsBtn?[this.actionsBtn]:[]];for(const n of e){n instanceof HTMLButtonElement&&(n.disabled=t);for(const e of n.querySelectorAll("button"))e.disabled=t}t&&(this.hideInsertLines(),this.cancelActiveResize(),this.activeContextMenu?.close(),this.activeContextMenu=null,this.closeBorderColorPopup())}destroy(){this.cancelActiveResize(),this.activeContextMenu?.destroy(),this.closeBorderColorPopup(),this.observer.disconnect(),this.wrapperEl?.removeEventListener("scroll",this.onWrapperScroll),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.colBar.remove(),this.rowBar.remove(),this.colResizeBar.remove(),this.rowResizeBar.remove(),this.resizeIndicator.remove(),this.insertLineH.remove(),this.insertLineV.remove(),this.addRowZone.remove(),this.addColZone.remove(),this.deleteTableBtn.remove(),this.borderColorBtn?.remove(),this.actionsBtn?.remove(),this.contextHint.remove()}bindEventListeners(){const t=this.insertLineH.querySelector(".ntbl-insert-btn"),e=this.insertLineV.querySelector(".ntbl-insert-btn");if(t.addEventListener("click",()=>{this.activeRowIndex>=0&&this.dispatchTransaction(Tt(this.getState(),this.tableId,this.activeRowIndex))}),e.addEventListener("click",()=>{this.activeColIndex>=0&&this.dispatchTransaction(Dt(this.getState(),this.tableId,this.activeColIndex))}),this.addRowZone.addEventListener("click",()=>{this.dispatchTransaction(Tt(this.getState(),this.tableId,this.numRows))}),this.addColZone.addEventListener("click",()=>{this.dispatchTransaction(Dt(this.getState(),this.tableId,this.numCols))}),this.deleteTableBtn.addEventListener("click",()=>{this.dispatchTransaction(_t(this.getState(),this.tableId))}),this.borderColorBtn&&this.pluginContext){const t=this.pluginContext;this.borderColorBtn.addEventListener("click",()=>{this.toggleBorderColorPopup(t)})}if(this.actionsBtn&&this.pluginContext){const t=this.pluginContext;this.actionsBtn.addEventListener("click",()=>{this.openActionsMenu(t)})}this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseleave",this.onMouseLeave)}openActionsMenu(t){if(this.readOnly||t.isReadOnly?.())return;if(this.activeContextMenu?.isOpen())return this.activeContextMenu.close(),void(this.activeContextMenu=null);if(!this.actionsBtn)return;const e=this.actionsBtn.getBoundingClientRect();this.activeContextMenu=ie(this.container,t,this.tableId,e,()=>{this.activeContextMenu=null},this.locale,void 0,{sizingConfig:this.config,restoreFocusTo:this.actionsBtn})}toggleBorderColorPopup(t){this.readOnly||t.isReadOnly?.()||(this.borderColorPopup?this.closeBorderColorPopup():(this.borderColorPopup=document.createElement("div"),this.borderColorPopup.className="notectl-table-context-menu",N(this.borderColorPopup,{position:"absolute",top:"24px",left:"24px",zIndex:"10000"}),this.borderColorPopup.setAttribute("contenteditable","false"),dt(this.borderColorPopup,t,this.tableId,()=>{this.closeBorderColorPopup()},this.locale),this.container.appendChild(this.borderColorPopup)))}closeBorderColorPopup(){this.borderColorPopup&&(this.borderColorPopup.remove(),this.borderColorPopup=null)}dispatchTransaction(t){!t||this.readOnly||this.pluginContext?.isReadOnly?.()||this.dispatchFn(t)}countCols(t){return V(t).columnCount}positionControls(){const t=Ce(this.tableEl,this.container),e=this.tableEl.getBoundingClientRect();N(this.colBar,{left:`${String(t.left)}px`,top:`${String(t.top-24)}px`}),B(this.rowBar,"top",`${String(t.top)}px`),function(t,e,n=0){const o=t.children;if(0===o.length)return;const r="number"==typeof e?Array.from({length:n},(t,o)=>({index:o,position:e/n*o,width:e/n})):ye(e,n);for(let l=0;l<o.length;l++){const t=o[l],e=r[l];e&&N(t,{left:`${Math.round(e.position)}px`,width:`${Math.round(e.width)}px`})}const i=r.reduce((t,e)=>Math.max(t,e.position+e.width),0);B(t,"width",`${Math.round(i)}px`)}(this.colBar,this.tableEl,this.numCols),function(t,e){const n=t.children;if(0===n.length)return;const o=e.querySelectorAll(":scope > tbody > tr"),r=e.getBoundingClientRect();let i=0;for(let l=0;l<n.length;l++){const t=n[l],e=o[l];if(e){const n=e.getBoundingClientRect(),o=n.top-r.top,l=n.height||e.offsetHeight;N(t,{top:`${o}px`,height:`${l}px`}),i=o+l}}B(t,"height",`${i}px`)}(this.rowBar,this.tableEl),function(t,e,n,o){const r=Ce(n,o),i=n.getBoundingClientRect(),l=i.height||n.offsetHeight,s=i.width||n.offsetWidth;N(t,{width:`${s}px`,left:`${r.left}px`}),N(e,{height:`${l}px`,top:`${r.top}px`})}(this.addRowZone,this.addColZone,this.tableEl,this.container),this.config.directResize&&this.positionResizeSeparators(t,e)}positionResizeSeparators(t,e){N(this.colResizeBar,{left:`${String(t.left)}px`,top:`${String(t.top)}px`,width:`${String(e.width)}px`,height:`${String(e.height)}px`}),N(this.rowResizeBar,{left:`${String(t.left)}px`,top:`${String(t.top)}px`,width:`${String(e.width)}px`,height:`${String(e.height)}px`});const n="rtl"===getComputedStyle(this.tableEl).direction,o=ye(this.tableEl,this.numCols);for(let i=0;i<this.colResizeBar.children.length;i++){const t=this.colResizeBar.children[i],r=o[i];if(!r)continue;const l=n?r.position:r.position+r.width;N(t,{left:`${String(l)}px`,top:"0px",height:`${String(e.height)}px`}),this.updateSeparatorValue(t,"column",i,r.width)}const r=Array.from(this.tableEl.querySelectorAll(":scope > tbody > tr"));for(let i=0;i<this.rowResizeBar.children.length;i++){const t=this.rowResizeBar.children[i],n=r[i];if(!n)continue;const o=n.getBoundingClientRect(),l=o.bottom-e.top;N(t,{left:"0px",top:`${String(l)}px`,width:`${String(e.width)}px`}),this.updateSeparatorValue(t,"row",i,o.height||n.offsetHeight)}}updateSeparatorValue(t,e,n,o){const r="column"===e?this.config.minColumnWidthPx:this.config.minRowHeightPx,i="column"===e?this.config.maxColumnWidthPx:this.config.maxRowHeightPx,l=Math.round(o);t.setAttribute("aria-valuemin",String(r)),t.setAttribute("aria-valuemax",String(i)),t.setAttribute("aria-valuenow",String(l)),t.setAttribute("aria-valuetext",`${String(l)} px`),t.dataset.index=String(n)}startResize(t,e,n){if(this.readOnly||this.pluginContext?.isReadOnly?.()||0!==t.button&&"touch"!==t.pointerType)return;const o=this.getRenderedDimension(e,n);null!==o&&(t.preventDefault(),t.stopPropagation(),this.cancelActiveResize(),this.resizeSession={kind:e,index:n,pointerId:t.pointerId,startCoordinate:"column"===e?t.clientX:t.clientY,startSize:o,currentSize:o},t.currentTarget?.setPointerCapture?.(t.pointerId),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("pointercancel",this.onPointerCancel),document.addEventListener("keydown",this.onDocumentKeyDown,!0),this.container.classList.add(`ntbl-container--resizing-${e}`),this.updateResizeIndicator(o,t.clientX,t.clientY))}moveResize(t){const e=this.resizeSession;if(!e||e.pointerId!==t.pointerId)return;t.preventDefault();let n=("column"===e.kind?t.clientX:t.clientY)-e.startCoordinate;"column"===e.kind&&"rtl"===getComputedStyle(this.tableEl).direction&&(n*=-1);const o=this.clampDimension(e.kind,e.startSize+n);e.currentSize=o,this.applyResizePreview(e.kind,e.index,o),this.updateResizeIndicator(o,t.clientX,t.clientY),this.positionControls()}finishResize(t){const e=this.resizeSession;if(!e||e.pointerId!==t.pointerId)return;t.currentTarget?.releasePointerCapture?.(t.pointerId),this.resizeSession=null,this.detachResizeListeners(),this.hideResizeIndicator();const n=Math.round(e.currentSize),o=this.getSizingService();("column"===e.kind?o?.setSize({kind:"column",tableId:this.tableId,column:e.index},{columnWidthPx:n}):o?.setSize({kind:"row",tableId:this.tableId,row:e.index},{rowMinHeightPx:n}))?"column"===e.kind?this.pluginContext?.announce(this.locale.announceColumnWidthSet(e.index,n)):this.pluginContext?.announce(this.locale.announceRowMinimumHeightSet(e.index,n)):this.restoreCanonicalDimensions()}cancelResize(t){this.resizeSession?.pointerId===t.pointerId&&this.cancelActiveResize()}cancelActiveResize(){this.resizeSession&&(this.resizeSession=null,this.detachResizeListeners(),this.hideResizeIndicator(),this.restoreCanonicalDimensions(),this.positionControls())}detachResizeListeners(){document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerCancel),document.removeEventListener("keydown",this.onDocumentKeyDown,!0),this.container.classList.remove("ntbl-container--resizing-column"),this.container.classList.remove("ntbl-container--resizing-row")}getRenderedDimension(t,e){if("column"===t)return ye(this.tableEl,this.numCols)[e]?.width??null;const n=Array.from(this.tableEl.querySelectorAll(":scope > tbody > tr"))[e];return n&&(n.getBoundingClientRect().height||n.offsetHeight)||null}clampDimension(t,e){const n="column"===t?this.config.minColumnWidthPx:this.config.minRowHeightPx,o="column"===t?this.config.maxColumnWidthPx:this.config.maxRowHeightPx;return Math.min(o,Math.max(n,e))}applyResizePreview(t,e,n){if("column"===t){const t=this.tableEl.querySelectorAll(":scope > colgroup > col")[e];if(!t)return;H(t,"width"),t.setAttribute("width",String(n));const o=xt(this.currentNode,this.numCols),r=o.reduce((t,o,r)=>t+(r===e?n:o??this.config.minColumnWidthPx),0);return B(this.tableEl,"minWidth",`${String(r)}px`),void(o.length>=this.numCols&&o.every((t,n)=>n===e||null!==t)?B(this.tableEl,"width",`${String(r)}px`):H(this.tableEl,"width"))}const o=this.tableEl.querySelectorAll(":scope > tbody > tr")[e];o&&(H(o,"height"),o.setAttribute("height",String(n)))}restoreCanonicalDimensions(){const t=xt(this.currentNode,this.numCols),e=Array.from(this.tableEl.querySelectorAll(":scope > colgroup > col"));let o=0;for(let n=0;n<e.length;n++){const r=e[n];if(!r)continue;const i=t[n]??null;r.removeAttribute("width"),null===i?(H(r,"width"),r.removeAttribute("data-notectl-width-px")):(B(r,"width",`${String(i)}px`),r.setAttribute("data-notectl-width-px",String(i))),o+=i??this.config.minColumnWidthPx}B(this.tableEl,"minWidth",`${String(o)}px`),t.length>=this.numCols&&t.every(t=>null!==t)?B(this.tableEl,"width",`${String(o)}px`):H(this.tableEl,"width");const r=n(this.currentNode),i=Array.from(this.tableEl.querySelectorAll(":scope > tbody > tr"));for(let n=0;n<i.length;n++){const t=i[n],e=r[n];if(!t||!e)continue;t.removeAttribute("height");const o=Ct(e);null===o?(H(t,"height"),t.removeAttribute("data-notectl-min-height-px")):(B(t,"height",`${String(o)}px`),t.setAttribute("data-notectl-min-height-px",String(o)))}}updateResizeIndicator(t,e,n){const o=this.container.getBoundingClientRect();this.resizeIndicator.textContent=`${String(Math.round(t))} px`,N(this.resizeIndicator,{left:`${String(e-o.left+this.container.scrollLeft+12)}px`,top:`${String(n-o.top+this.container.scrollTop+12)}px`}),this.resizeIndicator.classList.add("ntbl-resize-indicator--visible")}hideResizeIndicator(){this.resizeIndicator.classList.remove("ntbl-resize-indicator--visible")}showHorizontalLine(t){this.activeRowIndex=t.index;const e=Ce(this.tableEl,this.container);N(this.insertLineH,{top:e.top+t.position-1+"px",left:`${e.left}px`,width:`${this.tableEl.offsetWidth}px`}),this.insertLineH.classList.add("ntbl-insert-line--visible")}showVerticalLine(t){this.activeColIndex=t.index;const e=Ce(this.tableEl,this.container);N(this.insertLineV,{left:e.left+t.position-1+"px",top:`${e.top}px`,height:`${this.tableEl.offsetHeight}px`}),this.insertLineV.classList.add("ntbl-insert-line--visible")}hideInsertLines(){this.hideHorizontalLine(),this.hideVerticalLine()}hideHorizontalLine(){this.insertLineH.classList.remove("ntbl-insert-line--visible"),this.activeRowIndex=-1}hideVerticalLine(){this.insertLineV.classList.remove("ntbl-insert-line--visible"),this.activeColIndex=-1}rebuildColHandles(){this.colBar.innerHTML="";for(let t=0;t<this.numCols;t++){const e=ve("ntbl-col-handle",t,this.locale.deleteColumn,t=>{this.dispatchTransaction(Ot(this.getState(),this.tableId,t))},{label:this.locale.selectColumnLabel(t),onSelect:t=>this.selectColumn(t)});this.colBar.appendChild(e)}}rebuildRowHandles(){this.rowBar.innerHTML="";for(let t=0;t<this.numRows;t++){const e=ve("ntbl-row-handle",t,this.locale.deleteRow,t=>{this.dispatchTransaction(Wt(this.getState(),this.tableId,t))},{label:this.locale.selectRowLabel(t),onSelect:t=>this.selectRow(t)});this.rowBar.appendChild(e)}}rebuildResizeSeparators(){if(this.colResizeBar.innerHTML="",this.rowResizeBar.innerHTML="",!this.config.directResize)return;const t=this.locale.resizeKeyboardHint(this.config.keyboardResizeStepPx,this.config.keyboardResizeLargeStepPx);for(let e=0;e<this.numCols;e++){const n=we("column",e,this.locale.resizeColumnSeparatorLabel(e),t);n.addEventListener("pointerdown",t=>this.startResize(t,"column",e)),n.addEventListener("keydown",t=>this.resizeFromKeyboard(t,"column",e)),this.colResizeBar.appendChild(n)}for(let e=0;e<this.numRows;e++){const n=we("row",e,this.locale.resizeRowSeparatorLabel(e),t);n.addEventListener("pointerdown",t=>this.startResize(t,"row",e)),n.addEventListener("keydown",t=>this.resizeFromKeyboard(t,"row",e)),this.rowResizeBar.appendChild(n)}this.setReadOnly(this.readOnly)}resizeFromKeyboard(t,e,n){if(this.readOnly||this.pluginContext?.isReadOnly?.())return;const o=this.getSizingService();if(!o)return;const r=t.currentTarget;if("Delete"===t.key||"Backspace"===t.key){t.preventDefault(),t.stopPropagation();const i="column"===e?{kind:"column",tableId:this.tableId,column:n}:{kind:"row",tableId:this.tableId,row:n},l="column"===e?"columnWidthPx":"rowMinHeightPx";return void(o.resetSize(i,l)&&(this.restoreKeyboardResizeFocus(r),this.pluginContext?.announce("column"===e?this.locale.announceColumnWidthReset(n):this.locale.announceRowMinimumHeightReset(n))))}const i="column"===e?"ArrowLeft":"ArrowUp",l="column"===e?"ArrowRight":"ArrowDown";if(t.key!==i&&t.key!==l)return;t.preventDefault(),t.stopPropagation();const s=this.getRenderedDimension(e,n);if(null===s)return;const a=t.shiftKey?this.config.keyboardResizeLargeStepPx:this.config.keyboardResizeStepPx;let c=t.key===l?1:-1;"column"===e&&"rtl"===getComputedStyle(this.tableEl).direction&&(c=1===c?-1:1);const d=Math.round(this.clampDimension(e,s+a*c));("column"===e?o.setSize({kind:"column",tableId:this.tableId,column:n},{columnWidthPx:d}):o.setSize({kind:"row",tableId:this.tableId,row:n},{rowMinHeightPx:d}))&&(this.restoreKeyboardResizeFocus(r),this.pluginContext?.announce("column"===e?this.locale.announceColumnWidthSet(n,d):this.locale.announceRowMinimumHeightSet(n,d)),this.updateSeparatorValue(r,e,n,d))}restoreKeyboardResizeFocus(t){t.isConnected&&t.focus({preventScroll:!0})}selectColumn(t){this.readOnly||0===this.numRows||(this.getSelectionService()?.setSelectedRange({tableId:this.tableId,fromRow:0,fromCol:t,toRow:this.numRows-1,toCol:t}),this.updateHandleSelectionState())}selectRow(t){this.readOnly||0===this.numCols||(this.getSelectionService()?.setSelectedRange({tableId:this.tableId,fromRow:t,fromCol:0,toRow:t,toCol:this.numCols-1}),this.updateHandleSelectionState())}updateHandleSelectionState(){const t=this.getSelectionService()?.getSelectedRange();for(let e=0;e<this.colBar.children.length;e++){const n=!!t&&t.tableId===this.tableId&&Math.min(t.fromCol,t.toCol)===e&&Math.max(t.fromCol,t.toCol)===e&&0===Math.min(t.fromRow,t.toRow)&&Math.max(t.fromRow,t.toRow)===this.numRows-1;this.colBar.children[e]?.querySelector(".ntbl-handle-select")?.setAttribute("aria-pressed",n?"true":"false")}for(let e=0;e<this.rowBar.children.length;e++){const n=!!t&&t.tableId===this.tableId&&Math.min(t.fromRow,t.toRow)===e&&Math.max(t.fromRow,t.toRow)===e&&0===Math.min(t.fromCol,t.toCol)&&Math.max(t.fromCol,t.toCol)===this.numCols-1;this.rowBar.children[e]?.querySelector(".ntbl-handle-select")?.setAttribute("aria-pressed",n?"true":"false")}}getSizingService(){return this.pluginContext?.getService?.(gt)}getSelectionService(){return this.pluginContext?.getService?.(bt)}},ze={minColumnWidthPx:60,minRowHeightPx:24,maxColumnWidthPx:1e4,maxRowHeightPx:1e4,keyboardResizeStepPx:8,keyboardResizeLargeStepPx:32,directResize:!0};function Ie(t,e){"none"===e?(B(t,"--ntbl-border-color","transparent"),t.classList.add("notectl-table--borderless")):e?(B(t,"--ntbl-border-color",e),t.classList.remove("notectl-table--borderless")):(H(t,"--ntbl-border-color"),t.classList.remove("notectl-table--borderless"))}function ke(t,e,n,o=ze){const r=V(n).columnCount;for(B(t,"--ntbl-min-column-width",`${String(o.minColumnWidthPx)}px`);e.children.length>r;)e.lastElementChild?.remove();for(;e.children.length<r;)e.appendChild(document.createElement("col"));const i=n.attrs?.columnWidthsPx,l=Array.isArray(i)?i:[];let s=0;for(let a=0;a<r;a++){const t=e.children[a];if(!t)continue;t.removeAttribute("width");const n=l[a],r="number"==typeof n&&Number.isFinite(n)&&n>0?n:void 0;void 0!==r?(B(t,"width",`${String(r)}px`),t.setAttribute("data-notectl-width-px",String(r))):(H(t,"width"),t.removeAttribute("data-notectl-width-px")),s+=r??o.minColumnWidthPx}r>0?(B(t,"minWidth",`${String(s)}px`),l.length>=r&&l.slice(0,r).every(t=>"number"==typeof t)?B(t,"width",`${String(s)}px`):H(t,"width")):(H(t,"minWidth"),H(t,"width"))}function Ae(t,e){const n=e.attrs?.minHeightPx;t.removeAttribute("height"),"number"==typeof n&&Number.isFinite(n)&&n>0?(B(t,"height",`${String(n)}px`),t.setAttribute("data-notectl-min-height-px",String(n))):(H(t,"height"),t.removeAttribute("data-notectl-min-height-px"))}function Ee(t,e){const o=Array.from(t.querySelectorAll(":scope > tr"));for(const r of n(e)){const t=o.find(t=>t.getAttribute("data-block-id")===r.id);t&&Ae(t,r)}}function Pe(t){if(!t)return;const{borderColor:e,columnWidthsPx:n,...o}=t;return Object.keys(o).length>0?o:void 0}function Le(t){if(!t)return;const{minHeightPx:e,...n}=t;return Object.keys(n).length>0?n:void 0}var Me={maxPickerRows:8,maxPickerCols:8,...ft,directResize:!0},Be="border: 1px solid var(--ntbl-bc, #d0d0d0); padding: 8px 12px; vertical-align: top",He=class{id="table";name="Table";priority=40;config;locale;selectionService=null;cleanupMouseSelection=null;cleanupClipboard=null;context=null;controls=/* @__PURE__ */new Set;constructor(t){const e=wt(t??{});this.config={...Me,...t,...e,maxPickerRows:Ne(t?.maxPickerRows,Me.maxPickerRows),maxPickerCols:Ne(t?.maxPickerCols,Me.maxPickerCols),directResize:t?.directResize??!0}}async init(t){this.locale=await L(t,this.config.locale,nt,rt),t.registerStyleSheet('\n/* Table */\n.notectl-table-wrapper {\n\tmargin: 8px 0;\n\toverflow-x: auto;\n\tposition: relative;\n}\n\n.notectl-table {\n\twidth: 100%;\n\tborder-collapse: collapse;\n\ttable-layout: fixed;\n}\n\n.notectl-table col {\n\tbox-sizing: border-box;\n}\n\n/* Border resolution order: per-table local override → theme component token → theme global token.\n * The inline --ntbl-border-color is set by the toolbar\'s "border color" action and must win\n * over the theme so per-table customizations remain visible after a theme switch.\n */\n.notectl-table td {\n\tborder: 1px solid var(--ntbl-border-color, var(--notectl-table-border, var(--notectl-border)));\n\tbackground: var(--notectl-table-cell-bg, transparent);\n\tpadding: 8px 12px;\n\tmin-width: var(--ntbl-min-column-width, 60px);\n\tvertical-align: top;\n\tmin-height: 1.6em;\n}\n\n.notectl-table th {\n\tborder: 1px solid var(--ntbl-border-color, var(--notectl-table-border, var(--notectl-border)));\n\tbackground: var(--notectl-table-header-bg, var(--notectl-surface-raised));\n\tpadding: 8px 12px;\n\tmin-width: var(--ntbl-min-column-width, 60px);\n\tvertical-align: top;\n\ttext-align: start;\n\tfont-weight: 600;\n}\n\n.notectl-table--borderless td {\n\tborder: 1px dashed rgba(128, 128, 128, 0.15);\n}\n\n@media print {\n\t.notectl-table--borderless td {\n\t\tborder: none;\n\t}\n}\n\n.notectl-table td:focus-within {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-table-cell--selected {\n\tbackground: var(--notectl-primary-muted);\n}\n\n/* Table Context Menu */\n.notectl-table-context-menu {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\tpadding: 4px 0;\n\tmin-width: 180px;\n\tz-index: 10000;\n}\n\n.notectl-table-context-menu button {\n\tdisplay: block;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: start;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tfont-family: inherit;\n}\n\n.notectl-table-context-menu button:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-table-context-menu hr {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 4px 0;\n}\n\n/* === Table Controls === */\n\n/* Outer container for table + controls */\n.ntbl-container {\n\tposition: relative;\n\tmargin: 8px 0;\n\tpadding-block-start: 24px;\n\tpadding-inline-start: 24px;\n}\n\n.ntbl-container .notectl-table-wrapper {\n\tmargin: 0;\n}\n\n.ntbl-container.notectl-table--selected .notectl-table-wrapper {\n\toutline: 2px solid var(--notectl-accent-fg);\n\toutline-offset: 2px;\n\tborder-radius: 6px;\n}\n\n/* --- Column Handle Bar --- */\n.ntbl-col-bar {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 24px;\n\theight: 20px;\n\tdisplay: flex;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tz-index: 3;\n\tpointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-col-bar,\n.ntbl-container:focus-within .ntbl-col-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-col-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n/* --- Row Handle Bar --- */\n.ntbl-row-bar {\n\tposition: absolute;\n\ttop: 24px;\n\tinset-inline-start: 0;\n\twidth: 20px;\n\tdisplay: flex;\n\tflex-direction: column;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tz-index: 3;\n\tpointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-row-bar,\n.ntbl-container:focus-within .ntbl-row-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-row-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n/* --- Handle (shared base) --- */\n.ntbl-handle {\n\tposition: absolute;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\ttransition: background 0.15s ease;\n\tborder-radius: 3px;\n}\n\n.ntbl-handle-select {\n\tposition: absolute;\n\tinset: 0;\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0;\n\tborder-radius: inherit;\n\tbackground: transparent;\n\tcursor: pointer;\n}\n\n.ntbl-handle-select[aria-pressed="true"] {\n\tbackground: var(--notectl-primary-muted);\n\tbox-shadow: inset 0 0 0 1px var(--notectl-primary);\n}\n\n.ntbl-handle-select:focus-visible {\n\toutline: none;\n\tbox-shadow: inset 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-col-handle {\n\theight: 100%;\n\tbackground: var(--notectl-hover-bg);\n\tborder-radius: 4px 4px 0 0;\n}\n\n.ntbl-col-handle:hover {\n\tbackground: var(--notectl-border);\n}\n\n.ntbl-row-handle {\n\twidth: 100%;\n\tbackground: var(--notectl-hover-bg);\n\tborder-start-start-radius: 4px;\n\tborder-end-start-radius: 4px;\n}\n\n.ntbl-row-handle:hover {\n\tbackground: var(--notectl-border);\n}\n\n/* --- Handle Delete Button --- */\n.ntbl-handle-delete {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\theight: 16px;\n\tborder: none;\n\tbackground: transparent;\n\tcolor: var(--notectl-fg-muted);\n\tcursor: pointer;\n\tborder-radius: 3px;\n\tpadding: 0;\n\topacity: 0;\n\ttransform: scale(0.7);\n\ttransition: opacity 0.15s, transform 0.15s,\n\t\tbackground 0.15s, color 0.15s;\n\tz-index: 1;\n}\n\n/* --- Logical column/row resize separators --- */\n.ntbl-col-resize-bar,\n.ntbl-row-resize-bar {\n\tposition: absolute;\n\tinset: 0 auto auto 0;\n\tz-index: 8;\n\tpointer-events: none;\n}\n\n.ntbl-resize-separator {\n\tposition: absolute;\n\tdisplay: block;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tbackground: transparent;\n\topacity: 0;\n\tpointer-events: none;\n\ttouch-action: none;\n}\n\n.ntbl-resize-separator--column {\n\twidth: 12px;\n\ttransform: translateX(-6px);\n\tcursor: col-resize;\n}\n\n.ntbl-resize-separator--row {\n\theight: 12px;\n\ttransform: translateY(-6px);\n\tcursor: row-resize;\n}\n\n.ntbl-container:hover .ntbl-resize-separator,\n.ntbl-container:focus-within .ntbl-resize-separator,\n.ntbl-container.notectl-table--selected .ntbl-resize-separator,\n.ntbl-container--resizing-column .ntbl-resize-separator--column,\n.ntbl-container--resizing-row .ntbl-resize-separator--row {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-resize-separator::after {\n\tcontent: "";\n\tposition: absolute;\n\tbackground: var(--notectl-primary);\n\topacity: 0.35;\n}\n\n.ntbl-resize-separator--column::after {\n\tinset: 0 auto 0 5px;\n\twidth: 2px;\n}\n\n.ntbl-resize-separator--row::after {\n\tinset: 5px 0 auto 0;\n\theight: 2px;\n}\n\n.ntbl-resize-separator:hover::after,\n.ntbl-resize-separator:focus-visible::after {\n\topacity: 1;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-resize-separator:focus-visible {\n\toutline: none;\n}\n\n.ntbl-resize-indicator {\n\tposition: absolute;\n\tdisplay: none;\n\tz-index: 12;\n\tpadding: 3px 7px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-fg);\n\tcolor: var(--notectl-bg);\n\tfont: 12px/1.4 monospace;\n\tpointer-events: none;\n\twhite-space: nowrap;\n}\n\n.ntbl-resize-indicator--visible {\n\tdisplay: block;\n}\n\n.ntbl-container--resizing-column,\n.ntbl-container--resizing-column * {\n\tcursor: col-resize !important;\n\tuser-select: none !important;\n}\n\n.ntbl-container--resizing-row,\n.ntbl-container--resizing-row * {\n\tcursor: row-resize !important;\n\tuser-select: none !important;\n}\n\n.ntbl-handle:hover .ntbl-handle-delete,\n.ntbl-handle:focus-within .ntbl-handle-delete {\n\topacity: 1;\n\ttransform: scale(1);\n}\n\n.ntbl-handle-delete:hover,\n.ntbl-handle-delete:focus-visible {\n\tbackground: var(--notectl-danger-muted);\n\tcolor: var(--notectl-danger);\n}\n\n.ntbl-handle-delete:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Insert Lines --- */\n.ntbl-insert-line {\n\tposition: absolute;\n\tpointer-events: none;\n\topacity: 0;\n\ttransition: opacity 0.15s ease;\n\tz-index: 6;\n}\n\n.ntbl-insert-line--visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-insert-line--horizontal {\n\theight: 2px;\n\tbackground: linear-gradient(\n\t\t90deg,\n\t\ttransparent,\n\t\tvar(--notectl-primary) 8%,\n\t\tvar(--notectl-primary) 92%,\n\t\ttransparent\n\t);\n\tbox-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--vertical {\n\twidth: 2px;\n\tbackground: linear-gradient(\n\t\t180deg,\n\t\ttransparent,\n\t\tvar(--notectl-primary) 8%,\n\t\tvar(--notectl-primary) 92%,\n\t\ttransparent\n\t);\n\tbox-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n/* --- Insert Button on Line --- */\n.ntbl-insert-btn {\n\tposition: absolute;\n\twidth: 20px;\n\theight: 20px;\n\tborder-radius: 50%;\n\tbackground: var(--notectl-surface-raised);\n\tborder: 2px solid var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n\tcursor: pointer;\n\tpointer-events: all;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: 0;\n\tbox-shadow: 0 2px 8px var(--notectl-focus-ring);\n\ttransition: background 0.15s, color 0.15s,\n\t\ttransform 0.15s, box-shadow 0.15s;\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn {\n\tleft: 50%;\n\ttop: -9px;\n\ttransform: translateX(-50%);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn {\n\ttop: 50%;\n\tinset-inline-start: -9px;\n\ttransform: translateY(-50%);\n}\n\n.ntbl-insert-btn:hover,\n.ntbl-insert-btn:focus-visible {\n\tbackground: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg);\n\tbox-shadow: 0 2px 12px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn:hover {\n\ttransform: translateX(-50%) scale(1.2);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn:hover {\n\ttransform: translateY(-50%) scale(1.2);\n}\n\n/* --- Add Row / Add Column Zones --- */\n.ntbl-add-zone {\n\tposition: absolute;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\tuser-select: none;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.2s ease,\n\t\tborder-color 0.2s ease;\n}\n\n.ntbl-container:hover .ntbl-add-zone,\n.ntbl-container:focus-within .ntbl-add-zone {\n\topacity: 1;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-add-zone {\n\topacity: 1;\n}\n\n.ntbl-delete-table-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-danger);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-danger);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n}\n\n.ntbl-container:hover .ntbl-delete-table-btn,\n.ntbl-container:focus-within .ntbl-delete-table-btn,\n.ntbl-container.notectl-table--selected .ntbl-delete-table-btn {\n\topacity: 1;\n}\n\n.ntbl-delete-table-btn:hover,\n.ntbl-delete-table-btn:focus-visible {\n\tbackground: var(--notectl-danger-muted);\n\tborder-color: var(--notectl-danger);\n}\n\n.ntbl-delete-table-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Context Menu Discovery Hint --- */\n.ntbl-context-hint {\n\tposition: absolute;\n\ttop: 4px;\n\tinset-inline-end: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tpadding: 2px 8px;\n\tborder-radius: 4px;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tpointer-events: none;\n\twhite-space: nowrap;\n\tz-index: 5;\n}\n\n.ntbl-container:hover .ntbl-context-hint,\n.ntbl-container:focus-within .ntbl-context-hint,\n.ntbl-container.notectl-table--selected .ntbl-context-hint {\n\topacity: 1;\n}\n\n/* --- Table Actions Button --- */\n.ntbl-actions-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 48px;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg-muted);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n\tcursor: pointer;\n\tpadding: 0;\n}\n\n.ntbl-container:hover .ntbl-actions-btn,\n.ntbl-container:focus-within .ntbl-actions-btn,\n.ntbl-container.notectl-table--selected .ntbl-actions-btn {\n\topacity: 1;\n}\n\n.ntbl-actions-btn:hover,\n.ntbl-actions-btn:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-primary);\n}\n\n.ntbl-actions-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Border Color Button --- */\n.ntbl-border-color-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 24px;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg-muted);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n\tcursor: pointer;\n\tpadding: 0;\n}\n\n.ntbl-container:hover .ntbl-border-color-btn,\n.ntbl-container:focus-within .ntbl-border-color-btn,\n.ntbl-container.notectl-table--selected .ntbl-border-color-btn {\n\topacity: 1;\n}\n\n.ntbl-border-color-btn:hover,\n.ntbl-border-color-btn:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-primary);\n}\n\n.ntbl-border-color-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-border-color-swatch {\n\twidth: 10px;\n\theight: 10px;\n\tborder-radius: 2px;\n\tborder: 1px solid rgba(0, 0, 0, 0.15);\n}\n\n/* --- Context Menu Keyboard Hint --- */\n.notectl-table-context-menu__hint {\n\tpadding: 4px 12px 6px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin-top: 4px;\n\ttext-align: center;\n\tuser-select: none;\n}\n\n/* --- Context Menu Focus --- */\n.notectl-table-context-menu button:focus-visible {\n\toutline: none;\n\tbackground: var(--notectl-primary-muted);\n\tbox-shadow: inset 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-table-context-menu [role="separator"] {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 4px 0;\n\theight: 0;\n}\n\n/* --- Precise size editor --- */\n.notectl-table-size-editor {\n\tbox-sizing: border-box;\n\twidth: 340px;\n\tmax-width: calc(100vw - 16px);\n\tmin-width: 260px;\n\tpadding: 12px;\n}\n\n.notectl-table-size-editor__title {\n\tmargin-block-end: 10px;\n\tfont-weight: 600;\n}\n\n.notectl-table-size-editor__field {\n\tdisplay: grid;\n\tgap: 4px;\n\tmargin-block-end: 10px;\n\tfont-size: 13px;\n}\n\n.notectl-table-size-editor__input-wrap {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 6px;\n}\n\n.notectl-table-size-editor input {\n\tbox-sizing: border-box;\n\tmin-width: 0;\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-bg);\n\tcolor: var(--notectl-fg);\n\tfont: inherit;\n}\n\n.notectl-table-size-editor input:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: 1px;\n}\n\n.notectl-table-size-editor input[aria-invalid="true"] {\n\tborder-color: var(--notectl-danger);\n}\n\n.notectl-table-size-editor__unit {\n\tcolor: var(--notectl-fg-muted);\n}\n\n.notectl-table-size-editor__error {\n\tmin-height: 1.2em;\n\tcolor: var(--notectl-danger);\n\tfont-size: 11px;\n}\n\n.notectl-table-size-editor__resets,\n.notectl-table-size-editor__actions {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 4px;\n}\n\n.notectl-table-size-editor__resets {\n\tpadding-block-end: 10px;\n\tborder-block-end: 1px solid var(--notectl-border);\n}\n\n.notectl-table-size-editor__actions {\n\tjustify-content: flex-end;\n\tpadding-block-start: 10px;\n}\n\n.notectl-table-size-editor button {\n\twidth: auto;\n\tpadding: 6px 8px;\n\tborder-radius: 4px;\n\tfont-size: 12px;\n}\n\n.notectl-table-context-menu .notectl-table-size-editor__apply {\n\tbackground: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-table-context-menu .notectl-table-size-editor button:disabled {\n\topacity: 0.5;\n\tcursor: not-allowed;\n}\n\n/* Read-only tables keep semantic dimensions but expose no mutation affordances. */\n.ntbl-container[data-notectl-table-readonly] {\n\tpadding-block-start: 0;\n\tpadding-inline-start: 0;\n}\n\n.ntbl-container[data-notectl-table-readonly] > :is(\n\t.ntbl-col-bar,\n\t.ntbl-row-bar,\n\t.ntbl-col-resize-bar,\n\t.ntbl-row-resize-bar,\n\t.ntbl-insert-line,\n\t.ntbl-add-zone,\n\t.ntbl-delete-table-btn,\n\t.ntbl-border-color-btn,\n\t.ntbl-actions-btn,\n\t.ntbl-context-hint,\n\t.ntbl-resize-indicator\n) {\n\tdisplay: none !important;\n}\n\n.ntbl-add-row {\n\tbottom: 0;\n\theight: 24px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-end-start-radius: 6px;\n\tborder-end-end-radius: 6px;\n\tborder-block-start: none;\n\tcolor: var(--notectl-fg-muted);\n\ttransform: translateY(100%);\n}\n\n.ntbl-add-row:hover,\n.ntbl-add-row:focus-visible {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n}\n\n.ntbl-add-row:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-col {\n\tinset-inline-end: 0;\n\ttop: 24px;\n\twidth: 24px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-start-end-radius: 6px;\n\tborder-end-end-radius: 6px;\n\tborder-inline-start: none;\n\tcolor: var(--notectl-fg-muted);\n\ttransform: translateX(100%);\n}\n\n[dir="rtl"] .ntbl-add-col {\n\ttransform: translateX(-100%);\n}\n\n.ntbl-add-col:hover,\n.ntbl-add-col:focus-visible {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n}\n\n.ntbl-add-col:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-icon {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\ttransition: transform 0.2s ease;\n}\n\n.ntbl-add-zone:hover .ntbl-add-icon {\n\ttransform: scale(1.15);\n}\n\n@media print {\n\t.notectl-table-wrapper {\n\t\toverflow: visible;\n\t}\n\n\t.ntbl-container {\n\t\tpadding: 0;\n\t}\n\n\t.ntbl-container > [data-notectl-no-print] {\n\t\tdisplay: none !important;\n\t}\n}\n'),this.context=t,this.registerNodeSpecs(t),this.registerNodeViews(t),Xt(t,this.locale),t.registerCommand("resetTableBorderColor",()=>at(t,this.locale)),function(t,e,n={}){t.registerKeymap({Tab:()=>function(t,e){return se(t,(n,o,r)=>!!de(t,r,1,!1)||!t.isReadOnly?.()&&Ft(t,e))}(t,e),"Shift-Tab":()=>function(t){return se(t,(e,n,o)=>de(t,o,-1,!1)||!0)}(t),Backspace:()=>function(t){return se(t,(e,n,o)=>{if(!d(n))return!1;if(0!==n.anchor.offset)return!1;if(!function(t,e){const n=t.getBlock(e.tableId);return"table"===n?.type&&V(n).cells[0]?.cell.id===e.cellId}(e,o))return!1;const r=Q(e,o.cellId);return n.anchor.blockId===r&&he(t,o.tableId)})}(t),Delete:()=>function(t){return se(t,(e,n,o)=>{if(!d(n))return!1;const r=e.getBlock(n.anchor.blockId);if(!r)return!1;const i=s(r);if(n.anchor.offset!==i)return!1;if(!function(t,e){const n=t.getBlock(e.tableId);if(!n||"table"!==n.type)return!1;const o=V(n).cells;return o[o.length-1]?.cell.id===e.cellId}(e,o))return!1;const l=tt(e,o.cellId);return n.anchor.blockId===l&&he(t,o.tableId)})}(t),ArrowDown:()=>function(t){return se(t,(e,n,o)=>{const r=tt(e,o.cellId);return n.anchor.blockId===r&&(o.rowEnd>=o.totalRows?ae(t):ue(t,o.tableId,o.rowEnd,o.colIndex))})}(t),ArrowUp:()=>function(t){return se(t,(e,n,o)=>{const r=Q(e,o.cellId);return n.anchor.blockId===r&&!(o.rowIndex<=0)&&ue(t,o.tableId,o.rowIndex-1,o.colIndex)})}(t),ArrowRight:()=>function(t){return se(t,(e,n,o)=>{if(!d(n))return!1;const r=e.getBlock(n.anchor.blockId);if(!r)return!1;const i=s(r);if(n.anchor.offset!==i)return!1;const l=tt(e,o.cellId);return n.anchor.blockId===l&&(de(t,o,1,!1)||!0)})}(t),ArrowLeft:()=>function(t){return se(t,(e,n,o)=>{if(!d(n))return!1;if(0!==n.anchor.offset)return!1;const r=Q(e,o.cellId);return n.anchor.blockId===r&&(de(t,o,-1,!0)||!0)})}(t),Escape:()=>ae(t),"Shift-F10":()=>function(t,e,n){return!t.isReadOnly?.()&&se(t,(o,r,i)=>{const l=t.getContainer(),s=l.querySelector(`[data-block-id="${i.cellId}"]`);if(!s)return!1;const a=s.getBoundingClientRect(),c=new DOMRect(a.left+a.width/2,a.bottom,0,0),d=l.querySelector(`[data-block-id="${i.tableId}"].ntbl-container`)??l;le.get(t)?.close();const u=W(l)??s,h=ie(d,t,i.tableId,c,()=>{le.delete(t)},e,void 0,{sizeTarget:ce(t,i),sizingConfig:n,restoreFocusTo:u});return le.set(t,h),!0})}(t,e,n)},{priority:"context"})}(t,this.locale,this.config),this.registerToolbarItem(t),this.selectionService=function(t){let e=null,n=null,o=[],r=/* @__PURE__ */new Set;function i(){const t=l();if(!t)return o=[],void(r=/* @__PURE__ */new Set);const{grid:e,range:n}=t,i=e.cellsInRange({fromRow:n.fromRow,fromColumn:n.fromCol,toRow:n.toRow,toColumn:n.toCol}).map(t=>t.cell.id);o=i,r=new Set(i)}function l(){if(!e||!n)return null;const o=t.getState().getBlock(e.tableId);if(!o||"table"!==o.type)return s(),null;const r=V(o);return mt(r)!==n?(s(),null):{range:e,grid:r}}function s(){e=null,n=null,o=[],r=/* @__PURE__ */new Set}const a={getSelectedRange:()=>l()?.range??null,setSelectedRange(o){const r=t.getState();let l=null;if(o){const r=t.getState().getBlock(o.tableId),i="table"===r?.type?V(r):null,a=[o.fromRow,o.fromCol,o.toRow,o.toCol],c=i&&a.every(Number.isInteger)&&o.fromRow>=0&&o.toRow>=0&&o.fromCol>=0&&o.toCol>=0&&o.fromRow<i.rowCount&&o.toRow<i.rowCount&&o.fromCol<i.columnCount&&o.toCol<i.columnCount&&i?F(i,{fromRow:o.fromRow,fromColumn:o.fromCol,toRow:o.toRow,toColumn:o.toCol}):null;i&&c?(e={tableId:o.tableId,fromRow:c.fromRow,fromCol:c.fromColumn,toRow:c.toRow,toCol:c.toColumn},n=mt(i),l=i.cellAt(c.fromRow,c.fromColumn)?.cell.id??null):s()}else s();i();const a=h(r.selection)?G(r,r.selection.anchor.blockId):null,c=l&&a?.tableId!==o?.tableId?m(Q(r,l),0):r.selection;t.dispatch(r.transaction("api").setSelection(c).build())},clearSelectionSilent(){s()},getSelectedCellIds:()=>(i(),o),isSelected:t=>(i(),r.has(t))};return t.registerService(bt,a),a}(t),function(t,e={}){const n=wt(e),o={getSelectionSize(){const e=St(t);return e?kt(e):null},setSelectionSize(e){if(t.isReadOnly())return!1;const o=St(t);return!!o&&At(t,o,e,n)},resetSelectionSize(e){if(t.isReadOnly())return!1;const o=St(t);return!!o&&Et(t,o,e,n)},getSize(e){const n=Rt(t.getState(),e);return n?kt(n):null},setSize(e,o){if(t.isReadOnly())return!1;const r=Rt(t.getState(),e);return!!r&&At(t,r,o,n)},resetSize(e,o){if(t.isReadOnly())return!1;const r=Rt(t.getState(),e);return!!r&&Et(t,r,o,n)}};t.registerService(gt,o)}(t,this.config)}onReady(){this.context&&this.selectionService&&(this.cleanupMouseSelection=function(t,e){const n=t.getContainer();let o=null,r=!1;function i(i){if(0!==i.button||t.isReadOnly?.())return;if(!M(i,n))return;const l=i.target.closest("td[data-block-id]");if(!l)return o=null,r=!1,void e.setSelectedRange(null);if(i.shiftKey){if(o){const n=G(t.getState(),l.getAttribute("data-block-id"));if(!n||n.tableId!==o.tableId)return o=null,void e.setSelectedRange(null);i.preventDefault(),e.setSelectedRange(pt(o,n))}}else{e.setSelectedRange(null);const n=G(t.getState(),l.getAttribute("data-block-id"));if(!n)return o=null,void(r=!1);o={tableId:n.tableId,cellId:n.cellId,rowStart:n.rowIndex,rowEnd:n.rowEnd,colStart:n.colIndex,colEnd:n.colEnd},r=!0}}function l(n){if(t.isReadOnly?.()||!r||!o)return;const i=n.target.closest("td[data-block-id]");if(!i)return;const l=G(t.getState(),i.getAttribute("data-block-id"));l&&l.tableId===o.tableId&&l.cellId!==o.cellId&&(n.preventDefault(),e.setSelectedRange(pt(o,l)))}function s(){r=!1}return n.addEventListener("mousedown",i),n.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{n.removeEventListener("mousedown",i),n.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}}(this.context,this.selectionService),this.cleanupClipboard=function(t,e){const i=t.getContainer(),l=n=>{M(n,i)&&ut(n,t,e)},s=l=>{M(l,i)&&(t.isReadOnly?.()||ut(l,t,e)&&function(t,e){const i=e.getSelectedRange();if(!i)return;const l=t.getState(),s=l.getBlock(i.tableId);if(!s||"table"!==s.type)return;const c=V(s).cellsInRange({fromRow:i.fromRow,fromColumn:i.fromCol,toRow:i.toRow,toColumn:i.toCol});if(0===c.length)return;const d=l.transaction("input");let u=null;for(const h of c){const t=l.getNodePath(h.cell.id);if(!t)return;for(let o=n(h.cell).length-1;o>=0;o--)d.removeNode(t,o);const e=o(),i=a(f("paragraph"),[r("")],e);d.insertNode(t,0,i),u??=e}u&&(d.setSelection(m(u,0)),t.dispatch(d.build()),e.clearSelectionSilent())}(t,e))};return i.addEventListener("copy",l,!0),i.addEventListener("cut",s,!0),()=>{i.removeEventListener("copy",l,!0),i.removeEventListener("cut",s,!0)}}(this.context,this.selectionService))}destroy(){this.context&&re(this.context),this.cleanupMouseSelection?.(),this.cleanupMouseSelection=null,this.cleanupClipboard?.(),this.cleanupClipboard=null,this.selectionService=null,this.controls.clear(),this.context=null}onReadOnlyChange(t){for(const e of this.controls)e.setReadOnly(t);t&&this.context&&re(this.context)}decorations(t){if(!this.selectionService)return k.empty;if(!this.selectionService.getSelectedRange())return k.empty;const e=t.selection;if(!h(e)||!et(t,e.anchor.blockId))return this.selectionService.clearSelectionSilent(),k.empty;const n=this.selectionService.getSelectedCellIds();if(0===n.length)return k.empty;const o=[];for(const r of n)o.push(I(r,{class:"notectl-table-cell--selected"}));return k.create(o)}registerNodeSpecs(e){const n=this.config;e.registerNodeSpec({type:"table",attrs:{columnWidthsPx:{allowArray:!0}},group:"block",content:{allow:["table_row"],min:1},isolating:!0,selectable:!0,normalizeAttrs:t=>function(t,e){const n=De(t.attrs,["borderColor","columnWidthsPx"]),o=t.attrs?.borderColor;("none"===o||"string"==typeof o&&O(o))&&(n.borderColor=o);const r=V(t),i=t.attrs?.columnWidthsPx;if(Array.isArray(i)&&r.columnCount>0){const t=Array.from({length:r.columnCount},(t,n)=>{const o=x(i[n]);return void 0===o?null:Math.min(e.maxColumnWidthPx,Math.max(e.minColumnWidthPx,o))});t.some(t=>null!==t)&&(n.columnWidthsPx=Object.freeze(t))}return Object.keys(n).length>0?n:void 0}(t,this.config),normalizeNode:Te,transformSelectionSlice:K,toDOM(t){const e=document.createElement("div");return e.className="notectl-table-wrapper",e.setAttribute("data-block-id",t.id),e.setAttribute("part","table"),e},toHTML(e,o,r){const i=e.attrs?.borderColor,l=xt(e,V(e).columnCount),s=function(e,n,o){const r=n.reduce((t,e)=>t+(e??o),0),i=`border-collapse: collapse; table-layout: fixed; ${n.length>0&&n.every(t=>null!==t)?`width: ${String(r)}px`:"width: 100%"}; min-width: ${String(r)}px`;return e?"none"===e?`${i}; --ntbl-bc: transparent`:O(e)?`${i}; --ntbl-bc: ${t(e)}`:i:i}(i,l,n.minColumnWidthPx);return`<table${r?.styleAttr(s)??` style="${s}"`}><colgroup>${l.map(t=>null===t?"<col>":`<col${y(S,"width",t,r)}>`).join("")}</colgroup><tbody>${o}</tbody></table>`},sanitize:{tags:["table","colgroup","col","thead","tbody","tfoot"],attrs:[S,"width","span"]}}),e.registerNodeSpec({type:"table_row",group:"table_content",content:{allow:["table_cell"],min:0},normalizeAttrs:t=>function(t,e){const n=De(t.attrs,["minHeightPx"]),o=x(t.attrs?.minHeightPx);return void 0!==o&&(n.minHeightPx=Math.min(e.maxRowHeightPx,Math.max(e.minRowHeightPx,o))),Object.keys(n).length>0?n:void 0}(t,this.config),toDOM(t){const e=document.createElement("tr");return e.setAttribute("data-block-id",t.id),e.setAttribute("role","row"),e.setAttribute("part","table-row"),e},toHTML:(t,e,n)=>`<tr${y(R,"height",t.attrs?.minHeightPx,n)}>${e}</tr>`,sanitize:{tags:["tr"],attrs:[R,"height"]}}),e.registerNodeSpec({type:"table_cell",group:"table_content",content:{allow:["paragraph","list_item","heading","blockquote","image","video","horizontal_rule"],min:1},isolating:!0,normalizeAttrs:$e,toDOM(t){const e=document.createElement("td");return e.setAttribute("data-block-id",t.id),e.setAttribute("role","cell"),e.setAttribute("part","table-cell"),e},toHTML(t,e,n){const o=t.attrs?.colspan??1,r=t.attrs?.rowspan??1,i=[n?.styleAttr(Be)??` style="${Be}"`];return o>1&&i.push(` colspan="${o}"`),r>1&&i.push(` rowspan="${r}"`),`<td${i.join("")}>${e}</td>`},sanitize:{tags:["td","th"],attrs:["colspan","rowspan"]}})}registerNodeViews(t){t.getSchemaRegistry(),t.registerNodeView("table",function(t,e,o=nt,r=ze,i={}){return(t,l,s)=>{let a=t;const d=document.createElement("div");d.className="ntbl-container",d.setAttribute("data-block-id",t.id),d.setAttribute("data-selectable","true");const u=document.createElement("div");u.className="notectl-table-wrapper",u.setAttribute("part","table");const h=document.createElement("table");h.className="notectl-table",h.setAttribute("role","table");const b=document.createElement("colgroup");b.className="notectl-table-columns",h.appendChild(b);const m=n(t).length,p=V(t).columnCount;h.setAttribute("aria-label",o.tableAriaLabel(m,p)),h.setAttribute("aria-description",o.tableAriaDescription);const f=document.createElement("tbody");h.appendChild(f),u.appendChild(h),d.appendChild(u),Ie(h,t.attrs?.borderColor),ke(h,b,t,r);const g=document.createElement("div");g.className="notectl-sr-only",g.setAttribute("aria-live","polite"),g.setAttribute("aria-atomic","true"),d.appendChild(g);const w=function(t,e,n,o,r,i,l,s){return new Re(t,e,n,o,r,i,l,s)}(d,h,t,l,s,e,o,r);w.setReadOnly(e?.isReadOnly?.()??!1),i.onControlsCreated?.(w);let x=!1;const v=requestAnimationFrame(()=>{x||(Ie(h,a.attrs?.borderColor),ke(h,b,a,r),Ee(f,a))});let C=null,y=t.id;const S=t=>{if(!e||e.isReadOnly?.())return;t.preventDefault(),t.stopPropagation(),C?.close();const n=new DOMRect(t.clientX,t.clientY,0,0),i=t.target?.closest("td[data-block-id]"),l=i?.getAttribute("data-block-id"),s=l?G(e.getState(),l):null,a=!!l&&(e.getService?.(bt)?.isSelected(l)??!1),c=W(d)??(i instanceof HTMLElement?i:null);C=ie(d,e,y,n,()=>{C=null},o,void 0,{sizeTarget:s&&!a?{kind:"cell",tableId:s.tableId,row:s.rowIndex,column:s.colIndex}:void 0,sizingConfig:r,restoreFocusTo:c})};return h.addEventListener("contextmenu",S),{dom:d,contentDOM:f,update(t){if("table"!==t.type)return!1;if(!function(t,e){if(t.id!==e.id||t.htmlId!==e.htmlId)return!1;if(!c(Pe(t.attrs),Pe(e.attrs)))return!1;const o=n(t),r=n(e);return o.length===r.length&&o.every((t,e)=>{const n=r[e];return void 0!==n&&t.id===n.id&&t.htmlId===n.htmlId&&t.children===n.children&&c(Le(t.attrs),Le(n.attrs))})}(a,t))return!1;y=t.id,d.setAttribute("data-block-id",t.id),d.setAttribute("data-selectable","true");const e=n(t).length,i=V(t).columnCount;return h.setAttribute("aria-label",o.tableAriaLabel(e,i)),Ie(h,t.attrs?.borderColor),ke(h,b,t,r),Ee(f,t),w.update(t),a=t,!0},destroy(){x=!0,cancelAnimationFrame(v),C?.destroy(),h.removeEventListener("contextmenu",S),i.onControlsDestroyed?.(w),w.destroy()},selectNode(){d.classList.add("notectl-table--selected")},deselectNode(){d.classList.remove("notectl-table--selected")}}}}(0,t,this.locale,this.config,{onControlsCreated:t=>{this.controls.add(t)},onControlsDestroyed:t=>{this.controls.delete(t)}})),t.registerNodeView("table_row",(t,e,n)=>{let o=t;const r=document.createElement("tr");r.setAttribute("data-block-id",t.id),r.setAttribute("role","row"),r.setAttribute("part","table-row"),Ae(r,t);let i=!1;const l=requestAnimationFrame(()=>{i||Ae(r,o)});return{dom:r,contentDOM:r,update:t=>"table_row"===t.type&&t.children===o.children&&(r.setAttribute("data-block-id",t.id),Ae(r,t),o=t,!0),destroy(){i=!0,cancelAnimationFrame(l)}}}),t.registerNodeView("table_cell",(t,e,n)=>{const o=document.createElement("td");o.setAttribute("data-block-id",t.id),o.setAttribute("role","cell"),o.setAttribute("part","table-cell");const r=t.attrs?.colspan??1,i=t.attrs?.rowspan??1;r>1&&(o.colSpan=r),i>1&&(o.rowSpan=i);const l=t.attrs?.align;return l&&"left"!==l&&B(o,"textAlign",l),{dom:o,contentDOM:o,update(t){if("table_cell"!==t.type)return!1;o.setAttribute("data-block-id",t.id);const e=t.attrs?.colspan??1,n=t.attrs?.rowspan??1;return e>1?o.colSpan=e:o.removeAttribute("colspan"),n>1?o.rowSpan=n:o.removeAttribute("rowspan"),!1},destroy(){}}})}registerToolbarItem(t){const e=this.config.maxPickerRows??8,n=this.config.maxPickerCols??8;t.registerToolbarItem({id:"table",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 3h18v18H3V3zm2 2v4h6V5H5zm8 0v4h6V5h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6z"/></svg>',label:this.locale.insertTable,tooltip:this.locale.insertTable,command:"insertTable",popupType:"gridPicker",popupConfig:{maxRows:e,maxCols:n,onSelect:(e,n)=>{jt(t,e,n)}},isActive:t=>!!h(t.selection)&&et(t,t.selection.anchor.blockId)})}};function Ne(t,e){return"number"==typeof t&&Number.isInteger(t)&&t>0?Math.min(t,100):e}function $e(t){const e=De(t.attrs,["colspan","rowspan"]),n=q(t.attrs?.colspan),o=q(t.attrs?.rowspan);return n>1&&(e.colspan=n),o>1&&(e.rowspan=o),Object.keys(e).length>0?e:void 0}function Te(t){const e=n(t);let o=!1;const r=e.map((t,r)=>{let i=!1;const l=n(t).map(t=>{const n=q(t.attrs?.rowspan),o=Math.min(n,e.length-r);if(o===n)return t;i=!0;const{rowspan:l,...s}=t.attrs??{},a={...s,...o>1?{rowspan:o}:{}},{attrs:c,...d}=t;return Object.keys(a).length>0?{...d,attrs:a}:d});return i?(o=!0,{...t,children:l}):t});return o?{...t,children:r}:t}function De(t,e){const n={};for(const[o,r]of Object.entries(t??{})){if(e.includes(o))continue;const t=We(r);void 0!==t&&(n[o]=t)}return n}function We(t){if("string"==typeof t||"boolean"==typeof t)return t;if("number"==typeof t)return Number.isFinite(t)?t:void 0;if(!Array.isArray(t))return;const e=[];for(const n of t)if(null===n||"string"==typeof n||"boolean"==typeof n)e.push(n);else{if("number"!=typeof n||!Number.isFinite(n))return;e.push(n)}return Object.freeze(e)}export{nt as a,bt as i,ft as n,rt as o,gt as r,He as t};
2
+ //# sourceMappingURL=TablePlugin-CdXY0Px5.mjs.map