@notectl/core 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{ColorGrid-Dneqb8if.mjs → ColorGrid--lBQ7jCK.mjs} +2 -2
- package/dist/chunks/{ColorGrid-Dneqb8if.mjs.map → ColorGrid--lBQ7jCK.mjs.map} +1 -1
- package/dist/chunks/{ColorPickerPopup-CiCLBbe9.mjs → ColorPickerPopup-TpIRlXc8.mjs} +8 -8
- package/dist/chunks/ColorPickerPopup-TpIRlXc8.mjs.map +1 -0
- package/dist/chunks/Document-Brtw2jL1.mjs.map +1 -1
- package/dist/chunks/MarkCommands-6RUJ4L3r.mjs.map +1 -1
- package/dist/chunks/NodeSpec-NZVvcCuH.mjs.map +1 -1
- package/dist/chunks/PopupPositioning-CgjgAKjp.mjs +34 -0
- package/dist/chunks/PopupPositioning-CgjgAKjp.mjs.map +1 -0
- package/dist/chunks/{StyleRuntime-ChRjVQwL.mjs → StyleRuntime-CP4NCwKT.mjs} +49 -53
- package/dist/chunks/StyleRuntime-CP4NCwKT.mjs.map +1 -0
- package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -1
- package/dist/chunks/{index-D515iymW.mjs → index--7pBhSF4.mjs} +5 -5
- package/dist/chunks/index--7pBhSF4.mjs.map +1 -0
- package/dist/chunks/index-BXCkjDax.mjs +161 -0
- package/dist/chunks/index-BXCkjDax.mjs.map +1 -0
- package/dist/chunks/{ToolbarPlugin-DpLVJ71w.mjs → index-BcDRT4K2.mjs} +81 -93
- package/dist/chunks/index-BcDRT4K2.mjs.map +1 -0
- package/dist/chunks/{index--n1RGpq-.mjs → index-BjFBWBOC.mjs} +46 -49
- package/dist/chunks/index-BjFBWBOC.mjs.map +1 -0
- package/dist/chunks/{index-BqNUfq-y.mjs → index-CCyqQ0Dz.mjs} +2 -2
- package/dist/chunks/{index-BqNUfq-y.mjs.map → index-CCyqQ0Dz.mjs.map} +1 -1
- package/dist/chunks/{index-DyzigvbZ.mjs → index-DSAuGP4n.mjs} +50 -50
- package/dist/chunks/index-DSAuGP4n.mjs.map +1 -0
- package/dist/chunks/{index-BhDXjueu.mjs → index-DtRfqsq5.mjs} +14 -14
- package/dist/chunks/{index-BhDXjueu.mjs.map → index-DtRfqsq5.mjs.map} +1 -1
- package/dist/chunks/{index-Dk49P9N4.mjs → index-Dum8yE_t.mjs} +11 -11
- package/dist/chunks/{index-Dk49P9N4.mjs.map → index-Dum8yE_t.mjs.map} +1 -1
- package/dist/chunks/{index-CluzpB2b.mjs → index-DxbQirny.mjs} +7 -7
- package/dist/chunks/{index-CluzpB2b.mjs.map → index-DxbQirny.mjs.map} +1 -1
- package/dist/chunks/{index-CWltg1wK.mjs → index-WpbK_s_H.mjs} +20 -25
- package/dist/chunks/index-WpbK_s_H.mjs.map +1 -0
- package/dist/chunks/{index-D3NlpmT1.mjs → index-WrqH1wG8.mjs} +3 -3
- package/dist/chunks/{index-D3NlpmT1.mjs.map → index-WrqH1wG8.mjs.map} +1 -1
- package/dist/chunks/{index-BvqkuEY1.mjs → index-fx3KIap3.mjs} +3 -3
- package/dist/chunks/{index-BvqkuEY1.mjs.map → index-fx3KIap3.mjs.map} +1 -1
- package/dist/chunks/{index-BAke7kNL.mjs → index-oOJo-ywB.mjs} +41 -41
- package/dist/chunks/{index-BAke7kNL.mjs.map → index-oOJo-ywB.mjs.map} +1 -1
- package/dist/chunks/{index-ABlTDvEX.mjs → index-toj88jtL.mjs} +2 -2
- package/dist/chunks/{index-ABlTDvEX.mjs.map → index-toj88jtL.mjs.map} +1 -1
- package/dist/commands/MarkCommands.d.ts +3 -3
- package/dist/commands/MarkCommands.d.ts.map +1 -1
- package/dist/editor/CSSClassCollector.d.ts +36 -0
- package/dist/editor/CSSClassCollector.d.ts.map +1 -0
- package/dist/editor/ContentHTMLTypes.d.ts +29 -0
- package/dist/editor/ContentHTMLTypes.d.ts.map +1 -0
- package/dist/editor/ContentStyleInjector.d.ts +69 -0
- package/dist/editor/ContentStyleInjector.d.ts.map +1 -0
- package/dist/editor/DocumentParser.d.ts +9 -1
- package/dist/editor/DocumentParser.d.ts.map +1 -1
- package/dist/editor/DocumentSerializer.d.ts +6 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/MarkSerializer.d.ts +7 -0
- package/dist/editor/MarkSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +8 -11
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/styles/font-select.d.ts +1 -1
- package/dist/editor/styles/font-select.d.ts.map +1 -1
- package/dist/editor/styles/font-size-select.d.ts +1 -1
- package/dist/editor/styles/font-size-select.d.ts.map +1 -1
- package/dist/editor/styles/heading-select.d.ts +1 -1
- package/dist/editor/styles/heading-select.d.ts.map +1 -1
- package/dist/editor/styles/toolbar.d.ts +1 -1
- package/dist/editor/styles/toolbar.d.ts.map +1 -1
- package/dist/index.d.ts +10 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/model/Document.d.ts +0 -4
- package/dist/model/Document.d.ts.map +1 -1
- package/dist/model/NodeSpec.d.ts +19 -2
- package/dist/model/NodeSpec.d.ts.map +1 -1
- package/dist/notectl-core.mjs +460 -336
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +676 -587
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +0 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/index.d.ts +2 -1
- package/dist/plugins/code-block/index.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font/FontPlugin.d.ts +0 -1
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePlugin.d.ts +0 -2
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts +3 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/shared/ColorPickerPopup.d.ts +2 -1
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
- package/dist/plugins/shared/PopupManager.d.ts +12 -2
- package/dist/plugins/shared/PopupManager.d.ts.map +1 -1
- package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarItem.d.ts +3 -2
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts +0 -3
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +2 -2
- package/dist/presets/PresetTypes.d.ts +1 -1
- package/dist/presets/PresetTypes.d.ts.map +1 -1
- package/dist/style/StyleRuntime.d.ts +3 -7
- package/dist/style/StyleRuntime.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/ColorPickerPopup-CiCLBbe9.mjs.map +0 -1
- package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs +0 -32
- package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs.map +0 -1
- package/dist/chunks/StyleRuntime-ChRjVQwL.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-DpLVJ71w.mjs.map +0 -1
- package/dist/chunks/index--n1RGpq-.mjs.map +0 -1
- package/dist/chunks/index-4or5UzNO.mjs +0 -168
- package/dist/chunks/index-4or5UzNO.mjs.map +0 -1
- package/dist/chunks/index-CWltg1wK.mjs.map +0 -1
- package/dist/chunks/index-D515iymW.mjs.map +0 -1
- package/dist/chunks/index-DyzigvbZ.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-ABlTDvEX.mjs","sources":["../../src/plugins/alignment/AlignmentLocale.ts","../../src/plugins/alignment/AlignmentPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the AlignmentPlugin. */\n\nexport interface AlignmentLocale {\n\treadonly alignLeft: string;\n\treadonly alignCenter: string;\n\treadonly alignRight: string;\n\treadonly justify: string;\n\treadonly toolbarLabel: string;\n\treadonly toolbarTooltip: string;\n}\n\n// --- Default English Locale ---\n\nexport const ALIGNMENT_LOCALE_EN: AlignmentLocale = {\n\talignLeft: 'Align Left',\n\talignCenter: 'Align Center',\n\talignRight: 'Align Right',\n\tjustify: 'Justify',\n\ttoolbarLabel: 'Alignment',\n\ttoolbarTooltip: 'Alignment',\n};\n\n// --- German Locale ---\n\nexport const ALIGNMENT_LOCALE_DE: AlignmentLocale = {\n\talignLeft: 'Linksbündig',\n\talignCenter: 'Zentriert',\n\talignRight: 'Rechtsbündig',\n\tjustify: 'Blocksatz',\n\ttoolbarLabel: 'Ausrichtung',\n\ttoolbarTooltip: 'Ausrichtung',\n};\n\n// --- Spanish Locale ---\n\nexport const ALIGNMENT_LOCALE_ES: AlignmentLocale = {\n\talignLeft: 'Alinear a la izquierda',\n\talignCenter: 'Centrar',\n\talignRight: 'Alinear a la derecha',\n\tjustify: 'Justificar',\n\ttoolbarLabel: 'Alineación',\n\ttoolbarTooltip: 'Alineación',\n};\n\n// --- French Locale ---\n\nexport const ALIGNMENT_LOCALE_FR: AlignmentLocale = {\n\talignLeft: 'Aligner à gauche',\n\talignCenter: 'Centrer',\n\talignRight: 'Aligner à droite',\n\tjustify: 'Justifier',\n\ttoolbarLabel: 'Alignement',\n\ttoolbarTooltip: 'Alignement',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const ALIGNMENT_LOCALE_ZH: AlignmentLocale = {\n\talignLeft: '左对齐',\n\talignCenter: '居中',\n\talignRight: '右对齐',\n\tjustify: '两端对齐',\n\ttoolbarLabel: '对齐',\n\ttoolbarTooltip: '对齐',\n};\n\n// --- Russian Locale ---\n\nexport const ALIGNMENT_LOCALE_RU: AlignmentLocale = {\n\talignLeft: 'По левому краю',\n\talignCenter: 'По центру',\n\talignRight: 'По правому краю',\n\tjustify: 'По ширине',\n\ttoolbarLabel: 'Выравнивание',\n\ttoolbarTooltip: 'Выравнивание',\n};\n\n// --- Arabic Locale ---\n\nexport const ALIGNMENT_LOCALE_AR: AlignmentLocale = {\n\talignLeft: 'محاذاة لليسار',\n\talignCenter: 'توسيط',\n\talignRight: 'محاذاة لليمين',\n\tjustify: 'ضبط',\n\ttoolbarLabel: 'المحاذاة',\n\ttoolbarTooltip: 'المحاذاة',\n};\n\n// --- Hindi Locale ---\n\nexport const ALIGNMENT_LOCALE_HI: AlignmentLocale = {\n\talignLeft: 'बाएँ संरेखित करें',\n\talignCenter: 'केंद्र में',\n\talignRight: 'दाएँ संरेखित करें',\n\tjustify: 'समायोजित करें',\n\ttoolbarLabel: 'संरेखण',\n\ttoolbarTooltip: 'संरेखण',\n};\n\n// --- Locale Map ---\n\nexport const ALIGNMENT_LOCALES: Record<string, AlignmentLocale> = {\n\ten: ALIGNMENT_LOCALE_EN,\n\tde: ALIGNMENT_LOCALE_DE,\n\tes: ALIGNMENT_LOCALE_ES,\n\tfr: ALIGNMENT_LOCALE_FR,\n\tzh: ALIGNMENT_LOCALE_ZH,\n\tru: ALIGNMENT_LOCALE_RU,\n\tar: ALIGNMENT_LOCALE_AR,\n\thi: ALIGNMENT_LOCALE_HI,\n};\n","/**\n * AlignmentPlugin: adds left/center/right/justify alignment as a block\n * attribute on paragraphs, headings, images, and other alignable types.\n * Patches their NodeSpecs to render the `align` attribute via inline\n * `text-align` style and provides toggle commands, keyboard shortcuts,\n * and a toolbar dropdown. Handles both TextSelection and NodeSelection.\n */\n\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { findNodePath } from '../../model/NodeResolver.js';\nimport { isNodeSelection, isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { ALIGNMENT_LOCALES, type AlignmentLocale } from './AlignmentLocale.js';\n\n// --- Public Types ---\n\nexport type BlockAlignment = 'left' | 'center' | 'right' | 'justify';\n\nexport interface AlignmentConfig {\n\t/** Which alignments to expose. Defaults to all four. */\n\treadonly alignments: readonly BlockAlignment[];\n\t/** Block types that support alignment. Defaults to paragraph + heading + title + subtitle + table_cell + image. */\n\treadonly alignableTypes: readonly string[];\n\t/** Per-type default alignment (e.g. `{ image: 'center' }`). Falls back to `'left'`. */\n\treadonly defaults: Readonly<Record<string, BlockAlignment>>;\n\t/** When true, a separator is rendered after the toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: AlignmentLocale;\n}\n\n// --- Constants ---\n\nconst DEFAULT_CONFIG: AlignmentConfig = {\n\talignments: ['left', 'center', 'right', 'justify'],\n\talignableTypes: ['paragraph', 'heading', 'title', 'subtitle', 'table_cell', 'image'],\n\tdefaults: { image: 'center' },\n};\n\nexport const ALIGNMENT_ICONS: Readonly<Record<BlockAlignment, string>> = {\n\tleft: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z\"/></svg>',\n\tcenter:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z\"/></svg>',\n\tright:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z\"/></svg>',\n\tjustify:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zM3 3v2h18V3H3z\"/></svg>',\n};\n\n// --- Plugin ---\n\nexport class AlignmentPlugin implements Plugin {\n\treadonly id = 'alignment';\n\treadonly name = 'Alignment';\n\treadonly priority = 90;\n\n\tprivate readonly config: AlignmentConfig;\n\tprivate locale!: AlignmentLocale;\n\tprivate alignableTypes!: ReadonlySet<string>;\n\n\tconstructor(config?: Partial<AlignmentConfig>) {\n\t\tthis.config = {\n\t\t\t...DEFAULT_CONFIG,\n\t\t\t...config,\n\t\t\tdefaults: { ...DEFAULT_CONFIG.defaults, ...config?.defaults },\n\t\t};\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(ALIGNMENT_LOCALES, context, this.config.locale);\n\n\t\tthis.alignableTypes = new Set(this.config.alignableTypes);\n\t\tthis.patchNodeSpecs(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.registerMiddleware(context);\n\t}\n\n\t// --- NodeSpec Patching ---\n\n\t/**\n\t * Patches existing NodeSpecs for alignable block types to support the\n\t * `align` attribute and render it as an inline style. Skips types\n\t * that already define an `align` attribute in their spec.\n\t */\n\tprivate patchNodeSpecs(context: PluginContext): void {\n\t\tconst registry = context.getSchemaRegistry();\n\n\t\tfor (const type of this.config.alignableTypes) {\n\t\t\tconst spec = registry.getNodeSpec(type);\n\t\t\tif (!spec) continue;\n\n\t\t\t// Skip types that already declare an `align` attr (e.g. image)\n\t\t\tif (spec.attrs?.align) continue;\n\n\t\t\tconst originalToDOM = spec.toDOM;\n\t\t\tconst defaultAlign: BlockAlignment = this.config.defaults[type] ?? 'left';\n\n\t\t\tregistry.removeNodeSpec(type);\n\t\t\tregistry.registerNodeSpec({\n\t\t\t\t...spec,\n\t\t\t\tattrs: {\n\t\t\t\t\t...spec.attrs,\n\t\t\t\t\talign: { default: defaultAlign },\n\t\t\t\t},\n\t\t\t\ttoDOM(node) {\n\t\t\t\t\tconst el = originalToDOM.call(spec, node);\n\t\t\t\t\tapplyAlignment(el, node);\n\t\t\t\t\treturn el;\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tfor (const alignment of this.config.alignments) {\n\t\t\tcontext.registerCommand(`align${capitalize(alignment)}`, () => {\n\t\t\t\treturn this.setAlignment(context, alignment);\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tconst bindings: Record<string, () => boolean> = {};\n\n\t\tif (this.config.alignments.includes('left')) {\n\t\t\tbindings['Mod-Shift-L'] = () => context.executeCommand('alignLeft');\n\t\t}\n\t\tif (this.config.alignments.includes('center')) {\n\t\t\tbindings['Mod-Shift-E'] = () => context.executeCommand('alignCenter');\n\t\t}\n\t\tif (this.config.alignments.includes('right')) {\n\t\t\tbindings['Mod-Shift-R'] = () => context.executeCommand('alignRight');\n\t\t}\n\t\tif (this.config.alignments.includes('justify')) {\n\t\t\tbindings['Mod-Shift-J'] = () => context.executeCommand('alignJustify');\n\t\t}\n\n\t\tif (Object.keys(bindings).length > 0) {\n\t\t\tcontext.registerKeymap(bindings);\n\t\t}\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst dropdownItems = this.config.alignments.map((alignment) => ({\n\t\t\tlabel: this.getAlignmentLabel(alignment),\n\t\t\tcommand: `align${capitalize(alignment)}`,\n\t\t\ticon: ALIGNMENT_ICONS[alignment],\n\t\t}));\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'alignment',\n\t\t\tgroup: 'block',\n\t\t\ticon: ALIGNMENT_ICONS.left,\n\t\t\tlabel: this.locale.toolbarLabel,\n\t\t\ttooltip: this.locale.toolbarTooltip,\n\t\t\tcommand: 'alignLeft',\n\t\t\tpriority: 60,\n\t\t\tpopupType: 'dropdown',\n\t\t\tpopupConfig: { items: dropdownItems },\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: (state) => this.isNonDefaultAlignment(state),\n\t\t\tisEnabled: (state) => this.isAlignable(state),\n\t\t});\n\t}\n\n\tprivate getAlignmentLabel(alignment: BlockAlignment): string {\n\t\tconst labels: Record<BlockAlignment, string> = {\n\t\t\tleft: this.locale.alignLeft,\n\t\t\tcenter: this.locale.alignCenter,\n\t\t\tright: this.locale.alignRight,\n\t\t\tjustify: this.locale.justify,\n\t\t};\n\t\treturn labels[alignment];\n\t}\n\n\t// --- Middleware ---\n\n\t/**\n\t * Preserves the `align` attribute when other plugins change the block\n\t * type (e.g. paragraph → heading) via `setBlockType`, which replaces attrs.\n\t */\n\tprivate registerMiddleware(context: PluginContext): void {\n\t\tcontext.registerMiddleware(\n\t\t\t(tr, _state, next) => {\n\t\t\t\tlet patched = false;\n\n\t\t\t\tconst patchedSteps = tr.steps.map((step) => {\n\t\t\t\t\tif (step.type !== 'setBlockType') return step;\n\t\t\t\t\tif (!this.alignableTypes.has(step.nodeType)) return step;\n\n\t\t\t\t\tconst prevAlign = step.previousAttrs?.align;\n\t\t\t\t\tif (!prevAlign || prevAlign === 'left') return step;\n\n\t\t\t\t\t// Carry forward align into new attrs\n\t\t\t\t\tpatched = true;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...step,\n\t\t\t\t\t\tattrs: { ...step.attrs, align: prevAlign },\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tnext(patched ? { ...tr, steps: patchedSteps } : tr);\n\t\t\t},\n\t\t\t{ name: 'alignment:preserve-align' },\n\t\t);\n\t}\n\n\t// --- Alignment Logic ---\n\n\t/**\n\t * Gets the selected block, handling both TextSelection and NodeSelection.\n\t */\n\tprivate getSelectedBlock(state: EditorState): BlockNode | undefined {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) {\n\t\t\treturn state.getBlock(sel.nodeId);\n\t\t}\n\t\tif (isTextSelection(sel)) {\n\t\t\treturn state.getBlock(sel.anchor.blockId);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Gets the block ID of the selected block, handling both selection types.\n\t */\n\tprivate getSelectedBlockId(state: EditorState): BlockId | undefined {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return sel.nodeId;\n\t\tif (isTextSelection(sel)) return sel.anchor.blockId;\n\t\treturn undefined;\n\t}\n\n\tprivate setAlignment(context: PluginContext, alignment: BlockAlignment): boolean {\n\t\tconst state = context.getState();\n\t\tconst block = this.getSelectedBlock(state);\n\t\tif (!block || !this.alignableTypes.has(block.type)) return false;\n\n\t\tconst blockId = this.getSelectedBlockId(state);\n\t\tif (!blockId) return false;\n\n\t\tconst path = findNodePath(state.doc, blockId);\n\t\tif (!path) return false;\n\n\t\tconst newAttrs = { ...block.attrs, align: alignment };\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setNodeAttr(path as BlockId[], newAttrs)\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tprivate isNonDefaultAlignment(state: EditorState): boolean {\n\t\tconst block = this.getSelectedBlock(state);\n\t\tif (!block || !this.alignableTypes.has(block.type)) return false;\n\t\tconst align = block.attrs?.align;\n\t\tconst defaultAlign: BlockAlignment = this.config.defaults[block.type] ?? 'left';\n\t\treturn align != null && align !== defaultAlign;\n\t}\n\n\tprivate isAlignable(state: EditorState): boolean {\n\t\tconst block = this.getSelectedBlock(state);\n\t\treturn block != null && this.alignableTypes.has(block.type);\n\t}\n}\n\n// --- Helpers ---\n\nfunction applyAlignment(el: HTMLElement, node: BlockNode): void {\n\tconst align = node.attrs?.align;\n\tif (typeof align === 'string' && align !== 'left') {\n\t\tsetStyleProperty(el, 'textAlign', align);\n\t}\n}\n\nfunction capitalize(s: string): string {\n\treturn s.charAt(0).toUpperCase() + s.slice(1);\n}\n"],"names":["ALIGNMENT_LOCALE_EN","alignLeft","alignCenter","alignRight","justify","toolbarLabel","toolbarTooltip","ALIGNMENT_LOCALE_DE","ALIGNMENT_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","alignments","alignableTypes","defaults","image","ALIGNMENT_ICONS","left","center","right","AlignmentPlugin","id","name","priority","config","locale","this","context","resolvePluginLocale","Set","patchNodeSpecs","registerCommands","registerKeymaps","registerToolbarItem","registerMiddleware","registry","getSchemaRegistry","type","spec","getNodeSpec","attrs","align","originalToDOM","toDOM","defaultAlign","removeNodeSpec","registerNodeSpec","default","node","el","call","applyAlignment","alignment","registerCommand","capitalize","setAlignment","bindings","includes","executeCommand","Object","keys","length","registerKeymap","dropdownItems","map","label","getAlignmentLabel","command","icon","group","tooltip","popupType","popupConfig","items","separatorAfter","isActive","state","isNonDefaultAlignment","isEnabled","isAlignable","tr","_state","next","patched","patchedSteps","steps","step","has","nodeType","prevAlign","previousAttrs","sel","selection","isNodeSelection","getBlock","nodeId","isTextSelection","anchor","blockId","getState","block","getSelectedBlock","getSelectedBlockId","path","findNodePath","doc","newAttrs","transaction","setNodeAttr","setSelection","build","dispatch","setStyleProperty","s","charAt","toUpperCase","slice"],"mappings":";;;;AAaO,MAAMA,IAAuC,EACnDC,WAAW,cACXC,aAAa,gBACbC,YAAY,eACZC,SAAS,WACTC,cAAc,aACdC,gBAAgB,eAKJC,IAAuC,EACnD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YAAY,WACZC,YAAYL,IAAmBG,IAC/BG,aAAajC,GAAMgB,WACnBkB,MAAAA;AAGF,WADAnF,GAAQoF,SAAS/B,EAAAA,GAAAA;AAAAA,EAElB;AAAA,EAEQ,sBAAsBJ,IAAAA;AAC7B,UAAMwB,KAAQ1E,KAAK2E,iBAAiBzB,EAAAA;AACpC,QAAA,CAAKwB,MAAAA,CAAU1E,KAAKb,eAAe0E,IAAIa,GAAM/D,MAAO,QAAA;AACpD,UAAMI,KAAQ2D,GAAM5D,OAAOC,OACrBG,KAA+BlB,KAAKF,OAAOV,SAASsF,GAAM/D,IAAAA,KAAS;AACzE,WAAgB,QAATI,MAAiBA,OAAUG;AAAAA,EACnC;AAAA,EAEQ,YAAYgC,IAAAA;AACnB,UAAMwB,KAAQ1E,KAAK2E,iBAAiBzB,EAAAA;AACpC,WAAgB,QAATwB,MAAiB1E,KAAKb,eAAe0E,IAAIa,GAAM/D;EACvD;AAAA;AAKD,SAASc,EAAeF,IAAiBD;AACxC,QAAMP,KAAQO,GAAKR,OAAOC;AACL,qBAAVA,MAAgC,WAAVA,MAChCuE,EAAiB/D,IAAI,aAAaR,EAAAA;AAEpC;AAEA,SAASa,EAAW2D;AACnB,SAAOA,GAAEC,OAAO,CAAA,EAAGC,YAAAA,IAAgBF,GAAEG,MAAM,CAAA;AAC5C;"}
|
|
1
|
+
{"version":3,"file":"index-toj88jtL.mjs","sources":["../../src/plugins/alignment/AlignmentLocale.ts","../../src/plugins/alignment/AlignmentPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the AlignmentPlugin. */\n\nexport interface AlignmentLocale {\n\treadonly alignLeft: string;\n\treadonly alignCenter: string;\n\treadonly alignRight: string;\n\treadonly justify: string;\n\treadonly toolbarLabel: string;\n\treadonly toolbarTooltip: string;\n}\n\n// --- Default English Locale ---\n\nexport const ALIGNMENT_LOCALE_EN: AlignmentLocale = {\n\talignLeft: 'Align Left',\n\talignCenter: 'Align Center',\n\talignRight: 'Align Right',\n\tjustify: 'Justify',\n\ttoolbarLabel: 'Alignment',\n\ttoolbarTooltip: 'Alignment',\n};\n\n// --- German Locale ---\n\nexport const ALIGNMENT_LOCALE_DE: AlignmentLocale = {\n\talignLeft: 'Linksbündig',\n\talignCenter: 'Zentriert',\n\talignRight: 'Rechtsbündig',\n\tjustify: 'Blocksatz',\n\ttoolbarLabel: 'Ausrichtung',\n\ttoolbarTooltip: 'Ausrichtung',\n};\n\n// --- Spanish Locale ---\n\nexport const ALIGNMENT_LOCALE_ES: AlignmentLocale = {\n\talignLeft: 'Alinear a la izquierda',\n\talignCenter: 'Centrar',\n\talignRight: 'Alinear a la derecha',\n\tjustify: 'Justificar',\n\ttoolbarLabel: 'Alineación',\n\ttoolbarTooltip: 'Alineación',\n};\n\n// --- French Locale ---\n\nexport const ALIGNMENT_LOCALE_FR: AlignmentLocale = {\n\talignLeft: 'Aligner à gauche',\n\talignCenter: 'Centrer',\n\talignRight: 'Aligner à droite',\n\tjustify: 'Justifier',\n\ttoolbarLabel: 'Alignement',\n\ttoolbarTooltip: 'Alignement',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const ALIGNMENT_LOCALE_ZH: AlignmentLocale = {\n\talignLeft: '左对齐',\n\talignCenter: '居中',\n\talignRight: '右对齐',\n\tjustify: '两端对齐',\n\ttoolbarLabel: '对齐',\n\ttoolbarTooltip: '对齐',\n};\n\n// --- Russian Locale ---\n\nexport const ALIGNMENT_LOCALE_RU: AlignmentLocale = {\n\talignLeft: 'По левому краю',\n\talignCenter: 'По центру',\n\talignRight: 'По правому краю',\n\tjustify: 'По ширине',\n\ttoolbarLabel: 'Выравнивание',\n\ttoolbarTooltip: 'Выравнивание',\n};\n\n// --- Arabic Locale ---\n\nexport const ALIGNMENT_LOCALE_AR: AlignmentLocale = {\n\talignLeft: 'محاذاة لليسار',\n\talignCenter: 'توسيط',\n\talignRight: 'محاذاة لليمين',\n\tjustify: 'ضبط',\n\ttoolbarLabel: 'المحاذاة',\n\ttoolbarTooltip: 'المحاذاة',\n};\n\n// --- Hindi Locale ---\n\nexport const ALIGNMENT_LOCALE_HI: AlignmentLocale = {\n\talignLeft: 'बाएँ संरेखित करें',\n\talignCenter: 'केंद्र में',\n\talignRight: 'दाएँ संरेखित करें',\n\tjustify: 'समायोजित करें',\n\ttoolbarLabel: 'संरेखण',\n\ttoolbarTooltip: 'संरेखण',\n};\n\n// --- Locale Map ---\n\nexport const ALIGNMENT_LOCALES: Record<string, AlignmentLocale> = {\n\ten: ALIGNMENT_LOCALE_EN,\n\tde: ALIGNMENT_LOCALE_DE,\n\tes: ALIGNMENT_LOCALE_ES,\n\tfr: ALIGNMENT_LOCALE_FR,\n\tzh: ALIGNMENT_LOCALE_ZH,\n\tru: ALIGNMENT_LOCALE_RU,\n\tar: ALIGNMENT_LOCALE_AR,\n\thi: ALIGNMENT_LOCALE_HI,\n};\n","/**\n * AlignmentPlugin: adds left/center/right/justify alignment as a block\n * attribute on paragraphs, headings, images, and other alignable types.\n * Patches their NodeSpecs to render the `align` attribute via inline\n * `text-align` style and provides toggle commands, keyboard shortcuts,\n * and a toolbar dropdown. Handles both TextSelection and NodeSelection.\n */\n\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { findNodePath } from '../../model/NodeResolver.js';\nimport { isNodeSelection, isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { ALIGNMENT_LOCALES, type AlignmentLocale } from './AlignmentLocale.js';\n\n// --- Public Types ---\n\nexport type BlockAlignment = 'left' | 'center' | 'right' | 'justify';\n\nexport interface AlignmentConfig {\n\t/** Which alignments to expose. Defaults to all four. */\n\treadonly alignments: readonly BlockAlignment[];\n\t/** Block types that support alignment. Defaults to paragraph + heading + title + subtitle + table_cell + image. */\n\treadonly alignableTypes: readonly string[];\n\t/** Per-type default alignment (e.g. `{ image: 'center' }`). Falls back to `'left'`. */\n\treadonly defaults: Readonly<Record<string, BlockAlignment>>;\n\t/** When true, a separator is rendered after the toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: AlignmentLocale;\n}\n\n// --- Constants ---\n\nconst DEFAULT_CONFIG: AlignmentConfig = {\n\talignments: ['left', 'center', 'right', 'justify'],\n\talignableTypes: ['paragraph', 'heading', 'title', 'subtitle', 'table_cell', 'image'],\n\tdefaults: { image: 'center' },\n};\n\nexport const ALIGNMENT_ICONS: Readonly<Record<BlockAlignment, string>> = {\n\tleft: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z\"/></svg>',\n\tcenter:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z\"/></svg>',\n\tright:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z\"/></svg>',\n\tjustify:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zM3 3v2h18V3H3z\"/></svg>',\n};\n\n// --- Plugin ---\n\nexport class AlignmentPlugin implements Plugin {\n\treadonly id = 'alignment';\n\treadonly name = 'Alignment';\n\treadonly priority = 90;\n\n\tprivate readonly config: AlignmentConfig;\n\tprivate locale!: AlignmentLocale;\n\tprivate alignableTypes!: ReadonlySet<string>;\n\n\tconstructor(config?: Partial<AlignmentConfig>) {\n\t\tthis.config = {\n\t\t\t...DEFAULT_CONFIG,\n\t\t\t...config,\n\t\t\tdefaults: { ...DEFAULT_CONFIG.defaults, ...config?.defaults },\n\t\t};\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(ALIGNMENT_LOCALES, context, this.config.locale);\n\n\t\tthis.alignableTypes = new Set(this.config.alignableTypes);\n\t\tthis.patchNodeSpecs(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.registerMiddleware(context);\n\t}\n\n\t// --- NodeSpec Patching ---\n\n\t/**\n\t * Patches existing NodeSpecs for alignable block types to support the\n\t * `align` attribute and render it as an inline style. Skips types\n\t * that already define an `align` attribute in their spec.\n\t */\n\tprivate patchNodeSpecs(context: PluginContext): void {\n\t\tconst registry = context.getSchemaRegistry();\n\n\t\tfor (const type of this.config.alignableTypes) {\n\t\t\tconst spec = registry.getNodeSpec(type);\n\t\t\tif (!spec) continue;\n\n\t\t\t// Skip types that already declare an `align` attr (e.g. image)\n\t\t\tif (spec.attrs?.align) continue;\n\n\t\t\tconst originalToDOM = spec.toDOM;\n\t\t\tconst defaultAlign: BlockAlignment = this.config.defaults[type] ?? 'left';\n\n\t\t\tregistry.removeNodeSpec(type);\n\t\t\tregistry.registerNodeSpec({\n\t\t\t\t...spec,\n\t\t\t\tattrs: {\n\t\t\t\t\t...spec.attrs,\n\t\t\t\t\talign: { default: defaultAlign },\n\t\t\t\t},\n\t\t\t\ttoDOM(node) {\n\t\t\t\t\tconst el = originalToDOM.call(spec, node);\n\t\t\t\t\tapplyAlignment(el, node);\n\t\t\t\t\treturn el;\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tfor (const alignment of this.config.alignments) {\n\t\t\tcontext.registerCommand(`align${capitalize(alignment)}`, () => {\n\t\t\t\treturn this.setAlignment(context, alignment);\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tconst bindings: Record<string, () => boolean> = {};\n\n\t\tif (this.config.alignments.includes('left')) {\n\t\t\tbindings['Mod-Shift-L'] = () => context.executeCommand('alignLeft');\n\t\t}\n\t\tif (this.config.alignments.includes('center')) {\n\t\t\tbindings['Mod-Shift-E'] = () => context.executeCommand('alignCenter');\n\t\t}\n\t\tif (this.config.alignments.includes('right')) {\n\t\t\tbindings['Mod-Shift-R'] = () => context.executeCommand('alignRight');\n\t\t}\n\t\tif (this.config.alignments.includes('justify')) {\n\t\t\tbindings['Mod-Shift-J'] = () => context.executeCommand('alignJustify');\n\t\t}\n\n\t\tif (Object.keys(bindings).length > 0) {\n\t\t\tcontext.registerKeymap(bindings);\n\t\t}\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst dropdownItems = this.config.alignments.map((alignment) => ({\n\t\t\tlabel: this.getAlignmentLabel(alignment),\n\t\t\tcommand: `align${capitalize(alignment)}`,\n\t\t\ticon: ALIGNMENT_ICONS[alignment],\n\t\t}));\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'alignment',\n\t\t\tgroup: 'block',\n\t\t\ticon: ALIGNMENT_ICONS.left,\n\t\t\tlabel: this.locale.toolbarLabel,\n\t\t\ttooltip: this.locale.toolbarTooltip,\n\t\t\tcommand: 'alignLeft',\n\t\t\tpriority: 60,\n\t\t\tpopupType: 'dropdown',\n\t\t\tpopupConfig: { items: dropdownItems },\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: (state) => this.isNonDefaultAlignment(state),\n\t\t\tisEnabled: (state) => this.isAlignable(state),\n\t\t});\n\t}\n\n\tprivate getAlignmentLabel(alignment: BlockAlignment): string {\n\t\tconst labels: Record<BlockAlignment, string> = {\n\t\t\tleft: this.locale.alignLeft,\n\t\t\tcenter: this.locale.alignCenter,\n\t\t\tright: this.locale.alignRight,\n\t\t\tjustify: this.locale.justify,\n\t\t};\n\t\treturn labels[alignment];\n\t}\n\n\t// --- Middleware ---\n\n\t/**\n\t * Preserves the `align` attribute when other plugins change the block\n\t * type (e.g. paragraph → heading) via `setBlockType`, which replaces attrs.\n\t */\n\tprivate registerMiddleware(context: PluginContext): void {\n\t\tcontext.registerMiddleware(\n\t\t\t(tr, _state, next) => {\n\t\t\t\tlet patched = false;\n\n\t\t\t\tconst patchedSteps = tr.steps.map((step) => {\n\t\t\t\t\tif (step.type !== 'setBlockType') return step;\n\t\t\t\t\tif (!this.alignableTypes.has(step.nodeType)) return step;\n\n\t\t\t\t\tconst prevAlign = step.previousAttrs?.align;\n\t\t\t\t\tif (!prevAlign || prevAlign === 'left') return step;\n\n\t\t\t\t\t// Carry forward align into new attrs\n\t\t\t\t\tpatched = true;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...step,\n\t\t\t\t\t\tattrs: { ...step.attrs, align: prevAlign },\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tnext(patched ? { ...tr, steps: patchedSteps } : tr);\n\t\t\t},\n\t\t\t{ name: 'alignment:preserve-align' },\n\t\t);\n\t}\n\n\t// --- Alignment Logic ---\n\n\t/**\n\t * Gets the selected block, handling both TextSelection and NodeSelection.\n\t */\n\tprivate getSelectedBlock(state: EditorState): BlockNode | undefined {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) {\n\t\t\treturn state.getBlock(sel.nodeId);\n\t\t}\n\t\tif (isTextSelection(sel)) {\n\t\t\treturn state.getBlock(sel.anchor.blockId);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Gets the block ID of the selected block, handling both selection types.\n\t */\n\tprivate getSelectedBlockId(state: EditorState): BlockId | undefined {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return sel.nodeId;\n\t\tif (isTextSelection(sel)) return sel.anchor.blockId;\n\t\treturn undefined;\n\t}\n\n\tprivate setAlignment(context: PluginContext, alignment: BlockAlignment): boolean {\n\t\tconst state = context.getState();\n\t\tconst block = this.getSelectedBlock(state);\n\t\tif (!block || !this.alignableTypes.has(block.type)) return false;\n\n\t\tconst blockId = this.getSelectedBlockId(state);\n\t\tif (!blockId) return false;\n\n\t\tconst path = findNodePath(state.doc, blockId);\n\t\tif (!path) return false;\n\n\t\tconst newAttrs = { ...block.attrs, align: alignment };\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setNodeAttr(path as BlockId[], newAttrs)\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tprivate isNonDefaultAlignment(state: EditorState): boolean {\n\t\tconst block = this.getSelectedBlock(state);\n\t\tif (!block || !this.alignableTypes.has(block.type)) return false;\n\t\tconst align = block.attrs?.align;\n\t\tconst defaultAlign: BlockAlignment = this.config.defaults[block.type] ?? 'left';\n\t\treturn align != null && align !== defaultAlign;\n\t}\n\n\tprivate isAlignable(state: EditorState): boolean {\n\t\tconst block = this.getSelectedBlock(state);\n\t\treturn block != null && this.alignableTypes.has(block.type);\n\t}\n}\n\n// --- Helpers ---\n\nfunction applyAlignment(el: HTMLElement, node: BlockNode): void {\n\tconst align = node.attrs?.align;\n\tif (typeof align === 'string' && align !== 'left') {\n\t\tsetStyleProperty(el, 'textAlign', align);\n\t}\n}\n\nfunction capitalize(s: string): string {\n\treturn s.charAt(0).toUpperCase() + s.slice(1);\n}\n"],"names":["ALIGNMENT_LOCALE_EN","alignLeft","alignCenter","alignRight","justify","toolbarLabel","toolbarTooltip","ALIGNMENT_LOCALE_DE","ALIGNMENT_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","alignments","alignableTypes","defaults","image","ALIGNMENT_ICONS","left","center","right","AlignmentPlugin","id","name","priority","config","locale","this","context","resolvePluginLocale","Set","patchNodeSpecs","registerCommands","registerKeymaps","registerToolbarItem","registerMiddleware","registry","getSchemaRegistry","type","spec","getNodeSpec","attrs","align","originalToDOM","toDOM","defaultAlign","removeNodeSpec","registerNodeSpec","default","node","el","call","applyAlignment","alignment","registerCommand","capitalize","setAlignment","bindings","includes","executeCommand","Object","keys","length","registerKeymap","dropdownItems","map","label","getAlignmentLabel","command","icon","group","tooltip","popupType","popupConfig","items","separatorAfter","isActive","state","isNonDefaultAlignment","isEnabled","isAlignable","tr","_state","next","patched","patchedSteps","steps","step","has","nodeType","prevAlign","previousAttrs","sel","selection","isNodeSelection","getBlock","nodeId","isTextSelection","anchor","blockId","getState","block","getSelectedBlock","getSelectedBlockId","path","findNodePath","doc","newAttrs","transaction","setNodeAttr","setSelection","build","dispatch","setStyleProperty","s","charAt","toUpperCase","slice"],"mappings":";;;;AAaO,MAAMA,IAAuC,EACnDC,WAAW,cACXC,aAAa,gBACbC,YAAY,eACZC,SAAS,WACTC,cAAc,aACdC,gBAAgB,eAKJC,IAAuC,EACnDN,WAAW,eACXC,aAAa,aACbC,YAAY,gBACZC,SAAS,aACTC,cAAc,eACdC,gBAAgB,iBAuEJE,IAAqD,EACjEC,IAAIT,GACJU,IAAIH,GACJI,IArEmD,EACnDV,WAAW,0BACXC,aAAa,WACbC,YAAY,wBACZC,SAAS,cACTC,cAAc,cACdC,gBAAgB,aAAA,GAgEhBM,IA3DmD,EACnDX,WAAW,oBACXC,aAAa,WACbC,YAAY,oBACZC,SAAS,aACTC,cAAc,cACdC,gBAAgB,aAAA,GAsDhBO,IAjDmD,EACnDZ,WAAW,OACXC,aAAa,MACbC,YAAY,OACZC,SAAS,QACTC,cAAc,MACdC,gBAAgB,QA4ChBQ,IAvCmD,EACnDb,WAAW,kBACXC,aAAa,aACbC,YAAY,mBACZC,SAAS,aACTC,cAAc,gBACdC,gBAAgB,eAAA,GAkChBS,IA7BmD,EACnDd,WAAW,iBACXC,aAAa,SACbC,YAAY,iBACZC,SAAS,OACTC,cAAc,YACdC,gBAAgB,WAAA,GAwBhB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MP,KAAQO,GAAKR,OAAOC;AACL,qBAAVA,MAAgC,WAAVA,MAChCuE,EAAiB/D,IAAI,aAAaR,EAAAA;AAEpC;AAEA,SAASa,EAAW2D;AACnB,SAAOA,GAAEC,OAAO,CAAA,EAAGC,YAAAA,IAAgBF,GAAEG,MAAM,CAAA;AAC5C;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MarkTypeName } from '../model/TypeBrands.js';
|
|
2
2
|
import { EditorState } from '../state/EditorState.js';
|
|
3
3
|
import { Transaction } from '../state/Transaction.js';
|
|
4
4
|
export interface FeatureConfig {
|
|
@@ -10,10 +10,10 @@ export interface FeatureConfig {
|
|
|
10
10
|
* Toggles a mark on the current selection.
|
|
11
11
|
* If collapsed, toggles stored marks. If range, applies/removes from text.
|
|
12
12
|
*/
|
|
13
|
-
export declare function toggleMark(state: EditorState, markType:
|
|
13
|
+
export declare function toggleMark(state: EditorState, markType: MarkTypeName, features?: FeatureConfig): Transaction | null;
|
|
14
14
|
export declare function toggleBold(state: EditorState, features?: FeatureConfig): Transaction | null;
|
|
15
15
|
export declare function toggleItalic(state: EditorState, features?: FeatureConfig): Transaction | null;
|
|
16
16
|
export declare function toggleUnderline(state: EditorState, features?: FeatureConfig): Transaction | null;
|
|
17
17
|
/** Checks if a mark is active at the current selection. */
|
|
18
|
-
export declare function isMarkActive(state: EditorState, markType:
|
|
18
|
+
export declare function isMarkActive(state: EditorState, markType: MarkTypeName): boolean;
|
|
19
19
|
//# sourceMappingURL=MarkCommands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkCommands.d.ts","sourceRoot":"","sources":["../../src/commands/MarkCommands.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"MarkCommands.d.ts","sourceRoot":"","sources":["../../src/commands/MarkCommands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC5B;AAID;;;GAGG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,YAAY,EACtB,QAAQ,GAAE,aAA+B,GACvC,WAAW,GAAG,IAAI,CA0CpB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,WAAW,GAAG,IAAI,CAE3F;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,WAAW,GAAG,IAAI,CAE7F;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,WAAW,GAAG,IAAI,CAEhG;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAehF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSSClassCollector: maps CSS declarations to unique class names during serialization.
|
|
3
|
+
* Deduplicates identical declaration sets and produces a minimal stylesheet.
|
|
4
|
+
* Uses content-hash (FNV-1a) for deterministic, document-order-independent class names.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Stateful collector that assigns CSS class names to unique declaration sets.
|
|
8
|
+
* Used during a single serialization pass, then produces the collected stylesheet.
|
|
9
|
+
*
|
|
10
|
+
* Class names are deterministic: the same declarations always produce the same
|
|
11
|
+
* class name, regardless of encounter order across documents.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CSSClassCollector {
|
|
14
|
+
/** Maps normalized declarations → class name. */
|
|
15
|
+
private readonly classMap;
|
|
16
|
+
/** Tracks used hashes to handle the (extremely rare) collision case. */
|
|
17
|
+
private readonly usedHashes;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the class name for the given CSS declarations.
|
|
20
|
+
* If the same (normalized) declarations were seen before, returns the existing class.
|
|
21
|
+
*/
|
|
22
|
+
getClassName(declarations: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the semantic alignment class name for a given alignment value.
|
|
25
|
+
* Unlike style classes, alignment classes use descriptive names.
|
|
26
|
+
*/
|
|
27
|
+
getAlignmentClassName(alignment: string): string;
|
|
28
|
+
/** Produces CSS rules for all collected classes. Returns empty string if none collected. */
|
|
29
|
+
toCSS(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a map from class name → CSS declarations for round-trip support.
|
|
32
|
+
* Used by `setContentHTML` to rehydrate class-based HTML.
|
|
33
|
+
*/
|
|
34
|
+
toStyleMap(): ReadonlyMap<string, string>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=CSSClassCollector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CSSClassCollector.d.ts","sourceRoot":"","sources":["../../src/editor/CSSClassCollector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4CH;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC7B,iDAAiD;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAC3D,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0B;IAErD;;;OAGG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAoB1C;;;OAGG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAUhD,4FAA4F;IAC5F,KAAK,IAAI,MAAM;IAUf;;;OAGG;IACH,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;CAOzC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for class-based CSS serialization of document HTML.
|
|
3
|
+
*/
|
|
4
|
+
/** Controls whether exported HTML uses inline `style` attributes or CSS class names. */
|
|
5
|
+
export type CSSMode = 'inline' | 'classes';
|
|
6
|
+
/** Options for {@link NotectlEditor.getContentHTML}. */
|
|
7
|
+
export interface ContentHTMLOptions {
|
|
8
|
+
readonly pretty?: boolean;
|
|
9
|
+
readonly cssMode?: CSSMode;
|
|
10
|
+
}
|
|
11
|
+
/** Result of class-based HTML serialization (`cssMode: 'classes'`). */
|
|
12
|
+
export interface ContentCSSResult {
|
|
13
|
+
readonly html: string;
|
|
14
|
+
readonly css: string;
|
|
15
|
+
/**
|
|
16
|
+
* Maps each generated class name to its CSS declarations.
|
|
17
|
+
* Pass to `setContentHTML(html, { styleMap })` for round-trip re-import.
|
|
18
|
+
*/
|
|
19
|
+
readonly styleMap: ReadonlyMap<string, string>;
|
|
20
|
+
}
|
|
21
|
+
/** Options for {@link NotectlEditor.setContentHTML} when importing class-based HTML. */
|
|
22
|
+
export interface SetContentHTMLOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Style map from a previous `getContentHTML({ cssMode: 'classes' })` call.
|
|
25
|
+
* Used to rehydrate class-based HTML back into styled content.
|
|
26
|
+
*/
|
|
27
|
+
readonly styleMap?: ReadonlyMap<string, string>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ContentHTMLTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentHTMLTypes.d.ts","sourceRoot":"","sources":["../../src/editor/ContentHTMLTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wFAAwF;AACxF,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE3C,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C;AAED,wFAAwF;AACxF,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ContentStyleInjector: CSP-compliant utilities for injecting collected CSS
|
|
3
|
+
* into the document. Supports nonce-based `<style>` elements and adoptedStyleSheets.
|
|
4
|
+
*/
|
|
5
|
+
/** Options for {@link injectContentStyles}. */
|
|
6
|
+
export interface InjectStylesOptions {
|
|
7
|
+
/** Nonce value for CSP compliance. Added as `nonce` attribute on the `<style>` element. */
|
|
8
|
+
readonly nonce?: string;
|
|
9
|
+
/** Target document. Defaults to `globalThis.document`. */
|
|
10
|
+
readonly document?: Document;
|
|
11
|
+
/** Container element to append the `<style>` to. Defaults to `document.head`. */
|
|
12
|
+
readonly container?: HTMLElement;
|
|
13
|
+
/**
|
|
14
|
+
* Unique ID for the `<style>` element. When provided and an element with this ID
|
|
15
|
+
* already exists, its content is replaced (avoiding duplicates on re-renders).
|
|
16
|
+
*/
|
|
17
|
+
readonly id?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Injects CSS into the document via a `<style>` element.
|
|
21
|
+
* Returns the created/updated element for manual cleanup.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const result = editor.getContentHTML({ cssMode: 'classes' });
|
|
26
|
+
* const style = injectContentStyles(result.css, { nonce: 'abc123' });
|
|
27
|
+
* // Later: removeContentStyles('notectl-content', document);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function injectContentStyles(css: string, options?: InjectStylesOptions): HTMLStyleElement;
|
|
31
|
+
/**
|
|
32
|
+
* Removes a previously injected `<style>` element by its ID.
|
|
33
|
+
*
|
|
34
|
+
* @param id - The ID of the `<style>` element to remove.
|
|
35
|
+
* @param doc - Target document. Defaults to `globalThis.document`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function removeContentStyles(id: string, doc?: Document): void;
|
|
38
|
+
/** Options for {@link adoptContentStyles}. */
|
|
39
|
+
export interface AdoptStylesOptions {
|
|
40
|
+
/** Target document or ShadowRoot. Defaults to `globalThis.document`. */
|
|
41
|
+
readonly target?: Document | ShadowRoot;
|
|
42
|
+
/**
|
|
43
|
+
* When true, replaces any previously adopted notectl sheet on the same target.
|
|
44
|
+
* When false (default), appends a new sheet.
|
|
45
|
+
*/
|
|
46
|
+
readonly replace?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Injects CSS via `adoptedStyleSheets` — no DOM element, no nonce needed.
|
|
50
|
+
* Works with both `Document` and `ShadowRoot`, making it ideal for Web Components.
|
|
51
|
+
*
|
|
52
|
+
* Returns the created `CSSStyleSheet` for manual cleanup via {@link removeAdoptedStyles}.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const result = editor.getContentHTML({ cssMode: 'classes' });
|
|
57
|
+
* const sheet = adoptContentStyles(result.css);
|
|
58
|
+
* // Later: removeAdoptedStyles(sheet);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function adoptContentStyles(css: string, options?: AdoptStylesOptions): CSSStyleSheet;
|
|
62
|
+
/**
|
|
63
|
+
* Removes a specific adopted stylesheet from its target.
|
|
64
|
+
*
|
|
65
|
+
* @param sheet - The `CSSStyleSheet` returned by {@link adoptContentStyles}.
|
|
66
|
+
* @param target - Target document or ShadowRoot. Defaults to `globalThis.document`.
|
|
67
|
+
*/
|
|
68
|
+
export declare function removeAdoptedStyles(sheet: CSSStyleSheet, target?: Document | ShadowRoot): void;
|
|
69
|
+
//# sourceMappingURL=ContentStyleInjector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentStyleInjector.d.ts","sourceRoot":"","sources":["../../src/editor/ContentStyleInjector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IACnC,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,gBAAgB,CA4BhG;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAMpE;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IAClC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC3B;AAKD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAY3F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,IAAI,CAG9F"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Document } from '../model/Document.js';
|
|
2
2
|
import { SchemaRegistry } from '../model/SchemaRegistry.js';
|
|
3
|
+
/** Options for `parseHTMLToDocument` when importing class-based HTML. */
|
|
4
|
+
export interface ParseHTMLOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Style map from a previous `getContentHTML({ cssMode: 'classes' })` call.
|
|
7
|
+
* Used to rehydrate class-based HTML back into styled content.
|
|
8
|
+
*/
|
|
9
|
+
readonly styleMap?: ReadonlyMap<string, string>;
|
|
10
|
+
}
|
|
3
11
|
/** Parses an HTML string into a Document, applying sanitization and schema parse rules. */
|
|
4
|
-
export declare function parseHTMLToDocument(html: string, registry?: SchemaRegistry): Document;
|
|
12
|
+
export declare function parseHTMLToDocument(html: string, registry?: SchemaRegistry, options?: ParseHTMLOptions): Document;
|
|
5
13
|
//# sourceMappingURL=DocumentParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentParser.d.ts","sourceRoot":"","sources":["../../src/editor/DocumentParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAa,QAAQ,EAA8B,MAAM,sBAAsB,CAAC;AAQ5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,2FAA2F;AAC3F,wBAAgB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"DocumentParser.d.ts","sourceRoot":"","sources":["../../src/editor/DocumentParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAa,QAAQ,EAA8B,MAAM,sBAAsB,CAAC;AAQ5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,yEAAyE;AACzE,MAAM,WAAW,gBAAgB;IAChC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD;AAED,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,cAAc,EACzB,OAAO,CAAC,EAAE,gBAAgB,GACxB,QAAQ,CA6EV"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Document } from '../model/Document.js';
|
|
2
2
|
import { SchemaRegistry } from '../model/SchemaRegistry.js';
|
|
3
|
+
import { ContentCSSResult } from './ContentHTMLTypes.js';
|
|
3
4
|
/** Known-safe alignment values accepted by the serializer (defense-in-depth). */
|
|
4
5
|
export declare const VALID_ALIGNMENTS: ReadonlySet<string>;
|
|
5
6
|
/** Serializes a full document to sanitized HTML, wrapping list items in `<ul>`/`<ol>`. */
|
|
6
7
|
export declare function serializeDocumentToHTML(doc: Document, registry?: SchemaRegistry): string;
|
|
8
|
+
/**
|
|
9
|
+
* Serializes a document to HTML with CSS class names instead of inline styles.
|
|
10
|
+
* Returns the HTML and a collected stylesheet with only the rules actually used.
|
|
11
|
+
*/
|
|
12
|
+
export declare function serializeDocumentToCSS(doc: Document, registry?: SchemaRegistry): ContentCSSResult;
|
|
7
13
|
//# sourceMappingURL=DocumentSerializer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentSerializer.d.ts","sourceRoot":"","sources":["../../src/editor/DocumentSerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAa,QAAQ,EAAwB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"DocumentSerializer.d.ts","sourceRoot":"","sources":["../../src/editor/DocumentSerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAa,QAAQ,EAAwB,MAAM,sBAAsB,CAAC;AAWtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAc9D,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAK/C,CAAC;AAuBH,0FAA0F;AAC1F,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,MAAM,CAYxF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAwBjG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Mark } from '../model/Document.js';
|
|
2
2
|
import { SchemaRegistry } from '../model/SchemaRegistry.js';
|
|
3
|
+
import { CSSClassCollector } from './CSSClassCollector.js';
|
|
3
4
|
/** Builds a map of mark type name to rank from the registry (compute once per pass). */
|
|
4
5
|
export declare function buildMarkOrder(registry: SchemaRegistry): Map<string, number>;
|
|
5
6
|
/**
|
|
@@ -8,4 +9,10 @@ export declare function buildMarkOrder(registry: SchemaRegistry): Map<string, nu
|
|
|
8
9
|
* Tag-based marks (`toHTMLString`) wrap the content in rank order.
|
|
9
10
|
*/
|
|
10
11
|
export declare function serializeMarksToHTML(text: string, marks: readonly Mark[], registry: SchemaRegistry, markOrder?: Map<string, number>): string;
|
|
12
|
+
/**
|
|
13
|
+
* Serializes text with marks to HTML using CSS class names instead of inline styles.
|
|
14
|
+
* Style-based marks (`toHTMLStyle`) are collected into a `CSSClassCollector` and emitted
|
|
15
|
+
* as `<span class="...">`. Tag-based marks (`toHTMLString`) wrap identically to the inline path.
|
|
16
|
+
*/
|
|
17
|
+
export declare function serializeMarksToClassHTML(text: string, marks: readonly Mark[], registry: SchemaRegistry, collector: CSSClassCollector, markOrder?: Map<string, number>): string;
|
|
11
18
|
//# sourceMappingURL=MarkSerializer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkSerializer.d.ts","sourceRoot":"","sources":["../../src/editor/MarkSerializer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"MarkSerializer.d.ts","sourceRoot":"","sources":["../../src/editor/MarkSerializer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ5E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,cAAc,EACxB,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,MAAM,CAyCR;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,iBAAiB,EAC5B,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,MAAM,CA2CR"}
|
|
@@ -5,7 +5,7 @@ import { TextFormattingConfig } from '../plugins/text-formatting/TextFormattingP
|
|
|
5
5
|
import { ToolbarOverflowBehavior } from '../plugins/toolbar/ToolbarOverflowBehavior.js';
|
|
6
6
|
import { EditorState } from '../state/EditorState.js';
|
|
7
7
|
import { Transaction } from '../state/Transaction.js';
|
|
8
|
-
import {
|
|
8
|
+
import { ContentCSSResult, ContentHTMLOptions, SetContentHTMLOptions } from './ContentHTMLTypes.js';
|
|
9
9
|
import { PaperSize } from './PaperSize.js';
|
|
10
10
|
import { Theme, ThemePreset } from './theme/ThemeTokens.js';
|
|
11
11
|
/**
|
|
@@ -42,13 +42,6 @@ export interface NotectlEditorConfig {
|
|
|
42
42
|
maxHistoryDepth?: number;
|
|
43
43
|
/** Theme preset or custom Theme object. Defaults to ThemePreset.Light. */
|
|
44
44
|
theme?: ThemePreset | Theme;
|
|
45
|
-
/**
|
|
46
|
-
* Runtime style mode.
|
|
47
|
-
* - `strict`: avoids inline style attributes via dynamic stylesheet tokens (default)
|
|
48
|
-
* - `inline`: legacy inline style mutations
|
|
49
|
-
* Evaluated during initialization.
|
|
50
|
-
*/
|
|
51
|
-
styleMode?: RuntimeStyleMode;
|
|
52
45
|
/** Optional nonce for fallback runtime `<style>` elements when strict mode cannot use adopted sheets. */
|
|
53
46
|
styleNonce?: string;
|
|
54
47
|
/** Paper size for WYSIWYG page layout. When set, content renders at exact paper width. */
|
|
@@ -104,11 +97,15 @@ export declare class NotectlEditor extends HTMLElement {
|
|
|
104
97
|
/** Sets the document from JSON. */
|
|
105
98
|
setJSON(doc: Document): void;
|
|
106
99
|
/** Returns sanitized HTML representation of the document. */
|
|
107
|
-
getContentHTML(
|
|
100
|
+
getContentHTML(): string;
|
|
101
|
+
getContentHTML(options: {
|
|
108
102
|
pretty?: boolean;
|
|
109
103
|
}): string;
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
getContentHTML(options: ContentHTMLOptions & {
|
|
105
|
+
cssMode: 'classes';
|
|
106
|
+
}): ContentCSSResult;
|
|
107
|
+
/** Sets content from HTML (sanitized). Accepts optional `styleMap` for class-based round-trip. */
|
|
108
|
+
setContentHTML(html: string, options?: SetContentHTMLOptions): void;
|
|
112
109
|
/** Returns plain text content. */
|
|
113
110
|
getText(): string;
|
|
114
111
|
/** Returns true if the editor is empty (single empty paragraph). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotectlEditor.d.ts","sourceRoot":"","sources":["../../src/editor/NotectlEditor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,KAAK,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;AAKnE,OAAO,KAAK,EACX,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAG7F,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"NotectlEditor.d.ts","sourceRoot":"","sources":["../../src/editor/NotectlEditor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,KAAK,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;AAKnE,OAAO,KAAK,EACX,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAG7F,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQ3D,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,MAAM,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C,aAAa,CAAC,CAIvF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Font picker toolbar combobox + popup styles. */
|
|
2
|
-
export declare const FONT_SELECT_CSS = "\n/* Font Select \u2014 Width overrides for combobox button */\n.notectl-toolbar-btn--font {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Font Picker Popup */\n.notectl-font-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-font-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-font-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: left;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n.notectl-font-picker__item:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-font-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-picker__item--active:hover {\n\tbackground: var(--notectl-active-bg);\n}\n\n.notectl-font-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-primary-fg);\n}\n\n.notectl-font-picker__label {\n\tflex: 1;\n}\n\n.notectl-font-picker__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 8px;\n}\n";
|
|
2
|
+
export declare const FONT_SELECT_CSS = "\n/* Font Select \u2014 Width overrides for combobox button */\n.notectl-toolbar-btn--font {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Font Picker Popup */\n.notectl-font-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-font-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-font-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: left;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-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-primary-fg);\n}\n\n.notectl-font-picker__label {\n\tflex: 1;\n}\n\n.notectl-font-picker__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 8px;\n}\n";
|
|
3
3
|
//# sourceMappingURL=font-select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-select.d.ts","sourceRoot":"","sources":["../../../src/editor/styles/font-select.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"font-select.d.ts","sourceRoot":"","sources":["../../../src/editor/styles/font-select.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,eAAO,MAAM,eAAe,84CAyE3B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Font size picker toolbar combobox + popup styles. */
|
|
2
|
-
export declare const FONT_SIZE_SELECT_CSS = "\n/* Font Size Select \u2014 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-bg);\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: left;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n.notectl-font-size-picker__item:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-size-picker__item--active:hover {\n\tbackground: var(--notectl-active-bg);\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-primary-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n";
|
|
2
|
+
export declare const FONT_SIZE_SELECT_CSS = "\n/* Font Size Select \u2014 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-bg);\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: left;\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-primary-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-primary-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n";
|
|
3
3
|
//# sourceMappingURL=font-size-select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-size-select.d.ts","sourceRoot":"","sources":["../../../src/editor/styles/font-size-select.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"font-size-select.d.ts","sourceRoot":"","sources":["../../../src/editor/styles/font-size-select.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,wtEAwGhC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Heading picker toolbar combobox + popup styles. */
|
|
2
|
-
export declare const HEADING_SELECT_CSS = "\n/* Heading Select \u2014 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: left;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n.notectl-heading-picker__item:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-heading-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__item--active:hover {\n\tbackground: var(--notectl-active-bg);\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-primary-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n";
|
|
2
|
+
export declare const HEADING_SELECT_CSS = "\n/* Heading Select \u2014 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: left;\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-primary-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-primary-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n";
|
|
3
3
|
//# sourceMappingURL=heading-select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading-select.d.ts","sourceRoot":"","sources":["../../../src/editor/styles/heading-select.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"heading-select.d.ts","sourceRoot":"","sources":["../../../src/editor/styles/heading-select.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,eAAO,MAAM,kBAAkB,wyCAkE9B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Toolbar styles — buttons, separators, tooltips, popups, dropdowns. */
|
|
2
|
-
export declare const TOOLBAR_CSS = "\n/* Toolbar */\n.notectl-plugin-container--top {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\tborder-bottom: 1px solid var(--notectl-border);\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n\tmin-height: 40px;\n}\n\n.notectl-toolbar {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n\tflex: 1;\n\tmin-width: 0;\n\tgap: 2px;\n\tpadding: 4px 8px;\n}\n\n.notectl-toolbar[hidden] {\n\tdisplay: none;\n}\n\n.notectl-toolbar-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 14px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n.notectl-toolbar-btn:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-border);\n}\n\n.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-active-bg);\n\tborder-color: var(--notectl-primary-muted);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-toolbar-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n.notectl-toolbar-btn:disabled:hover {\n\tbackground: transparent;\n\tborder-color: transparent;\n}\n\n.notectl-toolbar-btn__icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n\tdisplay: block;\n\twidth: 18px;\n\theight: 18px;\n\tfill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n\tposition: fixed;\n\tpadding: 4px 8px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 10001;\n\tline-height: 1.4;\n\tletter-spacing: 0.01em;\n\tfont-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n\tdisplay: inline-block;\n\twidth: 1px;\n\theight: 20px;\n\tbackground: var(--notectl-border);\n\tmargin: 0 4px;\n\tvertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\toverflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-grid-picker__cell--highlighted {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n}\n\n/* Dropdown */\n.notectl-dropdown {\n\tmin-width: 160px;\n\tpadding: 4px 0;\n}\n\n.notectl-dropdown__item {\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: left;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\tfont-family: inherit;\n\twhite-space: nowrap;\n}\n\n
|
|
2
|
+
export declare const TOOLBAR_CSS = "\n/* Toolbar */\n.notectl-plugin-container--top {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\tborder-bottom: 1px solid var(--notectl-border);\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n\tmin-height: 40px;\n}\n\n.notectl-toolbar {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n\tflex: 1;\n\tmin-width: 0;\n\tgap: 2px;\n\tpadding: 4px 8px;\n}\n\n.notectl-toolbar[hidden] {\n\tdisplay: none;\n}\n\n.notectl-toolbar-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 14px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t\tborder-color: var(--notectl-border);\n\t}\n}\n\n.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-active-bg);\n\tborder-color: var(--notectl-primary-muted);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-toolbar-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn:disabled:hover {\n\t\tbackground: transparent;\n\t\tborder-color: transparent;\n\t}\n}\n\n.notectl-toolbar-btn__icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n\tdisplay: block;\n\twidth: 18px;\n\theight: 18px;\n\tfill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n\tposition: fixed;\n\tpadding: 4px 8px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 10001;\n\tline-height: 1.4;\n\tletter-spacing: 0.01em;\n\tfont-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n\tdisplay: inline-block;\n\twidth: 1px;\n\theight: 20px;\n\tbackground: var(--notectl-border);\n\tmargin: 0 4px;\n\tvertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\toverflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-grid-picker__cell--highlighted {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n}\n\n/* Dropdown */\n.notectl-dropdown {\n\tmin-width: 160px;\n\tpadding: 4px 0;\n}\n\n.notectl-dropdown__item {\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: left;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\tfont-family: inherit;\n\twhite-space: nowrap;\n}\n\n@media (hover: hover) {\n\t.notectl-dropdown__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-dropdown__item:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\toutline: none;\n}\n\n.notectl-dropdown__item-icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-fg-muted);\n\tflex-shrink: 0;\n}\n\n.notectl-dropdown__item-label {\n\tflex: 1;\n}\n\n/* Overflow behavior: flow mode \u2014 toolbar wraps to additional rows */\n.notectl-toolbar[data-overflow=\"flow\"] {\n\tflex-wrap: wrap;\n\toverflow: visible;\n}\n\n/* Overflow behavior: none \u2014 toolbar clips without any responsive behavior */\n.notectl-toolbar[data-overflow=\"none\"] {\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n}\n\n/* Overflow: hidden items (burger-menu mode) */\n.notectl-toolbar-btn--overflow-hidden,\n.notectl-toolbar-separator--overflow-hidden {\n\tdisplay: none;\n}\n\n/* Overflow \"more\" button */\n.notectl-toolbar-overflow-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 16px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\tmargin-left: auto;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-overflow-btn:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t\tborder-color: var(--notectl-border);\n\t}\n}\n\n.notectl-toolbar-overflow-btn--hidden {\n\tdisplay: none;\n}\n\n.notectl-toolbar-overflow-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n/* Dropdown item states shared by all dropdown menus (including overflow) */\n.notectl-dropdown__item:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n@media (hover: hover) {\n\t.notectl-dropdown__item:disabled:hover {\n\t\tbackground: none;\n\t}\n}\n\n.notectl-dropdown__item--active {\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-dropdown__item-icon svg {\n\tdisplay: block;\n\twidth: 16px;\n\theight: 16px;\n\tfill: currentColor;\n}\n\n.notectl-dropdown__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 0;\n}\n\n/* Combobox-style toolbar buttons (shared base for font, fontSize, heading, etc.) */\n.notectl-toolbar-btn[role=\"combobox\"] {\n\twidth: auto;\n\tpadding: 0 8px;\n\tgap: 4px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-bg);\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn[role=\"combobox\"]:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t\tborder-color: var(--notectl-fg-muted);\n\t}\n}\n\n.notectl-toolbar-btn[role=\"combobox\"].notectl-toolbar-btn--active {\n\tbackground: var(--notectl-bg);\n\tborder-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-combobox__label {\n\tflex: 1;\n\tfont-size: 13px;\n\tfont-weight: 500;\n\tcolor: var(--notectl-fg);\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\ttext-align: left;\n\tline-height: 30px;\n}\n\n.notectl-toolbar-combobox__arrow {\n\tflex-shrink: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tline-height: 30px;\n}\n\n/* Link Popup */\n.notectl-link-popup {\n\tpadding: 8px;\n\tmin-width: 200px;\n}\n\n.notectl-link-popup__input {\n\twidth: 100%;\n\tpadding: 4px;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-bg);\n}\n\n.notectl-link-popup__input:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-link-popup__button {\n\twidth: 100%;\n\tpadding: 6px 12px;\n\tcursor: pointer;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-bg);\n\tcolor: var(--notectl-fg);\n\tfont-size: 13px;\n}\n\n.notectl-link-popup__button--apply {\n\tmargin-top: 4px;\n}\n\n@media (hover: hover) {\n\t.notectl-link-popup__button:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-link-popup__button:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n";
|
|
3
3
|
//# sourceMappingURL=toolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../../../src/editor/styles/toolbar.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../../../src/editor/styles/toolbar.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,eAAO,MAAM,WAAW,6/OAgWvB,CAAC"}
|