@notectl/core 2.3.5 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/chunks/{ColorGrid-D0vLHsG6.mjs → ColorGrid-DAs0--ty.mjs} +2 -2
  2. package/dist/chunks/{ColorGrid-D0vLHsG6.mjs.map → ColorGrid-DAs0--ty.mjs.map} +1 -1
  3. package/dist/chunks/ColorPickerPopup-CFYCCN7m.mjs +2 -0
  4. package/dist/chunks/{ColorPickerPopup-_C5JZhki.mjs.map → ColorPickerPopup-CFYCCN7m.mjs.map} +1 -1
  5. package/dist/chunks/{FontPlugin-C_ScWZ0P.mjs → FontPlugin-BySgRcF3.mjs} +2 -2
  6. package/dist/chunks/{FontPlugin-C_ScWZ0P.mjs.map → FontPlugin-BySgRcF3.mjs.map} +1 -1
  7. package/dist/chunks/{FontSizePlugin-DB_0njtC.mjs → FontSizePlugin-zJDiyhUv.mjs} +2 -2
  8. package/dist/chunks/{FontSizePlugin-DB_0njtC.mjs.map → FontSizePlugin-zJDiyhUv.mjs.map} +1 -1
  9. package/dist/chunks/HeadingPlugin-BCh12hFT.mjs +2 -0
  10. package/dist/chunks/HeadingPlugin-BCh12hFT.mjs.map +1 -0
  11. package/dist/chunks/{HighlightPlugin-B4WlZawl.mjs → HighlightPlugin-By7CWUss.mjs} +2 -2
  12. package/dist/chunks/{HighlightPlugin-B4WlZawl.mjs.map → HighlightPlugin-By7CWUss.mjs.map} +1 -1
  13. package/dist/chunks/{ImagePlugin-C5ESNNsA.mjs → ImagePlugin-C_MuvfYo.mjs} +2 -2
  14. package/dist/chunks/ImagePlugin-C_MuvfYo.mjs.map +1 -0
  15. package/dist/chunks/{LinkPlugin-BwXDGHPe.mjs → LinkPlugin-Bsmt97Kw.mjs} +2 -2
  16. package/dist/chunks/{LinkPlugin-BwXDGHPe.mjs.map → LinkPlugin-Bsmt97Kw.mjs.map} +1 -1
  17. package/dist/chunks/ListPlugin--dqEctgn.mjs +2 -0
  18. package/dist/chunks/{ListPlugin-DSFPSWQC.mjs.map → ListPlugin--dqEctgn.mjs.map} +1 -1
  19. package/dist/chunks/TablePlugin-CdXY0Px5.mjs +2 -0
  20. package/dist/chunks/TablePlugin-CdXY0Px5.mjs.map +1 -0
  21. package/dist/chunks/{TextColorPlugin-D_MhNJT6.mjs → TextColorPlugin-BLTKft_Z.mjs} +2 -2
  22. package/dist/chunks/{TextColorPlugin-D_MhNJT6.mjs.map → TextColorPlugin-BLTKft_Z.mjs.map} +1 -1
  23. package/dist/chunks/ToolbarPlugin-CMHJCdYY.mjs +2 -0
  24. package/dist/chunks/ToolbarPlugin-CMHJCdYY.mjs.map +1 -0
  25. package/dist/chunks/{full-Cshz7aTP.mjs → full-9sO5JbWG.mjs} +2 -2
  26. package/dist/chunks/{full-Cshz7aTP.mjs.map → full-9sO5JbWG.mjs.map} +1 -1
  27. package/dist/chunks/minimal-C07d5reO.mjs +2 -0
  28. package/dist/chunks/{minimal-7XqMY9kC.mjs.map → minimal-C07d5reO.mjs.map} +1 -1
  29. package/dist/chunks/register-DMdtiQ_Z.mjs +3 -0
  30. package/dist/chunks/register-DMdtiQ_Z.mjs.map +1 -0
  31. package/dist/full.mjs +1 -1
  32. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  33. package/dist/model/Keymap.d.ts +5 -2
  34. package/dist/model/Keymap.d.ts.map +1 -1
  35. package/dist/model/KeymapRegistry.d.ts +4 -1
  36. package/dist/model/KeymapRegistry.d.ts.map +1 -1
  37. package/dist/notectl-core.mjs +1 -1
  38. package/dist/notectl-core.umd.js +1 -1
  39. package/dist/notectl-core.umd.js.map +1 -1
  40. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  41. package/dist/plugins/font-size.mjs +1 -1
  42. package/dist/plugins/font.mjs +1 -1
  43. package/dist/plugins/heading.mjs +1 -1
  44. package/dist/plugins/highlight.mjs +1 -1
  45. package/dist/plugins/image.mjs +1 -1
  46. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  47. package/dist/plugins/link.mjs +1 -1
  48. package/dist/plugins/list/ListPlugin.d.ts +2 -1
  49. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  50. package/dist/plugins/list.mjs +1 -1
  51. package/dist/plugins/shared/ColorGrid.d.ts.map +1 -1
  52. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
  53. package/dist/plugins/shared.mjs +1 -1
  54. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
  55. package/dist/plugins/table.mjs +1 -1
  56. package/dist/plugins/text-color.mjs +1 -1
  57. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
  58. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +16 -0
  59. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  60. package/dist/plugins/toolbar.mjs +1 -1
  61. package/dist/presets/full.mjs +1 -1
  62. package/dist/presets/minimal.mjs +1 -1
  63. package/dist/presets.mjs +1 -1
  64. package/dist/register.mjs +1 -1
  65. package/dist/test/PluginTestUtils.d.ts +25 -0
  66. package/dist/test/PluginTestUtils.d.ts.map +1 -1
  67. package/package.json +2 -2
  68. package/dist/chunks/ColorPickerPopup-_C5JZhki.mjs +0 -2
  69. package/dist/chunks/HeadingPlugin-LK8Pg4h0.mjs +0 -2
  70. package/dist/chunks/HeadingPlugin-LK8Pg4h0.mjs.map +0 -1
  71. package/dist/chunks/ImagePlugin-C5ESNNsA.mjs.map +0 -1
  72. package/dist/chunks/ListPlugin-DSFPSWQC.mjs +0 -2
  73. package/dist/chunks/TablePlugin-C4WMYGWN.mjs +0 -2
  74. package/dist/chunks/TablePlugin-C4WMYGWN.mjs.map +0 -1
  75. package/dist/chunks/ToolbarPlugin-DdrLarMD.mjs +0 -2
  76. package/dist/chunks/ToolbarPlugin-DdrLarMD.mjs.map +0 -1
  77. package/dist/chunks/minimal-7XqMY9kC.mjs +0 -2
  78. package/dist/chunks/register-ArnJV5vu.mjs +0 -3
  79. package/dist/chunks/register-ArnJV5vu.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FontSizePlugin-DB_0njtC.mjs","names":[],"sources":["../../src/editor/styles/font-size-select.ts","../../src/plugins/font-size/FontSizeLocale.ts","../../src/plugins/font-size/FontSizeOperations.ts","../../src/plugins/font-size/FontSizePopup.ts","../../src/plugins/font-size/FontSizePlugin.ts"],"sourcesContent":["/** Font size picker toolbar combobox + popup styles. */\nexport const FONT_SIZE_SELECT_CSS = `\n/* Font Size Select — Width overrides for combobox button */\n.notectl-toolbar-btn--fontSize {\n\tmin-width: 60px;\n\tmax-width: 80px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n\tmin-width: 140px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n\tpadding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tfont-family: inherit;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n\toutline: none;\n\tbox-sizing: border-box;\n\t-moz-appearance: textfield;\n}\n\n.notectl-font-size-picker__input::-webkit-inner-spin-button,\n.notectl-font-size-picker__input::-webkit-outer-spin-button {\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n\tmax-height: 280px;\n\toverflow-y: auto;\n\tpadding: 4px 0;\n}\n\n.notectl-font-size-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--focused {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-font-size-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n`;\n","/** Locale interface and default English locale for the FontSizePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface FontSizeLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly customFontSizeAria: string;\n\treadonly fontSizesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_SIZE_LOCALE_EN: FontSizeLocale = {\n\tlabel: 'Font Size',\n\ttooltip: 'Font Size',\n\tcustomFontSizeAria: 'Custom font size',\n\tfontSizesAria: 'Font sizes',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<FontSizeLocale> = import.meta.glob<{\n\tdefault: FontSizeLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadFontSizeLocale(lang: string): Promise<FontSizeLocale> {\n\treturn loadLocaleModule(localeModules, lang, FONT_SIZE_LOCALE_EN);\n}\n","/**\n * Pure business logic for font-size state queries and transaction builders.\n * All functions are DOM-free and operate on EditorState / PluginContext.\n *\n * Delegates to the generic AttributedMarkCommands helpers for the\n * collapsed-vs-range branching logic.\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport type { BlockAttrs, BlockNode, InlineNode, Mark } from '../../model/Document.js';\nimport {\n\tgetBlockLength,\n\tgetInlineChildren,\n\tisInlineNode,\n\tisTextNode,\n\twalkInlineContent,\n} from '../../model/Document.js';\nimport {\n\tisCollapsed,\n\tisNodeSelection,\n\tisTextSelection,\n\tselectionRange,\n} from '../../model/Selection.js';\nimport { type BlockId, type MarkTypeName, markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent } from '../shared/PluginHelpers.js';\n\n// --- Node-level font sizing ---\n//\n// Marks only apply to text, so they cannot size atomic nodes such as a formula\n// (an inline node carries no marks; a display formula is a void block). Instead,\n// a node opts into font sizing by declaring a `fontSize` attribute in its schema\n// spec; the font-size controls then read/write that attribute. This stays generic\n// (no formula-specific coupling) — any node or inline node can opt in the same way.\n\ntype InlineNodeAttrs = Readonly<Record<string, string | number | boolean>>;\n\ntype NodeFontSizeTarget =\n\t| { readonly kind: 'block'; readonly path: readonly BlockId[]; readonly attrs: BlockAttrs }\n\t| {\n\t\t\treadonly kind: 'inline';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly attrs: InlineNodeAttrs;\n\t };\n\nfunction specDeclaresFontSize(\n\tspec: { readonly attrs?: Readonly<Record<string, unknown>> } | undefined,\n): boolean {\n\treturn spec?.attrs?.fontSize !== undefined;\n}\n\n/**\n * Resolves the node the current selection targets for font sizing, when that\n * node's schema spec declares a `fontSize` attribute: a void/selectable block\n * under a NodeSelection, or a single atomic inline node under a width-1 text\n * selection. Returns null for ordinary text (which uses the fontSize mark).\n */\nfunction nodeFontSizeTarget(state: EditorState): NodeFontSizeTarget | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) {\n\t\tconst block = state.getBlock(sel.nodeId);\n\t\tif (!block || !specDeclaresFontSize(state.schema.getNodeSpec?.(block.type))) return null;\n\t\tconst path: readonly BlockId[] = state.getNodePath(sel.nodeId) ?? [sel.nodeId];\n\t\treturn { kind: 'block', path, attrs: block.attrs ?? {} };\n\t}\n\tconst inline = singleSelectedInlineNode(state);\n\tif (inline && specDeclaresFontSize(state.schema.getInlineNodeSpec?.(inline.node.inlineType))) {\n\t\treturn {\n\t\t\tkind: 'inline',\n\t\t\tblockId: inline.blockId,\n\t\t\toffset: inline.offset,\n\t\t\tattrs: inline.node.attrs,\n\t\t};\n\t}\n\treturn null;\n}\n\n/** Returns the single inline node a width-1 text selection covers, if any. */\nfunction singleSelectedInlineNode(\n\tstate: EditorState,\n): { readonly node: InlineNode; readonly blockId: BlockId; readonly offset: number } | null {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel) || isCollapsed(sel)) return null;\n\tif (sel.anchor.blockId !== sel.head.blockId) return null;\n\tconst from: number = Math.min(sel.anchor.offset, sel.head.offset);\n\tconst to: number = Math.max(sel.anchor.offset, sel.head.offset);\n\tif (to - from !== 1) return null;\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tfor (const { child, from: childFrom } of walkInlineContent(getInlineChildren(block))) {\n\t\tif (childFrom === from && isInlineNode(child)) {\n\t\t\treturn { node: child, blockId: sel.anchor.blockId, offset: from };\n\t\t}\n\t}\n\treturn null;\n}\n\n/** Reads a fontSize attr value from raw attrs, or null when unset. */\nfunction readFontSize(attrs: BlockAttrs | InlineNodeAttrs | undefined): string | null {\n\tconst fontSize = attrs?.fontSize;\n\treturn typeof fontSize === 'string' && fontSize.length > 0 ? fontSize : null;\n}\n\n/** Merges a fontSize value ('' clears it) into existing attrs, preserving the rest. */\nfunction mergeFontSize(\n\tattrs: InlineNodeAttrs | undefined,\n\tsize: string,\n): Record<string, string | number | boolean>;\nfunction mergeFontSize(attrs: BlockAttrs | undefined, size: string): BlockAttrs;\nfunction mergeFontSize(attrs: BlockAttrs | InlineNodeAttrs | undefined, size: string): BlockAttrs {\n\treturn { ...(attrs ?? {}), fontSize: size };\n}\n\n/** The node's current fontSize value, or null when unset. */\nfunction nodeFontSizeValue(target: NodeFontSizeTarget): string | null {\n\treturn readFontSize(target.attrs);\n}\n\n/** Writes `size` (or '' to clear) onto a single target node's fontSize attr. */\nfunction dispatchNodeFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\ttarget: NodeFontSizeTarget,\n\tsize: string,\n): boolean {\n\tconst builder = state.transaction('command');\n\tif (target.kind === 'block') {\n\t\tbuilder.setNodeAttr(target.path, mergeFontSize(target.attrs, size));\n\t} else {\n\t\tbuilder.setInlineNodeAttr(target.blockId, target.offset, mergeFontSize(target.attrs, size));\n\t}\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n// --- Range carriers (text marks + font-size-aware nodes) ---\n//\n// A font-size operation over a selection range touches every \"carrier\" it spans:\n// text runs (which take the fontSize mark) and atomic font-size-aware nodes such\n// as formulas (which take the fontSize attr). This is what lets a select-all that\n// includes a formula resize the formula alongside the surrounding text.\n\nconst FONT_SIZE_TYPE: MarkTypeName = markType('fontSize');\n\ntype FontSizeCarrier =\n\t| {\n\t\t\treadonly kind: 'text';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly from: number;\n\t\t\treadonly to: number;\n\t\t\treadonly mark: Mark | undefined;\n\t }\n\t| { readonly kind: 'blockNode'; readonly path: readonly BlockId[]; readonly attrs: BlockAttrs }\n\t| {\n\t\t\treadonly kind: 'inlineNode';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly attrs: InlineNodeAttrs;\n\t };\n\n/** Enumerates the font-size carriers within the current (non-collapsed) text range. */\nfunction rangeCarriers(state: EditorState): FontSizeCarrier[] {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return [];\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst range = selectionRange(sel, blockOrder);\n\tconst fromIdx: number = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx: number = blockOrder.indexOf(range.to.blockId);\n\tconst carriers: FontSizeCarrier[] = [];\n\n\tfor (let i = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\t\tconst from: number = i === fromIdx ? range.from.offset : 0;\n\t\tconst to: number = i === toIdx ? range.to.offset : getBlockLength(block);\n\n\t\t// Atomic, font-size-aware block (e.g. a display formula): size the whole node.\n\t\tif (specDeclaresFontSize(state.schema.getNodeSpec?.(block.type))) {\n\t\t\tcarriers.push({\n\t\t\t\tkind: 'blockNode',\n\t\t\t\tpath: state.getNodePath(blockId) ?? [blockId],\n\t\t\t\tattrs: block.attrs ?? {},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (from === to) continue;\n\t\tcollectInlineCarriers(state, block, blockId, from, to, carriers);\n\t}\n\treturn carriers;\n}\n\n/** Adds a text carrier (when the slice holds text) plus any font-size-aware inline nodes. */\nfunction collectInlineCarriers(\n\tstate: EditorState,\n\tblock: BlockNode,\n\tblockId: BlockId,\n\tfrom: number,\n\tto: number,\n\tcarriers: FontSizeCarrier[],\n): void {\n\tlet pos = 0;\n\tlet hasText = false;\n\tlet textMark: Mark | undefined;\n\tfor (const child of getInlineChildren(block)) {\n\t\tif (isTextNode(child)) {\n\t\t\tconst end: number = pos + child.text.length;\n\t\t\tif (child.text.length > 0 && end > from && pos < to) {\n\t\t\t\thasText = true;\n\t\t\t\tif (!textMark) textMark = child.marks.find((m) => m.type === FONT_SIZE_TYPE);\n\t\t\t}\n\t\t\tpos = end;\n\t\t} else {\n\t\t\tif (\n\t\t\t\tpos >= from &&\n\t\t\t\tpos < to &&\n\t\t\t\tspecDeclaresFontSize(state.schema.getInlineNodeSpec?.(child.inlineType))\n\t\t\t) {\n\t\t\t\tcarriers.push({ kind: 'inlineNode', blockId, offset: pos, attrs: child.attrs });\n\t\t\t}\n\t\t\tpos += 1;\n\t\t}\n\t}\n\tif (hasText) carriers.push({ kind: 'text', blockId, from, to, mark: textMark });\n}\n\n/** Sizes every carrier in the range ('' clears). Returns false when nothing changed. */\nfunction dispatchRangeFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst carriers: FontSizeCarrier[] = rangeCarriers(state);\n\tif (carriers.length === 0) return false;\n\tconst builder = state.transaction('command');\n\tlet changed = false;\n\n\tfor (const carrier of carriers) {\n\t\tif (carrier.kind === 'text') {\n\t\t\tif (size === '') {\n\t\t\t\tif (carrier.mark) {\n\t\t\t\t\tbuilder.removeMark(carrier.blockId, carrier.from, carrier.to, carrier.mark);\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (carrier.mark)\n\t\t\t\t\tbuilder.removeMark(carrier.blockId, carrier.from, carrier.to, carrier.mark);\n\t\t\t\tbuilder.addMark(carrier.blockId, carrier.from, carrier.to, {\n\t\t\t\t\ttype: FONT_SIZE_TYPE,\n\t\t\t\t\tattrs: { size },\n\t\t\t\t});\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst current: string | null = readFontSize(carrier.attrs);\n\t\tif (size === current || (size === '' && current === null)) continue;\n\t\tif (carrier.kind === 'blockNode') {\n\t\t\tbuilder.setNodeAttr(carrier.path, mergeFontSize(carrier.attrs, size));\n\t\t} else {\n\t\t\tbuilder.setInlineNodeAttr(\n\t\t\t\tcarrier.blockId,\n\t\t\t\tcarrier.offset,\n\t\t\t\tmergeFontSize(carrier.attrs, size),\n\t\t\t);\n\t\t}\n\t\tchanged = true;\n\t}\n\n\tif (!changed) return false;\n\tbuilder.setSelection(state.selection);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** The set of fontSize values carried by font-size-aware nodes in the range, or null when none. */\nfunction rangeNodeSizes(state: EditorState): Set<string> | null {\n\tconst nodeAttrs: (BlockAttrs | InlineNodeAttrs)[] = rangeCarriers(state)\n\t\t.filter((carrier) => carrier.kind !== 'text')\n\t\t.map((carrier) => carrier.attrs);\n\tif (nodeAttrs.length === 0) return null;\n\treturn new Set(nodeAttrs.map((attrs) => readFontSize(attrs) ?? ''));\n}\n\n// --- State Queries ---\n\n/** Returns the raw fontSize CSS value at the current selection, or null. */\nexport function getActiveSize(state: EditorState): string | null {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return nodeFontSizeValue(target);\n\t// Additive: when a range spans font-size-aware nodes (e.g. a formula) that all\n\t// share one explicit size, report it; otherwise read the text mark as before.\n\tconst sizes = rangeNodeSizes(state);\n\tif (sizes && sizes.size === 1) {\n\t\tconst [only] = sizes;\n\t\tif (only) return only;\n\t}\n\treturn getMarkAttrAtSelection(state, 'fontSize', (m) => m.attrs.size ?? null);\n}\n\n/** Returns the active font size as a number, falling back to defaultSize. */\nexport function getActiveSizeNumeric(state: EditorState, defaultSize: number): number {\n\tconst raw: string | null = getActiveSize(state);\n\tif (!raw) return defaultSize;\n\tconst parsed: number = Number.parseInt(raw, 10);\n\treturn Number.isNaN(parsed) ? defaultSize : parsed;\n}\n\n/** Returns true when the selection carries a fontSize (mark or node attribute). */\nexport function isFontSizeActive(state: EditorState): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return nodeFontSizeValue(target) !== null;\n\tconst sizes = rangeNodeSizes(state);\n\tif (sizes && [...sizes].some((size) => size.length > 0)) return true;\n\treturn isAttributedMarkActive(state, 'fontSize');\n}\n\n// --- Commands ---\n\n/**\n * Applies the given CSS size to the selection: as a node `fontSize` attribute\n * when a font-size-aware node is selected (e.g. a formula), otherwise as a\n * fontSize mark on the selected text.\n */\nexport function applyFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return dispatchNodeFontSize(context, state, target, size);\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tif (isCollapsed(sel)) {\n\t\tconst mark = { type: markType('fontSize'), attrs: { size } };\n\t\treturn dispatchIfPresent(context, applyAttributedMark(state, mark));\n\t}\n\treturn dispatchRangeFontSize(context, state, size);\n}\n\n/** Removes the fontSize (node attribute or mark) from the current selection. */\nexport function removeFontSize(context: PluginContext, state: EditorState): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) {\n\t\tif (nodeFontSizeValue(target) === null) return false;\n\t\treturn dispatchNodeFontSize(context, state, target, '');\n\t}\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tif (isCollapsed(sel)) {\n\t\treturn dispatchIfPresent(context, removeAttributedMark(state, markType('fontSize')));\n\t}\n\treturn dispatchRangeFontSize(context, state, '');\n}\n\n/** Steps the font size up or down through the preset list. */\nexport function stepFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n\tdefaultSize: number,\n): boolean {\n\tconst current: number = getActiveSizeNumeric(state, defaultSize);\n\tconst next: number | null = getNextPresetSize(current, direction, sizes);\n\tif (next === null) return false;\n\n\tif (next === defaultSize) {\n\t\treturn removeFontSize(context, state);\n\t}\n\treturn applyFontSize(context, state, `${next}px`);\n}\n\n/**\n * Selects a specific font size: removes the mark when size equals the\n * default, otherwise applies the new size.\n */\nexport function selectSize(context: PluginContext, size: number, defaultSize: number): void {\n\tif (size === defaultSize) {\n\t\tcontext.executeCommand('removeFontSize');\n\t} else {\n\t\tapplyFontSize(context, context.getState(), `${size}px`);\n\t}\n}\n\n// --- Helpers ---\n\n/** Finds the next preset size in the given direction, or null at boundaries. */\nexport function getNextPresetSize(\n\tcurrent: number,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n): number | null {\n\tif (direction === 'up') {\n\t\tfor (const size of sizes) {\n\t\t\tif (size > current) return size;\n\t\t}\n\t\treturn null;\n\t}\n\tfor (let i: number = sizes.length - 1; i >= 0; i--) {\n\t\tconst size: number | undefined = sizes[i];\n\t\tif (size !== undefined && size < current) return size;\n\t}\n\treturn null;\n}\n","/**\n * Renders the font-size picker popup with a custom numeric input\n * and an accessible preset list with keyboard navigation.\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport type { FontSizeLocale } from './FontSizeLocale.js';\nimport { getActiveSizeNumeric, selectSize } from './FontSizeOperations.js';\n\n// --- Constants ---\n\nconst MIN_CUSTOM_SIZE = 1;\nconst MAX_CUSTOM_SIZE = 400;\n\n// --- Config ---\n\nexport interface FontSizePopupConfig {\n\treadonly sizes: readonly number[];\n\treadonly defaultSize: number;\n\treadonly onClose: (options?: PopupCloseOptions) => void;\n\treadonly contentElement: HTMLElement;\n\treadonly locale: FontSizeLocale;\n}\n\n// --- Public Entry Point ---\n\n/** Builds the font-size picker DOM inside the given container. */\nexport function renderFontSizePopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tcontainer.classList.add('notectl-font-size-picker');\n\n\tconst currentSize: number = getActiveSizeNumeric(context.getState(), config.defaultSize);\n\n\tconst input: HTMLInputElement = buildCustomInput(currentSize, config);\n\tappendInputWrapper(container, input);\n\n\tconst { list, items } = buildSizeList(config.sizes, currentSize, context, config);\n\tcontainer.appendChild(list);\n\n\tscrollActiveIntoView(items, config.sizes, currentSize, list);\n\tattachKeyboardNavigation(input, list, items, context, config);\n}\n\n// --- Custom Input ---\n\nfunction buildCustomInput(currentSize: number, config: FontSizePopupConfig): HTMLInputElement {\n\tconst input: HTMLInputElement = document.createElement('input');\n\tinput.type = 'number';\n\tinput.className = 'notectl-font-size-picker__input';\n\tinput.min = String(MIN_CUSTOM_SIZE);\n\tinput.max = String(MAX_CUSTOM_SIZE);\n\tinput.value = String(currentSize);\n\tinput.setAttribute('aria-label', config.locale.customFontSizeAria);\n\treturn input;\n}\n\nfunction appendInputWrapper(container: HTMLElement, input: HTMLInputElement): void {\n\tconst wrapper: HTMLDivElement = document.createElement('div');\n\twrapper.className = 'notectl-font-size-picker__input-wrapper';\n\twrapper.appendChild(input);\n\tcontainer.appendChild(wrapper);\n}\n\n// --- Size List ---\n\ninterface SizeListResult {\n\treadonly list: HTMLDivElement;\n\treadonly items: HTMLButtonElement[];\n}\n\nfunction buildSizeList(\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): SizeListResult {\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-font-size-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', config.locale.fontSizesAria);\n\n\tconst items: HTMLButtonElement[] = [];\n\n\tfor (const size of sizes) {\n\t\tconst isActive: boolean = size === currentSize;\n\t\tconst item: HTMLButtonElement = buildSizeItem(size, isActive);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tselectSize(context, size, config.defaultSize);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t});\n\n\t\titems.push(item);\n\t\tlist.appendChild(item);\n\t}\n\n\treturn { list, items };\n}\n\nfunction buildSizeItem(size: number, isActive: boolean): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.id = `notectl-font-size-option-${size}`;\n\titem.className = 'notectl-font-size-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-font-size-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-font-size-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst label: HTMLSpanElement = document.createElement('span');\n\tlabel.className = 'notectl-font-size-picker__label';\n\tlabel.textContent = String(size);\n\titem.appendChild(label);\n\n\treturn item;\n}\n\n// --- Scroll ---\n\nfunction scrollActiveIntoView(\n\titems: HTMLButtonElement[],\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tlist: HTMLDivElement,\n): void {\n\tconst activeIdx: number = sizes.indexOf(currentSize);\n\tif (activeIdx < 0) return;\n\n\tconst activeItem: HTMLButtonElement | undefined = items[activeIdx];\n\tif (!activeItem) return;\n\n\trequestAnimationFrame(() => {\n\t\tactiveItem.scrollIntoView({ block: 'nearest' });\n\t});\n\tlist.setAttribute('aria-activedescendant', activeItem.id);\n}\n\n// --- Keyboard Navigation ---\n\nfunction attachKeyboardNavigation(\n\tinput: HTMLInputElement,\n\tlist: HTMLDivElement,\n\titems: HTMLButtonElement[],\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tlet focusedIndex = -1;\n\n\tconst setFocused = (idx: number): void => {\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length) {\n\t\t\titems[focusedIndex]?.classList.remove('notectl-font-size-picker__item--focused');\n\t\t}\n\t\tfocusedIndex = idx;\n\t\tconst el: HTMLButtonElement | undefined = items[focusedIndex];\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length && el) {\n\t\t\tel.classList.add('notectl-font-size-picker__item--focused');\n\t\t\tel.scrollIntoView({ block: 'nearest' });\n\t\t\tlist.setAttribute('aria-activedescendant', el.id);\n\t\t}\n\t};\n\n\t// As an editable combobox (input + listbox), this popup owns its keyboard\n\t// model. `consume` claims a handled key so the toolbar's generic popup\n\t// handler does not also act on it and advance focus a second time (#144).\n\tconst consume = (e: KeyboardEvent): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t};\n\n\tinput.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\tconsume(e);\n\t\t\tconst val: number = Number.parseInt(input.value, 10);\n\t\t\tif (!Number.isNaN(val) && val >= MIN_CUSTOM_SIZE && val <= MAX_CUSTOM_SIZE) {\n\t\t\t\tselectSize(context, val, config.defaultSize);\n\t\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t\t}\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\tconsume(e);\n\t\t\tsetFocused(0);\n\t\t\titems[0]?.focus();\n\t\t} else if (e.key === 'Escape') {\n\t\t\tconsume(e);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n\n\tlist.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'ArrowDown') {\n\t\t\tconsume(e);\n\t\t\tif (focusedIndex < items.length - 1) {\n\t\t\t\tsetFocused(focusedIndex + 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowUp') {\n\t\t\tconsume(e);\n\t\t\tif (focusedIndex > 0) {\n\t\t\t\tsetFocused(focusedIndex - 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t} else {\n\t\t\t\tsetFocused(-1);\n\t\t\t\tinput.focus();\n\t\t\t}\n\t\t} else if (e.key === 'Enter') {\n\t\t\tconsume(e);\n\t\t\tconst selectedSize: number | undefined = config.sizes[focusedIndex];\n\t\t\tif (focusedIndex >= 0 && focusedIndex < config.sizes.length && selectedSize !== undefined) {\n\t\t\t\tselectSize(context, selectedSize, config.defaultSize);\n\t\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t\t}\n\t\t} else if (e.key === 'Escape') {\n\t\t\tconsume(e);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n}\n","/**\n * FontSizePlugin: registers a fontSize mark with attrs, a combobox-style\n * toolbar selector with WCAG-accessible popup, and commands for\n * increasing / decreasing font size.\n */\n\nimport { FONT_SIZE_SELECT_CSS } from '../../editor/styles/font-size-select.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isValidCSSFontSize } from '../shared/ColorValidation.js';\nimport { createInlineStyleMarkSpec } from '../shared/InlineStyleMarkSpec.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { FONT_SIZE_LOCALE_EN, type FontSizeLocale, loadFontSizeLocale } from './FontSizeLocale.js';\nimport {\n\tgetActiveSizeNumeric,\n\tisFontSizeActive,\n\tremoveFontSize,\n\tstepFontSize,\n} from './FontSizeOperations.js';\nimport { renderFontSizePopup } from './FontSizePopup.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfontSize: { size: string };\n\t}\n}\n\n// --- Constants ---\n\n/** Default preset sizes shown in the font size dropdown. */\nexport const DEFAULT_FONT_SIZES: readonly number[] = [\n\t8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96,\n];\n\nconst DEFAULT_FONT_SIZE = 16;\n\n// --- Configuration ---\n\nexport interface FontSizeConfig {\n\t/**\n\t * Preset sizes shown in the font size dropdown.\n\t * Must contain positive integers. Values are sorted and deduplicated automatically.\n\t * Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The base font size that text has when no fontSize mark is applied.\n\t * Shown as the initial value in the toolbar combo and used as the\n\t * \"neutral\" size — selecting it removes the mark instead of applying one.\n\t * Defaults to 16.\n\t */\n\treadonly defaultSize?: number;\n\treadonly locale?: FontSizeLocale;\n}\n\n// --- Plugin ---\n\nexport class FontSizePlugin implements Plugin {\n\treadonly id = 'fontSize';\n\treadonly name = 'Font Size';\n\treadonly priority = 21;\n\n\tprivate readonly config: FontSizeConfig;\n\tprivate readonly sizes: readonly number[];\n\tprivate readonly defaultSize: number;\n\tprivate locale!: FontSizeLocale;\n\n\tconstructor(config?: Partial<FontSizeConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.sizes = resolveSizes(config?.sizes);\n\t\tthis.defaultSize = resolveDefaultSize(config?.defaultSize);\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tFONT_SIZE_LOCALE_EN,\n\t\t\tloadFontSizeLocale,\n\t\t);\n\n\t\tcontext.registerStyleSheet(FONT_SIZE_SELECT_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.applyDefaultSizeToContainer(context);\n\t}\n\n\tdestroy(): void {\n\t\t// no-op: nothing to clean up\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec(\n\t\t\tcreateInlineStyleMarkSpec({\n\t\t\t\ttype: 'fontSize',\n\t\t\t\trank: 4,\n\t\t\t\tvalueAttr: 'size',\n\t\t\t\tdomStyleProperty: 'fontSize',\n\t\t\t\tcssProperty: 'font-size',\n\t\t\t\tvalidate: isValidCSSFontSize,\n\t\t\t}),\n\t\t);\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFontSize', () => {\n\t\t\treturn removeFontSize(context, context.getState());\n\t\t});\n\n\t\tcontext.registerCommand('setFontSize', () => {\n\t\t\treturn false;\n\t\t});\n\n\t\tcontext.registerCommand('increaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t});\n\n\t\tcontext.registerCommand('decreaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t});\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-+': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t\t'Mod-Shift-_': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'fontSize',\n\t\t\tgroup: 'format',\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFontSize',\n\t\t\tpopupType: 'combobox',\n\t\t\tgetLabel: (state: EditorState): string =>\n\t\t\t\tString(getActiveSizeNumeric(state, this.defaultSize)),\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderFontSizePopup(container, ctx, {\n\t\t\t\t\tsizes: this.sizes,\n\t\t\t\t\tdefaultSize: this.defaultSize,\n\t\t\t\t\tonClose,\n\t\t\t\t\tcontentElement: ctx.getContainer(),\n\t\t\t\t\tlocale: this.locale,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state) => isFontSizeActive(state),\n\t\t});\n\t}\n\n\t/**\n\t * Sets the configured default font size on the editor content container\n\t * so that unformatted text renders at the correct size instead of the\n\t * browser default (16px).\n\t */\n\tprivate applyDefaultSizeToContainer(context: PluginContext): void {\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tsetStyleProperty(container, 'fontSize', `${this.defaultSize}px`);\n\t}\n}\n\n// --- Helpers ---\n\nfunction resolveSizes(sizes: readonly number[] | undefined): readonly number[] {\n\tif (!sizes || sizes.length === 0) return DEFAULT_FONT_SIZES;\n\tconst unique: number[] = [...new Set(sizes)].filter((n) => Number.isInteger(n) && n > 0);\n\tunique.sort((a, b) => a - b);\n\treturn unique.length > 0 ? unique : DEFAULT_FONT_SIZES;\n}\n\nfunction resolveDefaultSize(size: number | undefined): number {\n\tif (size === undefined) return DEFAULT_FONT_SIZE;\n\treturn Number.isInteger(size) && size > 0 ? size : DEFAULT_FONT_SIZE;\n}\n"],"mappings":"geACA,ICca,EAAsC,CAClD,MAAO,YACP,QAAS,YACT,mB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B,IAAjB,IAC9D,EAAW,EAAS,EAAc,EAAO,aACzC,EAAO,QAAQ,CAAE,eAAgB,EAAO,iBAE1C,KAAqB,WAAV,EAAE,MACZ,EAAQ,GACR,EAAO,QAAQ,CAAE,eAAgB,EAAO,mBAG3C,CAxLC,CAAyB,EAAO,EAAM,EAAO,EAAS,EACvD,CCgHI,CAAoB,EAAW,EAAK,CACnC,MAAO,KAAK,MACZ,YAAa,KAAK,YAClB,UACA,eAAgB,EAAI,eACpB,OAAQ,KAAK,UAGf,SAAW,GFqJd,SAAiC,GAChC,MAAM,EAAS,EAAmB,GAClC,GAAI,EAAQ,OAAqC,OAA9B,EAAkB,GACrC,MAAM,EAAQ,EAAe,GAC7B,SAAI,IAAS,IAAI,GAAO,KAAM,GAAS,EAAK,OAAS,KAC9C,EAAuB,EAAO,WACtC,CE3JwB,CAAiB,IAExC,CAOA,2BAAA,CAAoC,GACnC,MAAM,EAAyB,EAAQ,eACvC,EAAiB,EAAW,WAAY,GAAG,KAAK,gBACjD"}
1
+ {"version":3,"file":"FontSizePlugin-zJDiyhUv.mjs","names":[],"sources":["../../src/editor/styles/font-size-select.ts","../../src/plugins/font-size/FontSizeLocale.ts","../../src/plugins/font-size/FontSizeOperations.ts","../../src/plugins/font-size/FontSizePopup.ts","../../src/plugins/font-size/FontSizePlugin.ts"],"sourcesContent":["/** Font size picker toolbar combobox + popup styles. */\nexport const FONT_SIZE_SELECT_CSS = `\n/* Font Size Select — Width overrides for combobox button */\n.notectl-toolbar-btn--fontSize {\n\tmin-width: 60px;\n\tmax-width: 80px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n\tmin-width: 140px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n\tpadding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tfont-family: inherit;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n\toutline: none;\n\tbox-sizing: border-box;\n\t-moz-appearance: textfield;\n}\n\n.notectl-font-size-picker__input::-webkit-inner-spin-button,\n.notectl-font-size-picker__input::-webkit-outer-spin-button {\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n\tmax-height: 280px;\n\toverflow-y: auto;\n\tpadding: 4px 0;\n}\n\n.notectl-font-size-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--focused {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-font-size-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n`;\n","/** Locale interface and default English locale for the FontSizePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface FontSizeLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly customFontSizeAria: string;\n\treadonly fontSizesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_SIZE_LOCALE_EN: FontSizeLocale = {\n\tlabel: 'Font Size',\n\ttooltip: 'Font Size',\n\tcustomFontSizeAria: 'Custom font size',\n\tfontSizesAria: 'Font sizes',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<FontSizeLocale> = import.meta.glob<{\n\tdefault: FontSizeLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadFontSizeLocale(lang: string): Promise<FontSizeLocale> {\n\treturn loadLocaleModule(localeModules, lang, FONT_SIZE_LOCALE_EN);\n}\n","/**\n * Pure business logic for font-size state queries and transaction builders.\n * All functions are DOM-free and operate on EditorState / PluginContext.\n *\n * Delegates to the generic AttributedMarkCommands helpers for the\n * collapsed-vs-range branching logic.\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport type { BlockAttrs, BlockNode, InlineNode, Mark } from '../../model/Document.js';\nimport {\n\tgetBlockLength,\n\tgetInlineChildren,\n\tisInlineNode,\n\tisTextNode,\n\twalkInlineContent,\n} from '../../model/Document.js';\nimport {\n\tisCollapsed,\n\tisNodeSelection,\n\tisTextSelection,\n\tselectionRange,\n} from '../../model/Selection.js';\nimport { type BlockId, type MarkTypeName, markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent } from '../shared/PluginHelpers.js';\n\n// --- Node-level font sizing ---\n//\n// Marks only apply to text, so they cannot size atomic nodes such as a formula\n// (an inline node carries no marks; a display formula is a void block). Instead,\n// a node opts into font sizing by declaring a `fontSize` attribute in its schema\n// spec; the font-size controls then read/write that attribute. This stays generic\n// (no formula-specific coupling) — any node or inline node can opt in the same way.\n\ntype InlineNodeAttrs = Readonly<Record<string, string | number | boolean>>;\n\ntype NodeFontSizeTarget =\n\t| { readonly kind: 'block'; readonly path: readonly BlockId[]; readonly attrs: BlockAttrs }\n\t| {\n\t\t\treadonly kind: 'inline';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly attrs: InlineNodeAttrs;\n\t };\n\nfunction specDeclaresFontSize(\n\tspec: { readonly attrs?: Readonly<Record<string, unknown>> } | undefined,\n): boolean {\n\treturn spec?.attrs?.fontSize !== undefined;\n}\n\n/**\n * Resolves the node the current selection targets for font sizing, when that\n * node's schema spec declares a `fontSize` attribute: a void/selectable block\n * under a NodeSelection, or a single atomic inline node under a width-1 text\n * selection. Returns null for ordinary text (which uses the fontSize mark).\n */\nfunction nodeFontSizeTarget(state: EditorState): NodeFontSizeTarget | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) {\n\t\tconst block = state.getBlock(sel.nodeId);\n\t\tif (!block || !specDeclaresFontSize(state.schema.getNodeSpec?.(block.type))) return null;\n\t\tconst path: readonly BlockId[] = state.getNodePath(sel.nodeId) ?? [sel.nodeId];\n\t\treturn { kind: 'block', path, attrs: block.attrs ?? {} };\n\t}\n\tconst inline = singleSelectedInlineNode(state);\n\tif (inline && specDeclaresFontSize(state.schema.getInlineNodeSpec?.(inline.node.inlineType))) {\n\t\treturn {\n\t\t\tkind: 'inline',\n\t\t\tblockId: inline.blockId,\n\t\t\toffset: inline.offset,\n\t\t\tattrs: inline.node.attrs,\n\t\t};\n\t}\n\treturn null;\n}\n\n/** Returns the single inline node a width-1 text selection covers, if any. */\nfunction singleSelectedInlineNode(\n\tstate: EditorState,\n): { readonly node: InlineNode; readonly blockId: BlockId; readonly offset: number } | null {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel) || isCollapsed(sel)) return null;\n\tif (sel.anchor.blockId !== sel.head.blockId) return null;\n\tconst from: number = Math.min(sel.anchor.offset, sel.head.offset);\n\tconst to: number = Math.max(sel.anchor.offset, sel.head.offset);\n\tif (to - from !== 1) return null;\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tfor (const { child, from: childFrom } of walkInlineContent(getInlineChildren(block))) {\n\t\tif (childFrom === from && isInlineNode(child)) {\n\t\t\treturn { node: child, blockId: sel.anchor.blockId, offset: from };\n\t\t}\n\t}\n\treturn null;\n}\n\n/** Reads a fontSize attr value from raw attrs, or null when unset. */\nfunction readFontSize(attrs: BlockAttrs | InlineNodeAttrs | undefined): string | null {\n\tconst fontSize = attrs?.fontSize;\n\treturn typeof fontSize === 'string' && fontSize.length > 0 ? fontSize : null;\n}\n\n/** Merges a fontSize value ('' clears it) into existing attrs, preserving the rest. */\nfunction mergeFontSize(\n\tattrs: InlineNodeAttrs | undefined,\n\tsize: string,\n): Record<string, string | number | boolean>;\nfunction mergeFontSize(attrs: BlockAttrs | undefined, size: string): BlockAttrs;\nfunction mergeFontSize(attrs: BlockAttrs | InlineNodeAttrs | undefined, size: string): BlockAttrs {\n\treturn { ...(attrs ?? {}), fontSize: size };\n}\n\n/** The node's current fontSize value, or null when unset. */\nfunction nodeFontSizeValue(target: NodeFontSizeTarget): string | null {\n\treturn readFontSize(target.attrs);\n}\n\n/** Writes `size` (or '' to clear) onto a single target node's fontSize attr. */\nfunction dispatchNodeFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\ttarget: NodeFontSizeTarget,\n\tsize: string,\n): boolean {\n\tconst builder = state.transaction('command');\n\tif (target.kind === 'block') {\n\t\tbuilder.setNodeAttr(target.path, mergeFontSize(target.attrs, size));\n\t} else {\n\t\tbuilder.setInlineNodeAttr(target.blockId, target.offset, mergeFontSize(target.attrs, size));\n\t}\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n// --- Range carriers (text marks + font-size-aware nodes) ---\n//\n// A font-size operation over a selection range touches every \"carrier\" it spans:\n// text runs (which take the fontSize mark) and atomic font-size-aware nodes such\n// as formulas (which take the fontSize attr). This is what lets a select-all that\n// includes a formula resize the formula alongside the surrounding text.\n\nconst FONT_SIZE_TYPE: MarkTypeName = markType('fontSize');\n\ntype FontSizeCarrier =\n\t| {\n\t\t\treadonly kind: 'text';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly from: number;\n\t\t\treadonly to: number;\n\t\t\treadonly mark: Mark | undefined;\n\t }\n\t| { readonly kind: 'blockNode'; readonly path: readonly BlockId[]; readonly attrs: BlockAttrs }\n\t| {\n\t\t\treadonly kind: 'inlineNode';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly attrs: InlineNodeAttrs;\n\t };\n\n/** Enumerates the font-size carriers within the current (non-collapsed) text range. */\nfunction rangeCarriers(state: EditorState): FontSizeCarrier[] {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return [];\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst range = selectionRange(sel, blockOrder);\n\tconst fromIdx: number = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx: number = blockOrder.indexOf(range.to.blockId);\n\tconst carriers: FontSizeCarrier[] = [];\n\n\tfor (let i = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\t\tconst from: number = i === fromIdx ? range.from.offset : 0;\n\t\tconst to: number = i === toIdx ? range.to.offset : getBlockLength(block);\n\n\t\t// Atomic, font-size-aware block (e.g. a display formula): size the whole node.\n\t\tif (specDeclaresFontSize(state.schema.getNodeSpec?.(block.type))) {\n\t\t\tcarriers.push({\n\t\t\t\tkind: 'blockNode',\n\t\t\t\tpath: state.getNodePath(blockId) ?? [blockId],\n\t\t\t\tattrs: block.attrs ?? {},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (from === to) continue;\n\t\tcollectInlineCarriers(state, block, blockId, from, to, carriers);\n\t}\n\treturn carriers;\n}\n\n/** Adds a text carrier (when the slice holds text) plus any font-size-aware inline nodes. */\nfunction collectInlineCarriers(\n\tstate: EditorState,\n\tblock: BlockNode,\n\tblockId: BlockId,\n\tfrom: number,\n\tto: number,\n\tcarriers: FontSizeCarrier[],\n): void {\n\tlet pos = 0;\n\tlet hasText = false;\n\tlet textMark: Mark | undefined;\n\tfor (const child of getInlineChildren(block)) {\n\t\tif (isTextNode(child)) {\n\t\t\tconst end: number = pos + child.text.length;\n\t\t\tif (child.text.length > 0 && end > from && pos < to) {\n\t\t\t\thasText = true;\n\t\t\t\tif (!textMark) textMark = child.marks.find((m) => m.type === FONT_SIZE_TYPE);\n\t\t\t}\n\t\t\tpos = end;\n\t\t} else {\n\t\t\tif (\n\t\t\t\tpos >= from &&\n\t\t\t\tpos < to &&\n\t\t\t\tspecDeclaresFontSize(state.schema.getInlineNodeSpec?.(child.inlineType))\n\t\t\t) {\n\t\t\t\tcarriers.push({ kind: 'inlineNode', blockId, offset: pos, attrs: child.attrs });\n\t\t\t}\n\t\t\tpos += 1;\n\t\t}\n\t}\n\tif (hasText) carriers.push({ kind: 'text', blockId, from, to, mark: textMark });\n}\n\n/** Sizes every carrier in the range ('' clears). Returns false when nothing changed. */\nfunction dispatchRangeFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst carriers: FontSizeCarrier[] = rangeCarriers(state);\n\tif (carriers.length === 0) return false;\n\tconst builder = state.transaction('command');\n\tlet changed = false;\n\n\tfor (const carrier of carriers) {\n\t\tif (carrier.kind === 'text') {\n\t\t\tif (size === '') {\n\t\t\t\tif (carrier.mark) {\n\t\t\t\t\tbuilder.removeMark(carrier.blockId, carrier.from, carrier.to, carrier.mark);\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (carrier.mark)\n\t\t\t\t\tbuilder.removeMark(carrier.blockId, carrier.from, carrier.to, carrier.mark);\n\t\t\t\tbuilder.addMark(carrier.blockId, carrier.from, carrier.to, {\n\t\t\t\t\ttype: FONT_SIZE_TYPE,\n\t\t\t\t\tattrs: { size },\n\t\t\t\t});\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst current: string | null = readFontSize(carrier.attrs);\n\t\tif (size === current || (size === '' && current === null)) continue;\n\t\tif (carrier.kind === 'blockNode') {\n\t\t\tbuilder.setNodeAttr(carrier.path, mergeFontSize(carrier.attrs, size));\n\t\t} else {\n\t\t\tbuilder.setInlineNodeAttr(\n\t\t\t\tcarrier.blockId,\n\t\t\t\tcarrier.offset,\n\t\t\t\tmergeFontSize(carrier.attrs, size),\n\t\t\t);\n\t\t}\n\t\tchanged = true;\n\t}\n\n\tif (!changed) return false;\n\tbuilder.setSelection(state.selection);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** The set of fontSize values carried by font-size-aware nodes in the range, or null when none. */\nfunction rangeNodeSizes(state: EditorState): Set<string> | null {\n\tconst nodeAttrs: (BlockAttrs | InlineNodeAttrs)[] = rangeCarriers(state)\n\t\t.filter((carrier) => carrier.kind !== 'text')\n\t\t.map((carrier) => carrier.attrs);\n\tif (nodeAttrs.length === 0) return null;\n\treturn new Set(nodeAttrs.map((attrs) => readFontSize(attrs) ?? ''));\n}\n\n// --- State Queries ---\n\n/** Returns the raw fontSize CSS value at the current selection, or null. */\nexport function getActiveSize(state: EditorState): string | null {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return nodeFontSizeValue(target);\n\t// Additive: when a range spans font-size-aware nodes (e.g. a formula) that all\n\t// share one explicit size, report it; otherwise read the text mark as before.\n\tconst sizes = rangeNodeSizes(state);\n\tif (sizes && sizes.size === 1) {\n\t\tconst [only] = sizes;\n\t\tif (only) return only;\n\t}\n\treturn getMarkAttrAtSelection(state, 'fontSize', (m) => m.attrs.size ?? null);\n}\n\n/** Returns the active font size as a number, falling back to defaultSize. */\nexport function getActiveSizeNumeric(state: EditorState, defaultSize: number): number {\n\tconst raw: string | null = getActiveSize(state);\n\tif (!raw) return defaultSize;\n\tconst parsed: number = Number.parseInt(raw, 10);\n\treturn Number.isNaN(parsed) ? defaultSize : parsed;\n}\n\n/** Returns true when the selection carries a fontSize (mark or node attribute). */\nexport function isFontSizeActive(state: EditorState): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return nodeFontSizeValue(target) !== null;\n\tconst sizes = rangeNodeSizes(state);\n\tif (sizes && [...sizes].some((size) => size.length > 0)) return true;\n\treturn isAttributedMarkActive(state, 'fontSize');\n}\n\n// --- Commands ---\n\n/**\n * Applies the given CSS size to the selection: as a node `fontSize` attribute\n * when a font-size-aware node is selected (e.g. a formula), otherwise as a\n * fontSize mark on the selected text.\n */\nexport function applyFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return dispatchNodeFontSize(context, state, target, size);\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tif (isCollapsed(sel)) {\n\t\tconst mark = { type: markType('fontSize'), attrs: { size } };\n\t\treturn dispatchIfPresent(context, applyAttributedMark(state, mark));\n\t}\n\treturn dispatchRangeFontSize(context, state, size);\n}\n\n/** Removes the fontSize (node attribute or mark) from the current selection. */\nexport function removeFontSize(context: PluginContext, state: EditorState): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) {\n\t\tif (nodeFontSizeValue(target) === null) return false;\n\t\treturn dispatchNodeFontSize(context, state, target, '');\n\t}\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tif (isCollapsed(sel)) {\n\t\treturn dispatchIfPresent(context, removeAttributedMark(state, markType('fontSize')));\n\t}\n\treturn dispatchRangeFontSize(context, state, '');\n}\n\n/** Steps the font size up or down through the preset list. */\nexport function stepFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n\tdefaultSize: number,\n): boolean {\n\tconst current: number = getActiveSizeNumeric(state, defaultSize);\n\tconst next: number | null = getNextPresetSize(current, direction, sizes);\n\tif (next === null) return false;\n\n\tif (next === defaultSize) {\n\t\treturn removeFontSize(context, state);\n\t}\n\treturn applyFontSize(context, state, `${next}px`);\n}\n\n/**\n * Selects a specific font size: removes the mark when size equals the\n * default, otherwise applies the new size.\n */\nexport function selectSize(context: PluginContext, size: number, defaultSize: number): void {\n\tif (size === defaultSize) {\n\t\tcontext.executeCommand('removeFontSize');\n\t} else {\n\t\tapplyFontSize(context, context.getState(), `${size}px`);\n\t}\n}\n\n// --- Helpers ---\n\n/** Finds the next preset size in the given direction, or null at boundaries. */\nexport function getNextPresetSize(\n\tcurrent: number,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n): number | null {\n\tif (direction === 'up') {\n\t\tfor (const size of sizes) {\n\t\t\tif (size > current) return size;\n\t\t}\n\t\treturn null;\n\t}\n\tfor (let i: number = sizes.length - 1; i >= 0; i--) {\n\t\tconst size: number | undefined = sizes[i];\n\t\tif (size !== undefined && size < current) return size;\n\t}\n\treturn null;\n}\n","/**\n * Renders the font-size picker popup with a custom numeric input\n * and an accessible preset list with keyboard navigation.\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport type { FontSizeLocale } from './FontSizeLocale.js';\nimport { getActiveSizeNumeric, selectSize } from './FontSizeOperations.js';\n\n// --- Constants ---\n\nconst MIN_CUSTOM_SIZE = 1;\nconst MAX_CUSTOM_SIZE = 400;\n\n// --- Config ---\n\nexport interface FontSizePopupConfig {\n\treadonly sizes: readonly number[];\n\treadonly defaultSize: number;\n\treadonly onClose: (options?: PopupCloseOptions) => void;\n\treadonly contentElement: HTMLElement;\n\treadonly locale: FontSizeLocale;\n}\n\n// --- Public Entry Point ---\n\n/** Builds the font-size picker DOM inside the given container. */\nexport function renderFontSizePopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tcontainer.classList.add('notectl-font-size-picker');\n\n\tconst currentSize: number = getActiveSizeNumeric(context.getState(), config.defaultSize);\n\n\tconst input: HTMLInputElement = buildCustomInput(currentSize, config);\n\tappendInputWrapper(container, input);\n\n\tconst { list, items } = buildSizeList(config.sizes, currentSize, context, config);\n\tcontainer.appendChild(list);\n\n\tscrollActiveIntoView(items, config.sizes, currentSize, list);\n\tattachKeyboardNavigation(input, list, items, context, config);\n}\n\n// --- Custom Input ---\n\nfunction buildCustomInput(currentSize: number, config: FontSizePopupConfig): HTMLInputElement {\n\tconst input: HTMLInputElement = document.createElement('input');\n\tinput.type = 'number';\n\tinput.className = 'notectl-font-size-picker__input';\n\tinput.min = String(MIN_CUSTOM_SIZE);\n\tinput.max = String(MAX_CUSTOM_SIZE);\n\tinput.value = String(currentSize);\n\tinput.setAttribute('aria-label', config.locale.customFontSizeAria);\n\treturn input;\n}\n\nfunction appendInputWrapper(container: HTMLElement, input: HTMLInputElement): void {\n\tconst wrapper: HTMLDivElement = document.createElement('div');\n\twrapper.className = 'notectl-font-size-picker__input-wrapper';\n\twrapper.appendChild(input);\n\tcontainer.appendChild(wrapper);\n}\n\n// --- Size List ---\n\ninterface SizeListResult {\n\treadonly list: HTMLDivElement;\n\treadonly items: HTMLButtonElement[];\n}\n\nfunction buildSizeList(\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): SizeListResult {\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-font-size-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', config.locale.fontSizesAria);\n\n\tconst items: HTMLButtonElement[] = [];\n\n\tfor (const size of sizes) {\n\t\tconst isActive: boolean = size === currentSize;\n\t\tconst item: HTMLButtonElement = buildSizeItem(size, isActive);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t});\n\t\titem.addEventListener('click', () => {\n\t\t\tselectSize(context, size, config.defaultSize);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t});\n\n\t\titems.push(item);\n\t\tlist.appendChild(item);\n\t}\n\n\treturn { list, items };\n}\n\nfunction buildSizeItem(size: number, isActive: boolean): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.id = `notectl-font-size-option-${size}`;\n\titem.className = 'notectl-font-size-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-font-size-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-font-size-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst label: HTMLSpanElement = document.createElement('span');\n\tlabel.className = 'notectl-font-size-picker__label';\n\tlabel.textContent = String(size);\n\titem.appendChild(label);\n\n\treturn item;\n}\n\n// --- Scroll ---\n\nfunction scrollActiveIntoView(\n\titems: HTMLButtonElement[],\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tlist: HTMLDivElement,\n): void {\n\tconst activeIdx: number = sizes.indexOf(currentSize);\n\tif (activeIdx < 0) return;\n\n\tconst activeItem: HTMLButtonElement | undefined = items[activeIdx];\n\tif (!activeItem) return;\n\n\trequestAnimationFrame(() => {\n\t\tactiveItem.scrollIntoView({ block: 'nearest' });\n\t});\n\tlist.setAttribute('aria-activedescendant', activeItem.id);\n}\n\n// --- Keyboard Navigation ---\n\nfunction attachKeyboardNavigation(\n\tinput: HTMLInputElement,\n\tlist: HTMLDivElement,\n\titems: HTMLButtonElement[],\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tlet focusedIndex = -1;\n\n\tconst setFocused = (idx: number): void => {\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length) {\n\t\t\titems[focusedIndex]?.classList.remove('notectl-font-size-picker__item--focused');\n\t\t}\n\t\tfocusedIndex = idx;\n\t\tconst el: HTMLButtonElement | undefined = items[focusedIndex];\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length && el) {\n\t\t\tel.classList.add('notectl-font-size-picker__item--focused');\n\t\t\tel.scrollIntoView({ block: 'nearest' });\n\t\t\tlist.setAttribute('aria-activedescendant', el.id);\n\t\t}\n\t};\n\n\t// As an editable combobox (input + listbox), this popup owns its keyboard\n\t// model. `consume` claims a handled key so the toolbar's generic popup\n\t// handler does not also act on it and advance focus a second time (#144).\n\tconst consume = (e: KeyboardEvent): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t};\n\n\tinput.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\tconsume(e);\n\t\t\tconst val: number = Number.parseInt(input.value, 10);\n\t\t\tif (!Number.isNaN(val) && val >= MIN_CUSTOM_SIZE && val <= MAX_CUSTOM_SIZE) {\n\t\t\t\tselectSize(context, val, config.defaultSize);\n\t\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t\t}\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\tconsume(e);\n\t\t\tsetFocused(0);\n\t\t\titems[0]?.focus();\n\t\t} else if (e.key === 'Escape') {\n\t\t\tconsume(e);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n\n\tlist.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'ArrowDown') {\n\t\t\tconsume(e);\n\t\t\tif (focusedIndex < items.length - 1) {\n\t\t\t\tsetFocused(focusedIndex + 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowUp') {\n\t\t\tconsume(e);\n\t\t\tif (focusedIndex > 0) {\n\t\t\t\tsetFocused(focusedIndex - 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t} else {\n\t\t\t\tsetFocused(-1);\n\t\t\t\tinput.focus();\n\t\t\t}\n\t\t} else if (e.key === 'Enter') {\n\t\t\tconsume(e);\n\t\t\titems[focusedIndex]?.click();\n\t\t} else if (e.key === 'Escape') {\n\t\t\tconsume(e);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n}\n","/**\n * FontSizePlugin: registers a fontSize mark with attrs, a combobox-style\n * toolbar selector with WCAG-accessible popup, and commands for\n * increasing / decreasing font size.\n */\n\nimport { FONT_SIZE_SELECT_CSS } from '../../editor/styles/font-size-select.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isValidCSSFontSize } from '../shared/ColorValidation.js';\nimport { createInlineStyleMarkSpec } from '../shared/InlineStyleMarkSpec.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { FONT_SIZE_LOCALE_EN, type FontSizeLocale, loadFontSizeLocale } from './FontSizeLocale.js';\nimport {\n\tgetActiveSizeNumeric,\n\tisFontSizeActive,\n\tremoveFontSize,\n\tstepFontSize,\n} from './FontSizeOperations.js';\nimport { renderFontSizePopup } from './FontSizePopup.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfontSize: { size: string };\n\t}\n}\n\n// --- Constants ---\n\n/** Default preset sizes shown in the font size dropdown. */\nexport const DEFAULT_FONT_SIZES: readonly number[] = [\n\t8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96,\n];\n\nconst DEFAULT_FONT_SIZE = 16;\n\n// --- Configuration ---\n\nexport interface FontSizeConfig {\n\t/**\n\t * Preset sizes shown in the font size dropdown.\n\t * Must contain positive integers. Values are sorted and deduplicated automatically.\n\t * Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The base font size that text has when no fontSize mark is applied.\n\t * Shown as the initial value in the toolbar combo and used as the\n\t * \"neutral\" size — selecting it removes the mark instead of applying one.\n\t * Defaults to 16.\n\t */\n\treadonly defaultSize?: number;\n\treadonly locale?: FontSizeLocale;\n}\n\n// --- Plugin ---\n\nexport class FontSizePlugin implements Plugin {\n\treadonly id = 'fontSize';\n\treadonly name = 'Font Size';\n\treadonly priority = 21;\n\n\tprivate readonly config: FontSizeConfig;\n\tprivate readonly sizes: readonly number[];\n\tprivate readonly defaultSize: number;\n\tprivate locale!: FontSizeLocale;\n\n\tconstructor(config?: Partial<FontSizeConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.sizes = resolveSizes(config?.sizes);\n\t\tthis.defaultSize = resolveDefaultSize(config?.defaultSize);\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tFONT_SIZE_LOCALE_EN,\n\t\t\tloadFontSizeLocale,\n\t\t);\n\n\t\tcontext.registerStyleSheet(FONT_SIZE_SELECT_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.applyDefaultSizeToContainer(context);\n\t}\n\n\tdestroy(): void {\n\t\t// no-op: nothing to clean up\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec(\n\t\t\tcreateInlineStyleMarkSpec({\n\t\t\t\ttype: 'fontSize',\n\t\t\t\trank: 4,\n\t\t\t\tvalueAttr: 'size',\n\t\t\t\tdomStyleProperty: 'fontSize',\n\t\t\t\tcssProperty: 'font-size',\n\t\t\t\tvalidate: isValidCSSFontSize,\n\t\t\t}),\n\t\t);\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFontSize', () => {\n\t\t\treturn removeFontSize(context, context.getState());\n\t\t});\n\n\t\tcontext.registerCommand('setFontSize', () => {\n\t\t\treturn false;\n\t\t});\n\n\t\tcontext.registerCommand('increaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t});\n\n\t\tcontext.registerCommand('decreaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t});\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-+': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t\t'Mod-Shift-_': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'fontSize',\n\t\t\tgroup: 'format',\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFontSize',\n\t\t\tpopupType: 'combobox',\n\t\t\tgetLabel: (state: EditorState): string =>\n\t\t\t\tString(getActiveSizeNumeric(state, this.defaultSize)),\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderFontSizePopup(container, ctx, {\n\t\t\t\t\tsizes: this.sizes,\n\t\t\t\t\tdefaultSize: this.defaultSize,\n\t\t\t\t\tonClose,\n\t\t\t\t\tcontentElement: ctx.getContainer(),\n\t\t\t\t\tlocale: this.locale,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state) => isFontSizeActive(state),\n\t\t});\n\t}\n\n\t/**\n\t * Sets the configured default font size on the editor content container\n\t * so that unformatted text renders at the correct size instead of the\n\t * browser default (16px).\n\t */\n\tprivate applyDefaultSizeToContainer(context: PluginContext): void {\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tsetStyleProperty(container, 'fontSize', `${this.defaultSize}px`);\n\t}\n}\n\n// --- Helpers ---\n\nfunction resolveSizes(sizes: readonly number[] | undefined): readonly number[] {\n\tif (!sizes || sizes.length === 0) return DEFAULT_FONT_SIZES;\n\tconst unique: number[] = [...new Set(sizes)].filter((n) => Number.isInteger(n) && n > 0);\n\tunique.sort((a, b) => a - b);\n\treturn unique.length > 0 ? unique : DEFAULT_FONT_SIZES;\n}\n\nfunction resolveDefaultSize(size: number | undefined): number {\n\tif (size === undefined) return DEFAULT_FONT_SIZE;\n\treturn Number.isInteger(size) && size > 0 ? size : DEFAULT_FONT_SIZE;\n}\n"],"mappings":"geACA,ICca,EAAsC,CAClD,MAAO,YACP,QAAS,YACT,mBAAoB,mBACpB,cAAe,cAKV,iBAAiD,OAAA,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAIvD,eAAsB,EAAmB,GACxC,OAAO,EAAiB,EAAe,EAAM,EAC9C,CCsBA,SAAS,EACR,GAEA,YAAiC,IAA1B,GAAM,OAAO,QACrB,CAQA,SAAS,EAAmB,GAC3B,MAAM,EAAM,EAAM,UAClB,GAAI,EAAgB,GAAM,CACzB,MAAM,EAAQ,EAAM,SAAS,EAAI,QACjC,OAAK,GAAU,EAAqB,EAAM,OAAO,cAAc,EAAM,OAE9D,CAAE,KAAM,QAAS,KADS,EAAM,YAAY,EAAI,SAAW,CAAC,EAAI,QACzC,MAAO,EAAM,OAAS,CAAC,GAF+B,IAGrF,CACA,MAAM,EAaP,SACC,GAEA,MAAM,EAAM,EAAM,UAClB,IAAK,EAAgB,IAAQ,EAAY,GAAM,OAAO,KACtD,GAAI,EAAI,OAAO,UAAY,EAAI,KAAK,QAAS,OAAO,KACpD,MAAM,EAAe,KAAK,IAAI,EAAI,OAAO,OAAQ,EAAI,KAAK,QA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,EAAQ,GACR,EAAW,GACX,EAAM,IAAI,SACU,WAAV,EAAE,MACZ,EAAQ,GACR,EAAO,QAAQ,CAAE,eAAgB,EAAO,oBAI1C,EAAK,iBAAiB,UAAY,IACnB,cAAV,EAAE,KACL,EAAQ,GACJ,EAAe,EAAM,OAAS,IACjC,EAAW,EAAe,GAC1B,EAAM,IAAe,UAEF,YAAV,EAAE,KACZ,EAAQ,GACJ,EAAe,GAClB,EAAW,EAAe,GAC1B,EAAM,IAAe,UAErB,GAAW,GACX,EAAM,UAEa,UAAV,EAAE,KACZ,EAAQ,GACR,EAAM,IAAe,SACD,WAAV,EAAE,MACZ,EAAQ,GACR,EAAO,QAAQ,CAAE,eAAgB,EAAO,mBAG3C,CAtLC,CAAyB,EAAO,EAAM,EAAO,EAAS,EACvD,CCgHI,CAAoB,EAAW,EAAK,CACnC,MAAO,KAAK,MACZ,YAAa,KAAK,YAClB,UACA,eAAgB,EAAI,eACpB,OAAQ,KAAK,UAGf,SAAW,GFqJd,SAAiC,GAChC,MAAM,EAAS,EAAmB,GAClC,GAAI,EAAQ,OAAqC,OAA9B,EAAkB,GACrC,MAAM,EAAQ,EAAe,GAC7B,SAAI,IAAS,IAAI,GAAO,KAAM,GAAS,EAAK,OAAS,KAC9C,EAAuB,EAAO,WACtC,CE3JwB,CAAiB,IAExC,CAOA,2BAAA,CAAoC,GACnC,MAAM,EAAyB,EAAQ,eACvC,EAAiB,EAAW,WAAY,GAAG,KAAK,gBACjD"}
@@ -0,0 +1,2 @@
1
+ import{E as t,P as e,V as n,j as o,k as i}from"./Document-D_2cIBJG.mjs";import{c as r,f as a,n as s}from"./Selection-DC6AOGgF.mjs";import{a as c}from"./TypeBrands-Ch9856Gb.mjs";import{c as l,o as g}from"./PluginHelpers-WG1Lzzh3.mjs";import{s as p}from"./StyleRuntime-C0RSqKzG.mjs";import{n as d}from"./DomUtils-Bf7JLFlx.mjs";function h(t,e,n,o){const i=document.createElement("button");i.type="button",i.className="notectl-heading-picker__item",i.setAttribute("role","option"),i.setAttribute("aria-selected",String(e)),e&&i.classList.add("notectl-heading-picker__item--active");const r=document.createElement("span");r.className="notectl-heading-picker__check",r.textContent=e?"✓":"",i.appendChild(r);const a=document.createElement("span");return a.className="notectl-heading-picker__label",a.textContent=t,o&&p(a,{fontSize:o.fontSize,fontWeight:o.fontWeight}),i.appendChild(a),i.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),i.addEventListener("click",n),i}function u(t,e){return t[`heading${e}`]}function f(t,e){const n=t.getState();if(!a(n.selection))return!1;const o=n.getBlock(n.selection.anchor.blockId);return!!o&&(o.type===e?k(t,c("paragraph")):k(t,c(e)))}function m(t,e){const n=t.getState(),o=n.selection;if(!a(o))return!1;const i=n.getBlock(o.anchor.blockId);return!!i&&("heading"===i.type&&i.attrs?.level===e?k(t,c("paragraph")):k(t,c("heading"),{level:e}))}function k(t,o,r){const s=t.getState(),c=s.selection;if(!a(c))return!1;const l=s.getBlock(c.anchor.blockId);if(!l)return!1;const g=s.transaction("command"),p=t.getSchemaRegistry().getNodeSpec(o);p?.excludeMarks&&p.excludeMarks.length>0&&(function(t,o,r){if(0===i(o))return;const a=new Set(r),s=e(o);let c=0;for(const e of s)if(n(e)){if(e.text.length>0)for(const n of e.marks)a.has(n.type)&&t.removeMark(o.id,c,c+e.text.length,n);c+=e.text.length}else c+=1}(g,l,p.excludeMarks),function(t,e,n){if(!e.storedMarks)return;const o=new Set(n),i=e.storedMarks.filter(t=>!o.has(t.type));i.length!==e.storedMarks.length&&t.setStoredMarks(i.length>0?i:null,e.storedMarks)}(g,s,p.excludeMarks));const d=g.setBlockType(c.anchor.blockId,o,r).setSelection(c).build();return t.dispatch(d),!0}var b=/* @__PURE__ */new Set(["heading","title","subtitle"]);var y={paragraph:"Paragraph",title:"Title",subtitle:"Subtitle",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",blockTypeLabel:"Block Type",blockTypesAria:"Block types"},v=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-0g2bmXTn.mjs"),"./locales/de.ts":()=>import("./de-Bwxlcuee.mjs"),"./locales/es.ts":()=>import("./es-C7uVqFYr.mjs"),"./locales/fr.ts":()=>import("./fr-D5ulA3Z6.mjs"),"./locales/hi.ts":()=>import("./hi-CrmakMVj.mjs"),"./locales/pt.ts":()=>import("./pt-_qxIe7zX.mjs"),"./locales/ru.ts":()=>import("./ru-Cs8KCNyq.mjs"),"./locales/zh.ts":()=>import("./zh-BQ73oqxc.mjs")});async function x(t){return l(v,t,y)}var S={levels:[1,2,3,4,5,6]},T={1:"h1",2:"h2",3:"h3",4:"h4",5:"h5",6:"h6"},B=class{id="heading";name="Heading";priority=30;config;locale;constructor(t){this.config={...S,...t}}async init(e){this.locale=await g(e,this.config.locale,y,x),e.registerStyleSheet("\n/* Heading Select — Width overrides for combobox button */\n.notectl-toolbar-btn--heading {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-heading-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-heading-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n"),this.registerNodeSpecs(e),function(t,e){t.registerCommand("setTitle",()=>f(t,"title")),t.registerCommand("setSubtitle",()=>f(t,"subtitle"));for(const n of e.levels)t.registerCommand(`setHeading${n}`,()=>m(t,n));t.registerCommand("toggleHeading",()=>m(t,1)),t.registerCommand("setParagraph",()=>k(t,c("paragraph")))}(e,this.config),function(e,n){const l={Enter:()=>function(e){return function(t,e){const n=t.getState();if(!a(n.selection))return!1;const o=n.selection;if(!r(o))return!1;const i=n.getBlock(o.anchor.blockId);return!(!i||!b.has(i.type))&&e({state:n,block:i,blockId:o.anchor.blockId,offset:o.anchor.offset})}(e,n=>{if(""===o(n.block)){const t=n.state.transaction("input").setBlockType(n.blockId,c("paragraph")).setSelection(n.state.selection).build();return e.dispatch(t),!0}const r=i(n.block);if(n.offset>=r){const o=t(),i=n.state.transaction("input").splitBlock(n.blockId,n.offset,o).setBlockType(o,c("paragraph")).setSelection(s(o,0)).build();return e.dispatch(i),!0}return!1})}(e)};for(const t of n.levels)t<=6&&(l[`Mod-Shift-${t}`]=()=>e.executeCommand(`setHeading${t}`));e.registerKeymap(l)}(e,this.config),!1!==this.config.inputRule&&function(t,e){for(const n of e.levels){const e="#".repeat(n),o=new RegExp(`^${e} $`);t.registerInputRule({pattern:o,handler(t,e,o,i){const l=t.selection;if(!a(l))return null;if(!r(l))return null;const g=t.getBlock(l.anchor.blockId);return g&&"paragraph"===g.type?t.transaction("input").deleteTextAt(l.anchor.blockId,o,o+n+1).setBlockType(l.anchor.blockId,c("heading"),{level:n}).setSelection(s(l.anchor.blockId,0)).build():null}})}}(e,this.config),function(t,e,n){t.registerBlockTypePickerEntry({id:"paragraph",label:n.paragraph,command:"setParagraph",priority:10,isActive:t=>!!a(t.selection)&&"paragraph"===t.getBlock(t.selection.anchor.blockId)?.type}),t.registerBlockTypePickerEntry({id:"title",label:n.title,command:"setTitle",priority:20,style:{fontSize:"1.6em",fontWeight:"700"},isActive:t=>!!a(t.selection)&&"title"===t.getBlock(t.selection.anchor.blockId)?.type}),t.registerBlockTypePickerEntry({id:"subtitle",label:n.subtitle,command:"setSubtitle",priority:30,style:{fontSize:"1.3em",fontWeight:"500"},isActive:t=>!!a(t.selection)&&"subtitle"===t.getBlock(t.selection.anchor.blockId)?.type});for(const o of e.levels)t.registerBlockTypePickerEntry({id:`heading-${o}`,label:u(n,o),command:`setHeading${o}`,priority:100+o,style:{fontSize:1.4-.1*o+"em",fontWeight:"600"},isActive:t=>{if(!a(t.selection))return!1;const e=t.getBlock(t.selection.anchor.blockId);return"heading"===e?.type&&e.attrs?.level===o}})}(e,this.config,this.locale),function(t,e){t.registerToolbarItem({id:"heading",group:"block",label:e.blockTypeLabel,tooltip:e.blockTypeLabel,command:"setParagraph",popupType:"combobox",getLabel:n=>function(t,e,n){if(!a(t.selection))return n.paragraph;const o=e.getBlockTypePickerRegistry().getBlockTypePickerEntries();for(const i of o)if(i.isActive(t))return i.label;return n.paragraph}(n,t,e),renderPopup:(t,n,o)=>{!function(t,e,n,o){t.classList.add("notectl-heading-picker");const i=e.getState();if(!a(i.selection))return;const r=e.getContainer(),s=document.createElement("div");s.className="notectl-heading-picker__list",s.setAttribute("role","listbox"),s.setAttribute("aria-label",n.blockTypesAria);const c=e.getBlockTypePickerRegistry().getBlockTypePickerEntries();for(const a of c){const t=a.isActive(i);s.appendChild(h(a.label,t,()=>{e.executeCommand(a.command),o({restoreFocusTo:r})},a.style))}t.appendChild(s)}(t,n,e,o)},isActive:e=>t.getBlockTypePickerRegistry().getBlockTypePickerEntries().some(t=>"paragraph"!==t.id&&t.isActive(e))})}(e,this.locale)}registerNodeSpecs(t){t.registerNodeSpec({type:"title",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],toDOM(t){const e=d("h1",t.id);return e.classList.add("notectl-title"),e},toHTML:(t,e)=>`<h1 class="notectl-title">${e||"<br>"}</h1>`,parseHTML:[{tag:"h1",priority:60,getAttrs:t=>!!t.classList.contains("notectl-title")&&{}}],sanitize:{tags:["h1"],attrs:["class"]}}),t.registerNodeSpec({type:"subtitle",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],toDOM(t){const e=d("h2",t.id);return e.classList.add("notectl-subtitle"),e},toHTML:(t,e)=>`<h2 class="notectl-subtitle">${e||"<br>"}</h2>`,parseHTML:[{tag:"h2",priority:60,getAttrs:t=>!!t.classList.contains("notectl-subtitle")&&{}}],sanitize:{tags:["h2"],attrs:["class"]}}),t.registerNodeSpec({type:"heading",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],attrs:{level:{default:1}},toDOM(t){const e=t.attrs?.level??1;return d(T[e]??"h1",t.id)},toHTML(t,e){const n=t.attrs?.level??1,o=T[n]??"h1";return`<${o}>${e||"<br>"}</${o}>`},parseHTML:[{tag:"h1",getAttrs:()=>({level:1})},{tag:"h2",getAttrs:()=>({level:2})},{tag:"h3",getAttrs:()=>({level:3})},{tag:"h4",getAttrs:()=>({level:4})},{tag:"h5",getAttrs:()=>({level:5})},{tag:"h6",getAttrs:()=>({level:6})}],sanitize:{tags:["h1","h2","h3","h4","h5","h6"]}})}};export{y as n,x as r,B as t};
2
+ //# sourceMappingURL=HeadingPlugin-BCh12hFT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeadingPlugin-BCh12hFT.mjs","names":[],"sources":["../../src/editor/styles/heading-select.ts","../../src/plugins/heading/HeadingBlockTypePicker.ts","../../src/plugins/heading/HeadingCommands.ts","../../src/plugins/heading/HeadingInputRules.ts","../../src/plugins/heading/HeadingKeyboardHandlers.ts","../../src/plugins/heading/HeadingLocale.ts","../../src/plugins/heading/HeadingPlugin.ts"],"sourcesContent":["/** Heading picker toolbar combobox + popup styles. */\nexport const HEADING_SELECT_CSS = `\n/* Heading Select — Width overrides for combobox button */\n.notectl-toolbar-btn--heading {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-heading-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-heading-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n`;\n","/**\n * Block type picker entries and toolbar dropdown for heading block types.\n * Registers picker entries for paragraph, title, subtitle, and all heading levels,\n * plus a combobox-style toolbar item with a custom popup.\n */\n\nimport { isTextSelection } from '../../model/Selection.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperties } from '../../style/StyleRuntime.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport type { PickerEntryStyle } from './BlockTypePickerEntry.js';\nimport type { HeadingLocale } from './HeadingLocale.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\nimport type { HeadingLevel } from './HeadingPlugin.js';\n\n// --- Picker Entry Registration ---\n\n/** Registers block type picker entries for paragraph, title, subtitle, and heading levels. */\nexport function registerHeadingPickerEntries(\n\tcontext: PluginContext,\n\tconfig: HeadingConfig,\n\tlocale: HeadingLocale,\n): void {\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'paragraph',\n\t\tlabel: locale.paragraph,\n\t\tcommand: 'setParagraph',\n\t\tpriority: 10,\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'paragraph';\n\t\t},\n\t});\n\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'title',\n\t\tlabel: locale.title,\n\t\tcommand: 'setTitle',\n\t\tpriority: 20,\n\t\tstyle: { fontSize: '1.6em', fontWeight: '700' },\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'title';\n\t\t},\n\t});\n\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'subtitle',\n\t\tlabel: locale.subtitle,\n\t\tcommand: 'setSubtitle',\n\t\tpriority: 30,\n\t\tstyle: { fontSize: '1.3em', fontWeight: '500' },\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'subtitle';\n\t\t},\n\t});\n\n\tfor (const level of config.levels) {\n\t\tcontext.registerBlockTypePickerEntry({\n\t\t\tid: `heading-${level}`,\n\t\t\tlabel: getHeadingLabel(locale, level),\n\t\t\tcommand: `setHeading${level}`,\n\t\t\tpriority: 100 + level,\n\t\t\tstyle: { fontSize: `${1.4 - level * 0.1}em`, fontWeight: '600' },\n\t\t\tisActive: (state) => {\n\t\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\t\treturn block?.type === 'heading' && block.attrs?.level === level;\n\t\t\t},\n\t\t});\n\t}\n}\n\n// --- Toolbar Item ---\n\n/** Registers the heading toolbar dropdown with a combobox picker popup. */\nexport function registerHeadingToolbarItem(context: PluginContext, locale: HeadingLocale): void {\n\tcontext.registerToolbarItem({\n\t\tid: 'heading',\n\t\tgroup: 'block',\n\t\tlabel: locale.blockTypeLabel,\n\t\ttooltip: locale.blockTypeLabel,\n\t\tcommand: 'setParagraph',\n\t\tpopupType: 'combobox',\n\t\tgetLabel: (state: EditorState): string => getActiveLabel(state, context, locale),\n\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\trenderHeadingPopup(container, ctx, locale, onClose);\n\t\t},\n\t\tisActive: (state) => {\n\t\t\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\t\t\treturn entries.some((entry) => entry.id !== 'paragraph' && entry.isActive(state));\n\t\t},\n\t});\n}\n\n// --- Popup Rendering ---\n\nfunction renderHeadingPopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tlocale: HeadingLocale,\n\tonClose: (options?: PopupCloseOptions) => void,\n): void {\n\tcontainer.classList.add('notectl-heading-picker');\n\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return;\n\n\tconst contentElement: HTMLElement = context.getContainer();\n\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-heading-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', locale.blockTypesAria);\n\n\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\tfor (const entry of entries) {\n\t\tconst active: boolean = entry.isActive(state);\n\t\tlist.appendChild(\n\t\t\tcreatePickerItem(\n\t\t\t\tentry.label,\n\t\t\t\tactive,\n\t\t\t\t() => {\n\t\t\t\t\tcontext.executeCommand(entry.command);\n\t\t\t\t\tonClose({ restoreFocusTo: contentElement });\n\t\t\t\t},\n\t\t\t\tentry.style,\n\t\t\t),\n\t\t);\n\t}\n\n\tcontainer.appendChild(list);\n}\n\nfunction createPickerItem(\n\tlabel: string,\n\tisActive: boolean,\n\tonActivate: () => void,\n\tstyle?: PickerEntryStyle,\n): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.className = 'notectl-heading-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-heading-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-heading-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\tlabelSpan.className = 'notectl-heading-picker__label';\n\tlabelSpan.textContent = label;\n\tif (style) {\n\t\tsetStyleProperties(labelSpan, {\n\t\t\tfontSize: style.fontSize,\n\t\t\tfontWeight: style.fontWeight,\n\t\t});\n\t}\n\titem.appendChild(labelSpan);\n\n\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t});\n\titem.addEventListener('click', onActivate);\n\treturn item;\n}\n\n// --- Helpers ---\n\nfunction getHeadingLabel(locale: HeadingLocale, level: HeadingLevel): string {\n\tconst key = `heading${level}` as keyof HeadingLocale;\n\treturn locale[key] as string;\n}\n\nfunction getActiveLabel(state: EditorState, context: PluginContext, locale: HeadingLocale): string {\n\tif (!isTextSelection(state.selection)) return locale.paragraph;\n\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\tfor (const entry of entries) {\n\t\tif (entry.isActive(state)) return entry.label;\n\t}\n\treturn locale.paragraph;\n}\n","/**\n * Command registration and implementations for heading block types.\n * Handles toggle between heading/title/subtitle and paragraph,\n * plus excluded-mark stripping when switching block types.\n */\n\nimport type { BlockNode, Mark } from '../../model/Document.js';\nimport { getBlockLength, getInlineChildren, isTextNode } from '../../model/Document.js';\nimport { isTextSelection } from '../../model/Selection.js';\nimport { type NodeTypeName, nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { TransactionBuilder } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig, HeadingLevel } from './HeadingPlugin.js';\n\n/** Registers all heading commands (setTitle, setSubtitle, setHeadingN, toggleHeading, setParagraph). */\nexport function registerHeadingCommands(context: PluginContext, config: HeadingConfig): void {\n\tcontext.registerCommand('setTitle', () => toggleSpecialBlock(context, 'title'));\n\n\tcontext.registerCommand('setSubtitle', () => toggleSpecialBlock(context, 'subtitle'));\n\n\tfor (const level of config.levels) {\n\t\tcontext.registerCommand(`setHeading${level}`, () => toggleHeading(context, level));\n\t}\n\n\tcontext.registerCommand('toggleHeading', () => toggleHeading(context, 1));\n\n\tcontext.registerCommand('setParagraph', () => setBlockType(context, nodeType('paragraph')));\n}\n\n// --- Command Implementations ---\n\n/**\n * Toggles between a special block type (title/subtitle) and paragraph.\n * If the block is already that type, resets to paragraph.\n */\nfunction toggleSpecialBlock(context: PluginContext, type: string): boolean {\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === type) {\n\t\treturn setBlockType(context, nodeType('paragraph'));\n\t}\n\n\treturn setBlockType(context, nodeType(type) as NodeTypeName);\n}\n\n/**\n * Toggles between heading (at given level) and paragraph.\n * If the block is already a heading at the same level, resets to paragraph.\n */\nfunction toggleHeading(context: PluginContext, level: HeadingLevel): boolean {\n\tconst state: EditorState = context.getState();\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === 'heading' && block.attrs?.level === level) {\n\t\treturn setBlockType(context, nodeType('paragraph'));\n\t}\n\n\treturn setBlockType(context, nodeType('heading'), { level });\n}\n\nfunction setBlockType(\n\tcontext: PluginContext,\n\ttype: NodeTypeName,\n\tattrs?: Record<string, string | number | boolean>,\n): boolean {\n\tconst state: EditorState = context.getState();\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block) return false;\n\n\tconst builder: TransactionBuilder = state.transaction('command');\n\n\tconst spec = context.getSchemaRegistry().getNodeSpec(type);\n\tif (spec?.excludeMarks && spec.excludeMarks.length > 0) {\n\t\tstripExcludedMarks(builder, block, spec.excludeMarks);\n\t\tclearExcludedStoredMarks(builder, state, spec.excludeMarks);\n\t}\n\n\tconst tr = builder.setBlockType(sel.anchor.blockId, type, attrs).setSelection(sel).build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n// --- Mark Stripping Helpers ---\n\n/**\n * Adds removeMark steps for each excluded mark type found\n * on the block's inline text content.\n */\nfunction stripExcludedMarks(\n\tbuilder: TransactionBuilder,\n\tblock: BlockNode,\n\texcludeMarks: readonly string[],\n): void {\n\tconst blockLength: number = getBlockLength(block);\n\tif (blockLength === 0) return;\n\n\tconst excludeSet: Set<string> = new Set(excludeMarks);\n\tconst inlineChildren = getInlineChildren(block);\n\tlet offset = 0;\n\n\tfor (const child of inlineChildren) {\n\t\tif (isTextNode(child)) {\n\t\t\tif (child.text.length > 0) {\n\t\t\t\tfor (const mark of child.marks) {\n\t\t\t\t\tif (excludeSet.has(mark.type)) {\n\t\t\t\t\t\tbuilder.removeMark(block.id, offset, offset + child.text.length, mark);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += child.text.length;\n\t\t} else {\n\t\t\toffset += 1;\n\t\t}\n\t}\n}\n\n/**\n * Clears excluded mark types from stored marks so that\n * subsequent typing does not reintroduce them.\n */\nfunction clearExcludedStoredMarks(\n\tbuilder: TransactionBuilder,\n\tstate: EditorState,\n\texcludeMarks: readonly string[],\n): void {\n\tif (!state.storedMarks) return;\n\n\tconst excludeSet: Set<string> = new Set(excludeMarks);\n\tconst filtered: readonly Mark[] = state.storedMarks.filter((m: Mark) => !excludeSet.has(m.type));\n\n\tif (filtered.length !== state.storedMarks.length) {\n\t\tbuilder.setStoredMarks(filtered.length > 0 ? filtered : null, state.storedMarks);\n\t}\n}\n","/**\n * Input rule registration for heading block types.\n * Converts `# `, `## `, etc. at the start of a paragraph into headings.\n */\n\nimport { createCollapsedSelection, isCollapsed, isTextSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\n\n/** Registers markdown-style input rules (e.g. `# ` → H1) for configured heading levels. */\nexport function registerHeadingInputRules(context: PluginContext, config: HeadingConfig): void {\n\tfor (const level of config.levels) {\n\t\tconst hashes: string = '#'.repeat(level);\n\t\tconst pattern: RegExp = new RegExp(`^${hashes} $`);\n\n\t\tcontext.registerInputRule({\n\t\t\tpattern,\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\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + level + 1)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('heading'), { level })\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 heading block types.\n * Handles Enter key behavior: empty heading → paragraph, cursor at end → split + paragraph.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockLength, 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 type { HeadingConfig } from './HeadingPlugin.js';\n\n// --- Context Guard ---\n\nconst HEADING_TYPES: ReadonlySet<string> = new Set(['heading', 'title', 'subtitle']);\n\ninterface HeadingContext {\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-heading blocks.\n * Returns false (not handled) if the cursor is not inside a heading-type block.\n */\nfunction withHeadingContext(\n\tcontext: PluginContext,\n\thandler: (ctx: HeadingContext) => boolean,\n): 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 || !HEADING_TYPES.has(block.type)) 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 all heading keyboard handlers (Enter, Mod-Shift-N shortcuts). */\nexport function registerHeadingKeymaps(context: PluginContext, config: HeadingConfig): void {\n\tconst keymap: Record<string, () => boolean> = {\n\t\tEnter: () => handleEnter(context),\n\t};\n\n\tfor (const level of config.levels) {\n\t\tif (level <= 6) {\n\t\t\tkeymap[`Mod-Shift-${level}`] = () => context.executeCommand(`setHeading${level}`);\n\t\t}\n\t}\n\n\tcontext.registerKeymap(keymap);\n}\n\n// --- Enter Handler ---\n\n/**\n * Handles Enter inside a heading block.\n * Empty heading → convert to paragraph.\n * Cursor at end → split and convert new block to paragraph.\n * Cursor in middle → normal split (both stay heading).\n */\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withHeadingContext(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 blockLength: number = getBlockLength(ctx.block);\n\n\t\tif (ctx.offset >= blockLength) {\n\t\t\tconst newBlockId = generateBlockId();\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.splitBlock(ctx.blockId, ctx.offset, newBlockId)\n\t\t\t\t.setBlockType(newBlockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(createCollapsedSelection(newBlockId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n","/**\n * Locale interface and default English locale for the HeadingPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface HeadingLocale {\n\treadonly paragraph: string;\n\treadonly title: string;\n\treadonly subtitle: string;\n\treadonly heading1: string;\n\treadonly heading2: string;\n\treadonly heading3: string;\n\treadonly heading4: string;\n\treadonly heading5: string;\n\treadonly heading6: string;\n\treadonly blockTypeLabel: string;\n\treadonly blockTypesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const HEADING_LOCALE_EN: HeadingLocale = {\n\tparagraph: 'Paragraph',\n\ttitle: 'Title',\n\tsubtitle: 'Subtitle',\n\theading1: 'Heading 1',\n\theading2: 'Heading 2',\n\theading3: 'Heading 3',\n\theading4: 'Heading 4',\n\theading5: 'Heading 5',\n\theading6: 'Heading 6',\n\tblockTypeLabel: 'Block Type',\n\tblockTypesAria: 'Block types',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<HeadingLocale> = import.meta.glob<{\n\tdefault: HeadingLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadHeadingLocale(lang: string): Promise<HeadingLocale> {\n\treturn loadLocaleModule(localeModules, lang, HEADING_LOCALE_EN);\n}\n","/**\n * HeadingPlugin: registers Title, Subtitle, and H1–H6 heading block types\n * with NodeSpec, toggle commands, keyboard shortcuts, input rules, and a\n * combobox-style toolbar dropdown that reflects the current block type.\n *\n * This file is a thin orchestrator — command logic, input rules, keyboard\n * handlers, and picker/toolbar rendering are delegated to dedicated modules.\n */\n\nimport { HEADING_SELECT_CSS } from '../../editor/styles/heading-select.js';\nimport type { BlockAlignment } from '../../model/BlockAlignment.js';\nimport { createBlockElement } from '../../view/DomUtils.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport {\n\tregisterHeadingPickerEntries,\n\tregisterHeadingToolbarItem,\n} from './HeadingBlockTypePicker.js';\nimport { registerHeadingCommands } from './HeadingCommands.js';\nimport { registerHeadingInputRules } from './HeadingInputRules.js';\nimport { registerHeadingKeymaps } from './HeadingKeyboardHandlers.js';\nimport { HEADING_LOCALE_EN, type HeadingLocale, loadHeadingLocale } from './HeadingLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\theading: { level: HeadingLevel; align?: BlockAlignment };\n\t\ttitle: { align?: BlockAlignment };\n\t\tsubtitle: { align?: BlockAlignment };\n\t}\n}\n\n// --- Configuration ---\n\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport interface HeadingConfig {\n\t/** Which heading levels to enable. Defaults to [1, 2, 3, 4, 5, 6]. */\n\treadonly levels: readonly HeadingLevel[];\n\t/** Live Markdown shortcut: `# ` ... `###### ` to set a heading. Default true. */\n\treadonly inputRule?: boolean;\n\treadonly locale?: HeadingLocale;\n}\n\nconst DEFAULT_CONFIG: HeadingConfig = {\n\tlevels: [1, 2, 3, 4, 5, 6],\n};\n\n// --- Heading Tag Mapping ---\n\nconst HEADING_TAGS: Record<HeadingLevel, string> = {\n\t1: 'h1',\n\t2: 'h2',\n\t3: 'h3',\n\t4: 'h4',\n\t5: 'h5',\n\t6: 'h6',\n};\n\n// --- Plugin ---\n\nexport class HeadingPlugin implements Plugin {\n\treadonly id = 'heading';\n\treadonly name = 'Heading';\n\treadonly priority = 30;\n\n\tprivate readonly config: HeadingConfig;\n\tprivate locale!: HeadingLocale;\n\n\tconstructor(config?: Partial<HeadingConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tHEADING_LOCALE_EN,\n\t\t\tloadHeadingLocale,\n\t\t);\n\t\tcontext.registerStyleSheet(HEADING_SELECT_CSS);\n\n\t\tthis.registerNodeSpecs(context);\n\t\tregisterHeadingCommands(context, this.config);\n\t\tregisterHeadingKeymaps(context, this.config);\n\t\tif (this.config.inputRule !== false) registerHeadingInputRules(context, this.config);\n\t\tregisterHeadingPickerEntries(context, this.config, this.locale);\n\t\tregisterHeadingToolbarItem(context, this.locale);\n\t}\n\n\tprivate registerNodeSpecs(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'title',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\ttoDOM(node) {\n\t\t\t\tconst el = createBlockElement('h1', node.id);\n\t\t\t\tel.classList.add('notectl-title');\n\t\t\t\treturn el;\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<h1 class=\"notectl-title\">${content || '<br>'}</h1>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'h1',\n\t\t\t\t\tpriority: 60,\n\t\t\t\t\tgetAttrs: (el) => (el.classList.contains('notectl-title') ? {} : false),\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['h1'], attrs: ['class'] },\n\t\t});\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'subtitle',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\ttoDOM(node) {\n\t\t\t\tconst el = createBlockElement('h2', node.id);\n\t\t\t\tel.classList.add('notectl-subtitle');\n\t\t\t\treturn el;\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<h2 class=\"notectl-subtitle\">${content || '<br>'}</h2>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'h2',\n\t\t\t\t\tpriority: 60,\n\t\t\t\t\tgetAttrs: (el) => (el.classList.contains('notectl-subtitle') ? {} : false),\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['h2'], attrs: ['class'] },\n\t\t});\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'heading',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\tattrs: {\n\t\t\t\tlevel: { default: 1 },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst level = node.attrs?.level ?? 1;\n\t\t\t\tconst tag = HEADING_TAGS[level] ?? 'h1';\n\t\t\t\treturn createBlockElement(tag, node.id);\n\t\t\t},\n\t\t\ttoHTML(node, content) {\n\t\t\t\tconst level = (node.attrs?.level ?? 1) as HeadingLevel;\n\t\t\t\tconst tag: string = HEADING_TAGS[level] ?? 'h1';\n\t\t\t\treturn `<${tag}>${content || '<br>'}</${tag}>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{ tag: 'h1', getAttrs: () => ({ level: 1 }) },\n\t\t\t\t{ tag: 'h2', getAttrs: () => ({ level: 2 }) },\n\t\t\t\t{ tag: 'h3', getAttrs: () => ({ level: 3 }) },\n\t\t\t\t{ tag: 'h4', getAttrs: () => ({ level: 4 }) },\n\t\t\t\t{ tag: 'h5', getAttrs: () => ({ level: 5 }) },\n\t\t\t\t{ tag: 'h6', getAttrs: () => ({ level: 6 }) },\n\t\t\t],\n\t\t\tsanitize: { tags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] },\n\t\t});\n\t}\n}\n"],"mappings":"qUC2IA,SAAS,EACR,EACA,EACA,EACA,GAEA,MAAM,EAA0B,SAAS,cAAc,UACvD,EAAK,KAAO,SACZ,EAAK,UAAY,+BACjB,EAAK,aAAa,OAAQ,UAC1B,EAAK,aAAa,gBAAiB,OAAO,IAEtC,GACH,EAAK,UAAU,IAAI,wCAGpB,MAAM,EAAyB,SAAS,cAAc,QACtD,EAAM,UAAY,gCAClB,EAAM,YAAc,EAAW,IAAW,GAC1C,EAAK,YAAY,GAEjB,MAAM,EAA6B,SAAS,cAAc,QAgB1D,OAfA,EAAU,UAAY,gCACtB,EAAU,YAAc,EACpB,GACH,EAAmB,EAAW,CAC7B,SAAU,EAAM,SAChB,WAAY,EAAM,aAGpB,EAAK,YAAY,GAEjB,EAAK,iBAAiB,YAAc,IACnC,EAAE,iBACF,EAAE,oBAEH,EAAK,iBAAiB,QAAS,GACxB,CACR,CAIA,SAAS,EAAgB,EAAuB,GAE/C,OAAO,EAAO,UADQ,IAEvB,CCpJA,SAAS,EAAmB,EAAwB,GACnD,MAAM,EAAqB,EAAQ,WACnC,IAAK,EAAgB,EAAM,WAAY,OAAO,EAE9C,MAAM,EAA+B,EAAM,SAAS,EAAM,UAAU,OAAO,SAC3E,QAAK,IAED,EAAM,OAAS,EACX,EAAa,EAAS,EAAS,cAGhC,EAAa,EAAS,EAAS,IACvC,CAMA,SAAS,EAAc,EAAwB,GAC9C,MAAM,EAAqB,EAAQ,WAC7B,EAAM,EAAM,UAClB,IAAK,EAAgB,GAAM,OAAO,EAElC,MAAM,EAA+B,EAAM,SA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1
- import{c as e,o as t}from"./PluginHelpers-WG1Lzzh3.mjs";import{a as o,t as r}from"./ColorValidation-B9d_umnf.mjs";import{t as a}from"./InlineStyleMarkSpec-Cx3goc3W.mjs";import{t as i}from"./color-picker-DJ05ey9o.mjs";import{a as s,i as l,t as f}from"./ColorPickerPopup-_C5JZhki.mjs";var c={label:"Highlight",tooltip:"Highlight Color",resetLabel:"None",ariaLabelPrefix:"Highlight color"},h=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BAfInw85.mjs"),"./locales/de.ts":()=>import("./de-C9ZhDqPi.mjs"),"./locales/es.ts":()=>import("./es-BMm9kqjC.mjs"),"./locales/fr.ts":()=>import("./fr-F2ZrfVaF.mjs"),"./locales/hi.ts":()=>import("./hi-uACJUw53.mjs"),"./locales/pt.ts":()=>import("./pt-zMHcNGPk.mjs"),"./locales/ru.ts":()=>import("./ru-k7o3Qks3.mjs"),"./locales/zh.ts":()=>import("./zh-DlVfQn4z.mjs")});async function m(t){return e(h,t,c)}var g=["#fff176","#aed581","#4dd0e1","#64b5f6","#ce93d8","#f48fb1","#ffab91","#ff8a65","#e6ee9c","#80cbc4","#fff9c4","#dcedc8","#e0f7fa","#e3f2fd","#f3e5f5","#fce4ec","#fff3e0","#fbe9e7","#f9fbe7","#e0f2f1","#fff59d","#c5e1a5","#80deea","#90caf9","#e1bee7","#f8bbd0","#ffcc80","#ffab91","#e6ee9c","#a5d6a7","#ffee58","#9ccc65","#26c6da","#42a5f5","#ab47bc","#ec407a","#ffa726","#ff7043","#d4e157","#66bb6a","#ffffff","#fafafa","#f5f5f5","#eeeeee","#e0e0e0","#bdbdbd","#e8eaf6","#efebe9","#eceff1","#fafafa"],p=class{id="highlight";name="Highlight";priority=24;config;colors;locale;constructor(e){this.config={...e},this.colors=o(e?.colors,g,"HighlightPlugin")}async init(e){this.locale=await t(e,this.config.locale,c,m),e.registerStyleSheet(i),this.registerMarkSpec(e),this.registerCommands(e),this.registerToolbarItem(e)}registerMarkSpec(e){e.registerMarkSpec(a({type:"highlight",rank:4,valueAttr:"color",domStyleProperty:"backgroundColor",cssProperty:"background-color",validate:r,validateOnParse:!0}))}registerCommands(e){e.registerCommand("removeHighlight",()=>s(e,e.getState(),"highlight"))}registerToolbarItem(e){const t=['<svg xmlns="http://www.w3.org/2000/svg"',' viewBox="0 0 24 24">','<path d="M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z"/>','<rect x="3" y="17" width="18" height="6"',' rx="0.5" fill="#fff176"/>',"</svg>"].join("");e.registerToolbarItem({id:"highlight",group:"format",icon:t,label:this.locale.label,tooltip:this.locale.tooltip,command:"removeHighlight",popupType:"custom",renderPopup:(e,t,o)=>{f(e,t,{markType:"highlight",colors:this.colors,columns:10,resetLabel:this.locale.resetLabel,resetCommand:"removeHighlight",ariaLabelPrefix:this.locale.ariaLabelPrefix,onClose:o})},isActive:e=>l(e,"highlight")})}};export{c as n,m as r,p as t};
2
- //# sourceMappingURL=HighlightPlugin-B4WlZawl.mjs.map
1
+ import{c as e,o as t}from"./PluginHelpers-WG1Lzzh3.mjs";import{a as o,t as r}from"./ColorValidation-B9d_umnf.mjs";import{t as a}from"./InlineStyleMarkSpec-Cx3goc3W.mjs";import{t as i}from"./color-picker-DJ05ey9o.mjs";import{a as s,i as l,t as f}from"./ColorPickerPopup-CFYCCN7m.mjs";var c={label:"Highlight",tooltip:"Highlight Color",resetLabel:"None",ariaLabelPrefix:"Highlight color"},h=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BAfInw85.mjs"),"./locales/de.ts":()=>import("./de-C9ZhDqPi.mjs"),"./locales/es.ts":()=>import("./es-BMm9kqjC.mjs"),"./locales/fr.ts":()=>import("./fr-F2ZrfVaF.mjs"),"./locales/hi.ts":()=>import("./hi-uACJUw53.mjs"),"./locales/pt.ts":()=>import("./pt-zMHcNGPk.mjs"),"./locales/ru.ts":()=>import("./ru-k7o3Qks3.mjs"),"./locales/zh.ts":()=>import("./zh-DlVfQn4z.mjs")});async function m(t){return e(h,t,c)}var g=["#fff176","#aed581","#4dd0e1","#64b5f6","#ce93d8","#f48fb1","#ffab91","#ff8a65","#e6ee9c","#80cbc4","#fff9c4","#dcedc8","#e0f7fa","#e3f2fd","#f3e5f5","#fce4ec","#fff3e0","#fbe9e7","#f9fbe7","#e0f2f1","#fff59d","#c5e1a5","#80deea","#90caf9","#e1bee7","#f8bbd0","#ffcc80","#ffab91","#e6ee9c","#a5d6a7","#ffee58","#9ccc65","#26c6da","#42a5f5","#ab47bc","#ec407a","#ffa726","#ff7043","#d4e157","#66bb6a","#ffffff","#fafafa","#f5f5f5","#eeeeee","#e0e0e0","#bdbdbd","#e8eaf6","#efebe9","#eceff1","#fafafa"],p=class{id="highlight";name="Highlight";priority=24;config;colors;locale;constructor(e){this.config={...e},this.colors=o(e?.colors,g,"HighlightPlugin")}async init(e){this.locale=await t(e,this.config.locale,c,m),e.registerStyleSheet(i),this.registerMarkSpec(e),this.registerCommands(e),this.registerToolbarItem(e)}registerMarkSpec(e){e.registerMarkSpec(a({type:"highlight",rank:4,valueAttr:"color",domStyleProperty:"backgroundColor",cssProperty:"background-color",validate:r,validateOnParse:!0}))}registerCommands(e){e.registerCommand("removeHighlight",()=>s(e,e.getState(),"highlight"))}registerToolbarItem(e){const t=['<svg xmlns="http://www.w3.org/2000/svg"',' viewBox="0 0 24 24">','<path d="M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z"/>','<rect x="3" y="17" width="18" height="6"',' rx="0.5" fill="#fff176"/>',"</svg>"].join("");e.registerToolbarItem({id:"highlight",group:"format",icon:t,label:this.locale.label,tooltip:this.locale.tooltip,command:"removeHighlight",popupType:"custom",renderPopup:(e,t,o)=>{f(e,t,{markType:"highlight",colors:this.colors,columns:10,resetLabel:this.locale.resetLabel,resetCommand:"removeHighlight",ariaLabelPrefix:this.locale.ariaLabelPrefix,onClose:o})},isActive:e=>l(e,"highlight")})}};export{c as n,m as r,p as t};
2
+ //# sourceMappingURL=HighlightPlugin-By7CWUss.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"HighlightPlugin-B4WlZawl.mjs","names":[],"sources":["../../src/plugins/highlight/HighlightLocale.ts","../../src/plugins/highlight/HighlightPalette.ts","../../src/plugins/highlight/HighlightPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the HighlightPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface HighlightLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly resetLabel: string;\n\treadonly ariaLabelPrefix: string;\n}\n\n// --- Default English Locale ---\n\nexport const HIGHLIGHT_LOCALE_EN: HighlightLocale = {\n\tlabel: 'Highlight',\n\ttooltip: 'Highlight Color',\n\tresetLabel: 'None',\n\tariaLabelPrefix: 'Highlight color',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<HighlightLocale> = import.meta.glob<{\n\tdefault: HighlightLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadHighlightLocale(lang: string): Promise<HighlightLocale> {\n\treturn loadLocaleModule(localeModules, lang, HIGHLIGHT_LOCALE_EN);\n}\n","/**\n * Default highlight color palette (10 columns x 5 rows), optimized for\n * background highlighting. Used by HighlightPlugin when no `colors` override is\n * provided.\n */\nexport const HIGHLIGHT_PALETTE: readonly string[] = [\n\t// Row 1 — Classic highlighter colors (bright, vivid)\n\t'#fff176',\n\t'#aed581',\n\t'#4dd0e1',\n\t'#64b5f6',\n\t'#ce93d8',\n\t'#f48fb1',\n\t'#ffab91',\n\t'#ff8a65',\n\t'#e6ee9c',\n\t'#80cbc4',\n\t// Row 2 — Light pastels\n\t'#fff9c4',\n\t'#dcedc8',\n\t'#e0f7fa',\n\t'#e3f2fd',\n\t'#f3e5f5',\n\t'#fce4ec',\n\t'#fff3e0',\n\t'#fbe9e7',\n\t'#f9fbe7',\n\t'#e0f2f1',\n\t// Row 3 — Medium pastels\n\t'#fff59d',\n\t'#c5e1a5',\n\t'#80deea',\n\t'#90caf9',\n\t'#e1bee7',\n\t'#f8bbd0',\n\t'#ffcc80',\n\t'#ffab91',\n\t'#e6ee9c',\n\t'#a5d6a7',\n\t// Row 4 — Bold pastels\n\t'#ffee58',\n\t'#9ccc65',\n\t'#26c6da',\n\t'#42a5f5',\n\t'#ab47bc',\n\t'#ec407a',\n\t'#ffa726',\n\t'#ff7043',\n\t'#d4e157',\n\t'#66bb6a',\n\t// Row 5 — Grays and neutral highlights\n\t'#ffffff',\n\t'#fafafa',\n\t'#f5f5f5',\n\t'#eeeeee',\n\t'#e0e0e0',\n\t'#bdbdbd',\n\t'#e8eaf6',\n\t'#efebe9',\n\t'#eceff1',\n\t'#fafafa',\n];\n","/**\n * HighlightPlugin: registers a highlight (background-color) mark with attrs,\n * toolbar button with a color picker popup, and removeHighlight command.\n */\n\nimport { COLOR_PICKER_CSS } from '../../editor/styles/color-picker.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isColorMarkActive, removeColorMark } from '../shared/ColorMarkOperations.js';\nimport { renderColorPickerPopup } from '../shared/ColorPickerPopup.js';\nimport { isValidCSSColor, resolveColors } from '../shared/ColorValidation.js';\nimport { createInlineStyleMarkSpec } from '../shared/InlineStyleMarkSpec.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport {\n\tHIGHLIGHT_LOCALE_EN,\n\ttype HighlightLocale,\n\tloadHighlightLocale,\n} from './HighlightLocale.js';\nimport { HIGHLIGHT_PALETTE } from './HighlightPalette.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\thighlight: { color: string };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface HighlightConfig {\n\t/**\n\t * Restricts the color picker to a specific set of hex colors.\n\t * Each value must be a valid hex color code (`#RGB` or `#RRGGBB`).\n\t * Duplicates are removed automatically (case-insensitive).\n\t * When omitted, the full default palette is shown.\n\t */\n\treadonly colors?: readonly string[];\n\treadonly locale?: HighlightLocale;\n}\n\n// --- Plugin ---\n\nexport class HighlightPlugin implements Plugin {\n\treadonly id = 'highlight';\n\treadonly name = 'Highlight';\n\treadonly priority = 24;\n\n\tprivate readonly config: HighlightConfig;\n\tprivate readonly colors: readonly string[];\n\tprivate locale!: HighlightLocale;\n\n\tconstructor(config?: Partial<HighlightConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.colors = resolveColors(config?.colors, HIGHLIGHT_PALETTE, 'HighlightPlugin');\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tHIGHLIGHT_LOCALE_EN,\n\t\t\tloadHighlightLocale,\n\t\t);\n\n\t\tcontext.registerStyleSheet(COLOR_PICKER_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec(\n\t\t\tcreateInlineStyleMarkSpec({\n\t\t\t\ttype: 'highlight',\n\t\t\t\trank: 4,\n\t\t\t\tvalueAttr: 'color',\n\t\t\t\tdomStyleProperty: 'backgroundColor',\n\t\t\t\tcssProperty: 'background-color',\n\t\t\t\tvalidate: isValidCSSColor,\n\t\t\t\tvalidateOnParse: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeHighlight', () => {\n\t\t\treturn removeColorMark(context, context.getState(), 'highlight');\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst pathD =\n\t\t\t'M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2z' + 'm-1.38 9L12 5.67 14.38 12H9.62z';\n\t\tconst icon: string = [\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\"',\n\t\t\t' viewBox=\"0 0 24 24\">',\n\t\t\t`<path d=\"${pathD}\"/>`,\n\t\t\t'<rect x=\"3\" y=\"17\" width=\"18\" height=\"6\"',\n\t\t\t' rx=\"0.5\" fill=\"#fff176\"/>',\n\t\t\t'</svg>',\n\t\t].join('');\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'highlight',\n\t\t\tgroup: 'format',\n\t\t\ticon,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeHighlight',\n\t\t\tpopupType: 'custom',\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderColorPickerPopup(container, ctx, {\n\t\t\t\t\tmarkType: 'highlight',\n\t\t\t\t\tcolors: this.colors,\n\t\t\t\t\tcolumns: 10,\n\t\t\t\t\tresetLabel: this.locale.resetLabel,\n\t\t\t\t\tresetCommand: 'removeHighlight',\n\t\t\t\t\tariaLabelPrefix: this.locale.ariaLabelPrefix,\n\t\t\t\t\tonClose,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state: EditorState) => isColorMarkActive(state, 'highlight'),\n\t\t});\n\t}\n}\n"],"mappings":"2RAeA,IAAa,EAAuC,CACnD,MAAO,YACP,QAAS,kBACT,WAAY,OACZ,gBAAiB,mBAKZ,iBAAkD,OAAA,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAIxD,eAAsB,EAAoB,GACzC,OAAO,EAAiB,EAAe,EAAM,EAC9C,CCzBA,IAAa,EAAuC,CAEnD,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UAEA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UAEA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UAEA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UAEA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,WCjBY,EAAb,MACC,GAAc,YACd,KAAgB,YAChB,SAAoB,GAEpB,OACA,OACA,OAEA,WAAA,CAAY,GACX,KAAK,OAAS,IAAK,GACnB,KAAK,OAAS,EAAc,GAAQ,OAAQ,EAAmB,kBAChE,CAEA,UAAM,CAAK,GACV,KAAK,aAAe,EACnB,EACA,KAAK,OAAO,OACZ,EACA,GAGD,EAAQ,mBAAmB,GAC3B,KAAK,iBAAiB,GACtB,KAAK,iBAAiB,GACtB,KAAK,oBAAoB,EAC1B,CAEA,gBAAA,CAAyB,GACxB,EAAQ,iBACP,EAA0B,CACzB,KAAM,YACN,KAAM,EACN,UAAW,QACX,iBAAkB,kBAClB,YAAa,mBACb,SAAU,EACV,iBAAiB,IAGpB,CAEA,gBAAA,CAAyB,GACxB,EAAQ,gBAAgB,kBAAA,IAChB,EAAgB,EAAS,EAAQ,WAAY,aAEtD,CAEA,mBAAA,CAA4B,GAG3B,MAAM,EAAe,CACpB,0CACA,wBACA,gGACA,2CACA,6BACA,UACC,KAAK,IAEP,EAAQ,oBAAoB,CAC3B,GAAI,YACJ,MAAO,SACP,OACA,MAAO,KAAK,OAAO,MACnB,QAAS,KAAK,OAAO,QACrB,QAAS,kBACT,UAAW,SACX,YAAA,CAAc,EAAW,EAAK,KAC7B,EAAuB,EAAW,EAAK,CACtC,SAAU,YACV,OAAQ,KAAK,OACb,QAAS,GACT,WAAY,KAAK,OAAO,WACxB,aAAc,kBACd,gBAAiB,KAAK,OAAO,gBAC7B,aAGF,SAAW,GAAuB,EAAkB,EAAO,cAE7D"}
1
+ {"version":3,"file":"HighlightPlugin-By7CWUss.mjs","names":[],"sources":["../../src/plugins/highlight/HighlightLocale.ts","../../src/plugins/highlight/HighlightPalette.ts","../../src/plugins/highlight/HighlightPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the HighlightPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface HighlightLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly resetLabel: string;\n\treadonly ariaLabelPrefix: string;\n}\n\n// --- Default English Locale ---\n\nexport const HIGHLIGHT_LOCALE_EN: HighlightLocale = {\n\tlabel: 'Highlight',\n\ttooltip: 'Highlight Color',\n\tresetLabel: 'None',\n\tariaLabelPrefix: 'Highlight color',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<HighlightLocale> = import.meta.glob<{\n\tdefault: HighlightLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadHighlightLocale(lang: string): Promise<HighlightLocale> {\n\treturn loadLocaleModule(localeModules, lang, HIGHLIGHT_LOCALE_EN);\n}\n","/**\n * Default highlight color palette (10 columns x 5 rows), optimized for\n * background highlighting. Used by HighlightPlugin when no `colors` override is\n * provided.\n */\nexport const HIGHLIGHT_PALETTE: readonly string[] = [\n\t// Row 1 — Classic highlighter colors (bright, vivid)\n\t'#fff176',\n\t'#aed581',\n\t'#4dd0e1',\n\t'#64b5f6',\n\t'#ce93d8',\n\t'#f48fb1',\n\t'#ffab91',\n\t'#ff8a65',\n\t'#e6ee9c',\n\t'#80cbc4',\n\t// Row 2 — Light pastels\n\t'#fff9c4',\n\t'#dcedc8',\n\t'#e0f7fa',\n\t'#e3f2fd',\n\t'#f3e5f5',\n\t'#fce4ec',\n\t'#fff3e0',\n\t'#fbe9e7',\n\t'#f9fbe7',\n\t'#e0f2f1',\n\t// Row 3 — Medium pastels\n\t'#fff59d',\n\t'#c5e1a5',\n\t'#80deea',\n\t'#90caf9',\n\t'#e1bee7',\n\t'#f8bbd0',\n\t'#ffcc80',\n\t'#ffab91',\n\t'#e6ee9c',\n\t'#a5d6a7',\n\t// Row 4 — Bold pastels\n\t'#ffee58',\n\t'#9ccc65',\n\t'#26c6da',\n\t'#42a5f5',\n\t'#ab47bc',\n\t'#ec407a',\n\t'#ffa726',\n\t'#ff7043',\n\t'#d4e157',\n\t'#66bb6a',\n\t// Row 5 — Grays and neutral highlights\n\t'#ffffff',\n\t'#fafafa',\n\t'#f5f5f5',\n\t'#eeeeee',\n\t'#e0e0e0',\n\t'#bdbdbd',\n\t'#e8eaf6',\n\t'#efebe9',\n\t'#eceff1',\n\t'#fafafa',\n];\n","/**\n * HighlightPlugin: registers a highlight (background-color) mark with attrs,\n * toolbar button with a color picker popup, and removeHighlight command.\n */\n\nimport { COLOR_PICKER_CSS } from '../../editor/styles/color-picker.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isColorMarkActive, removeColorMark } from '../shared/ColorMarkOperations.js';\nimport { renderColorPickerPopup } from '../shared/ColorPickerPopup.js';\nimport { isValidCSSColor, resolveColors } from '../shared/ColorValidation.js';\nimport { createInlineStyleMarkSpec } from '../shared/InlineStyleMarkSpec.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport {\n\tHIGHLIGHT_LOCALE_EN,\n\ttype HighlightLocale,\n\tloadHighlightLocale,\n} from './HighlightLocale.js';\nimport { HIGHLIGHT_PALETTE } from './HighlightPalette.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\thighlight: { color: string };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface HighlightConfig {\n\t/**\n\t * Restricts the color picker to a specific set of hex colors.\n\t * Each value must be a valid hex color code (`#RGB` or `#RRGGBB`).\n\t * Duplicates are removed automatically (case-insensitive).\n\t * When omitted, the full default palette is shown.\n\t */\n\treadonly colors?: readonly string[];\n\treadonly locale?: HighlightLocale;\n}\n\n// --- Plugin ---\n\nexport class HighlightPlugin implements Plugin {\n\treadonly id = 'highlight';\n\treadonly name = 'Highlight';\n\treadonly priority = 24;\n\n\tprivate readonly config: HighlightConfig;\n\tprivate readonly colors: readonly string[];\n\tprivate locale!: HighlightLocale;\n\n\tconstructor(config?: Partial<HighlightConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.colors = resolveColors(config?.colors, HIGHLIGHT_PALETTE, 'HighlightPlugin');\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tHIGHLIGHT_LOCALE_EN,\n\t\t\tloadHighlightLocale,\n\t\t);\n\n\t\tcontext.registerStyleSheet(COLOR_PICKER_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec(\n\t\t\tcreateInlineStyleMarkSpec({\n\t\t\t\ttype: 'highlight',\n\t\t\t\trank: 4,\n\t\t\t\tvalueAttr: 'color',\n\t\t\t\tdomStyleProperty: 'backgroundColor',\n\t\t\t\tcssProperty: 'background-color',\n\t\t\t\tvalidate: isValidCSSColor,\n\t\t\t\tvalidateOnParse: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeHighlight', () => {\n\t\t\treturn removeColorMark(context, context.getState(), 'highlight');\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst pathD =\n\t\t\t'M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2z' + 'm-1.38 9L12 5.67 14.38 12H9.62z';\n\t\tconst icon: string = [\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\"',\n\t\t\t' viewBox=\"0 0 24 24\">',\n\t\t\t`<path d=\"${pathD}\"/>`,\n\t\t\t'<rect x=\"3\" y=\"17\" width=\"18\" height=\"6\"',\n\t\t\t' rx=\"0.5\" fill=\"#fff176\"/>',\n\t\t\t'</svg>',\n\t\t].join('');\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'highlight',\n\t\t\tgroup: 'format',\n\t\t\ticon,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeHighlight',\n\t\t\tpopupType: 'custom',\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderColorPickerPopup(container, ctx, {\n\t\t\t\t\tmarkType: 'highlight',\n\t\t\t\t\tcolors: this.colors,\n\t\t\t\t\tcolumns: 10,\n\t\t\t\t\tresetLabel: this.locale.resetLabel,\n\t\t\t\t\tresetCommand: 'removeHighlight',\n\t\t\t\t\tariaLabelPrefix: this.locale.ariaLabelPrefix,\n\t\t\t\t\tonClose,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state: EditorState) => isColorMarkActive(state, 'highlight'),\n\t\t});\n\t}\n}\n"],"mappings":"2RAeA,IAAa,EAAuC,CACnD,MAAO,YACP,QAAS,kBACT,WAAY,OACZ,gBAAiB,mBAKZ,iBAAkD,OAAA,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAIxD,eAAsB,EAAoB,GACzC,OAAO,EAAiB,EAAe,EAAM,EAC9C,CCzBA,IAAa,EAAuC,CAEnD,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UAEA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UAEA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UAEA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UAEA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,WCjBY,EAAb,MACC,GAAc,YACd,KAAgB,YAChB,SAAoB,GAEpB,OACA,OACA,OAEA,WAAA,CAAY,GACX,KAAK,OAAS,IAAK,GACnB,KAAK,OAAS,EAAc,GAAQ,OAAQ,EAAmB,kBAChE,CAEA,UAAM,CAAK,GACV,KAAK,aAAe,EACnB,EACA,KAAK,OAAO,OACZ,EACA,GAGD,EAAQ,mBAAmB,GAC3B,KAAK,iBAAiB,GACtB,KAAK,iBAAiB,GACtB,KAAK,oBAAoB,EAC1B,CAEA,gBAAA,CAAyB,GACxB,EAAQ,iBACP,EAA0B,CACzB,KAAM,YACN,KAAM,EACN,UAAW,QACX,iBAAkB,kBAClB,YAAa,mBACb,SAAU,EACV,iBAAiB,IAGpB,CAEA,gBAAA,CAAyB,GACxB,EAAQ,gBAAgB,kBAAA,IAChB,EAAgB,EAAS,EAAQ,WAAY,aAEtD,CAEA,mBAAA,CAA4B,GAG3B,MAAM,EAAe,CACpB,0CACA,wBACA,gGACA,2CACA,6BACA,UACC,KAAK,IAEP,EAAQ,oBAAoB,CAC3B,GAAI,YACJ,MAAO,SACP,OACA,MAAO,KAAK,OAAO,MACnB,QAAS,KAAK,OAAO,QACrB,QAAS,kBACT,UAAW,SACX,YAAA,CAAc,EAAW,EAAK,KAC7B,EAAuB,EAAW,EAAK,CACtC,SAAU,YACV,OAAQ,KAAK,OACb,QAAS,GACT,WAAY,KAAK,OAAO,WACxB,aAAc,kBACd,gBAAiB,KAAK,OAAO,gBAC7B,aAGF,SAAW,GAAuB,EAAkB,EAAO,cAE7D"}
@@ -1,2 +1,2 @@
1
- import{r as t}from"./HTMLUtils-B0nGyFLb.mjs";import{D as e,R as n,p as i}from"./Document-D_2cIBJG.mjs";import{d as r,i as o,u as a}from"./Selection-DC6AOGgF.mjs";import{a as s}from"./TypeBrands-Ch9856Gb.mjs";import{s as l}from"./BlockInsertion-O5pAFKid.mjs";import{t as c}from"./NodeSelectionCommands-DK3iEh18.mjs";import{n as d}from"./TypedKeys-CA4bfw9O.mjs";import{c as g,o as m}from"./PluginHelpers-WG1Lzzh3.mjs";import{c as p,n as u,s as h}from"./StyleRuntime-C0RSqKzG.mjs";import{t as f}from"./Platform-ByobkiCc.mjs";import{n as b}from"./DomUtils-Bf7JLFlx.mjs";import{t as v}from"./ShortcutFormatting-TwiufqeV.mjs";function x(t,c){const d=t.getState(),g=d.selection,m={src:c.src,alt:c.alt??"",align:c.align??"center",...void 0!==c.width?{width:c.width}:{},...void 0!==c.height?{height:c.height}:{}};if(a(g))return!1;const p=r(g)?g.nodeId:g.anchor.blockId,u=function(t,e){if("table_cell"===t.getBlock(e)?.type)return e;const n=t.getNodePath(e);if(n)for(const i of n)if("table_cell"===t.getBlock(i)?.type)return i}(d,p);return u?function(t,r,a,l){const c=t.getNodePath(a);if(!c)return!1;const d=i(s("image"),[],void 0,l),g=t.getBlock(a);if(!g)return!1;const m=t.transaction("command"),p=e(g);for(let e=p.length-1;e>=0;e--){const t=g.children.findIndex(t=>n(t)&&t.id===p[e]?.id);-1!==t&&m.removeNode(c,t)}return m.insertNode(c,0,d),m.setSelection(o(d.id,[...c,d.id])),r.dispatch(m.build()),!0}(d,t,u,m):function(t,e,n,r){const a=i(s("image"),[],void 0,r),c=t.transaction("command");return!!l(t,c,n,a)&&(c.setSelection(o(a.id,[])),e.dispatch(c.build()),!0)}(d,t,p,m)}function _(t,e,n){const i=t.getState(),o=i.selection;if(!r(o))return!1;const a=i.getBlock(o.nodeId);if(!a||"image"!==a.type)return!1;const s=a.attrs?.width,l=a.attrs?.height;if(void 0===s||void 0===l)return!1;const c=l>0?s/l:1,d=Math.max(50,Math.min(n,s+e)),g=Math.round(d/c);return(d!==s||g!==l)&&function(t,e){const n=t.getState(),i=n.selection;if(!r(i))return!1;const o=n.getBlock(i.nodeId);if(!o||"image"!==o.type)return!1;const a=n.getNodePath(i.nodeId);if(!a)return!1;const s={...o.attrs??{},...e},l=n.transaction("command").setNodeAttr(a,s).build();return t.dispatch(l),!0}(t,{width:d,height:g})}var w={insertImage:"Insert Image",insertImageTooltip:"Insert Image",uploadFromComputer:"Upload from computer",uploadAria:"Upload image from computer",separator:"or",urlPlaceholder:"https://...",urlAria:"Image URL",insertButton:"Insert",insertAria:"Insert image",imageAria:(t,e,n)=>{const i=[t||"Image"];return void 0!==e&&void 0!==n&&i.push(`${e} by ${n} pixels`),i.join(", ")},resetToNaturalSize:"Image reset to natural size.",uploadFailed:"Upload failed.",uploading:"Uploading...",resizeHandleLabel:t=>`Resize ${t}`,imageSelected:"Image selected.",altTextPrefix:"Alt text: ",imageSizeAnnounce:(t,e)=>`Size: ${t} by ${e} pixels.`,resizeHint:(t,e)=>`${t} / ${e} to resize.`,imageResized:(t,e)=>`Image resized to ${t} by ${e} pixels.`,keyboardResizeHint:(t,e)=>`${t} / ${e} to resize`},z=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-4b8e2YSc.mjs"),"./locales/de.ts":()=>import("./de-i95F9SDy.mjs"),"./locales/es.ts":()=>import("./es-DehVGwQ8.mjs"),"./locales/fr.ts":()=>import("./fr-DEZ_oxzS.mjs"),"./locales/hi.ts":()=>import("./hi-J8ErB5nB.mjs"),"./locales/pt.ts":()=>import("./pt-BlFAJZo7.mjs"),"./locales/ru.ts":()=>import("./ru-D53d-_UB.mjs"),"./locales/zh.ts":()=>import("./zh-DdzgYD7k.mjs")});async function y(t){return g(z,t,w)}var S={start:"notectl-image--start",center:"notectl-image--center",end:"notectl-image--end"},I={nw:"nwse-resize",ne:"nesw-resize",sw:"nesw-resize",se:"nwse-resize"},k={nw:-1,ne:1,sw:-1,se:1},A={nw:"nesw-resize",ne:"nwse-resize",sw:"nwse-resize",se:"nesw-resize"},L=null;function C(){L&&(L.remove(),L=null)}function N(t,e,n,i=w){return(r,o,a)=>{const s=document.createElement("figure");s.className="notectl-image",s.setAttribute("data-block-id",r.id),s.setAttribute("data-void","true"),s.setAttribute("data-selectable","true");const l=document.createElement("div");l.className="notectl-image__container";const c=document.createElement("img");c.className="notectl-image__img",c.draggable=!1;const d=document.createElement("div");d.className="notectl-image__overlay",l.appendChild(c),l.appendChild(d),s.appendChild(l);let g=r.id,m=null;function b(t){const n=t.attrs?.src??"",r=t.attrs?.alt??"",o=t.attrs?.width,a=t.attrs?.height,l=t.attrs?.align??"center";c.src!==n&&(c.src=n),c.alt=r,p(c,"width",void 0!==o?`${o}px`:""),p(c,"height",void 0!==a?`${a}px`:"");for(const e of Object.values(S))s.classList.remove(e);const g=S[l];g&&s.classList.add(g);const m=e.get(t.id)??"idle",u="uploading"===m;d.classList.toggle("notectl-image__overlay--uploading",u),d.classList.toggle("notectl-image__overlay--error","error"===m),d.textContent=u?i.uploading:"error"===m?i.uploadFailed:"",u?s.setAttribute("aria-busy","true"):s.removeAttribute("aria-busy"),function(t){const e=t.attrs?.alt??"",n=t.attrs?.width,r=t.attrs?.height;s.setAttribute("aria-label",i.imageAria(e,n,r))}(t)}b(r);let x=!1;function _(e,n,i,r){let l=0,d=0,g=1,m=k[n];const p=e=>{const n=e.clientX-l,i=(o=d+n*m,Math.max(50,Math.min(t.maxWidth,o)));var o;const a=Math.round(i/g);h(c,{width:`${i}px`,height:`${a}px`}),r.textContent=`${Math.round(i)} × ${a}`},b=t=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",b),s.classList.remove("notectl-image--resizing"),r.classList.remove("notectl-image__size-indicator--visible"),C();const e=Math.round(c.getBoundingClientRect().width);!function(t,e,n){const i=o(),r=i.getBlock(t);if(!r)return;const s=r.attrs?.width,l=r.attrs?.height;if(s===e&&l===n)return;const c=i.getNodePath(t);if(!c)return;const d={...r.attrs??{},width:e,height:n};a(i.transaction("command").setNodeAttr(c,d).build())}(i,e,Math.round(e/g)),t.target?.releasePointerCapture?.(t.pointerId)};e.addEventListener("pointerdown",t=>{t.preventDefault(),t.stopPropagation();const e="rtl"===f(s);m=function(t,e){const n=k[t];return e?-n:n}(n,e),l=t.clientX,d=c.getBoundingClientRect().width;const i=c.getBoundingClientRect().height;g=i>0?d/i:1,s.classList.add("notectl-image--resizing"),r.textContent=`${Math.round(d)} × ${Math.round(i)}`,r.classList.add("notectl-image__size-indicator--visible"),function(t,e){C(),L=document.createElement("style");const n=e?u(e):void 0;n&&L.setAttribute("nonce",n),L.textContent=`*{cursor:${t}!important;user-select:none!important}`,document.head.appendChild(L)}(e?A[n]:I[n],s),t.target.setPointerCapture(t.pointerId),document.addEventListener("pointermove",p),document.addEventListener("pointerup",b)})}function w(){C(),m&&(m.remove(),m=null)}return c.addEventListener("load",()=>{if(x)return;const e=o(),n=e.getBlock(g);if(!n||"image"!==n.type)return;const i=void 0!==n.attrs?.width,r=void 0!==n.attrs?.height;if(i&&r)return void(x=!0);const s=c.naturalWidth,l=c.naturalHeight;if(0===s||0===l)return;const d=Math.min(s,t.maxWidth),m=s>0?l/s:1,p=Math.round(d*m),u=e.getNodePath(g);if(!u)return;const h={...n.attrs??{},width:d,height:p};a(e.transaction("command").setNodeAttr(u,h).build()),x=!0}),{dom:s,contentDOM:null,update:t=>"image"===t.type&&(g=t.id,s.setAttribute("data-block-id",t.id),b(t),!0),selectNode(){s.classList.add("notectl-image--selected"),function(e){if(!t.resizable||m)return;m=document.createElement("div"),m.className="notectl-image__resize-overlay",m.setAttribute("data-notectl-no-print","");const r=document.createElement("div");r.className="notectl-image__size-indicator",m.appendChild(r);for(const t of["nw","ne","sw","se"]){const n=document.createElement("div");n.className=`notectl-image__resize-handle notectl-image__resize-handle--${t}`,n.setAttribute("aria-hidden","true"),_(n,t,e,r),m.appendChild(n)}if(n){const t=function(t,e){const n=t.shrinkWidth??null,i=t.growWidth??null;return n&&i?e.keyboardResizeHint(v(n),v(i)):""}(n,i);if(t){const e=document.createElement("div");e.className="notectl-image__keyboard-hint",e.setAttribute("aria-hidden","true"),e.textContent=t,m.appendChild(e)}}l.appendChild(m)}(g)},deselectNode(){s.classList.remove("notectl-image--selected"),w()},destroy(){w()}}}}var j=new d("image:upload"),$={growWidth:"Mod-Shift-ArrowRight",shrinkWidth:"Mod-Shift-ArrowLeft",growWidthLarge:"Mod-Shift-Alt-ArrowRight",shrinkWidthLarge:"Mod-Shift-Alt-ArrowLeft",resetSize:"Mod-Shift-0"},E={maxWidth:800,maxFileSize:10485760,acceptedTypes:["image/png","image/jpeg","image/gif","image/webp","image/svg+xml"],resizable:!0,resizeStep:10,resizeStepLarge:50},M=class{id="image";name="Image";priority=45;config;resolvedKeymap;uploadStates=/* @__PURE__ */new Map;blobUrls=/* @__PURE__ */new Set;context=null;locale;constructor(t){this.config={...E,...t},this.resolvedKeymap={...$,...t?.keymap}}async init(t){this.locale=await m(t,this.config.locale,w,y),t.registerStyleSheet('\n/* Image */\n.notectl-image {\n\tmargin: 8px 0;\n\tuser-select: none;\n\tline-height: 0;\n}\n\n.notectl-image--center {\n\ttext-align: center;\n}\n\n.notectl-image--start {\n\ttext-align: start;\n}\n\n.notectl-image--end {\n\ttext-align: end;\n}\n\n.notectl-image__container {\n\tdisplay: inline-block;\n\tposition: relative;\n\tline-height: 0;\n}\n\n.notectl-image__img {\n\tdisplay: block;\n\tmax-width: 100%;\n\tborder-radius: 4px;\n}\n\n.notectl-image--selected .notectl-image__container {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n\tborder-radius: 6px;\n}\n\n/* Alignment toolbar (appears on image selection) */\n.notectl-image__align-toolbar {\n\tdisplay: flex;\n\tgap: 2px;\n\tposition: absolute;\n\ttop: -36px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tpadding: 2px;\n\tbox-shadow: 0 2px 8px var(--notectl-shadow);\n\tz-index: 10;\n}\n\n.notectl-image__align-btn {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\theight: 28px;\n\tborder: none;\n\tbackground: transparent;\n\tborder-radius: 4px;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-image__align-btn:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-image__align-btn--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-image__align-btn svg {\n\twidth: 16px;\n\theight: 16px;\n\tfill: currentColor;\n}\n\n/* Upload overlay */\n.notectl-image__overlay {\n\tposition: absolute;\n\tinset: 0;\n\tdisplay: none;\n\talign-items: center;\n\tjustify-content: center;\n\tbackground: rgba(255, 255, 255, 0.8);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg-muted);\n}\n\n.notectl-image__overlay--uploading {\n\tdisplay: flex;\n}\n\n.notectl-image__overlay--error {\n\tdisplay: flex;\n\tbackground: var(--notectl-danger-muted);\n\tcolor: var(--notectl-danger);\n}\n\n/* Resize overlay + handles */\n.notectl-image__resize-overlay {\n\tposition: absolute;\n\tinset: 0;\n\tpointer-events: none;\n}\n\n.notectl-image__resize-handle {\n\tposition: absolute;\n\twidth: 10px;\n\theight: 10px;\n\tbackground: var(--notectl-surface-raised);\n\tborder: 2px solid var(--notectl-primary);\n\tborder-radius: 50%;\n\tpointer-events: all;\n\tz-index: 2;\n\ttransition: transform 0.1s, background 0.1s;\n}\n\n.notectl-image__resize-handle:hover {\n\tbackground: var(--notectl-primary);\n\ttransform: scale(1.3);\n}\n\n.notectl-image--resizing .notectl-image__resize-handle {\n\tbackground: var(--notectl-primary);\n}\n\n.notectl-image__resize-handle--nw {\n\ttop: -5px;\n\tinset-inline-start: -5px;\n\tcursor: nwse-resize;\n}\n\n.notectl-image__resize-handle--ne {\n\ttop: -5px;\n\tinset-inline-end: -5px;\n\tcursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--sw {\n\tbottom: -5px;\n\tinset-inline-start: -5px;\n\tcursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--se {\n\tbottom: -5px;\n\tinset-inline-end: -5px;\n\tcursor: nwse-resize;\n}\n\n/* RTL cursor overrides — flip diagonal cursors when in RTL context */\n[dir="rtl"] .notectl-image__resize-handle--nw {\n\tcursor: nesw-resize;\n}\n\n[dir="rtl"] .notectl-image__resize-handle--ne {\n\tcursor: nwse-resize;\n}\n\n[dir="rtl"] .notectl-image__resize-handle--sw {\n\tcursor: nwse-resize;\n}\n\n[dir="rtl"] .notectl-image__resize-handle--se {\n\tcursor: nesw-resize;\n}\n\n/* Size indicator tooltip */\n.notectl-image__size-indicator {\n\tposition: absolute;\n\tbottom: -28px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tpadding: 2px 8px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\tborder-radius: 4px;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\topacity: 0;\n\ttransition: opacity 0.15s;\n\tz-index: 3;\n}\n\n.notectl-image__size-indicator--visible {\n\topacity: 1;\n}\n\n/* Keyboard resize hint (shown on selection, hidden during drag) */\n.notectl-image__keyboard-hint {\n\tdisplay: none;\n\tposition: absolute;\n\tbottom: -28px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tpadding: 2px 8px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 3;\n}\n\n.notectl-image--selected .notectl-image__keyboard-hint {\n\tdisplay: block;\n}\n\n.notectl-image--resizing .notectl-image__keyboard-hint {\n\tdisplay: none;\n}\n\n/* Resizing feedback */\n.notectl-image--resizing .notectl-image__img {\n\topacity: 0.85;\n}\n'),t.registerStyleSheet("\n.notectl-image-popup {\n\tpadding: 8px;\n\tmin-width: 240px;\n}\n\n.notectl-image-popup__file-input {\n\tposition: absolute;\n\twidth: 0;\n\theight: 0;\n\toverflow: hidden;\n\topacity: 0;\n}\n\n.notectl-image-popup__upload-btn {\n\tdisplay: block;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\tcursor: pointer;\n\ttext-align: center;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-image-popup__separator {\n\tdisplay: flex;\n\talign-items: center;\n\tmargin: 8px 0;\n\tcolor: var(--notectl-fg-muted);\n\tfont-size: 12px;\n}\n\n.notectl-image-popup__separator-line {\n\tflex: 1;\n\theight: 1px;\n\tbackground: var(--notectl-border);\n}\n\n.notectl-image-popup__separator-text {\n\tpadding: 0 8px;\n}\n\n.notectl-image-popup__url-input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-overlay);\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-image-popup__insert-btn {\n\twidth: 100%;\n\tpadding: 8px 12px;\n\tmargin-top: 4px;\n\tcursor: pointer;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg);\n}\n"),this.context=t,this.registerNodeSpec(t),this.registerInlineImageNodeSpec(t),this.registerNodeView(t),function(t){t.registerCommand("insertImage",()=>x(t,{src:""})),t.registerCommand("removeImage",()=>function(t){const e=t.getState(),n=e.selection;if(!r(n))return!1;const i=e.getBlock(n.nodeId);if(!i||"image"!==i.type)return!1;const a=e.getNodePath(n.nodeId);if(!a||0===a.length)return!1;const s=c(e,o(n.nodeId,a));return!!s&&(t.dispatch(s),!0)}(t))}(t),this.registerResizeCommands(t),this.registerResizeKeymaps(t),this.registerFileHandler(t),this.registerToolbarItem(t)}destroy(){for(const t of this.blobUrls)URL.revokeObjectURL(t);this.blobUrls.clear(),this.uploadStates.clear(),this.context=null}onStateChange(t,e,n){if(!this.context)return;for(const o of this.uploadStates.keys())e.getBlock(o)||this.uploadStates.delete(o);const i=this.isImageSelected(t),r=this.isImageSelected(e);!i&&r&&this.announceImageSelection(e)}registerNodeSpec(e){const n=this.locale;e.registerNodeSpec({type:"image",group:"block",isVoid:!0,selectable:!0,attrs:{src:{default:""},alt:{default:""},title:{default:""},align:{default:"center"}},toDOM(t){const e=b("figure",t.id);e.className="notectl-image",e.setAttribute("data-void","true"),e.setAttribute("data-selectable","true");const i=document.createElement("div");i.className="notectl-image__container";const r=t.attrs?.alt??"",o=t.attrs?.width,a=t.attrs?.height,s=document.createElement("img");s.className="notectl-image__img",s.src=t.attrs?.src??"",s.alt=r;const l=t.attrs?.title??"";l&&(s.title=l),s.draggable=!1,void 0!==o&&p(s,"width",`${o}px`),void 0!==a&&p(s,"height",`${a}px`);const c={start:"notectl-image--start",center:"notectl-image--center",end:"notectl-image--end"}[t.attrs?.align??"center"];return c&&e.classList.add(c),e.setAttribute("aria-label",n.imageAria(r,o,a)),i.appendChild(s),e.appendChild(i),e},toHTML(e){const n=t(e.attrs?.src??""),i=t(e.attrs?.alt??""),r=e.attrs?.width,o=e.attrs?.height,a=(void 0!==r?` width="${r}"`:"")+(void 0!==o?` height="${o}"`:""),s=e.attrs?.title??"";return`<figure><img src="${n}" alt="${i}"${s?` title="${t(s)}"`:""}${a}></figure>`},parseHTML:[{tag:"figure",getAttrs(t){const e=t.querySelector("img");if(!e)return!1;const n={src:e.getAttribute("src")??"",alt:e.getAttribute("alt")??"",align:"center"},i=e.getAttribute("width"),r=e.getAttribute("height");i&&(n.width=Number.parseInt(i,10)),r&&(n.height=Number.parseInt(r,10));const o=e.getAttribute("title");o&&(n.title=o);const a=t.style?.textAlign??"";return"start"===a||"end"===a||"center"===a?n.align=a:"left"===a?n.align="start":"right"===a?n.align="end":t.classList.contains("notectl-align-start")||t.classList.contains("notectl-align-left")||t.classList.contains("notectl-image--start")||t.classList.contains("notectl-image--left")?n.align="start":t.classList.contains("notectl-align-end")||t.classList.contains("notectl-align-right")||t.classList.contains("notectl-image--end")||t.classList.contains("notectl-image--right")?n.align="end":t.classList.contains("notectl-align-center")&&(n.align="center"),n}},{tag:"img",getAttrs(t){const e={src:t.getAttribute("src")??"",alt:t.getAttribute("alt")??"",align:"center"},n=t.getAttribute("width"),i=t.getAttribute("height");n&&(e.width=Number.parseInt(n,10)),i&&(e.height=Number.parseInt(i,10));const r=t.getAttribute("title");return r&&(e.title=r),e}}],sanitize:{tags:["figure","img"],attrs:["src","alt","title","width","height","class","style"]}})}registerInlineImageNodeSpec(e){e.registerInlineNodeSpec({type:"image_inline",group:"inline",attrs:{src:{default:""},alt:{default:""},title:{default:""}},toDOM(t){const e=document.createElement("img");e.className="notectl-image-inline",e.setAttribute("contenteditable","false"),e.src=String(t.attrs.src??""),e.alt=String(t.attrs.alt??"");const n=String(t.attrs.title??"");return n&&(e.title=n),e.draggable=!1,e},toHTMLString(e){const n=t(String(e.attrs.src??"")),i=t(String(e.attrs.alt??"")),r=String(e.attrs.title??"");return`<img src="${n}" alt="${i}"${r?` title="${t(r)}"`:""}>`},parseHTML:[{tag:"img",getAttrs:t=>{const e={src:t.getAttribute("src")??"",alt:t.getAttribute("alt")??""},n=t.getAttribute("title");return n&&(e.title=n),e}}],sanitize:{tags:["img"],attrs:["src","alt","title"]}})}registerNodeView(t){t.registerNodeView("image",N(this.config,this.uploadStates,this.resolvedKeymap,this.locale))}registerResizeCommands(t){const e=this.config.resizeStep??10,n=this.config.resizeStepLarge??50,i=this.config.maxWidth;t.registerCommand("resizeImageGrow",()=>{const n=_(t,e,i);return n&&this.announceCurrentSize(t),n}),t.registerCommand("resizeImageShrink",()=>{const n=_(t,-e,i);return n&&this.announceCurrentSize(t),n}),t.registerCommand("resizeImageGrowLarge",()=>{const e=_(t,n,i);return e&&this.announceCurrentSize(t),e}),t.registerCommand("resizeImageShrinkLarge",()=>{const e=_(t,-n,i);return e&&this.announceCurrentSize(t),e}),t.registerCommand("resetImageSize",()=>{const e=function(t){const e=t.getState(),n=e.selection;if(!r(n))return!1;const i=e.getBlock(n.nodeId);if(!i||"image"!==i.type)return!1;const o=e.getNodePath(n.nodeId);if(!o)return!1;const a={...i.attrs??{}},s=Object.fromEntries(Object.entries(a).filter(([t])=>"width"!==t&&"height"!==t)),l=e.transaction("command").setNodeAttr(o,s).build();return t.dispatch(l),!0}(t);return e&&t.announce(this.locale.resetToNaturalSize),e})}registerResizeKeymaps(t){const e={};for(const[n,i]of Object.entries({growWidth:"resizeImageGrow",shrinkWidth:"resizeImageShrink",growWidthLarge:"resizeImageGrowLarge",shrinkWidthLarge:"resizeImageShrinkLarge",resetSize:"resetImageSize"})){const r=this.resolvedKeymap[n]??null;r&&(e[r]=()=>t.executeCommand(i))}Object.keys(e).length>0&&t.registerKeymap(e)}registerFileHandler(t){t.registerFileHandler("image/*",async(e,n)=>!!this.isAcceptedType(e.type)&&(this.handleFileInsert(t,e),!0))}handleFileInsert(t,e){if(e.size>this.config.maxFileSize)return;const n=URL.createObjectURL(e);if(this.blobUrls.add(n),!x(t,{src:n}))return URL.revokeObjectURL(n),void this.blobUrls.delete(n);const i=t.getState().selection;if(!r(i))return;const o=i.nodeId;this.uploadStates.set(o,"uploading"),t.getService(j)?this.uploadFile(t,e,o,n):this.uploadStates.set(o,"complete")}async uploadFile(t,e,n,i){const r=t.getService(j);if(r)try{const o=await r.upload(e);this.uploadStates.set(n,"complete");const a=t.getState(),s=a.getBlock(n);if(!s)return;const l=a.getNodePath(n);if(!l)return;const c={...s.attrs??{},src:o.url,...void 0!==o.width?{width:o.width}:{},...void 0!==o.height?{height:o.height}:{}},d=a.transaction("command").setNodeAttr(l,c).build();t.dispatch(d),URL.revokeObjectURL(i),this.blobUrls.delete(i)}catch{this.uploadStates.set(n,"error"),t.announce(this.locale.uploadFailed)}}registerToolbarItem(t){t.registerToolbarItem({id:"image",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>',label:this.locale.insertImage,tooltip:this.locale.insertImageTooltip,command:"insertImage",popupType:"custom",renderPopup:(t,e,n)=>{!function(t,e,n){t.classList.add("notectl-image-popup"),function(t,e,n){const i=document.createElement("input");i.type="file",i.accept=n.acceptedTypes.join(","),i.className="notectl-image-popup__file-input";const r=document.createElement("button");r.type="button",r.textContent=n.locale.uploadFromComputer,r.setAttribute("aria-label",n.locale.uploadAria),r.className="notectl-image-popup__upload-btn",r.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),i.click()}),i.addEventListener("change",()=>{const t=i.files?.[0];t&&(n.onFileInsert(e,t),n.onClose(),e.getContainer().focus())}),t.appendChild(i),t.appendChild(r)}(t,e,n),function(t,e){const n=document.createElement("div");n.className="notectl-image-popup__separator";const i=document.createElement("span");i.className="notectl-image-popup__separator-line";const r=document.createElement("span");r.textContent=e.separator,r.className="notectl-image-popup__separator-text";const o=document.createElement("span");o.className="notectl-image-popup__separator-line",n.appendChild(i),n.appendChild(r),n.appendChild(o),t.appendChild(n)}(t,n.locale),function(t,e,n){const i=document.createElement("input");i.type="url",i.placeholder=n.locale.urlPlaceholder,i.setAttribute("aria-label",n.locale.urlAria),i.className="notectl-image-popup__url-input";const r=document.createElement("button");r.type="button",r.textContent=n.locale.insertButton,r.setAttribute("aria-label",n.locale.insertAria),r.className="notectl-image-popup__insert-btn";const o=()=>{const t=i.value.trim();t&&(x(e,{src:t}),n.onClose(),e.getContainer().focus())};r.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),o()}),i.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),o())}),t.appendChild(i),t.appendChild(r),requestAnimationFrame(()=>i.focus())}(t,e,n)}(t,e,{acceptedTypes:this.config.acceptedTypes,locale:this.locale,onFileInsert:(t,e)=>this.handleFileInsert(t,e),onClose:n})}})}isAcceptedType(t){return this.config.acceptedTypes.some(e=>e===t||e.endsWith("/*")&&t.startsWith(e.slice(0,-1)))}isImageSelected(t){const e=t.selection;return!!r(e)&&"image"===t.getBlock(e.nodeId)?.type}announceImageSelection(t){if(!this.context)return;const e=t.selection;if(!r(e))return;const n=t.getBlock(e.nodeId);if(!n||"image"!==n.type)return;const i=n.attrs?.alt??"",o=n.attrs?.width,a=n.attrs?.height,s=[this.locale.imageSelected];i&&s.push(`${this.locale.altTextPrefix}${i}.`),void 0!==o&&void 0!==a&&s.push(this.locale.imageSizeAnnounce(o,a));const l=this.resolvedKeymap.shrinkWidth??null,c=this.resolvedKeymap.growWidth??null;l&&c&&s.push(this.locale.resizeHint(v(l),v(c))),this.context.announce(s.join(" "))}announceCurrentSize(t){const e=t.getState(),n=e.selection;if(!r(n))return;const i=e.getBlock(n.nodeId);if(!i||"image"!==i.type)return;const o=i.attrs?.width,a=i.attrs?.height;void 0!==o&&void 0!==a&&t.announce(this.locale.imageResized(o,a))}};export{y as a,w as i,$ as n,j as r,M as t};
2
- //# sourceMappingURL=ImagePlugin-C5ESNNsA.mjs.map
1
+ import{r as t}from"./HTMLUtils-B0nGyFLb.mjs";import{D as e,R as n,p as i}from"./Document-D_2cIBJG.mjs";import{d as r,i as o,u as a}from"./Selection-DC6AOGgF.mjs";import{a as s}from"./TypeBrands-Ch9856Gb.mjs";import{s as l}from"./BlockInsertion-O5pAFKid.mjs";import{t as c}from"./NodeSelectionCommands-DK3iEh18.mjs";import{n as d}from"./TypedKeys-CA4bfw9O.mjs";import{c as g,o as m}from"./PluginHelpers-WG1Lzzh3.mjs";import{c as p,n as u,s as h}from"./StyleRuntime-C0RSqKzG.mjs";import{t as f}from"./Platform-ByobkiCc.mjs";import{n as b}from"./DomUtils-Bf7JLFlx.mjs";import{t as v}from"./ShortcutFormatting-TwiufqeV.mjs";function x(t,c){const d=t.getState(),g=d.selection,m={src:c.src,alt:c.alt??"",align:c.align??"center",...void 0!==c.width?{width:c.width}:{},...void 0!==c.height?{height:c.height}:{}};if(a(g))return!1;const p=r(g)?g.nodeId:g.anchor.blockId,u=function(t,e){if("table_cell"===t.getBlock(e)?.type)return e;const n=t.getNodePath(e);if(n)for(const i of n)if("table_cell"===t.getBlock(i)?.type)return i}(d,p);return u?function(t,r,a,l){const c=t.getNodePath(a);if(!c)return!1;const d=i(s("image"),[],void 0,l),g=t.getBlock(a);if(!g)return!1;const m=t.transaction("command"),p=e(g);for(let e=p.length-1;e>=0;e--){const t=g.children.findIndex(t=>n(t)&&t.id===p[e]?.id);-1!==t&&m.removeNode(c,t)}return m.insertNode(c,0,d),m.setSelection(o(d.id,[...c,d.id])),r.dispatch(m.build()),!0}(d,t,u,m):function(t,e,n,r){const a=i(s("image"),[],void 0,r),c=t.transaction("command");return!!l(t,c,n,a)&&(c.setSelection(o(a.id,[])),e.dispatch(c.build()),!0)}(d,t,p,m)}function _(t,e,n){const i=t.getState(),o=i.selection;if(!r(o))return!1;const a=i.getBlock(o.nodeId);if(!a||"image"!==a.type)return!1;const s=a.attrs?.width,l=a.attrs?.height;if(void 0===s||void 0===l)return!1;const c=l>0?s/l:1,d=Math.max(50,Math.min(n,s+e)),g=Math.round(d/c);return(d!==s||g!==l)&&function(t,e){const n=t.getState(),i=n.selection;if(!r(i))return!1;const o=n.getBlock(i.nodeId);if(!o||"image"!==o.type)return!1;const a=n.getNodePath(i.nodeId);if(!a)return!1;const s={...o.attrs??{},...e},l=n.transaction("command").setNodeAttr(a,s).build();return t.dispatch(l),!0}(t,{width:d,height:g})}var w={insertImage:"Insert Image",insertImageTooltip:"Insert Image",uploadFromComputer:"Upload from computer",uploadAria:"Upload image from computer",separator:"or",urlPlaceholder:"https://...",urlAria:"Image URL",insertButton:"Insert",insertAria:"Insert image",imageAria:(t,e,n)=>{const i=[t||"Image"];return void 0!==e&&void 0!==n&&i.push(`${e} by ${n} pixels`),i.join(", ")},resetToNaturalSize:"Image reset to natural size.",uploadFailed:"Upload failed.",uploading:"Uploading...",resizeHandleLabel:t=>`Resize ${t}`,imageSelected:"Image selected.",altTextPrefix:"Alt text: ",imageSizeAnnounce:(t,e)=>`Size: ${t} by ${e} pixels.`,resizeHint:(t,e)=>`${t} / ${e} to resize.`,imageResized:(t,e)=>`Image resized to ${t} by ${e} pixels.`,keyboardResizeHint:(t,e)=>`${t} / ${e} to resize`},z=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-4b8e2YSc.mjs"),"./locales/de.ts":()=>import("./de-i95F9SDy.mjs"),"./locales/es.ts":()=>import("./es-DehVGwQ8.mjs"),"./locales/fr.ts":()=>import("./fr-DEZ_oxzS.mjs"),"./locales/hi.ts":()=>import("./hi-J8ErB5nB.mjs"),"./locales/pt.ts":()=>import("./pt-BlFAJZo7.mjs"),"./locales/ru.ts":()=>import("./ru-D53d-_UB.mjs"),"./locales/zh.ts":()=>import("./zh-DdzgYD7k.mjs")});async function y(t){return g(z,t,w)}var S={start:"notectl-image--start",center:"notectl-image--center",end:"notectl-image--end"},I={nw:"nwse-resize",ne:"nesw-resize",sw:"nesw-resize",se:"nwse-resize"},k={nw:-1,ne:1,sw:-1,se:1},L={nw:"nesw-resize",ne:"nwse-resize",sw:"nwse-resize",se:"nesw-resize"},A=null;function C(){A&&(A.remove(),A=null)}function N(t,e,n,i=w){return(r,o,a)=>{const s=document.createElement("figure");s.className="notectl-image",s.setAttribute("data-block-id",r.id),s.setAttribute("data-void","true"),s.setAttribute("data-selectable","true");const l=document.createElement("div");l.className="notectl-image__container";const c=document.createElement("img");c.className="notectl-image__img",c.draggable=!1;const d=document.createElement("div");d.className="notectl-image__overlay",l.appendChild(c),l.appendChild(d),s.appendChild(l);let g=r.id,m=null;function b(t){const n=t.attrs?.src??"",r=t.attrs?.alt??"",o=t.attrs?.width,a=t.attrs?.height,l=t.attrs?.align??"center";c.src!==n&&(c.src=n),c.alt=r,p(c,"width",void 0!==o?`${o}px`:""),p(c,"height",void 0!==a?`${a}px`:"");for(const e of Object.values(S))s.classList.remove(e);const g=S[l];g&&s.classList.add(g);const m=e.get(t.id)??"idle",u="uploading"===m;d.classList.toggle("notectl-image__overlay--uploading",u),d.classList.toggle("notectl-image__overlay--error","error"===m),d.textContent=u?i.uploading:"error"===m?i.uploadFailed:"",u?s.setAttribute("aria-busy","true"):s.removeAttribute("aria-busy"),function(t){const e=t.attrs?.alt??"",n=t.attrs?.width,r=t.attrs?.height;s.setAttribute("aria-label",i.imageAria(e,n,r))}(t)}b(r);let x=!1;function _(e,n,i,r){let l=0,d=0,g=1,m=k[n];const p=e=>{const n=e.clientX-l,i=(o=d+n*m,Math.max(50,Math.min(t.maxWidth,o)));var o;const a=Math.round(i/g);h(c,{width:`${i}px`,height:`${a}px`}),r.textContent=`${Math.round(i)} × ${a}`},b=t=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",b),s.classList.remove("notectl-image--resizing"),r.classList.remove("notectl-image__size-indicator--visible"),C();const e=Math.round(c.getBoundingClientRect().width);!function(t,e,n){const i=o(),r=i.getBlock(t);if(!r)return;const s=r.attrs?.width,l=r.attrs?.height;if(s===e&&l===n)return;const c=i.getNodePath(t);if(!c)return;const d={...r.attrs??{},width:e,height:n};a(i.transaction("command").setNodeAttr(c,d).build())}(i,e,Math.round(e/g)),t.target?.releasePointerCapture?.(t.pointerId)};e.addEventListener("pointerdown",t=>{t.preventDefault(),t.stopPropagation();const e="rtl"===f(s);m=function(t,e){const n=k[t];return e?-n:n}(n,e),l=t.clientX,d=c.getBoundingClientRect().width;const i=c.getBoundingClientRect().height;g=i>0?d/i:1,s.classList.add("notectl-image--resizing"),r.textContent=`${Math.round(d)} × ${Math.round(i)}`,r.classList.add("notectl-image__size-indicator--visible"),function(t,e){C(),A=document.createElement("style");const n=e?u(e):void 0;n&&A.setAttribute("nonce",n),A.textContent=`*{cursor:${t}!important;user-select:none!important}`,document.head.appendChild(A)}(e?L[n]:I[n],s),t.target.setPointerCapture(t.pointerId),document.addEventListener("pointermove",p),document.addEventListener("pointerup",b)})}function w(){C(),m&&(m.remove(),m=null)}return c.addEventListener("load",()=>{if(x)return;const e=o(),n=e.getBlock(g);if(!n||"image"!==n.type)return;const i=void 0!==n.attrs?.width,r=void 0!==n.attrs?.height;if(i&&r)return void(x=!0);const s=c.naturalWidth,l=c.naturalHeight;if(0===s||0===l)return;const d=Math.min(s,t.maxWidth),m=s>0?l/s:1,p=Math.round(d*m),u=e.getNodePath(g);if(!u)return;const h={...n.attrs??{},width:d,height:p};a(e.transaction("command").setNodeAttr(u,h).build()),x=!0}),{dom:s,contentDOM:null,update:t=>"image"===t.type&&(g=t.id,s.setAttribute("data-block-id",t.id),b(t),!0),selectNode(){s.classList.add("notectl-image--selected"),function(e){if(!t.resizable||m)return;m=document.createElement("div"),m.className="notectl-image__resize-overlay",m.setAttribute("data-notectl-no-print","");const r=document.createElement("div");r.className="notectl-image__size-indicator",m.appendChild(r);for(const t of["nw","ne","sw","se"]){const n=document.createElement("div");n.className=`notectl-image__resize-handle notectl-image__resize-handle--${t}`,n.setAttribute("aria-hidden","true"),_(n,t,e,r),m.appendChild(n)}if(n){const t=function(t,e){const n=t.shrinkWidth??null,i=t.growWidth??null;return n&&i?e.keyboardResizeHint(v(n),v(i)):""}(n,i);if(t){const e=document.createElement("div");e.className="notectl-image__keyboard-hint",e.setAttribute("aria-hidden","true"),e.textContent=t,m.appendChild(e)}}l.appendChild(m)}(g)},deselectNode(){s.classList.remove("notectl-image--selected"),w()},destroy(){w()}}}}var j=new d("image:upload"),$={growWidth:"Mod-Shift-ArrowRight",shrinkWidth:"Mod-Shift-ArrowLeft",growWidthLarge:"Mod-Shift-Alt-ArrowRight",shrinkWidthLarge:"Mod-Shift-Alt-ArrowLeft",resetSize:"Mod-Shift-0"},E={maxWidth:800,maxFileSize:10485760,acceptedTypes:["image/png","image/jpeg","image/gif","image/webp","image/svg+xml"],resizable:!0,resizeStep:10,resizeStepLarge:50},M=class{id="image";name="Image";priority=45;config;resolvedKeymap;uploadStates=/* @__PURE__ */new Map;blobUrls=/* @__PURE__ */new Set;context=null;locale;constructor(t){this.config={...E,...t},this.resolvedKeymap={...$,...t?.keymap}}async init(t){this.locale=await m(t,this.config.locale,w,y),t.registerStyleSheet('\n/* Image */\n.notectl-image {\n\tmargin: 8px 0;\n\tuser-select: none;\n\tline-height: 0;\n}\n\n.notectl-image--center {\n\ttext-align: center;\n}\n\n.notectl-image--start {\n\ttext-align: start;\n}\n\n.notectl-image--end {\n\ttext-align: end;\n}\n\n.notectl-image__container {\n\tdisplay: inline-block;\n\tposition: relative;\n\tline-height: 0;\n}\n\n.notectl-image__img {\n\tdisplay: block;\n\tmax-width: 100%;\n\tborder-radius: 4px;\n}\n\n.notectl-image--selected .notectl-image__container {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n\tborder-radius: 6px;\n}\n\n/* Alignment toolbar (appears on image selection) */\n.notectl-image__align-toolbar {\n\tdisplay: flex;\n\tgap: 2px;\n\tposition: absolute;\n\ttop: -36px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tpadding: 2px;\n\tbox-shadow: 0 2px 8px var(--notectl-shadow);\n\tz-index: 10;\n}\n\n.notectl-image__align-btn {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\theight: 28px;\n\tborder: none;\n\tbackground: transparent;\n\tborder-radius: 4px;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-image__align-btn:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-image__align-btn--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-image__align-btn svg {\n\twidth: 16px;\n\theight: 16px;\n\tfill: currentColor;\n}\n\n/* Upload overlay */\n.notectl-image__overlay {\n\tposition: absolute;\n\tinset: 0;\n\tdisplay: none;\n\talign-items: center;\n\tjustify-content: center;\n\tbackground: rgba(255, 255, 255, 0.8);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg-muted);\n}\n\n.notectl-image__overlay--uploading {\n\tdisplay: flex;\n}\n\n.notectl-image__overlay--error {\n\tdisplay: flex;\n\tbackground: var(--notectl-danger-muted);\n\tcolor: var(--notectl-danger);\n}\n\n/* Resize overlay + handles */\n.notectl-image__resize-overlay {\n\tposition: absolute;\n\tinset: 0;\n\tpointer-events: none;\n}\n\n.notectl-image__resize-handle {\n\tposition: absolute;\n\twidth: 10px;\n\theight: 10px;\n\tbackground: var(--notectl-surface-raised);\n\tborder: 2px solid var(--notectl-primary);\n\tborder-radius: 50%;\n\tpointer-events: all;\n\tz-index: 2;\n\ttransition: transform 0.1s, background 0.1s;\n}\n\n.notectl-image__resize-handle:hover {\n\tbackground: var(--notectl-primary);\n\ttransform: scale(1.3);\n}\n\n.notectl-image--resizing .notectl-image__resize-handle {\n\tbackground: var(--notectl-primary);\n}\n\n.notectl-image__resize-handle--nw {\n\ttop: -5px;\n\tinset-inline-start: -5px;\n\tcursor: nwse-resize;\n}\n\n.notectl-image__resize-handle--ne {\n\ttop: -5px;\n\tinset-inline-end: -5px;\n\tcursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--sw {\n\tbottom: -5px;\n\tinset-inline-start: -5px;\n\tcursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--se {\n\tbottom: -5px;\n\tinset-inline-end: -5px;\n\tcursor: nwse-resize;\n}\n\n/* RTL cursor overrides — flip diagonal cursors when in RTL context */\n[dir="rtl"] .notectl-image__resize-handle--nw {\n\tcursor: nesw-resize;\n}\n\n[dir="rtl"] .notectl-image__resize-handle--ne {\n\tcursor: nwse-resize;\n}\n\n[dir="rtl"] .notectl-image__resize-handle--sw {\n\tcursor: nwse-resize;\n}\n\n[dir="rtl"] .notectl-image__resize-handle--se {\n\tcursor: nesw-resize;\n}\n\n/* Size indicator tooltip */\n.notectl-image__size-indicator {\n\tposition: absolute;\n\tbottom: -28px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tpadding: 2px 8px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\tborder-radius: 4px;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\topacity: 0;\n\ttransition: opacity 0.15s;\n\tz-index: 3;\n}\n\n.notectl-image__size-indicator--visible {\n\topacity: 1;\n}\n\n/* Keyboard resize hint (shown on selection, hidden during drag) */\n.notectl-image__keyboard-hint {\n\tdisplay: none;\n\tposition: absolute;\n\tbottom: -28px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tpadding: 2px 8px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 3;\n}\n\n.notectl-image--selected .notectl-image__keyboard-hint {\n\tdisplay: block;\n}\n\n.notectl-image--resizing .notectl-image__keyboard-hint {\n\tdisplay: none;\n}\n\n/* Resizing feedback */\n.notectl-image--resizing .notectl-image__img {\n\topacity: 0.85;\n}\n'),t.registerStyleSheet("\n.notectl-image-popup {\n\tpadding: 8px;\n\tmin-width: 240px;\n}\n\n.notectl-image-popup__file-input {\n\tposition: absolute;\n\twidth: 0;\n\theight: 0;\n\toverflow: hidden;\n\topacity: 0;\n}\n\n.notectl-image-popup__upload-btn {\n\tdisplay: block;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\tcursor: pointer;\n\ttext-align: center;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-image-popup__separator {\n\tdisplay: flex;\n\talign-items: center;\n\tmargin: 8px 0;\n\tcolor: var(--notectl-fg-muted);\n\tfont-size: 12px;\n}\n\n.notectl-image-popup__separator-line {\n\tflex: 1;\n\theight: 1px;\n\tbackground: var(--notectl-border);\n}\n\n.notectl-image-popup__separator-text {\n\tpadding: 0 8px;\n}\n\n.notectl-image-popup__url-input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-overlay);\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-image-popup__insert-btn {\n\twidth: 100%;\n\tpadding: 8px 12px;\n\tmargin-top: 4px;\n\tcursor: pointer;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg);\n}\n"),this.context=t,this.registerNodeSpec(t),this.registerInlineImageNodeSpec(t),this.registerNodeView(t),function(t){t.registerCommand("insertImage",()=>x(t,{src:""})),t.registerCommand("removeImage",()=>function(t){const e=t.getState(),n=e.selection;if(!r(n))return!1;const i=e.getBlock(n.nodeId);if(!i||"image"!==i.type)return!1;const a=e.getNodePath(n.nodeId);if(!a||0===a.length)return!1;const s=c(e,o(n.nodeId,a));return!!s&&(t.dispatch(s),!0)}(t))}(t),this.registerResizeCommands(t),this.registerResizeKeymaps(t),this.registerFileHandler(t),this.registerToolbarItem(t)}destroy(){for(const t of this.blobUrls)URL.revokeObjectURL(t);this.blobUrls.clear(),this.uploadStates.clear(),this.context=null}onStateChange(t,e,n){if(!this.context)return;for(const o of this.uploadStates.keys())e.getBlock(o)||this.uploadStates.delete(o);const i=this.isImageSelected(t),r=this.isImageSelected(e);!i&&r&&this.announceImageSelection(e)}registerNodeSpec(e){const n=this.locale;e.registerNodeSpec({type:"image",group:"block",isVoid:!0,selectable:!0,attrs:{src:{default:""},alt:{default:""},title:{default:""},align:{default:"center"}},toDOM(t){const e=b("figure",t.id);e.className="notectl-image",e.setAttribute("data-void","true"),e.setAttribute("data-selectable","true");const i=document.createElement("div");i.className="notectl-image__container";const r=t.attrs?.alt??"",o=t.attrs?.width,a=t.attrs?.height,s=document.createElement("img");s.className="notectl-image__img",s.src=t.attrs?.src??"",s.alt=r;const l=t.attrs?.title??"";l&&(s.title=l),s.draggable=!1,void 0!==o&&p(s,"width",`${o}px`),void 0!==a&&p(s,"height",`${a}px`);const c={start:"notectl-image--start",center:"notectl-image--center",end:"notectl-image--end"}[t.attrs?.align??"center"];return c&&e.classList.add(c),e.setAttribute("aria-label",n.imageAria(r,o,a)),i.appendChild(s),e.appendChild(i),e},toHTML(e){const n=t(e.attrs?.src??""),i=t(e.attrs?.alt??""),r=e.attrs?.width,o=e.attrs?.height,a=(void 0!==r?` width="${r}"`:"")+(void 0!==o?` height="${o}"`:""),s=e.attrs?.title??"";return`<figure><img src="${n}" alt="${i}"${s?` title="${t(s)}"`:""}${a}></figure>`},parseHTML:[{tag:"figure",getAttrs(t){const e=t.querySelector("img");if(!e)return!1;const n={src:e.getAttribute("src")??"",alt:e.getAttribute("alt")??"",align:"center"},i=e.getAttribute("width"),r=e.getAttribute("height");i&&(n.width=Number.parseInt(i,10)),r&&(n.height=Number.parseInt(r,10));const o=e.getAttribute("title");o&&(n.title=o);const a=t.style?.textAlign??"";return"start"===a||"end"===a||"center"===a?n.align=a:"left"===a?n.align="start":"right"===a?n.align="end":t.classList.contains("notectl-align-start")||t.classList.contains("notectl-align-left")||t.classList.contains("notectl-image--start")||t.classList.contains("notectl-image--left")?n.align="start":t.classList.contains("notectl-align-end")||t.classList.contains("notectl-align-right")||t.classList.contains("notectl-image--end")||t.classList.contains("notectl-image--right")?n.align="end":t.classList.contains("notectl-align-center")&&(n.align="center"),n}},{tag:"img",getAttrs(t){const e={src:t.getAttribute("src")??"",alt:t.getAttribute("alt")??"",align:"center"},n=t.getAttribute("width"),i=t.getAttribute("height");n&&(e.width=Number.parseInt(n,10)),i&&(e.height=Number.parseInt(i,10));const r=t.getAttribute("title");return r&&(e.title=r),e}}],sanitize:{tags:["figure","img"],attrs:["src","alt","title","width","height","class","style"]}})}registerInlineImageNodeSpec(e){e.registerInlineNodeSpec({type:"image_inline",group:"inline",attrs:{src:{default:""},alt:{default:""},title:{default:""}},toDOM(t){const e=document.createElement("img");e.className="notectl-image-inline",e.setAttribute("contenteditable","false"),e.src=String(t.attrs.src??""),e.alt=String(t.attrs.alt??"");const n=String(t.attrs.title??"");return n&&(e.title=n),e.draggable=!1,e},toHTMLString(e){const n=t(String(e.attrs.src??"")),i=t(String(e.attrs.alt??"")),r=String(e.attrs.title??"");return`<img src="${n}" alt="${i}"${r?` title="${t(r)}"`:""}>`},parseHTML:[{tag:"img",getAttrs:t=>{const e={src:t.getAttribute("src")??"",alt:t.getAttribute("alt")??""},n=t.getAttribute("title");return n&&(e.title=n),e}}],sanitize:{tags:["img"],attrs:["src","alt","title"]}})}registerNodeView(t){t.registerNodeView("image",N(this.config,this.uploadStates,this.resolvedKeymap,this.locale))}registerResizeCommands(t){const e=this.config.resizeStep??10,n=this.config.resizeStepLarge??50,i=this.config.maxWidth;t.registerCommand("resizeImageGrow",()=>{const n=_(t,e,i);return n&&this.announceCurrentSize(t),n}),t.registerCommand("resizeImageShrink",()=>{const n=_(t,-e,i);return n&&this.announceCurrentSize(t),n}),t.registerCommand("resizeImageGrowLarge",()=>{const e=_(t,n,i);return e&&this.announceCurrentSize(t),e}),t.registerCommand("resizeImageShrinkLarge",()=>{const e=_(t,-n,i);return e&&this.announceCurrentSize(t),e}),t.registerCommand("resetImageSize",()=>{const e=function(t){const e=t.getState(),n=e.selection;if(!r(n))return!1;const i=e.getBlock(n.nodeId);if(!i||"image"!==i.type)return!1;const o=e.getNodePath(n.nodeId);if(!o)return!1;const a={...i.attrs??{}},s=Object.fromEntries(Object.entries(a).filter(([t])=>"width"!==t&&"height"!==t)),l=e.transaction("command").setNodeAttr(o,s).build();return t.dispatch(l),!0}(t);return e&&t.announce(this.locale.resetToNaturalSize),e})}registerResizeKeymaps(t){const e={};for(const[n,i]of Object.entries({growWidth:"resizeImageGrow",shrinkWidth:"resizeImageShrink",growWidthLarge:"resizeImageGrowLarge",shrinkWidthLarge:"resizeImageShrinkLarge",resetSize:"resetImageSize"})){const r=this.resolvedKeymap[n]??null;r&&(e[r]=()=>t.executeCommand(i))}Object.keys(e).length>0&&t.registerKeymap(e)}registerFileHandler(t){t.registerFileHandler("image/*",async(e,n)=>!!this.isAcceptedType(e.type)&&(this.handleFileInsert(t,e),!0))}handleFileInsert(t,e){if(e.size>this.config.maxFileSize)return;const n=URL.createObjectURL(e);if(this.blobUrls.add(n),!x(t,{src:n}))return URL.revokeObjectURL(n),void this.blobUrls.delete(n);const i=t.getState().selection;if(!r(i))return;const o=i.nodeId;this.uploadStates.set(o,"uploading"),t.getService(j)?this.uploadFile(t,e,o,n):this.uploadStates.set(o,"complete")}async uploadFile(t,e,n,i){const r=t.getService(j);if(r)try{const o=await r.upload(e);this.uploadStates.set(n,"complete");const a=t.getState(),s=a.getBlock(n);if(!s)return;const l=a.getNodePath(n);if(!l)return;const c={...s.attrs??{},src:o.url,...void 0!==o.width?{width:o.width}:{},...void 0!==o.height?{height:o.height}:{}},d=a.transaction("command").setNodeAttr(l,c).build();t.dispatch(d),URL.revokeObjectURL(i),this.blobUrls.delete(i)}catch{this.uploadStates.set(n,"error"),t.announce(this.locale.uploadFailed)}}registerToolbarItem(t){t.registerToolbarItem({id:"image",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>',label:this.locale.insertImage,tooltip:this.locale.insertImageTooltip,command:"insertImage",popupType:"custom",renderPopup:(t,e,n)=>{!function(t,e,n){t.classList.add("notectl-image-popup"),function(t,e,n){const i=document.createElement("input");i.type="file",i.accept=n.acceptedTypes.join(","),i.className="notectl-image-popup__file-input";const r=document.createElement("button");r.type="button",r.textContent=n.locale.uploadFromComputer,r.setAttribute("aria-label",n.locale.uploadAria),r.className="notectl-image-popup__upload-btn",r.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),r.addEventListener("click",()=>{i.click()}),i.addEventListener("change",()=>{const t=i.files?.[0];t&&(n.onFileInsert(e,t),n.onClose(),e.getContainer().focus())}),t.appendChild(i),t.appendChild(r)}(t,e,n),function(t,e){const n=document.createElement("div");n.className="notectl-image-popup__separator";const i=document.createElement("span");i.className="notectl-image-popup__separator-line";const r=document.createElement("span");r.textContent=e.separator,r.className="notectl-image-popup__separator-text";const o=document.createElement("span");o.className="notectl-image-popup__separator-line",n.appendChild(i),n.appendChild(r),n.appendChild(o),t.appendChild(n)}(t,n.locale),function(t,e,n){const i=document.createElement("input");i.type="url",i.placeholder=n.locale.urlPlaceholder,i.setAttribute("aria-label",n.locale.urlAria),i.className="notectl-image-popup__url-input";const r=document.createElement("button");r.type="button",r.textContent=n.locale.insertButton,r.setAttribute("aria-label",n.locale.insertAria),r.className="notectl-image-popup__insert-btn";const o=()=>{const t=i.value.trim();t&&(x(e,{src:t}),n.onClose(),e.getContainer().focus())};r.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),r.addEventListener("click",()=>{o()}),i.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),o())}),t.appendChild(i),t.appendChild(r),requestAnimationFrame(()=>i.focus())}(t,e,n)}(t,e,{acceptedTypes:this.config.acceptedTypes,locale:this.locale,onFileInsert:(t,e)=>this.handleFileInsert(t,e),onClose:n})}})}isAcceptedType(t){return this.config.acceptedTypes.some(e=>e===t||e.endsWith("/*")&&t.startsWith(e.slice(0,-1)))}isImageSelected(t){const e=t.selection;return!!r(e)&&"image"===t.getBlock(e.nodeId)?.type}announceImageSelection(t){if(!this.context)return;const e=t.selection;if(!r(e))return;const n=t.getBlock(e.nodeId);if(!n||"image"!==n.type)return;const i=n.attrs?.alt??"",o=n.attrs?.width,a=n.attrs?.height,s=[this.locale.imageSelected];i&&s.push(`${this.locale.altTextPrefix}${i}.`),void 0!==o&&void 0!==a&&s.push(this.locale.imageSizeAnnounce(o,a));const l=this.resolvedKeymap.shrinkWidth??null,c=this.resolvedKeymap.growWidth??null;l&&c&&s.push(this.locale.resizeHint(v(l),v(c))),this.context.announce(s.join(" "))}announceCurrentSize(t){const e=t.getState(),n=e.selection;if(!r(n))return;const i=e.getBlock(n.nodeId);if(!i||"image"!==i.type)return;const o=i.attrs?.width,a=i.attrs?.height;void 0!==o&&void 0!==a&&t.announce(this.locale.imageResized(o,a))}};export{y as a,w as i,$ as n,j as r,M as t};
2
+ //# sourceMappingURL=ImagePlugin-C_MuvfYo.mjs.map