@notectl/core 1.0.6 → 1.0.9
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/README.md +78 -56
- package/custom-elements.json +344 -0
- package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs → AttrRegistry-D-przlzb.mjs} +4 -4
- package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs.map → AttrRegistry-D-przlzb.mjs.map} +1 -1
- package/dist/chunks/ColorNames-iaWsSZx1.mjs +35 -0
- package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +1 -0
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +140 -0
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +1 -0
- package/dist/chunks/{Commands-DLP85Mp5.mjs → Commands-CSpSwGXv.mjs} +13 -13
- package/dist/chunks/{Commands-DLP85Mp5.mjs.map → Commands-CSpSwGXv.mjs.map} +1 -1
- package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs +46 -0
- package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs.map +1 -0
- package/dist/chunks/ToolbarPlugin-DFkl1uYO.mjs +818 -0
- package/dist/chunks/ToolbarPlugin-DFkl1uYO.mjs.map +1 -0
- package/dist/chunks/index-BCvuDpVr.mjs +191 -0
- package/dist/chunks/index-BCvuDpVr.mjs.map +1 -0
- package/dist/chunks/index-BFsYGsBR.mjs +92 -0
- package/dist/chunks/index-BFsYGsBR.mjs.map +1 -0
- package/dist/chunks/index-BIL37LSL.mjs +73 -0
- package/dist/chunks/index-BIL37LSL.mjs.map +1 -0
- package/dist/chunks/index-BL56fbXt.mjs +402 -0
- package/dist/chunks/index-BL56fbXt.mjs.map +1 -0
- package/dist/chunks/index-BQ8iIYLn.mjs +209 -0
- package/dist/chunks/index-BQ8iIYLn.mjs.map +1 -0
- package/dist/chunks/index-BRYzYOYC.mjs +63 -0
- package/dist/chunks/index-BRYzYOYC.mjs.map +1 -0
- package/dist/chunks/index-BSFLNveF.mjs +953 -0
- package/dist/chunks/index-BSFLNveF.mjs.map +1 -0
- package/dist/chunks/index-BTJfyJlJ.mjs +187 -0
- package/dist/chunks/index-BTJfyJlJ.mjs.map +1 -0
- package/dist/chunks/index-Bsp4LC5t.mjs +130 -0
- package/dist/chunks/index-Bsp4LC5t.mjs.map +1 -0
- package/dist/chunks/index-DA8TG2S8.mjs +220 -0
- package/dist/chunks/index-DA8TG2S8.mjs.map +1 -0
- package/dist/chunks/index-DAFCISBN.mjs +100 -0
- package/dist/chunks/index-DAFCISBN.mjs.map +1 -0
- package/dist/chunks/index-DC1EK22F.mjs +41 -0
- package/dist/chunks/index-DC1EK22F.mjs.map +1 -0
- package/dist/chunks/index-DGrRWMlW.mjs +541 -0
- package/dist/chunks/index-DGrRWMlW.mjs.map +1 -0
- package/dist/chunks/index-DfO_fKw6.mjs +39 -0
- package/dist/chunks/index-DfO_fKw6.mjs.map +1 -0
- package/dist/chunks/index-o6hDR07y.mjs +41 -0
- package/dist/chunks/index-o6hDR07y.mjs.map +1 -0
- package/dist/chunks/index-uTnc9y7M.mjs +62 -0
- package/dist/chunks/index-uTnc9y7M.mjs.map +1 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs +34 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +37 -5
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/PaperLayoutController.d.ts +27 -0
- package/dist/editor/PaperLayoutController.d.ts.map +1 -0
- package/dist/editor/PaperSize.d.ts +35 -0
- package/dist/editor/PaperSize.d.ts.map +1 -0
- package/dist/editor/styles/color-picker.d.ts +1 -1
- package/dist/editor/styles/color-picker.d.ts.map +1 -1
- package/dist/editor/styles/list.d.ts +2 -0
- package/dist/editor/styles/list.d.ts.map +1 -1
- package/dist/editor/styles/paper.d.ts +3 -0
- package/dist/editor/styles/paper.d.ts.map +1 -0
- package/dist/editor/styles/table.d.ts +1 -1
- package/dist/editor/styles/table.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/editor/styles.d.ts.map +1 -1
- package/dist/i18n/Locale.d.ts +17 -0
- package/dist/i18n/Locale.d.ts.map +1 -0
- package/dist/i18n/LocaleService.d.ts +8 -0
- package/dist/i18n/LocaleService.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/resolvePluginLocale.d.ts +3 -0
- package/dist/i18n/resolvePluginLocale.d.ts.map +1 -0
- package/dist/index.d.ts +48 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +2 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts +2 -0
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/KeyboardHandler.d.ts +2 -0
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/LegacyHTMLNormalizer.d.ts +18 -0
- package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +4 -0
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/model/HTMLParser.d.ts +13 -0
- package/dist/model/HTMLParser.d.ts.map +1 -1
- package/dist/model/SchemaRegistry.d.ts +2 -2
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2297 -1971
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +2894 -1825
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/Plugin.d.ts +17 -2
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +22 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentLocale.d.ts +19 -0
- package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts +4 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +3 -89
- package/dist/plugins/alignment.mjs.map +1 -1
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts +17 -0
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts +3 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
- package/dist/plugins/blockquote.mjs +2 -55
- package/dist/plugins/blockquote.mjs.map +1 -1
- package/dist/plugins/code-block/CodeBlockLocale.d.ts +17 -0
- package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +2 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +3 -3
- package/dist/plugins/font/FontLocale.d.ts +15 -0
- package/dist/plugins/font/FontLocale.d.ts.map +1 -0
- package/dist/plugins/font/FontPlugin.d.ts +3 -0
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeLocale.d.ts +17 -0
- package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +3 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts +2 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +2 -201
- package/dist/plugins/font-size.mjs.map +1 -1
- package/dist/plugins/font.mjs +2 -183
- package/dist/plugins/font.mjs.map +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +14 -0
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingCommands.d.ts +5 -0
- package/dist/plugins/heading/HeadingCommands.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts +5 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts +5 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingLocale.d.ts +26 -0
- package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +4 -40
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -184
- package/dist/plugins/heading.mjs.map +1 -1
- package/dist/plugins/highlight/HighlightLocale.d.ts +17 -0
- package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts +3 -5
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +2 -123
- package/dist/plugins/highlight.mjs.map +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts +15 -0
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +4 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +2 -56
- package/dist/plugins/horizontal-rule.mjs.map +1 -1
- package/dist/plugins/image/ImageLocale.d.ts +25 -0
- package/dist/plugins/image/ImageLocale.d.ts.map +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image/ImageUpload.d.ts +3 -0
- package/dist/plugins/image/ImageUpload.d.ts.map +1 -1
- package/dist/plugins/image.mjs +4 -378
- package/dist/plugins/image.mjs.map +1 -1
- package/dist/plugins/link/LinkLocale.d.ts +23 -0
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +3 -0
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +2 -124
- package/dist/plugins/link.mjs.map +1 -1
- package/dist/plugins/list/ListLocale.d.ts +18 -0
- package/dist/plugins/list/ListLocale.d.ts.map +1 -0
- package/dist/plugins/list/ListPlugin.d.ts +13 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +2 -190
- package/dist/plugins/list.mjs.map +1 -1
- package/dist/plugins/print/PrintLocale.d.ts +16 -0
- package/dist/plugins/print/PrintLocale.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/dist/plugins/print/PrintStyleCollector.d.ts +7 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
- package/dist/plugins/print/PrintTypes.d.ts +5 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
- package/dist/plugins/shared/ColorMarkOperations.d.ts +28 -0
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -0
- package/dist/plugins/shared/ColorNames.d.ts +22 -0
- package/dist/plugins/shared/ColorNames.d.ts.map +1 -0
- package/dist/plugins/shared/ColorPickerPopup.d.ts +31 -0
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -0
- package/dist/plugins/shared/ColorValidation.d.ts +14 -0
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts +17 -0
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +3 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +2 -32
- package/dist/plugins/strikethrough.mjs.map +1 -1
- package/dist/plugins/super-sub/SuperSubLocale.d.ts +19 -0
- package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts +3 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +2 -78
- package/dist/plugins/super-sub.mjs.map +1 -1
- package/dist/plugins/table/TableBorderColor.d.ts +24 -0
- package/dist/plugins/table/TableBorderColor.d.ts.map +1 -0
- package/dist/plugins/table/TableCommands.d.ts +9 -8
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts +14 -0
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts +3 -1
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts +13 -1
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table/TableLocale.d.ts +48 -0
- package/dist/plugins/table/TableLocale.d.ts.map +1 -0
- package/dist/plugins/table/TableNavigation.d.ts +2 -1
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
- package/dist/plugins/table/TableNodeViews.d.ts +3 -1
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts +7 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table/index.d.ts +3 -0
- package/dist/plugins/table/index.d.ts.map +1 -1
- package/dist/plugins/table.mjs +18 -660
- package/dist/plugins/table.mjs.map +1 -1
- package/dist/plugins/text-color/TextColorLocale.d.ts +17 -0
- package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts +3 -5
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +2 -123
- package/dist/plugins/text-color.mjs.map +1 -1
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts +18 -0
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +4 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +2 -49
- package/dist/plugins/text-formatting.mjs.map +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts +15 -0
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts +23 -0
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +56 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +18 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/state/EditorState.d.ts +4 -1
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/state/ReadonlyGuard.d.ts +6 -0
- package/dist/state/ReadonlyGuard.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +4 -0
- package/dist/state/Transaction.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts +2 -0
- package/dist/view/EditorView.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs +0 -15
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs +0 -398
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +0 -1
- package/dist/chunks/color-picker-Csf0wx5a.mjs +0 -5
- package/dist/chunks/color-picker-Csf0wx5a.mjs.map +0 -1
- package/dist/chunks/index-QvKiO9_4.mjs +0 -538
- package/dist/chunks/index-QvKiO9_4.mjs.map +0 -1
- package/dist/input/SourceNormalizer.d.ts +0 -7
- package/dist/input/SourceNormalizer.d.ts.map +0 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { r as e } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
2
|
+
import { c as t } from "./NodeSpec-NZVvcCuH.mjs";
|
|
3
|
+
import { i as n, a as o, c as i } from "./Selection-D5ZjXoB7.mjs";
|
|
4
|
+
import { a } from "./ToolbarPlugin-DFkl1uYO.mjs";
|
|
5
|
+
import { g as r, j as l, k as c, p as s, b as g } from "./Document-CI3iCwEP.mjs";
|
|
6
|
+
import { n as d } from "./TypeBrands-C09nE2qO.mjs";
|
|
7
|
+
function h(e2, t2, n2, o2) {
|
|
8
|
+
const i2 = document.createElement("button");
|
|
9
|
+
i2.type = "button", i2.className = "notectl-heading-picker__item", i2.setAttribute("role", "option"), i2.setAttribute("aria-selected", String(t2)), t2 && i2.classList.add("notectl-heading-picker__item--active");
|
|
10
|
+
const a2 = document.createElement("span");
|
|
11
|
+
a2.className = "notectl-heading-picker__check", a2.textContent = t2 ? "✓" : "", i2.appendChild(a2);
|
|
12
|
+
const r2 = document.createElement("span");
|
|
13
|
+
return r2.className = "notectl-heading-picker__label", r2.textContent = e2, o2 && (r2.style.fontSize = o2.fontSize, r2.style.fontWeight = o2.fontWeight), i2.appendChild(r2), i2.addEventListener("mousedown", n2), i2;
|
|
14
|
+
}
|
|
15
|
+
function p(e2, t2) {
|
|
16
|
+
return e2[`heading${t2}`];
|
|
17
|
+
}
|
|
18
|
+
function b(e2, t2) {
|
|
19
|
+
const o2 = e2.getState();
|
|
20
|
+
if (n(o2.selection)) return false;
|
|
21
|
+
const i2 = o2.getBlock(o2.selection.anchor.blockId);
|
|
22
|
+
return !!i2 && (i2.type === t2 ? f(e2, d("paragraph")) : f(e2, d(t2)));
|
|
23
|
+
}
|
|
24
|
+
function u(e2, t2) {
|
|
25
|
+
const o2 = e2.getState(), i2 = o2.selection;
|
|
26
|
+
if (n(i2)) return false;
|
|
27
|
+
const a2 = o2.getBlock(i2.anchor.blockId);
|
|
28
|
+
return !!a2 && ("heading" === a2.type && a2.attrs?.level === t2 ? f(e2, d("paragraph")) : f(e2, d("heading"), { level: t2 }));
|
|
29
|
+
}
|
|
30
|
+
function f(e2, t2, o2) {
|
|
31
|
+
const i2 = e2.getState(), a2 = i2.selection;
|
|
32
|
+
if (n(a2)) return false;
|
|
33
|
+
const s2 = i2.getBlock(a2.anchor.blockId);
|
|
34
|
+
if (!s2) return false;
|
|
35
|
+
const g2 = i2.transaction("command"), d2 = e2.getSchemaRegistry().getNodeSpec(t2);
|
|
36
|
+
d2?.excludeMarks && d2.excludeMarks.length > 0 && ((function(e3, t3, n2) {
|
|
37
|
+
if (0 === r(t3)) return;
|
|
38
|
+
const o3 = new Set(n2), i3 = l(t3);
|
|
39
|
+
let a3 = 0;
|
|
40
|
+
for (const n3 of i3) if (c(n3)) {
|
|
41
|
+
if (n3.text.length > 0) for (const i4 of n3.marks) o3.has(i4.type) && e3.removeMark(t3.id, a3, a3 + n3.text.length, i4);
|
|
42
|
+
a3 += n3.text.length;
|
|
43
|
+
} else a3 += 1;
|
|
44
|
+
})(g2, s2, d2.excludeMarks), (function(e3, t3, n2) {
|
|
45
|
+
if (!t3.storedMarks) return;
|
|
46
|
+
const o3 = new Set(n2), i3 = t3.storedMarks.filter((e4) => !o3.has(e4.type));
|
|
47
|
+
i3.length !== t3.storedMarks.length && e3.setStoredMarks(i3.length > 0 ? i3 : null, t3.storedMarks);
|
|
48
|
+
})(g2, i2, d2.excludeMarks));
|
|
49
|
+
const h2 = g2.setBlockType(a2.anchor.blockId, t2, o2).setSelection(a2).build();
|
|
50
|
+
return e2.dispatch(h2), true;
|
|
51
|
+
}
|
|
52
|
+
const k = /* @__PURE__ */ new Set(["heading", "title", "subtitle"]);
|
|
53
|
+
const m = { 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" }, y = { en: m, de: { paragraph: "Absatz", title: "Titel", subtitle: "Untertitel", heading1: "Überschrift 1", heading2: "Überschrift 2", heading3: "Überschrift 3", heading4: "Überschrift 4", heading5: "Überschrift 5", heading6: "Überschrift 6", blockTypeLabel: "Blocktyp", blockTypesAria: "Blocktypen" }, es: { paragraph: "Párrafo", title: "Título", subtitle: "Subtítulo", heading1: "Encabezado 1", heading2: "Encabezado 2", heading3: "Encabezado 3", heading4: "Encabezado 4", heading5: "Encabezado 5", heading6: "Encabezado 6", blockTypeLabel: "Tipo de bloque", blockTypesAria: "Tipos de bloque" }, fr: { paragraph: "Paragraphe", title: "Titre", subtitle: "Sous-titre", heading1: "Titre 1", heading2: "Titre 2", heading3: "Titre 3", heading4: "Titre 4", heading5: "Titre 5", heading6: "Titre 6", blockTypeLabel: "Type de bloc", blockTypesAria: "Types de bloc" }, zh: { paragraph: "正文", title: "标题", subtitle: "副标题", heading1: "一级标题", heading2: "二级标题", heading3: "三级标题", heading4: "四级标题", heading5: "五级标题", heading6: "六级标题", blockTypeLabel: "块类型", blockTypesAria: "块类型列表" }, ru: { paragraph: "Абзац", title: "Заголовок", subtitle: "Подзаголовок", heading1: "Заголовок 1", heading2: "Заголовок 2", heading3: "Заголовок 3", heading4: "Заголовок 4", heading5: "Заголовок 5", heading6: "Заголовок 6", blockTypeLabel: "Тип блока", blockTypesAria: "Типы блоков" }, ar: { paragraph: "فقرة", title: "عنوان", subtitle: "عنوان فرعي", heading1: "عنوان 1", heading2: "عنوان 2", heading3: "عنوان 3", heading4: "عنوان 4", heading5: "عنوان 5", heading6: "عنوان 6", blockTypeLabel: "نوع الكتلة", blockTypesAria: "أنواع الكتل" }, hi: { paragraph: "अनुच्छेद", title: "शीर्षक", subtitle: "उपशीर्षक", heading1: "शीर्षक 1", heading2: "शीर्षक 2", heading3: "शीर्षक 3", heading4: "शीर्षक 4", heading5: "शीर्षक 5", heading6: "शीर्षक 6", blockTypeLabel: "ब्लॉक प्रकार", blockTypesAria: "ब्लॉक प्रकार सूची" } }, v = { levels: [1, 2, 3, 4, 5, 6] }, x = { 1: "h1", 2: "h2", 3: "h3", 4: "h4", 5: "h5", 6: "h6" };
|
|
54
|
+
class T {
|
|
55
|
+
id = "heading";
|
|
56
|
+
name = "Heading";
|
|
57
|
+
priority = 30;
|
|
58
|
+
config;
|
|
59
|
+
locale;
|
|
60
|
+
context = null;
|
|
61
|
+
comboLabel = null;
|
|
62
|
+
constructor(e2) {
|
|
63
|
+
this.config = { ...v, ...e2 };
|
|
64
|
+
}
|
|
65
|
+
init(t2) {
|
|
66
|
+
this.locale = e(y, t2, this.config.locale), t2.registerStyleSheet("\n/* Heading Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--heading {\n width: auto;\n min-width: 100px;\n max-width: 160px;\n padding: 0 8px;\n gap: 4px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n}\n\n.notectl-toolbar-btn--heading:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--heading.notectl-toolbar-btn--active {\n background: var(--notectl-bg);\n border-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--heading .notectl-toolbar-btn__icon {\n display: flex;\n align-items: center;\n gap: 4px;\n width: 100%;\n overflow: hidden;\n}\n\n.notectl-toolbar-btn--heading .notectl-toolbar-btn__icon svg {\n display: none;\n}\n\n.notectl-heading-select__label {\n flex: 1;\n font-size: 13px;\n font-weight: 500;\n color: var(--notectl-fg);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: left;\n line-height: 30px;\n}\n\n.notectl-heading-select__arrow {\n flex-shrink: 0;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n line-height: 30px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n min-width: 200px;\n max-height: 320px;\n overflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n padding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 7px 12px;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n text-align: left;\n white-space: nowrap;\n font-family: inherit;\n transition: background 0.1s;\n}\n\n.notectl-heading-picker__item:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-heading-picker__item--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__item--active:hover {\n background: var(--notectl-active-bg);\n}\n\n.notectl-heading-picker__check {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n flex-shrink: 0;\n font-size: 13px;\n font-weight: 600;\n color: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__label {\n flex: 1;\n}\n"), this.context = t2, this.registerNodeSpecs(t2), (function(e2, t3) {
|
|
67
|
+
e2.registerCommand("setTitle", () => b(e2, "title")), e2.registerCommand("setSubtitle", () => b(e2, "subtitle"));
|
|
68
|
+
for (const n2 of t3.levels) e2.registerCommand(`setHeading${n2}`, () => u(e2, n2));
|
|
69
|
+
e2.registerCommand("toggleHeading", () => u(e2, 1)), e2.registerCommand("setParagraph", () => f(e2, d("paragraph")));
|
|
70
|
+
})(t2, this.config), (function(e2, t3) {
|
|
71
|
+
const a2 = { Enter: () => (function(e3) {
|
|
72
|
+
return (function(e4, t4) {
|
|
73
|
+
const i2 = e4.getState();
|
|
74
|
+
if (n(i2.selection)) return false;
|
|
75
|
+
const a3 = i2.selection;
|
|
76
|
+
if (!o(a3)) return false;
|
|
77
|
+
const r2 = i2.getBlock(a3.anchor.blockId);
|
|
78
|
+
return !(!r2 || !k.has(r2.type)) && t4({ state: i2, block: r2, blockId: a3.anchor.blockId, offset: a3.anchor.offset });
|
|
79
|
+
})(e3, (t4) => {
|
|
80
|
+
if ("" === s(t4.block)) {
|
|
81
|
+
const n3 = t4.state.transaction("input").setBlockType(t4.blockId, d("paragraph")).setSelection(t4.state.selection).build();
|
|
82
|
+
return e3.dispatch(n3), true;
|
|
83
|
+
}
|
|
84
|
+
const n2 = r(t4.block);
|
|
85
|
+
if (t4.offset >= n2) {
|
|
86
|
+
const n3 = g(), o2 = t4.state.transaction("input").splitBlock(t4.blockId, t4.offset, n3).setBlockType(n3, d("paragraph")).setSelection(i(n3, 0)).build();
|
|
87
|
+
return e3.dispatch(o2), true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
});
|
|
91
|
+
})(e2) };
|
|
92
|
+
for (const n2 of t3.levels) n2 <= 6 && (a2[`Mod-Shift-${n2}`] = () => e2.executeCommand(`setHeading${n2}`));
|
|
93
|
+
e2.registerKeymap(a2);
|
|
94
|
+
})(t2, this.config), (function(e2, t3) {
|
|
95
|
+
for (const a2 of t3.levels) {
|
|
96
|
+
const t4 = "#".repeat(a2), r2 = new RegExp(`^${t4} $`);
|
|
97
|
+
e2.registerInputRule({ pattern: r2, handler(e3, t5, r3, l2) {
|
|
98
|
+
const c2 = e3.selection;
|
|
99
|
+
if (n(c2)) return null;
|
|
100
|
+
if (!o(c2)) return null;
|
|
101
|
+
const s2 = e3.getBlock(c2.anchor.blockId);
|
|
102
|
+
return s2 && "paragraph" === s2.type ? e3.transaction("input").deleteTextAt(c2.anchor.blockId, r3, r3 + a2 + 1).setBlockType(c2.anchor.blockId, d("heading"), { level: a2 }).setSelection(i(c2.anchor.blockId, 0)).build() : null;
|
|
103
|
+
} });
|
|
104
|
+
}
|
|
105
|
+
})(t2, this.config), (function(e2, t3, o2) {
|
|
106
|
+
e2.registerBlockTypePickerEntry({ id: "paragraph", label: o2.paragraph, command: "setParagraph", priority: 10, isActive: (e3) => {
|
|
107
|
+
if (n(e3.selection)) return false;
|
|
108
|
+
const t4 = e3.getBlock(e3.selection.anchor.blockId);
|
|
109
|
+
return "paragraph" === t4?.type;
|
|
110
|
+
} }), e2.registerBlockTypePickerEntry({ id: "title", label: o2.title, command: "setTitle", priority: 20, style: { fontSize: "1.6em", fontWeight: "700" }, isActive: (e3) => {
|
|
111
|
+
if (n(e3.selection)) return false;
|
|
112
|
+
const t4 = e3.getBlock(e3.selection.anchor.blockId);
|
|
113
|
+
return "title" === t4?.type;
|
|
114
|
+
} }), e2.registerBlockTypePickerEntry({ id: "subtitle", label: o2.subtitle, command: "setSubtitle", priority: 30, style: { fontSize: "1.3em", fontWeight: "500" }, isActive: (e3) => {
|
|
115
|
+
if (n(e3.selection)) return false;
|
|
116
|
+
const t4 = e3.getBlock(e3.selection.anchor.blockId);
|
|
117
|
+
return "subtitle" === t4?.type;
|
|
118
|
+
} });
|
|
119
|
+
for (const i2 of t3.levels) e2.registerBlockTypePickerEntry({ id: `heading-${i2}`, label: p(o2, i2), command: `setHeading${i2}`, priority: 100 + i2, style: { fontSize: 1.4 - 0.1 * i2 + "em", fontWeight: "600" }, isActive: (e3) => {
|
|
120
|
+
if (n(e3.selection)) return false;
|
|
121
|
+
const t4 = e3.getBlock(e3.selection.anchor.blockId);
|
|
122
|
+
return "heading" === t4?.type && t4.attrs?.level === i2;
|
|
123
|
+
} });
|
|
124
|
+
})(t2, this.config, this.locale), (function(e2, t3, o2) {
|
|
125
|
+
const i2 = `<span class="notectl-heading-select__label" data-heading-label>${o2.paragraph}</span><span class="notectl-heading-select__arrow">▾</span>`;
|
|
126
|
+
e2.registerToolbarItem({ id: "heading", group: "block", icon: i2, label: o2.blockTypeLabel, tooltip: o2.blockTypeLabel, command: "setParagraph", priority: 50, popupType: "custom", separatorAfter: t3.separatorAfter, renderPopup: (e3, t4) => {
|
|
127
|
+
!(function(e4, t5, o3) {
|
|
128
|
+
e4.classList.add("notectl-heading-picker");
|
|
129
|
+
const i3 = t5.getState();
|
|
130
|
+
if (n(i3.selection)) return;
|
|
131
|
+
const r2 = document.createElement("div");
|
|
132
|
+
r2.className = "notectl-heading-picker__list", r2.setAttribute("role", "listbox"), r2.setAttribute("aria-label", o3.blockTypesAria);
|
|
133
|
+
const l2 = t5.getSchemaRegistry().getBlockTypePickerEntries();
|
|
134
|
+
for (const e5 of l2) {
|
|
135
|
+
const n2 = e5.isActive(i3);
|
|
136
|
+
r2.appendChild(h(e5.label, n2, (n3) => {
|
|
137
|
+
n3.preventDefault(), n3.stopPropagation(), t5.executeCommand(e5.command);
|
|
138
|
+
const o4 = t5.getService(a);
|
|
139
|
+
o4?.closePopup();
|
|
140
|
+
}, e5.style));
|
|
141
|
+
}
|
|
142
|
+
e4.appendChild(r2);
|
|
143
|
+
})(e3, t4, o2);
|
|
144
|
+
}, isActive: (t4) => e2.getSchemaRegistry().getBlockTypePickerEntries().some((e3) => "paragraph" !== e3.id && e3.isActive(t4)) });
|
|
145
|
+
})(t2, this.config, this.locale);
|
|
146
|
+
}
|
|
147
|
+
destroy() {
|
|
148
|
+
this.context = null, this.comboLabel = null;
|
|
149
|
+
}
|
|
150
|
+
onStateChange(e2, t2, o2) {
|
|
151
|
+
this.context && (this.comboLabel = (function(e3, t3, o3, i2) {
|
|
152
|
+
let a2 = i2;
|
|
153
|
+
if (!a2) {
|
|
154
|
+
const e4 = t3.getPluginContainer("top");
|
|
155
|
+
if (!e4) return null;
|
|
156
|
+
if (a2 = e4.querySelector("[data-heading-label]") ?? null, !a2) return null;
|
|
157
|
+
}
|
|
158
|
+
return a2.textContent = (function(e4, t4, o4) {
|
|
159
|
+
if (n(e4.selection)) return o4.paragraph;
|
|
160
|
+
const i3 = t4.getSchemaRegistry().getBlockTypePickerEntries();
|
|
161
|
+
for (const t5 of i3) if (t5.isActive(e4)) return t5.label;
|
|
162
|
+
return o4.paragraph;
|
|
163
|
+
})(e3, t3, o3), a2;
|
|
164
|
+
})(t2, this.context, this.locale, this.comboLabel));
|
|
165
|
+
}
|
|
166
|
+
registerNodeSpecs(e2) {
|
|
167
|
+
e2.registerNodeSpec({ type: "title", group: "block", content: { allow: ["text"] }, excludeMarks: ["fontSize"], toDOM(e3) {
|
|
168
|
+
const n2 = t("h1", e3.id);
|
|
169
|
+
return n2.classList.add("notectl-title"), n2;
|
|
170
|
+
}, toHTML: (e3, t2) => `<h1>${t2 || "<br>"}</h1>`, sanitize: { tags: ["h1"] } }), e2.registerNodeSpec({ type: "subtitle", group: "block", content: { allow: ["text"] }, excludeMarks: ["fontSize"], toDOM(e3) {
|
|
171
|
+
const n2 = t("h2", e3.id);
|
|
172
|
+
return n2.classList.add("notectl-subtitle"), n2;
|
|
173
|
+
}, toHTML: (e3, t2) => `<h2>${t2 || "<br>"}</h2>`, sanitize: { tags: ["h2"] } }), e2.registerNodeSpec({ type: "heading", group: "block", content: { allow: ["text"] }, excludeMarks: ["fontSize"], attrs: { level: { default: 1 } }, toDOM(e3) {
|
|
174
|
+
const n2 = e3.attrs?.level ?? 1;
|
|
175
|
+
return t(x[n2] ?? "h1", e3.id);
|
|
176
|
+
}, toHTML(e3, t2) {
|
|
177
|
+
const n2 = e3.attrs?.level ?? 1, o2 = x[n2] ?? "h1";
|
|
178
|
+
return `<${o2}>${t2 || "<br>"}</${o2}>`;
|
|
179
|
+
}, 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"] } });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export {
|
|
183
|
+
y as H,
|
|
184
|
+
m as a,
|
|
185
|
+
T as b
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=index-BTJfyJlJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BTJfyJlJ.mjs","sources":["../../src/plugins/heading/HeadingBlockTypePicker.ts","../../src/plugins/heading/HeadingCommands.ts","../../src/plugins/heading/HeadingKeyboardHandlers.ts","../../src/plugins/heading/HeadingLocale.ts","../../src/plugins/heading/HeadingPlugin.ts","../../src/editor/styles/heading-select.ts","../../src/plugins/heading/HeadingInputRules.ts"],"sourcesContent":["/**\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 { isNodeSelection } from '../../model/Selection.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { ToolbarServiceKey } from '../toolbar/ToolbarPlugin.js';\nimport type { PickerEntryStyle } from './BlockTypePickerEntry.js';\nimport type { HeadingLocale } from './HeadingLocale.js';\nimport type { HeadingConfig, 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 (isNodeSelection(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 (isNodeSelection(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 (isNodeSelection(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 (isNodeSelection(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 custom picker popup. */\nexport function registerHeadingToolbarItem(\n\tcontext: PluginContext,\n\tconfig: HeadingConfig,\n\tlocale: HeadingLocale,\n): void {\n\tconst icon: string = `<span class=\"notectl-heading-select__label\" data-heading-label>${locale.paragraph}</span><span class=\"notectl-heading-select__arrow\">\\u25BE</span>`;\n\n\tcontext.registerToolbarItem({\n\t\tid: 'heading',\n\t\tgroup: 'block',\n\t\ticon,\n\t\tlabel: locale.blockTypeLabel,\n\t\ttooltip: locale.blockTypeLabel,\n\t\tcommand: 'setParagraph',\n\t\tpriority: 50,\n\t\tpopupType: 'custom',\n\t\tseparatorAfter: config.separatorAfter,\n\t\trenderPopup: (container, ctx) => {\n\t\t\trenderHeadingPopup(container, ctx, locale);\n\t\t},\n\t\tisActive: (state) => {\n\t\t\tconst entries = context.getSchemaRegistry().getBlockTypePickerEntries();\n\t\t\treturn entries.some((entry) => entry.id !== 'paragraph' && entry.isActive(state));\n\t\t},\n\t});\n}\n\n// --- Combo Label Update ---\n\n/**\n * Updates the combobox label in the toolbar to reflect the current block type.\n * Returns the resolved HTMLSpanElement (cached across calls) for reuse.\n */\nexport function updateComboLabel(\n\tstate: EditorState,\n\tcontext: PluginContext,\n\tlocale: HeadingLocale,\n\tcachedLabel: HTMLSpanElement | null,\n): HTMLSpanElement | null {\n\tlet label: HTMLSpanElement | null = cachedLabel;\n\n\tif (!label) {\n\t\tconst container: HTMLElement | undefined = context.getPluginContainer('top');\n\t\tif (!container) return null;\n\t\tlabel = container.querySelector<HTMLSpanElement>('[data-heading-label]') ?? null;\n\t\tif (!label) return null;\n\t}\n\n\tlabel.textContent = getActiveLabel(state, context, locale);\n\treturn label;\n}\n\n// --- Popup Rendering ---\n\nfunction renderHeadingPopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tlocale: HeadingLocale,\n): void {\n\tcontainer.classList.add('notectl-heading-picker');\n\n\tconst state: EditorState = context.getState();\n\tif (isNodeSelection(state.selection)) return;\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.getSchemaRegistry().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(e: MouseEvent) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\tcontext.executeCommand(entry.command);\n\t\t\t\t\tconst toolbar = context.getService(ToolbarServiceKey);\n\t\t\t\t\ttoolbar?.closePopup();\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\thandler: (e: MouseEvent) => 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\tlabelSpan.style.fontSize = style.fontSize;\n\t\tlabelSpan.style.fontWeight = style.fontWeight;\n\t}\n\titem.appendChild(labelSpan);\n\n\titem.addEventListener('mousedown', handler);\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 (isNodeSelection(state.selection)) return locale.paragraph;\n\tconst entries = context.getSchemaRegistry().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 { isNodeSelection } 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 (isNodeSelection(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 (isNodeSelection(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 (isNodeSelection(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 * 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, isNodeSelection } 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 (isNodeSelection(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\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// --- German Locale ---\n\nexport const HEADING_LOCALE_DE: HeadingLocale = {\n\tparagraph: 'Absatz',\n\ttitle: 'Titel',\n\tsubtitle: 'Untertitel',\n\theading1: 'Überschrift 1',\n\theading2: 'Überschrift 2',\n\theading3: 'Überschrift 3',\n\theading4: 'Überschrift 4',\n\theading5: 'Überschrift 5',\n\theading6: 'Überschrift 6',\n\tblockTypeLabel: 'Blocktyp',\n\tblockTypesAria: 'Blocktypen',\n};\n\n// --- Spanish Locale ---\n\nexport const HEADING_LOCALE_ES: HeadingLocale = {\n\tparagraph: 'Párrafo',\n\ttitle: 'Título',\n\tsubtitle: 'Subtítulo',\n\theading1: 'Encabezado 1',\n\theading2: 'Encabezado 2',\n\theading3: 'Encabezado 3',\n\theading4: 'Encabezado 4',\n\theading5: 'Encabezado 5',\n\theading6: 'Encabezado 6',\n\tblockTypeLabel: 'Tipo de bloque',\n\tblockTypesAria: 'Tipos de bloque',\n};\n\n// --- French Locale ---\n\nexport const HEADING_LOCALE_FR: HeadingLocale = {\n\tparagraph: 'Paragraphe',\n\ttitle: 'Titre',\n\tsubtitle: 'Sous-titre',\n\theading1: 'Titre 1',\n\theading2: 'Titre 2',\n\theading3: 'Titre 3',\n\theading4: 'Titre 4',\n\theading5: 'Titre 5',\n\theading6: 'Titre 6',\n\tblockTypeLabel: 'Type de bloc',\n\tblockTypesAria: 'Types de bloc',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const HEADING_LOCALE_ZH: HeadingLocale = {\n\tparagraph: '正文',\n\ttitle: '标题',\n\tsubtitle: '副标题',\n\theading1: '一级标题',\n\theading2: '二级标题',\n\theading3: '三级标题',\n\theading4: '四级标题',\n\theading5: '五级标题',\n\theading6: '六级标题',\n\tblockTypeLabel: '块类型',\n\tblockTypesAria: '块类型列表',\n};\n\n// --- Russian Locale ---\n\nexport const HEADING_LOCALE_RU: HeadingLocale = {\n\tparagraph: 'Абзац',\n\ttitle: 'Заголовок',\n\tsubtitle: 'Подзаголовок',\n\theading1: 'Заголовок 1',\n\theading2: 'Заголовок 2',\n\theading3: 'Заголовок 3',\n\theading4: 'Заголовок 4',\n\theading5: 'Заголовок 5',\n\theading6: 'Заголовок 6',\n\tblockTypeLabel: 'Тип блока',\n\tblockTypesAria: 'Типы блоков',\n};\n\n// --- Arabic Locale ---\n\nexport const HEADING_LOCALE_AR: HeadingLocale = {\n\tparagraph: 'فقرة',\n\ttitle: 'عنوان',\n\tsubtitle: 'عنوان فرعي',\n\theading1: 'عنوان 1',\n\theading2: 'عنوان 2',\n\theading3: 'عنوان 3',\n\theading4: 'عنوان 4',\n\theading5: 'عنوان 5',\n\theading6: 'عنوان 6',\n\tblockTypeLabel: 'نوع الكتلة',\n\tblockTypesAria: 'أنواع الكتل',\n};\n\n// --- Hindi Locale ---\n\nexport const HEADING_LOCALE_HI: HeadingLocale = {\n\tparagraph: 'अनुच्छेद',\n\ttitle: 'शीर्षक',\n\tsubtitle: 'उपशीर्षक',\n\theading1: 'शीर्षक 1',\n\theading2: 'शीर्षक 2',\n\theading3: 'शीर्षक 3',\n\theading4: 'शीर्षक 4',\n\theading5: 'शीर्षक 5',\n\theading6: 'शीर्षक 6',\n\tblockTypeLabel: 'ब्लॉक प्रकार',\n\tblockTypesAria: 'ब्लॉक प्रकार सूची',\n};\n\n// --- Locale Map ---\n\nexport const HEADING_LOCALES: Record<string, HeadingLocale> = {\n\ten: HEADING_LOCALE_EN,\n\tde: HEADING_LOCALE_DE,\n\tes: HEADING_LOCALE_ES,\n\tfr: HEADING_LOCALE_FR,\n\tzh: HEADING_LOCALE_ZH,\n\tru: HEADING_LOCALE_RU,\n\tar: HEADING_LOCALE_AR,\n\thi: HEADING_LOCALE_HI,\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 { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { createBlockElement } from '../../model/NodeSpec.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport type { BlockAlignment } from '../alignment/AlignmentPlugin.js';\nimport {\n\tregisterHeadingPickerEntries,\n\tregisterHeadingToolbarItem,\n\tupdateComboLabel,\n} from './HeadingBlockTypePicker.js';\nimport { registerHeadingCommands } from './HeadingCommands.js';\nimport { registerHeadingInputRules } from './HeadingInputRules.js';\nimport { registerHeadingKeymaps } from './HeadingKeyboardHandlers.js';\nimport { HEADING_LOCALES, type HeadingLocale } 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/** When true, a separator is rendered after the heading toolbar item. */\n\treadonly separatorAfter?: 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\tprivate context: PluginContext | null = null;\n\tprivate comboLabel: HTMLSpanElement | null = null;\n\n\tconstructor(config?: Partial<HeadingConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(HEADING_LOCALES, context, this.config.locale);\n\t\tcontext.registerStyleSheet(HEADING_SELECT_CSS);\n\t\tthis.context = context;\n\n\t\tthis.registerNodeSpecs(context);\n\t\tregisterHeadingCommands(context, this.config);\n\t\tregisterHeadingKeymaps(context, this.config);\n\t\tregisterHeadingInputRules(context, this.config);\n\t\tregisterHeadingPickerEntries(context, this.config, this.locale);\n\t\tregisterHeadingToolbarItem(context, this.config, this.locale);\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t\tthis.comboLabel = null;\n\t}\n\n\tonStateChange(_oldState: EditorState, _newState: EditorState, _tr: Transaction): void {\n\t\tif (!this.context) return;\n\t\tthis.comboLabel = updateComboLabel(_newState, this.context, this.locale, this.comboLabel);\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>${content || '<br>'}</h1>`;\n\t\t\t},\n\t\t\tsanitize: { tags: ['h1'] },\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>${content || '<br>'}</h2>`;\n\t\t\t},\n\t\t\tsanitize: { tags: ['h2'] },\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","/** Heading picker toolbar combobox + popup styles. */\nexport const HEADING_SELECT_CSS = `\n/* Heading Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--heading {\n\twidth: auto;\n\tmin-width: 100px;\n\tmax-width: 160px;\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.notectl-toolbar-btn--heading:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--heading.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-bg);\n\tborder-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--heading .notectl-toolbar-btn__icon {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n\twidth: 100%;\n\toverflow: hidden;\n}\n\n.notectl-toolbar-btn--heading .notectl-toolbar-btn__icon svg {\n\tdisplay: none;\n}\n\n.notectl-heading-select__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-heading-select__arrow {\n\tflex-shrink: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tline-height: 30px;\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`;\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, isNodeSelection } 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 (isNodeSelection(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"],"names":["createPickerItem","label","isActive","handler","style","item","document","createElement","type","className","setAttribute","String","classList","add","check","textContent","appendChild","labelSpan","fontSize","fontWeight","addEventListener","getHeadingLabel","locale","level","toggleSpecialBlock","context","state","getState","isNodeSelection","selection","block","getBlock","anchor","blockId","setBlockType","nodeType","toggleHeading","sel","attrs","builder","transaction","spec","getSchemaRegistry","getNodeSpec","excludeMarks","length","getBlockLength","excludeSet","Set","inlineChildren","getInlineChildren","offset","child","isTextNode","text","mark","marks","has","removeMark","id","storedMarks","filtered","filter","m","setStoredMarks","tr","setSelection","build","dispatch","HEADING_TYPES","HEADING_LOCALE_EN","paragraph","title","subtitle","heading1","heading2","heading3","heading4","heading5","heading6","blockTypeLabel","blockTypesAria","HEADING_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","levels","HEADING_TAGS","HeadingPlugin","name","priority","config","comboLabel","this","resolvePluginLocale","registerStyleSheet","registerNodeSpecs","registerCommand","keymap","Enter","isCollapsed","ctx","getBlockText","blockLength","newBlockId","generateBlockId","splitBlock","createCollapsedSelection","executeCommand","registerKeymap","hashes","repeat","pattern","RegExp","registerInputRule","_match","start","_end","deleteTextAt","registerBlockTypePickerEntry","command","icon","registerToolbarItem","group","tooltip","popupType","separatorAfter","renderPopup","container","list","entries","getBlockTypePickerEntries","entry","active","e","preventDefault","stopPropagation","toolbar","getService","ToolbarServiceKey","closePopup","some","_oldState","_newState","_tr","cachedLabel","getPluginContainer","querySelector","registerNodeSpec","content","allow","node","el","createBlockElement","toHTML","_node","sanitize","tags","default","tag","parseHTML","getAttrs"],"mappings":";;;;;;AA0KA,SAASA,EACRC,IACAC,IACAC,IACAC;AAEA,QAAMC,KAA0BC,SAASC,cAAc,QAAA;AACvDF,EAAAA,GAAKG,OAAO,UACZH,GAAKI,YAAY,gCACjBJ,GAAKK,aAAa,QAAQ,WAC1BL,GAAKK,aAAa,iBAAiBC,OAAOT,EAAAA,CAAAA,GAEtCA,MACHG,GAAKO,UAAUC,IAAI,sCAAA;AAGpB,QAAMC,KAAyBR,SAASC,cAAc;AACtDO,EAAAA,GAAML,YAAY,iCAClBK,GAAMC,cAAcb,KAAW,MAAW,IAC1CG,GAAKW,YAAYF,EAAAA;AAEjB,QAAMG,KAA6BX,SAASC,cAAc,MAAA;AAU1D,SAT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Py.mjs";
|
|
3
|
+
import { e as r, h as i } from "./Document-CI3iCwEP.mjs";
|
|
4
|
+
import { e as n } from "./HTMLUtils-0wvCRvJc.mjs";
|
|
5
|
+
import { a as o, i as a, s as l } from "./Selection-D5ZjXoB7.mjs";
|
|
6
|
+
import { m as s } from "./TypeBrands-C09nE2qO.mjs";
|
|
7
|
+
import { f as p } from "./ToolbarItem-ugDymuXi.mjs";
|
|
8
|
+
const c = { label: "Link", tooltip: (e2) => `Insert Link (${e2})`, removeLink: "Remove Link", removeLinkAria: "Remove link", urlPlaceholder: "https://...", urlAria: "Link URL", apply: "Apply", applyAria: "Apply link" }, m = { en: c, de: { label: "Link", tooltip: (e2) => `Link einfügen (${e2})`, removeLink: "Link entfernen", removeLinkAria: "Link entfernen", urlPlaceholder: "https://...", urlAria: "Link-URL", apply: "Anwenden", applyAria: "Link anwenden" }, es: { label: "Enlace", tooltip: (e2) => `Insertar enlace (${e2})`, removeLink: "Eliminar enlace", removeLinkAria: "Eliminar enlace", urlPlaceholder: "https://...", urlAria: "URL del enlace", apply: "Aplicar", applyAria: "Aplicar enlace" }, fr: { label: "Lien", tooltip: (e2) => `Insérer un lien (${e2})`, removeLink: "Supprimer le lien", removeLinkAria: "Supprimer le lien", urlPlaceholder: "https://...", urlAria: "URL du lien", apply: "Appliquer", applyAria: "Appliquer le lien" }, zh: { label: "链接", tooltip: (e2) => `插入链接 (${e2})`, removeLink: "移除链接", removeLinkAria: "移除链接", urlPlaceholder: "https://...", urlAria: "链接地址", apply: "应用", applyAria: "应用链接" }, ru: { label: "Ссылка", tooltip: (e2) => `Вставить ссылку (${e2})`, removeLink: "Удалить ссылку", removeLinkAria: "Удалить ссылку", urlPlaceholder: "https://...", urlAria: "URL ссылки", apply: "Применить", applyAria: "Применить ссылку" }, ar: { label: "رابط", tooltip: (e2) => `إدراج رابط (${e2})`, removeLink: "إزالة الرابط", removeLinkAria: "إزالة الرابط", urlPlaceholder: "https://...", urlAria: "عنوان الرابط", apply: "تطبيق", applyAria: "تطبيق الرابط" }, hi: { label: "लिंक", tooltip: (e2) => `लिंक डालें (${e2})`, removeLink: "लिंक हटाएँ", removeLinkAria: "लिंक हटाएँ", urlPlaceholder: "https://...", urlAria: "लिंक URL", apply: "लागू करें", applyAria: "लिंक लागू करें" } }, d = { openInNewTab: true };
|
|
9
|
+
class h {
|
|
10
|
+
id = "link";
|
|
11
|
+
name = "Link";
|
|
12
|
+
priority = 25;
|
|
13
|
+
config;
|
|
14
|
+
locale;
|
|
15
|
+
constructor(e2) {
|
|
16
|
+
this.config = { ...d, ...e2 };
|
|
17
|
+
}
|
|
18
|
+
init(e2) {
|
|
19
|
+
this.locale = t(m, e2, this.config.locale), this.registerMarkSpec(e2), this.registerCommands(e2), this.registerKeymap(e2), this.registerToolbarItem(e2);
|
|
20
|
+
}
|
|
21
|
+
registerMarkSpec(e2) {
|
|
22
|
+
const t2 = this.config.openInNewTab;
|
|
23
|
+
e2.registerMarkSpec({ type: "link", rank: 10, attrs: { href: { default: "" } }, toDOM(e3) {
|
|
24
|
+
const r2 = document.createElement("a"), i2 = e3.attrs?.href ?? "";
|
|
25
|
+
return r2.setAttribute("href", i2), t2 && (r2.setAttribute("target", "_blank"), r2.setAttribute("rel", "noopener noreferrer")), r2;
|
|
26
|
+
}, toHTMLString: (e3, t3) => `<a href="${n(String(e3.attrs?.href ?? ""))}">${t3}</a>`, parseHTML: [{ tag: "a", getAttrs: (e3) => ({ href: e3.getAttribute("href") ?? "" }) }], sanitize: { tags: ["a"], attrs: ["href", "target", "rel"] } });
|
|
27
|
+
}
|
|
28
|
+
registerCommands(e2) {
|
|
29
|
+
e2.registerCommand("toggleLink", () => {
|
|
30
|
+
const t2 = e2.getState();
|
|
31
|
+
return this.toggleLink(e2, t2);
|
|
32
|
+
}), e2.registerCommand("setLink", () => false), e2.registerCommand("removeLink", () => {
|
|
33
|
+
const t2 = e2.getState();
|
|
34
|
+
return this.removeLink(e2, t2);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
registerKeymap(e2) {
|
|
38
|
+
e2.registerKeymap({ "Mod-K": () => e2.executeCommand("toggleLink") });
|
|
39
|
+
}
|
|
40
|
+
registerToolbarItem(e2) {
|
|
41
|
+
e2.registerToolbarItem({ id: "link", group: "insert", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>', label: this.locale.label, tooltip: this.locale.tooltip(p("Mod-K")), command: "toggleLink", priority: 60, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (e3, t2, r2) => {
|
|
42
|
+
this.renderLinkPopup(e3, t2, r2);
|
|
43
|
+
}, isActive: (e3) => this.isLinkActive(e3), isEnabled: (e3) => !o(e3.selection) });
|
|
44
|
+
}
|
|
45
|
+
isLinkActive(e2) {
|
|
46
|
+
const t2 = e2.selection;
|
|
47
|
+
if (a(t2)) return false;
|
|
48
|
+
if (o(t2)) {
|
|
49
|
+
const n3 = e2.getBlock(t2.anchor.blockId);
|
|
50
|
+
if (!n3) return false;
|
|
51
|
+
const o2 = r(n3, t2.anchor.offset);
|
|
52
|
+
return i(o2, s("link"));
|
|
53
|
+
}
|
|
54
|
+
const n2 = e2.getBlock(t2.anchor.blockId);
|
|
55
|
+
if (!n2) return false;
|
|
56
|
+
const l2 = r(n2, t2.anchor.offset);
|
|
57
|
+
return i(l2, s("link"));
|
|
58
|
+
}
|
|
59
|
+
toggleLink(e2, t2) {
|
|
60
|
+
return !!this.isLinkActive(t2) && this.removeLink(e2, t2);
|
|
61
|
+
}
|
|
62
|
+
addLink(t2, r2, i2) {
|
|
63
|
+
const n2 = r2.selection;
|
|
64
|
+
if (a(n2)) return false;
|
|
65
|
+
if (o(n2)) return false;
|
|
66
|
+
const p2 = l(n2, r2.getBlockOrder()), c2 = r2.transaction("command"), m2 = { type: s("link"), attrs: { href: i2 } };
|
|
67
|
+
return e(r2, p2, (e2, t3, r3) => {
|
|
68
|
+
c2.addMark(e2, t3, r3, m2);
|
|
69
|
+
}), c2.setSelection(n2), t2.dispatch(c2.build()), true;
|
|
70
|
+
}
|
|
71
|
+
removeLink(t2, r2) {
|
|
72
|
+
const n2 = r2.selection;
|
|
73
|
+
if (a(n2)) return false;
|
|
74
|
+
const p2 = r2.getBlockOrder(), c2 = o(n2) ? { from: n2.anchor, to: n2.anchor } : l(n2, p2), m2 = r2.transaction("command");
|
|
75
|
+
if (o(n2)) {
|
|
76
|
+
const e2 = r2.getBlock(n2.anchor.blockId);
|
|
77
|
+
if (!e2) return false;
|
|
78
|
+
const t3 = [];
|
|
79
|
+
let o2 = 0;
|
|
80
|
+
for (const r3 of e2.children) {
|
|
81
|
+
if (!("text" in r3)) continue;
|
|
82
|
+
const e3 = o2 + r3.text.length;
|
|
83
|
+
t3.push({ pos: o2, end: e3, hasLink: i(r3.marks, s("link")) }), o2 = e3;
|
|
84
|
+
}
|
|
85
|
+
const a2 = t3.findIndex((e3) => n2.anchor.offset >= e3.pos && n2.anchor.offset <= e3.end), l2 = a2 >= 0 ? t3[a2] : void 0;
|
|
86
|
+
if (-1 === a2 || !l2?.hasLink) return false;
|
|
87
|
+
let p3 = a2;
|
|
88
|
+
for (; p3 > 0 && t3[p3 - 1]?.hasLink; ) p3--;
|
|
89
|
+
let c3 = a2;
|
|
90
|
+
for (; c3 < t3.length - 1 && t3[c3 + 1]?.hasLink; ) c3++;
|
|
91
|
+
const d2 = t3[p3], h2 = t3[c3];
|
|
92
|
+
if (!d2 || !h2) return false;
|
|
93
|
+
const u = d2.pos, k = h2.end;
|
|
94
|
+
m2.removeMark(n2.anchor.blockId, u, k, { type: s("link") });
|
|
95
|
+
} else e(r2, c2, (e2, t3, r3) => {
|
|
96
|
+
m2.removeMark(e2, t3, r3, { type: s("link") });
|
|
97
|
+
});
|
|
98
|
+
return m2.setSelection(n2), t2.dispatch(m2.build()), true;
|
|
99
|
+
}
|
|
100
|
+
renderLinkPopup(e2, t2, r2) {
|
|
101
|
+
e2.style.padding = "8px", e2.style.minWidth = "200px";
|
|
102
|
+
const i2 = t2.getState();
|
|
103
|
+
if (this.isLinkActive(i2)) {
|
|
104
|
+
const i3 = document.createElement("button");
|
|
105
|
+
i3.type = "button", i3.textContent = this.locale.removeLink, i3.setAttribute("aria-label", this.locale.removeLinkAria), i3.style.cssText = "width:100%;padding:6px 12px;cursor:pointer;", i3.addEventListener("mousedown", (e3) => {
|
|
106
|
+
e3.preventDefault(), e3.stopPropagation(), t2.executeCommand("removeLink"), r2(), t2.getContainer().focus();
|
|
107
|
+
}), e2.appendChild(i3);
|
|
108
|
+
} else {
|
|
109
|
+
const i3 = document.createElement("input");
|
|
110
|
+
i3.type = "url", i3.placeholder = this.locale.urlPlaceholder, i3.setAttribute("aria-label", this.locale.urlAria), i3.style.cssText = "width:100%;padding:4px;box-sizing:border-box;";
|
|
111
|
+
const n2 = document.createElement("button");
|
|
112
|
+
n2.type = "button", n2.textContent = this.locale.apply, n2.setAttribute("aria-label", this.locale.applyAria), n2.style.cssText = "width:100%;padding:6px 12px;margin-top:4px;cursor:pointer;";
|
|
113
|
+
const o2 = () => {
|
|
114
|
+
const e3 = i3.value.trim();
|
|
115
|
+
e3 && (this.addLink(t2, t2.getState(), e3), r2(), t2.getContainer().focus());
|
|
116
|
+
};
|
|
117
|
+
n2.addEventListener("mousedown", (e3) => {
|
|
118
|
+
e3.preventDefault(), e3.stopPropagation(), o2();
|
|
119
|
+
}), i3.addEventListener("keydown", (e3) => {
|
|
120
|
+
"Enter" === e3.key && (e3.preventDefault(), o2());
|
|
121
|
+
}), e2.appendChild(i3), e2.appendChild(n2), requestAnimationFrame(() => i3.focus());
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
m as L,
|
|
127
|
+
c as a,
|
|
128
|
+
h as b
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=index-Bsp4LC5t.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Bsp4LC5t.mjs","sources":["../../src/plugins/link/LinkLocale.ts","../../src/plugins/link/LinkPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the LinkPlugin.\n */\n\n// --- Locale Interface ---\n\nexport interface LinkLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut: string) => string;\n\treadonly removeLink: string;\n\treadonly removeLinkAria: string;\n\treadonly urlPlaceholder: string;\n\treadonly urlAria: string;\n\treadonly apply: string;\n\treadonly applyAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const LINK_LOCALE_EN: LinkLocale = {\n\tlabel: 'Link',\n\ttooltip: (shortcut: string) => `Insert Link (${shortcut})`,\n\tremoveLink: 'Remove Link',\n\tremoveLinkAria: 'Remove link',\n\turlPlaceholder: 'https://...',\n\turlAria: 'Link URL',\n\tapply: 'Apply',\n\tapplyAria: 'Apply link',\n};\n\n// --- German Locale ---\n\nexport const LINK_LOCALE_DE: LinkLocale = {\n\tlabel: 'Link',\n\ttooltip: (shortcut: string) => `Link einfügen (${shortcut})`,\n\tremoveLink: 'Link entfernen',\n\tremoveLinkAria: 'Link entfernen',\n\turlPlaceholder: 'https://...',\n\turlAria: 'Link-URL',\n\tapply: 'Anwenden',\n\tapplyAria: 'Link anwenden',\n};\n\n// --- Spanish Locale ---\n\nexport const LINK_LOCALE_ES: LinkLocale = {\n\tlabel: 'Enlace',\n\ttooltip: (shortcut: string) => `Insertar enlace (${shortcut})`,\n\tremoveLink: 'Eliminar enlace',\n\tremoveLinkAria: 'Eliminar enlace',\n\turlPlaceholder: 'https://...',\n\turlAria: 'URL del enlace',\n\tapply: 'Aplicar',\n\tapplyAria: 'Aplicar enlace',\n};\n\n// --- French Locale ---\n\nexport const LINK_LOCALE_FR: LinkLocale = {\n\tlabel: 'Lien',\n\ttooltip: (shortcut: string) => `Insérer un lien (${shortcut})`,\n\tremoveLink: 'Supprimer le lien',\n\tremoveLinkAria: 'Supprimer le lien',\n\turlPlaceholder: 'https://...',\n\turlAria: 'URL du lien',\n\tapply: 'Appliquer',\n\tapplyAria: 'Appliquer le lien',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const LINK_LOCALE_ZH: LinkLocale = {\n\tlabel: '链接',\n\ttooltip: (shortcut: string) => `插入链接 (${shortcut})`,\n\tremoveLink: '移除链接',\n\tremoveLinkAria: '移除链接',\n\turlPlaceholder: 'https://...',\n\turlAria: '链接地址',\n\tapply: '应用',\n\tapplyAria: '应用链接',\n};\n\n// --- Russian Locale ---\n\nexport const LINK_LOCALE_RU: LinkLocale = {\n\tlabel: 'Ссылка',\n\ttooltip: (shortcut: string) => `Вставить ссылку (${shortcut})`,\n\tremoveLink: 'Удалить ссылку',\n\tremoveLinkAria: 'Удалить ссылку',\n\turlPlaceholder: 'https://...',\n\turlAria: 'URL ссылки',\n\tapply: 'Применить',\n\tapplyAria: 'Применить ссылку',\n};\n\n// --- Arabic Locale ---\n\nexport const LINK_LOCALE_AR: LinkLocale = {\n\tlabel: 'رابط',\n\ttooltip: (shortcut: string) => `إدراج رابط (${shortcut})`,\n\tremoveLink: 'إزالة الرابط',\n\tremoveLinkAria: 'إزالة الرابط',\n\turlPlaceholder: 'https://...',\n\turlAria: 'عنوان الرابط',\n\tapply: 'تطبيق',\n\tapplyAria: 'تطبيق الرابط',\n};\n\n// --- Hindi Locale ---\n\nexport const LINK_LOCALE_HI: LinkLocale = {\n\tlabel: 'लिंक',\n\ttooltip: (shortcut: string) => `लिंक डालें (${shortcut})`,\n\tremoveLink: 'लिंक हटाएँ',\n\tremoveLinkAria: 'लिंक हटाएँ',\n\turlPlaceholder: 'https://...',\n\turlAria: 'लिंक URL',\n\tapply: 'लागू करें',\n\tapplyAria: 'लिंक लागू करें',\n};\n\n// --- Locale Map ---\n\nexport const LINK_LOCALES: Record<string, LinkLocale> = {\n\ten: LINK_LOCALE_EN,\n\tde: LINK_LOCALE_DE,\n\tes: LINK_LOCALE_ES,\n\tfr: LINK_LOCALE_FR,\n\tzh: LINK_LOCALE_ZH,\n\tru: LINK_LOCALE_RU,\n\tar: LINK_LOCALE_AR,\n\thi: LINK_LOCALE_HI,\n};\n","/**\n * LinkPlugin: registers a link mark type with href attribute,\n * toggle command, keyboard shortcut (Mod-K), and toolbar button\n * with a URL input popup.\n */\n\nimport { forEachBlockInRange } from '../../commands/Commands.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { getBlockMarksAtOffset, hasMark } from '../../model/Document.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport { isCollapsed, isNodeSelection, selectionRange } from '../../model/Selection.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { LINK_LOCALES, type LinkLocale } from './LinkLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tlink: { href: string };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface LinkConfig {\n\t/** Whether to add rel=\"noopener noreferrer\" and target=\"_blank\" by default. */\n\treadonly openInNewTab: boolean;\n\t/** When true, a separator is rendered after the link toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: LinkLocale;\n}\n\nconst DEFAULT_CONFIG: LinkConfig = {\n\topenInNewTab: true,\n};\n\n// --- Plugin ---\n\nexport class LinkPlugin implements Plugin {\n\treadonly id = 'link';\n\treadonly name = 'Link';\n\treadonly priority = 25;\n\n\tprivate readonly config: LinkConfig;\n\tprivate locale!: LinkLocale;\n\n\tconstructor(config?: Partial<LinkConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(LINK_LOCALES, context, this.config.locale);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymap(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tconst openInNewTab = this.config.openInNewTab;\n\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: 'link',\n\t\t\trank: 10,\n\t\t\tattrs: {\n\t\t\t\thref: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(mark) {\n\t\t\t\tconst a = document.createElement('a');\n\t\t\t\tconst href = mark.attrs?.href ?? '';\n\t\t\t\ta.setAttribute('href', href);\n\t\t\t\tif (openInNewTab) {\n\t\t\t\t\ta.setAttribute('target', '_blank');\n\t\t\t\t\ta.setAttribute('rel', 'noopener noreferrer');\n\t\t\t\t}\n\t\t\t\treturn a;\n\t\t\t},\n\t\t\ttoHTMLString: (mark, content) => {\n\t\t\t\tconst href: string = escapeHTML(String(mark.attrs?.href ?? ''));\n\t\t\t\treturn `<a href=\"${href}\">${content}</a>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'a',\n\t\t\t\t\tgetAttrs: (el) => {\n\t\t\t\t\t\tconst href: string = el.getAttribute('href') ?? '';\n\t\t\t\t\t\treturn { href };\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['a'], attrs: ['href', 'target', 'rel'] },\n\t\t});\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('toggleLink', () => {\n\t\t\tconst state = context.getState();\n\t\t\treturn this.toggleLink(context, state);\n\t\t});\n\n\t\tcontext.registerCommand('setLink', () => {\n\t\t\t// setLink is called by the popup after URL input\n\t\t\t// The actual URL is set via the popup's custom render\n\t\t\treturn false;\n\t\t});\n\n\t\tcontext.registerCommand('removeLink', () => {\n\t\t\tconst state = context.getState();\n\t\t\treturn this.removeLink(context, state);\n\t\t});\n\t}\n\n\tprivate registerKeymap(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-K': () => context.executeCommand('toggleLink'),\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z\"/></svg>';\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'link',\n\t\t\tgroup: 'insert',\n\t\t\ticon,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip(formatShortcut('Mod-K')),\n\t\t\tcommand: 'toggleLink',\n\t\t\tpriority: 60,\n\t\t\tpopupType: 'custom',\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\tthis.renderLinkPopup(container, ctx, onClose);\n\t\t\t},\n\t\t\tisActive: (state) => this.isLinkActive(state),\n\t\t\tisEnabled: (state) => !isCollapsed(state.selection),\n\t\t});\n\t}\n\n\tprivate isLinkActive(state: EditorState): boolean {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return false;\n\t\tif (isCollapsed(sel)) {\n\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\tif (!block) return false;\n\t\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\t\treturn hasMark(marks, markType('link'));\n\t\t}\n\n\t\t// Check if link is active anywhere in selection\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return false;\n\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\treturn hasMark(marks, markType('link'));\n\t}\n\n\tprivate toggleLink(context: PluginContext, state: EditorState): boolean {\n\t\tif (this.isLinkActive(state)) {\n\t\t\treturn this.removeLink(context, state);\n\t\t}\n\t\t// Adding links requires the toolbar popup for URL input\n\t\treturn false;\n\t}\n\n\tprivate addLink(context: PluginContext, state: EditorState, href: string): boolean {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return false;\n\t\tif (isCollapsed(sel)) return false;\n\n\t\tconst range = selectionRange(sel, state.getBlockOrder());\n\t\tconst builder = state.transaction('command');\n\t\tconst mark = { type: markType('link'), attrs: { href } };\n\n\t\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\t\tbuilder.addMark(blockId, from, to, mark);\n\t\t});\n\n\t\tbuilder.setSelection(sel);\n\t\tcontext.dispatch(builder.build());\n\t\treturn true;\n\t}\n\n\tprivate removeLink(context: PluginContext, state: EditorState): boolean {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return false;\n\t\tconst blockOrder = state.getBlockOrder();\n\t\tconst range = isCollapsed(sel)\n\t\t\t? { from: sel.anchor, to: sel.anchor }\n\t\t\t: selectionRange(sel, blockOrder);\n\n\t\tconst builder = state.transaction('command');\n\n\t\tif (isCollapsed(sel)) {\n\t\t\t// Remove link from entire link span around cursor\n\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\tif (!block) return false;\n\n\t\t\t// Find the extent of the link mark around the cursor.\n\t\t\t// Build a list of text children with their positions first,\n\t\t\t// then scan backward and forward from the cursor node.\n\t\t\tconst textChildren: { pos: number; end: number; hasLink: boolean }[] = [];\n\t\t\tlet pos = 0;\n\t\t\tfor (const child of block.children) {\n\t\t\t\tif (!('text' in child)) continue;\n\t\t\t\tconst end = pos + child.text.length;\n\t\t\t\ttextChildren.push({ pos, end, hasLink: hasMark(child.marks, markType('link')) });\n\t\t\t\tpos = end;\n\t\t\t}\n\n\t\t\t// Find the text child containing the cursor\n\t\t\tconst cursorIdx = textChildren.findIndex(\n\t\t\t\t(c) => sel.anchor.offset >= c.pos && sel.anchor.offset <= c.end,\n\t\t\t);\n\t\t\tconst cursorEntry = cursorIdx >= 0 ? textChildren[cursorIdx] : undefined;\n\t\t\tif (cursorIdx === -1 || !cursorEntry?.hasLink) return false;\n\n\t\t\t// Scan backward from cursor node to find link start\n\t\t\tlet startIdx = cursorIdx;\n\t\t\twhile (startIdx > 0 && textChildren[startIdx - 1]?.hasLink) {\n\t\t\t\tstartIdx--;\n\t\t\t}\n\n\t\t\t// Scan forward from cursor node to find link end\n\t\t\tlet endIdx = cursorIdx;\n\t\t\twhile (endIdx < textChildren.length - 1 && textChildren[endIdx + 1]?.hasLink) {\n\t\t\t\tendIdx++;\n\t\t\t}\n\n\t\t\tconst startEntry = textChildren[startIdx];\n\t\t\tconst endEntry = textChildren[endIdx];\n\t\t\tif (!startEntry || !endEntry) return false;\n\n\t\t\tconst linkStart = startEntry.pos;\n\t\t\tconst linkEnd = endEntry.end;\n\n\t\t\tbuilder.removeMark(sel.anchor.blockId, linkStart, linkEnd, { type: markType('link') });\n\t\t} else {\n\t\t\t// Remove link from selection range\n\t\t\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\t\t\tbuilder.removeMark(blockId, from, to, { type: markType('link') });\n\t\t\t});\n\t\t}\n\n\t\tbuilder.setSelection(sel);\n\t\tcontext.dispatch(builder.build());\n\t\treturn true;\n\t}\n\n\tprivate renderLinkPopup(\n\t\tcontainer: HTMLElement,\n\t\tcontext: PluginContext,\n\t\tonClose: () => void,\n\t): void {\n\t\tcontainer.style.padding = '8px';\n\t\tcontainer.style.minWidth = '200px';\n\n\t\tconst state = context.getState();\n\t\tconst isActive = this.isLinkActive(state);\n\n\t\tif (isActive) {\n\t\t\t// Show remove link button\n\t\t\tconst removeBtn = document.createElement('button');\n\t\t\tremoveBtn.type = 'button';\n\t\t\tremoveBtn.textContent = this.locale.removeLink;\n\t\t\tremoveBtn.setAttribute('aria-label', this.locale.removeLinkAria);\n\t\t\tremoveBtn.style.cssText = 'width:100%;padding:6px 12px;cursor:pointer;';\n\t\t\tremoveBtn.addEventListener('mousedown', (e) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tcontext.executeCommand('removeLink');\n\t\t\t\tonClose();\n\t\t\t\tcontext.getContainer().focus();\n\t\t\t});\n\t\t\tcontainer.appendChild(removeBtn);\n\t\t} else {\n\t\t\t// Show URL input\n\t\t\tconst input = document.createElement('input');\n\t\t\tinput.type = 'url';\n\t\t\tinput.placeholder = this.locale.urlPlaceholder;\n\t\t\tinput.setAttribute('aria-label', this.locale.urlAria);\n\t\t\tinput.style.cssText = 'width:100%;padding:4px;box-sizing:border-box;';\n\n\t\t\tconst applyBtn = document.createElement('button');\n\t\t\tapplyBtn.type = 'button';\n\t\t\tapplyBtn.textContent = this.locale.apply;\n\t\t\tapplyBtn.setAttribute('aria-label', this.locale.applyAria);\n\t\t\tapplyBtn.style.cssText = 'width:100%;padding:6px 12px;margin-top:4px;cursor:pointer;';\n\n\t\t\tconst applyLink = (): void => {\n\t\t\t\tconst href = input.value.trim();\n\t\t\t\tif (href) {\n\t\t\t\t\tthis.addLink(context, context.getState(), href);\n\t\t\t\t\tonClose();\n\t\t\t\t\tcontext.getContainer().focus();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tapplyBtn.addEventListener('mousedown', (e) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tapplyLink();\n\t\t\t});\n\n\t\t\tinput.addEventListener('keydown', (e) => {\n\t\t\t\tif (e.key === 'Enter') {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tapplyLink();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tcontainer.appendChild(input);\n\t\t\tcontainer.appendChild(applyBtn);\n\n\t\t\t// Auto-focus input\n\t\t\trequestAnimationFrame(() => input.focus());\n\t\t}\n\t}\n}\n"],"names":["LINK_LOCALE_EN","label","tooltip","shortcut","removeLink","removeLinkAria","urlPlaceholder","urlAria","apply","applyAria","LINK_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","openInNewTab","LinkPlugin","id","name","priority","config","locale","this","context","resolvePluginLocale","registerMarkSpec","registerCommands","registerKeymap","registerToolbarItem","type","rank","attrs","href","default","mark","a","document","createElement","setAttribute","toHTMLString","content","escapeHTML","String","parseHTML","tag","getAttrs","el","getAttribute","sanitize","tags","registerCommand","state","getState","toggleLink","executeCommand","group","icon","formatShortcut","command","popupType","separatorAfter","renderPopup","container","ctx","onClose","renderLinkPopup","isActive","isLinkActive","isEnabled","isCollapsed","selection","sel","isNodeSelection","block","getBlock","anchor","blockId","marks","getBlockMarksAtOffset","offset","hasMark","markType","range","selectionRange","getBlockOrder","builder","transaction","forEachBlockInRange","from","to","addMark","setSelection","dispatch","build","blockOrder","textChildren","pos","child","children","end","text","length","push","hasLink","cursorIdx","findIndex","c","cursorEntry","startIdx","endIdx","startEntry","endEntry","linkStart","linkEnd","removeMark","style","padding","minWidth","removeBtn","textContent","cssText","addEventListener","e","preventDefault","stopPropagation","getContainer","focus","appendChild","input","placeholder","applyBtn","applyLink","value","trim","addLink","key","requestAnimationFrame"],"mappings":";;;;;;;AAmBO,MAAMA,IAA6B,EACzCC,OAAO,QACPC,SAAUC,CAAAA,OAAqB,gBAAgBA,EAAAA,KAC/CC,YAAY,eACZC,gBAAgB,eAChBC,gBAAgB,eAChBC,SAAS,YACTC,OAAO,SACPC,WAAW,aAAA,GAgGCC,IAA2C,EACvDC,IAAIX,GACJY,IA7FyC,EACzCX,OAAO,QACPC,SAAUC,CAAAA,OAAqB,kBAAkBA,EAAAA,KACjDC,YAAY,kBACZC,gBAAgB,kBAChBC,gBAAgB,eAChBC,SAAS,YACTC,OAAO,YACPC,WAAW,gBAAA,GAsFXI,IAj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