@notectl/core 1.0.5 → 1.0.8
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 -55
- 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-D5VqeBPT.mjs → ToolbarPlugin-DY2xaJiu.mjs} +63 -93
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +1 -0
- package/dist/chunks/index-BAk1EG1x.mjs +541 -0
- package/dist/chunks/index-BAk1EG1x.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-BYgspns5.mjs +209 -0
- package/dist/chunks/index-BYgspns5.mjs.map +1 -0
- package/dist/chunks/index-B_3qDrUN.mjs +64 -0
- package/dist/chunks/index-B_3qDrUN.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-C-YWHOcC.mjs +100 -0
- package/dist/chunks/index-C-YWHOcC.mjs.map +1 -0
- package/dist/chunks/index-C2GQoHot.mjs +92 -0
- package/dist/chunks/index-C2GQoHot.mjs.map +1 -0
- package/dist/chunks/index-CT3HGdQt.mjs +39 -0
- package/dist/chunks/index-CT3HGdQt.mjs.map +1 -0
- package/dist/chunks/index-Ct0ivLhO.mjs +407 -0
- package/dist/chunks/index-Ct0ivLhO.mjs.map +1 -0
- package/dist/chunks/index-CxiWyUho.mjs +191 -0
- package/dist/chunks/index-CxiWyUho.mjs.map +1 -0
- package/dist/chunks/index-D3CQWJiw.mjs +200 -0
- package/dist/chunks/index-D3CQWJiw.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-Dh76rR13.mjs +196 -0
- package/dist/chunks/index-Dh76rR13.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/EditorDOM.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +15 -1
- 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/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 +44 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/notectl-core.mjs +1145 -837
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +2368 -1826
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +8 -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/CodeBlockCommands.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts +10 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -0
- 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/CodeBlockNodeView.d.ts +1 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +4 -111
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockService.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +71 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -0
- 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/FontSizeOperations.d.ts +22 -0
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +4 -10
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts +11 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -0
- package/dist/plugins/font-size.mjs +2 -217
- 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/HeadingLocale.d.ts +26 -0
- package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +4 -0
- 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/ImageNodeView.d.ts.map +1 -1
- 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 +4 -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/PrintContentPreparer.d.ts +12 -0
- package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -0
- 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 +13 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts +7 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts +17 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -0
- package/dist/plugins/print/PrintTypes.d.ts +61 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -0
- 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 +14 -0
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -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/view/EditorView.d.ts.map +1 -1
- package/dist/view/Reconciler.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-D5VqeBPT.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-CPPb-Jah.mjs +0 -569
- package/dist/chunks/index-CPPb-Jah.mjs.map +0 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { r as t } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
2
|
+
import { a as e } from "./ToolbarPlugin-DY2xaJiu.mjs";
|
|
3
|
+
import { f as n } from "./Commands-CSpSwGXv.mjs";
|
|
4
|
+
import { i as o } from "./AttrRegistry-D-przlzb.mjs";
|
|
5
|
+
import { e as i, h as r } from "./Document-CI3iCwEP.mjs";
|
|
6
|
+
import { i as s, a, s as l } from "./Selection-D5ZjXoB7.mjs";
|
|
7
|
+
import { m as c } from "./TypeBrands-C09nE2qO.mjs";
|
|
8
|
+
const p = { label: "Font Size", tooltip: "Font Size", customFontSizeAria: "Custom font size", fontSizesAria: "Font sizes" }, f = { en: p, de: { label: "Schriftgröße", tooltip: "Schriftgröße", customFontSizeAria: "Benutzerdefinierte Schriftgröße", fontSizesAria: "Schriftgrößen" }, es: { label: "Tamaño de fuente", tooltip: "Tamaño de fuente", customFontSizeAria: "Tamaño de fuente personalizado", fontSizesAria: "Tamaños de fuente" }, fr: { label: "Taille de police", tooltip: "Taille de police", customFontSizeAria: "Taille de police personnalisée", fontSizesAria: "Tailles de police" }, zh: { label: "字号", tooltip: "字号", customFontSizeAria: "自定义字号", fontSizesAria: "字号列表" }, ru: { label: "Размер шрифта", tooltip: "Размер шрифта", customFontSizeAria: "Произвольный размер шрифта", fontSizesAria: "Размеры шрифта" }, ar: { label: "حجم الخط", tooltip: "حجم الخط", customFontSizeAria: "حجم خط مخصص", fontSizesAria: "أحجام الخط" }, hi: { label: "फ़ॉन्ट आकार", tooltip: "फ़ॉन्ट आकार", customFontSizeAria: "कस्टम फ़ॉन्ट आकार", fontSizesAria: "फ़ॉन्ट आकार सूची" } };
|
|
9
|
+
function u(t2) {
|
|
10
|
+
const e2 = t2.selection;
|
|
11
|
+
if (s(e2)) return null;
|
|
12
|
+
if (a(e2) && t2.storedMarks) return h(t2.storedMarks);
|
|
13
|
+
const n2 = t2.getBlock(e2.anchor.blockId);
|
|
14
|
+
return n2 ? h(i(n2, e2.anchor.offset)) : null;
|
|
15
|
+
}
|
|
16
|
+
function d(t2, e2) {
|
|
17
|
+
const n2 = u(t2);
|
|
18
|
+
if (!n2) return e2;
|
|
19
|
+
const o2 = Number.parseInt(n2, 10);
|
|
20
|
+
return Number.isNaN(o2) ? e2 : o2;
|
|
21
|
+
}
|
|
22
|
+
function m(t2, e2, o2) {
|
|
23
|
+
const r2 = e2.selection;
|
|
24
|
+
if (s(r2)) return false;
|
|
25
|
+
if (a(r2)) {
|
|
26
|
+
const n2 = e2.getBlock(r2.anchor.blockId);
|
|
27
|
+
if (!n2) return false;
|
|
28
|
+
const s2 = [...(e2.storedMarks ?? i(n2, r2.anchor.offset)).filter((t3) => "fontSize" !== t3.type), { type: c("fontSize"), attrs: { size: o2 } }], a2 = e2.transaction("command").setStoredMarks(s2, e2.storedMarks).setSelection(r2).build();
|
|
29
|
+
return t2.dispatch(a2), true;
|
|
30
|
+
}
|
|
31
|
+
const p2 = l(r2, e2.getBlockOrder()), f2 = e2.transaction("command"), u2 = { type: c("fontSize"), attrs: { size: o2 } };
|
|
32
|
+
return n(e2, p2, (t3, e3, n2) => {
|
|
33
|
+
f2.removeMark(t3, e3, n2, { type: c("fontSize") }), f2.addMark(t3, e3, n2, u2);
|
|
34
|
+
}), f2.setSelection(r2), t2.dispatch(f2.build()), true;
|
|
35
|
+
}
|
|
36
|
+
function z(t2, e2) {
|
|
37
|
+
const o2 = e2.selection;
|
|
38
|
+
if (s(o2)) return false;
|
|
39
|
+
if (a(o2)) {
|
|
40
|
+
const n2 = e2.getBlock(o2.anchor.blockId);
|
|
41
|
+
if (!n2) return false;
|
|
42
|
+
const s2 = e2.storedMarks ?? i(n2, o2.anchor.offset);
|
|
43
|
+
if (!r(s2, c("fontSize"))) return false;
|
|
44
|
+
const a2 = s2.filter((t3) => "fontSize" !== t3.type), l2 = e2.transaction("command").setStoredMarks(a2, e2.storedMarks).setSelection(o2).build();
|
|
45
|
+
return t2.dispatch(l2), true;
|
|
46
|
+
}
|
|
47
|
+
const p2 = l(o2, e2.getBlockOrder()), f2 = e2.transaction("command");
|
|
48
|
+
return n(e2, p2, (t3, e3, n2) => {
|
|
49
|
+
f2.removeMark(t3, e3, n2, { type: c("fontSize") });
|
|
50
|
+
}), f2.setSelection(o2), t2.dispatch(f2.build()), true;
|
|
51
|
+
}
|
|
52
|
+
function b(t2, e2, n2, o2, i2) {
|
|
53
|
+
const r2 = (function(t3, e3, n3) {
|
|
54
|
+
if ("up" === e3) {
|
|
55
|
+
for (const e4 of n3) if (e4 > t3) return e4;
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
for (let e4 = n3.length - 1; e4 >= 0; e4--) {
|
|
59
|
+
const o3 = n3[e4];
|
|
60
|
+
if (void 0 !== o3 && o3 < t3) return o3;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
})(d(e2, i2), n2, o2);
|
|
64
|
+
return null !== r2 && (r2 === i2 ? z(t2, e2) : m(t2, e2, `${r2}px`));
|
|
65
|
+
}
|
|
66
|
+
function g(t2, e2, n2) {
|
|
67
|
+
e2 === n2 ? t2.executeCommand("removeFontSize") : m(t2, t2.getState(), `${e2}px`);
|
|
68
|
+
}
|
|
69
|
+
function h(t2) {
|
|
70
|
+
const e2 = t2.find((t3) => "fontSize" === t3.type);
|
|
71
|
+
return e2 && o(e2, "fontSize") ? e2.attrs.size ?? null : null;
|
|
72
|
+
}
|
|
73
|
+
function S(t2, e2) {
|
|
74
|
+
const n2 = document.createElement("button");
|
|
75
|
+
n2.type = "button", n2.id = `notectl-font-size-option-${t2}`, n2.className = "notectl-font-size-picker__item", n2.setAttribute("role", "option"), n2.setAttribute("aria-selected", String(e2)), e2 && n2.classList.add("notectl-font-size-picker__item--active");
|
|
76
|
+
const o2 = document.createElement("span");
|
|
77
|
+
o2.className = "notectl-font-size-picker__check", o2.textContent = e2 ? "✓" : "", n2.appendChild(o2);
|
|
78
|
+
const i2 = document.createElement("span");
|
|
79
|
+
return i2.className = "notectl-font-size-picker__label", i2.textContent = String(t2), n2.appendChild(i2), n2;
|
|
80
|
+
}
|
|
81
|
+
const k = [8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96];
|
|
82
|
+
class v {
|
|
83
|
+
id = "fontSize";
|
|
84
|
+
name = "Font Size";
|
|
85
|
+
priority = 21;
|
|
86
|
+
config;
|
|
87
|
+
sizes;
|
|
88
|
+
defaultSize;
|
|
89
|
+
locale;
|
|
90
|
+
context = null;
|
|
91
|
+
comboLabel = null;
|
|
92
|
+
constructor(t2) {
|
|
93
|
+
var e2;
|
|
94
|
+
this.config = { ...t2 }, this.sizes = (function(t3) {
|
|
95
|
+
if (!t3 || 0 === t3.length) return k;
|
|
96
|
+
const e3 = [...new Set(t3)].filter((t4) => Number.isInteger(t4) && t4 > 0);
|
|
97
|
+
return e3.sort((t4, e4) => t4 - e4), e3.length > 0 ? e3 : k;
|
|
98
|
+
})(t2?.sizes), this.defaultSize = (e2 = t2?.defaultSize, void 0 === e2 ? 16 : Number.isInteger(e2) && e2 > 0 ? e2 : 16);
|
|
99
|
+
}
|
|
100
|
+
init(e2) {
|
|
101
|
+
this.locale = t(f, e2, this.config.locale), e2.registerStyleSheet("\n/* Font Size Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--fontSize {\n width: auto;\n min-width: 60px;\n max-width: 80px;\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--fontSize:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--fontSize.notectl-toolbar-btn--active {\n background: var(--notectl-bg);\n border-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--fontSize .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--fontSize .notectl-toolbar-btn__icon svg {\n display: none;\n}\n\n.notectl-font-size-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-font-size-select__arrow {\n flex-shrink: 0;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n line-height: 30px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n min-width: 140px;\n display: flex;\n flex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n padding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n font-size: 13px;\n font-family: inherit;\n color: var(--notectl-fg);\n background: var(--notectl-bg);\n outline: none;\n box-sizing: border-box;\n -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 -webkit-appearance: none;\n margin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n border-color: var(--notectl-border-focus);\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n max-height: 280px;\n overflow-y: auto;\n padding: 4px 0;\n}\n\n.notectl-font-size-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 line-height: 1.4;\n text-align: left;\n white-space: nowrap;\n font-family: inherit;\n transition: background 0.1s;\n outline: none;\n}\n\n.notectl-font-size-picker__item:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-font-size-picker__item--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-font-size-picker__item--active:hover {\n background: var(--notectl-active-bg);\n}\n\n.notectl-font-size-picker__item--focused {\n outline: 2px solid var(--notectl-primary);\n outline-offset: -2px;\n}\n\n.notectl-font-size-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-font-size-picker__label {\n flex: 1;\n}\n"), this.context = e2, this.registerMarkSpec(e2), this.registerCommands(e2), this.registerKeymaps(e2), this.registerToolbarItem(e2), this.applyDefaultSizeToContainer(e2);
|
|
102
|
+
}
|
|
103
|
+
destroy() {
|
|
104
|
+
this.context = null, this.comboLabel = null;
|
|
105
|
+
}
|
|
106
|
+
onStateChange(t2, e2, n2) {
|
|
107
|
+
this.updateComboLabel(e2);
|
|
108
|
+
}
|
|
109
|
+
registerMarkSpec(t2) {
|
|
110
|
+
t2.registerMarkSpec({ type: "fontSize", rank: 4, attrs: { size: { default: "" } }, toDOM(t3) {
|
|
111
|
+
const e2 = document.createElement("span"), n2 = t3.attrs?.size ?? "";
|
|
112
|
+
return n2 && (e2.style.fontSize = n2), e2;
|
|
113
|
+
}, toHTMLString: (t3, e2) => {
|
|
114
|
+
const n2 = String(t3.attrs?.size ?? "");
|
|
115
|
+
return n2 ? `<span style="font-size: ${n2}">${e2}</span>` : e2;
|
|
116
|
+
}, parseHTML: [{ tag: "span", getAttrs: (t3) => {
|
|
117
|
+
const e2 = t3.style.fontSize;
|
|
118
|
+
return !!e2 && { size: e2 };
|
|
119
|
+
} }], sanitize: { tags: ["span"] } });
|
|
120
|
+
}
|
|
121
|
+
registerCommands(t2) {
|
|
122
|
+
t2.registerCommand("removeFontSize", () => z(t2, t2.getState())), t2.registerCommand("setFontSize", () => false), t2.registerCommand("increaseFontSize", () => b(t2, t2.getState(), "up", this.sizes, this.defaultSize)), t2.registerCommand("decreaseFontSize", () => b(t2, t2.getState(), "down", this.sizes, this.defaultSize));
|
|
123
|
+
}
|
|
124
|
+
registerKeymaps(t2) {
|
|
125
|
+
t2.registerKeymap({ "Mod-Shift-+": () => b(t2, t2.getState(), "up", this.sizes, this.defaultSize), "Mod-Shift-_": () => b(t2, t2.getState(), "down", this.sizes, this.defaultSize) });
|
|
126
|
+
}
|
|
127
|
+
registerToolbarItem(t2) {
|
|
128
|
+
const e2 = `<span class="notectl-font-size-select__label" data-font-size-label>${this.defaultSize}</span><span class="notectl-font-size-select__arrow">▾</span>`;
|
|
129
|
+
t2.registerToolbarItem({ id: "fontSize", group: "format", icon: e2, label: this.locale.label, tooltip: this.locale.tooltip, command: "removeFontSize", priority: 6, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, e3) => {
|
|
130
|
+
!(function(t4, e4, n2) {
|
|
131
|
+
t4.classList.add("notectl-font-size-picker");
|
|
132
|
+
const o2 = d(e4.getState(), n2.defaultSize), i2 = (function(t5, e5) {
|
|
133
|
+
const n3 = document.createElement("input");
|
|
134
|
+
return n3.type = "number", n3.className = "notectl-font-size-picker__input", n3.min = String(1), n3.max = String(400), n3.value = String(t5), n3.setAttribute("aria-label", e5.locale?.customFontSizeAria ?? "Custom font size"), n3;
|
|
135
|
+
})(o2, n2);
|
|
136
|
+
!(function(t5, e5) {
|
|
137
|
+
const n3 = document.createElement("div");
|
|
138
|
+
n3.className = "notectl-font-size-picker__input-wrapper", n3.appendChild(e5), t5.appendChild(n3);
|
|
139
|
+
})(t4, i2);
|
|
140
|
+
const { list: r2, items: s2 } = (function(t5, e5, n3, o3) {
|
|
141
|
+
const i3 = document.createElement("div");
|
|
142
|
+
i3.className = "notectl-font-size-picker__list", i3.setAttribute("role", "listbox"), i3.setAttribute("aria-label", o3.locale?.fontSizesAria ?? "Font sizes");
|
|
143
|
+
const r3 = [];
|
|
144
|
+
for (const s3 of t5) {
|
|
145
|
+
const t6 = S(s3, s3 === e5);
|
|
146
|
+
t6.addEventListener("mousedown", (t7) => {
|
|
147
|
+
t7.preventDefault(), t7.stopPropagation(), g(n3, s3, o3.defaultSize), o3.dismissPopup();
|
|
148
|
+
}), r3.push(t6), i3.appendChild(t6);
|
|
149
|
+
}
|
|
150
|
+
return { list: i3, items: r3 };
|
|
151
|
+
})(n2.sizes, o2, e4, n2);
|
|
152
|
+
t4.appendChild(r2), (function(t5, e5, n3, o3) {
|
|
153
|
+
const i3 = e5.indexOf(n3);
|
|
154
|
+
if (i3 < 0) return;
|
|
155
|
+
const r3 = t5[i3];
|
|
156
|
+
r3 && (requestAnimationFrame(() => {
|
|
157
|
+
r3.scrollIntoView({ block: "nearest" });
|
|
158
|
+
}), o3.setAttribute("aria-activedescendant", r3.id));
|
|
159
|
+
})(s2, n2.sizes, o2, r2), (function(t5, e5, n3, o3, i3) {
|
|
160
|
+
let r3 = -1;
|
|
161
|
+
const s3 = (t6) => {
|
|
162
|
+
r3 >= 0 && r3 < n3.length && n3[r3]?.classList.remove("notectl-font-size-picker__item--focused"), r3 = t6;
|
|
163
|
+
const o4 = n3[r3];
|
|
164
|
+
r3 >= 0 && r3 < n3.length && o4 && (o4.classList.add("notectl-font-size-picker__item--focused"), o4.scrollIntoView({ block: "nearest" }), e5.setAttribute("aria-activedescendant", o4.id));
|
|
165
|
+
};
|
|
166
|
+
t5.addEventListener("keydown", (e6) => {
|
|
167
|
+
if ("Enter" === e6.key) {
|
|
168
|
+
e6.preventDefault();
|
|
169
|
+
const n4 = Number.parseInt(t5.value, 10);
|
|
170
|
+
!Number.isNaN(n4) && n4 >= 1 && n4 <= 400 && (g(o3, n4, i3.defaultSize), i3.dismissPopup());
|
|
171
|
+
} else "ArrowDown" === e6.key ? (e6.preventDefault(), s3(0), n3[0]?.focus()) : "Escape" === e6.key && (e6.preventDefault(), i3.dismissPopup());
|
|
172
|
+
}), e5.addEventListener("keydown", (e6) => {
|
|
173
|
+
if ("ArrowDown" === e6.key) e6.preventDefault(), r3 < n3.length - 1 && (s3(r3 + 1), n3[r3]?.focus());
|
|
174
|
+
else if ("ArrowUp" === e6.key) e6.preventDefault(), r3 > 0 ? (s3(r3 - 1), n3[r3]?.focus()) : (s3(-1), t5.focus());
|
|
175
|
+
else if ("Enter" === e6.key) {
|
|
176
|
+
e6.preventDefault();
|
|
177
|
+
const t6 = i3.sizes[r3];
|
|
178
|
+
r3 >= 0 && r3 < i3.sizes.length && void 0 !== t6 && (g(o3, t6, i3.defaultSize), i3.dismissPopup());
|
|
179
|
+
} else "Escape" === e6.key && (e6.preventDefault(), i3.dismissPopup());
|
|
180
|
+
});
|
|
181
|
+
})(i2, r2, s2, e4, n2);
|
|
182
|
+
})(t3, e3, { sizes: this.sizes, defaultSize: this.defaultSize, dismissPopup: () => this.dismissPopup(), locale: this.locale });
|
|
183
|
+
}, isActive: (t3) => (function(t4) {
|
|
184
|
+
return null !== u(t4);
|
|
185
|
+
})(t3) });
|
|
186
|
+
}
|
|
187
|
+
applyDefaultSizeToContainer(t2) {
|
|
188
|
+
t2.getContainer().style.fontSize = `${this.defaultSize}px`;
|
|
189
|
+
}
|
|
190
|
+
dismissPopup() {
|
|
191
|
+
const t2 = this.context?.getService(e);
|
|
192
|
+
t2?.closePopup();
|
|
193
|
+
}
|
|
194
|
+
updateComboLabel(t2) {
|
|
195
|
+
if (!this.comboLabel) {
|
|
196
|
+
const t3 = this.context?.getPluginContainer("top");
|
|
197
|
+
if (!t3) return;
|
|
198
|
+
if (this.comboLabel = t3.querySelector("[data-font-size-label]") ?? null, !this.comboLabel) return;
|
|
199
|
+
}
|
|
200
|
+
const e2 = d(t2, this.defaultSize);
|
|
201
|
+
this.comboLabel.textContent = String(e2);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
export {
|
|
205
|
+
f as F,
|
|
206
|
+
p as a,
|
|
207
|
+
v as b
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=index-BYgspns5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BYgspns5.mjs","sources":["../../src/editor/styles/font-size-select.ts","../../src/plugins/font-size/FontSizeLocale.ts","../../src/plugins/font-size/FontSizeOperations.ts","../../src/plugins/font-size/FontSizePopup.ts","../../src/plugins/font-size/FontSizePlugin.ts"],"sourcesContent":["/** Font size picker toolbar combobox + popup styles. */\nexport const FONT_SIZE_SELECT_CSS = `\n/* Font Size Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--fontSize {\n\twidth: auto;\n\tmin-width: 60px;\n\tmax-width: 80px;\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--fontSize:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--fontSize.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-bg);\n\tborder-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--fontSize .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--fontSize .notectl-toolbar-btn__icon svg {\n\tdisplay: none;\n}\n\n.notectl-font-size-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-font-size-select__arrow {\n\tflex-shrink: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tline-height: 30px;\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`;\n","/** Locale interface and default English locale for the FontSizePlugin. */\n\n// --- Locale Interface ---\n\nexport interface FontSizeLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly customFontSizeAria: string;\n\treadonly fontSizesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_SIZE_LOCALE_EN: FontSizeLocale = {\n\tlabel: 'Font Size',\n\ttooltip: 'Font Size',\n\tcustomFontSizeAria: 'Custom font size',\n\tfontSizesAria: 'Font sizes',\n};\n\n// --- German Locale ---\n\nexport const FONT_SIZE_LOCALE_DE: FontSizeLocale = {\n\tlabel: 'Schriftgröße',\n\ttooltip: 'Schriftgröße',\n\tcustomFontSizeAria: 'Benutzerdefinierte Schriftgröße',\n\tfontSizesAria: 'Schriftgrößen',\n};\n\n// --- Spanish Locale ---\n\nexport const FONT_SIZE_LOCALE_ES: FontSizeLocale = {\n\tlabel: 'Tamaño de fuente',\n\ttooltip: 'Tamaño de fuente',\n\tcustomFontSizeAria: 'Tamaño de fuente personalizado',\n\tfontSizesAria: 'Tamaños de fuente',\n};\n\n// --- French Locale ---\n\nexport const FONT_SIZE_LOCALE_FR: FontSizeLocale = {\n\tlabel: 'Taille de police',\n\ttooltip: 'Taille de police',\n\tcustomFontSizeAria: 'Taille de police personnalisée',\n\tfontSizesAria: 'Tailles de police',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const FONT_SIZE_LOCALE_ZH: FontSizeLocale = {\n\tlabel: '字号',\n\ttooltip: '字号',\n\tcustomFontSizeAria: '自定义字号',\n\tfontSizesAria: '字号列表',\n};\n\n// --- Russian Locale ---\n\nexport const FONT_SIZE_LOCALE_RU: FontSizeLocale = {\n\tlabel: 'Размер шрифта',\n\ttooltip: 'Размер шрифта',\n\tcustomFontSizeAria: 'Произвольный размер шрифта',\n\tfontSizesAria: 'Размеры шрифта',\n};\n\n// --- Arabic Locale ---\n\nexport const FONT_SIZE_LOCALE_AR: FontSizeLocale = {\n\tlabel: 'حجم الخط',\n\ttooltip: 'حجم الخط',\n\tcustomFontSizeAria: 'حجم خط مخصص',\n\tfontSizesAria: 'أحجام الخط',\n};\n\n// --- Hindi Locale ---\n\nexport const FONT_SIZE_LOCALE_HI: FontSizeLocale = {\n\tlabel: 'फ़ॉन्ट आकार',\n\ttooltip: 'फ़ॉन्ट आकार',\n\tcustomFontSizeAria: 'कस्टम फ़ॉन्ट आकार',\n\tfontSizesAria: 'फ़ॉन्ट आकार सूची',\n};\n\n// --- Locale Map ---\n\nexport const FONT_SIZE_LOCALES: Record<string, FontSizeLocale> = {\n\ten: FONT_SIZE_LOCALE_EN,\n\tde: FONT_SIZE_LOCALE_DE,\n\tes: FONT_SIZE_LOCALE_ES,\n\tfr: FONT_SIZE_LOCALE_FR,\n\tzh: FONT_SIZE_LOCALE_ZH,\n\tru: FONT_SIZE_LOCALE_RU,\n\tar: FONT_SIZE_LOCALE_AR,\n\thi: FONT_SIZE_LOCALE_HI,\n};\n","/**\n * Pure business logic for font-size state queries and transaction builders.\n * All functions are DOM-free and operate on EditorState / PluginContext.\n */\n\nimport { forEachBlockInRange } from '../../commands/Commands.js';\nimport { isMarkOfType } from '../../model/AttrRegistry.js';\nimport type { Mark } from '../../model/Document.js';\nimport { getBlockMarksAtOffset, hasMark } from '../../model/Document.js';\nimport { isCollapsed, isNodeSelection, selectionRange } from '../../model/Selection.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\n\n// --- State Queries ---\n\n/** Returns the raw fontSize CSS value at the current selection, or null. */\nexport function getActiveSize(state: EditorState): string | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return null;\n\n\tif (isCollapsed(sel) && state.storedMarks) {\n\t\treturn extractFontSize(state.storedMarks);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\treturn extractFontSize(getBlockMarksAtOffset(block, sel.anchor.offset));\n}\n\n/** Returns the active font size as a number, falling back to defaultSize. */\nexport function getActiveSizeNumeric(state: EditorState, defaultSize: number): number {\n\tconst raw: string | null = getActiveSize(state);\n\tif (!raw) return defaultSize;\n\tconst parsed: number = Number.parseInt(raw, 10);\n\treturn Number.isNaN(parsed) ? defaultSize : parsed;\n}\n\n/** Returns true when the selection carries a fontSize mark. */\nexport function isFontSizeActive(state: EditorState): boolean {\n\treturn getActiveSize(state) !== null;\n}\n\n// --- Commands ---\n\n/** Applies a fontSize mark with the given CSS size string to the selection. */\nexport function applyFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return false;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tconst withoutSize = currentMarks.filter((m) => m.type !== 'fontSize');\n\t\tconst newMarks = [...withoutSize, { type: markType('fontSize'), attrs: { size } }];\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\tconst mark = { type: markType('fontSize'), attrs: { size } };\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tbuilder.removeMark(blockId, from, to, { type: markType('fontSize') });\n\t\tbuilder.addMark(blockId, from, to, mark);\n\t});\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** Removes the fontSize mark from the current selection. */\nexport function removeFontSize(context: PluginContext, state: EditorState): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return false;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tif (!hasMark(currentMarks, markType('fontSize'))) return false;\n\n\t\tconst newMarks = currentMarks.filter((m) => m.type !== 'fontSize');\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tbuilder.removeMark(blockId, from, to, { type: markType('fontSize') });\n\t});\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** Steps the font size up or down through the preset list. */\nexport function stepFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n\tdefaultSize: number,\n): boolean {\n\tconst current: number = getActiveSizeNumeric(state, defaultSize);\n\tconst next: number | null = getNextPresetSize(current, direction, sizes);\n\tif (next === null) return false;\n\n\tif (next === defaultSize) {\n\t\treturn removeFontSize(context, state);\n\t}\n\treturn applyFontSize(context, state, `${next}px`);\n}\n\n/**\n * Selects a specific font size: removes the mark when size equals the\n * default, otherwise applies the new size.\n */\nexport function selectSize(context: PluginContext, size: number, defaultSize: number): void {\n\tif (size === defaultSize) {\n\t\tcontext.executeCommand('removeFontSize');\n\t} else {\n\t\tapplyFontSize(context, context.getState(), `${size}px`);\n\t}\n}\n\n// --- Helpers ---\n\n/** Finds the next preset size in the given direction, or null at boundaries. */\nexport function getNextPresetSize(\n\tcurrent: number,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n): number | null {\n\tif (direction === 'up') {\n\t\tfor (const size of sizes) {\n\t\t\tif (size > current) return size;\n\t\t}\n\t\treturn null;\n\t}\n\tfor (let i: number = sizes.length - 1; i >= 0; i--) {\n\t\tconst size: number | undefined = sizes[i];\n\t\tif (size !== undefined && size < current) return size;\n\t}\n\treturn null;\n}\n\nfunction extractFontSize(marks: readonly Mark[]): string | null {\n\tconst mark = marks.find((m) => m.type === 'fontSize');\n\treturn mark && isMarkOfType(mark, 'fontSize') ? (mark.attrs.size ?? null) : null;\n}\n","/**\n * Renders the font-size picker popup with a custom numeric input\n * and an accessible preset list with keyboard navigation.\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport type { FontSizeLocale } from './FontSizeLocale.js';\nimport { getActiveSizeNumeric, selectSize } from './FontSizeOperations.js';\n\n// --- Constants ---\n\nconst MIN_CUSTOM_SIZE = 1;\nconst MAX_CUSTOM_SIZE = 400;\n\n// --- Config ---\n\nexport interface FontSizePopupConfig {\n\treadonly sizes: readonly number[];\n\treadonly defaultSize: number;\n\treadonly dismissPopup: () => void;\n\treadonly locale?: FontSizeLocale;\n}\n\n// --- Public Entry Point ---\n\n/** Builds the font-size picker DOM inside the given container. */\nexport function renderFontSizePopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tcontainer.classList.add('notectl-font-size-picker');\n\n\tconst currentSize: number = getActiveSizeNumeric(context.getState(), config.defaultSize);\n\n\tconst input: HTMLInputElement = buildCustomInput(currentSize, config);\n\tappendInputWrapper(container, input);\n\n\tconst { list, items } = buildSizeList(config.sizes, currentSize, context, config);\n\tcontainer.appendChild(list);\n\n\tscrollActiveIntoView(items, config.sizes, currentSize, list);\n\tattachKeyboardNavigation(input, list, items, context, config);\n}\n\n// --- Custom Input ---\n\nfunction buildCustomInput(currentSize: number, config: FontSizePopupConfig): HTMLInputElement {\n\tconst input: HTMLInputElement = document.createElement('input');\n\tinput.type = 'number';\n\tinput.className = 'notectl-font-size-picker__input';\n\tinput.min = String(MIN_CUSTOM_SIZE);\n\tinput.max = String(MAX_CUSTOM_SIZE);\n\tinput.value = String(currentSize);\n\tinput.setAttribute('aria-label', config.locale?.customFontSizeAria ?? 'Custom font size');\n\treturn input;\n}\n\nfunction appendInputWrapper(container: HTMLElement, input: HTMLInputElement): void {\n\tconst wrapper: HTMLDivElement = document.createElement('div');\n\twrapper.className = 'notectl-font-size-picker__input-wrapper';\n\twrapper.appendChild(input);\n\tcontainer.appendChild(wrapper);\n}\n\n// --- Size List ---\n\ninterface SizeListResult {\n\treadonly list: HTMLDivElement;\n\treadonly items: HTMLButtonElement[];\n}\n\nfunction buildSizeList(\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): SizeListResult {\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-font-size-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', config.locale?.fontSizesAria ?? 'Font sizes');\n\n\tconst items: HTMLButtonElement[] = [];\n\n\tfor (const size of sizes) {\n\t\tconst isActive: boolean = size === currentSize;\n\t\tconst item: HTMLButtonElement = buildSizeItem(size, isActive);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tselectSize(context, size, config.defaultSize);\n\t\t\tconfig.dismissPopup();\n\t\t});\n\n\t\titems.push(item);\n\t\tlist.appendChild(item);\n\t}\n\n\treturn { list, items };\n}\n\nfunction buildSizeItem(size: number, isActive: boolean): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.id = `notectl-font-size-option-${size}`;\n\titem.className = 'notectl-font-size-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-font-size-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-font-size-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst label: HTMLSpanElement = document.createElement('span');\n\tlabel.className = 'notectl-font-size-picker__label';\n\tlabel.textContent = String(size);\n\titem.appendChild(label);\n\n\treturn item;\n}\n\n// --- Scroll ---\n\nfunction scrollActiveIntoView(\n\titems: HTMLButtonElement[],\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tlist: HTMLDivElement,\n): void {\n\tconst activeIdx: number = sizes.indexOf(currentSize);\n\tif (activeIdx < 0) return;\n\n\tconst activeItem: HTMLButtonElement | undefined = items[activeIdx];\n\tif (!activeItem) return;\n\n\trequestAnimationFrame(() => {\n\t\tactiveItem.scrollIntoView({ block: 'nearest' });\n\t});\n\tlist.setAttribute('aria-activedescendant', activeItem.id);\n}\n\n// --- Keyboard Navigation ---\n\nfunction attachKeyboardNavigation(\n\tinput: HTMLInputElement,\n\tlist: HTMLDivElement,\n\titems: HTMLButtonElement[],\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tlet focusedIndex = -1;\n\n\tconst setFocused = (idx: number): void => {\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length) {\n\t\t\titems[focusedIndex]?.classList.remove('notectl-font-size-picker__item--focused');\n\t\t}\n\t\tfocusedIndex = idx;\n\t\tconst el: HTMLButtonElement | undefined = items[focusedIndex];\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length && el) {\n\t\t\tel.classList.add('notectl-font-size-picker__item--focused');\n\t\t\tel.scrollIntoView({ block: 'nearest' });\n\t\t\tlist.setAttribute('aria-activedescendant', el.id);\n\t\t}\n\t};\n\n\tinput.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\tconst val: number = Number.parseInt(input.value, 10);\n\t\t\tif (!Number.isNaN(val) && val >= MIN_CUSTOM_SIZE && val <= MAX_CUSTOM_SIZE) {\n\t\t\t\tselectSize(context, val, config.defaultSize);\n\t\t\t\tconfig.dismissPopup();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\te.preventDefault();\n\t\t\tsetFocused(0);\n\t\t\titems[0]?.focus();\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.dismissPopup();\n\t\t}\n\t});\n\n\tlist.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'ArrowDown') {\n\t\t\te.preventDefault();\n\t\t\tif (focusedIndex < items.length - 1) {\n\t\t\t\tsetFocused(focusedIndex + 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowUp') {\n\t\t\te.preventDefault();\n\t\t\tif (focusedIndex > 0) {\n\t\t\t\tsetFocused(focusedIndex - 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t} else {\n\t\t\t\tsetFocused(-1);\n\t\t\t\tinput.focus();\n\t\t\t}\n\t\t} else if (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\tconst selectedSize: number | undefined = config.sizes[focusedIndex];\n\t\t\tif (focusedIndex >= 0 && focusedIndex < config.sizes.length && selectedSize !== undefined) {\n\t\t\t\tselectSize(context, selectedSize, config.defaultSize);\n\t\t\t\tconfig.dismissPopup();\n\t\t\t}\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.dismissPopup();\n\t\t}\n\t});\n}\n","/**\n * FontSizePlugin: registers a fontSize mark with attrs, a combobox-style\n * toolbar selector with WCAG-accessible popup, and commands for\n * increasing / decreasing font size.\n */\n\nimport { FONT_SIZE_SELECT_CSS } from '../../editor/styles/font-size-select.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { ToolbarServiceKey } from '../toolbar/ToolbarPlugin.js';\nimport { FONT_SIZE_LOCALES, type FontSizeLocale } from './FontSizeLocale.js';\nimport {\n\tgetActiveSizeNumeric,\n\tisFontSizeActive,\n\tremoveFontSize,\n\tstepFontSize,\n} from './FontSizeOperations.js';\nimport { renderFontSizePopup } from './FontSizePopup.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfontSize: { size: string };\n\t}\n}\n\n// --- Constants ---\n\n/** Default preset sizes shown in the font size dropdown. */\nexport const DEFAULT_FONT_SIZES: readonly number[] = [\n\t8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96,\n];\n\nconst DEFAULT_FONT_SIZE = 16;\n\n// --- Configuration ---\n\nexport interface FontSizeConfig {\n\t/**\n\t * Preset sizes shown in the font size dropdown.\n\t * Must contain positive integers. Values are sorted and deduplicated automatically.\n\t * Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The base font size that text has when no fontSize mark is applied.\n\t * Shown as the initial value in the toolbar combo and used as the\n\t * \"neutral\" size — selecting it removes the mark instead of applying one.\n\t * Defaults to 16.\n\t */\n\treadonly defaultSize?: number;\n\t/** When true, a separator is rendered after the fontSize toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: FontSizeLocale;\n}\n\n// --- Plugin ---\n\nexport class FontSizePlugin implements Plugin {\n\treadonly id = 'fontSize';\n\treadonly name = 'Font Size';\n\treadonly priority = 21;\n\n\tprivate readonly config: FontSizeConfig;\n\tprivate readonly sizes: readonly number[];\n\tprivate readonly defaultSize: number;\n\tprivate locale!: FontSizeLocale;\n\tprivate context: PluginContext | null = null;\n\tprivate comboLabel: HTMLSpanElement | null = null;\n\n\tconstructor(config?: Partial<FontSizeConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.sizes = resolveSizes(config?.sizes);\n\t\tthis.defaultSize = resolveDefaultSize(config?.defaultSize);\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(FONT_SIZE_LOCALES, context, this.config.locale);\n\n\t\tcontext.registerStyleSheet(FONT_SIZE_SELECT_CSS);\n\t\tthis.context = context;\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.applyDefaultSizeToContainer(context);\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t\tthis.comboLabel = null;\n\t}\n\n\tonStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tthis.updateComboLabel(newState);\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: 'fontSize',\n\t\t\trank: 4,\n\t\t\tattrs: {\n\t\t\t\tsize: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(mark) {\n\t\t\t\tconst span: HTMLElement = document.createElement('span');\n\t\t\t\tconst size: string = mark.attrs?.size ?? '';\n\t\t\t\tif (size) {\n\t\t\t\t\tspan.style.fontSize = size;\n\t\t\t\t}\n\t\t\t\treturn span;\n\t\t\t},\n\t\t\ttoHTMLString: (mark, content) => {\n\t\t\t\tconst size: string = String(mark.attrs?.size ?? '');\n\t\t\t\tif (!size) return content;\n\t\t\t\treturn `<span style=\"font-size: ${size}\">${content}</span>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'span',\n\t\t\t\t\tgetAttrs: (el) => {\n\t\t\t\t\t\tconst size: string = el.style.fontSize;\n\t\t\t\t\t\tif (!size) return false;\n\t\t\t\t\t\treturn { size };\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['span'] },\n\t\t});\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFontSize', () => {\n\t\t\treturn removeFontSize(context, context.getState());\n\t\t});\n\n\t\tcontext.registerCommand('setFontSize', () => {\n\t\t\treturn false;\n\t\t});\n\n\t\tcontext.registerCommand('increaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t});\n\n\t\tcontext.registerCommand('decreaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t});\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-+': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t\t'Mod-Shift-_': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst icon: string = `<span class=\"notectl-font-size-select__label\" data-font-size-label>${this.defaultSize}</span><span class=\"notectl-font-size-select__arrow\">\\u25BE</span>`;\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'fontSize',\n\t\t\tgroup: 'format',\n\t\t\ticon,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFontSize',\n\t\t\tpriority: 6,\n\t\t\tpopupType: 'custom',\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\trenderPopup: (container, ctx) => {\n\t\t\t\trenderFontSizePopup(container, ctx, {\n\t\t\t\t\tsizes: this.sizes,\n\t\t\t\t\tdefaultSize: this.defaultSize,\n\t\t\t\t\tdismissPopup: () => this.dismissPopup(),\n\t\t\t\t\tlocale: this.locale,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state) => isFontSizeActive(state),\n\t\t});\n\t}\n\n\t/**\n\t * Sets the configured default font size on the editor content container\n\t * so that unformatted text renders at the correct size instead of the\n\t * browser default (16px).\n\t */\n\tprivate applyDefaultSizeToContainer(context: PluginContext): void {\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tcontainer.style.fontSize = `${this.defaultSize}px`;\n\t}\n\n\tprivate dismissPopup(): void {\n\t\tconst toolbar = this.context?.getService(ToolbarServiceKey);\n\t\ttoolbar?.closePopup();\n\t}\n\n\tprivate updateComboLabel(state: EditorState): void {\n\t\tif (!this.comboLabel) {\n\t\t\tconst container: HTMLElement | undefined = this.context?.getPluginContainer('top');\n\t\t\tif (!container) return;\n\t\t\tthis.comboLabel = container.querySelector<HTMLSpanElement>('[data-font-size-label]') ?? null;\n\t\t\tif (!this.comboLabel) return;\n\t\t}\n\n\t\tconst activeSize: number = getActiveSizeNumeric(state, this.defaultSize);\n\t\tthis.comboLabel.textContent = String(activeSize);\n\t}\n}\n\n// --- Helpers ---\n\nfunction resolveSizes(sizes: readonly number[] | undefined): readonly number[] {\n\tif (!sizes || sizes.length === 0) return DEFAULT_FONT_SIZES;\n\tconst unique: number[] = [...new Set(sizes)].filter((n) => Number.isInteger(n) && n > 0);\n\tunique.sort((a, b) => a - b);\n\treturn unique.length > 0 ? unique : DEFAULT_FONT_SIZES;\n}\n\nfunction resolveDefaultSize(size: number | undefined): number {\n\tif (size === undefined) return DEFAULT_FONT_SIZE;\n\treturn Number.isInteger(size) && size > 0 ? size : DEFAULT_FONT_SIZE;\n}\n"],"names":["FONT_SIZE_LOCALE_EN","label","tooltip","customFontSizeAria","fontSizesAria","FONT_SIZE_LOCALES","en","de","es","fr","zh","ru","ar","hi","getActiveSize","state","sel","selection","isNodeSelection","isCollapsed","storedMarks","extractFontSize","block","getBlock","anchor","blockId","getBlockMarksAtOffset","offset","getActiveSizeNumeric","defaultSize","raw","parsed","Number","parseInt","isNaN","applyFontSize","context","size","anchorBlock","newMarks","filter","m","type","markType","attrs","tr","transaction","setStoredMarks","setSelection","build","dispatch","range","selectionRange","getBlockOrder","builder","mark","forEachBlockInRange","from","to","removeMark","addMark","removeFontSize","currentMarks","hasMark","stepFontSize","direction","sizes","next","current","i","length","selectSize","executeCommand","getState","marks","find","isMarkOfType","buildSizeItem","isActive","item","document","createElement","id","className","setAttribute","String","classList","add","check","textContent","appendChild","DEFAULT_FONT_SIZES","FontSizePlugin","name","priority","config","locale","comboLabel","this","unique","Set","n","isInteger","sort","a","b","resolvePluginLocale","registerStyleSheet","registerMarkSpec","registerCommands","registerKeymaps","registerToolbarItem","applyDefaultSizeToContainer","destroy","_oldState","newState","_tr","updateComboLabel","rank","default","span","style","fontSize","toHTMLString","content","parseHTML","tag","getAttrs","el","sanitize","tags","registerCommand","registerKeymap","icon","group","command","popupType","separatorAfter","renderPopup","container","ctx","currentSize","input","min","max","value","wrapper","list","items","addEventListener","e","preventDefault","stopPropagation","dismissPopup","push","activeIdx","indexOf","activeItem","requestAnimationFrame","scrollIntoView","focusedIndex","setFocused","idx","remove","key","val","focus","selectedSize","getContainer","toolbar","getService","ToolbarServiceKey","closePopup","getPluginContainer","querySelector","activeSize"],"mappings":";;;;;;;AACO,MCYMA,IAAsC,EAClDC,OAAO,aACPC,SAAS,aACTC,oBAAoB,oBACpBC,eAAe,gBAoEHC,IAAoD,EAChEC,IA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AAAA;AAAAA,IAAAA,GAGflB,UAAW/D,CAAAA,QFzJP,SAA0BA,IAAAA;AAChC,aAAgC,SAAzBD,EAAcC,EAAAA;AAAAA,IACtB,GEuJyCA,EAAAA,EAAAA,CAAAA;AAAAA,EAExC;AAAA,EAOQ,4BAA4BqB,IAAAA;AACJA,IAAAA,GAAQoI,eAC7B/C,MAAMC,WAAW,GAAGxB,KAAKrE,WAAAA;AAAAA,EACpC;AAAA,EAEQ;AACP,UAAM4I,KAAUvE,KAAK9D,SAASsI,WAAWC;AACzCF,IAAAA,IAASG,WAAAA;AAAAA,EACV;AAAA,EAEQ,iBAAiB7J,IAAAA;AACxB,QAAA,CAAKmF,KAAKD,YAAY;AACrB,YAAM0C,KAAqCzC,KAAK9D,SAASyI,mBAAmB,KAAA;AAC5E,UAAA,CAAKlC,GAAW;AAEhB,UADAzC,KAAKD,aAAa0C,GAAUmC,cAA+B,wBAAA,KAA6B,OACnF5E,KAAKD,WAAY;AAAA,IACvB;AAEA,UAAM8E,KAAqBnJ,EAAqBb,IAAOmF,KAAKrE,WAAAA;AAC5DqE,SAAKD,WAAWR,cAAcJ,OAAO0F,EAAAA;AAAAA,EACtC;AAAA;"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { A as e, t } from "./Commands-CSpSwGXv.mjs";
|
|
2
|
+
import { r as i } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
3
|
+
import { m as a } from "./TypeBrands-C09nE2qO.mjs";
|
|
4
|
+
import { f as o } from "./ToolbarItem-ugDymuXi.mjs";
|
|
5
|
+
const r = { boldLabel: "Bold", italicLabel: "Italic", underlineLabel: "Underline" }, n = { en: r, de: { boldLabel: "Fett", italicLabel: "Kursiv", underlineLabel: "Unterstrichen" }, es: { boldLabel: "Negrita", italicLabel: "Cursiva", underlineLabel: "Subrayado" }, fr: { boldLabel: "Gras", italicLabel: "Italique", underlineLabel: "Souligné" }, zh: { boldLabel: "粗体", italicLabel: "斜体", underlineLabel: "下划线" }, ru: { boldLabel: "Жирный", italicLabel: "Курсив", underlineLabel: "Подчёркнутый" }, ar: { boldLabel: "غامق", italicLabel: "مائل", underlineLabel: "تحته خط" }, hi: { boldLabel: "बोल्ड", italicLabel: "इटैलिक", underlineLabel: "अंडरलाइन" } }, l = { bold: true, italic: true, underline: true }, s = [{ type: "bold", configKey: "bold", rank: 0, tag: "strong", label: "Bold", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/></svg>', keyBinding: "Mod-B", toHTMLString: (e2) => `<strong>${e2}</strong>`, parseHTML: [{ tag: "strong" }, { tag: "b" }], sanitize: { tags: ["strong", "b"] } }, { type: "italic", configKey: "italic", rank: 1, tag: "em", label: "Italic", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/></svg>', keyBinding: "Mod-I", toHTMLString: (e2) => `<em>${e2}</em>`, parseHTML: [{ tag: "em" }, { tag: "i" }], sanitize: { tags: ["em", "i"] } }, { type: "underline", configKey: "underline", rank: 2, tag: "u", label: "Underline", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/></svg>', keyBinding: "Mod-U", toHTMLString: (e2) => `<u>${e2}</u>`, parseHTML: [{ tag: "u" }], sanitize: { tags: ["u"] } }];
|
|
6
|
+
class g {
|
|
7
|
+
id = "text-formatting";
|
|
8
|
+
name = "Text Formatting";
|
|
9
|
+
priority = 20;
|
|
10
|
+
config;
|
|
11
|
+
locale;
|
|
12
|
+
constructor(e2) {
|
|
13
|
+
this.config = { ...l, ...e2 };
|
|
14
|
+
}
|
|
15
|
+
init(e2) {
|
|
16
|
+
this.locale = i(n, e2, this.config.locale);
|
|
17
|
+
const t2 = s.filter((e3) => this.config[e3.configKey]), a2 = t2.filter((e3) => this.isToolbarVisible(e3.configKey)).at(-1);
|
|
18
|
+
for (const i2 of t2) {
|
|
19
|
+
const t3 = this.config.separatorAfter && i2 === a2;
|
|
20
|
+
this.registerMark(e2, i2, t3);
|
|
21
|
+
}
|
|
22
|
+
this.registerKeymaps(e2, t2), this.registerDisabledToolbarItems(e2);
|
|
23
|
+
}
|
|
24
|
+
registerMark(i2, r2, n2) {
|
|
25
|
+
const l2 = c(r2.type), s2 = this.isToolbarVisible(r2.configKey);
|
|
26
|
+
if (i2.registerMarkSpec({ type: r2.type, rank: r2.rank, toDOM: () => document.createElement(r2.tag), toHTMLString: (e2, t2) => r2.toHTMLString(t2), parseHTML: r2.parseHTML, sanitize: r2.sanitize }), i2.registerCommand(l2, () => {
|
|
27
|
+
const t2 = e(i2.getState(), a(r2.type));
|
|
28
|
+
return !!t2 && (i2.dispatch(t2), true);
|
|
29
|
+
}), s2) {
|
|
30
|
+
const e2 = this.getMarkLabel(r2.type);
|
|
31
|
+
i2.registerToolbarItem({ id: r2.type, group: "format", icon: r2.icon, label: e2, tooltip: `${e2} (${o(r2.keyBinding)})`, command: l2, priority: 10 * r2.rank + 10, separatorAfter: n2, isActive: (e3) => t(e3, a(r2.type)) });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
registerKeymaps(e2, t2) {
|
|
35
|
+
const i2 = {};
|
|
36
|
+
for (const a2 of t2) {
|
|
37
|
+
const t3 = c(a2.type);
|
|
38
|
+
i2[a2.keyBinding] = () => e2.executeCommand(t3);
|
|
39
|
+
}
|
|
40
|
+
Object.keys(i2).length > 0 && e2.registerKeymap(i2);
|
|
41
|
+
}
|
|
42
|
+
registerDisabledToolbarItems(e2) {
|
|
43
|
+
if (this.config.toolbar) for (const t2 of s) {
|
|
44
|
+
const i2 = this.config[t2.configKey], a2 = this.config.toolbar[t2.configKey] ?? true;
|
|
45
|
+
!i2 && a2 && e2.registerToolbarItem({ id: t2.type, group: "format", icon: t2.icon, label: this.getMarkLabel(t2.type), command: c(t2.type), priority: 10 * t2.rank + 10, isEnabled: () => false });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
getMarkLabel(e2) {
|
|
49
|
+
const t2 = `${e2}Label`;
|
|
50
|
+
return this.locale[t2];
|
|
51
|
+
}
|
|
52
|
+
isToolbarVisible(e2) {
|
|
53
|
+
return !this.config.toolbar || (this.config.toolbar[e2] ?? true);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function c(e2) {
|
|
57
|
+
return `toggle${e2.charAt(0).toUpperCase()}${e2.slice(1)}`;
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
g as T,
|
|
61
|
+
n as a,
|
|
62
|
+
r as b
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=index-B_3qDrUN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B_3qDrUN.mjs","sources":["../../src/plugins/text-formatting/TextFormattingLocale.ts","../../src/plugins/text-formatting/TextFormattingPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the TextFormattingPlugin.\n */\n\n// --- Locale Interface ---\n\nexport interface TextFormattingLocale {\n\treadonly boldLabel: string;\n\treadonly italicLabel: string;\n\treadonly underlineLabel: string;\n}\n\n// --- Default English Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_EN: TextFormattingLocale = {\n\tboldLabel: 'Bold',\n\titalicLabel: 'Italic',\n\tunderlineLabel: 'Underline',\n};\n\n// --- German Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_DE: TextFormattingLocale = {\n\tboldLabel: 'Fett',\n\titalicLabel: 'Kursiv',\n\tunderlineLabel: 'Unterstrichen',\n};\n\n// --- Spanish Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_ES: TextFormattingLocale = {\n\tboldLabel: 'Negrita',\n\titalicLabel: 'Cursiva',\n\tunderlineLabel: 'Subrayado',\n};\n\n// --- French Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_FR: TextFormattingLocale = {\n\tboldLabel: 'Gras',\n\titalicLabel: 'Italique',\n\tunderlineLabel: 'Souligné',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_ZH: TextFormattingLocale = {\n\tboldLabel: '粗体',\n\titalicLabel: '斜体',\n\tunderlineLabel: '下划线',\n};\n\n// --- Russian Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_RU: TextFormattingLocale = {\n\tboldLabel: 'Жирный',\n\titalicLabel: 'Курсив',\n\tunderlineLabel: 'Подчёркнутый',\n};\n\n// --- Arabic Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_AR: TextFormattingLocale = {\n\tboldLabel: 'غامق',\n\titalicLabel: 'مائل',\n\tunderlineLabel: 'تحته خط',\n};\n\n// --- Hindi Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_HI: TextFormattingLocale = {\n\tboldLabel: 'बोल्ड',\n\titalicLabel: 'इटैलिक',\n\tunderlineLabel: 'अंडरलाइन',\n};\n\n// --- Locale Map ---\n\nexport const TEXT_FORMATTING_LOCALES: Record<string, TextFormattingLocale> = {\n\ten: TEXT_FORMATTING_LOCALE_EN,\n\tde: TEXT_FORMATTING_LOCALE_DE,\n\tes: TEXT_FORMATTING_LOCALE_ES,\n\tfr: TEXT_FORMATTING_LOCALE_FR,\n\tzh: TEXT_FORMATTING_LOCALE_ZH,\n\tru: TEXT_FORMATTING_LOCALE_RU,\n\tar: TEXT_FORMATTING_LOCALE_AR,\n\thi: TEXT_FORMATTING_LOCALE_HI,\n};\n","/**\n * TextFormattingPlugin: registers inline marks (bold, italic, underline)\n * with their MarkSpecs, toggle commands, keyboard shortcuts, and toolbar items.\n *\n * This plugin is data-driven — each mark type is defined declaratively and\n * all registrations (MarkSpec, command, keymap, toolbar item) are derived\n * from the same definition.\n *\n * Supports two separate config dimensions:\n * - Feature config (bold/italic/underline): controls whether the mark is\n * registered in the schema. When disabled, the keyboard shortcut does nothing.\n * - Toolbar config: controls whether the toolbar button is visible.\n * When a feature is disabled but toolbar is enabled, the button renders as disabled.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { ParseRule } from '../../model/ParseRule.js';\nimport type { SanitizeConfig } from '../../model/SanitizeConfig.js';\nimport { markType as mkType } from '../../model/TypeBrands.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { TEXT_FORMATTING_LOCALES, type TextFormattingLocale } from './TextFormattingLocale.js';\n\n// --- Configuration ---\n\n/** Controls toolbar button visibility per mark. */\nexport interface TextFormattingToolbarConfig {\n\treadonly bold?: boolean;\n\treadonly italic?: boolean;\n\treadonly underline?: boolean;\n}\n\n/** Controls which inline marks are enabled and which toolbar buttons are shown. */\nexport interface TextFormattingConfig {\n\treadonly bold: boolean;\n\treadonly italic: boolean;\n\treadonly underline: boolean;\n\treadonly toolbar?: TextFormattingToolbarConfig;\n\t/** When true, a separator is rendered after the last text-formatting toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: TextFormattingLocale;\n}\n\nconst DEFAULT_CONFIG: TextFormattingConfig = {\n\tbold: true,\n\titalic: true,\n\tunderline: true,\n};\n\n// --- Mark Definitions ---\n\ninterface MarkDefinition {\n\treadonly type: string;\n\treadonly configKey: keyof Omit<TextFormattingConfig, 'toolbar' | 'separatorAfter' | 'locale'>;\n\treadonly rank: number;\n\treadonly tag: string;\n\treadonly label: string;\n\treadonly icon: string;\n\treadonly keyBinding: string;\n\treadonly toHTMLString: (content: string) => string;\n\treadonly parseHTML: readonly ParseRule[];\n\treadonly sanitize: SanitizeConfig;\n}\n\nconst BOLD_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\"/></svg>';\nconst ITALIC_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z\"/></svg>';\nconst UNDERLINE_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z\"/></svg>';\n\nconst MARK_DEFINITIONS: readonly MarkDefinition[] = [\n\t{\n\t\ttype: 'bold',\n\t\tconfigKey: 'bold',\n\t\trank: 0,\n\t\ttag: 'strong',\n\t\tlabel: 'Bold',\n\t\ticon: BOLD_ICON,\n\t\tkeyBinding: 'Mod-B',\n\t\ttoHTMLString: (content) => `<strong>${content}</strong>`,\n\t\tparseHTML: [{ tag: 'strong' }, { tag: 'b' }],\n\t\tsanitize: { tags: ['strong', 'b'] },\n\t},\n\t{\n\t\ttype: 'italic',\n\t\tconfigKey: 'italic',\n\t\trank: 1,\n\t\ttag: 'em',\n\t\tlabel: 'Italic',\n\t\ticon: ITALIC_ICON,\n\t\tkeyBinding: 'Mod-I',\n\t\ttoHTMLString: (content) => `<em>${content}</em>`,\n\t\tparseHTML: [{ tag: 'em' }, { tag: 'i' }],\n\t\tsanitize: { tags: ['em', 'i'] },\n\t},\n\t{\n\t\ttype: 'underline',\n\t\tconfigKey: 'underline',\n\t\trank: 2,\n\t\ttag: 'u',\n\t\tlabel: 'Underline',\n\t\ticon: UNDERLINE_ICON,\n\t\tkeyBinding: 'Mod-U',\n\t\ttoHTMLString: (content) => `<u>${content}</u>`,\n\t\tparseHTML: [{ tag: 'u' }],\n\t\tsanitize: { tags: ['u'] },\n\t},\n];\n\n// --- Plugin ---\n\nexport class TextFormattingPlugin implements Plugin {\n\treadonly id = 'text-formatting';\n\treadonly name = 'Text Formatting';\n\treadonly priority = 20;\n\n\tprivate readonly config: TextFormattingConfig;\n\tprivate locale!: TextFormattingLocale;\n\n\tconstructor(config?: Partial<TextFormattingConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(TEXT_FORMATTING_LOCALES, context, this.config.locale);\n\n\t\tconst enabledMarks = MARK_DEFINITIONS.filter((def) => this.config[def.configKey]);\n\n\t\t// Determine which marks will have visible toolbar items\n\t\tconst visibleToolbarMarks = enabledMarks.filter((def) => this.isToolbarVisible(def.configKey));\n\t\tconst lastVisibleMark = visibleToolbarMarks.at(-1);\n\n\t\tfor (const def of enabledMarks) {\n\t\t\tconst isSeparatorTarget = this.config.separatorAfter && def === lastVisibleMark;\n\t\t\tthis.registerMark(context, def, isSeparatorTarget);\n\t\t}\n\n\t\tthis.registerKeymaps(context, enabledMarks);\n\n\t\t// Register disabled placeholder buttons for marks that are disabled\n\t\t// as features but explicitly requested in the toolbar config\n\t\tthis.registerDisabledToolbarItems(context);\n\t}\n\n\tprivate registerMark(\n\t\tcontext: PluginContext,\n\t\tdef: MarkDefinition,\n\t\tseparatorAfter?: boolean,\n\t): void {\n\t\tconst commandName = toCommandName(def.type);\n\t\tconst toolbarVisible = this.isToolbarVisible(def.configKey);\n\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: def.type,\n\t\t\trank: def.rank,\n\t\t\ttoDOM() {\n\t\t\t\treturn document.createElement(def.tag);\n\t\t\t},\n\t\t\ttoHTMLString: (_mark, content) => def.toHTMLString(content),\n\t\t\tparseHTML: def.parseHTML,\n\t\t\tsanitize: def.sanitize,\n\t\t});\n\n\t\tcontext.registerCommand(commandName, () => {\n\t\t\tconst tr = toggleMark(context.getState(), mkType(def.type));\n\t\t\tif (tr) {\n\t\t\t\tcontext.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\n\t\tif (toolbarVisible) {\n\t\t\tconst label: string = this.getMarkLabel(def.type);\n\t\t\tcontext.registerToolbarItem({\n\t\t\t\tid: def.type,\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon: def.icon,\n\t\t\t\tlabel,\n\t\t\t\ttooltip: `${label} (${formatShortcut(def.keyBinding)})`,\n\t\t\t\tcommand: commandName,\n\t\t\t\tpriority: def.rank * 10 + 10,\n\t\t\t\tseparatorAfter,\n\t\t\t\tisActive: (state) => isMarkActive(state, mkType(def.type)),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate registerKeymaps(context: PluginContext, marks: readonly MarkDefinition[]): void {\n\t\tconst keymap: Record<string, () => boolean> = {};\n\t\tfor (const def of marks) {\n\t\t\tconst commandName = toCommandName(def.type);\n\t\t\tkeymap[def.keyBinding] = () => context.executeCommand(commandName);\n\t\t}\n\t\tif (Object.keys(keymap).length > 0) {\n\t\t\tcontext.registerKeymap(keymap);\n\t\t}\n\t}\n\n\t/**\n\t * Registers disabled toolbar buttons for marks whose feature is disabled\n\t * but whose toolbar button is explicitly requested.\n\t */\n\tprivate registerDisabledToolbarItems(context: PluginContext): void {\n\t\tif (!this.config.toolbar) return;\n\n\t\tfor (const def of MARK_DEFINITIONS) {\n\t\t\tconst featureEnabled = this.config[def.configKey];\n\t\t\tconst toolbarVisible = this.config.toolbar[def.configKey] ?? true;\n\n\t\t\tif (!featureEnabled && toolbarVisible) {\n\t\t\t\tcontext.registerToolbarItem({\n\t\t\t\t\tid: def.type,\n\t\t\t\t\tgroup: 'format',\n\t\t\t\t\ticon: def.icon,\n\t\t\t\t\tlabel: this.getMarkLabel(def.type),\n\t\t\t\t\tcommand: toCommandName(def.type),\n\t\t\t\t\tpriority: def.rank * 10 + 10,\n\t\t\t\t\tisEnabled: () => false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getMarkLabel(type: string): string {\n\t\tconst key = `${type}Label` as keyof TextFormattingLocale;\n\t\treturn this.locale[key] as string;\n\t}\n\n\t/** Checks if a toolbar button should be visible for a given mark. */\n\tprivate isToolbarVisible(\n\t\tconfigKey: keyof Omit<TextFormattingConfig, 'toolbar' | 'separatorAfter' | 'locale'>,\n\t): boolean {\n\t\tif (!this.config.toolbar) return true;\n\t\treturn this.config.toolbar[configKey] ?? true;\n\t}\n}\n\n/** Converts a mark type to its toggle command name (e.g. 'bold' → 'toggleBold'). */\nfunction toCommandName(markType: string): string {\n\treturn `toggle${markType.charAt(0).toUpperCase()}${markType.slice(1)}`;\n}\n"],"names":["TEXT_FORMATTING_LOCALE_EN","boldLabel","italicLabel","underlineLabel","TEXT_FORMATTING_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","bold","italic","underline","MARK_DEFINITIONS","type","configKey","rank","tag","label","icon","keyBinding","toHTMLString","content","parseHTML","sanitize","tags","TextFormattingPlugin","id","name","priority","config","locale","this","context","resolvePluginLocale","enabledMarks","filter","def","lastVisibleMark","isToolbarVisible","at","isSeparatorTarget","separatorAfter","registerMark","registerKeymaps","registerDisabledToolbarItems","commandName","toCommandName","toolbarVisible","registerMarkSpec","toDOM","document","createElement","_mark","registerCommand","tr","toggleMark","getState","mkType","dispatch","getMarkLabel","registerToolbarItem","group","tooltip","formatShortcut","command","isActive","state","isMarkActive","marks","keymap","executeCommand","Object","keys","length","registerKeymap","toolbar","featureEnabled","isEnabled","key","markType","charAt","toUpperCase","slice"],"mappings":";;;;AAcO,MAAMA,IAAkD,EAC9DC,WAAW,QACXC,aAAa,UACbC,gBAAgB,YAAA,GA6DJC,IAAgE,EAC5EC,IAAIL,GACJM,IA1D8D,EAC9DL,WAAW,QACXC,aAAa,UACbC,gBAAgB,gBAAA,GAwDhBI,IAnD8D,EAC9DN,WAAW,WACXC,aAAa,WACbC,gBAAgB,YAAA,GAiDhBK,IA5C8D,EAC9DP,WAAW,QACXC,aAAa,YACbC,gBAAgB,WAAA,GA0ChBM,IArC8D,EAC9DR,WAAW,MACXC,aAAa,MACbC,gBAAgB,MAAA,GAmChBO,IA9B8D,EAC9DT,WAAW,UACXC,aAAa,UACbC,gBAAgB,kBA4BhBQ,IAvB8D,EAC9DV,WAAW,QACXC,aAAa,QACbC,gBAAgB,UAAA,GAqBhBS,IAhB8D,EAC9DX,WAAW,SACXC,aAAa,UACbC,gBAAgB,WAAA,EAAA,GC7BXU,IAAuC,EAC5CC,MAAAA,MACAC,QAAAA,MACAC,WAAAA,KAAW,GAyBNC,IAA8C,CACnD,EACCC,MAAM,QACNC,WAAW,QACXC,MAAM,GACNC,KAAK,UACLC,OAAO,QACPC,MAbD,uTAcCC,YAAY,SACZC,cAAeC,CAAAA,OAAY,WAAWA,EAAAA,aACtCC,WAAW,CAAC,EAAEN,KAAK,SAAA,GAAY,EAAEA,KAAK,IAAA,CAAA,GACtCO,UAAU,EAAEC,MAAM,CAAC,UAAU,GAAA,EAAA,EAAA,GAE9B,EACCX,MAAM,UACNC,WAAW,UACXC,MAAM,GACNC,KAAK,MACLC,OAAO,UACPC,MAvBD,kIAwBCC,YAAY,SACZC,cAAeC,CAAAA,OAAY,OAAOA,EAAAA,SAClCC,WAAW,CAAC,EAAEN,KAAK,KAAA,GAAQ,EAAEA,KAAK,IAAA,CAAA,GAClCO,UAAU,EAAEC,MAAM,CAAC,MAAM,GAAA,EAAA,EAAA,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AItB,SAAAA,KAAAA;AAAc,OAExD8D,MAAkB7B,MACtBf,GAAQ4B,oBAAoB,EAC3BlC,IAAIU,GAAIvB,MACRgD,OAAO,UACP3C,MAAMkB,GAAIlB,MACVD,OAAOc,KAAK4B,aAAavB,GAAIvB,IAAAA,GAC7BmD,SAASlB,EAAcV,GAAIvB,IAAAA,GAC3Be,UAAqB,KAAXQ,GAAIrB,OAAY,IAC1B8D,WAAW,MAAA,MAAM,CAAA;AAAA,IAGpB;AAAA,EACD;AAAA,EAEQ,aAAahE,IAAAA;AACpB,UAAMiE,KAAM,GAAGjE,EAAAA;AACf,WAAOkB,KAAKD,OAAOgD,EAAAA;AAAAA,EACpB;AAAA,EAGQ,iBACPhE,IAAAA;AAEA,WAAA,CAAKiB,KAAKF,OAAO8C,YACV5C,KAAKF,OAAO8C,QAAQ7D,EAAAA,KAAAA;AAAAA,EAC5B;AAAA;AAID,SAASgC,EAAciC,IAAAA;AACtB,SAAO,SAASA,GAASC,OAAO,CAAA,EAAGC,YAAAA,CAAAA,GAAgBF,GAASG,MAAM,CAAA,CAAA;AACnE;"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { f as e } from "./Commands-CSpSwGXv.mjs";
|
|
2
|
+
import { r as t } from "./resolvePluginLocale-B4w1OkPy.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,IAjFyC,EACzCZ,OAAO,UACPC,SAAUC,CAAAA,OAAqB,oBAAoBA,OACnDC,YAAY,mBACZC,gBAAgB,mBAChBC,gBAAgB,eAChBC,SAAS,kBACTC,OAAO,WACPC,WAAW,iBAAA,GA0EXK,IArEyC,EACzCb,OAAO,QACPC,SAAUC,CAAAA,OAAqB,oBAAoBA,EAAAA,KACnDC,YAAY,qBACZC,gBAAgB,qBAChBC,gBAAgB,eAChBC,SAAS,eACTC,OAAO,aACPC,WAAW,oBAAA,GA8DXM,IAzDyC,EACzCd,OAAO,MACPC,SAAUC,CAAAA,OAAqB,SAASA,EAAAA,KACxCC,YAAY,QACZC,gBAAgB,QAChBC,gBAAgB,eAChBC,SA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