@notectl/core 1.7.0 → 1.7.1
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 +2 -2
- package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs → AttrRegistry-Ci0qAvtS.mjs} +2 -2
- package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs.map → AttrRegistry-Ci0qAvtS.mjs.map} +1 -1
- package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs +58 -0
- package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs.map +1 -0
- package/dist/chunks/{CaretNavigation-CAJXoaae.mjs → CaretNavigation-qLfeL0So.mjs} +56 -56
- package/dist/chunks/{CaretNavigation-CAJXoaae.mjs.map → CaretNavigation-qLfeL0So.mjs.map} +1 -1
- package/dist/chunks/ColorGrid-BBkN0AOb.mjs +80 -0
- package/dist/chunks/ColorGrid-BBkN0AOb.mjs.map +1 -0
- package/dist/chunks/ColorPickerPopup-D3ysvOH-.mjs +37 -0
- package/dist/chunks/ColorPickerPopup-D3ysvOH-.mjs.map +1 -0
- package/dist/chunks/ColorValidation-CV4f1wu6.mjs +39 -0
- package/dist/chunks/ColorValidation-CV4f1wu6.mjs.map +1 -0
- package/dist/chunks/{Document-CuwE73FF.mjs → Document-DfZ1NOjs.mjs} +15 -15
- package/dist/chunks/{Document-CuwE73FF.mjs.map → Document-DfZ1NOjs.mjs.map} +1 -1
- package/dist/chunks/MarkCommands-uybmkw9l.mjs +94 -0
- package/dist/chunks/MarkCommands-uybmkw9l.mjs.map +1 -0
- package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs → NavigationUtils-Cspt2ZrK.mjs} +3 -3
- package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs.map → NavigationUtils-Cspt2ZrK.mjs.map} +1 -1
- package/dist/chunks/{NodeResolver-B-wzthAQ.mjs → NodeResolver-CzLmmrph.mjs} +2 -2
- package/dist/chunks/{NodeResolver-B-wzthAQ.mjs.map → NodeResolver-CzLmmrph.mjs.map} +1 -1
- package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs +30 -0
- package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs.map +1 -0
- package/dist/chunks/RangeIterator-Bye0UtbY.mjs +16 -0
- package/dist/chunks/RangeIterator-Bye0UtbY.mjs.map +1 -0
- package/dist/chunks/{Selection-DmFDwiPJ.mjs → Selection-BRTab5hO.mjs} +7 -7
- package/dist/chunks/{Selection-DmFDwiPJ.mjs.map → Selection-BRTab5hO.mjs.map} +1 -1
- package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -1
- package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs → ToolbarKeyboardNav-DhpL8zNV.mjs} +3 -3
- package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs.map → ToolbarKeyboardNav-DhpL8zNV.mjs.map} +1 -1
- package/dist/chunks/{ToolbarPlugin-B6JETWaw.mjs → ToolbarPlugin-B7oJRzpl.mjs} +339 -127
- package/dist/chunks/ToolbarPlugin-B7oJRzpl.mjs.map +1 -0
- package/dist/chunks/{index-CAV2N-fF.mjs → index-Bt_d4IqB.mjs} +8 -8
- package/dist/chunks/{index-CAV2N-fF.mjs.map → index-Bt_d4IqB.mjs.map} +1 -1
- package/dist/chunks/{index-pxbbDHVH.mjs → index-CFJFD4lF.mjs} +3 -3
- package/dist/chunks/{index-pxbbDHVH.mjs.map → index-CFJFD4lF.mjs.map} +1 -1
- package/dist/chunks/{index-C0cEs7Jc.mjs → index-CFPP456m.mjs} +10 -10
- package/dist/chunks/{index-C0cEs7Jc.mjs.map → index-CFPP456m.mjs.map} +1 -1
- package/dist/chunks/{index-FlTg80Pk.mjs → index-CH1r7DL-.mjs} +257 -298
- package/dist/chunks/index-CH1r7DL-.mjs.map +1 -0
- package/dist/chunks/{index-D0s0Q8Wc.mjs → index-CfyS_pgH.mjs} +25 -18
- package/dist/chunks/index-CfyS_pgH.mjs.map +1 -0
- package/dist/chunks/{index-CflvcXSd.mjs → index-Ckzqtn5D.mjs} +17 -14
- package/dist/chunks/{index-CflvcXSd.mjs.map → index-Ckzqtn5D.mjs.map} +1 -1
- package/dist/chunks/{index-C9gc3Bws.mjs → index-CrKz_IEn.mjs} +32 -32
- package/dist/chunks/{index-C9gc3Bws.mjs.map → index-CrKz_IEn.mjs.map} +1 -1
- package/dist/chunks/{index-DMt3ojrY.mjs → index-DGKQhSAl.mjs} +2 -2
- package/dist/chunks/{index-DMt3ojrY.mjs.map → index-DGKQhSAl.mjs.map} +1 -1
- package/dist/chunks/{index-CoeD4T9-.mjs → index-DIvHQtE2.mjs} +10 -7
- package/dist/chunks/{index-CoeD4T9-.mjs.map → index-DIvHQtE2.mjs.map} +1 -1
- package/dist/chunks/index-DayTn6Re.mjs +166 -0
- package/dist/chunks/index-DayTn6Re.mjs.map +1 -0
- package/dist/chunks/index-Deag_lVi.mjs +121 -0
- package/dist/chunks/index-Deag_lVi.mjs.map +1 -0
- package/dist/chunks/{index--z_Txzej.mjs → index-DmuuFS5D.mjs} +6 -6
- package/dist/chunks/{index--z_Txzej.mjs.map → index-DmuuFS5D.mjs.map} +1 -1
- package/dist/chunks/{index-B9GkDVsx.mjs → index-DoCvDkfj.mjs} +77 -94
- package/dist/chunks/index-DoCvDkfj.mjs.map +1 -0
- package/dist/chunks/index-DuRNETFv.mjs +296 -0
- package/dist/chunks/index-DuRNETFv.mjs.map +1 -0
- package/dist/chunks/{index-B-NSeaM4.mjs → index-Dum8yE_t.mjs} +12 -12
- package/dist/chunks/{index-B-NSeaM4.mjs.map → index-Dum8yE_t.mjs.map} +1 -1
- package/dist/chunks/{index-CNs4QQ8l.mjs → index-Dy6SllXW.mjs} +52 -64
- package/dist/chunks/index-Dy6SllXW.mjs.map +1 -0
- package/dist/chunks/{index-D8tbbW97.mjs → index-E7OgN7hM.mjs} +2 -2
- package/dist/chunks/{index-D8tbbW97.mjs.map → index-E7OgN7hM.mjs.map} +1 -1
- package/dist/chunks/{index-DyIwN_67.mjs → index-yhz2qeeh.mjs} +220 -218
- package/dist/chunks/index-yhz2qeeh.mjs.map +1 -0
- package/dist/commands/AttributedMarkCommands.d.ts +46 -0
- package/dist/commands/AttributedMarkCommands.d.ts.map +1 -0
- package/dist/commands/CommandHelpers.d.ts +21 -0
- package/dist/commands/CommandHelpers.d.ts.map +1 -0
- package/dist/commands/Commands.d.ts +2 -8
- package/dist/commands/Commands.d.ts.map +1 -1
- package/dist/commands/DeleteCommands.d.ts.map +1 -1
- package/dist/commands/GapCursorCommands.d.ts.map +1 -1
- package/dist/commands/NodeSelectionCommands.d.ts.map +1 -1
- package/dist/commands/PasteCommand.d.ts.map +1 -1
- package/dist/commands/RangeIterator.d.ts +10 -0
- package/dist/commands/RangeIterator.d.ts.map +1 -0
- package/dist/editor/DocumentParser.d.ts.map +1 -1
- package/dist/editor/DocumentSerializer.d.ts +2 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/MarkSerializer.d.ts +11 -0
- package/dist/editor/MarkSerializer.d.ts.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +6 -3
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/PaperLayoutController.d.ts +2 -0
- package/dist/editor/PaperLayoutController.d.ts.map +1 -1
- package/dist/editor/styles/font-select.d.ts +1 -1
- package/dist/editor/styles/font-select.d.ts.map +1 -1
- package/dist/editor/styles/font-size-select.d.ts +1 -1
- package/dist/editor/styles/font-size-select.d.ts.map +1 -1
- package/dist/editor/styles/heading-select.d.ts +1 -1
- package/dist/editor/styles/heading-select.d.ts.map +1 -1
- package/dist/editor/styles/toolbar.d.ts +1 -1
- package/dist/editor/styles/toolbar.d.ts.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +0 -2
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/model/MarkSpec.d.ts +6 -0
- package/dist/model/MarkSpec.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2227 -2090
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +2527 -2337
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +2 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font/FontPlugin.d.ts +0 -6
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePlugin.d.ts +0 -5
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/gap-cursor.mjs +7 -7
- package/dist/plugins/hard-break.mjs +2 -25
- package/dist/plugins/hard-break.mjs.map +1 -1
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +1 -7
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -1
- package/dist/plugins/heading/HeadingPlugin.d.ts +0 -6
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/shared/ColorGrid.d.ts +25 -0
- package/dist/plugins/shared/ColorGrid.d.ts.map +1 -0
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
- package/dist/plugins/shared/ColorValidation.d.ts +13 -2
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
- package/dist/plugins/shared/PopupKeyboardPatterns.d.ts +43 -0
- package/dist/plugins/shared/PopupKeyboardPatterns.d.ts.map +1 -0
- package/dist/plugins/shared/PopupManager.d.ts +45 -0
- package/dist/plugins/shared/PopupManager.d.ts.map +1 -0
- package/dist/plugins/shared/PopupPositioning.d.ts +21 -0
- package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -0
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts +2 -1
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarItem.d.ts +11 -2
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +5 -1
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts +9 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
- package/dist/plugins/toolbar/index.d.ts +1 -1
- package/dist/plugins/toolbar/index.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/state/BlockTreeOps.d.ts +21 -0
- package/dist/state/BlockTreeOps.d.ts.map +1 -0
- package/dist/state/InlineContentOps.d.ts +37 -0
- package/dist/state/InlineContentOps.d.ts.map +1 -0
- package/dist/state/StepApplication.d.ts.map +1 -1
- package/dist/test/PluginTestUtils.d.ts +4 -0
- package/dist/test/PluginTestUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/ColorNames-BdsHwA2f.mjs +0 -59
- package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +0 -1
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +0 -125
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +0 -1
- package/dist/chunks/Commands-CicwYoTQ.mjs +0 -286
- package/dist/chunks/Commands-CicwYoTQ.mjs.map +0 -1
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs +0 -94
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +0 -1
- package/dist/chunks/index-B9GkDVsx.mjs.map +0 -1
- package/dist/chunks/index-CKPrAOr6.mjs +0 -209
- package/dist/chunks/index-CKPrAOr6.mjs.map +0 -1
- package/dist/chunks/index-CNs4QQ8l.mjs.map +0 -1
- package/dist/chunks/index-D0s0Q8Wc.mjs.map +0 -1
- package/dist/chunks/index-DfzCof6H.mjs +0 -191
- package/dist/chunks/index-DfzCof6H.mjs.map +0 -1
- package/dist/chunks/index-DyIwN_67.mjs.map +0 -1
- package/dist/chunks/index-FlTg80Pk.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as t } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
2
|
-
import { a as e } from "./AttrRegistry-
|
|
3
|
-
import {
|
|
2
|
+
import { a as e } from "./AttrRegistry-Ci0qAvtS.mjs";
|
|
3
|
+
import { m as n, u as i } from "./Document-DfZ1NOjs.mjs";
|
|
4
4
|
import { c as s } from "./NodeSpec-NZVvcCuH.mjs";
|
|
5
|
-
import { i as
|
|
5
|
+
import { i as c, a as l, b as r, d as o } from "./Selection-BRTab5hO.mjs";
|
|
6
6
|
import { n as a, b as d } from "./TypeBrands-C09nE2qO.mjs";
|
|
7
7
|
const h = { bulletList: "Bullet List", numberedList: "Numbered List", checklist: "Checklist" }, u = { en: h, de: { bulletList: "Aufzählung", numberedList: "Nummerierte Liste", checklist: "Checkliste" }, es: { bulletList: "Lista con viñetas", numberedList: "Lista numerada", checklist: "Lista de verificación" }, fr: { bulletList: "Liste à puces", numberedList: "Liste numérotée", checklist: "Liste de contrôle" }, zh: { bulletList: "无序列表", numberedList: "有序列表", checklist: "清单" }, ru: { bulletList: "Маркированный список", numberedList: "Нумерованный список", checklist: "Чек-лист" }, ar: { bulletList: "قائمة نقطية", numberedList: "قائمة مرقمة", checklist: "قائمة تحقق" }, hi: { bulletList: "बुलेट सूची", numberedList: "क्रमांकित सूची", checklist: "चेकलिस्ट" } }, p = { types: ["bullet", "ordered", "checklist"], maxIndent: 4 }, m = [{ type: "bullet", label: "Bullet List", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"/></svg>', inputPattern: /^[-*] $/, inputPrefix: "- " }, { type: "ordered", label: "Numbered List", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"/></svg>', inputPattern: /^\d+\. $/, inputPrefix: "1. " }, { type: "checklist", label: "Checklist", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 7h-9v2h9V7zm0 8h-9v2h9v-2zM5.54 11L2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 11zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 19z"/></svg>', inputPattern: /^\[[ x]] $/, inputPrefix: "[ ] " }];
|
|
8
8
|
class g {
|
|
@@ -87,12 +87,19 @@ class g {
|
|
|
87
87
|
}
|
|
88
88
|
registerNodeSpec(t2) {
|
|
89
89
|
t2.registerNodeSpec({ type: "list_item", group: "block", content: { allow: ["text"] }, attrs: { listType: { default: "bullet" }, indent: { default: 0 }, checked: { default: false } }, toDOM(t3) {
|
|
90
|
-
const e2 = t3.attrs?.listType ?? "bullet", n2 = t3.attrs?.indent ?? 0, i2 = t3.attrs?.checked ?? false,
|
|
91
|
-
return
|
|
90
|
+
const e2 = t3.attrs?.listType ?? "bullet", n2 = t3.attrs?.indent ?? 0, i2 = t3.attrs?.checked ?? false, c2 = s("li", t3.id);
|
|
91
|
+
return c2.setAttribute("role", "listitem"), c2.setAttribute("data-list-type", e2), c2.setAttribute("data-indent", String(n2)), c2.className = `notectl-list-item notectl-list-item--${e2}`, n2 > 0 && (c2.style.marginLeft = 24 * n2 + "px"), "checklist" === e2 && (c2.setAttribute("data-checked", String(i2)), c2.setAttribute("aria-checked", String(i2))), c2.setAttribute("aria-level", String(n2 + 1)), c2;
|
|
92
92
|
}, wrapper(t3) {
|
|
93
93
|
const e2 = t3.attrs?.listType ?? "bullet";
|
|
94
94
|
return { tag: "ordered" === e2 ? "ol" : "ul", key: `list-${e2}`, className: `notectl-list notectl-list--${e2}`, attrs: { role: "list" } };
|
|
95
|
-
}, toHTML
|
|
95
|
+
}, toHTML(t3, e2) {
|
|
96
|
+
const n2 = t3.attrs?.listType ?? "bullet", i2 = t3.attrs?.checked ?? false;
|
|
97
|
+
if ("checklist" === n2) {
|
|
98
|
+
const t4 = i2 ? " checked" : "";
|
|
99
|
+
return `<li role="checkbox" aria-checked="${String(i2)}"><input type="checkbox" disabled${t4}>${e2 || "<br>"}</li>`;
|
|
100
|
+
}
|
|
101
|
+
return `<li>${e2 || "<br>"}</li>`;
|
|
102
|
+
}, parseHTML: [{ tag: "li" }], sanitize: { tags: ["ul", "ol", "li", "input"], attrs: ["type", "disabled", "checked", "role", "aria-checked"] } });
|
|
96
103
|
}
|
|
97
104
|
registerCommands(t2) {
|
|
98
105
|
const e2 = this.getEnabledTypes();
|
|
@@ -106,7 +113,7 @@ class g {
|
|
|
106
113
|
const e2 = this.getEnabledTypes();
|
|
107
114
|
for (const n2 of e2) t2.registerInputRule({ pattern: n2.inputPattern, handler: (t3, e3, i2, s2) => {
|
|
108
115
|
const d2 = t3.selection;
|
|
109
|
-
if (
|
|
116
|
+
if (c(d2) || l(d2)) return null;
|
|
110
117
|
if (!r(d2)) return null;
|
|
111
118
|
const h2 = t3.getBlock(d2.anchor.blockId);
|
|
112
119
|
if (!h2 || "paragraph" !== h2.type) return null;
|
|
@@ -123,7 +130,7 @@ class g {
|
|
|
123
130
|
}
|
|
124
131
|
toggleList(t2, n2) {
|
|
125
132
|
const i2 = t2.getState(), s2 = i2.selection;
|
|
126
|
-
if (
|
|
133
|
+
if (c(s2) || l(s2)) return false;
|
|
127
134
|
const r2 = i2.getBlock(s2.anchor.blockId);
|
|
128
135
|
if (!r2) return false;
|
|
129
136
|
if ("list_item" === r2.type && r2.attrs?.listType === n2) {
|
|
@@ -137,19 +144,19 @@ class g {
|
|
|
137
144
|
}
|
|
138
145
|
indent(t2) {
|
|
139
146
|
const n2 = t2.getState();
|
|
140
|
-
if (
|
|
147
|
+
if (c(n2.selection) || l(n2.selection)) return false;
|
|
141
148
|
const i2 = n2.getBlock(n2.selection.anchor.blockId);
|
|
142
149
|
return !(!i2 || !e(i2, "list_item")) && !(i2.attrs.indent >= this.config.maxIndent) && this.setIndent(t2, n2, i2.attrs.indent + 1);
|
|
143
150
|
}
|
|
144
151
|
outdent(t2) {
|
|
145
152
|
const n2 = t2.getState();
|
|
146
|
-
if (
|
|
153
|
+
if (c(n2.selection) || l(n2.selection)) return false;
|
|
147
154
|
const i2 = n2.getBlock(n2.selection.anchor.blockId);
|
|
148
155
|
return !(!i2 || !e(i2, "list_item")) && !(i2.attrs.indent <= 0) && this.setIndent(t2, n2, i2.attrs.indent - 1);
|
|
149
156
|
}
|
|
150
157
|
setIndent(t2, e2, n2) {
|
|
151
158
|
const i2 = e2.selection;
|
|
152
|
-
if (
|
|
159
|
+
if (c(i2) || l(i2)) return false;
|
|
153
160
|
const s2 = e2.getBlock(i2.anchor.blockId);
|
|
154
161
|
if (!s2) return false;
|
|
155
162
|
const r2 = { ...s2.attrs, indent: n2 }, o2 = e2.transaction("command").setBlockType(i2.anchor.blockId, a("list_item"), r2).setSelection(i2).build();
|
|
@@ -157,7 +164,7 @@ class g {
|
|
|
157
164
|
}
|
|
158
165
|
toggleChecked(t2, e2) {
|
|
159
166
|
if (t2.isReadOnly() && !this.config.interactiveCheckboxes) return false;
|
|
160
|
-
const n2 = t2.getState(), i2 = e2 ?? (
|
|
167
|
+
const n2 = t2.getState(), i2 = e2 ?? (c(n2.selection) || l(n2.selection) ? null : n2.selection.anchor.blockId);
|
|
161
168
|
if (!i2) return false;
|
|
162
169
|
const s2 = n2.getBlock(i2);
|
|
163
170
|
if (!s2 || "list_item" !== s2.type || "checklist" !== s2.attrs?.listType) return false;
|
|
@@ -166,7 +173,7 @@ class g {
|
|
|
166
173
|
}
|
|
167
174
|
handleBackspace(t2) {
|
|
168
175
|
const e2 = t2.getState(), n2 = e2.selection;
|
|
169
|
-
if (
|
|
176
|
+
if (c(n2) || l(n2)) return false;
|
|
170
177
|
if (!r(n2)) return false;
|
|
171
178
|
const i2 = e2.getBlock(n2.anchor.blockId);
|
|
172
179
|
if (!i2 || "list_item" !== i2.type) return false;
|
|
@@ -176,7 +183,7 @@ class g {
|
|
|
176
183
|
}
|
|
177
184
|
handleEnter(t2) {
|
|
178
185
|
const s2 = t2.getState(), d2 = s2.selection;
|
|
179
|
-
if (
|
|
186
|
+
if (c(d2) || l(d2)) return false;
|
|
180
187
|
if (!r(d2)) return false;
|
|
181
188
|
const h2 = s2.getBlock(d2.anchor.blockId);
|
|
182
189
|
if (!h2 || "list_item" !== h2.type) return false;
|
|
@@ -199,12 +206,12 @@ class g {
|
|
|
199
206
|
const s2 = i2.getBoundingClientRect();
|
|
200
207
|
if (e2.clientX - s2.left >= 24) return;
|
|
201
208
|
e2.preventDefault();
|
|
202
|
-
const
|
|
203
|
-
|
|
209
|
+
const c2 = i2.getAttribute("data-block-id");
|
|
210
|
+
c2 && this.toggleChecked(t2, d(c2));
|
|
204
211
|
}, t2.getContainer().addEventListener("mousedown", this.checkboxClickHandler));
|
|
205
212
|
}
|
|
206
213
|
isListActive(t2, e2) {
|
|
207
|
-
if (
|
|
214
|
+
if (c(t2.selection) || l(t2.selection)) return false;
|
|
208
215
|
const n2 = t2.getBlock(t2.selection.anchor.blockId);
|
|
209
216
|
return "list_item" === n2?.type && n2.attrs?.listType === e2;
|
|
210
217
|
}
|
|
@@ -217,4 +224,4 @@ export {
|
|
|
217
224
|
u as a,
|
|
218
225
|
h as b
|
|
219
226
|
};
|
|
220
|
-
//# sourceMappingURL=index-
|
|
227
|
+
//# sourceMappingURL=index-CfyS_pgH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CfyS_pgH.mjs","sources":["../../src/editor/styles/list.ts","../../src/plugins/list/ListLocale.ts","../../src/plugins/list/ListPlugin.ts"],"sourcesContent":["/** Width of the list marker / checkbox area in pixels. */\nexport const LIST_MARKER_WIDTH = 24;\n\n/** List styles — bullet, ordered, checklist items. */\nexport const LIST_CSS = `\n/* List Wrappers — suppress native markers, we use ::before pseudo-elements */\n.notectl-list {\n\tlist-style: none;\n\tmargin: 0;\n\tpadding: 0;\n}\n\n/* Ordered List — each <ol> wrapper resets the counter */\n.notectl-list--ordered {\n\tcounter-reset: notectl-ordered;\n}\n\n/* List Items */\n.notectl-list-item {\n\tmargin: 0;\n\tpadding: 2px 0 2px ${LIST_MARKER_WIDTH}px;\n\tmin-height: 1.6em;\n\tposition: relative;\n}\n\n.notectl-list-item::before {\n\tposition: absolute;\n\tleft: 0;\n\tdisplay: inline-block;\n\twidth: ${LIST_MARKER_WIDTH}px;\n\ttext-align: center;\n}\n\n/* Bullet List */\n.notectl-list-item--bullet::before {\n\tcontent: '\\\\2022';\n\tcolor: var(--notectl-fg);\n}\n\n/* Ordered List — counter increment per item */\n.notectl-list-item--ordered {\n\tcounter-increment: notectl-ordered;\n}\n\n.notectl-list-item--ordered::before {\n\tcontent: counter(notectl-ordered) '.';\n\tcolor: var(--notectl-fg);\n\tfont-size: 14px;\n}\n\n/* Checklist */\n.notectl-list-item--checklist::before {\n\tcontent: '\\\\2610';\n\tfont-size: 16px;\n\tcolor: var(--notectl-fg-muted);\n\tcursor: pointer;\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"]::before {\n\tcontent: '\\\\2611';\n\tcolor: var(--notectl-success);\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] {\n\tcolor: var(--notectl-fg-muted);\n\ttext-decoration: line-through;\n}\n`;\n","/**\n * Locale interface and default English locale for the ListPlugin.\n */\n\n// --- Locale Interface ---\n\nexport interface ListLocale {\n\treadonly bulletList: string;\n\treadonly numberedList: string;\n\treadonly checklist: string;\n}\n\n// --- Default English Locale ---\n\nexport const LIST_LOCALE_EN: ListLocale = {\n\tbulletList: 'Bullet List',\n\tnumberedList: 'Numbered List',\n\tchecklist: 'Checklist',\n};\n\n// --- German Locale ---\n\nexport const LIST_LOCALE_DE: ListLocale = {\n\tbulletList: 'Aufzählung',\n\tnumberedList: 'Nummerierte Liste',\n\tchecklist: 'Checkliste',\n};\n\n// --- Spanish Locale ---\n\nexport const LIST_LOCALE_ES: ListLocale = {\n\tbulletList: 'Lista con viñetas',\n\tnumberedList: 'Lista numerada',\n\tchecklist: 'Lista de verificación',\n};\n\n// --- French Locale ---\n\nexport const LIST_LOCALE_FR: ListLocale = {\n\tbulletList: 'Liste à puces',\n\tnumberedList: 'Liste numérotée',\n\tchecklist: 'Liste de contrôle',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const LIST_LOCALE_ZH: ListLocale = {\n\tbulletList: '无序列表',\n\tnumberedList: '有序列表',\n\tchecklist: '清单',\n};\n\n// --- Russian Locale ---\n\nexport const LIST_LOCALE_RU: ListLocale = {\n\tbulletList: 'Маркированный список',\n\tnumberedList: 'Нумерованный список',\n\tchecklist: 'Чек-лист',\n};\n\n// --- Arabic Locale ---\n\nexport const LIST_LOCALE_AR: ListLocale = {\n\tbulletList: 'قائمة نقطية',\n\tnumberedList: 'قائمة مرقمة',\n\tchecklist: 'قائمة تحقق',\n};\n\n// --- Hindi Locale ---\n\nexport const LIST_LOCALE_HI: ListLocale = {\n\tbulletList: 'बुलेट सूची',\n\tnumberedList: 'क्रमांकित सूची',\n\tchecklist: 'चेकलिस्ट',\n};\n\n// --- Locale Map ---\n\nexport const LIST_LOCALES: Record<string, ListLocale> = {\n\ten: LIST_LOCALE_EN,\n\tde: LIST_LOCALE_DE,\n\tes: LIST_LOCALE_ES,\n\tfr: LIST_LOCALE_FR,\n\tzh: LIST_LOCALE_ZH,\n\tru: LIST_LOCALE_RU,\n\tar: LIST_LOCALE_AR,\n\thi: LIST_LOCALE_HI,\n};\n","/**\n * ListPlugin: registers ordered, unordered, and checklist block types\n * with NodeSpecs, toggle commands, indent/outdent (Tab/Shift-Tab),\n * input rules, and toolbar buttons.\n *\n * List items are modeled as flat blocks with a `listType` and `indent` attribute,\n * allowing simple nesting representation without deep tree structures.\n */\n\nimport { LIST_CSS, LIST_MARKER_WIDTH } from '../../editor/styles/list.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport { generateBlockId, getBlockText } from '../../model/Document.js';\nimport { createBlockElement } from '../../model/NodeSpec.js';\nimport {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../../model/Selection.js';\nimport { type BlockId, blockId, nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { LIST_LOCALES, type ListLocale } from './ListLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\nexport type ListType = 'bullet' | 'ordered' | 'checklist';\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\tlist_item: { listType: ListType; indent: number; checked: boolean };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface ListConfig {\n\t/** Which list types to enable. Defaults to all. */\n\treadonly types: readonly ListType[];\n\t/** Maximum indent depth. Defaults to 4. */\n\treadonly maxIndent: number;\n\t/** When true, a separator is rendered after the last list toolbar item. */\n\treadonly separatorAfter?: boolean;\n\t/**\n\t * When true, checklist checkboxes remain interactive even in read-only mode.\n\t * Defaults to false (checkboxes are fully read-only).\n\t */\n\treadonly interactiveCheckboxes?: boolean;\n\treadonly locale?: ListLocale;\n}\n\nconst DEFAULT_CONFIG: ListConfig = {\n\ttypes: ['bullet', 'ordered', 'checklist'],\n\tmaxIndent: 4,\n};\n\n// --- List Type Metadata ---\n\ninterface ListTypeDefinition {\n\treadonly type: ListType;\n\treadonly label: string;\n\treadonly icon: string;\n\treadonly inputPattern: RegExp;\n\treadonly inputPrefix: string;\n}\n\nconst BULLET_LIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z\"/></svg>';\nconst NUMBERED_LIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z\"/></svg>';\nconst CHECKLIST_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M22 7h-9v2h9V7zm0 8h-9v2h9v-2zM5.54 11L2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 11zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 19z\"/></svg>';\n\nconst LIST_TYPE_DEFINITIONS: readonly ListTypeDefinition[] = [\n\t{\n\t\ttype: 'bullet',\n\t\tlabel: 'Bullet List',\n\t\ticon: BULLET_LIST_ICON,\n\t\tinputPattern: /^[-*] $/,\n\t\tinputPrefix: '- ',\n\t},\n\t{\n\t\ttype: 'ordered',\n\t\tlabel: 'Numbered List',\n\t\ticon: NUMBERED_LIST_ICON,\n\t\tinputPattern: /^\\d+\\. $/,\n\t\tinputPrefix: '1. ',\n\t},\n\t{\n\t\ttype: 'checklist',\n\t\tlabel: 'Checklist',\n\t\ticon: CHECKLIST_ICON,\n\t\tinputPattern: /^\\[[ x]] $/,\n\t\tinputPrefix: '[ ] ',\n\t},\n];\n\n// --- Plugin ---\n\nexport class ListPlugin implements Plugin {\n\treadonly id = 'list';\n\treadonly name = 'List';\n\treadonly priority = 35;\n\n\tprivate readonly config: ListConfig;\n\tprivate locale!: ListLocale;\n\tprivate context: PluginContext | null = null;\n\tprivate checkboxClickHandler: ((e: MouseEvent) => void) | null = null;\n\n\tconstructor(config?: Partial<ListConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.context = context;\n\t\tthis.locale = resolvePluginLocale(LIST_LOCALES, context, this.config.locale);\n\t\tcontext.registerStyleSheet(LIST_CSS);\n\t\tthis.registerNodeSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerInputRules(context);\n\t\tthis.registerToolbarItems(context);\n\t\tthis.registerCheckboxClickHandler(context);\n\t}\n\n\tdestroy(): void {\n\t\tif (this.checkboxClickHandler && this.context) {\n\t\t\tconst container: HTMLElement = this.context.getContainer();\n\t\t\tcontainer.removeEventListener('mousedown', this.checkboxClickHandler);\n\t\t}\n\t\tthis.checkboxClickHandler = null;\n\t\tthis.context = null;\n\t}\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'list_item',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\tattrs: {\n\t\t\t\tlistType: { default: 'bullet' },\n\t\t\t\tindent: { default: 0 },\n\t\t\t\tchecked: { default: false },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst listType = node.attrs?.listType ?? 'bullet';\n\t\t\t\tconst indent = node.attrs?.indent ?? 0;\n\t\t\t\tconst checked = node.attrs?.checked ?? false;\n\n\t\t\t\tconst li = createBlockElement('li', node.id);\n\t\t\t\tli.setAttribute('role', 'listitem');\n\t\t\t\tli.setAttribute('data-list-type', listType);\n\t\t\t\tli.setAttribute('data-indent', String(indent));\n\t\t\t\tli.className = `notectl-list-item notectl-list-item--${listType}`;\n\n\t\t\t\tif (indent > 0) {\n\t\t\t\t\tli.style.marginLeft = `${indent * LIST_MARKER_WIDTH}px`;\n\t\t\t\t}\n\n\t\t\t\tif (listType === 'checklist') {\n\t\t\t\t\tli.setAttribute('data-checked', String(checked));\n\t\t\t\t\tli.setAttribute('aria-checked', String(checked));\n\t\t\t\t}\n\t\t\t\tli.setAttribute('aria-level', String(indent + 1));\n\n\t\t\t\treturn li;\n\t\t\t},\n\t\t\twrapper(node) {\n\t\t\t\tconst listType = node.attrs?.listType ?? 'bullet';\n\t\t\t\tconst tag = listType === 'ordered' ? 'ol' : 'ul';\n\t\t\t\treturn {\n\t\t\t\t\ttag,\n\t\t\t\t\tkey: `list-${listType}`,\n\t\t\t\t\tclassName: `notectl-list notectl-list--${listType}`,\n\t\t\t\t\tattrs: { role: 'list' },\n\t\t\t\t};\n\t\t\t},\n\t\t\ttoHTML(node, content) {\n\t\t\t\tconst listType: string = (node.attrs?.listType as string) ?? 'bullet';\n\t\t\t\tconst checked: boolean = (node.attrs?.checked as boolean) ?? false;\n\n\t\t\t\tif (listType === 'checklist') {\n\t\t\t\t\tconst checkedAttr: string = checked ? ' checked' : '';\n\t\t\t\t\tconst ariaChecked: string = String(checked);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t`<li role=\"checkbox\" aria-checked=\"${ariaChecked}\">` +\n\t\t\t\t\t\t`<input type=\"checkbox\" disabled${checkedAttr}>` +\n\t\t\t\t\t\t`${content || '<br>'}</li>`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn `<li>${content || '<br>'}</li>`;\n\t\t\t},\n\t\t\tparseHTML: [{ tag: 'li' }],\n\t\t\tsanitize: {\n\t\t\t\ttags: ['ul', 'ol', 'li', 'input'],\n\t\t\t\tattrs: ['type', 'disabled', 'checked', 'role', 'aria-checked'],\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tconst enabledTypes = this.getEnabledTypes();\n\n\t\tfor (const def of enabledTypes) {\n\t\t\tcontext.registerCommand(`toggleList:${def.type}`, () => {\n\t\t\t\treturn this.toggleList(context, def.type);\n\t\t\t});\n\t\t}\n\n\t\tcontext.registerCommand('indentListItem', () => {\n\t\t\treturn this.indent(context);\n\t\t});\n\n\t\tcontext.registerCommand('outdentListItem', () => {\n\t\t\treturn this.outdent(context);\n\t\t});\n\n\t\tif (this.config.types.includes('checklist')) {\n\t\t\tcontext.registerCommand('toggleChecklistItem', () => this.toggleChecked(context), {\n\t\t\t\treadonlyAllowed: true,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\tEnter: () => this.handleEnter(context),\n\t\t\tBackspace: () => this.handleBackspace(context),\n\t\t\tTab: () => this.indent(context),\n\t\t\t'Shift-Tab': () => this.outdent(context),\n\t\t});\n\t}\n\n\tprivate registerInputRules(context: PluginContext): void {\n\t\tconst enabledTypes = this.getEnabledTypes();\n\n\t\tfor (const def of enabledTypes) {\n\t\t\tcontext.registerInputRule({\n\t\t\t\tpattern: def.inputPattern,\n\t\t\t\thandler: (state, match, start, _end) => {\n\t\t\t\t\tconst sel = state.selection;\n\t\t\t\t\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\t\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\t\tconst matchStr = match[0] ?? '';\n\t\t\t\t\tconst matchLen = matchStr.length;\n\t\t\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\t\t\tlistType: def.type,\n\t\t\t\t\t\tindent: 0,\n\t\t\t\t\t};\n\t\t\t\t\tif (def.type === 'checklist') {\n\t\t\t\t\t\tattrs.checked = matchStr.includes('[x]');\n\t\t\t\t\t}\n\n\t\t\t\t\treturn state\n\t\t\t\t\t\t.transaction('input')\n\t\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + matchLen)\n\t\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('list_item'), attrs)\n\t\t\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t\t\t.build();\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate getListLabel(type: ListType): string {\n\t\tconst labels: Record<ListType, string> = {\n\t\t\tbullet: this.locale.bulletList,\n\t\t\tordered: this.locale.numberedList,\n\t\t\tchecklist: this.locale.checklist,\n\t\t};\n\t\treturn labels[type];\n\t}\n\n\tprivate registerToolbarItems(context: PluginContext): void {\n\t\tconst enabledTypes = this.getEnabledTypes();\n\t\tconst lastType = enabledTypes.at(-1);\n\n\t\tfor (const def of enabledTypes) {\n\t\t\tcontext.registerToolbarItem({\n\t\t\t\tid: `list-${def.type}`,\n\t\t\t\tgroup: 'block',\n\t\t\t\ticon: def.icon,\n\t\t\t\tlabel: this.getListLabel(def.type),\n\t\t\t\tcommand: `toggleList:${def.type}`,\n\t\t\t\tpriority: def.type === 'bullet' ? 70 : def.type === 'ordered' ? 71 : 72,\n\t\t\t\tseparatorAfter: this.config.separatorAfter && def === lastType,\n\t\t\t\tisActive: (state) => this.isListActive(state, def.type),\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- Command Implementations ---\n\n\tprivate toggleList(context: PluginContext, listType: ListType): boolean {\n\t\tconst state = context.getState();\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return false;\n\n\t\t// If already this list type, convert back to paragraph\n\t\tif (block.type === 'list_item' && block.attrs?.listType === listType) {\n\t\t\tconst tr = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(sel)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Convert to list item\n\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\tlistType,\n\t\t\tindent: isNodeOfType(block, 'list_item') ? block.attrs.indent : 0,\n\t\t};\n\t\tif (listType === 'checklist') {\n\t\t\tattrs.checked = false;\n\t\t}\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(sel.anchor.blockId, nodeType('list_item'), attrs)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tprivate indent(context: PluginContext): boolean {\n\t\tconst state = context.getState();\n\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\tif (!block || !isNodeOfType(block, 'list_item')) return false;\n\n\t\tif (block.attrs.indent >= this.config.maxIndent) return false;\n\n\t\treturn this.setIndent(context, state, block.attrs.indent + 1);\n\t}\n\n\tprivate outdent(context: PluginContext): boolean {\n\t\tconst state = context.getState();\n\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\tif (!block || !isNodeOfType(block, 'list_item')) return false;\n\n\t\tif (block.attrs.indent <= 0) return false;\n\n\t\treturn this.setIndent(context, state, block.attrs.indent - 1);\n\t}\n\n\tprivate setIndent(context: PluginContext, state: EditorState, indent: number): boolean {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return false;\n\n\t\tconst attrs = { ...block.attrs, indent } as Record<string, string | number | boolean>;\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(sel.anchor.blockId, nodeType('list_item'), attrs)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tprivate toggleChecked(context: PluginContext, targetId?: BlockId): boolean {\n\t\tif (context.isReadOnly() && !this.config.interactiveCheckboxes) return false;\n\n\t\tconst state = context.getState();\n\t\tconst bid: BlockId | null =\n\t\t\ttargetId ??\n\t\t\t(isNodeSelection(state.selection) || isGapCursor(state.selection)\n\t\t\t\t? null\n\t\t\t\t: state.selection.anchor.blockId);\n\t\tif (!bid) return false;\n\n\t\tconst block = state.getBlock(bid);\n\t\tif (!block || block.type !== 'list_item' || block.attrs?.listType !== 'checklist') {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst checked: boolean = !block.attrs?.checked;\n\t\tconst attrs = { ...block.attrs, checked } as Record<string, string | number | boolean>;\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(bid, nodeType('list_item'), attrs)\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Handles Backspace at the start of a list item.\n\t * Converts the list item back to a paragraph, preserving text.\n\t */\n\tprivate handleBackspace(context: PluginContext): boolean {\n\t\tconst state = context.getState();\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\t\tif (!isCollapsed(sel)) return false;\n\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block || block.type !== 'list_item') return false;\n\t\tif (sel.anchor.offset !== 0) return false;\n\n\t\tconst tr = state\n\t\t\t.transaction('input')\n\t\t\t.setBlockType(sel.anchor.blockId, nodeType('paragraph'))\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Handles Enter inside a list item.\n\t * Empty item → exit list (convert to paragraph).\n\t * Non-empty item → split and create a new list item with the same type.\n\t */\n\tprivate handleEnter(context: PluginContext): boolean {\n\t\tconst state = context.getState();\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\t\tif (!isCollapsed(sel)) return false;\n\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block || block.type !== 'list_item') return false;\n\n\t\tconst text = getBlockText(block);\n\n\t\tif (text === '') {\n\t\t\t// Empty list item → convert to paragraph (exit list)\n\t\t\tconst tr = state\n\t\t\t\t.transaction('input')\n\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(sel)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Non-empty → split block and set new block to same list type\n\t\tconst newBlockId = generateBlockId();\n\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\tlistType: isNodeOfType(block, 'list_item') ? block.attrs.listType : 'bullet',\n\t\t\tindent: isNodeOfType(block, 'list_item') ? block.attrs.indent : 0,\n\t\t};\n\t\tif (attrs.listType === 'checklist') {\n\t\t\tattrs.checked = false;\n\t\t}\n\n\t\tconst tr = state\n\t\t\t.transaction('input')\n\t\t\t.splitBlock(sel.anchor.blockId, sel.anchor.offset, newBlockId)\n\t\t\t.setBlockType(newBlockId, nodeType('list_item'), attrs)\n\t\t\t.setSelection(createCollapsedSelection(newBlockId, 0))\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\t// --- Checkbox Click Handling ---\n\n\tprivate registerCheckboxClickHandler(context: PluginContext): void {\n\t\tif (!this.config.types.includes('checklist')) return;\n\n\t\tthis.checkboxClickHandler = (e: MouseEvent) => {\n\t\t\tif (context.isReadOnly() && !this.config.interactiveCheckboxes) return;\n\n\t\t\tconst target: EventTarget | null = e.target;\n\t\t\tif (!(target instanceof HTMLElement)) return;\n\n\t\t\tconst li: HTMLElement | null = target.closest('.notectl-list-item--checklist');\n\t\t\tif (!li) return;\n\n\t\t\tconst rect: DOMRect = li.getBoundingClientRect();\n\t\t\tif (e.clientX - rect.left >= LIST_MARKER_WIDTH) return;\n\n\t\t\te.preventDefault();\n\n\t\t\tconst bid: string | null = li.getAttribute('data-block-id');\n\t\t\tif (!bid) return;\n\n\t\t\tthis.toggleChecked(context, blockId(bid));\n\t\t};\n\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tcontainer.addEventListener('mousedown', this.checkboxClickHandler);\n\t}\n\n\t// --- Helpers ---\n\n\tprivate isListActive(state: EditorState, listType: ListType): boolean {\n\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\treturn block?.type === 'list_item' && block.attrs?.listType === listType;\n\t}\n\n\tprivate getEnabledTypes(): readonly ListTypeDefinition[] {\n\t\treturn LIST_TYPE_DEFINITIONS.filter((def) => this.config.types.includes(def.type));\n\t}\n}\n"],"names":["LIST_LOCALE_EN","bulletList","numberedList","checklist","LIST_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","types","maxIndent","LIST_TYPE_DEFINITIONS","type","label","icon","inputPattern","inputPrefix","ListPlugin","id","name","priority","config","locale","context","checkboxClickHandler","this","resolvePluginLocale","registerStyleSheet","registerNodeSpec","registerCommands","registerKeymaps","registerInputRules","registerToolbarItems","registerCheckboxClickHandler","destroy","getContainer","removeEventListener","group","content","allow","attrs","listType","default","indent","checked","node","li","createBlockElement","setAttribute","String","className","style","marginLeft","tag","key","role","checkedAttr","parseHTML","sanitize","tags","enabledTypes","getEnabledTypes","def","registerCommand","toggleList","outdent","includes","toggleChecked","readonlyAllowed","registerKeymap","Enter","handleEnter","Backspace","handleBackspace","Tab","registerInputRule","pattern","handler","state","match","start","_end","sel","selection","isNodeSelection","isGapCursor","isCollapsed","block","getBlock","anchor","blockId","matchStr","matchLen","length","transaction","deleteTextAt","setBlockType","nodeType","setSelection","createCollapsedSelection","build","bullet","ordered","lastType","at","registerToolbarItem","getListLabel","command","separatorAfter","isActive","isListActive","getState","tr","dispatch","isNodeOfType","setIndent","targetId","isReadOnly","interactiveCheckboxes","bid","offset","getBlockText","newBlockId","generateBlockId","splitBlock","e","target","HTMLElement","closest","rect","getBoundingClientRect","clientX","left","preventDefault","getAttribute","addEventListener","filter"],"mappings":";;;;;;AACO,MCaMA,IAA6B,EACzCC,YAAY,eACZC,cAAc,iBACdC,WAAW,eA6DCC,IAA2C,EACvDC,IAAIL,GACJM,IA1DyC,EACzC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|
2
2
|
import { r as a } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
3
3
|
import { e as l } from "./HTMLUtils-DTqQzcKR.mjs";
|
|
4
|
-
import { r as s, i } from "./
|
|
5
|
-
const
|
|
4
|
+
import { r as s, i } from "./ColorValidation-CV4f1wu6.mjs";
|
|
5
|
+
const c = { label: "Text Color", tooltip: "Text Color", resetLabel: "Default", ariaLabelPrefix: "Text color" }, f = { en: c, de: { label: "Textfarbe", tooltip: "Textfarbe", resetLabel: "Standard", ariaLabelPrefix: "Textfarbe" }, es: { label: "Color de texto", tooltip: "Color de texto", resetLabel: "Predeterminado", ariaLabelPrefix: "Color de texto" }, fr: { label: "Couleur du texte", tooltip: "Couleur du texte", resetLabel: "Par défaut", ariaLabelPrefix: "Couleur du texte" }, zh: { label: "文字颜色", tooltip: "文字颜色", resetLabel: "默认", ariaLabelPrefix: "文字颜色" }, ru: { label: "Цвет текста", tooltip: "Цвет текста", resetLabel: "По умолчанию", ariaLabelPrefix: "Цвет текста" }, ar: { label: "لون النص", tooltip: "لون النص", resetLabel: "افتراضي", ariaLabelPrefix: "لون النص" }, hi: { label: "टेक्स्ट रंग", tooltip: "टेक्स्ट रंग", resetLabel: "डिफ़ॉल्ट", ariaLabelPrefix: "टेक्स्ट रंग" } }, b = ["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc", "#d9d9d9", "#efefef", "#f3f3f3", "#ffffff", "#980000", "#ff0000", "#ff9900", "#ffff00", "#00ff00", "#00ffff", "#4a86e8", "#0000ff", "#9900ff", "#ff00ff", "#e6b8af", "#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#c9daf8", "#cfe2f3", "#d9d2e9", "#ead1dc", "#dd7e6b", "#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#a4c2f4", "#9fc5e8", "#b4a7d6", "#d5a6bd", "#cc4125", "#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6d9eeb", "#6fa8dc", "#8e7cc3", "#c27ba0", "#a61c00", "#cc0000", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3c78d8", "#3d85c6", "#674ea7", "#a64d79", "#85200c", "#990000", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#1155cc", "#0b5394", "#351c75", "#741b47"];
|
|
6
6
|
class d {
|
|
7
7
|
id = "textColor";
|
|
8
8
|
name = "Text Color";
|
|
@@ -14,15 +14,18 @@ class d {
|
|
|
14
14
|
this.config = { ...e2 }, this.colors = s(e2?.colors, b, "TextColorPlugin");
|
|
15
15
|
}
|
|
16
16
|
init(t2) {
|
|
17
|
-
this.locale = a(
|
|
17
|
+
this.locale = a(f, t2, this.config.locale), t2.registerStyleSheet(e), this.registerMarkSpec(t2), this.registerCommands(t2), this.registerToolbarItem(t2);
|
|
18
18
|
}
|
|
19
19
|
registerMarkSpec(e2) {
|
|
20
20
|
e2.registerMarkSpec({ type: "textColor", rank: 5, attrs: { color: { default: "" } }, toDOM(e3) {
|
|
21
|
-
const t2 = document.createElement("span"),
|
|
22
|
-
return t2.style.color =
|
|
21
|
+
const t2 = document.createElement("span"), o2 = e3.attrs?.color ?? "";
|
|
22
|
+
return t2.style.color = o2, t2;
|
|
23
23
|
}, toHTMLString: (e3, t2) => {
|
|
24
|
-
const
|
|
25
|
-
return
|
|
24
|
+
const o2 = String(e3.attrs?.color ?? "");
|
|
25
|
+
return o2 && i(o2) ? `<span style="color: ${l(o2)}">${t2}</span>` : t2;
|
|
26
|
+
}, toHTMLStyle: (e3) => {
|
|
27
|
+
const t2 = String(e3.attrs?.color ?? "");
|
|
28
|
+
return t2 && i(t2) ? `color: ${l(t2)}` : null;
|
|
26
29
|
}, parseHTML: [{ tag: "span", getAttrs: (e3) => {
|
|
27
30
|
const t2 = e3.style.color;
|
|
28
31
|
return !(!t2 || !i(t2)) && { color: t2 };
|
|
@@ -33,14 +36,14 @@ class d {
|
|
|
33
36
|
}
|
|
34
37
|
registerToolbarItem(e2) {
|
|
35
38
|
const t2 = ['<svg xmlns="http://www.w3.org/2000/svg"', ' viewBox="0 0 24 24">', '<path d="M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z"/>', '<rect x="3" y="19.5" width="18" height="3"', ' rx="0.5" fill="#e53935"/>', "</svg>"].join("");
|
|
36
|
-
e2.registerToolbarItem({ id: "textColor", group: "format", icon: t2, label: this.locale.label, tooltip: this.locale.tooltip, command: "removeTextColor", priority: 45, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (e3, t3,
|
|
37
|
-
|
|
38
|
-
}, isActive: (e3) =>
|
|
39
|
+
e2.registerToolbarItem({ id: "textColor", group: "format", icon: t2, label: this.locale.label, tooltip: this.locale.tooltip, command: "removeTextColor", priority: 45, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (e3, t3, o2) => {
|
|
40
|
+
r(e3, t3, { markType: "textColor", colors: this.colors, columns: 10, resetLabel: this.locale.resetLabel, resetCommand: "removeTextColor", ariaLabelPrefix: this.locale.ariaLabelPrefix, onClose: o2 });
|
|
41
|
+
}, isActive: (e3) => o(e3, "textColor") });
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
export {
|
|
42
45
|
d as T,
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
f as a,
|
|
47
|
+
c as b
|
|
45
48
|
};
|
|
46
|
-
//# sourceMappingURL=index-
|
|
49
|
+
//# sourceMappingURL=index-Ckzqtn5D.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-CflvcXSd.mjs","sources":["../../src/plugins/text-color/TextColorLocale.ts","../../src/plugins/text-color/TextColorPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the TextColorPlugin. */\n\n// --- Locale Interface ---\n\nexport interface TextColorLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly resetLabel: string;\n\treadonly ariaLabelPrefix: string;\n}\n\n// --- Default English Locale ---\n\nexport const TEXT_COLOR_LOCALE_EN: TextColorLocale = {\n\tlabel: 'Text Color',\n\ttooltip: 'Text Color',\n\tresetLabel: 'Default',\n\tariaLabelPrefix: 'Text color',\n};\n\n// --- German Locale ---\n\nexport const TEXT_COLOR_LOCALE_DE: TextColorLocale = {\n\tlabel: 'Textfarbe',\n\ttooltip: 'Textfarbe',\n\tresetLabel: 'Standard',\n\tariaLabelPrefix: 'Textfarbe',\n};\n\n// --- Spanish Locale ---\n\nexport const TEXT_COLOR_LOCALE_ES: TextColorLocale = {\n\tlabel: 'Color de texto',\n\ttooltip: 'Color de texto',\n\tresetLabel: 'Predeterminado',\n\tariaLabelPrefix: 'Color de texto',\n};\n\n// --- French Locale ---\n\nexport const TEXT_COLOR_LOCALE_FR: TextColorLocale = {\n\tlabel: 'Couleur du texte',\n\ttooltip: 'Couleur du texte',\n\tresetLabel: 'Par défaut',\n\tariaLabelPrefix: 'Couleur du texte',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const TEXT_COLOR_LOCALE_ZH: TextColorLocale = {\n\tlabel: '文字颜色',\n\ttooltip: '文字颜色',\n\tresetLabel: '默认',\n\tariaLabelPrefix: '文字颜色',\n};\n\n// --- Russian Locale ---\n\nexport const TEXT_COLOR_LOCALE_RU: TextColorLocale = {\n\tlabel: 'Цвет текста',\n\ttooltip: 'Цвет текста',\n\tresetLabel: 'По умолчанию',\n\tariaLabelPrefix: 'Цвет текста',\n};\n\n// --- Arabic Locale ---\n\nexport const TEXT_COLOR_LOCALE_AR: TextColorLocale = {\n\tlabel: 'لون النص',\n\ttooltip: 'لون النص',\n\tresetLabel: 'افتراضي',\n\tariaLabelPrefix: 'لون النص',\n};\n\n// --- Hindi Locale ---\n\nexport const TEXT_COLOR_LOCALE_HI: TextColorLocale = {\n\tlabel: 'टेक्स्ट रंग',\n\ttooltip: 'टेक्स्ट रंग',\n\tresetLabel: 'डिफ़ॉल्ट',\n\tariaLabelPrefix: 'टेक्स्ट रंग',\n};\n\n// --- Locale Map ---\n\nexport const TEXT_COLOR_LOCALES: Record<string, TextColorLocale> = {\n\ten: TEXT_COLOR_LOCALE_EN,\n\tde: TEXT_COLOR_LOCALE_DE,\n\tes: TEXT_COLOR_LOCALE_ES,\n\tfr: TEXT_COLOR_LOCALE_FR,\n\tzh: TEXT_COLOR_LOCALE_ZH,\n\tru: TEXT_COLOR_LOCALE_RU,\n\tar: TEXT_COLOR_LOCALE_AR,\n\thi: TEXT_COLOR_LOCALE_HI,\n};\n","/**\n * TextColorPlugin: registers a text color mark with attrs,\n * toolbar button with a color picker popup, and removeTextColor command.\n */\n\nimport { COLOR_PICKER_CSS } from '../../editor/styles/color-picker.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isColorMarkActive, removeColorMark } from '../shared/ColorMarkOperations.js';\nimport { renderColorPickerPopup } from '../shared/ColorPickerPopup.js';\nimport { isValidCSSColor, resolveColors } from '../shared/ColorValidation.js';\nimport { TEXT_COLOR_LOCALES, type TextColorLocale } from './TextColorLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\ttextColor: { color: string };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface TextColorConfig {\n\t/**\n\t * Restricts the color picker to a specific set of hex colors.\n\t * Each value must be a valid hex color code (`#RGB` or `#RRGGBB`).\n\t * Duplicates are removed automatically (case-insensitive).\n\t * When omitted, the full default palette is shown.\n\t */\n\treadonly colors?: readonly string[];\n\t/** When true, a separator is rendered after the textColor toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: TextColorLocale;\n}\n\n// --- Color Palette (Google Docs style: 10 columns x 7 rows) ---\n\nconst COLOR_PALETTE: readonly string[] = [\n\t// Row 1 — dark\n\t'#000000',\n\t'#434343',\n\t'#666666',\n\t'#999999',\n\t'#b7b7b7',\n\t'#cccccc',\n\t'#d9d9d9',\n\t'#efefef',\n\t'#f3f3f3',\n\t'#ffffff',\n\t// Row 2 — vivid\n\t'#980000',\n\t'#ff0000',\n\t'#ff9900',\n\t'#ffff00',\n\t'#00ff00',\n\t'#00ffff',\n\t'#4a86e8',\n\t'#0000ff',\n\t'#9900ff',\n\t'#ff00ff',\n\t// Row 3 — light 3\n\t'#e6b8af',\n\t'#f4cccc',\n\t'#fce5cd',\n\t'#fff2cc',\n\t'#d9ead3',\n\t'#d0e0e3',\n\t'#c9daf8',\n\t'#cfe2f3',\n\t'#d9d2e9',\n\t'#ead1dc',\n\t// Row 4 — light 2\n\t'#dd7e6b',\n\t'#ea9999',\n\t'#f9cb9c',\n\t'#ffe599',\n\t'#b6d7a8',\n\t'#a2c4c9',\n\t'#a4c2f4',\n\t'#9fc5e8',\n\t'#b4a7d6',\n\t'#d5a6bd',\n\t// Row 5 — light 1\n\t'#cc4125',\n\t'#e06666',\n\t'#f6b26b',\n\t'#ffd966',\n\t'#93c47d',\n\t'#76a5af',\n\t'#6d9eeb',\n\t'#6fa8dc',\n\t'#8e7cc3',\n\t'#c27ba0',\n\t// Row 6 — dark 1\n\t'#a61c00',\n\t'#cc0000',\n\t'#e69138',\n\t'#f1c232',\n\t'#6aa84f',\n\t'#45818e',\n\t'#3c78d8',\n\t'#3d85c6',\n\t'#674ea7',\n\t'#a64d79',\n\t// Row 7 — dark 2\n\t'#85200c',\n\t'#990000',\n\t'#b45f06',\n\t'#bf9000',\n\t'#38761d',\n\t'#134f5c',\n\t'#1155cc',\n\t'#0b5394',\n\t'#351c75',\n\t'#741b47',\n];\n\n// --- Plugin ---\n\nexport class TextColorPlugin implements Plugin {\n\treadonly id = 'textColor';\n\treadonly name = 'Text Color';\n\treadonly priority = 23;\n\n\tprivate readonly config: TextColorConfig;\n\tprivate readonly colors: readonly string[];\n\tprivate locale!: TextColorLocale;\n\n\tconstructor(config?: Partial<TextColorConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.colors = resolveColors(config?.colors, COLOR_PALETTE, 'TextColorPlugin');\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(TEXT_COLOR_LOCALES, context, this.config.locale);\n\n\t\tcontext.registerStyleSheet(COLOR_PICKER_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: 'textColor',\n\t\t\trank: 5,\n\t\t\tattrs: {\n\t\t\t\tcolor: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(mark) {\n\t\t\t\tconst span = document.createElement('span');\n\t\t\t\tconst color = mark.attrs?.color ?? '';\n\t\t\t\tspan.style.color = color;\n\t\t\t\treturn span;\n\t\t\t},\n\t\t\ttoHTMLString: (mark, content) => {\n\t\t\t\tconst color: string = String(mark.attrs?.color ?? '');\n\t\t\t\tif (!color || !isValidCSSColor(color)) return content;\n\t\t\t\treturn `<span style=\"color: ${escapeHTML(color)}\">${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 color: string = el.style.color;\n\t\t\t\t\t\tif (!color || !isValidCSSColor(color)) return false;\n\t\t\t\t\t\treturn { color };\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\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeTextColor', () => {\n\t\t\treturn removeColorMark(context, context.getState(), 'textColor');\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst pathD =\n\t\t\t'M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2z' + 'm-1.38 9L12 5.67 14.38 12H9.62z';\n\t\tconst icon: string = [\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\"',\n\t\t\t' viewBox=\"0 0 24 24\">',\n\t\t\t`<path d=\"${pathD}\"/>`,\n\t\t\t'<rect x=\"3\" y=\"19.5\" width=\"18\" height=\"3\"',\n\t\t\t' rx=\"0.5\" fill=\"#e53935\"/>',\n\t\t\t'</svg>',\n\t\t].join('');\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'textColor',\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: 'removeTextColor',\n\t\t\tpriority: 45,\n\t\t\tpopupType: 'custom',\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderColorPickerPopup(container, ctx, {\n\t\t\t\t\tmarkType: 'textColor',\n\t\t\t\t\tcolors: this.colors,\n\t\t\t\t\tcolumns: 10,\n\t\t\t\t\tresetLabel: this.locale.resetLabel,\n\t\t\t\t\tresetCommand: 'removeTextColor',\n\t\t\t\t\tariaLabelPrefix: this.locale.ariaLabelPrefix,\n\t\t\t\t\tonClose,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state: EditorState) => isColorMarkActive(state, 'textColor'),\n\t\t});\n\t}\n}\n"],"names":["TEXT_COLOR_LOCALE_EN","label","tooltip","resetLabel","ariaLabelPrefix","TEXT_COLOR_LOCALES","en","de","es","fr","zh","ru","ar","hi","COLOR_PALETTE","TextColorPlugin","id","name","priority","config","colors","locale","this","resolveColors","context","resolvePluginLocale","registerStyleSheet","COLOR_PICKER_CSS","registerMarkSpec","registerCommands","registerToolbarItem","type","rank","attrs","color","default","mark","span","document","createElement","style","toHTMLString","content","String","isValidCSSColor","escapeHTML","parseHTML","tag","getAttrs","el","sanitize","tags","registerCommand","removeColorMark","getState","icon","join","group","command","popupType","separatorAfter","renderPopup","container","ctx","onClose","renderColorPickerPopup","markType","columns","resetCommand","isActive","state","isColorMarkActive"],"mappings":";;;;AAaO,MAAMA,IAAwC,EACpDC,OAAO,cACPC,SAAS,cACTC,YAAY,WACZC,iBAAiB,aAAA,GAoELC,IAAsD,EAClEC,IAAIN,GACJO,IAjEoD,EACpDN,OAAO,aACPC,SAAS,aACTC,YAAY,YACZC,iBAAiB,YAAA,GA8DjBI,IAzDoD,EACpDP,OAAO,kBACPC,SAAS,kBACTC,YAAY,kBACZC,iBAAiB,iBAAA,GAsDjBK,IAjDoD,EACpDR,OAAO,oBACPC,SAAS,oBACTC,YAAY,cACZC,iBAAiB,sBA8CjBM,IAzCoD,EACpDT,OAAO,QACPC,SAAS,QACTC,YAAY,MACZC,iBAAiB,OAAA,GAsCjBO,IAjCoD,EACpDV,OAAO,eACPC,SAAS,eACTC,YAAY,gBACZC,iBAAiB,cAAA,GA8BjBQ,IAzBoD,EACpDX,OAAO,YACPC,SAAS,YACTC,YAAY,WACZC,iBAAiB,cAsBjBS,IAjBoD,EACpDZ,OAAO,eACPC,SAAS,eACTC,YAAY,YACZC,iBAAiB,mBCxCZU,IAAmC,CAExC,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WAEA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WAEA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WAEA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WAEA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WAEA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WAEA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA;AAKM,MAAMC,EAAAA;AAAAA,EACHC,KAAK;AAAA,EACLC,OAAO;AAAA,EACPC,WAAW;AAAA,EAEHC;AAAAA,EACAC;AAAAA,EACTC;AAAAA,EAER,YAAYF,IAAAA;AACXG,SAAKH,SAAS,EAAA,GAAKA,MACnBG,KA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AA,GAAQM,oBAAoB,EAC3Bd,IAAI,aACJyC,OAAO,UACPF,MAAAA,IACAtD,OAAOqB,KAAKD,OAAOpB,OACnBC,SAASoB,KAAKD,OAAOnB,SACrBwD,SAAS,mBACTxC,UAAU,IACVyC,WAAW,UACXC,gBAAgBtC,KAAKH,OAAOyC,gBAC5BC,aAAa,CAACC,IAAWC,IAAKC,OAAAA;AAC7BC,QAAuBH,IAAWC,IAAK,EACtCG,UAAU,aACV9C,QAAQE,KAAKF,QACb+C,SAAS,IACThE,YAAYmB,KAAKD,OAAOlB,YACxBiE,cAAc,mBACdhE,iBAAiBkB,KAAKD,OAAOjB,iBAC7B4D;OAGFK,UAAWC,CAAAA,OAAuBC,EAAkBD,IAAO,WAAA,EAAA,CAAA;AAAA,EAE7D;AAAA;"}
|
|
1
|
+
{"version":3,"file":"index-Ckzqtn5D.mjs","sources":["../../src/plugins/text-color/TextColorLocale.ts","../../src/plugins/text-color/TextColorPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the TextColorPlugin. */\n\n// --- Locale Interface ---\n\nexport interface TextColorLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly resetLabel: string;\n\treadonly ariaLabelPrefix: string;\n}\n\n// --- Default English Locale ---\n\nexport const TEXT_COLOR_LOCALE_EN: TextColorLocale = {\n\tlabel: 'Text Color',\n\ttooltip: 'Text Color',\n\tresetLabel: 'Default',\n\tariaLabelPrefix: 'Text color',\n};\n\n// --- German Locale ---\n\nexport const TEXT_COLOR_LOCALE_DE: TextColorLocale = {\n\tlabel: 'Textfarbe',\n\ttooltip: 'Textfarbe',\n\tresetLabel: 'Standard',\n\tariaLabelPrefix: 'Textfarbe',\n};\n\n// --- Spanish Locale ---\n\nexport const TEXT_COLOR_LOCALE_ES: TextColorLocale = {\n\tlabel: 'Color de texto',\n\ttooltip: 'Color de texto',\n\tresetLabel: 'Predeterminado',\n\tariaLabelPrefix: 'Color de texto',\n};\n\n// --- French Locale ---\n\nexport const TEXT_COLOR_LOCALE_FR: TextColorLocale = {\n\tlabel: 'Couleur du texte',\n\ttooltip: 'Couleur du texte',\n\tresetLabel: 'Par défaut',\n\tariaLabelPrefix: 'Couleur du texte',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const TEXT_COLOR_LOCALE_ZH: TextColorLocale = {\n\tlabel: '文字颜色',\n\ttooltip: '文字颜色',\n\tresetLabel: '默认',\n\tariaLabelPrefix: '文字颜色',\n};\n\n// --- Russian Locale ---\n\nexport const TEXT_COLOR_LOCALE_RU: TextColorLocale = {\n\tlabel: 'Цвет текста',\n\ttooltip: 'Цвет текста',\n\tresetLabel: 'По умолчанию',\n\tariaLabelPrefix: 'Цвет текста',\n};\n\n// --- Arabic Locale ---\n\nexport const TEXT_COLOR_LOCALE_AR: TextColorLocale = {\n\tlabel: 'لون النص',\n\ttooltip: 'لون النص',\n\tresetLabel: 'افتراضي',\n\tariaLabelPrefix: 'لون النص',\n};\n\n// --- Hindi Locale ---\n\nexport const TEXT_COLOR_LOCALE_HI: TextColorLocale = {\n\tlabel: 'टेक्स्ट रंग',\n\ttooltip: 'टेक्स्ट रंग',\n\tresetLabel: 'डिफ़ॉल्ट',\n\tariaLabelPrefix: 'टेक्स्ट रंग',\n};\n\n// --- Locale Map ---\n\nexport const TEXT_COLOR_LOCALES: Record<string, TextColorLocale> = {\n\ten: TEXT_COLOR_LOCALE_EN,\n\tde: TEXT_COLOR_LOCALE_DE,\n\tes: TEXT_COLOR_LOCALE_ES,\n\tfr: TEXT_COLOR_LOCALE_FR,\n\tzh: TEXT_COLOR_LOCALE_ZH,\n\tru: TEXT_COLOR_LOCALE_RU,\n\tar: TEXT_COLOR_LOCALE_AR,\n\thi: TEXT_COLOR_LOCALE_HI,\n};\n","/**\n * TextColorPlugin: registers a text color mark with attrs,\n * toolbar button with a color picker popup, and removeTextColor command.\n */\n\nimport { COLOR_PICKER_CSS } from '../../editor/styles/color-picker.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isColorMarkActive, removeColorMark } from '../shared/ColorMarkOperations.js';\nimport { renderColorPickerPopup } from '../shared/ColorPickerPopup.js';\nimport { isValidCSSColor, resolveColors } from '../shared/ColorValidation.js';\nimport { TEXT_COLOR_LOCALES, type TextColorLocale } from './TextColorLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\ttextColor: { color: string };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface TextColorConfig {\n\t/**\n\t * Restricts the color picker to a specific set of hex colors.\n\t * Each value must be a valid hex color code (`#RGB` or `#RRGGBB`).\n\t * Duplicates are removed automatically (case-insensitive).\n\t * When omitted, the full default palette is shown.\n\t */\n\treadonly colors?: readonly string[];\n\t/** When true, a separator is rendered after the textColor toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: TextColorLocale;\n}\n\n// --- Color Palette (Google Docs style: 10 columns x 7 rows) ---\n\nconst COLOR_PALETTE: readonly string[] = [\n\t// Row 1 — dark\n\t'#000000',\n\t'#434343',\n\t'#666666',\n\t'#999999',\n\t'#b7b7b7',\n\t'#cccccc',\n\t'#d9d9d9',\n\t'#efefef',\n\t'#f3f3f3',\n\t'#ffffff',\n\t// Row 2 — vivid\n\t'#980000',\n\t'#ff0000',\n\t'#ff9900',\n\t'#ffff00',\n\t'#00ff00',\n\t'#00ffff',\n\t'#4a86e8',\n\t'#0000ff',\n\t'#9900ff',\n\t'#ff00ff',\n\t// Row 3 — light 3\n\t'#e6b8af',\n\t'#f4cccc',\n\t'#fce5cd',\n\t'#fff2cc',\n\t'#d9ead3',\n\t'#d0e0e3',\n\t'#c9daf8',\n\t'#cfe2f3',\n\t'#d9d2e9',\n\t'#ead1dc',\n\t// Row 4 — light 2\n\t'#dd7e6b',\n\t'#ea9999',\n\t'#f9cb9c',\n\t'#ffe599',\n\t'#b6d7a8',\n\t'#a2c4c9',\n\t'#a4c2f4',\n\t'#9fc5e8',\n\t'#b4a7d6',\n\t'#d5a6bd',\n\t// Row 5 — light 1\n\t'#cc4125',\n\t'#e06666',\n\t'#f6b26b',\n\t'#ffd966',\n\t'#93c47d',\n\t'#76a5af',\n\t'#6d9eeb',\n\t'#6fa8dc',\n\t'#8e7cc3',\n\t'#c27ba0',\n\t// Row 6 — dark 1\n\t'#a61c00',\n\t'#cc0000',\n\t'#e69138',\n\t'#f1c232',\n\t'#6aa84f',\n\t'#45818e',\n\t'#3c78d8',\n\t'#3d85c6',\n\t'#674ea7',\n\t'#a64d79',\n\t// Row 7 — dark 2\n\t'#85200c',\n\t'#990000',\n\t'#b45f06',\n\t'#bf9000',\n\t'#38761d',\n\t'#134f5c',\n\t'#1155cc',\n\t'#0b5394',\n\t'#351c75',\n\t'#741b47',\n];\n\n// --- Plugin ---\n\nexport class TextColorPlugin implements Plugin {\n\treadonly id = 'textColor';\n\treadonly name = 'Text Color';\n\treadonly priority = 23;\n\n\tprivate readonly config: TextColorConfig;\n\tprivate readonly colors: readonly string[];\n\tprivate locale!: TextColorLocale;\n\n\tconstructor(config?: Partial<TextColorConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.colors = resolveColors(config?.colors, COLOR_PALETTE, 'TextColorPlugin');\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(TEXT_COLOR_LOCALES, context, this.config.locale);\n\n\t\tcontext.registerStyleSheet(COLOR_PICKER_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: 'textColor',\n\t\t\trank: 5,\n\t\t\tattrs: {\n\t\t\t\tcolor: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(mark) {\n\t\t\t\tconst span = document.createElement('span');\n\t\t\t\tconst color = mark.attrs?.color ?? '';\n\t\t\t\tspan.style.color = color;\n\t\t\t\treturn span;\n\t\t\t},\n\t\t\ttoHTMLString: (mark, content) => {\n\t\t\t\tconst color: string = String(mark.attrs?.color ?? '');\n\t\t\t\tif (!color || !isValidCSSColor(color)) return content;\n\t\t\t\treturn `<span style=\"color: ${escapeHTML(color)}\">${content}</span>`;\n\t\t\t},\n\t\t\ttoHTMLStyle: (mark) => {\n\t\t\t\tconst color: string = String(mark.attrs?.color ?? '');\n\t\t\t\tif (!color || !isValidCSSColor(color)) return null;\n\t\t\t\treturn `color: ${escapeHTML(color)}`;\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 color: string = el.style.color;\n\t\t\t\t\t\tif (!color || !isValidCSSColor(color)) return false;\n\t\t\t\t\t\treturn { color };\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\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeTextColor', () => {\n\t\t\treturn removeColorMark(context, context.getState(), 'textColor');\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst pathD =\n\t\t\t'M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2z' + 'm-1.38 9L12 5.67 14.38 12H9.62z';\n\t\tconst icon: string = [\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\"',\n\t\t\t' viewBox=\"0 0 24 24\">',\n\t\t\t`<path d=\"${pathD}\"/>`,\n\t\t\t'<rect x=\"3\" y=\"19.5\" width=\"18\" height=\"3\"',\n\t\t\t' rx=\"0.5\" fill=\"#e53935\"/>',\n\t\t\t'</svg>',\n\t\t].join('');\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'textColor',\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: 'removeTextColor',\n\t\t\tpriority: 45,\n\t\t\tpopupType: 'custom',\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderColorPickerPopup(container, ctx, {\n\t\t\t\t\tmarkType: 'textColor',\n\t\t\t\t\tcolors: this.colors,\n\t\t\t\t\tcolumns: 10,\n\t\t\t\t\tresetLabel: this.locale.resetLabel,\n\t\t\t\t\tresetCommand: 'removeTextColor',\n\t\t\t\t\tariaLabelPrefix: this.locale.ariaLabelPrefix,\n\t\t\t\t\tonClose,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state: EditorState) => isColorMarkActive(state, 'textColor'),\n\t\t});\n\t}\n}\n"],"names":["TEXT_COLOR_LOCALE_EN","label","tooltip","resetLabel","ariaLabelPrefix","TEXT_COLOR_LOCALES","en","de","es","fr","zh","ru","ar","hi","COLOR_PALETTE","TextColorPlugin","id","name","priority","config","colors","locale","this","resolveColors","context","resolvePluginLocale","registerStyleSheet","COLOR_PICKER_CSS","registerMarkSpec","registerCommands","registerToolbarItem","type","rank","attrs","color","default","mark","span","document","createElement","style","toHTMLString","content","String","isValidCSSColor","escapeHTML","toHTMLStyle","parseHTML","tag","getAttrs","el","sanitize","tags","registerCommand","removeColorMark","getState","icon","join","group","command","popupType","separatorAfter","renderPopup","container","ctx","onClose","renderColorPickerPopup","markType","columns","resetCommand","isActive","state","isColorMarkActive"],"mappings":";;;;AAaO,MAAMA,IAAwC,EACpDC,OAAO,cACPC,SAAS,cACTC,YAAY,WACZC,iBAAiB,aAAA,GAoELC,IAAsD,EAClEC,IAAIN,GACJO,IAjEoD,EACpDN,OAAO,aACPC,SAAS,aACTC,YAAY,YACZC,iBAAiB,eA8DjBI,IAzDoD,EACpDP,OAAO,kBACPC,SAAS,kBACTC,YAAY,kBACZC,iBA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,UAAU,IACV0C,WAAW,UACXC,gBAAgBvC,KAAKH,OAAO0C,gBAC5BC,aAAa,CAACC,IAAWC,IAAKC,OAAAA;AAC7BC,QAAuBH,IAAWC,IAAK,EACtCG,UAAU,aACV/C,QAAQE,KAAKF,QACbgD,SAAS,IACTjE,YAAYmB,KAAKD,OAAOlB,YACxBkE,cAAc,mBACdjE,iBAAiBkB,KAAKD,OAAOjB,iBAC7B6D;OAGFK,UAAWC,CAAAA,OAAuBC,EAAkBD,IAAO,WAAA,EAAA,CAAA;AAAA,EAE7D;AAAA;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as t } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
2
2
|
import { m as s } from "./TypeBrands-C09nE2qO.mjs";
|
|
3
|
-
import { f as
|
|
4
|
-
import { e
|
|
3
|
+
import { f as i } from "./ToolbarItem-BpZggUGo.mjs";
|
|
4
|
+
import { e, b as r } from "./MarkCommands-uybmkw9l.mjs";
|
|
5
5
|
const o = { superscriptLabel: "Superscript", superscriptTooltip: (t2) => `Superscript (${t2})`, subscriptLabel: "Subscript", subscriptTooltip: (t2) => `Subscript (${t2})` }, p = { en: o, de: { superscriptLabel: "Hochgestellt", superscriptTooltip: (t2) => `Hochgestellt (${t2})`, subscriptLabel: "Tiefgestellt", subscriptTooltip: (t2) => `Tiefgestellt (${t2})` }, es: { superscriptLabel: "Superíndice", superscriptTooltip: (t2) => `Superíndice (${t2})`, subscriptLabel: "Subíndice", subscriptTooltip: (t2) => `Subíndice (${t2})` }, fr: { superscriptLabel: "Exposant", superscriptTooltip: (t2) => `Exposant (${t2})`, subscriptLabel: "Indice", subscriptTooltip: (t2) => `Indice (${t2})` }, zh: { superscriptLabel: "上标", superscriptTooltip: (t2) => `上标 (${t2})`, subscriptLabel: "下标", subscriptTooltip: (t2) => `下标 (${t2})` }, ru: { superscriptLabel: "Надстрочный", superscriptTooltip: (t2) => `Надстрочный (${t2})`, subscriptLabel: "Подстрочный", subscriptTooltip: (t2) => `Подстрочный (${t2})` }, ar: { superscriptLabel: "مرتفع", superscriptTooltip: (t2) => `مرتفع (${t2})`, subscriptLabel: "منخفض", subscriptTooltip: (t2) => `منخفض (${t2})` }, hi: { superscriptLabel: "सुपरस्क्रिप्ट", superscriptTooltip: (t2) => `सुपरस्क्रिप्ट (${t2})`, subscriptLabel: "सबस्क्रिप्ट", subscriptTooltip: (t2) => `सबस्क्रिप्ट (${t2})` } }, c = { superscript: true, subscript: true }, a = [{ type: "superscript", opposite: "subscript", configKey: "superscript", rank: 4, tag: "sup", label: "Superscript", icon: ['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">', '<path d="M16 7.41L11.41 12 16 16.59 14.59 18l-6-6 6-6z"', ' fill="none"/>', '<path d="M9.64 7.64c.23-.5.36-1.05.36-1.64', " 0-2.21-1.79-4-4-4H2v14h4.36c2.34 0 4.24-1.9", " 4.24-4.24 0-1.6-.89-2.99-2.2-3.71zM4.5 4.5H6c.83", " 0 1.5.67 1.5 1.5S6.83 7.5 6 7.5H4.5v-3zm2 9H4.5v-3H6.5c.83", ' 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z" fill="none"/>', '<path d="M15.97 3.84c0-.47.19-.91.53-1.21.34-.31.8-.49', " 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02", "-.96-.43-1.83-1.13-2.42C19.36.77 18.45.44 17.5.44c-.88", " 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34", " 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53", " 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54", "-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96", " 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56", "-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46", '-.59-.46-.94z"/>', '<path d="M5.88 20h2.66l3.4-5.42L15.3 20h2.67l-4.73-7.38', ' 4.37-6.62h-2.6l-3.07 4.98L8.92 6h-2.6l4.26 6.58z"/>', "</svg>"].join(""), keyBinding: "Mod-.", toolbarPriority: 50, toHTMLString: (t2) => `<sup>${t2}</sup>`, parseHTML: [{ tag: "sup" }], sanitize: { tags: ["sup"] } }, { type: "subscript", opposite: "superscript", configKey: "subscript", rank: 4, tag: "sub", label: "Subscript", icon: ['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">', '<path d="M15.97 16.84c0-.47.19-.91.53-1.21.34-.31.8-.49', " 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02", "-.96-.43-1.83-1.13-2.42-.7-.58-1.61-.91-2.56-.91-.88", " 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34", " 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53", " 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54", "-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96", " 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56", "-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46", '-.59-.46-.94z"/>', '<path d="M5.88 18h2.66l3.4-5.42L15.3 18h2.67l-4.73-7.38', ' 4.37-6.62h-2.6l-3.07 4.98L8.92 4h-2.6l4.26 6.58z"/>', "</svg>"].join(""), keyBinding: "Mod-,", toolbarPriority: 51, toHTMLString: (t2) => `<sub>${t2}</sub>`, parseHTML: [{ tag: "sub" }], sanitize: { tags: ["sub"] } }];
|
|
6
6
|
class l {
|
|
7
7
|
id = "super-sub";
|
|
@@ -14,48 +14,48 @@ class l {
|
|
|
14
14
|
}
|
|
15
15
|
init(s2) {
|
|
16
16
|
this.locale = t(p, s2, this.config.locale);
|
|
17
|
-
const
|
|
18
|
-
for (const t2 of
|
|
19
|
-
const
|
|
20
|
-
this.registerMark(s2, t2,
|
|
17
|
+
const i2 = a.filter((t2) => this.config[t2.configKey]), e2 = i2.filter((t2) => this.isToolbarVisible(t2.configKey)).at(-1);
|
|
18
|
+
for (const t2 of i2) {
|
|
19
|
+
const i3 = !!this.config.separatorAfter && t2 === e2;
|
|
20
|
+
this.registerMark(s2, t2, i3);
|
|
21
21
|
}
|
|
22
|
-
this.registerKeymaps(s2,
|
|
22
|
+
this.registerKeymaps(s2, i2), this.registerExclusivityMiddleware(s2, i2), this.registerDisabledToolbarItems(s2);
|
|
23
23
|
}
|
|
24
24
|
registerMark(t2, o2, p2) {
|
|
25
25
|
const c2 = n(o2.type), a2 = this.isToolbarVisible(o2.configKey);
|
|
26
26
|
if (t2.registerMarkSpec({ type: o2.type, rank: o2.rank, toDOM: () => document.createElement(o2.tag), toHTMLString: (t3, s2) => o2.toHTMLString(s2), parseHTML: o2.parseHTML, sanitize: o2.sanitize }), t2.registerCommand(c2, () => {
|
|
27
|
-
const
|
|
28
|
-
return !!
|
|
27
|
+
const i2 = e(t2.getState(), s(o2.type));
|
|
28
|
+
return !!i2 && (t2.dispatch(i2), true);
|
|
29
29
|
}), a2) {
|
|
30
|
-
const
|
|
31
|
-
t2.registerToolbarItem({ id: o2.type, group: "format", icon: o2.icon, label:
|
|
30
|
+
const e2 = "superscript" === o2.type ? this.locale.superscriptLabel : this.locale.subscriptLabel, a3 = "superscript" === o2.type ? this.locale.superscriptTooltip(i(o2.keyBinding)) : this.locale.subscriptTooltip(i(o2.keyBinding));
|
|
31
|
+
t2.registerToolbarItem({ id: o2.type, group: "format", icon: o2.icon, label: e2, tooltip: a3, command: c2, priority: o2.toolbarPriority, separatorAfter: p2, isActive: (t3) => r(t3, s(o2.type)) });
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
registerKeymaps(t2, s2) {
|
|
35
|
-
const
|
|
36
|
-
for (const
|
|
37
|
-
const s3 = n(
|
|
38
|
-
e2
|
|
35
|
+
const i2 = {};
|
|
36
|
+
for (const e2 of s2) {
|
|
37
|
+
const s3 = n(e2.type);
|
|
38
|
+
i2[e2.keyBinding] = () => t2.executeCommand(s3);
|
|
39
39
|
}
|
|
40
|
-
Object.keys(
|
|
40
|
+
Object.keys(i2).length > 0 && t2.registerKeymap(i2);
|
|
41
41
|
}
|
|
42
|
-
registerExclusivityMiddleware(t2,
|
|
43
|
-
|
|
42
|
+
registerExclusivityMiddleware(t2, i2) {
|
|
43
|
+
i2.some((t3) => "superscript" === t3.type) && i2.some((t3) => "subscript" === t3.type) && t2.registerMiddleware((t3, i3, e2) => {
|
|
44
44
|
let r2 = false;
|
|
45
45
|
const o2 = [];
|
|
46
|
-
for (const
|
|
47
|
-
if ("addMark" !==
|
|
48
|
-
o2.push(
|
|
46
|
+
for (const i4 of t3.steps) {
|
|
47
|
+
if ("addMark" !== i4.type) {
|
|
48
|
+
o2.push(i4);
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
|
-
const t4 =
|
|
52
|
-
if (!
|
|
53
|
-
o2.push(
|
|
51
|
+
const t4 = i4.mark.type, e3 = a.find((s2) => s2.type === t4);
|
|
52
|
+
if (!e3) {
|
|
53
|
+
o2.push(i4);
|
|
54
54
|
continue;
|
|
55
55
|
}
|
|
56
56
|
r2 = true;
|
|
57
|
-
const p3 = { type: "removeMark", blockId:
|
|
58
|
-
o2.push(p3,
|
|
57
|
+
const p3 = { type: "removeMark", blockId: i4.blockId, from: i4.from, to: i4.to, mark: { type: s(e3.opposite) }, ...i4.path ? { path: i4.path } : {} };
|
|
58
|
+
o2.push(p3, i4);
|
|
59
59
|
}
|
|
60
60
|
let p2 = t3.storedMarksAfter;
|
|
61
61
|
if (p2) {
|
|
@@ -65,15 +65,15 @@ class l {
|
|
|
65
65
|
p2 = p2.filter((s3) => s3.type !== t5), r2 = true;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
e2(r2 ? { ...t3, steps: o2, storedMarksAfter: p2 } : t3);
|
|
69
69
|
}, { name: "super-sub:exclusivity" });
|
|
70
70
|
}
|
|
71
71
|
registerDisabledToolbarItems(t2) {
|
|
72
72
|
if (this.config.toolbar) for (const s2 of a) {
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
75
|
-
const
|
|
76
|
-
t2.registerToolbarItem({ id: s2.type, group: "format", icon: s2.icon, label:
|
|
73
|
+
const i2 = this.config[s2.configKey], e2 = this.config.toolbar[s2.configKey] ?? true;
|
|
74
|
+
if (!i2 && e2) {
|
|
75
|
+
const i3 = "superscript" === s2.type ? this.locale.superscriptLabel : this.locale.subscriptLabel;
|
|
76
|
+
t2.registerToolbarItem({ id: s2.type, group: "format", icon: s2.icon, label: i3, command: n(s2.type), priority: s2.toolbarPriority, isEnabled: () => false });
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -89,4 +89,4 @@ export {
|
|
|
89
89
|
p as a,
|
|
90
90
|
o as b
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=index-
|
|
92
|
+
//# sourceMappingURL=index-CrKz_IEn.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-C9gc3Bws.mjs","sources":["../../src/plugins/super-sub/SuperSubLocale.ts","../../src/plugins/super-sub/SuperSubPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the SuperSubPlugin.\n */\n\n// --- Locale Interface ---\n\nexport interface SuperSubLocale {\n\treadonly superscriptLabel: string;\n\treadonly superscriptTooltip: (shortcut: string) => string;\n\treadonly subscriptLabel: string;\n\treadonly subscriptTooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const SUPER_SUB_LOCALE_EN: SuperSubLocale = {\n\tsuperscriptLabel: 'Superscript',\n\tsuperscriptTooltip: (shortcut: string) => `Superscript (${shortcut})`,\n\tsubscriptLabel: 'Subscript',\n\tsubscriptTooltip: (shortcut: string) => `Subscript (${shortcut})`,\n};\n\n// --- German Locale ---\n\nexport const SUPER_SUB_LOCALE_DE: SuperSubLocale = {\n\tsuperscriptLabel: 'Hochgestellt',\n\tsuperscriptTooltip: (shortcut: string) => `Hochgestellt (${shortcut})`,\n\tsubscriptLabel: 'Tiefgestellt',\n\tsubscriptTooltip: (shortcut: string) => `Tiefgestellt (${shortcut})`,\n};\n\n// --- Spanish Locale ---\n\nexport const SUPER_SUB_LOCALE_ES: SuperSubLocale = {\n\tsuperscriptLabel: 'Superíndice',\n\tsuperscriptTooltip: (shortcut: string) => `Superíndice (${shortcut})`,\n\tsubscriptLabel: 'Subíndice',\n\tsubscriptTooltip: (shortcut: string) => `Subíndice (${shortcut})`,\n};\n\n// --- French Locale ---\n\nexport const SUPER_SUB_LOCALE_FR: SuperSubLocale = {\n\tsuperscriptLabel: 'Exposant',\n\tsuperscriptTooltip: (shortcut: string) => `Exposant (${shortcut})`,\n\tsubscriptLabel: 'Indice',\n\tsubscriptTooltip: (shortcut: string) => `Indice (${shortcut})`,\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const SUPER_SUB_LOCALE_ZH: SuperSubLocale = {\n\tsuperscriptLabel: '上标',\n\tsuperscriptTooltip: (shortcut: string) => `上标 (${shortcut})`,\n\tsubscriptLabel: '下标',\n\tsubscriptTooltip: (shortcut: string) => `下标 (${shortcut})`,\n};\n\n// --- Russian Locale ---\n\nexport const SUPER_SUB_LOCALE_RU: SuperSubLocale = {\n\tsuperscriptLabel: 'Надстрочный',\n\tsuperscriptTooltip: (shortcut: string) => `Надстрочный (${shortcut})`,\n\tsubscriptLabel: 'Подстрочный',\n\tsubscriptTooltip: (shortcut: string) => `Подстрочный (${shortcut})`,\n};\n\n// --- Arabic Locale ---\n\nexport const SUPER_SUB_LOCALE_AR: SuperSubLocale = {\n\tsuperscriptLabel: 'مرتفع',\n\tsuperscriptTooltip: (shortcut: string) => `مرتفع (${shortcut})`,\n\tsubscriptLabel: 'منخفض',\n\tsubscriptTooltip: (shortcut: string) => `منخفض (${shortcut})`,\n};\n\n// --- Hindi Locale ---\n\nexport const SUPER_SUB_LOCALE_HI: SuperSubLocale = {\n\tsuperscriptLabel: 'सुपरस्क्रिप्ट',\n\tsuperscriptTooltip: (shortcut: string) => `सुपरस्क्रिप्ट (${shortcut})`,\n\tsubscriptLabel: 'सबस्क्रिप्ट',\n\tsubscriptTooltip: (shortcut: string) => `सबस्क्रिप्ट (${shortcut})`,\n};\n\n// --- Locale Map ---\n\nexport const SUPER_SUB_LOCALES: Record<string, SuperSubLocale> = {\n\ten: SUPER_SUB_LOCALE_EN,\n\tde: SUPER_SUB_LOCALE_DE,\n\tes: SUPER_SUB_LOCALE_ES,\n\tfr: SUPER_SUB_LOCALE_FR,\n\tzh: SUPER_SUB_LOCALE_ZH,\n\tru: SUPER_SUB_LOCALE_RU,\n\tar: SUPER_SUB_LOCALE_AR,\n\thi: SUPER_SUB_LOCALE_HI,\n};\n","/**\n * SuperSubPlugin: registers superscript and subscript inline marks with\n * MarkSpecs, toggle commands, keyboard shortcuts, toolbar buttons, and\n * a middleware that enforces mutual exclusivity between the two marks.\n *\n * Data-driven — each mark type is defined declaratively and all\n * registrations are derived from the same definition table.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { Mark } from '../../model/Document.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 { RemoveMarkStep, Step } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { SUPER_SUB_LOCALES, type SuperSubLocale } from './SuperSubLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tsuperscript: Record<string, never>;\n\t\tsubscript: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\n/** Controls toolbar button visibility per mark. */\nexport interface SuperSubToolbarConfig {\n\treadonly superscript?: boolean;\n\treadonly subscript?: boolean;\n}\n\n/** Controls which marks are enabled and which toolbar buttons are shown. */\nexport interface SuperSubConfig {\n\treadonly superscript: boolean;\n\treadonly subscript: boolean;\n\treadonly toolbar?: SuperSubToolbarConfig;\n\t/** When true, a separator is rendered after the last toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: SuperSubLocale;\n}\n\nconst DEFAULT_CONFIG: SuperSubConfig = {\n\tsuperscript: true,\n\tsubscript: true,\n};\n\n// --- Mark Definitions ---\n\ninterface MarkDefinition {\n\treadonly type: 'superscript' | 'subscript';\n\treadonly opposite: 'superscript' | 'subscript';\n\treadonly configKey: keyof Omit<SuperSubConfig, '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 toolbarPriority: number;\n\treadonly toHTMLString: (content: string) => string;\n\treadonly parseHTML: readonly ParseRule[];\n\treadonly sanitize: SanitizeConfig;\n}\n\nconst SUPERSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M16 7.41L11.41 12 16 16.59 14.59 18l-6-6 6-6z\"',\n\t' fill=\"none\"/>',\n\t'<path d=\"M9.64 7.64c.23-.5.36-1.05.36-1.64',\n\t' 0-2.21-1.79-4-4-4H2v14h4.36c2.34 0 4.24-1.9',\n\t' 4.24-4.24 0-1.6-.89-2.99-2.2-3.71zM4.5 4.5H6c.83',\n\t' 0 1.5.67 1.5 1.5S6.83 7.5 6 7.5H4.5v-3zm2 9H4.5v-3H6.5c.83',\n\t' 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\" fill=\"none\"/>',\n\t'<path d=\"M15.97 3.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42C19.36.77 18.45.44 17.5.44c-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 20h2.66l3.4-5.42L15.3 20h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 6h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst SUBSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M15.97 16.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42-.7-.58-1.61-.91-2.56-.91-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 18h2.66l3.4-5.42L15.3 18h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 4h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst MARK_DEFINITIONS: readonly MarkDefinition[] = [\n\t{\n\t\ttype: 'superscript',\n\t\topposite: 'subscript',\n\t\tconfigKey: 'superscript',\n\t\trank: 4,\n\t\ttag: 'sup',\n\t\tlabel: 'Superscript',\n\t\ticon: SUPERSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-.',\n\t\ttoolbarPriority: 50,\n\t\ttoHTMLString: (content) => `<sup>${content}</sup>`,\n\t\tparseHTML: [{ tag: 'sup' }],\n\t\tsanitize: { tags: ['sup'] },\n\t},\n\t{\n\t\ttype: 'subscript',\n\t\topposite: 'superscript',\n\t\tconfigKey: 'subscript',\n\t\trank: 4,\n\t\ttag: 'sub',\n\t\tlabel: 'Subscript',\n\t\ticon: SUBSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-,',\n\t\ttoolbarPriority: 51,\n\t\ttoHTMLString: (content) => `<sub>${content}</sub>`,\n\t\tparseHTML: [{ tag: 'sub' }],\n\t\tsanitize: { tags: ['sub'] },\n\t},\n];\n\n// --- Plugin ---\n\nexport class SuperSubPlugin implements Plugin {\n\treadonly id = 'super-sub';\n\treadonly name = 'Superscript & Subscript';\n\treadonly priority = 23;\n\n\tprivate readonly config: SuperSubConfig;\n\tprivate locale!: SuperSubLocale;\n\n\tconstructor(config?: Partial<SuperSubConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(SUPER_SUB_LOCALES, context, this.config.locale);\n\n\t\tconst enabledMarks: MarkDefinition[] = MARK_DEFINITIONS.filter(\n\t\t\t(def) => this.config[def.configKey],\n\t\t);\n\n\t\tconst visibleToolbarMarks: MarkDefinition[] = enabledMarks.filter((def) =>\n\t\t\tthis.isToolbarVisible(def.configKey),\n\t\t);\n\t\tconst lastVisibleMark: MarkDefinition | undefined = visibleToolbarMarks.at(-1);\n\n\t\tfor (const def of enabledMarks) {\n\t\t\tconst isSeparatorTarget: boolean = !!this.config.separatorAfter && def === lastVisibleMark;\n\t\t\tthis.registerMark(context, def, isSeparatorTarget);\n\t\t}\n\n\t\tthis.registerKeymaps(context, enabledMarks);\n\t\tthis.registerExclusivityMiddleware(context, enabledMarks);\n\t\tthis.registerDisabledToolbarItems(context);\n\t}\n\n\tprivate registerMark(context: PluginContext, def: MarkDefinition, separatorAfter: boolean): void {\n\t\tconst commandName: string = toCommandName(def.type);\n\t\tconst toolbarVisible: boolean = 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 =\n\t\t\t\tdef.type === 'superscript' ? this.locale.superscriptLabel : this.locale.subscriptLabel;\n\t\t\tconst tooltip: string =\n\t\t\t\tdef.type === 'superscript'\n\t\t\t\t\t? this.locale.superscriptTooltip(formatShortcut(def.keyBinding))\n\t\t\t\t\t: this.locale.subscriptTooltip(formatShortcut(def.keyBinding));\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,\n\t\t\t\tcommand: commandName,\n\t\t\t\tpriority: def.toolbarPriority,\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: string = 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 * Ensures superscript and subscript are mutually exclusive.\n\t * When an addMark step for one type is found, a removeMark step\n\t * for the opposite type is injected. For stored marks, the opposite\n\t * mark is filtered out.\n\t */\n\tprivate registerExclusivityMiddleware(\n\t\tcontext: PluginContext,\n\t\tenabledMarks: readonly MarkDefinition[],\n\t): void {\n\t\tconst bothEnabled: boolean =\n\t\t\tenabledMarks.some((d) => d.type === 'superscript') &&\n\t\t\tenabledMarks.some((d) => d.type === 'subscript');\n\n\t\tif (!bothEnabled) return;\n\n\t\tcontext.registerMiddleware(\n\t\t\t(tr, _state, next) => {\n\t\t\t\tlet patched = false;\n\n\t\t\t\t// Handle addMark steps: inject removeMark for the opposite type\n\t\t\t\tconst patchedSteps: Step[] = [];\n\t\t\t\tfor (const step of tr.steps) {\n\t\t\t\t\tif (step.type !== 'addMark') {\n\t\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst markName: string = step.mark.type;\n\t\t\t\t\tconst def: MarkDefinition | undefined = MARK_DEFINITIONS.find((d) => d.type === markName);\n\t\t\t\t\tif (!def) {\n\t\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tpatched = true;\n\t\t\t\t\tconst removeStep: RemoveMarkStep = {\n\t\t\t\t\t\ttype: 'removeMark',\n\t\t\t\t\t\tblockId: step.blockId,\n\t\t\t\t\t\tfrom: step.from,\n\t\t\t\t\t\tto: step.to,\n\t\t\t\t\t\tmark: { type: mkType(def.opposite) },\n\t\t\t\t\t\t...(step.path ? { path: step.path } : {}),\n\t\t\t\t\t};\n\t\t\t\t\tpatchedSteps.push(removeStep, step);\n\t\t\t\t}\n\n\t\t\t\t// Handle stored marks: remove the opposite mark\n\t\t\t\tlet storedMarksAfter: readonly Mark[] | null = tr.storedMarksAfter;\n\t\t\t\tif (storedMarksAfter) {\n\t\t\t\t\tconst hasSup: boolean = storedMarksAfter.some((m) => m.type === 'superscript');\n\t\t\t\t\tconst hasSub: boolean = storedMarksAfter.some((m) => m.type === 'subscript');\n\n\t\t\t\t\tif (hasSup && hasSub) {\n\t\t\t\t\t\t// Keep the one that was most recently added (last in array)\n\t\t\t\t\t\tconst lastSupIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t\t(m) => m.type === 'superscript',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst lastSubIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t\t(m) => m.type === 'subscript',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst removeType: string = lastSupIdx > lastSubIdx ? 'subscript' : 'superscript';\n\n\t\t\t\t\t\tstoredMarksAfter = storedMarksAfter.filter((m) => m.type !== removeType);\n\t\t\t\t\t\tpatched = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnext(patched ? { ...tr, steps: patchedSteps, storedMarksAfter } : tr);\n\t\t\t},\n\t\t\t{ name: 'super-sub:exclusivity' },\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: boolean = this.config[def.configKey];\n\t\t\tconst toolbarVisible: boolean = this.config.toolbar[def.configKey] ?? true;\n\n\t\t\tif (!featureEnabled && toolbarVisible) {\n\t\t\t\tconst label: string =\n\t\t\t\t\tdef.type === 'superscript' ? this.locale.superscriptLabel : this.locale.subscriptLabel;\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,\n\t\t\t\t\tcommand: toCommandName(def.type),\n\t\t\t\t\tpriority: def.toolbarPriority,\n\t\t\t\t\tisEnabled: () => false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate isToolbarVisible(\n\t\tconfigKey: keyof Omit<SuperSubConfig, '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. 'superscript' → 'toggleSuperscript'). */\nfunction toCommandName(markType: string): string {\n\treturn `toggle${markType.charAt(0).toUpperCase()}${markType.slice(1)}`;\n}\n"],"names":["SUPER_SUB_LOCALE_EN","superscriptLabel","superscriptTooltip","shortcut","subscriptLabel","subscriptTooltip","SUPER_SUB_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","superscript","subscript","MARK_DEFINITIONS","type","opposite","configKey","rank","tag","label","icon","join","keyBinding","toolbarPriority","toHTMLString","content","parseHTML","sanitize","tags","SuperSubPlugin","id","name","priority","config","locale","this","context","resolvePluginLocale","enabledMarks","filter","def","lastVisibleMark","isToolbarVisible","at","isSeparatorTarget","separatorAfter","registerMark","registerKeymaps","registerExclusivityMiddleware","registerDisabledToolbarItems","commandName","toCommandName","toolbarVisible","registerMarkSpec","toDOM","document","createElement","_mark","registerCommand","tr","toggleMark","getState","mkType","dispatch","tooltip","formatShortcut","registerToolbarItem","group","command","isActive","state","isMarkActive","marks","keymap","executeCommand","Object","keys","length","registerKeymap","some","d","registerMiddleware","_state","next","patched","patchedSteps","step","steps","push","markName","mark","find","removeStep","blockId","from","to","path","storedMarksAfter","hasSup","m","hasSub","removeType","findLastIndex","toolbar","featureEnabled","isEnabled","markType","charAt","toUpperCase","slice"],"mappings":";;;;AAeO,MAAMA,IAAsC,EAClDC,kBAAkB,eAClBC,oBAAqBC,CAAAA,OAAqB,gBAAgBA,EAAAA,KAC1DC,gBAAgB,aAChBC,kBAAmBF,CAAAA,OAAqB,cAAcA,SAoE1CG,IAAoD,EAChEC,IAAIP,GACJQ,IAjEkD,EAClDP,kBAAkB,gBAClBC,oBAAqBC,CAAAA,OAAqB,iBAAiBA,OAC3DC,gBAAgB,gBAChBC,kBAAmBF,CAAAA,OAAqB,iBAAiBA,SA8DzDM,IAzDkD,EAClDR,kBAAkB,eAClBC,oBAAqBC,CAAAA,OAAqB,gBAAgBA,OAC1DC,gBAAgB,aAChBC,kBAAmBF,CAAAA,OAAqB,cAAcA,SAsDtDO,IAjDkD,EAClDT,kBAAkB,YAClBC,oBAAqBC,CAAAA,OAAqB,aAAaA,EAAAA,KACvDC,gBAAgB,UAChBC,kBAAmBF,CAAAA,OAAqB,WAAWA,SA8CnDQ,IAzCkD,EAClDV,kBAAkB,MAClBC,oBAAqBC,CAAAA,OAAqB,OAAOA,EAAAA,KACjDC,gBAAgB,MAChBC,kBAAmBF,CAAAA,OAAqB,OAAOA,EAAAA,IAAAA,GAsC/CS,IAjCkD,EAClDX,kBAAkB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3B,GAAkB;AACnC,YAAM2F,KAA0BrE,KAAKF,OAAOO,GAAIxB,SAAAA,GAC1CoC,KAA0BjB,KAAKF,OAAOsE,QAAQ/D,GAAIxB,SAAAA,KAAAA;AAExD,UAAA,CAAKwF,MAAkBpD,IAAgB;AACtC,cAAMjC,KACQ,kBAAbqB,GAAI1B,OAAyBqB,KAAKD,OAAOtC,mBAAmBuC,KAAKD,OAAOnC;AACzEqC,QAAAA,GAAQ8B,oBAAoB,EAC3BpC,IAAIU,GAAI1B,MACRqD,OAAO,UACP/C,MAAMoB,GAAIpB,MACVD,OAAAA,IACAiD,SAASjB,EAAcX,GAAI1B,IAAAA,GAC3BkB,UAAUQ,GAAIjB,iBACdkF,WAAW,MAAA,MAAM,CAAA;AAAA,MAEnB;AAAA,IACD;AAAA,EACD;AAAA,EAEQ,iBACPzF,IAAAA;AAEA,YAAKmB,KAAKF,OAAOsE,YACVpE,KAAKF,OAAOsE,QAAQvF,EAAAA,KAAAA;AAAAA,EAC5B;AAAA;AAID,SAASmC,EAAcuD,IAAAA;AACtB,SAAO,SAASA,GAASC,OAAO,GAAGC,YAAAA,CAAAA,GAAgBF,GAASG,MAAM,CAAA,CAAA;AACnE;"}
|
|
1
|
+
{"version":3,"file":"index-CrKz_IEn.mjs","sources":["../../src/plugins/super-sub/SuperSubLocale.ts","../../src/plugins/super-sub/SuperSubPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the SuperSubPlugin.\n */\n\n// --- Locale Interface ---\n\nexport interface SuperSubLocale {\n\treadonly superscriptLabel: string;\n\treadonly superscriptTooltip: (shortcut: string) => string;\n\treadonly subscriptLabel: string;\n\treadonly subscriptTooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const SUPER_SUB_LOCALE_EN: SuperSubLocale = {\n\tsuperscriptLabel: 'Superscript',\n\tsuperscriptTooltip: (shortcut: string) => `Superscript (${shortcut})`,\n\tsubscriptLabel: 'Subscript',\n\tsubscriptTooltip: (shortcut: string) => `Subscript (${shortcut})`,\n};\n\n// --- German Locale ---\n\nexport const SUPER_SUB_LOCALE_DE: SuperSubLocale = {\n\tsuperscriptLabel: 'Hochgestellt',\n\tsuperscriptTooltip: (shortcut: string) => `Hochgestellt (${shortcut})`,\n\tsubscriptLabel: 'Tiefgestellt',\n\tsubscriptTooltip: (shortcut: string) => `Tiefgestellt (${shortcut})`,\n};\n\n// --- Spanish Locale ---\n\nexport const SUPER_SUB_LOCALE_ES: SuperSubLocale = {\n\tsuperscriptLabel: 'Superíndice',\n\tsuperscriptTooltip: (shortcut: string) => `Superíndice (${shortcut})`,\n\tsubscriptLabel: 'Subíndice',\n\tsubscriptTooltip: (shortcut: string) => `Subíndice (${shortcut})`,\n};\n\n// --- French Locale ---\n\nexport const SUPER_SUB_LOCALE_FR: SuperSubLocale = {\n\tsuperscriptLabel: 'Exposant',\n\tsuperscriptTooltip: (shortcut: string) => `Exposant (${shortcut})`,\n\tsubscriptLabel: 'Indice',\n\tsubscriptTooltip: (shortcut: string) => `Indice (${shortcut})`,\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const SUPER_SUB_LOCALE_ZH: SuperSubLocale = {\n\tsuperscriptLabel: '上标',\n\tsuperscriptTooltip: (shortcut: string) => `上标 (${shortcut})`,\n\tsubscriptLabel: '下标',\n\tsubscriptTooltip: (shortcut: string) => `下标 (${shortcut})`,\n};\n\n// --- Russian Locale ---\n\nexport const SUPER_SUB_LOCALE_RU: SuperSubLocale = {\n\tsuperscriptLabel: 'Надстрочный',\n\tsuperscriptTooltip: (shortcut: string) => `Надстрочный (${shortcut})`,\n\tsubscriptLabel: 'Подстрочный',\n\tsubscriptTooltip: (shortcut: string) => `Подстрочный (${shortcut})`,\n};\n\n// --- Arabic Locale ---\n\nexport const SUPER_SUB_LOCALE_AR: SuperSubLocale = {\n\tsuperscriptLabel: 'مرتفع',\n\tsuperscriptTooltip: (shortcut: string) => `مرتفع (${shortcut})`,\n\tsubscriptLabel: 'منخفض',\n\tsubscriptTooltip: (shortcut: string) => `منخفض (${shortcut})`,\n};\n\n// --- Hindi Locale ---\n\nexport const SUPER_SUB_LOCALE_HI: SuperSubLocale = {\n\tsuperscriptLabel: 'सुपरस्क्रिप्ट',\n\tsuperscriptTooltip: (shortcut: string) => `सुपरस्क्रिप्ट (${shortcut})`,\n\tsubscriptLabel: 'सबस्क्रिप्ट',\n\tsubscriptTooltip: (shortcut: string) => `सबस्क्रिप्ट (${shortcut})`,\n};\n\n// --- Locale Map ---\n\nexport const SUPER_SUB_LOCALES: Record<string, SuperSubLocale> = {\n\ten: SUPER_SUB_LOCALE_EN,\n\tde: SUPER_SUB_LOCALE_DE,\n\tes: SUPER_SUB_LOCALE_ES,\n\tfr: SUPER_SUB_LOCALE_FR,\n\tzh: SUPER_SUB_LOCALE_ZH,\n\tru: SUPER_SUB_LOCALE_RU,\n\tar: SUPER_SUB_LOCALE_AR,\n\thi: SUPER_SUB_LOCALE_HI,\n};\n","/**\n * SuperSubPlugin: registers superscript and subscript inline marks with\n * MarkSpecs, toggle commands, keyboard shortcuts, toolbar buttons, and\n * a middleware that enforces mutual exclusivity between the two marks.\n *\n * Data-driven — each mark type is defined declaratively and all\n * registrations are derived from the same definition table.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { Mark } from '../../model/Document.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 { RemoveMarkStep, Step } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { SUPER_SUB_LOCALES, type SuperSubLocale } from './SuperSubLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tsuperscript: Record<string, never>;\n\t\tsubscript: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\n/** Controls toolbar button visibility per mark. */\nexport interface SuperSubToolbarConfig {\n\treadonly superscript?: boolean;\n\treadonly subscript?: boolean;\n}\n\n/** Controls which marks are enabled and which toolbar buttons are shown. */\nexport interface SuperSubConfig {\n\treadonly superscript: boolean;\n\treadonly subscript: boolean;\n\treadonly toolbar?: SuperSubToolbarConfig;\n\t/** When true, a separator is rendered after the last toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: SuperSubLocale;\n}\n\nconst DEFAULT_CONFIG: SuperSubConfig = {\n\tsuperscript: true,\n\tsubscript: true,\n};\n\n// --- Mark Definitions ---\n\ninterface MarkDefinition {\n\treadonly type: 'superscript' | 'subscript';\n\treadonly opposite: 'superscript' | 'subscript';\n\treadonly configKey: keyof Omit<SuperSubConfig, '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 toolbarPriority: number;\n\treadonly toHTMLString: (content: string) => string;\n\treadonly parseHTML: readonly ParseRule[];\n\treadonly sanitize: SanitizeConfig;\n}\n\nconst SUPERSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M16 7.41L11.41 12 16 16.59 14.59 18l-6-6 6-6z\"',\n\t' fill=\"none\"/>',\n\t'<path d=\"M9.64 7.64c.23-.5.36-1.05.36-1.64',\n\t' 0-2.21-1.79-4-4-4H2v14h4.36c2.34 0 4.24-1.9',\n\t' 4.24-4.24 0-1.6-.89-2.99-2.2-3.71zM4.5 4.5H6c.83',\n\t' 0 1.5.67 1.5 1.5S6.83 7.5 6 7.5H4.5v-3zm2 9H4.5v-3H6.5c.83',\n\t' 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\" fill=\"none\"/>',\n\t'<path d=\"M15.97 3.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42C19.36.77 18.45.44 17.5.44c-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 20h2.66l3.4-5.42L15.3 20h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 6h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst SUBSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M15.97 16.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42-.7-.58-1.61-.91-2.56-.91-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 18h2.66l3.4-5.42L15.3 18h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 4h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst MARK_DEFINITIONS: readonly MarkDefinition[] = [\n\t{\n\t\ttype: 'superscript',\n\t\topposite: 'subscript',\n\t\tconfigKey: 'superscript',\n\t\trank: 4,\n\t\ttag: 'sup',\n\t\tlabel: 'Superscript',\n\t\ticon: SUPERSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-.',\n\t\ttoolbarPriority: 50,\n\t\ttoHTMLString: (content) => `<sup>${content}</sup>`,\n\t\tparseHTML: [{ tag: 'sup' }],\n\t\tsanitize: { tags: ['sup'] },\n\t},\n\t{\n\t\ttype: 'subscript',\n\t\topposite: 'superscript',\n\t\tconfigKey: 'subscript',\n\t\trank: 4,\n\t\ttag: 'sub',\n\t\tlabel: 'Subscript',\n\t\ticon: SUBSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-,',\n\t\ttoolbarPriority: 51,\n\t\ttoHTMLString: (content) => `<sub>${content}</sub>`,\n\t\tparseHTML: [{ tag: 'sub' }],\n\t\tsanitize: { tags: ['sub'] },\n\t},\n];\n\n// --- Plugin ---\n\nexport class SuperSubPlugin implements Plugin {\n\treadonly id = 'super-sub';\n\treadonly name = 'Superscript & Subscript';\n\treadonly priority = 23;\n\n\tprivate readonly config: SuperSubConfig;\n\tprivate locale!: SuperSubLocale;\n\n\tconstructor(config?: Partial<SuperSubConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(SUPER_SUB_LOCALES, context, this.config.locale);\n\n\t\tconst enabledMarks: MarkDefinition[] = MARK_DEFINITIONS.filter(\n\t\t\t(def) => this.config[def.configKey],\n\t\t);\n\n\t\tconst visibleToolbarMarks: MarkDefinition[] = enabledMarks.filter((def) =>\n\t\t\tthis.isToolbarVisible(def.configKey),\n\t\t);\n\t\tconst lastVisibleMark: MarkDefinition | undefined = visibleToolbarMarks.at(-1);\n\n\t\tfor (const def of enabledMarks) {\n\t\t\tconst isSeparatorTarget: boolean = !!this.config.separatorAfter && def === lastVisibleMark;\n\t\t\tthis.registerMark(context, def, isSeparatorTarget);\n\t\t}\n\n\t\tthis.registerKeymaps(context, enabledMarks);\n\t\tthis.registerExclusivityMiddleware(context, enabledMarks);\n\t\tthis.registerDisabledToolbarItems(context);\n\t}\n\n\tprivate registerMark(context: PluginContext, def: MarkDefinition, separatorAfter: boolean): void {\n\t\tconst commandName: string = toCommandName(def.type);\n\t\tconst toolbarVisible: boolean = 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 =\n\t\t\t\tdef.type === 'superscript' ? this.locale.superscriptLabel : this.locale.subscriptLabel;\n\t\t\tconst tooltip: string =\n\t\t\t\tdef.type === 'superscript'\n\t\t\t\t\t? this.locale.superscriptTooltip(formatShortcut(def.keyBinding))\n\t\t\t\t\t: this.locale.subscriptTooltip(formatShortcut(def.keyBinding));\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,\n\t\t\t\tcommand: commandName,\n\t\t\t\tpriority: def.toolbarPriority,\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: string = 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 * Ensures superscript and subscript are mutually exclusive.\n\t * When an addMark step for one type is found, a removeMark step\n\t * for the opposite type is injected. For stored marks, the opposite\n\t * mark is filtered out.\n\t */\n\tprivate registerExclusivityMiddleware(\n\t\tcontext: PluginContext,\n\t\tenabledMarks: readonly MarkDefinition[],\n\t): void {\n\t\tconst bothEnabled: boolean =\n\t\t\tenabledMarks.some((d) => d.type === 'superscript') &&\n\t\t\tenabledMarks.some((d) => d.type === 'subscript');\n\n\t\tif (!bothEnabled) return;\n\n\t\tcontext.registerMiddleware(\n\t\t\t(tr, _state, next) => {\n\t\t\t\tlet patched = false;\n\n\t\t\t\t// Handle addMark steps: inject removeMark for the opposite type\n\t\t\t\tconst patchedSteps: Step[] = [];\n\t\t\t\tfor (const step of tr.steps) {\n\t\t\t\t\tif (step.type !== 'addMark') {\n\t\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst markName: string = step.mark.type;\n\t\t\t\t\tconst def: MarkDefinition | undefined = MARK_DEFINITIONS.find((d) => d.type === markName);\n\t\t\t\t\tif (!def) {\n\t\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tpatched = true;\n\t\t\t\t\tconst removeStep: RemoveMarkStep = {\n\t\t\t\t\t\ttype: 'removeMark',\n\t\t\t\t\t\tblockId: step.blockId,\n\t\t\t\t\t\tfrom: step.from,\n\t\t\t\t\t\tto: step.to,\n\t\t\t\t\t\tmark: { type: mkType(def.opposite) },\n\t\t\t\t\t\t...(step.path ? { path: step.path } : {}),\n\t\t\t\t\t};\n\t\t\t\t\tpatchedSteps.push(removeStep, step);\n\t\t\t\t}\n\n\t\t\t\t// Handle stored marks: remove the opposite mark\n\t\t\t\tlet storedMarksAfter: readonly Mark[] | null = tr.storedMarksAfter;\n\t\t\t\tif (storedMarksAfter) {\n\t\t\t\t\tconst hasSup: boolean = storedMarksAfter.some((m) => m.type === 'superscript');\n\t\t\t\t\tconst hasSub: boolean = storedMarksAfter.some((m) => m.type === 'subscript');\n\n\t\t\t\t\tif (hasSup && hasSub) {\n\t\t\t\t\t\t// Keep the one that was most recently added (last in array)\n\t\t\t\t\t\tconst lastSupIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t\t(m) => m.type === 'superscript',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst lastSubIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t\t(m) => m.type === 'subscript',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst removeType: string = lastSupIdx > lastSubIdx ? 'subscript' : 'superscript';\n\n\t\t\t\t\t\tstoredMarksAfter = storedMarksAfter.filter((m) => m.type !== removeType);\n\t\t\t\t\t\tpatched = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnext(patched ? { ...tr, steps: patchedSteps, storedMarksAfter } : tr);\n\t\t\t},\n\t\t\t{ name: 'super-sub:exclusivity' },\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: boolean = this.config[def.configKey];\n\t\t\tconst toolbarVisible: boolean = this.config.toolbar[def.configKey] ?? true;\n\n\t\t\tif (!featureEnabled && toolbarVisible) {\n\t\t\t\tconst label: string =\n\t\t\t\t\tdef.type === 'superscript' ? this.locale.superscriptLabel : this.locale.subscriptLabel;\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,\n\t\t\t\t\tcommand: toCommandName(def.type),\n\t\t\t\t\tpriority: def.toolbarPriority,\n\t\t\t\t\tisEnabled: () => false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate isToolbarVisible(\n\t\tconfigKey: keyof Omit<SuperSubConfig, '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. 'superscript' → 'toggleSuperscript'). */\nfunction toCommandName(markType: string): string {\n\treturn `toggle${markType.charAt(0).toUpperCase()}${markType.slice(1)}`;\n}\n"],"names":["SUPER_SUB_LOCALE_EN","superscriptLabel","superscriptTooltip","shortcut","subscriptLabel","subscriptTooltip","SUPER_SUB_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","superscript","subscript","MARK_DEFINITIONS","type","opposite","configKey","rank","tag","label","icon","join","keyBinding","toolbarPriority","toHTMLString","content","parseHTML","sanitize","tags","SuperSubPlugin","id","name","priority","config","locale","this","context","resolvePluginLocale","enabledMarks","filter","def","lastVisibleMark","isToolbarVisible","at","isSeparatorTarget","separatorAfter","registerMark","registerKeymaps","registerExclusivityMiddleware","registerDisabledToolbarItems","commandName","toCommandName","toolbarVisible","registerMarkSpec","toDOM","document","createElement","_mark","registerCommand","tr","toggleMark","getState","mkType","dispatch","tooltip","formatShortcut","registerToolbarItem","group","command","isActive","state","isMarkActive","marks","keymap","executeCommand","Object","keys","length","registerKeymap","some","d","registerMiddleware","_state","next","patched","patchedSteps","step","steps","push","markName","mark","find","removeStep","blockId","from","to","path","storedMarksAfter","hasSup","m","hasSub","removeType","findLastIndex","toolbar","featureEnabled","isEnabled","markType","charAt","toUpperCase","slice"],"mappings":";;;;AAeO,MAAMA,IAAsC,EAClDC,kBAAkB,eAClBC,oBAAqBC,CAAAA,OAAqB,gBAAgBA,EAAAA,KAC1DC,gBAAgB,aAChBC,kBAAmBF,CAAAA,OAAqB,cAAcA,SAoE1CG,IAAoD,EAChEC,IAAIP,GACJQ,IAjEkD,EAClDP,kBAAkB,gBAClBC,oBAAqBC,CAAAA,OAAqB,iBAAiBA,OAC3DC,gBAAgB,gBAChBC,kBAAmBF,CAAAA,OAAqB,iBAAiBA,SA8DzDM,IAzDkD,EAClDR,kBAAkB,eAClBC,oBAAqBC,CAAAA,OAAqB,gBAAgBA,OAC1DC,gBAAgB,aAChBC,kBAAmBF,CAAAA,OAAqB,cAAcA,SAsDtDO,IAjDkD,EAClDT,kBAAkB,YAClBC,oBAAqBC,CAAAA,OAAqB,aAAaA,EAAAA,KACvDC,gBAAgB,UAChBC,kBAAmBF,CAAAA,OAAqB,WAAWA,SA8CnDQ,IAzCkD,EAClDV,kBAAkB,MAClBC,oBAAqBC,CAAAA,OAAqB,OAAOA,EAAAA,KACjDC,gBAAgB,MAChBC,kBAAmBF,CAAAA,OAAqB,OAAOA,EAAAA,IAAAA,GAsC/CS,IAjCkD,EAClDX,kBAAkB,eAClBC,oBAAqBC,CAAAA,OAAqB,gBAAgBA,EAAAA,KAC1DC,gBAAgB,eAChBC,kBAAmBF,CAAAA,OAAqB,gBAAgBA,EAAAA,IAAAA,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