@notectl/core 2.2.5 → 2.2.6

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 (92) hide show
  1. package/dist/chunks/{AlignmentPlugin-BCHxo16v.mjs → AlignmentPlugin-DeD4C4EP.mjs} +2 -2
  2. package/dist/chunks/{AlignmentPlugin-BCHxo16v.mjs.map → AlignmentPlugin-DeD4C4EP.mjs.map} +1 -1
  3. package/dist/chunks/{CodeBlockPlugin-DC0-BnNy.mjs → CodeBlockPlugin-3V2K3RBe.mjs} +2 -2
  4. package/dist/chunks/{CodeBlockPlugin-DC0-BnNy.mjs.map → CodeBlockPlugin-3V2K3RBe.mjs.map} +1 -1
  5. package/dist/chunks/{ColorGrid-CXRdpP_n.mjs → ColorGrid-DPNiXxpD.mjs} +2 -2
  6. package/dist/chunks/{ColorGrid-CXRdpP_n.mjs.map → ColorGrid-DPNiXxpD.mjs.map} +1 -1
  7. package/dist/chunks/{ColorPickerPopup-C_74bqid.mjs → ColorPickerPopup-lcf3jS6G.mjs} +2 -2
  8. package/dist/chunks/{ColorPickerPopup-C_74bqid.mjs.map → ColorPickerPopup-lcf3jS6G.mjs.map} +1 -1
  9. package/dist/chunks/FontPlugin-DQMj65Bc.mjs +2 -0
  10. package/dist/chunks/{FontPlugin-DB1_bgam.mjs.map → FontPlugin-DQMj65Bc.mjs.map} +1 -1
  11. package/dist/chunks/{FontSizePlugin-DFvp7Ki9.mjs → FontSizePlugin-9StCjEfN.mjs} +2 -2
  12. package/dist/chunks/{FontSizePlugin-DFvp7Ki9.mjs.map → FontSizePlugin-9StCjEfN.mjs.map} +1 -1
  13. package/dist/chunks/{FormulaPlugin-BLEcyazj.mjs → FormulaPlugin-CV5VUxkb.mjs} +2 -2
  14. package/dist/chunks/{FormulaPlugin-BLEcyazj.mjs.map → FormulaPlugin-CV5VUxkb.mjs.map} +1 -1
  15. package/dist/chunks/{HeadingPlugin-D9yvG2Aw.mjs → HeadingPlugin-BuGoM9Rz.mjs} +2 -2
  16. package/dist/chunks/{HeadingPlugin-D9yvG2Aw.mjs.map → HeadingPlugin-BuGoM9Rz.mjs.map} +1 -1
  17. package/dist/chunks/{HighlightPlugin-D4gh4RP7.mjs → HighlightPlugin-C6pHifVz.mjs} +2 -2
  18. package/dist/chunks/{HighlightPlugin-D4gh4RP7.mjs.map → HighlightPlugin-C6pHifVz.mjs.map} +1 -1
  19. package/dist/chunks/{ImagePlugin-Cp_RINtc.mjs → ImagePlugin-KpkuE2LH.mjs} +2 -2
  20. package/dist/chunks/{ImagePlugin-Cp_RINtc.mjs.map → ImagePlugin-KpkuE2LH.mjs.map} +1 -1
  21. package/dist/chunks/{InlineStyleMarkSpec-4R6DC7ij.mjs → InlineStyleMarkSpec-C6LJT7kp.mjs} +2 -2
  22. package/dist/chunks/{InlineStyleMarkSpec-4R6DC7ij.mjs.map → InlineStyleMarkSpec-C6LJT7kp.mjs.map} +1 -1
  23. package/dist/chunks/{ListPlugin-CVId2dE0.mjs → ListPlugin-2yl6KiTK.mjs} +2 -2
  24. package/dist/chunks/{ListPlugin-CVId2dE0.mjs.map → ListPlugin-2yl6KiTK.mjs.map} +1 -1
  25. package/dist/chunks/{PopupManager-CyOfZUab.mjs → PopupManager-DUtaK3WX.mjs} +2 -2
  26. package/dist/chunks/{PopupManager-CyOfZUab.mjs.map → PopupManager-DUtaK3WX.mjs.map} +1 -1
  27. package/dist/chunks/{PopupPositioning-DtUrY9bh.mjs → PopupPositioning-BB97-__N.mjs} +2 -2
  28. package/dist/chunks/{PopupPositioning-DtUrY9bh.mjs.map → PopupPositioning-BB97-__N.mjs.map} +1 -1
  29. package/dist/chunks/PrintPlugin-DyIZDY3Q.mjs +2 -0
  30. package/dist/chunks/PrintPlugin-DyIZDY3Q.mjs.map +1 -0
  31. package/dist/chunks/{PrintTypes-WdtgSj74.mjs → PrintTypes-CxU69qu3.mjs} +3 -2
  32. package/dist/chunks/PrintTypes-CxU69qu3.mjs.map +1 -0
  33. package/dist/chunks/StyleRuntime-BFKu52mS.mjs +2 -0
  34. package/dist/chunks/StyleRuntime-BFKu52mS.mjs.map +1 -0
  35. package/dist/chunks/{TablePlugin-D93RR5xH.mjs → TablePlugin-BTH9VRZq.mjs} +2 -2
  36. package/dist/chunks/{TablePlugin-D93RR5xH.mjs.map → TablePlugin-BTH9VRZq.mjs.map} +1 -1
  37. package/dist/chunks/{TextColorPlugin-C1qpzEOa.mjs → TextColorPlugin-CEfZQ6Md.mjs} +2 -2
  38. package/dist/chunks/{TextColorPlugin-C1qpzEOa.mjs.map → TextColorPlugin-CEfZQ6Md.mjs.map} +1 -1
  39. package/dist/chunks/{ToolbarPlugin-CLz2wa2c.mjs → ToolbarPlugin-DVGrFf8v.mjs} +2 -2
  40. package/dist/chunks/{ToolbarPlugin-CLz2wa2c.mjs.map → ToolbarPlugin-DVGrFf8v.mjs.map} +1 -1
  41. package/dist/chunks/{VideoPlugin-D9rQZol6.mjs → VideoPlugin-B3uf1Dwp.mjs} +2 -2
  42. package/dist/chunks/{VideoPlugin-D9rQZol6.mjs.map → VideoPlugin-B3uf1Dwp.mjs.map} +1 -1
  43. package/dist/chunks/{full-Cah3qjCT.mjs → full-BBl7mvwH.mjs} +2 -2
  44. package/dist/chunks/{full-Cah3qjCT.mjs.map → full-BBl7mvwH.mjs.map} +1 -1
  45. package/dist/chunks/minimal-CtnR4dqp.mjs +2 -0
  46. package/dist/chunks/{minimal-DqATlnAL.mjs.map → minimal-CtnR4dqp.mjs.map} +1 -1
  47. package/dist/chunks/src-C89Cw7ni.mjs +2 -0
  48. package/dist/chunks/{src-YY6n2SmV.mjs.map → src-C89Cw7ni.mjs.map} +1 -1
  49. package/dist/editor/NotectlEditor.d.ts +22 -3
  50. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  51. package/dist/full.mjs +1 -1
  52. package/dist/notectl-core.mjs +1 -1
  53. package/dist/notectl-core.umd.js +1 -1
  54. package/dist/notectl-core.umd.js.map +1 -1
  55. package/dist/plugins/alignment.mjs +1 -1
  56. package/dist/plugins/code-block.mjs +1 -1
  57. package/dist/plugins/font-size.mjs +1 -1
  58. package/dist/plugins/font.mjs +1 -1
  59. package/dist/plugins/formula.mjs +1 -1
  60. package/dist/plugins/heading.mjs +1 -1
  61. package/dist/plugins/highlight.mjs +1 -1
  62. package/dist/plugins/image.mjs +1 -1
  63. package/dist/plugins/list.mjs +1 -1
  64. package/dist/plugins/print/PrintHostStyles.d.ts +50 -0
  65. package/dist/plugins/print/PrintHostStyles.d.ts.map +1 -0
  66. package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
  67. package/dist/plugins/print/PrintServiceImpl.d.ts +72 -3
  68. package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -1
  69. package/dist/plugins/print/PrintStyleCollector.d.ts +150 -21
  70. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
  71. package/dist/plugins/print/StaticHostMarker.d.ts +18 -0
  72. package/dist/plugins/print/StaticHostMarker.d.ts.map +1 -0
  73. package/dist/plugins/print.mjs +1 -1
  74. package/dist/plugins/shared.mjs +1 -1
  75. package/dist/plugins/table.mjs +1 -1
  76. package/dist/plugins/text-color.mjs +1 -1
  77. package/dist/plugins/toolbar.mjs +1 -1
  78. package/dist/plugins/video.mjs +1 -1
  79. package/dist/presets/full.mjs +1 -1
  80. package/dist/presets/minimal.mjs +1 -1
  81. package/dist/presets.mjs +1 -1
  82. package/dist/style/StyleRuntime.d.ts +7 -0
  83. package/dist/style/StyleRuntime.d.ts.map +1 -1
  84. package/package.json +1 -1
  85. package/dist/chunks/FontPlugin-DB1_bgam.mjs +0 -2
  86. package/dist/chunks/PrintPlugin-C6gOJT6d.mjs +0 -2
  87. package/dist/chunks/PrintPlugin-C6gOJT6d.mjs.map +0 -1
  88. package/dist/chunks/PrintTypes-WdtgSj74.mjs.map +0 -1
  89. package/dist/chunks/StyleRuntime-BAutwDZT.mjs +0 -2
  90. package/dist/chunks/StyleRuntime-BAutwDZT.mjs.map +0 -1
  91. package/dist/chunks/minimal-DqATlnAL.mjs +0 -2
  92. package/dist/chunks/src-YY6n2SmV.mjs +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ListPlugin-CVId2dE0.mjs","names":[],"sources":["../../src/editor/styles/list.ts","../../src/plugins/list/ListAttrsFactory.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/* 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 * 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 { 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 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: true,\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\tif (block.type === 'list_item' && block.attrs?.listType === listType) {\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(sel.anchor.blockId, nodeType('paragraph'))\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst existingIndent: number = isNodeOfType(block, 'list_item') ? block.attrs.indent : 0;\n\tconst attrs = buildListItemAttrs(listType, existingIndent);\n\n\tconst tr = state\n\t\t.transaction('command')\n\t\t.setBlockType(sel.anchor.blockId, 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\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = state.getBlock(bid);\n\t\tif (!block) return;\n\n\t\tif (toggleOff) {\n\t\t\tbuilder.setBlockType(bid, nodeType('paragraph'));\n\t\t} else {\n\t\t\tconst existingIndent: number = isNodeOfType(block, 'list_item') ? block.attrs.indent : 0;\n\t\t\tconst existingChecked: boolean =\n\t\t\t\tisNodeOfType(block, 'list_item') &&\n\t\t\t\tblock.attrs.listType === 'checklist' &&\n\t\t\t\tblock.attrs.checked;\n\t\t\tbuilder.setBlockType(\n\t\t\t\tbid,\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// --- 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 = state.getBlock(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(sel.anchor.blockId, 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\n\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = state.getBlock(bid);\n\t\tif (!block || !isNodeOfType(block, 'list_item')) return;\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\tbid,\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 = state.getBlock(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 tr = state\n\t\t.transaction('command')\n\t\t.setBlockType(bid, nodeType('list_item'), attrs)\n\t\t.setSelection(state.selection)\n\t\t.build();\n\tcontext.dispatch(tr);\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/** Checks whether all blocks in a range are list items of the given type. Exported for toolbar. */\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 = state.getBlock(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\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 * Handles Enter (split/exit list) and Backspace (convert to paragraph).\n */\n\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockText } 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';\n\n// --- Context Guard ---\n\ninterface ListContext {\n\treadonly state: EditorState;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection, non-collapsed selections, and non-list blocks.\n * Returns false (not handled) if the cursor is not inside a list_item block.\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 || block.type !== 'list_item') return false;\n\n\treturn handler({\n\t\tstate,\n\t\tblock,\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 * Empty item → exit list (convert to paragraph).\n * Non-empty item → split and create a new list item with the same type.\n */\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withListContext(context, (ctx) => {\n\t\tconst text: string = getBlockText(ctx.block);\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.block, 'list_item') ? ctx.block.attrs.listType : 'bullet';\n\t\tconst indent: number = isNodeOfType(ctx.block, 'list_item') ? ctx.block.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// --- Backspace Handler ---\n\n/**\n * Handles Backspace at the start of a list item.\n * Converts the list item back to a paragraph, preserving text.\n */\nfunction handleBackspace(context: PluginContext): boolean {\n\treturn withListContext(context, (ctx) => {\n\t\tif (ctx.offset !== 0) return false;\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 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\tconst block = state.getBlock(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 * List items are modeled as flat blocks with a `listType` and `indent` attribute,\n * allowing simple nesting representation without deep tree structures.\n */\n\nimport { LIST_CSS, LIST_MARKER_WIDTH } from '../../editor/styles/list.js';\nimport { blockId } from '../../model/TypeBrands.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/**\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\tregisterListInputRules(context, enabledTypes);\n\t\tregisterListToolbarItems(context, enabledTypes, this.locale);\n\t\tthis.registerCheckboxClickHandler(context);\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\tcontent: { allow: ['text'] },\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":"+ZCSA,SAAgB,EACf,EACA,EACA,GAEA,MAAiB,cAAb,EACI,CAAE,WAAU,SAAQ,QAAS,IAAW,GAEzC,CAAE,WAAU,SACpB,CCwCA,SAAS,EAAW,EAAwB,GAC3C,MAAM,EAAqB,EAAQ,WAC7B,EAAM,EAAM,UAClB,QAAK,EAAgB,KAEjB,EAAI,OAAO,UAAY,EAAI,KAAK,QAsCrC,SAAyB,EAAwB,EAAoB,GACpE,MAAM,EAAM,EAAM,UAClB,IAAK,EAAgB,GAAM,OAAO,EAElC,MAAM,EAAQ,EAAe,EAAK,EAAM,iBAClC,EAAqB,EAAuB,EAAO,EAAO,GAC1D,EAAU,EAAM,YAAY,WAwBlC,OAtBA,EAAsB,EAAO,EAAQ,IACpC,MAAM,EAAQ,EAAM,SAAS,GAC7B,GAAK,EAEL,GAAI,EACH,EAAQ,aAAa,EAAK,EAAS,kBAC7B,CACN,MAAM,EAAyB,EAAa,EAAO,aAAe,EAAM,MAAM,OAAS,EACjF,EACL,EAAa,EAAO,cACK,cAAzB,EAAM,MAAM,UACZ,EAAM,MAAM,QACb,EAAQ,aACP,EACA,EAAS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vC,CACR,EACA,OAAA,CAAQ,GACP,MAAM,EAAW,EAAK,OAAO,UAAY,SAEzC,MAAO,CACN,IAFwB,YAAb,EAAyB,KAAO,KAG3C,IAAK,QAAQ,IACb,UAAW,8BAA8B,IACzC,MAAO,CAAE,KAAM,QAEjB,EACA,MAAA,CAAO,EAAM,GACZ,MAAM,EAAoB,EAAK,OAAO,UAAuB,SACvD,EAAoB,EAAK,OAAO,UAAuB,EAE7D,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,4BAAA,CAAqC,GAC/B,KAAK,OAAO,MAAM,SAAS,eAEhC,KAAK,qBAAwB,IAC5B,GAAI,EAAQ,eAAiB,KAAK,OAAO,sBAAuB,OAEhE,MAAM,EAA6B,EAAE,OACrC,KAAM,aAAkB,aAAc,OAItC,MAAM,EAAyB,EAAO,QAAQ,IAAI,KAClD,IAAK,EAAQ,OAEb,MAAM,EAAqB,EAAO,QAAQ,iCAC1C,IAAK,EAAI,OAET,EAAE,iBAEF,MAAM,EAAqB,EAAG,aAAa,iBACtC,GAEL,EAAc,EAAS,CACtB,sBAAuB,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-2yl6KiTK.mjs","names":[],"sources":["../../src/editor/styles/list.ts","../../src/plugins/list/ListAttrsFactory.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/* 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 * 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 { 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 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: true,\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\tif (block.type === 'list_item' && block.attrs?.listType === listType) {\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(sel.anchor.blockId, nodeType('paragraph'))\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst existingIndent: number = isNodeOfType(block, 'list_item') ? block.attrs.indent : 0;\n\tconst attrs = buildListItemAttrs(listType, existingIndent);\n\n\tconst tr = state\n\t\t.transaction('command')\n\t\t.setBlockType(sel.anchor.blockId, 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\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = state.getBlock(bid);\n\t\tif (!block) return;\n\n\t\tif (toggleOff) {\n\t\t\tbuilder.setBlockType(bid, nodeType('paragraph'));\n\t\t} else {\n\t\t\tconst existingIndent: number = isNodeOfType(block, 'list_item') ? block.attrs.indent : 0;\n\t\t\tconst existingChecked: boolean =\n\t\t\t\tisNodeOfType(block, 'list_item') &&\n\t\t\t\tblock.attrs.listType === 'checklist' &&\n\t\t\t\tblock.attrs.checked;\n\t\t\tbuilder.setBlockType(\n\t\t\t\tbid,\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// --- 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 = state.getBlock(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(sel.anchor.blockId, 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\n\tforEachBlockIdInRange(state, range, (bid: BlockId) => {\n\t\tconst block = state.getBlock(bid);\n\t\tif (!block || !isNodeOfType(block, 'list_item')) return;\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\tbid,\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 = state.getBlock(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 tr = state\n\t\t.transaction('command')\n\t\t.setBlockType(bid, nodeType('list_item'), attrs)\n\t\t.setSelection(state.selection)\n\t\t.build();\n\tcontext.dispatch(tr);\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/** Checks whether all blocks in a range are list items of the given type. Exported for toolbar. */\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 = state.getBlock(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\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 * Handles Enter (split/exit list) and Backspace (convert to paragraph).\n */\n\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockText } 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';\n\n// --- Context Guard ---\n\ninterface ListContext {\n\treadonly state: EditorState;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection, non-collapsed selections, and non-list blocks.\n * Returns false (not handled) if the cursor is not inside a list_item block.\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 || block.type !== 'list_item') return false;\n\n\treturn handler({\n\t\tstate,\n\t\tblock,\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 * Empty item → exit list (convert to paragraph).\n * Non-empty item → split and create a new list item with the same type.\n */\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withListContext(context, (ctx) => {\n\t\tconst text: string = getBlockText(ctx.block);\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.block, 'list_item') ? ctx.block.attrs.listType : 'bullet';\n\t\tconst indent: number = isNodeOfType(ctx.block, 'list_item') ? ctx.block.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// --- Backspace Handler ---\n\n/**\n * Handles Backspace at the start of a list item.\n * Converts the list item back to a paragraph, preserving text.\n */\nfunction handleBackspace(context: PluginContext): boolean {\n\treturn withListContext(context, (ctx) => {\n\t\tif (ctx.offset !== 0) return false;\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 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\tconst block = state.getBlock(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 * List items are modeled as flat blocks with a `listType` and `indent` attribute,\n * allowing simple nesting representation without deep tree structures.\n */\n\nimport { LIST_CSS, LIST_MARKER_WIDTH } from '../../editor/styles/list.js';\nimport { blockId } from '../../model/TypeBrands.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/**\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\tregisterListInputRules(context, enabledTypes);\n\t\tregisterListToolbarItems(context, enabledTypes, this.locale);\n\t\tthis.registerCheckboxClickHandler(context);\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\tcontent: { allow: ['text'] },\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":"+ZCSA,SAAgB,EACf,EACA,EACA,GAEA,MAAiB,cAAb,EACI,CAAE,WAAU,SAAQ,QAAS,IAAW,GAEzC,CAAE,WAAU,SACpB,CCwCA,SAAS,EAAW,EAAwB,GAC3C,MAAM,EAAqB,EAAQ,WAC7B,EAAM,EAAM,UAClB,QAAK,EAAgB,KAEjB,EAAI,OAAO,UAAY,EAAI,KAAK,QAsCrC,SAAyB,EAAwB,EAAoB,GACpE,MAAM,EAAM,EAAM,UAClB,IAAK,EAAgB,GAAM,OAAO,EAElC,MAAM,EAAQ,EAAe,EAAK,EAAM,iBAClC,EAAqB,EAAuB,EAAO,EAAO,GAC1D,EAAU,EAAM,YAAY,WAwBlC,OAtBA,EAAsB,EAAO,EAAQ,IACpC,MAAM,EAAQ,EAAM,SAAS,GAC7B,GAAK,EAEL,GAAI,EACH,EAAQ,aAAa,EAAK,EAAS,kBAC7B,CACN,MAAM,EAAyB,EAAa,EAAO,aAAe,EAAM,MAAM,OAAS,EACjF,EACL,EAAa,EAAO,cACK,cAAzB,EAAM,MAAM,UACZ,EAAM,MAAM,QACb,EAAQ,aACP,EACA,EAAS,aACT,EAAmB,EAAU,EAAgB,GAE/C,IAGD,EAAQ,aAAa,GACrB,EAAQ,SAAS,EAAQ,UAClB,CACR,CApES,CAAgB,EAAS,EAAO,GAKzC,SACC,EACA,EACA,GAEA,MAAM,EAAM,EAAM,UAClB,IAAK,EAAgB,GAAM,OAAO,EAClC,MAAM,EAAQ,EAAM,SAAS,EAAI,OAAO,SACxC,IAAK,EAAO,OAAO,EAEnB,GAAmB,cAAf,E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AiB,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,4BAAA,CAAqC,GAC/B,KAAK,OAAO,MAAM,SAAS,eAEhC,KAAK,qBAAwB,IAC5B,GAAI,EAAQ,eAAiB,KAAK,OAAO,sBAAuB,OAEhE,MAAM,EAA6B,EAAE,OACrC,KAAM,aAAkB,aAAc,OAItC,MAAM,EAAyB,EAAO,QAAQ,IAAI,KAClD,IAAK,EAAQ,OAEb,MAAM,EAAqB,EAAO,QAAQ,iCAC1C,IAAK,EAAI,OAET,EAAE,iBAEF,MAAM,EAAqB,EAAG,aAAa,iBACtC,GAEL,EAAc,EAAS,CACtB,sBAAuB,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,2 +1,2 @@
1
- import{i as e}from"./Platform-ByobkiCc.mjs";import{n as t}from"./TypedKeys-CA4bfw9O.mjs";import{i as s,r as n,t as o}from"./PopupPositioning-DtUrY9bh.mjs";var r=new t("popup"),i=class{stack=[];referenceNode;constructor(e){this.referenceNode=e}open(e){const t=document.createElement("div");t.className=e.className?`notectl-popup ${e.className}`:"notectl-popup",e.ariaRole&&t.setAttribute("role",e.ariaRole),e.ariaLabel&&t.setAttribute("aria-label",e.ariaLabel);const r=e.parent?this.findEntryByHandle(e.parent):null;let i;const c={close:e=>this.closeEntry(i,e),getElement:()=>t},l=s=>{const n=s.composedPath();if(!n.includes(t)){for(const e of this.stack)if(n.includes(e.element))return;e.anchor instanceof HTMLElement&&n.includes(e.anchor)||this.closeEntry(i)}};i={element:t,config:e,clickOutsideHandler:l,parent:r,listenerRegistrationTimer:null,documentListenerAttached:!1},this.stack.push(i);try{e.content(t,e=>this.closeEntry(i,e))}catch(a){throw this.removeEntry(i),a}return this.stack.includes(i)?(o(t,e.referenceNode??this.referenceNode),s(t),n(t,e.anchor instanceof HTMLElement?e.anchor.getBoundingClientRect():e.anchor,{position:e.position??"below-start",isRtl:this.isRtlContext()}),i.listenerRegistrationTimer=setTimeout(()=>{i.listenerRegistrationTimer=null,this.stack.includes(i)&&(document.addEventListener("mousedown",l),i.documentListenerAttached=!0)},0),this.focusFirstItem(t),c):c}close(){const e=this.stack[this.stack.length-1];e&&this.closeEntry(e)}closeAll(){for(;this.stack.length>0;){const e=this.stack[this.stack.length-1];e&&this.closeEntry(e)}}isOpen(){return this.stack.length>0}destroy(){this.closeAll()}closeEntry(e,t){const s=this.stack.indexOf(e);if(-1!==s){for(;this.stack.length>s+1;){const e=this.stack[this.stack.length-1];e&&this.removeEntry(e)}this.removeEntry(e),void 0!==t&&"restoreFocusTo"in t?t.restoreFocusTo?.focus():e.config.restoreFocusTo&&e.config.restoreFocusTo.focus(),e.config.onClose?.()}}removeEntry(e){const t=this.stack.indexOf(e);-1!==t&&(this.stack.splice(t,1),null!==e.listenerRegistrationTimer&&(clearTimeout(e.listenerRegistrationTimer),e.listenerRegistrationTimer=null),e.element.remove(),e.documentListenerAttached&&(document.removeEventListener("mousedown",e.clickOutsideHandler),e.documentListenerAttached=!1))}findEntryByHandle(e){const t=e.getElement();return this.stack.find(e=>e.element===t)??null}isRtlContext(){return this.referenceNode instanceof HTMLElement&&e(this.referenceNode)}focusFirstItem(e){requestAnimationFrame(()=>{(e.querySelector('[role="menuitem"]')??e.querySelector('[role="option"]')??e.querySelector('[role="gridcell"]')??e.querySelector("input, textarea")??e.querySelector("button"))?.focus()})}};export{r as n,i as t};
2
- //# sourceMappingURL=PopupManager-CyOfZUab.mjs.map
1
+ import{i as e}from"./Platform-ByobkiCc.mjs";import{n as t}from"./TypedKeys-CA4bfw9O.mjs";import{i as s,r as n,t as o}from"./PopupPositioning-BB97-__N.mjs";var r=new t("popup"),i=class{stack=[];referenceNode;constructor(e){this.referenceNode=e}open(e){const t=document.createElement("div");t.className=e.className?`notectl-popup ${e.className}`:"notectl-popup",e.ariaRole&&t.setAttribute("role",e.ariaRole),e.ariaLabel&&t.setAttribute("aria-label",e.ariaLabel);const r=e.parent?this.findEntryByHandle(e.parent):null;let i;const c={close:e=>this.closeEntry(i,e),getElement:()=>t},l=s=>{const n=s.composedPath();if(!n.includes(t)){for(const e of this.stack)if(n.includes(e.element))return;e.anchor instanceof HTMLElement&&n.includes(e.anchor)||this.closeEntry(i)}};i={element:t,config:e,clickOutsideHandler:l,parent:r,listenerRegistrationTimer:null,documentListenerAttached:!1},this.stack.push(i);try{e.content(t,e=>this.closeEntry(i,e))}catch(a){throw this.removeEntry(i),a}return this.stack.includes(i)?(o(t,e.referenceNode??this.referenceNode),s(t),n(t,e.anchor instanceof HTMLElement?e.anchor.getBoundingClientRect():e.anchor,{position:e.position??"below-start",isRtl:this.isRtlContext()}),i.listenerRegistrationTimer=setTimeout(()=>{i.listenerRegistrationTimer=null,this.stack.includes(i)&&(document.addEventListener("mousedown",l),i.documentListenerAttached=!0)},0),this.focusFirstItem(t),c):c}close(){const e=this.stack[this.stack.length-1];e&&this.closeEntry(e)}closeAll(){for(;this.stack.length>0;){const e=this.stack[this.stack.length-1];e&&this.closeEntry(e)}}isOpen(){return this.stack.length>0}destroy(){this.closeAll()}closeEntry(e,t){const s=this.stack.indexOf(e);if(-1!==s){for(;this.stack.length>s+1;){const e=this.stack[this.stack.length-1];e&&this.removeEntry(e)}this.removeEntry(e),void 0!==t&&"restoreFocusTo"in t?t.restoreFocusTo?.focus():e.config.restoreFocusTo&&e.config.restoreFocusTo.focus(),e.config.onClose?.()}}removeEntry(e){const t=this.stack.indexOf(e);-1!==t&&(this.stack.splice(t,1),null!==e.listenerRegistrationTimer&&(clearTimeout(e.listenerRegistrationTimer),e.listenerRegistrationTimer=null),e.element.remove(),e.documentListenerAttached&&(document.removeEventListener("mousedown",e.clickOutsideHandler),e.documentListenerAttached=!1))}findEntryByHandle(e){const t=e.getElement();return this.stack.find(e=>e.element===t)??null}isRtlContext(){return this.referenceNode instanceof HTMLElement&&e(this.referenceNode)}focusFirstItem(e){requestAnimationFrame(()=>{(e.querySelector('[role="menuitem"]')??e.querySelector('[role="option"]')??e.querySelector('[role="gridcell"]')??e.querySelector("input, textarea")??e.querySelector("button"))?.focus()})}};export{r as n,i as t};
2
+ //# sourceMappingURL=PopupManager-DUtaK3WX.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PopupManager-CyOfZUab.mjs","names":[],"sources":["../../src/plugins/shared/PopupManager.ts"],"sourcesContent":["/**\n * Central popup lifecycle manager. Handles creation, positioning,\n * click-outside closing, Escape key, focus restoration, and popup stacking\n * for submenus/nested popups.\n */\n\nimport { isRtlContext } from '../../platform/Platform.js';\nimport { ServiceKey } from '../Plugin.js';\nimport {\n\ttype PopupPosition,\n\tappendToRoot,\n\tpositionPopup,\n\tpromoteToTopLayer,\n} from './PopupPositioning.js';\n\n// --- Types ---\n\n/** Options for overriding focus restoration when closing a popup. */\nexport interface PopupCloseOptions {\n\t/**\n\t * Override the default focus target on close.\n\t * - `HTMLElement` → focus that element instead of `config.restoreFocusTo`\n\t * - `null` → skip focus restoration entirely\n\t * - `undefined` / omitted → use default `config.restoreFocusTo`\n\t */\n\treadonly restoreFocusTo?: HTMLElement | null;\n}\n\nexport interface PopupConfig {\n\treadonly anchor: HTMLElement | DOMRect;\n\treadonly content: (container: HTMLElement, close: (options?: PopupCloseOptions) => void) => void;\n\treadonly className?: string;\n\treadonly ariaRole?: 'menu' | 'listbox' | 'grid' | 'dialog';\n\treadonly ariaLabel?: string;\n\treadonly restoreFocusTo?: HTMLElement;\n\treadonly onClose?: () => void;\n\treadonly position?: PopupPosition;\n\treadonly parent?: PopupHandle;\n\treadonly referenceNode?: Node;\n}\n\nexport interface PopupHandle {\n\tclose(options?: PopupCloseOptions): void;\n\tgetElement(): HTMLElement;\n}\n\nexport interface PopupServiceAPI {\n\topen(config: PopupConfig): PopupHandle;\n\tclose(): void;\n\tcloseAll(): void;\n\tisOpen(): boolean;\n}\n\nexport const PopupServiceKey = new ServiceKey<PopupServiceAPI>('popup');\n\n// --- Internal Entry ---\n\ninterface PopupEntry {\n\treadonly element: HTMLElement;\n\treadonly config: PopupConfig;\n\treadonly clickOutsideHandler: (e: MouseEvent) => void;\n\treadonly parent: PopupEntry | null;\n\tlistenerRegistrationTimer: ReturnType<typeof setTimeout> | null;\n\tdocumentListenerAttached: boolean;\n}\n\n// --- Manager ---\n\nexport class PopupManager implements PopupServiceAPI {\n\tprivate readonly stack: PopupEntry[] = [];\n\tprivate readonly referenceNode: Node;\n\n\tconstructor(referenceNode: Node) {\n\t\tthis.referenceNode = referenceNode;\n\t}\n\n\t/** Opens a popup with the given configuration. Returns a handle for closing it. */\n\topen(config: PopupConfig): PopupHandle {\n\t\tconst popup: HTMLDivElement = document.createElement('div');\n\t\tpopup.className = config.className ? `notectl-popup ${config.className}` : 'notectl-popup';\n\n\t\tif (config.ariaRole) {\n\t\t\tpopup.setAttribute('role', config.ariaRole);\n\t\t}\n\t\tif (config.ariaLabel) {\n\t\t\tpopup.setAttribute('aria-label', config.ariaLabel);\n\t\t}\n\n\t\tconst parentEntry: PopupEntry | null = config.parent\n\t\t\t? this.findEntryByHandle(config.parent)\n\t\t\t: null;\n\n\t\tlet entry!: PopupEntry;\n\t\tconst handle: PopupHandle = {\n\t\t\tclose: (options?: PopupCloseOptions) => this.closeEntry(entry, options),\n\t\t\tgetElement: () => popup,\n\t\t};\n\n\t\tconst clickOutsideHandler = (e: MouseEvent): void => {\n\t\t\tconst path: EventTarget[] = e.composedPath();\n\t\t\tif (path.includes(popup)) return;\n\n\t\t\t// Don't close if click is inside any ancestor popup in the stack\n\t\t\tfor (const stackEntry of this.stack) {\n\t\t\t\tif (path.includes(stackEntry.element)) return;\n\t\t\t}\n\n\t\t\t// Don't close if click is on the anchor element\n\t\t\tif (config.anchor instanceof HTMLElement && path.includes(config.anchor)) return;\n\n\t\t\tthis.closeEntry(entry);\n\t\t};\n\n\t\tentry = {\n\t\t\telement: popup,\n\t\t\tconfig,\n\t\t\tclickOutsideHandler,\n\t\t\tparent: parentEntry,\n\t\t\tlistenerRegistrationTimer: null,\n\t\t\tdocumentListenerAttached: false,\n\t\t};\n\n\t\tthis.stack.push(entry);\n\n\t\ttry {\n\t\t\tconfig.content(popup, (options?: PopupCloseOptions) => this.closeEntry(entry, options));\n\t\t} catch (error) {\n\t\t\tthis.removeEntry(entry);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!this.stack.includes(entry)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\tconst refNode: Node = config.referenceNode ?? this.referenceNode;\n\t\tappendToRoot(popup, refNode);\n\t\t// Promote to the top layer before measuring/positioning so the popup\n\t\t// escapes any ancestor stacking context in the host page.\n\t\tpromoteToTopLayer(popup);\n\n\t\tconst anchorRect: DOMRect =\n\t\t\tconfig.anchor instanceof HTMLElement ? config.anchor.getBoundingClientRect() : config.anchor;\n\t\tpositionPopup(popup, anchorRect, {\n\t\t\tposition: config.position ?? 'below-start',\n\t\t\tisRtl: this.isRtlContext(),\n\t\t});\n\n\t\tentry.listenerRegistrationTimer = setTimeout(() => {\n\t\t\tentry.listenerRegistrationTimer = null;\n\t\t\tif (!this.stack.includes(entry)) return;\n\t\t\tdocument.addEventListener('mousedown', clickOutsideHandler);\n\t\t\tentry.documentListenerAttached = true;\n\t\t}, 0);\n\n\t\tthis.focusFirstItem(popup);\n\n\t\treturn handle;\n\t}\n\n\t/** Closes the topmost popup in the stack. */\n\tclose(): void {\n\t\tconst top: PopupEntry | undefined = this.stack[this.stack.length - 1];\n\t\tif (top) {\n\t\t\tthis.closeEntry(top);\n\t\t}\n\t}\n\n\t/** Closes all open popups. */\n\tcloseAll(): void {\n\t\twhile (this.stack.length > 0) {\n\t\t\tconst top: PopupEntry | undefined = this.stack[this.stack.length - 1];\n\t\t\tif (top) {\n\t\t\t\tthis.closeEntry(top);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Returns true if any popup is currently open. */\n\tisOpen(): boolean {\n\t\treturn this.stack.length > 0;\n\t}\n\n\t/** Cleans up all popups and event listeners. */\n\tdestroy(): void {\n\t\tthis.closeAll();\n\t}\n\n\t// --- Internal ---\n\n\tprivate closeEntry(entry: PopupEntry, options?: PopupCloseOptions): void {\n\t\tconst index: number = this.stack.indexOf(entry);\n\t\tif (index === -1) return;\n\n\t\t// Close all child popups first (anything above this entry in the stack)\n\t\twhile (this.stack.length > index + 1) {\n\t\t\tconst child: PopupEntry | undefined = this.stack[this.stack.length - 1];\n\t\t\tif (child) {\n\t\t\t\tthis.removeEntry(child);\n\t\t\t}\n\t\t}\n\n\t\tthis.removeEntry(entry);\n\n\t\tif (options !== undefined && 'restoreFocusTo' in options) {\n\t\t\toptions.restoreFocusTo?.focus();\n\t\t} else if (entry.config.restoreFocusTo) {\n\t\t\tentry.config.restoreFocusTo.focus();\n\t\t}\n\t\tentry.config.onClose?.();\n\t}\n\n\tprivate removeEntry(entry: PopupEntry): void {\n\t\tconst index: number = this.stack.indexOf(entry);\n\t\tif (index === -1) return;\n\n\t\tthis.stack.splice(index, 1);\n\t\tif (entry.listenerRegistrationTimer !== null) {\n\t\t\tclearTimeout(entry.listenerRegistrationTimer);\n\t\t\tentry.listenerRegistrationTimer = null;\n\t\t}\n\t\tentry.element.remove();\n\t\tif (entry.documentListenerAttached) {\n\t\t\tdocument.removeEventListener('mousedown', entry.clickOutsideHandler);\n\t\t\tentry.documentListenerAttached = false;\n\t\t}\n\t}\n\n\tprivate findEntryByHandle(handle: PopupHandle): PopupEntry | null {\n\t\tconst element: HTMLElement = handle.getElement();\n\t\treturn this.stack.find((e) => e.element === element) ?? null;\n\t}\n\n\t/** Detects whether the editor context is RTL from the computed style. */\n\tprivate isRtlContext(): boolean {\n\t\tif (this.referenceNode instanceof HTMLElement) {\n\t\t\treturn isRtlContext(this.referenceNode);\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate focusFirstItem(popup: HTMLElement): void {\n\t\trequestAnimationFrame(() => {\n\t\t\tconst firstFocusable: HTMLElement | null =\n\t\t\t\tpopup.querySelector('[role=\"menuitem\"]') ??\n\t\t\t\tpopup.querySelector('[role=\"option\"]') ??\n\t\t\t\tpopup.querySelector('[role=\"gridcell\"]') ??\n\t\t\t\t// `input, textarea` returns whichever comes first in the DOM, so a\n\t\t\t\t// popup whose primary field is a textarea (e.g. the formula editor's\n\t\t\t\t// LaTeX field) focuses that rather than a later text input.\n\t\t\t\tpopup.querySelector('input, textarea') ??\n\t\t\t\tpopup.querySelector('button');\n\t\t\tfirstFocusable?.focus();\n\t\t});\n\t}\n}\n"],"mappings":"2JAqDA,IAAa,EAAkB,IAAI,EAA4B,SAelD,EAAb,MACC,MAAuC,GACvC,cAEA,WAAA,CAAY,GACX,KAAK,cAAgB,CACtB,CAGA,IAAA,CAAK,GACJ,MAAM,EAAwB,SAAS,cAAc,OACrD,EAAM,UAAY,EAAO,UAAY,iBAAiB,EAAO,YAAc,gBAEvE,EAAO,UACV,EAAM,aAAa,OAAQ,EAAO,UAE/B,EAAO,WACV,EAAM,aAAa,aAAc,EAAO,WAGzC,MAAM,EAAiC,EAAO,OAC3C,KAAK,kBAAkB,EAAO,QAC9B,KAEH,IAAI,EACJ,MAAM,EAAsB,CAC3B,MAAQ,GAAgC,KAAK,WAAW,EAAO,GAC/D,WAAA,IAAkB,GAGb,EAAuB,IAC5B,MAAM,EAAsB,EAAE,eAC9B,IAAI,EAAK,SAAS,GAAlB,CAGA,IAAK,MAAM,KAAc,KAAK,MAC7B,GAAI,EAAK,SAAS,EAAW,SAAU,OAIpC,EAAO,kBAAkB,aAAe,EAAK,SAAS,EAAO,SAEjE,KAAK,WAAW,EAVU,GAa3B,EAAQ,CACP,Q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MAAM,EAAgB,KAAK,MAAM,QAAQ,IAC3B,IAAV,IAEJ,KAAK,MAAM,OAAO,EAAO,GACe,OAApC,EAAM,4BACT,aAAa,EAAM,2BACnB,EAAM,0BAA4B,MAEnC,EAAM,QAAQ,SACV,EAAM,2BACT,SAAS,oBAAoB,YAAa,EAAM,qBAChD,EAAM,0BAA2B,GAEnC,CAEA,iBAAA,CAA0B,GACzB,MAAM,EAAuB,EAAO,aACpC,OAAO,KAAK,MAAM,KAAM,GAAM,EAAE,UAAY,IAAY,IACzD,CAGA,YAAA,GACC,OAAI,KAAK,yBAAyB,aAC1B,EAAa,KAAK,cAG3B,CAEA,cAAA,CAAuB,GACtB,sBAAA,MAEE,EAAM,cAAc,sBACpB,EAAM,cAAc,oBACpB,EAAM,cAAc,sBAIpB,EAAM,cAAc,oBACpB,EAAM,cAAc,YACL,SAElB"}
1
+ {"version":3,"file":"PopupManager-DUtaK3WX.mjs","names":[],"sources":["../../src/plugins/shared/PopupManager.ts"],"sourcesContent":["/**\n * Central popup lifecycle manager. Handles creation, positioning,\n * click-outside closing, Escape key, focus restoration, and popup stacking\n * for submenus/nested popups.\n */\n\nimport { isRtlContext } from '../../platform/Platform.js';\nimport { ServiceKey } from '../Plugin.js';\nimport {\n\ttype PopupPosition,\n\tappendToRoot,\n\tpositionPopup,\n\tpromoteToTopLayer,\n} from './PopupPositioning.js';\n\n// --- Types ---\n\n/** Options for overriding focus restoration when closing a popup. */\nexport interface PopupCloseOptions {\n\t/**\n\t * Override the default focus target on close.\n\t * - `HTMLElement` → focus that element instead of `config.restoreFocusTo`\n\t * - `null` → skip focus restoration entirely\n\t * - `undefined` / omitted → use default `config.restoreFocusTo`\n\t */\n\treadonly restoreFocusTo?: HTMLElement | null;\n}\n\nexport interface PopupConfig {\n\treadonly anchor: HTMLElement | DOMRect;\n\treadonly content: (container: HTMLElement, close: (options?: PopupCloseOptions) => void) => void;\n\treadonly className?: string;\n\treadonly ariaRole?: 'menu' | 'listbox' | 'grid' | 'dialog';\n\treadonly ariaLabel?: string;\n\treadonly restoreFocusTo?: HTMLElement;\n\treadonly onClose?: () => void;\n\treadonly position?: PopupPosition;\n\treadonly parent?: PopupHandle;\n\treadonly referenceNode?: Node;\n}\n\nexport interface PopupHandle {\n\tclose(options?: PopupCloseOptions): void;\n\tgetElement(): HTMLElement;\n}\n\nexport interface PopupServiceAPI {\n\topen(config: PopupConfig): PopupHandle;\n\tclose(): void;\n\tcloseAll(): void;\n\tisOpen(): boolean;\n}\n\nexport const PopupServiceKey = new ServiceKey<PopupServiceAPI>('popup');\n\n// --- Internal Entry ---\n\ninterface PopupEntry {\n\treadonly element: HTMLElement;\n\treadonly config: PopupConfig;\n\treadonly clickOutsideHandler: (e: MouseEvent) => void;\n\treadonly parent: PopupEntry | null;\n\tlistenerRegistrationTimer: ReturnType<typeof setTimeout> | null;\n\tdocumentListenerAttached: boolean;\n}\n\n// --- Manager ---\n\nexport class PopupManager implements PopupServiceAPI {\n\tprivate readonly stack: PopupEntry[] = [];\n\tprivate readonly referenceNode: Node;\n\n\tconstructor(referenceNode: Node) {\n\t\tthis.referenceNode = referenceNode;\n\t}\n\n\t/** Opens a popup with the given configuration. Returns a handle for closing it. */\n\topen(config: PopupConfig): PopupHandle {\n\t\tconst popup: HTMLDivElement = document.createElement('div');\n\t\tpopup.className = config.className ? `notectl-popup ${config.className}` : 'notectl-popup';\n\n\t\tif (config.ariaRole) {\n\t\t\tpopup.setAttribute('role', config.ariaRole);\n\t\t}\n\t\tif (config.ariaLabel) {\n\t\t\tpopup.setAttribute('aria-label', config.ariaLabel);\n\t\t}\n\n\t\tconst parentEntry: PopupEntry | null = config.parent\n\t\t\t? this.findEntryByHandle(config.parent)\n\t\t\t: null;\n\n\t\tlet entry!: PopupEntry;\n\t\tconst handle: PopupHandle = {\n\t\t\tclose: (options?: PopupCloseOptions) => this.closeEntry(entry, options),\n\t\t\tgetElement: () => popup,\n\t\t};\n\n\t\tconst clickOutsideHandler = (e: MouseEvent): void => {\n\t\t\tconst path: EventTarget[] = e.composedPath();\n\t\t\tif (path.includes(popup)) return;\n\n\t\t\t// Don't close if click is inside any ancestor popup in the stack\n\t\t\tfor (const stackEntry of this.stack) {\n\t\t\t\tif (path.includes(stackEntry.element)) return;\n\t\t\t}\n\n\t\t\t// Don't close if click is on the anchor element\n\t\t\tif (config.anchor instanceof HTMLElement && path.includes(config.anchor)) return;\n\n\t\t\tthis.closeEntry(entry);\n\t\t};\n\n\t\tentry = {\n\t\t\telement: popup,\n\t\t\tconfig,\n\t\t\tclickOutsideHandler,\n\t\t\tparent: parentEntry,\n\t\t\tlistenerRegistrationTimer: null,\n\t\t\tdocumentListenerAttached: false,\n\t\t};\n\n\t\tthis.stack.push(entry);\n\n\t\ttry {\n\t\t\tconfig.content(popup, (options?: PopupCloseOptions) => this.closeEntry(entry, options));\n\t\t} catch (error) {\n\t\t\tthis.removeEntry(entry);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!this.stack.includes(entry)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\tconst refNode: Node = config.referenceNode ?? this.referenceNode;\n\t\tappendToRoot(popup, refNode);\n\t\t// Promote to the top layer before measuring/positioning so the popup\n\t\t// escapes any ancestor stacking context in the host page.\n\t\tpromoteToTopLayer(popup);\n\n\t\tconst anchorRect: DOMRect =\n\t\t\tconfig.anchor instanceof HTMLElement ? config.anchor.getBoundingClientRect() : config.anchor;\n\t\tpositionPopup(popup, anchorRect, {\n\t\t\tposition: config.position ?? 'below-start',\n\t\t\tisRtl: this.isRtlContext(),\n\t\t});\n\n\t\tentry.listenerRegistrationTimer = setTimeout(() => {\n\t\t\tentry.listenerRegistrationTimer = null;\n\t\t\tif (!this.stack.includes(entry)) return;\n\t\t\tdocument.addEventListener('mousedown', clickOutsideHandler);\n\t\t\tentry.documentListenerAttached = true;\n\t\t}, 0);\n\n\t\tthis.focusFirstItem(popup);\n\n\t\treturn handle;\n\t}\n\n\t/** Closes the topmost popup in the stack. */\n\tclose(): void {\n\t\tconst top: PopupEntry | undefined = this.stack[this.stack.length - 1];\n\t\tif (top) {\n\t\t\tthis.closeEntry(top);\n\t\t}\n\t}\n\n\t/** Closes all open popups. */\n\tcloseAll(): void {\n\t\twhile (this.stack.length > 0) {\n\t\t\tconst top: PopupEntry | undefined = this.stack[this.stack.length - 1];\n\t\t\tif (top) {\n\t\t\t\tthis.closeEntry(top);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Returns true if any popup is currently open. */\n\tisOpen(): boolean {\n\t\treturn this.stack.length > 0;\n\t}\n\n\t/** Cleans up all popups and event listeners. */\n\tdestroy(): void {\n\t\tthis.closeAll();\n\t}\n\n\t// --- Internal ---\n\n\tprivate closeEntry(entry: PopupEntry, options?: PopupCloseOptions): void {\n\t\tconst index: number = this.stack.indexOf(entry);\n\t\tif (index === -1) return;\n\n\t\t// Close all child popups first (anything above this entry in the stack)\n\t\twhile (this.stack.length > index + 1) {\n\t\t\tconst child: PopupEntry | undefined = this.stack[this.stack.length - 1];\n\t\t\tif (child) {\n\t\t\t\tthis.removeEntry(child);\n\t\t\t}\n\t\t}\n\n\t\tthis.removeEntry(entry);\n\n\t\tif (options !== undefined && 'restoreFocusTo' in options) {\n\t\t\toptions.restoreFocusTo?.focus();\n\t\t} else if (entry.config.restoreFocusTo) {\n\t\t\tentry.config.restoreFocusTo.focus();\n\t\t}\n\t\tentry.config.onClose?.();\n\t}\n\n\tprivate removeEntry(entry: PopupEntry): void {\n\t\tconst index: number = this.stack.indexOf(entry);\n\t\tif (index === -1) return;\n\n\t\tthis.stack.splice(index, 1);\n\t\tif (entry.listenerRegistrationTimer !== null) {\n\t\t\tclearTimeout(entry.listenerRegistrationTimer);\n\t\t\tentry.listenerRegistrationTimer = null;\n\t\t}\n\t\tentry.element.remove();\n\t\tif (entry.documentListenerAttached) {\n\t\t\tdocument.removeEventListener('mousedown', entry.clickOutsideHandler);\n\t\t\tentry.documentListenerAttached = false;\n\t\t}\n\t}\n\n\tprivate findEntryByHandle(handle: PopupHandle): PopupEntry | null {\n\t\tconst element: HTMLElement = handle.getElement();\n\t\treturn this.stack.find((e) => e.element === element) ?? null;\n\t}\n\n\t/** Detects whether the editor context is RTL from the computed style. */\n\tprivate isRtlContext(): boolean {\n\t\tif (this.referenceNode instanceof HTMLElement) {\n\t\t\treturn isRtlContext(this.referenceNode);\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate focusFirstItem(popup: HTMLElement): void {\n\t\trequestAnimationFrame(() => {\n\t\t\tconst firstFocusable: HTMLElement | null =\n\t\t\t\tpopup.querySelector('[role=\"menuitem\"]') ??\n\t\t\t\tpopup.querySelector('[role=\"option\"]') ??\n\t\t\t\tpopup.querySelector('[role=\"gridcell\"]') ??\n\t\t\t\t// `input, textarea` returns whichever comes first in the DOM, so a\n\t\t\t\t// popup whose primary field is a textarea (e.g. the formula editor's\n\t\t\t\t// LaTeX field) focuses that rather than a later text input.\n\t\t\t\tpopup.querySelector('input, textarea') ??\n\t\t\t\tpopup.querySelector('button');\n\t\t\tfirstFocusable?.focus();\n\t\t});\n\t}\n}\n"],"mappings":"2JAqDA,IAAa,EAAkB,IAAI,EAA4B,SAelD,EAAb,MACC,MAAuC,GACvC,cAEA,WAAA,CAAY,GACX,KAAK,cAAgB,CACtB,CAGA,IAAA,CAAK,GACJ,MAAM,EAAwB,SAAS,cAAc,OACrD,EAAM,UAAY,EAAO,UAAY,iBAAiB,EAAO,YAAc,gBAEvE,EAAO,UACV,EAAM,aAAa,OAAQ,EAAO,UAE/B,EAAO,WACV,EAAM,aAAa,aAAc,EAAO,WAGzC,MAAM,EAAiC,EAAO,OAC3C,KAAK,kBAAkB,EAAO,QAC9B,KAEH,IAAI,EACJ,MAAM,EAAsB,CAC3B,MAAQ,GAAgC,KAAK,WAAW,EAAO,GAC/D,WAAA,IAAkB,GAGb,EAAuB,IAC5B,MAAM,EAAsB,EAAE,eAC9B,IAAI,EAAK,SAAS,GAAlB,CAGA,IAAK,MAAM,KAAc,KAAK,MAC7B,GAA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EAAQ,gBAAgB,QACd,EAAM,OAAO,gBACvB,EAAM,OAAO,eAAe,QAE7B,EAAM,OAAO,WAjBK,CAkBnB,CAEA,WAAA,CAAoB,GACnB,MAAM,EAAgB,KAAK,MAAM,QAAQ,IAC3B,IAAV,IAEJ,KAAK,MAAM,OAAO,EAAO,GACe,OAApC,EAAM,4BACT,aAAa,EAAM,2BACnB,EAAM,0BAA4B,MAEnC,EAAM,QAAQ,SACV,EAAM,2BACT,SAAS,oBAAoB,YAAa,EAAM,qBAChD,EAAM,0BAA2B,GAEnC,CAEA,iBAAA,CAA0B,GACzB,MAAM,EAAuB,EAAO,aACpC,OAAO,KAAK,MAAM,KAAM,GAAM,EAAE,UAAY,IAAY,IACzD,CAGA,YAAA,GACC,OAAI,KAAK,yBAAyB,aAC1B,EAAa,KAAK,cAG3B,CAEA,cAAA,CAAuB,GACtB,sBAAA,MAEE,EAAM,cAAc,sBACpB,EAAM,cAAc,oBACpB,EAAM,cAAc,sBAIpB,EAAM,cAAc,oBACpB,EAAM,cAAc,YACL,SAElB"}
@@ -1,2 +1,2 @@
1
- import{o as t}from"./StyleRuntime-BAutwDZT.mjs";function e(t){const e=t.style.top,o=t.style.left,i=t.style.right;t.style.top="0px",t.style.left="0px",t.style.right="auto";const l=t.getBoundingClientRect(),n=l.left,p=l.top;t.style.left="auto",t.style.right="0px";const s=t.getBoundingClientRect(),r=window.innerWidth-s.right;return t.style.top=e,t.style.left=o,t.style.right=i,{x:n,y:p,rightX:r}}function o(o,i,l){const n=l.offset??2,p=window.innerWidth,s=window.innerHeight;t(o,{position:"fixed",zIndex:"10000"});const r=e(o),f=o.offsetWidth,h=o.offsetHeight,a={};switch(l.position){case"below-start":{let t=i.bottom+n;if(l.isRtl){let e=p-i.right;e+f>p-4&&(e=p-f-4),t+h>s-4&&(t=i.top-h-n),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.right=e-r.rightX+"px",a.left="auto"}else{let e=i.left;e+f>p-4&&(e=p-f-4),t+h>s-4&&(t=i.top-h-n),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.left=e-r.x+"px",a.right="auto"}break}case"below-end":{let t=i.bottom+n;if(l.isRtl){let e=i.left;e+f>p-4&&(e=p-f-4),t+h>s-4&&(t=i.top-h-n),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.left=e-r.x+"px",a.right="auto"}else{let e=p-i.right;e+f>p-4&&(e=p-f-4),t+h>s-4&&(t=i.top-h-n),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.right=e-r.rightX+"px",a.left="auto"}break}case"right":{let t=i.top;if(l.isRtl){let e=i.left-f-n;e<4&&(e=i.right+n),t+h>s-4&&(t=s-h-4),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.left=e-r.x+"px",a.right="auto"}else{let e=i.right+n;e+f>p-4&&(e=i.left-f-n),t+h>s-4&&(t=s-h-4),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.left=e-r.x+"px",a.right="auto"}break}}t(o,a)}function i(t,e){const o=e.getRootNode();o instanceof ShadowRoot?o.appendChild(t):document.body.appendChild(t)}function l(e){if("function"==typeof e.showPopover){e.setAttribute("popover","manual");try{e.showPopover()}catch{return void e.removeAttribute("popover")}t(e,{margin:"0",inset:"auto"})}}export{l as i,e as n,o as r,i as t};
2
- //# sourceMappingURL=PopupPositioning-DtUrY9bh.mjs.map
1
+ import{s as t}from"./StyleRuntime-BFKu52mS.mjs";function e(t){const e=t.style.top,o=t.style.left,i=t.style.right;t.style.top="0px",t.style.left="0px",t.style.right="auto";const l=t.getBoundingClientRect(),n=l.left,p=l.top;t.style.left="auto",t.style.right="0px";const s=t.getBoundingClientRect(),r=window.innerWidth-s.right;return t.style.top=e,t.style.left=o,t.style.right=i,{x:n,y:p,rightX:r}}function o(o,i,l){const n=l.offset??2,p=window.innerWidth,s=window.innerHeight;t(o,{position:"fixed",zIndex:"10000"});const r=e(o),f=o.offsetWidth,h=o.offsetHeight,a={};switch(l.position){case"below-start":{let t=i.bottom+n;if(l.isRtl){let e=p-i.right;e+f>p-4&&(e=p-f-4),t+h>s-4&&(t=i.top-h-n),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.right=e-r.rightX+"px",a.left="auto"}else{let e=i.left;e+f>p-4&&(e=p-f-4),t+h>s-4&&(t=i.top-h-n),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.left=e-r.x+"px",a.right="auto"}break}case"below-end":{let t=i.bottom+n;if(l.isRtl){let e=i.left;e+f>p-4&&(e=p-f-4),t+h>s-4&&(t=i.top-h-n),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.left=e-r.x+"px",a.right="auto"}else{let e=p-i.right;e+f>p-4&&(e=p-f-4),t+h>s-4&&(t=i.top-h-n),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.right=e-r.rightX+"px",a.left="auto"}break}case"right":{let t=i.top;if(l.isRtl){let e=i.left-f-n;e<4&&(e=i.right+n),t+h>s-4&&(t=s-h-4),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.left=e-r.x+"px",a.right="auto"}else{let e=i.right+n;e+f>p-4&&(e=i.left-f-n),t+h>s-4&&(t=s-h-4),e<4&&(e=4),t<4&&(t=4),a.top=t-r.y+"px",a.left=e-r.x+"px",a.right="auto"}break}}t(o,a)}function i(t,e){const o=e.getRootNode();o instanceof ShadowRoot?o.appendChild(t):document.body.appendChild(t)}function l(e){if("function"==typeof e.showPopover){e.setAttribute("popover","manual");try{e.showPopover()}catch{return void e.removeAttribute("popover")}t(e,{margin:"0",inset:"auto"})}}export{l as i,e as n,o as r,i as t};
2
+ //# sourceMappingURL=PopupPositioning-BB97-__N.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PopupPositioning-DtUrY9bh.mjs","names":[],"sources":["../../src/plugins/shared/PopupPositioning.ts"],"sourcesContent":["/**\n * Shared popup positioning logic. Positions a popup element relative to an\n * anchor rectangle, clamping to the viewport. Also provides a shadow DOM-aware\n * append helper.\n */\n\nimport { setStyleProperties } from '../../style/StyleRuntime.js';\n\n// --- Types ---\n\nexport type PopupPosition = 'below-start' | 'below-end' | 'right';\n\nexport interface PositionOptions {\n\treadonly position: PopupPosition;\n\treadonly offset?: number;\n\treadonly isRtl?: boolean;\n}\n\nexport interface ContainingBlockOffset {\n\treadonly x: number;\n\treadonly y: number;\n\treadonly rightX: number;\n}\n\n// --- Constants ---\n\nconst DEFAULT_OFFSET = 2;\nconst Z_INDEX = '10000';\nconst POPUP_MIN_MARGIN = 4;\n\n// --- Containing Block Offset ---\n\n/**\n * Measures the offset between the popup's CSS containing block and the\n * viewport. When an ancestor has `transform`, `will-change: transform`,\n * `filter`, or `perspective`, `position: fixed` resolves relative to that\n * ancestor — not the viewport. This probe detects the shift so callers\n * can compensate.\n *\n * Technique: temporarily set `top: 0; left: 0` on the fixed-position\n * element and read `getBoundingClientRect()`. If no containing-block\n * ancestor exists the rect origin is `(0, 0)`; otherwise it equals the\n * ancestor's offset.\n */\nexport function measureContainingBlockOffset(popup: HTMLElement): ContainingBlockOffset {\n\tconst prevTop: string = popup.style.top;\n\tconst prevLeft: string = popup.style.left;\n\tconst prevRight: string = popup.style.right;\n\n\t// Probe 1: left-edge offset\n\tpopup.style.top = '0px';\n\tpopup.style.left = '0px';\n\tpopup.style.right = 'auto';\n\n\tconst leftRect: DOMRect = popup.getBoundingClientRect();\n\tconst x: number = leftRect.left;\n\tconst y: number = leftRect.top;\n\n\t// Probe 2: right-edge offset\n\tpopup.style.left = 'auto';\n\tpopup.style.right = '0px';\n\n\tconst rightRect: DOMRect = popup.getBoundingClientRect();\n\tconst rightX: number = window.innerWidth - rightRect.right;\n\n\tpopup.style.top = prevTop;\n\tpopup.style.left = prevLeft;\n\tpopup.style.right = prevRight;\n\n\treturn { x, y, rightX };\n}\n\n// --- Positioning ---\n\n/**\n * Positions a popup element relative to the given anchor rectangle.\n * Uses fixed positioning and clamps to the viewport edges.\n * Automatically compensates for ancestors that create a new containing\n * block (e.g. `transform`, `will-change: transform`).\n */\nexport function positionPopup(popup: HTMLElement, anchor: DOMRect, options: PositionOptions): void {\n\tconst offset: number = options.offset ?? DEFAULT_OFFSET;\n\tconst vpWidth: number = window.innerWidth;\n\tconst vpHeight: number = window.innerHeight;\n\n\t// Apply fixed positioning first so offsetWidth/offsetHeight reflect\n\t// shrink-to-fit sizing rather than normal-flow block width.\n\tsetStyleProperties(popup, { position: 'fixed', zIndex: Z_INDEX });\n\n\t// Detect containing-block offset caused by ancestor transforms etc.\n\tconst cbOffset: ContainingBlockOffset = measureContainingBlockOffset(popup);\n\n\tconst popupWidth: number = popup.offsetWidth;\n\tconst popupHeight: number = popup.offsetHeight;\n\n\tconst styles: Record<string, string> = {};\n\n\tswitch (options.position) {\n\t\tcase 'below-start': {\n\t\t\tlet top: number = anchor.bottom + offset;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: anchor to physical right edge (visual start)\n\t\t\t\tlet right: number = vpWidth - anchor.right;\n\t\t\t\tif (right + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tright = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (right < POPUP_MIN_MARGIN) right = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.right = `${right - cbOffset.rightX}px`;\n\t\t\t\tstyles.left = 'auto';\n\t\t\t} else {\n\t\t\t\tlet left: number = anchor.left;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'below-end': {\n\t\t\tlet top: number = anchor.bottom + offset;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: \"end\" = physical left edge\n\t\t\t\tlet left: number = anchor.left;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t} else {\n\t\t\t\t// LTR: \"end\" = physical right edge\n\t\t\t\tlet right: number = vpWidth - anchor.right;\n\t\t\t\tif (right + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tright = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (right < POPUP_MIN_MARGIN) right = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.right = `${right - cbOffset.rightX}px`;\n\t\t\t\tstyles.left = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'right': {\n\t\t\tlet top: number = anchor.top;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: open submenu to the physical left\n\t\t\t\tlet left: number = anchor.left - popupWidth - offset;\n\t\t\t\tif (left < POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = anchor.right + offset;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = vpHeight - popupHeight - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t} else {\n\t\t\t\tlet left: number = anchor.right + offset;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = anchor.left - popupWidth - offset;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = vpHeight - popupHeight - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tsetStyleProperties(popup, styles);\n}\n\n/**\n * Appends an element to the appropriate root: the shadow root if the\n * reference node lives inside one, otherwise `document.body`.\n */\nexport function appendToRoot(element: HTMLElement, referenceNode: Node): void {\n\tconst root: Node = referenceNode.getRootNode();\n\tif (root instanceof ShadowRoot) {\n\t\troot.appendChild(element);\n\t} else {\n\t\tdocument.body.appendChild(element);\n\t}\n}\n\n/**\n * Promotes a popup/overlay to the browser's top layer via the Popover API so it\n * paints above — and receives pointer events ahead of — every stacking context\n * in the host page. A high `z-index` alone is not enough: an ancestor that forms\n * a stacking context (e.g. Starlight's `isolation: isolate` content wrapper)\n * traps the popup below a sibling such as the fixed table-of-contents sidebar,\n * so clicks on the overlapped region hit the sidebar and dismiss the popup.\n *\n * The element keeps living in the editor's shadow DOM, so its registered styles\n * still apply; only its paint layer changes. Must be called while the element is\n * connected to the document and BEFORE positioning, so subsequent\n * `offsetWidth`/containing-block measurements reflect the displayed top-layer\n * box.\n *\n * No-ops when the Popover API is unavailable (older engines, happy-dom in unit\n * tests); callers then fall back to plain `z-index` stacking. Neutralizes the UA\n * popover box styles (`inset: 0; margin: auto`) so the caller's explicit\n * `top`/`left` placement is what positions the element.\n */\nexport function promoteToTopLayer(element: HTMLElement): void {\n\tif (typeof element.showPopover !== 'function') return;\n\telement.setAttribute('popover', 'manual');\n\ttry {\n\t\telement.showPopover();\n\t} catch {\n\t\telement.removeAttribute('popover');\n\t\treturn;\n\t}\n\tsetStyleProperties(element, { margin: '0', inset: 'auto' });\n}\n"],"mappings":"gDA4CA,SAAgB,EAA6B,GAC5C,MAAM,EAAkB,EAAM,MAAM,IAC9B,EAAmB,EAAM,MAAM,KAC/B,EAAoB,EAAM,MAAM,MAGtC,EAAM,MAAM,IAAM,MAClB,EAAM,MAAM,KAAO,MACnB,EAAM,MAAM,MAAQ,OAEpB,MAAM,EAAoB,EAAM,wBAC1B,EAAY,EAAS,KACrB,EAAY,EAAS,IAG3B,EAAM,MAAM,KAAO,OACnB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,KAAU,EAAO,EAAS,EAAnB,KACd,EAAO,MAAQ,MAChB,CACA,KACD,EAGD,EAAmB,EAAO,EAC3B,CAMA,SAAgB,EAAa,EAAsB,GAClD,MAAM,EAAa,EAAc,cAC7B,aAAgB,WACnB,EAAK,YAAY,GAEjB,SAAS,KAAK,YAAY,EAE5B,CAqBA,SAAgB,EAAkB,GACjC,GAAmC,mBAAxB,EAAQ,YAAnB,CACA,EAAQ,aAAa,UAAW,UAChC,IACC,EAAQ,aACT,CAAA,MAEC,YADA,EAAQ,gBAAgB,UAEzB,CACA,EAAmB,EAAS,CAAE,OAAQ,IAAK,MAAO,QARH,CAShD"}
1
+ {"version":3,"file":"PopupPositioning-BB97-__N.mjs","names":[],"sources":["../../src/plugins/shared/PopupPositioning.ts"],"sourcesContent":["/**\n * Shared popup positioning logic. Positions a popup element relative to an\n * anchor rectangle, clamping to the viewport. Also provides a shadow DOM-aware\n * append helper.\n */\n\nimport { setStyleProperties } from '../../style/StyleRuntime.js';\n\n// --- Types ---\n\nexport type PopupPosition = 'below-start' | 'below-end' | 'right';\n\nexport interface PositionOptions {\n\treadonly position: PopupPosition;\n\treadonly offset?: number;\n\treadonly isRtl?: boolean;\n}\n\nexport interface ContainingBlockOffset {\n\treadonly x: number;\n\treadonly y: number;\n\treadonly rightX: number;\n}\n\n// --- Constants ---\n\nconst DEFAULT_OFFSET = 2;\nconst Z_INDEX = '10000';\nconst POPUP_MIN_MARGIN = 4;\n\n// --- Containing Block Offset ---\n\n/**\n * Measures the offset between the popup's CSS containing block and the\n * viewport. When an ancestor has `transform`, `will-change: transform`,\n * `filter`, or `perspective`, `position: fixed` resolves relative to that\n * ancestor — not the viewport. This probe detects the shift so callers\n * can compensate.\n *\n * Technique: temporarily set `top: 0; left: 0` on the fixed-position\n * element and read `getBoundingClientRect()`. If no containing-block\n * ancestor exists the rect origin is `(0, 0)`; otherwise it equals the\n * ancestor's offset.\n */\nexport function measureContainingBlockOffset(popup: HTMLElement): ContainingBlockOffset {\n\tconst prevTop: string = popup.style.top;\n\tconst prevLeft: string = popup.style.left;\n\tconst prevRight: string = popup.style.right;\n\n\t// Probe 1: left-edge offset\n\tpopup.style.top = '0px';\n\tpopup.style.left = '0px';\n\tpopup.style.right = 'auto';\n\n\tconst leftRect: DOMRect = popup.getBoundingClientRect();\n\tconst x: number = leftRect.left;\n\tconst y: number = leftRect.top;\n\n\t// Probe 2: right-edge offset\n\tpopup.style.left = 'auto';\n\tpopup.style.right = '0px';\n\n\tconst rightRect: DOMRect = popup.getBoundingClientRect();\n\tconst rightX: number = window.innerWidth - rightRect.right;\n\n\tpopup.style.top = prevTop;\n\tpopup.style.left = prevLeft;\n\tpopup.style.right = prevRight;\n\n\treturn { x, y, rightX };\n}\n\n// --- Positioning ---\n\n/**\n * Positions a popup element relative to the given anchor rectangle.\n * Uses fixed positioning and clamps to the viewport edges.\n * Automatically compensates for ancestors that create a new containing\n * block (e.g. `transform`, `will-change: transform`).\n */\nexport function positionPopup(popup: HTMLElement, anchor: DOMRect, options: PositionOptions): void {\n\tconst offset: number = options.offset ?? DEFAULT_OFFSET;\n\tconst vpWidth: number = window.innerWidth;\n\tconst vpHeight: number = window.innerHeight;\n\n\t// Apply fixed positioning first so offsetWidth/offsetHeight reflect\n\t// shrink-to-fit sizing rather than normal-flow block width.\n\tsetStyleProperties(popup, { position: 'fixed', zIndex: Z_INDEX });\n\n\t// Detect containing-block offset caused by ancestor transforms etc.\n\tconst cbOffset: ContainingBlockOffset = measureContainingBlockOffset(popup);\n\n\tconst popupWidth: number = popup.offsetWidth;\n\tconst popupHeight: number = popup.offsetHeight;\n\n\tconst styles: Record<string, string> = {};\n\n\tswitch (options.position) {\n\t\tcase 'below-start': {\n\t\t\tlet top: number = anchor.bottom + offset;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: anchor to physical right edge (visual start)\n\t\t\t\tlet right: number = vpWidth - anchor.right;\n\t\t\t\tif (right + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tright = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (right < POPUP_MIN_MARGIN) right = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.right = `${right - cbOffset.rightX}px`;\n\t\t\t\tstyles.left = 'auto';\n\t\t\t} else {\n\t\t\t\tlet left: number = anchor.left;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'below-end': {\n\t\t\tlet top: number = anchor.bottom + offset;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: \"end\" = physical left edge\n\t\t\t\tlet left: number = anchor.left;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t} else {\n\t\t\t\t// LTR: \"end\" = physical right edge\n\t\t\t\tlet right: number = vpWidth - anchor.right;\n\t\t\t\tif (right + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tright = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (right < POPUP_MIN_MARGIN) right = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.right = `${right - cbOffset.rightX}px`;\n\t\t\t\tstyles.left = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'right': {\n\t\t\tlet top: number = anchor.top;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: open submenu to the physical left\n\t\t\t\tlet left: number = anchor.left - popupWidth - offset;\n\t\t\t\tif (left < POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = anchor.right + offset;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = vpHeight - popupHeight - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t} else {\n\t\t\t\tlet left: number = anchor.right + offset;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = anchor.left - popupWidth - offset;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = vpHeight - popupHeight - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tsetStyleProperties(popup, styles);\n}\n\n/**\n * Appends an element to the appropriate root: the shadow root if the\n * reference node lives inside one, otherwise `document.body`.\n */\nexport function appendToRoot(element: HTMLElement, referenceNode: Node): void {\n\tconst root: Node = referenceNode.getRootNode();\n\tif (root instanceof ShadowRoot) {\n\t\troot.appendChild(element);\n\t} else {\n\t\tdocument.body.appendChild(element);\n\t}\n}\n\n/**\n * Promotes a popup/overlay to the browser's top layer via the Popover API so it\n * paints above — and receives pointer events ahead of — every stacking context\n * in the host page. A high `z-index` alone is not enough: an ancestor that forms\n * a stacking context (e.g. Starlight's `isolation: isolate` content wrapper)\n * traps the popup below a sibling such as the fixed table-of-contents sidebar,\n * so clicks on the overlapped region hit the sidebar and dismiss the popup.\n *\n * The element keeps living in the editor's shadow DOM, so its registered styles\n * still apply; only its paint layer changes. Must be called while the element is\n * connected to the document and BEFORE positioning, so subsequent\n * `offsetWidth`/containing-block measurements reflect the displayed top-layer\n * box.\n *\n * No-ops when the Popover API is unavailable (older engines, happy-dom in unit\n * tests); callers then fall back to plain `z-index` stacking. Neutralizes the UA\n * popover box styles (`inset: 0; margin: auto`) so the caller's explicit\n * `top`/`left` placement is what positions the element.\n */\nexport function promoteToTopLayer(element: HTMLElement): void {\n\tif (typeof element.showPopover !== 'function') return;\n\telement.setAttribute('popover', 'manual');\n\ttry {\n\t\telement.showPopover();\n\t} catch {\n\t\telement.removeAttribute('popover');\n\t\treturn;\n\t}\n\tsetStyleProperties(element, { margin: '0', inset: 'auto' });\n}\n"],"mappings":"gDA4CA,SAAgB,EAA6B,GAC5C,MAAM,EAAkB,EAAM,MAAM,IAC9B,EAAmB,EAAM,MAAM,KAC/B,EAAoB,EAAM,MAAM,MAGtC,EAAM,MAAM,IAAM,MAClB,EAAM,MAAM,KAAO,MACnB,EAAM,MAAM,MAAQ,OAEpB,MAAM,EAAoB,EAAM,wBAC1B,EAAY,EAAS,KACrB,EAAY,EAAS,IAG3B,EAAM,MAAM,KAAO,OACnB,EAAM,MAAM,MAAQ,MAEpB,MAAM,EAAqB,EAAM,wBAC3B,EAAiB,OAAO,WAAa,EAAU,MAMrD,OAJA,EAAM,MAAM,IAAM,EAClB,EAAM,MAAM,KAAO,EACnB,EAAM,MAAM,MAAQ,EAEb,CAAE,IAAG,IAAG,SAChB,CAUA,SAAgB,EAAc,EAAoB,EAAiB,GAClE,MAAM,EAAiB,EAAQ,QAvDT,EAwDhB,EAAkB,OAAO,WACzB,EAAmB,OAAO,YAIhC,EAAmB,EAAO,CAAE,SAAU,QAAS,OA5DhC,UA+Df,MAAM,EAAkC,EAA6B,GAE/D,EAAqB,EAAM,YAC3B,EAAsB,EAAM,aAE5B,EAAiC,CAAC,EAExC,OAAQ,EAAQ,UACf,IAAK,cAAe,CACnB,IAAI,EAAc,EAAO,OAAS,EAElC,GAAI,EAAQ,MAAO,CAElB,IAAI,EAAgB,EAAU,EAAO,MACjC,EAAQ,EAAa,EA5EJ,IA6EpB,EAAQ,EAAU,EA7EE,GA+EjB,EAAM,EAAc,EA/EH,IAgFpB,EAAM,EAAO,IAAM,EAAc,GAE9B,EAlFiB,IAkF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O,KAAO,EAAa,EAC1C,EA/IiB,IAgJpB,EAAO,EAAO,MAAQ,GAEnB,EAAM,EAAc,EAlJH,IAmJpB,EAAM,EAAW,EAnJG,GAqJjB,EArJiB,IAqJQ,EArJR,GAsJjB,EAtJiB,IAsJO,EAtJP,GAuJrB,EAAO,IAAS,EAAM,EAAS,EAAlB,KACb,EAAO,KAAU,EAAO,EAAS,EAAnB,KACd,EAAO,MAAQ,MAChB,KAAO,CACN,IAAI,EAAe,EAAO,MAAQ,EAC9B,EAAO,EAAa,EA5JH,IA6JpB,EAAO,EAAO,KAAO,EAAa,GAE/B,EAAM,EAAc,EA/JH,IAgKpB,EAAM,EAAW,EAhKG,GAkKjB,EAlKiB,IAkKQ,EAlKR,GAmKjB,EAnKiB,IAmKO,EAnKP,GAoKrB,EAAO,IAAS,EAAM,EAAS,EAAlB,KACb,EAAO,KAAU,EAAO,EAAS,EAAnB,KACd,EAAO,MAAQ,MAChB,CACA,KACD,EAGD,EAAmB,EAAO,EAC3B,CAMA,SAAgB,EAAa,EAAsB,GAClD,MAAM,EAAa,EAAc,cAC7B,aAAgB,WACnB,EAAK,YAAY,GAEjB,SAAS,KAAK,YAAY,EAE5B,CAqBA,SAAgB,EAAkB,GACjC,GAAmC,mBAAxB,EAAQ,YAAnB,CACA,EAAQ,aAAa,UAAW,UAChC,IACC,EAAQ,aACT,CAAA,MAEC,YADA,EAAQ,gBAAgB,UAEzB,CACA,EAAmB,EAAS,CAAE,OAAQ,IAAK,MAAO,QARH,CAShD"}
@@ -0,0 +1,2 @@
1
+ import{n as t,r as e}from"./HTMLUtils-C6B4UT00.mjs";import{i as n,l as o,r,s}from"./StyleRuntime-BFKu52mS.mjs";import{_ as i,c as a,d as c,h as l,i as u,n as p,r as m,s as h,t as d}from"./PrintTypes-CxU69qu3.mjs";import{c as f,o as g}from"./PluginHelpers-KDuTlmXm.mjs";import{t as y}from"./ShortcutFormatting-TwiufqeV.mjs";import $ from"dompurify";var v={label:"Print",tooltip:t=>`Print (${t})`,printingAnnouncement:"Printing"},b=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-Uzo1Azdw.mjs"),"./locales/de.ts":()=>import("./de-DcMhfRBu.mjs"),"./locales/es.ts":()=>import("./es-BJHF95J_.mjs"),"./locales/fr.ts":()=>import("./fr-KXmbys88.mjs"),"./locales/hi.ts":()=>import("./hi-l6DA-aOw.mjs"),"./locales/pt.ts":()=>import("./pt-C8sOyw0V.mjs"),"./locales/ru.ts":()=>import("./ru-B1m8J9dl.mjs"),"./locales/zh.ts":()=>import("./zh-dGSDBBzb.mjs")});async function S(t){return f(b,t,v)}var w=["h1","h2","h3","h4","h5","h6","p","div","span","br","hr","strong","b","em","i","u","s","sub","sup","small","ul","ol","li","table","thead","tbody","tr","th","td","img"],j=["style","class","src","alt","width","height","colspan","rowspan"];function k(t){const e="function"==typeof t?t():t;return $.sanitize(e,{ALLOWED_TAGS:[...w],ALLOWED_ATTR:[...j]})}var C="notectl-host";function T(t){const e=Array.from(t.styleSheets),n=t.adoptedStyleSheets;return n&&e.push(...n),e}function x(t,e){const n=t[e]??'"';let o=e+1;for(;o<t.length;){const e=t[o]??"";if("\\"!==e){if(e===n)return o+1;o++}else o+=2}return t.length}function L(t,e){if("url("!==t.slice(e,e+4).toLowerCase())return!1;const n=e>0?t[e-1]??"":"";return!/[\w-]/.test(n)}function A(t,e){let n=e+4;for(;n<t.length&&/\s/.test(t[n]??"");)n++;const o=t[n]??"";let r;if('"'===o||"'"===o){const e=x(t,n);r=t.slice(n+1,e-1),n=e}else{const e=t.indexOf(")",n);if(-1===e)return null;r=t.slice(n,e).trim(),n=e}for(;n<t.length&&/\s/.test(t[n]??"");)n++;return")"!==t[n]?null:{end:n+1,url:(s=r,s.replace(/\\([0-9a-f]{1,6}\s?|[\s\S])/gi,(t,e)=>{const n=e.trim();if(/^[0-9a-f]{1,6}$/i.test(n)){const t=Number.parseInt(n,16);return t>0&&t<=1114111?String.fromCodePoint(t):"�"}return e}))};var s}function R(t,e,n){if(!e||!function(t){return!t.startsWith("#")&&!t.startsWith("//")&&!/^[a-z][a-z0-9+.-]*:/i.test(t)}(e))return t;try{return`url("${new URL(e,n).href}")`}catch{return t}}function N(t,e){if(!t.toLowerCase().includes("url("))return t;let n="",o=0;for(;o<t.length;){const r=t[o]??"";if('"'===r||"'"===r){const e=x(t,o);n+=t.slice(o,e),o=e;continue}if(L(t,o)){const r=A(t,o);if(r){n+=R(t.slice(o,r.end),r.url,e),o=r.end;continue}}n+=r,o++}return n}function E(t,e,n,o,r){const s=n.trim(),i=s&&"all"!==s?` ${s}`:"";let a=C;""===o?a=`${C}.${function(t){return t.anonymousLayerCount+=1,`notectl-anonymous-${t.anonymousLayerCount}`}(t)}`:o&&(a=`${C}.${o}`);const c=r?.trim()?` supports(${r.trim()})`:"";var l;t.segments.push({kind:"import",statement:`@import url("${l=e,l.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}") layer(${a})${c}${i};`})}function z(t,e){const n=e.trim();return n&&"all"!==n?`@media ${n} {\n${t}\n}`:t}function B(t,e){if(e.seen.has(t))return;if(e.seen.add(t),t.disabled)return;let n;try{n=t.cssRules}catch{return void(t.href&&E(e,t.href,t.media.mediaText,null,null))}const o=t.href??e.baseURL,r=[];for(const i of n)3!==i.type?r.push(N(i.cssText,o)):H(i,e,r);const s=r.join("\n");s&&function(t,e){const n=t.segments[t.segments.length-1];"rules"!==n?.kind?t.segments.push({kind:"rules",css:e}):t.segments[t.segments.length-1]={kind:"rules",css:`${n.css}\n${e}`}}(e,z(s,t.media.mediaText))}function H(t,e,n){const o=t.layerName??null,r=t.supportsText??null,s=t.styleSheet;if(s&&!e.seen.has(s)){let i;try{i=s.cssRules}catch{i=null}if(i){e.seen.add(s);const a=s.href??e.baseURL,c=[];for(const t of i)3!==t.type?c.push(N(t.cssText,a)):H(t,e,c);let l=c.join("\n");return void(l&&(null!==o&&(l=""===o?`@layer {\n${l}\n}`:`@layer ${o} {\n${l}\n}`),r?.trim()&&(l=`@supports (${r.trim()}) {\n${l}\n}`),n.push(z(l,t.media.mediaText))))}}const i=s?.href??t.href;i&&E(e,i,t.media.mediaText,o,r)}var P="notectl-print",M="notectl-custom";function q(t){return t.replace(/;$/gm," !important;")}function D(t){return q(l(i).replace(":host {",`${t} {`))}function W(t,e){const n=getComputedStyle(t),o=[];for(let r=0;r<n.length;r++){const t=n[r]??"";if(t.startsWith("--notectl-")){const e=n.getPropertyValue(t).trim();e&&o.push(` ${t}: ${e};`)}}return 0===o.length?"":`${e} {\n${o.join("\n")}\n}`}var U=["","transparent","rgba(0, 0, 0, 0)"];function O(t){let e=t;for(;e;){const t=getComputedStyle(e).getPropertyValue("background-color").trim();if(!U.includes(t))return t;const n=e.getRootNode();e=e.parentElement??(n instanceof ShadowRoot?n.host:null)}return"#ffffff"}function V(t,e,n="#ffffff",o="body"){const r=getComputedStyle(t),s=["font-family","font-size","font-weight","line-height","letter-spacing","word-spacing","color"],i=[" margin: 0;",` background: ${n};`];for(const a of s){if("color"===a&&e){i.push(` color: ${e};`);continue}const t=r.getPropertyValue(a).trim();t&&i.push(` ${a}: ${t};`)}return`${o} {\n${i.join("\n")}\n}`}var I=["display: block","position: static","inset: auto","width: auto","height: auto","min-width: 0","min-height: 0","max-width: none","max-height: none","margin: 0","padding: 0","border: none","border-radius: 0","outline: none","box-shadow: none","background: transparent","overflow: visible","transform: none","filter: none","opacity: 1","contain: none","float: none","visibility: visible"],_=["display: block","visibility: visible","opacity: 1","position: static","height: auto","min-height: 0","max-height: none","overflow: visible","transform: none","filter: none","contain: none"];function F(t){return[`${t} {`,...I.map(t=>` ${t} !important;`),"}"].join("\n")}function G(t,e,n){const o=t.tagName.toLowerCase(),r=[],s=!1!==n.forceLightTheme,a=[F(o),["html, body {",..._.map(t=>` ${t} !important;`),"}"].join("\n")];if(s&&a.push(D(`:root, ${o}`)),!1!==n.printBackground&&a.push("* {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n}"),r.push(`@layer ${P} {\n${a.join("\n\n")}\n}`),!s){const e=W(t,`:root, ${o}`);e&&r.push(e)}const l=s?i.primitives.foreground:void 0,u=s?"#ffffff":O(e);r.push(V(t,l,u));const p=function(t){const e=[];if(t.margin?e.push(` margin: ${t.margin};`):t.paperSize&&e.push(" margin: 0;"),t.paperSize||t.orientation){const n=[t.paperSize?c(t.paperSize):"A4"];t.orientation&&n.push(t.orientation),e.push(` size: ${n.join(" ")};`)}return 0===e.length?"":`@page {\n${e.join("\n")}\n}`}(n);return p&&r.push(p),n.customCSS&&(r.push(n.customCSS),r.push(`@layer ${M} {\n${n.customCSS}\n}`)),r.join("\n\n")}function K(t,e,n,o){const r=`${t.tagName.toLowerCase()}[${o}]`,s=!1!==n.forceLightTheme,a=[F(r)];s&&a.push(D(r)),!1!==n.printBackground&&a.push(`${r}, ${r} * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n}`);const c=s?i.primitives.foreground:void 0,l=s?"#ffffff":O(e);a.push(q(V(t,c,l,r)));const u=[`@layer ${P} {\n${a.join("\n\n")}\n}`];if(!s){const e=W(t,r);e&&u.push(e)}return u.join("\n\n")}var Y="data-notectl-print-fallback",J=["(function () {"," var head = document.head;"," if (head && head.querySelector('meta[name=\"notectl-print-export\"]')) {"," var bundles = document.querySelectorAll('template[data-notectl-print-styles]');"," for (var b = 0; b < bundles.length; b++) {"," if (bundles[b].content) head.appendChild(bundles[b].content);"," bundles[b].parentNode.removeChild(bundles[b]);"," }"," }"," var statics = document.querySelectorAll('[data-notectl-static]');"," for (var i = 0; i < statics.length; i++) {"," var host = statics[i];"," if (!host.shadowRoot && host.attachShadow) {"," for (var j = 0; j < host.children.length; j++) {"," var child = host.children[j];"," if (child.tagName !== 'TEMPLATE') continue;"," if (!child.getAttribute('shadowrootmode') || !child.content) continue;"," host.attachShadow({ mode: 'open' }).appendChild(child.content);"," host.removeChild(child);"," break;"," }"," }"," if (!host.shadowRoot) continue;"," var fallbacks = host.querySelectorAll('[data-notectl-print-fallback]');"," for (var k = 0; k < fallbacks.length; k++) {"," fallbacks[k].parentNode.removeChild(fallbacks[k]);"," }"," }","})();"].join("\n");function Q(t){return t.replace(/<\//g,"<\\/")}function X(e,n){const o=[];for(const r of Array.from(e.attributes))n(r.name)&&o.push(""===r.value?r.name:`${r.name}="${t(r.value)}"`);return o.length>0?` ${o.join(" ")}`:""}function Z(t){return t?X(t,t=>"class"===t||t.startsWith("data-")):""}function tt(e){const n=function(t){if(!(t instanceof HTMLElement))return"";const e=[];for(let n=0;n<t.style.length;n++){const o=t.style[n]??"";if(!o.startsWith("--notectl-"))continue;const r=t.style.getPropertyValue(o).trim();r&&e.push(`${o}: ${r}`)}return e.join("; ")}(e);return n?` style="${t(n)}"`:""}function et(n){const o=n.host.ownerDocument,r=n.host.tagName.toLowerCase(),s="export"===n.variant,i=s?["style","id",u]:["style",u],a=(c=n.host,l=i,X(c,t=>!l.includes(t)));var c,l;const p=n.carryThemeContext?tt(n.host):"",m=n.carryThemeContext?Z(o.documentElement)+tt(o.documentElement):"",h=n.carryThemeContext?Z(o.body)+tt(o.body):"",d=n.styleNonce?` nonce="${t(n.styleNonce)}"`:"",f=['<meta charset="utf-8">',`<title>${e(n.title)}</title>`];s&&f.push('<meta name="notectl-print-export">'),f.push(`<style${d}>@layer ${M}, ${P}, ${C};</style>`),f.push(`<style${d}>${Q(n.documentCSS)}</style>`);const g=n.hostSegments.map(t=>`<style${d}>${Q("import"===t.kind?t.statement:`@layer ${C} {\n${t.css}\n}`)}</style>`);s||f.push(...g);const y=s?`<template data-notectl-print-styles><style>${Q(n.standaloneCSS)}</style>${g.join("")}</template>`:"",$=s?`<div ${Y}><style>@scope ([${Y}]) {\n${Q(n.shadowCSS)}\n}</style>${n.contentHTML}</div>`:"",v=s?`<script>${J}<\/script>`:"",b=[`<${r}${a}${p} ${u}>`,'<template shadowrootmode="open">',`<style${d}>${Q(n.shadowCSS)}</style>`,n.contentHTML,"</template>",...$?[$]:[],`</${r}>`,...y?[y]:[],...v?[v]:[]];return["<!DOCTYPE html>",`<html lang="${t(n.lang)}"${m}>`,"<head>",...f,"</head>",`<body${h}>`,...b,"</body>","</html>"].join("\n")}var nt={print(){},toHTML:()=>"",dispose(){}},ot=class{id="print";name="Print";config;service=null;locale;constructor(t){this.config=t??{}}async init(t){this.locale=await g(t,this.config.locale,v,S);const e=t.getContainer(),i=e.getRootNode();if(i instanceof ShadowRoot){const a=i.host,c=t.getEventBus();this.service=function(t,e,i,a){const c=/* @__PURE__ */new Set;function l(t){return t??{}}function m(o){const r={options:o,cancelled:!1};if(a.emit(p,r),r.cancelled)return null;const c=r.options,l=function(t,e){const o=[],r=function(t){const e=[],o=[];for(const r of t.adoptedStyleSheets){const t=n(r)?o:e;for(const e of r.cssRules)t.push(e.cssText)}return{base:e.join("\n"),runtime:o.join("\n")}}(t);r.base&&o.push(`@layer notectl-base {\n${r.base}\n}`),r.runtime&&o.push(r.runtime);const s=function(t){const e=[];e.push(".notectl-content { height: auto !important; max-height: none !important; min-height: 0 !important; overflow: visible !important; }"),t.paperSize&&e.push(".notectl-content { padding: 48px 56px !important; }");const n=[];return n.push("[data-notectl-no-print] { display: none !important; }"),n.push(".notectl-code-block { white-space: pre-wrap !important; word-break: break-all !important; page-break-inside: avoid; }"),n.push("img { page-break-inside: avoid; }"),n.push(".notectl-table { break-inside: avoid; }"),!1!==t.printBackground&&n.push("* { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }"),e.push(`@media print {\n ${n.join("\n ")}\n}`),e.join("\n\n")}(e);return s&&o.push(s),e.customCSS&&o.push(e.customCSS),o.join("\n\n")}(t,c),m=function(t){const e={segments:[],seen:/* @__PURE__ */new Set,baseURL:t.ownerDocument.baseURI??"",anonymousLayerCount:0};for(const n of function(t){const e=[];let n=t.getRootNode();for(;n instanceof ShadowRoot;)e.push(n),n=n.host.getRootNode();return e.push(t.ownerDocument),e.reverse()}(t))for(const t of T(n))B(t,e);return e.segments}(e),h=function(t,e){const n=function(t){return(t.querySelector(".notectl-content")??t).cloneNode(!0)}(t);return function(t){t.removeAttribute("contenteditable");for(const e of["notectl-node-selected","notectl-content--empty"]){t.classList.remove(e);for(const n of t.querySelectorAll(`.${e}`))n.classList.remove(e)}t.removeAttribute("data-placeholder")}(n),function(t,e){if(e.excludeBlockTypes)for(const n of e.excludeBlockTypes){const e=t.querySelectorAll(`[data-block-type="${n}"]`);for(const t of e)t.remove()}if(e.pageBreakBefore)for(const n of e.pageBreakBefore){const e=t.querySelectorAll(`[data-block-type="${n}"]`);for(const t of e)s(t,{breakBefore:"page",pageBreakBefore:"always"})}}(n,e),function(t,e){if(e.header){const n=document.createElement("div");n.className="notectl-print-header",n.innerHTML=k(e.header),t.insertBefore(n,t.firstChild)}if(e.footer){const n=document.createElement("div");n.className="notectl-print-footer",n.innerHTML=k(e.footer),t.appendChild(n)}}(n,e),n}(i,c).outerHTML,f=c.title??"",g=e.ownerDocument,y=e.closest("[lang]")?.getAttribute("lang")??(g.documentElement.lang||"en"),$={documentCSS:K(e,i,c,u),standaloneCSS:G(e,i,c),hostSegments:m,shadowCSS:l,host:e,contentHTML:h,title:f,lang:y,carryThemeContext:!1===c.forceLightTheme,variant:"export"},v=et($),b={html:v};return a.emit(d,b),{html:v,input:$}}return{print(t){const e=m(l(t));if(!e)return;const n=et({...e.input,documentCSS:e.input.standaloneCSS,variant:"internal",styleNonce:r(i)}),s=document.createElement("iframe");o(s,"position:fixed;left:-9999px;width:0;height:0;border:none"),document.body.appendChild(s);const a=s.contentDocument,u=s.contentWindow;if(!a||!u)return void document.body.removeChild(s);a.open(),a.write(n),a.close();const p=()=>{s.remove()},h=()=>{u.addEventListener("afterprint",p,{once:!0}),u.print()};if("complete"===a.readyState)return void h();let d=!1;const f=()=>{d||(d=!0,c.delete(g),window.clearTimeout(y),h())},g=()=>{d=!0,window.clearTimeout(y),u.removeEventListener("load",f),s.remove()},y=window.setTimeout(f,4e3);c.add(g),u.addEventListener("load",f,{once:!0})},toHTML:t=>m(l(t))?.html??"",dispose(){for(const t of c)t();c.clear()}}}(i,a,e,c)}else this.service=nt;t.registerService(m,this.service);const a=this.config.defaults??{},c=this.service,l=this.locale;t.registerCommand("print",()=>(t.announce(l.printingAnnouncement),c.print(a),!0));const h=this.config.keyBinding??"Mod-P";if(t.registerKeymap({[h]:()=>(t.executeCommand("print"),!0)}),!1!==this.config.showToolbarItem){const e=y(h);t.registerToolbarItem({id:"print",group:"actions",label:this.locale.label,tooltip:this.locale.tooltip(e),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"/></svg>',command:"print"})}}destroy(){this.service?.dispose(),this.service=null}};export{v as n,S as r,ot as t};
2
+ //# sourceMappingURL=PrintPlugin-DyIZDY3Q.mjs.map