@notectl/core 1.0.5 → 1.0.6
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 -1
- package/dist/chunks/{ToolbarPlugin-D5VqeBPT.mjs → ToolbarPlugin-sJTiZr-S.mjs} +2 -2
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +1 -0
- package/dist/chunks/index-QvKiO9_4.mjs +538 -0
- package/dist/chunks/index-QvKiO9_4.mjs.map +1 -0
- package/dist/editor/EditorDOM.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +5 -1
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/notectl-core.mjs +1846 -1712
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +1050 -966
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +3 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockCommands.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts +10 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts +1 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +3 -111
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockService.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +69 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -0
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font-size/FontSizeOperations.d.ts +22 -0
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +1 -10
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts +9 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -0
- package/dist/plugins/font-size.mjs +146 -162
- package/dist/plugins/font-size.mjs.map +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/image/ImageNodeView.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/image.mjs.map +1 -1
- package/dist/plugins/print/PrintContentPreparer.d.ts +12 -0
- package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts +12 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts +7 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts +10 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -0
- package/dist/plugins/print/PrintTypes.d.ts +56 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table.mjs +13 -13
- package/dist/plugins/table.mjs.map +1 -1
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/view/Reconciler.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs.map +0 -1
- package/dist/chunks/index-CPPb-Jah.mjs +0 -569
- package/dist/chunks/index-CPPb-Jah.mjs.map +0 -1
package/dist/notectl-core.umd.js
CHANGED
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
function d() {
|
|
45
45
|
return `block-${crypto.randomUUID()}`;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return { children: t2 ?? [
|
|
47
|
+
function u(t2) {
|
|
48
|
+
return { children: t2 ?? [h("paragraph")] };
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function h(t2, e2, n2, o2) {
|
|
51
51
|
return { id: n2 ?? d(), type: t2, ...o2 ? { attrs: o2 } : {}, children: e2 ?? [p("")] };
|
|
52
52
|
}
|
|
53
53
|
function p(t2, e2) {
|
|
@@ -166,13 +166,13 @@
|
|
|
166
166
|
function B(t2, e2) {
|
|
167
167
|
return C(t2) && C(e2) ? t2.nodeId === e2.nodeId : !(!T(t2) || !T(e2)) && t2.anchor.blockId === e2.anchor.blockId && t2.anchor.offset === e2.anchor.offset && t2.head.blockId === e2.head.blockId && t2.head.offset === e2.head.offset;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function E(t2, e2, n2) {
|
|
170
170
|
return n2 ? { blockId: t2, offset: e2, path: n2 } : { blockId: t2, offset: e2 };
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function M(t2, e2) {
|
|
173
173
|
return { anchor: t2, head: e2 };
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function A(t2, e2) {
|
|
176
176
|
const n2 = { blockId: t2, offset: e2 };
|
|
177
177
|
return { anchor: n2, head: n2 };
|
|
178
178
|
}
|
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
}
|
|
337
337
|
matchFileHandlers(t2) {
|
|
338
338
|
const e2 = [];
|
|
339
|
-
for (const n2 of this._fileHandlers)
|
|
339
|
+
for (const n2 of this._fileHandlers) j(n2.pattern, t2) && e2.push(n2.handler);
|
|
340
340
|
return e2;
|
|
341
341
|
}
|
|
342
342
|
removeFileHandler(t2) {
|
|
@@ -386,7 +386,7 @@
|
|
|
386
386
|
this._nodeSpecs.clear(), this._markSpecs.clear(), this._inlineNodeSpecs.clear(), this._nodeViews.clear(), this._keymaps.length = 0, this._inputRules.length = 0, this._toolbarItems.clear(), this._toolbarItemPluginMap.clear(), this._fileHandlers.length = 0, this._blockTypePickerEntries.clear();
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function j(t2, e2) {
|
|
390
390
|
if ("*" === t2 || "*/*" === t2) return true;
|
|
391
391
|
if (t2 === e2) return true;
|
|
392
392
|
if (t2.endsWith("/*")) {
|
|
@@ -395,7 +395,7 @@
|
|
|
395
395
|
}
|
|
396
396
|
return false;
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function q(t2, e2) {
|
|
399
399
|
if (0 === e2.length) return;
|
|
400
400
|
let n2 = t2.children.find((t3) => t3.id === e2[0]);
|
|
401
401
|
if (n2) {
|
|
@@ -409,7 +409,7 @@
|
|
|
409
409
|
return n2;
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function U(t2, e2) {
|
|
413
413
|
for (const n2 of t2.children) {
|
|
414
414
|
if (n2.id === e2) return [e2];
|
|
415
415
|
const t3 = W(n2, e2);
|
|
@@ -535,8 +535,8 @@
|
|
|
535
535
|
if (-1 !== n2) {
|
|
536
536
|
const o2 = t3.children[n2];
|
|
537
537
|
if (!o2) return t3;
|
|
538
|
-
const r2 = l(o2), i2 = m(o2), s2 = it(r2, 0, e3.offset), c2 = it(r2, e3.offset, i2), a2 = { ...o2, children: w(s2) }, d2 =
|
|
539
|
-
return
|
|
538
|
+
const r2 = l(o2), i2 = m(o2), s2 = it(r2, 0, e3.offset), c2 = it(r2, e3.offset, i2), a2 = { ...o2, children: w(s2) }, d2 = h(o2.type, w(c2), e3.newBlockId, o2.attrs), u2 = [...t3.children];
|
|
539
|
+
return u2.splice(n2, 1, a2, d2), { children: u2 };
|
|
540
540
|
}
|
|
541
541
|
return { children: t3.children.map((t4) => tt(t4, e3) ?? t4) };
|
|
542
542
|
})(t2, e2);
|
|
@@ -650,8 +650,8 @@
|
|
|
650
650
|
function tt(t2, e2) {
|
|
651
651
|
const n2 = t2.children.findIndex((t3) => i(t3) && t3.id === e2.blockId);
|
|
652
652
|
if (-1 !== n2) {
|
|
653
|
-
const o3 = t2.children[n2], r3 = l(o3), i2 = m(o3), s2 = it(r3, 0, e2.offset), c2 = it(r3, e2.offset, i2), a2 = { ...o3, children: w(s2) }, d2 =
|
|
654
|
-
return
|
|
653
|
+
const o3 = t2.children[n2], r3 = l(o3), i2 = m(o3), s2 = it(r3, 0, e2.offset), c2 = it(r3, e2.offset, i2), a2 = { ...o3, children: w(s2) }, d2 = h(o3.type, w(c2), e2.newBlockId, o3.attrs), u2 = [...t2.children];
|
|
654
|
+
return u2.splice(n2, 1, a2, d2), { ...t2, children: u2 };
|
|
655
655
|
}
|
|
656
656
|
let o2 = false;
|
|
657
657
|
const r2 = t2.children.map((t3) => {
|
|
@@ -724,12 +724,12 @@
|
|
|
724
724
|
const t4 = i2 ? v(l2.marks, o2) : x(l2.marks, o2.type);
|
|
725
725
|
s2.push(p(l2.text, t4));
|
|
726
726
|
} else {
|
|
727
|
-
const t4 = Math.max(0, e2 - c2), r2 = Math.min(l2.text.length, n2 - c2), a2 = l2.text.slice(0, t4), d2 = l2.text.slice(t4, r2),
|
|
727
|
+
const t4 = Math.max(0, e2 - c2), r2 = Math.min(l2.text.length, n2 - c2), a2 = l2.text.slice(0, t4), d2 = l2.text.slice(t4, r2), u2 = l2.text.slice(r2);
|
|
728
728
|
if (a2 && s2.push(p(a2, l2.marks)), d2) {
|
|
729
729
|
const t5 = i2 ? v(l2.marks, o2) : x(l2.marks, o2.type);
|
|
730
730
|
s2.push(p(d2, t5));
|
|
731
731
|
}
|
|
732
|
-
|
|
732
|
+
u2 && s2.push(p(u2, l2.marks));
|
|
733
733
|
}
|
|
734
734
|
c2 = t3;
|
|
735
735
|
}
|
|
@@ -781,7 +781,7 @@
|
|
|
781
781
|
function dt(t2) {
|
|
782
782
|
return { steps: t2.steps.map(at).reverse(), selectionBefore: t2.selectionAfter, selectionAfter: t2.selectionBefore, storedMarksAfter: null, metadata: { origin: "history", timestamp: Date.now() } };
|
|
783
783
|
}
|
|
784
|
-
class
|
|
784
|
+
class ut {
|
|
785
785
|
steps = [];
|
|
786
786
|
selection;
|
|
787
787
|
storedMarks;
|
|
@@ -857,7 +857,7 @@
|
|
|
857
857
|
const e4 = t3.children[n3];
|
|
858
858
|
return e4 && i(e4) ? e4 : void 0;
|
|
859
859
|
}
|
|
860
|
-
const o3 =
|
|
860
|
+
const o3 = q(t3, e3);
|
|
861
861
|
if (!o3) return;
|
|
862
862
|
const r3 = o3.children[n3];
|
|
863
863
|
return r3 && i(r3) ? r3 : void 0;
|
|
@@ -869,7 +869,7 @@
|
|
|
869
869
|
setNodeAttr(t2, e2) {
|
|
870
870
|
const n2 = this.workingDoc;
|
|
871
871
|
if (!n2) throw new Error("setNodeAttr requires a document. Use state.transaction() or provide doc to constructor.");
|
|
872
|
-
const o2 =
|
|
872
|
+
const o2 = q(n2, t2);
|
|
873
873
|
if (!o2) throw new Error(`Node not found at path [${t2.join(", ")}].`);
|
|
874
874
|
const r2 = { type: "setNodeAttr", path: t2, attrs: e2, ...o2.attrs ? { previousAttrs: o2.attrs } : {} };
|
|
875
875
|
return this.steps.push(r2), this.advanceDoc(r2), this;
|
|
@@ -920,7 +920,7 @@
|
|
|
920
920
|
this.workingDoc && (this.workingDoc = Q(this.workingDoc, t2));
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
class
|
|
923
|
+
class ht {
|
|
924
924
|
doc;
|
|
925
925
|
selection;
|
|
926
926
|
storedMarks;
|
|
@@ -932,11 +932,11 @@
|
|
|
932
932
|
}
|
|
933
933
|
static create(t2) {
|
|
934
934
|
const e2 = t2?.schema ?? { nodeTypes: ["paragraph"], markTypes: ["bold", "italic", "underline"], getNodeSpec: () => {
|
|
935
|
-
} }, n2 = t2?.doc ??
|
|
936
|
-
return new
|
|
935
|
+
} }, n2 = t2?.doc ?? u(), o2 = n2.children[0], r2 = t2?.selection ?? A(o2 ? o2.id : "", 0);
|
|
936
|
+
return new ht(n2, r2, null, e2);
|
|
937
937
|
}
|
|
938
938
|
transaction(t2 = "api") {
|
|
939
|
-
return new
|
|
939
|
+
return new ut(this.selection, this.storedMarks, t2, this.doc);
|
|
940
940
|
}
|
|
941
941
|
apply(t2) {
|
|
942
942
|
let e2 = this.doc;
|
|
@@ -945,12 +945,12 @@
|
|
|
945
945
|
if (C(e3)) {
|
|
946
946
|
if (X(t3, e3.nodeId)) return e3;
|
|
947
947
|
const n4 = t3.children[0];
|
|
948
|
-
return n4 ?
|
|
948
|
+
return n4 ? A(n4.id, 0) : e3;
|
|
949
949
|
}
|
|
950
950
|
const n3 = pt(t3, e3.anchor), o2 = pt(t3, e3.head);
|
|
951
|
-
return n3 === e3.anchor && o2 === e3.head ? e3 :
|
|
951
|
+
return n3 === e3.anchor && o2 === e3.head ? e3 : M(n3, o2);
|
|
952
952
|
})(e2, t2.selectionAfter);
|
|
953
|
-
return new
|
|
953
|
+
return new ht(e2, n2, t2.storedMarksAfter, this.schema);
|
|
954
954
|
}
|
|
955
955
|
getBlock(t2) {
|
|
956
956
|
return this._blockMap ??= (function(t3) {
|
|
@@ -969,10 +969,10 @@
|
|
|
969
969
|
})(this.doc), this._blockOrder;
|
|
970
970
|
}
|
|
971
971
|
getNodePath(t2) {
|
|
972
|
-
return
|
|
972
|
+
return U(this.doc, t2);
|
|
973
973
|
}
|
|
974
974
|
getParent(t2) {
|
|
975
|
-
const e2 =
|
|
975
|
+
const e2 = U(this.doc, t2);
|
|
976
976
|
if (!e2 || e2.length <= 1) return;
|
|
977
977
|
const n2 = e2[e2.length - 2];
|
|
978
978
|
return n2 ? X(this.doc, n2) : void 0;
|
|
@@ -981,7 +981,7 @@
|
|
|
981
981
|
return { doc: this.doc, selection: this.selection };
|
|
982
982
|
}
|
|
983
983
|
static fromJSON(t2, e2) {
|
|
984
|
-
return new
|
|
984
|
+
return new ht(t2.doc, t2.selection, null, e2 ?? { nodeTypes: ["paragraph"], markTypes: ["bold", "italic", "underline"], getNodeSpec: () => {
|
|
985
985
|
} });
|
|
986
986
|
}
|
|
987
987
|
}
|
|
@@ -989,10 +989,10 @@
|
|
|
989
989
|
const n2 = X(t2, e2.blockId);
|
|
990
990
|
if (n2) {
|
|
991
991
|
const t3 = m(n2);
|
|
992
|
-
return e2.offset > t3 ?
|
|
992
|
+
return e2.offset > t3 ? E(e2.blockId, t3, e2.path) : e2;
|
|
993
993
|
}
|
|
994
994
|
const o2 = t2.children[0];
|
|
995
|
-
return o2 ?
|
|
995
|
+
return o2 ? E(o2.id, 0) : e2;
|
|
996
996
|
}
|
|
997
997
|
class ft {
|
|
998
998
|
undoStack = [];
|
|
@@ -1053,7 +1053,7 @@
|
|
|
1053
1053
|
return !!o2 && true === o2(n2.type)?.isVoid;
|
|
1054
1054
|
}
|
|
1055
1055
|
function bt(t2, e2) {
|
|
1056
|
-
const n2 =
|
|
1056
|
+
const n2 = U(t2.doc, e2.nodeId);
|
|
1057
1057
|
if (!n2) return null;
|
|
1058
1058
|
const o2 = n2.length > 1 ? n2.slice(0, -1) : [], r2 = 0 === o2.length ? t2.doc.children : (() => {
|
|
1059
1059
|
const e3 = t2.getBlock(o2[o2.length - 1]);
|
|
@@ -1063,7 +1063,7 @@
|
|
|
1063
1063
|
const c2 = t2.transaction("input");
|
|
1064
1064
|
if (1 === r2.length && 0 === o2.length) {
|
|
1065
1065
|
const t3 = d();
|
|
1066
|
-
return c2.insertNode(o2, 0,
|
|
1066
|
+
return c2.insertNode(o2, 0, h("paragraph", [p("")], t3)), c2.removeNode(o2, 1), c2.setSelection(A(t3, 0)), c2.build();
|
|
1067
1067
|
}
|
|
1068
1068
|
c2.removeNode(o2, s2);
|
|
1069
1069
|
const l2 = r2[s2 - 1];
|
|
@@ -1085,7 +1085,7 @@
|
|
|
1085
1085
|
})(l2);
|
|
1086
1086
|
if (e3) {
|
|
1087
1087
|
const n3 = t2.getBlock(e3), o3 = n3 ? m(n3) : 0;
|
|
1088
|
-
c2.setSelection(
|
|
1088
|
+
c2.setSelection(A(e3, o3));
|
|
1089
1089
|
}
|
|
1090
1090
|
} else {
|
|
1091
1091
|
const t3 = r2[s2 + 1];
|
|
@@ -1098,7 +1098,7 @@
|
|
|
1098
1098
|
e4 = t5;
|
|
1099
1099
|
}
|
|
1100
1100
|
})(t3);
|
|
1101
|
-
e3 && c2.setSelection(
|
|
1101
|
+
e3 && c2.setSelection(A(e3, 0));
|
|
1102
1102
|
}
|
|
1103
1103
|
}
|
|
1104
1104
|
return c2.build();
|
|
@@ -1160,11 +1160,11 @@
|
|
|
1160
1160
|
function wt(t2, e2, n2 = "input") {
|
|
1161
1161
|
const o2 = t2.selection;
|
|
1162
1162
|
if (C(o2)) return (function(t3, e3, n3, o3) {
|
|
1163
|
-
const r3 =
|
|
1163
|
+
const r3 = U(t3.doc, e3.nodeId), i3 = r3 && r3.length > 1 ? r3.slice(0, -1) : [], s3 = 0 === i3.length ? t3.doc.children : (() => {
|
|
1164
1164
|
const e4 = t3.getBlock(i3[i3.length - 1]);
|
|
1165
1165
|
return e4 ? e4.children : [];
|
|
1166
|
-
})(), c3 = s3.findIndex((t4) => "id" in t4 && t4.id === e3.nodeId), l3 = d(), a2 = t3.transaction(o3),
|
|
1167
|
-
return a2.insertNode(i3,
|
|
1166
|
+
})(), c3 = s3.findIndex((t4) => "id" in t4 && t4.id === e3.nodeId), l3 = d(), a2 = t3.transaction(o3), u2 = c3 >= 0 ? c3 + 1 : s3.length;
|
|
1167
|
+
return a2.insertNode(i3, u2, h("paragraph", [p("")], l3)), a2.insertText(l3, 0, n3, []), a2.setSelection(A(l3, n3.length)), a2.build();
|
|
1168
1168
|
})(t2, o2, e2, n2);
|
|
1169
1169
|
const r2 = t2.transaction(n2), i2 = (function(t3) {
|
|
1170
1170
|
if (t3.storedMarks) return t3.storedMarks;
|
|
@@ -1174,7 +1174,7 @@
|
|
|
1174
1174
|
})(t2);
|
|
1175
1175
|
_(o2) || Pt(t2, r2);
|
|
1176
1176
|
const s2 = _(o2) ? null : N(o2, t2.getBlockOrder()), c2 = s2 ? s2.from.blockId : o2.anchor.blockId, l2 = s2 ? s2.from.offset : o2.anchor.offset;
|
|
1177
|
-
return r2.insertText(c2, l2, e2, i2), r2.setSelection(
|
|
1177
|
+
return r2.insertText(c2, l2, e2, i2), r2.setSelection(A(c2, l2 + e2.length)), r2.build();
|
|
1178
1178
|
}
|
|
1179
1179
|
function St(t2) {
|
|
1180
1180
|
if (C(t2.selection)) return bt(t2, t2.selection);
|
|
@@ -1182,14 +1182,14 @@
|
|
|
1182
1182
|
const e2 = t2.transaction("input");
|
|
1183
1183
|
Pt(t2, e2);
|
|
1184
1184
|
const n2 = N(t2.selection, t2.getBlockOrder());
|
|
1185
|
-
return e2.setSelection(
|
|
1185
|
+
return e2.setSelection(A(n2.from.blockId, n2.from.offset)), e2.build();
|
|
1186
1186
|
}
|
|
1187
1187
|
function It(t2) {
|
|
1188
1188
|
const e2 = t2.selection;
|
|
1189
1189
|
if (C(e2)) return bt(t2, e2);
|
|
1190
1190
|
if (!_(e2)) return St(t2);
|
|
1191
1191
|
const n2 = t2.getBlock(e2.anchor.blockId);
|
|
1192
|
-
return n2 ? e2.anchor.offset > 0 ? t2.transaction("input").deleteTextAt(n2.id, e2.anchor.offset - 1, e2.anchor.offset).setSelection(
|
|
1192
|
+
return n2 ? e2.anchor.offset > 0 ? t2.transaction("input").deleteTextAt(n2.id, e2.anchor.offset - 1, e2.anchor.offset).setSelection(A(n2.id, e2.anchor.offset - 1)).build() : _t(t2) : null;
|
|
1193
1193
|
}
|
|
1194
1194
|
function Ct(t2) {
|
|
1195
1195
|
const e2 = t2.selection;
|
|
@@ -1198,12 +1198,12 @@
|
|
|
1198
1198
|
const n2 = t2.getBlock(e2.anchor.blockId);
|
|
1199
1199
|
if (!n2) return null;
|
|
1200
1200
|
const o2 = m(n2);
|
|
1201
|
-
return e2.anchor.offset < o2 ? t2.transaction("input").deleteTextAt(n2.id, e2.anchor.offset, e2.anchor.offset + 1).setSelection(
|
|
1201
|
+
return e2.anchor.offset < o2 ? t2.transaction("input").deleteTextAt(n2.id, e2.anchor.offset, e2.anchor.offset + 1).setSelection(A(n2.id, e2.anchor.offset)).build() : Lt(t2);
|
|
1202
1202
|
}
|
|
1203
1203
|
function Tt(t2) {
|
|
1204
1204
|
const e2 = t2.selection;
|
|
1205
1205
|
if (C(e2)) return (function(t3, e3) {
|
|
1206
|
-
const n3 =
|
|
1206
|
+
const n3 = U(t3.doc, e3.nodeId);
|
|
1207
1207
|
if (!n3) return null;
|
|
1208
1208
|
const o3 = n3.length > 1 ? n3.slice(0, -1) : [], r3 = (0 === o3.length ? t3.doc.children : (() => {
|
|
1209
1209
|
const e4 = t3.getBlock(o3[o3.length - 1]);
|
|
@@ -1211,12 +1211,12 @@
|
|
|
1211
1211
|
})()).findIndex((t4) => "id" in t4 && t4.id === e3.nodeId);
|
|
1212
1212
|
if (r3 < 0) return null;
|
|
1213
1213
|
const i3 = d(), s2 = t3.transaction("input");
|
|
1214
|
-
return s2.insertNode(o3, r3 + 1,
|
|
1214
|
+
return s2.insertNode(o3, r3 + 1, h("paragraph", [p("")], i3)), s2.setSelection(A(i3, 0)), s2.build();
|
|
1215
1215
|
})(t2, e2);
|
|
1216
1216
|
const n2 = t2.transaction("input");
|
|
1217
1217
|
_(e2) || Pt(t2, n2);
|
|
1218
1218
|
const o2 = _(e2) ? e2.anchor.blockId : N(e2, t2.getBlockOrder()).from.blockId, r2 = _(e2) ? e2.anchor.offset : N(e2, t2.getBlockOrder()).from.offset, i2 = d();
|
|
1219
|
-
return n2.splitBlock(o2, r2, i2), n2.setSelection(
|
|
1219
|
+
return n2.splitBlock(o2, r2, i2), n2.setSelection(A(i2, 0)), n2.build();
|
|
1220
1220
|
}
|
|
1221
1221
|
function Bt(t2) {
|
|
1222
1222
|
const e2 = t2.selection;
|
|
@@ -1224,16 +1224,16 @@
|
|
|
1224
1224
|
const n2 = t2.transaction("input");
|
|
1225
1225
|
_(e2) || Pt(t2, n2);
|
|
1226
1226
|
const o2 = _(e2) ? null : N(e2, t2.getBlockOrder()), r2 = o2 ? o2.from.blockId : e2.anchor.blockId, i2 = o2 ? o2.from.offset : e2.anchor.offset, s2 = f("hard_break");
|
|
1227
|
-
return n2.insertInlineNode(r2, i2, s2), n2.setSelection(
|
|
1227
|
+
return n2.insertInlineNode(r2, i2, s2), n2.setSelection(A(r2, i2 + 1)), n2.build();
|
|
1228
1228
|
}
|
|
1229
|
-
function
|
|
1229
|
+
function Et(t2, e2, n2) {
|
|
1230
1230
|
const o2 = t2.getNodePath(e2), r2 = t2.getNodePath(n2);
|
|
1231
1231
|
if (!o2 || !r2) return false;
|
|
1232
1232
|
if (o2.length !== r2.length) return false;
|
|
1233
1233
|
for (let t3 = 0; t3 < o2.length - 1; t3++) if (o2[t3] !== r2[t3]) return false;
|
|
1234
1234
|
return true;
|
|
1235
1235
|
}
|
|
1236
|
-
function
|
|
1236
|
+
function Mt(t2, e2) {
|
|
1237
1237
|
const n2 = t2.schema.getNodeSpec;
|
|
1238
1238
|
if (!n2) return false;
|
|
1239
1239
|
const o2 = t2.getNodePath(e2);
|
|
@@ -1248,7 +1248,7 @@
|
|
|
1248
1248
|
}
|
|
1249
1249
|
return false;
|
|
1250
1250
|
}
|
|
1251
|
-
function
|
|
1251
|
+
function At(t2, e2) {
|
|
1252
1252
|
const n2 = t2.schema.getNodeSpec;
|
|
1253
1253
|
if (!n2) return false;
|
|
1254
1254
|
const o2 = t2.getBlock(e2);
|
|
@@ -1261,16 +1261,16 @@
|
|
|
1261
1261
|
if (o2 <= 0) return null;
|
|
1262
1262
|
const r2 = n2[o2 - 1];
|
|
1263
1263
|
if (!r2) return null;
|
|
1264
|
-
if (
|
|
1265
|
-
if (!
|
|
1264
|
+
if (At(t2, e2.anchor.blockId) || At(t2, r2)) return null;
|
|
1265
|
+
if (!Et(t2, e2.anchor.blockId, r2) && Mt(t2, e2.anchor.blockId)) return null;
|
|
1266
1266
|
if (mt(t2, r2)) {
|
|
1267
|
-
const e3 =
|
|
1267
|
+
const e3 = U(t2.doc, r2) ?? [];
|
|
1268
1268
|
return t2.transaction("input").setSelection(I(r2, e3)).build();
|
|
1269
1269
|
}
|
|
1270
1270
|
const i2 = t2.getBlock(r2);
|
|
1271
1271
|
if (!i2) return null;
|
|
1272
1272
|
const s2 = m(i2);
|
|
1273
|
-
return t2.transaction("input").mergeBlocksAt(r2, e2.anchor.blockId).setSelection(
|
|
1273
|
+
return t2.transaction("input").mergeBlocksAt(r2, e2.anchor.blockId).setSelection(A(r2, s2)).build();
|
|
1274
1274
|
}
|
|
1275
1275
|
function Lt(t2) {
|
|
1276
1276
|
const e2 = t2.selection;
|
|
@@ -1279,19 +1279,19 @@
|
|
|
1279
1279
|
if (o2 >= n2.length - 1) return null;
|
|
1280
1280
|
const r2 = n2[o2 + 1];
|
|
1281
1281
|
if (!r2) return null;
|
|
1282
|
-
if (
|
|
1283
|
-
if (!
|
|
1282
|
+
if (At(t2, e2.anchor.blockId) || At(t2, r2)) return null;
|
|
1283
|
+
if (!Et(t2, e2.anchor.blockId, r2) && Mt(t2, e2.anchor.blockId)) return null;
|
|
1284
1284
|
if (mt(t2, r2)) {
|
|
1285
|
-
const e3 =
|
|
1285
|
+
const e3 = U(t2.doc, r2) ?? [];
|
|
1286
1286
|
return t2.transaction("input").setSelection(I(r2, e3)).build();
|
|
1287
1287
|
}
|
|
1288
|
-
return t2.transaction("input").mergeBlocksAt(e2.anchor.blockId, r2).setSelection(
|
|
1288
|
+
return t2.transaction("input").mergeBlocksAt(e2.anchor.blockId, r2).setSelection(A(e2.anchor.blockId, e2.anchor.offset)).build();
|
|
1289
1289
|
}
|
|
1290
1290
|
function Nt(t2) {
|
|
1291
1291
|
const e2 = t2.doc.children, n2 = e2[0], o2 = e2[e2.length - 1];
|
|
1292
1292
|
if (!n2 || !o2) return t2.transaction("command").setSelection(t2.selection).build();
|
|
1293
1293
|
const r2 = m(o2);
|
|
1294
|
-
return t2.transaction("command").setSelection(
|
|
1294
|
+
return t2.transaction("command").setSelection(M({ blockId: n2.id, offset: 0 }, { blockId: o2.id, offset: r2 })).build();
|
|
1295
1295
|
}
|
|
1296
1296
|
function zt(t2, e2) {
|
|
1297
1297
|
const n2 = t2.selection;
|
|
@@ -1332,11 +1332,11 @@
|
|
|
1332
1332
|
const e3 = o2[r3 - 1];
|
|
1333
1333
|
if (!e3) return null;
|
|
1334
1334
|
if (mt(t2, e3)) {
|
|
1335
|
-
const n4 =
|
|
1335
|
+
const n4 = U(t2.doc, e3) ?? [];
|
|
1336
1336
|
return t2.transaction("input").setSelection(I(e3, n4)).build();
|
|
1337
1337
|
}
|
|
1338
1338
|
const n3 = t2.getBlock(e3), i3 = n3 ? m(n3) : 0;
|
|
1339
|
-
return t2.transaction("input").setSelection(
|
|
1339
|
+
return t2.transaction("input").setSelection(A(e3, i3)).build();
|
|
1340
1340
|
}
|
|
1341
1341
|
return null;
|
|
1342
1342
|
}
|
|
@@ -1344,10 +1344,10 @@
|
|
|
1344
1344
|
const e3 = o2[r3 + 1];
|
|
1345
1345
|
if (!e3) return null;
|
|
1346
1346
|
if (mt(t2, e3)) {
|
|
1347
|
-
const n3 =
|
|
1347
|
+
const n3 = U(t2.doc, e3) ?? [];
|
|
1348
1348
|
return t2.transaction("input").setSelection(I(e3, n3)).build();
|
|
1349
1349
|
}
|
|
1350
|
-
return t2.transaction("input").setSelection(
|
|
1350
|
+
return t2.transaction("input").setSelection(A(e3, 0)).build();
|
|
1351
1351
|
}
|
|
1352
1352
|
return null;
|
|
1353
1353
|
}
|
|
@@ -1358,14 +1358,14 @@
|
|
|
1358
1358
|
if (("right" === e2 || "down" === e2) && n2.anchor.offset === s2 && r2 < o2.length - 1) {
|
|
1359
1359
|
const e3 = o2[r2 + 1];
|
|
1360
1360
|
if (e3 && mt(t2, e3)) {
|
|
1361
|
-
const n3 =
|
|
1361
|
+
const n3 = U(t2.doc, e3) ?? [];
|
|
1362
1362
|
return t2.transaction("input").setSelection(I(e3, n3)).build();
|
|
1363
1363
|
}
|
|
1364
1364
|
}
|
|
1365
1365
|
if (("left" === e2 || "up" === e2) && 0 === n2.anchor.offset && r2 > 0) {
|
|
1366
1366
|
const e3 = o2[r2 - 1];
|
|
1367
1367
|
if (e3 && mt(t2, e3)) {
|
|
1368
|
-
const n3 =
|
|
1368
|
+
const n3 = U(t2.doc, e3) ?? [];
|
|
1369
1369
|
return t2.transaction("input").setSelection(I(e3, n3)).build();
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
@@ -1507,7 +1507,7 @@
|
|
|
1507
1507
|
if (!n3) continue;
|
|
1508
1508
|
const a3 = e2.getBlock(n3);
|
|
1509
1509
|
if (!a3) continue;
|
|
1510
|
-
const d2 = g(a3),
|
|
1510
|
+
const d2 = g(a3), u2 = m(a3), h2 = t3 === i2 ? r2.from.offset : 0, p2 = t3 === s2 ? r2.to.offset : u2, f2 = d2.slice(h2, p2);
|
|
1511
1511
|
c2.push(f2), l2.push({ type: a3.type, text: f2, ...a3.attrs ? { attrs: { ...a3.attrs } } : {} });
|
|
1512
1512
|
}
|
|
1513
1513
|
const a2 = c2.join("\n");
|
|
@@ -1566,6 +1566,11 @@
|
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
1568
|
class Kt {
|
|
1569
|
+
constructor(t2) {
|
|
1570
|
+
this.id = t2;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
class Vt {
|
|
1569
1574
|
listeners = /* @__PURE__ */ new Map();
|
|
1570
1575
|
emit(t2, e2) {
|
|
1571
1576
|
const n2 = this.listeners.get(t2.id);
|
|
@@ -1591,7 +1596,7 @@
|
|
|
1591
1596
|
this.listeners.clear();
|
|
1592
1597
|
}
|
|
1593
1598
|
}
|
|
1594
|
-
function
|
|
1599
|
+
function jt(t2, e2) {
|
|
1595
1600
|
switch (t2.type) {
|
|
1596
1601
|
case "inline":
|
|
1597
1602
|
return (function(t3, e3) {
|
|
@@ -1605,7 +1610,7 @@
|
|
|
1605
1610
|
case "deleteText":
|
|
1606
1611
|
return (function(t4, e4) {
|
|
1607
1612
|
if (t4.blockId !== e4.blockId) return t4;
|
|
1608
|
-
const n2 = e4.to - e4.from, o2 =
|
|
1613
|
+
const n2 = e4.to - e4.from, o2 = Ut(t4.from, e4.from, e4.to, n2), r2 = Ut(t4.to, e4.from, e4.to, n2);
|
|
1609
1614
|
return o2 >= r2 ? null : o2 === t4.from && r2 === t4.to ? t4 : { ...t4, from: o2, to: r2 };
|
|
1610
1615
|
})(t3, e3);
|
|
1611
1616
|
case "splitBlock":
|
|
@@ -1620,7 +1625,7 @@
|
|
|
1620
1625
|
return t4.blockId !== e4.sourceBlockId ? t4 : { ...t4, blockId: e4.targetBlockId, from: t4.from + e4.targetLengthBefore, to: t4.to + e4.targetLengthBefore };
|
|
1621
1626
|
})(t3, e3);
|
|
1622
1627
|
case "removeNode":
|
|
1623
|
-
return
|
|
1628
|
+
return qt(t3, e3);
|
|
1624
1629
|
default:
|
|
1625
1630
|
return t3;
|
|
1626
1631
|
}
|
|
@@ -1650,7 +1655,7 @@
|
|
|
1650
1655
|
return t4.blockId !== e4.sourceBlockId ? t4 : { ...t4, blockId: e4.targetBlockId, offset: t4.offset + e4.targetLengthBefore };
|
|
1651
1656
|
})(t3, e3);
|
|
1652
1657
|
case "removeNode":
|
|
1653
|
-
return
|
|
1658
|
+
return qt(t3, e3);
|
|
1654
1659
|
default:
|
|
1655
1660
|
return t3;
|
|
1656
1661
|
}
|
|
@@ -1663,35 +1668,35 @@
|
|
|
1663
1668
|
return t4.blockId === e4.sourceBlockId ? null : t4;
|
|
1664
1669
|
})(t3, e3);
|
|
1665
1670
|
case "removeNode":
|
|
1666
|
-
return
|
|
1671
|
+
return qt(t3, e3);
|
|
1667
1672
|
default:
|
|
1668
1673
|
return t3;
|
|
1669
1674
|
}
|
|
1670
1675
|
})(t2, e2);
|
|
1671
1676
|
}
|
|
1672
1677
|
}
|
|
1673
|
-
function
|
|
1678
|
+
function qt(t2, e2) {
|
|
1674
1679
|
return t2.blockId === e2.removedNode.id ? null : t2;
|
|
1675
1680
|
}
|
|
1676
|
-
function
|
|
1681
|
+
function Ut(t2, e2, n2, o2) {
|
|
1677
1682
|
return t2 <= e2 ? t2 : t2 >= n2 ? t2 - o2 : e2;
|
|
1678
1683
|
}
|
|
1679
|
-
function
|
|
1684
|
+
function Wt(t2, e2, n2, o2) {
|
|
1680
1685
|
return { type: "inline", blockId: t2, from: e2, to: n2, attrs: o2 };
|
|
1681
1686
|
}
|
|
1682
|
-
class
|
|
1687
|
+
class Gt {
|
|
1683
1688
|
constructor(t2) {
|
|
1684
1689
|
this.byBlock = t2;
|
|
1685
1690
|
}
|
|
1686
|
-
static empty = new
|
|
1691
|
+
static empty = new Gt(/* @__PURE__ */ new Map());
|
|
1687
1692
|
static create(t2) {
|
|
1688
|
-
if (0 === t2.length) return
|
|
1693
|
+
if (0 === t2.length) return Gt.empty;
|
|
1689
1694
|
const e2 = /* @__PURE__ */ new Map();
|
|
1690
1695
|
for (const n2 of t2) {
|
|
1691
1696
|
const t3 = e2.get(n2.blockId);
|
|
1692
1697
|
t3 ? t3.push(n2) : e2.set(n2.blockId, [n2]);
|
|
1693
1698
|
}
|
|
1694
|
-
return new
|
|
1699
|
+
return new Gt(e2);
|
|
1695
1700
|
}
|
|
1696
1701
|
find(t2) {
|
|
1697
1702
|
return this.byBlock.get(t2) ?? [];
|
|
@@ -1710,14 +1715,14 @@
|
|
|
1710
1715
|
}
|
|
1711
1716
|
add(t2) {
|
|
1712
1717
|
if (0 === t2.length) return this;
|
|
1713
|
-
if (this.isEmpty) return
|
|
1718
|
+
if (this.isEmpty) return Gt.create(t2);
|
|
1714
1719
|
const e2 = /* @__PURE__ */ new Map();
|
|
1715
1720
|
for (const [t3, n2] of this.byBlock) e2.set(t3, [...n2]);
|
|
1716
1721
|
for (const n2 of t2) {
|
|
1717
1722
|
const t3 = e2.get(n2.blockId);
|
|
1718
1723
|
t3 ? t3.push(n2) : e2.set(n2.blockId, [n2]);
|
|
1719
1724
|
}
|
|
1720
|
-
return new
|
|
1725
|
+
return new Gt(e2);
|
|
1721
1726
|
}
|
|
1722
1727
|
remove(t2) {
|
|
1723
1728
|
const e2 = /* @__PURE__ */ new Map();
|
|
@@ -1726,7 +1731,7 @@
|
|
|
1726
1731
|
const i2 = r2.filter((e3) => !t2(e3));
|
|
1727
1732
|
i2.length !== r2.length && (n2 = true), i2.length > 0 && e2.set(o2, i2);
|
|
1728
1733
|
}
|
|
1729
|
-
return n2 ? 0 === e2.size ?
|
|
1734
|
+
return n2 ? 0 === e2.size ? Gt.empty : new Gt(e2) : this;
|
|
1730
1735
|
}
|
|
1731
1736
|
merge(t2) {
|
|
1732
1737
|
if (t2.isEmpty) return this;
|
|
@@ -1737,7 +1742,7 @@
|
|
|
1737
1742
|
const t3 = e2.get(n2);
|
|
1738
1743
|
t3 ? t3.push(...o2) : e2.set(n2, [...o2]);
|
|
1739
1744
|
}
|
|
1740
|
-
return new
|
|
1745
|
+
return new Gt(e2);
|
|
1741
1746
|
}
|
|
1742
1747
|
equals(t2) {
|
|
1743
1748
|
if (this === t2) return true;
|
|
@@ -1745,7 +1750,7 @@
|
|
|
1745
1750
|
for (const [e2, n2] of this.byBlock) {
|
|
1746
1751
|
const o2 = t2.byBlock.get(e2);
|
|
1747
1752
|
if (!o2) return false;
|
|
1748
|
-
if (!
|
|
1753
|
+
if (!Xt(n2, o2)) return false;
|
|
1749
1754
|
}
|
|
1750
1755
|
return true;
|
|
1751
1756
|
}
|
|
@@ -1759,35 +1764,35 @@
|
|
|
1759
1764
|
for (const n2 of t2.steps) {
|
|
1760
1765
|
const t3 = [];
|
|
1761
1766
|
for (const o2 of e2) {
|
|
1762
|
-
const e3 =
|
|
1767
|
+
const e3 = jt(o2, n2);
|
|
1763
1768
|
if (null !== e3) if (Array.isArray(e3)) for (const n3 of e3) t3.push(n3);
|
|
1764
1769
|
else t3.push(e3);
|
|
1765
1770
|
}
|
|
1766
1771
|
e2 = t3;
|
|
1767
1772
|
}
|
|
1768
|
-
return 0 === e2.length ?
|
|
1773
|
+
return 0 === e2.length ? Gt.empty : Gt.create(e2);
|
|
1769
1774
|
}
|
|
1770
1775
|
}
|
|
1771
|
-
function
|
|
1776
|
+
function Xt(t2, e2) {
|
|
1772
1777
|
if (t2 === e2) return true;
|
|
1773
1778
|
if (t2.length !== e2.length) return false;
|
|
1774
1779
|
for (let n2 = 0; n2 < t2.length; n2++) {
|
|
1775
1780
|
const o2 = t2[n2], r2 = e2[n2];
|
|
1776
|
-
if (!o2 || !r2 || !
|
|
1781
|
+
if (!o2 || !r2 || !Yt(o2, r2)) return false;
|
|
1777
1782
|
}
|
|
1778
1783
|
return true;
|
|
1779
1784
|
}
|
|
1780
|
-
function
|
|
1785
|
+
function Yt(t2, e2) {
|
|
1781
1786
|
if (t2.type !== e2.type) return false;
|
|
1782
1787
|
if (t2.blockId !== e2.blockId) return false;
|
|
1783
1788
|
switch (t2.type) {
|
|
1784
1789
|
case "inline": {
|
|
1785
1790
|
const n2 = e2;
|
|
1786
|
-
return t2.from === n2.from && t2.to === n2.to &&
|
|
1791
|
+
return t2.from === n2.from && t2.to === n2.to && Jt(t2.attrs, n2.attrs);
|
|
1787
1792
|
}
|
|
1788
1793
|
case "node": {
|
|
1789
1794
|
const n2 = e2;
|
|
1790
|
-
return
|
|
1795
|
+
return Jt(t2.attrs, n2.attrs);
|
|
1791
1796
|
}
|
|
1792
1797
|
case "widget": {
|
|
1793
1798
|
const n2 = e2;
|
|
@@ -1795,20 +1800,20 @@
|
|
|
1795
1800
|
}
|
|
1796
1801
|
}
|
|
1797
1802
|
}
|
|
1798
|
-
function
|
|
1803
|
+
function Jt(t2, e2) {
|
|
1799
1804
|
if (t2 === e2) return true;
|
|
1800
1805
|
const n2 = Object.keys(t2), o2 = Object.keys(e2);
|
|
1801
1806
|
if (n2.length !== o2.length) return false;
|
|
1802
1807
|
for (const o3 of n2) if (t2[o3] !== e2[o3]) return false;
|
|
1803
1808
|
return true;
|
|
1804
1809
|
}
|
|
1805
|
-
class
|
|
1810
|
+
class Zt {
|
|
1806
1811
|
plugins = /* @__PURE__ */ new Map();
|
|
1807
1812
|
commands = /* @__PURE__ */ new Map();
|
|
1808
1813
|
services = /* @__PURE__ */ new Map();
|
|
1809
1814
|
middlewares = [];
|
|
1810
1815
|
registrations = /* @__PURE__ */ new Map();
|
|
1811
|
-
eventBus = new
|
|
1816
|
+
eventBus = new Vt();
|
|
1812
1817
|
pluginStyleSheets = [];
|
|
1813
1818
|
schemaRegistry = new V();
|
|
1814
1819
|
middlewareSorted = null;
|
|
@@ -1856,7 +1861,7 @@
|
|
|
1856
1861
|
}
|
|
1857
1862
|
}
|
|
1858
1863
|
collectDecorations(t2, e2) {
|
|
1859
|
-
let n2 =
|
|
1864
|
+
let n2 = Gt.empty;
|
|
1860
1865
|
for (const o2 of this.initOrder) {
|
|
1861
1866
|
const r2 = this.plugins.get(o2);
|
|
1862
1867
|
if (r2?.decorations) try {
|
|
@@ -1916,6 +1921,9 @@
|
|
|
1916
1921
|
getService(t2) {
|
|
1917
1922
|
return this.services.get(t2.id);
|
|
1918
1923
|
}
|
|
1924
|
+
onEvent(t2, e2) {
|
|
1925
|
+
return this.eventBus.on(t2, e2);
|
|
1926
|
+
}
|
|
1919
1927
|
getPluginStyleSheets() {
|
|
1920
1928
|
return this.pluginStyleSheets;
|
|
1921
1929
|
}
|
|
@@ -2051,39 +2059,39 @@
|
|
|
2051
2059
|
return r2;
|
|
2052
2060
|
}
|
|
2053
2061
|
}
|
|
2054
|
-
function
|
|
2062
|
+
function Qt(t2, e2, n2) {
|
|
2055
2063
|
const o2 = t2.length;
|
|
2056
2064
|
if (0 === o2) return -1;
|
|
2057
2065
|
let r2 = e2;
|
|
2058
2066
|
for (let e3 = 0; e3 < o2; e3++) if (r2 = (r2 + n2 + o2) % o2, !t2[r2]?.disabled) return r2;
|
|
2059
2067
|
return e2;
|
|
2060
2068
|
}
|
|
2061
|
-
function
|
|
2069
|
+
function te(t2) {
|
|
2062
2070
|
for (let e2 = 0; e2 < t2.length; e2++) if (!t2[e2]?.disabled) return e2;
|
|
2063
2071
|
return -1;
|
|
2064
2072
|
}
|
|
2065
|
-
function
|
|
2073
|
+
function ee(t2, e2) {
|
|
2066
2074
|
for (let n2 = 0; n2 < t2.length; n2++) {
|
|
2067
2075
|
const o2 = t2[n2];
|
|
2068
2076
|
o2 && o2.setAttribute("tabindex", n2 === e2 ? "0" : "-1");
|
|
2069
2077
|
}
|
|
2070
2078
|
}
|
|
2071
|
-
function
|
|
2079
|
+
function ne(t2, e2, n2) {
|
|
2072
2080
|
const o2 = t2.length;
|
|
2073
2081
|
return 0 === o2 ? -1 : (e2 + n2 + o2) % o2;
|
|
2074
2082
|
}
|
|
2075
|
-
function
|
|
2083
|
+
function oe(t2, e2, n2) {
|
|
2076
2084
|
const o2 = t2.querySelectorAll(".notectl-grid-picker__cell");
|
|
2077
2085
|
for (const t3 of o2) {
|
|
2078
2086
|
const o3 = Number(t3.getAttribute("data-row")), r2 = Number(t3.getAttribute("data-col"));
|
|
2079
2087
|
t3.classList.toggle("notectl-grid-picker__cell--highlighted", o3 <= e2 && r2 <= n2);
|
|
2080
2088
|
}
|
|
2081
2089
|
}
|
|
2082
|
-
function
|
|
2090
|
+
function re() {
|
|
2083
2091
|
const t2 = document.createElement("span");
|
|
2084
2092
|
return t2.className = "notectl-toolbar-separator", t2.setAttribute("role", "separator"), t2;
|
|
2085
2093
|
}
|
|
2086
|
-
class
|
|
2094
|
+
class ie {
|
|
2087
2095
|
activePopup = null;
|
|
2088
2096
|
activePopupButton = null;
|
|
2089
2097
|
closePopupHandler = null;
|
|
@@ -2108,7 +2116,7 @@
|
|
|
2108
2116
|
for (let t4 = 1; t4 <= e3.maxRows; t4++) for (let i2 = 1; i2 <= e3.maxCols; i2++) {
|
|
2109
2117
|
const s2 = document.createElement("div");
|
|
2110
2118
|
s2.className = "notectl-grid-picker__cell", s2.setAttribute("role", "gridcell"), s2.setAttribute("tabindex", "-1"), s2.setAttribute("aria-label", `${t4} x ${i2}`), s2.style.width = "20px", s2.style.height = "20px", s2.style.border = "1px solid #ccc", s2.style.cursor = "pointer", s2.setAttribute("data-row", String(t4)), s2.setAttribute("data-col", String(i2)), s2.addEventListener("mouseenter", () => {
|
|
2111
|
-
|
|
2119
|
+
oe(o3, t4, i2), r2.textContent = `${t4} x ${i2}`;
|
|
2112
2120
|
}), s2.addEventListener("mousedown", (o4) => {
|
|
2113
2121
|
o4.preventDefault(), o4.stopPropagation(), e3.onSelect(t4, i2), n3();
|
|
2114
2122
|
}), s2.addEventListener("click", () => {
|
|
@@ -2180,13 +2188,13 @@
|
|
|
2180
2188
|
switch (t2.key) {
|
|
2181
2189
|
case "ArrowDown": {
|
|
2182
2190
|
t2.preventDefault();
|
|
2183
|
-
const e3 =
|
|
2191
|
+
const e3 = ne(n2, o2, 1);
|
|
2184
2192
|
n2[e3]?.focus();
|
|
2185
2193
|
break;
|
|
2186
2194
|
}
|
|
2187
2195
|
case "ArrowUp": {
|
|
2188
2196
|
t2.preventDefault();
|
|
2189
|
-
const e3 =
|
|
2197
|
+
const e3 = ne(n2, o2, -1);
|
|
2190
2198
|
n2[e3]?.focus();
|
|
2191
2199
|
break;
|
|
2192
2200
|
}
|
|
@@ -2217,7 +2225,7 @@
|
|
|
2217
2225
|
return [t3, e4 < o3 ? e4 + 1 : 1];
|
|
2218
2226
|
}
|
|
2219
2227
|
})(n2, o2, c2, s2, t2.key), l2 = r2.querySelector(`.notectl-grid-picker__cell[data-row="${e3}"][data-col="${i3}"]`);
|
|
2220
|
-
l2?.focus(),
|
|
2228
|
+
l2?.focus(), oe(r2, e3, i3);
|
|
2221
2229
|
const a2 = this.activePopup?.querySelector(".notectl-grid-picker__label") ?? null;
|
|
2222
2230
|
a2 && (a2.textContent = `${e3} x ${i3}`);
|
|
2223
2231
|
}
|
|
@@ -2231,13 +2239,13 @@
|
|
|
2231
2239
|
switch (t2.key) {
|
|
2232
2240
|
case "ArrowDown": {
|
|
2233
2241
|
t2.preventDefault();
|
|
2234
|
-
const n3 =
|
|
2242
|
+
const n3 = ne(e2, o2, 1);
|
|
2235
2243
|
e2[n3]?.focus();
|
|
2236
2244
|
break;
|
|
2237
2245
|
}
|
|
2238
2246
|
case "ArrowUp": {
|
|
2239
2247
|
t2.preventDefault();
|
|
2240
|
-
const n3 =
|
|
2248
|
+
const n3 = ne(e2, o2, -1);
|
|
2241
2249
|
e2[n3]?.focus();
|
|
2242
2250
|
break;
|
|
2243
2251
|
}
|
|
@@ -2247,14 +2255,14 @@
|
|
|
2247
2255
|
}
|
|
2248
2256
|
}
|
|
2249
2257
|
}
|
|
2250
|
-
class
|
|
2258
|
+
class se {
|
|
2251
2259
|
element;
|
|
2252
2260
|
timer = null;
|
|
2253
2261
|
target = null;
|
|
2254
2262
|
isPopupActive;
|
|
2255
2263
|
static TOOLTIP_ID = "notectl-toolbar-tooltip";
|
|
2256
2264
|
constructor(t2) {
|
|
2257
|
-
this.isPopupActive = t2, this.element = document.createElement("div"), this.element.className = "notectl-toolbar-tooltip", this.element.id =
|
|
2265
|
+
this.isPopupActive = t2, this.element = document.createElement("div"), this.element.className = "notectl-toolbar-tooltip", this.element.id = se.TOOLTIP_ID, this.element.setAttribute("role", "tooltip"), this.element.style.display = "none";
|
|
2258
2266
|
}
|
|
2259
2267
|
show(t2) {
|
|
2260
2268
|
if (this.hide(), this.isPopupActive() || t2.disabled) return;
|
|
@@ -2263,7 +2271,7 @@
|
|
|
2263
2271
|
if (this.isPopupActive()) return;
|
|
2264
2272
|
this.element.textContent = e2, this.element.style.display = "";
|
|
2265
2273
|
const n2 = t2.getRootNode();
|
|
2266
|
-
n2 instanceof ShadowRoot && !this.element.parentNode ? n2.appendChild(this.element) : n2 instanceof ShadowRoot || this.element.parentNode || document.body.appendChild(this.element), t2.setAttribute("aria-describedby",
|
|
2274
|
+
n2 instanceof ShadowRoot && !this.element.parentNode ? n2.appendChild(this.element) : n2 instanceof ShadowRoot || this.element.parentNode || document.body.appendChild(this.element), t2.setAttribute("aria-describedby", se.TOOLTIP_ID);
|
|
2267
2275
|
const o2 = t2.getBoundingClientRect();
|
|
2268
2276
|
this.element.style.position = "fixed", this.element.style.top = `${o2.bottom + 6}px`, this.element.style.left = `${o2.left + o2.width / 2}px`, this.element.style.transform = "translateX(-50%)";
|
|
2269
2277
|
}, 500));
|
|
@@ -2275,8 +2283,8 @@
|
|
|
2275
2283
|
this.hide(), this.element.remove();
|
|
2276
2284
|
}
|
|
2277
2285
|
}
|
|
2278
|
-
const
|
|
2279
|
-
class
|
|
2286
|
+
const ce = new Kt("toolbar");
|
|
2287
|
+
class le {
|
|
2280
2288
|
id = "toolbar";
|
|
2281
2289
|
name = "Toolbar";
|
|
2282
2290
|
priority = 10;
|
|
@@ -2292,7 +2300,7 @@
|
|
|
2292
2300
|
this.layoutConfig = t2 ?? null;
|
|
2293
2301
|
}
|
|
2294
2302
|
init(t2) {
|
|
2295
|
-
t2.registerStyleSheet("\n/* Toolbar */\n.notectl-plugin-container--top {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n border-bottom: 1px solid var(--notectl-border);\n background: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n min-height: 40px;\n}\n\n.notectl-toolbar {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 2px;\n padding: 4px 8px;\n}\n\n.notectl-toolbar-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n border: 1px solid transparent;\n border-radius: 4px;\n background: transparent;\n cursor: pointer;\n color: var(--notectl-fg);\n font-size: 14px;\n line-height: 1;\n padding: 0;\n transition: background 0.1s, border-color 0.1s;\n}\n\n.notectl-toolbar-btn:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-border);\n}\n\n.notectl-toolbar-btn--active {\n background: var(--notectl-active-bg);\n border-color: var(--notectl-primary-muted);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-toolbar-btn:focus-visible {\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n outline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.notectl-toolbar-btn:disabled:hover {\n background: transparent;\n border-color: transparent;\n}\n\n.notectl-toolbar-btn__icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n display: block;\n width: 18px;\n height: 18px;\n fill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n position: fixed;\n padding: 4px 8px;\n border-radius: 4px;\n background: var(--notectl-tooltip-bg);\n color: var(--notectl-tooltip-fg);\n font-size: 11px;\n font-weight: 500;\n white-space: nowrap;\n pointer-events: none;\n z-index: 10001;\n line-height: 1.4;\n letter-spacing: 0.01em;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n display: inline-block;\n width: 1px;\n height: 20px;\n background: var(--notectl-border);\n margin: 0 4px;\n vertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px var(--notectl-shadow);\n overflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n outline: 2px solid var(--notectl-focus-ring);\n outline-offset: -1px;\n}\n\n/* Dropdown */\n.notectl-dropdown {\n min-width: 160px;\n padding: 4px 0;\n}\n\n.notectl-dropdown__item {\n display: flex;\n align-items: center;\n width: 100%;\n padding: 8px 12px;\n text-align: left;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n line-height: 1.4;\n font-family: inherit;\n white-space: nowrap;\n}\n\n.notectl-dropdown__item:hover,\n.notectl-dropdown__item:focus-visible {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-dropdown__item:focus-visible {\n outline: none;\n}\n\n.notectl-dropdown__item-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n font-weight: 600;\n color: var(--notectl-fg-muted);\n flex-shrink: 0;\n}\n\n.notectl-dropdown__item-label {\n flex: 1;\n}\n"), this.context = t2, this.popupController = new
|
|
2303
|
+
t2.registerStyleSheet("\n/* Toolbar */\n.notectl-plugin-container--top {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n border-bottom: 1px solid var(--notectl-border);\n background: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n min-height: 40px;\n}\n\n.notectl-toolbar {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 2px;\n padding: 4px 8px;\n}\n\n.notectl-toolbar-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n border: 1px solid transparent;\n border-radius: 4px;\n background: transparent;\n cursor: pointer;\n color: var(--notectl-fg);\n font-size: 14px;\n line-height: 1;\n padding: 0;\n transition: background 0.1s, border-color 0.1s;\n}\n\n.notectl-toolbar-btn:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-border);\n}\n\n.notectl-toolbar-btn--active {\n background: var(--notectl-active-bg);\n border-color: var(--notectl-primary-muted);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-toolbar-btn:focus-visible {\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n outline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.notectl-toolbar-btn:disabled:hover {\n background: transparent;\n border-color: transparent;\n}\n\n.notectl-toolbar-btn__icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n display: block;\n width: 18px;\n height: 18px;\n fill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n position: fixed;\n padding: 4px 8px;\n border-radius: 4px;\n background: var(--notectl-tooltip-bg);\n color: var(--notectl-tooltip-fg);\n font-size: 11px;\n font-weight: 500;\n white-space: nowrap;\n pointer-events: none;\n z-index: 10001;\n line-height: 1.4;\n letter-spacing: 0.01em;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n display: inline-block;\n width: 1px;\n height: 20px;\n background: var(--notectl-border);\n margin: 0 4px;\n vertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px var(--notectl-shadow);\n overflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n outline: 2px solid var(--notectl-focus-ring);\n outline-offset: -1px;\n}\n\n/* Dropdown */\n.notectl-dropdown {\n min-width: 160px;\n padding: 4px 0;\n}\n\n.notectl-dropdown__item {\n display: flex;\n align-items: center;\n width: 100%;\n padding: 8px 12px;\n text-align: left;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n line-height: 1.4;\n font-family: inherit;\n white-space: nowrap;\n}\n\n.notectl-dropdown__item:hover,\n.notectl-dropdown__item:focus-visible {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-dropdown__item:focus-visible {\n outline: none;\n}\n\n.notectl-dropdown__item-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n font-weight: 600;\n color: var(--notectl-fg-muted);\n flex-shrink: 0;\n}\n\n.notectl-dropdown__item-label {\n flex: 1;\n}\n"), this.context = t2, this.popupController = new ie(() => this.getActiveElement()), this.tooltip = new se(() => this.popupController?.isOpen() ?? false), t2.registerService(ce, { refresh: () => this.updateButtonStates(t2.getState()), closePopup: () => this.popupController?.close() }), this.createToolbarElement();
|
|
2296
2304
|
}
|
|
2297
2305
|
onReady() {
|
|
2298
2306
|
this.renderItems();
|
|
@@ -2311,7 +2319,7 @@
|
|
|
2311
2319
|
if (!this.context) return;
|
|
2312
2320
|
this.toolbarElement && this.toolbarElement.remove(), this.buttons = [];
|
|
2313
2321
|
const t2 = this.context.getPluginContainer("top");
|
|
2314
|
-
this.toolbarElement = document.createElement("div"), this.toolbarElement.setAttribute("role", "toolbar"), this.toolbarElement.setAttribute("aria-label", "Formatting options"), this.toolbarElement.className = "notectl-toolbar", this.toolbarElement.addEventListener("keydown", (t3) => this.handleToolbarKeydown(t3)), t2.appendChild(this.toolbarElement);
|
|
2322
|
+
this.toolbarElement = document.createElement("div"), this.toolbarElement.setAttribute("role", "toolbar"), this.toolbarElement.setAttribute("aria-label", "Formatting options"), this.toolbarElement.setAttribute("data-notectl-no-print", ""), this.toolbarElement.className = "notectl-toolbar", this.toolbarElement.addEventListener("keydown", (t3) => this.handleToolbarKeydown(t3)), t2.appendChild(this.toolbarElement);
|
|
2315
2323
|
}
|
|
2316
2324
|
renderItems() {
|
|
2317
2325
|
if (this.context && this.toolbarElement) {
|
|
@@ -2322,14 +2330,14 @@
|
|
|
2322
2330
|
}
|
|
2323
2331
|
}
|
|
2324
2332
|
initRovingTabindex() {
|
|
2325
|
-
const t2 = this.buttons.map((t3) => t3.element), e2 =
|
|
2326
|
-
this.focusedIndex = e2 >= 0 ? e2 : 0,
|
|
2333
|
+
const t2 = this.buttons.map((t3) => t3.element), e2 = te(t2);
|
|
2334
|
+
this.focusedIndex = e2 >= 0 ? e2 : 0, ee(t2, this.focusedIndex);
|
|
2327
2335
|
}
|
|
2328
2336
|
setRovingFocus(t2) {
|
|
2329
2337
|
if (t2 < 0 || t2 >= this.buttons.length) return;
|
|
2330
2338
|
this.focusedIndex = t2;
|
|
2331
2339
|
const e2 = this.buttons.map((t3) => t3.element);
|
|
2332
|
-
|
|
2340
|
+
ee(e2, t2), e2[t2]?.focus();
|
|
2333
2341
|
}
|
|
2334
2342
|
getActiveElement() {
|
|
2335
2343
|
const t2 = this.toolbarElement?.getRootNode();
|
|
@@ -2344,19 +2352,19 @@
|
|
|
2344
2352
|
if (0 !== e2.length) switch (this.syncFocusedIndex(), t2.key) {
|
|
2345
2353
|
case "ArrowRight": {
|
|
2346
2354
|
t2.preventDefault();
|
|
2347
|
-
const n2 =
|
|
2355
|
+
const n2 = Qt(e2, this.focusedIndex, 1);
|
|
2348
2356
|
this.setRovingFocus(n2);
|
|
2349
2357
|
break;
|
|
2350
2358
|
}
|
|
2351
2359
|
case "ArrowLeft": {
|
|
2352
2360
|
t2.preventDefault();
|
|
2353
|
-
const n2 =
|
|
2361
|
+
const n2 = Qt(e2, this.focusedIndex, -1);
|
|
2354
2362
|
this.setRovingFocus(n2);
|
|
2355
2363
|
break;
|
|
2356
2364
|
}
|
|
2357
2365
|
case "Home": {
|
|
2358
2366
|
t2.preventDefault();
|
|
2359
|
-
const n2 =
|
|
2367
|
+
const n2 = te(e2);
|
|
2360
2368
|
n2 >= 0 && this.setRovingFocus(n2);
|
|
2361
2369
|
break;
|
|
2362
2370
|
}
|
|
@@ -2392,7 +2400,7 @@
|
|
|
2392
2400
|
n3.sort((t3, e4) => (t3.priority ?? 100) - (e4.priority ?? 100)), o2.push(...n3);
|
|
2393
2401
|
}
|
|
2394
2402
|
if (0 !== o2.length) {
|
|
2395
|
-
e2 || this.toolbarElement.appendChild(
|
|
2403
|
+
e2 || this.toolbarElement.appendChild(re()), e2 = false;
|
|
2396
2404
|
for (const t3 of o2) {
|
|
2397
2405
|
const e3 = this.createButton(t3);
|
|
2398
2406
|
this.toolbarElement.appendChild(e3.element), this.buttons.push(e3);
|
|
@@ -2410,7 +2418,7 @@
|
|
|
2410
2418
|
const n2 = e2[t3];
|
|
2411
2419
|
if (!n2) continue;
|
|
2412
2420
|
const o2 = this.createButton(n2);
|
|
2413
|
-
this.toolbarElement.appendChild(o2.element), this.buttons.push(o2), n2.separatorAfter && t3 < e2.length - 1 && this.toolbarElement.appendChild(
|
|
2421
|
+
this.toolbarElement.appendChild(o2.element), this.buttons.push(o2), n2.separatorAfter && t3 < e2.length - 1 && this.toolbarElement.appendChild(re());
|
|
2414
2422
|
}
|
|
2415
2423
|
else {
|
|
2416
2424
|
const t3 = /* @__PURE__ */ new Map();
|
|
@@ -2420,7 +2428,7 @@
|
|
|
2420
2428
|
}
|
|
2421
2429
|
let n2 = true;
|
|
2422
2430
|
for (const [, e3] of t3) {
|
|
2423
|
-
n2 || this.toolbarElement.appendChild(
|
|
2431
|
+
n2 || this.toolbarElement.appendChild(re()), n2 = false;
|
|
2424
2432
|
for (const t4 of e3) {
|
|
2425
2433
|
const e4 = this.createButton(t4);
|
|
2426
2434
|
this.toolbarElement.appendChild(e4.element), this.buttons.push(e4);
|
|
@@ -2443,20 +2451,20 @@
|
|
|
2443
2451
|
}
|
|
2444
2452
|
}
|
|
2445
2453
|
}
|
|
2446
|
-
function
|
|
2454
|
+
function ae(t2) {
|
|
2447
2455
|
return "undefined" != typeof navigator && /Mac|iPhone|iPad|iPod/.test(navigator.platform) ? t2.replace(/Mod/g, "⌘").replace(/Shift/g, "⇧").replace(/Alt/g, "⌥").replace(/-/g, "") : t2.replace(/Mod/g, "Ctrl").replace(/-/g, "+");
|
|
2448
2456
|
}
|
|
2449
|
-
const
|
|
2457
|
+
const de = { bold: true, italic: true, underline: true }, ue = [{ type: "bold", configKey: "bold", rank: 0, tag: "strong", label: "Bold", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/></svg>', keyBinding: "Mod-B", toHTMLString: (t2) => `<strong>${t2}</strong>`, parseHTML: [{ tag: "strong" }, { tag: "b" }], sanitize: { tags: ["strong", "b"] } }, { type: "italic", configKey: "italic", rank: 1, tag: "em", label: "Italic", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/></svg>', keyBinding: "Mod-I", toHTMLString: (t2) => `<em>${t2}</em>`, parseHTML: [{ tag: "em" }, { tag: "i" }], sanitize: { tags: ["em", "i"] } }, { type: "underline", configKey: "underline", rank: 2, tag: "u", label: "Underline", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/></svg>', keyBinding: "Mod-U", toHTMLString: (t2) => `<u>${t2}</u>`, parseHTML: [{ tag: "u" }], sanitize: { tags: ["u"] } }];
|
|
2450
2458
|
class he {
|
|
2451
2459
|
id = "text-formatting";
|
|
2452
2460
|
name = "Text Formatting";
|
|
2453
2461
|
priority = 20;
|
|
2454
2462
|
config;
|
|
2455
2463
|
constructor(t2) {
|
|
2456
|
-
this.config = { ...
|
|
2464
|
+
this.config = { ...de, ...t2 };
|
|
2457
2465
|
}
|
|
2458
2466
|
init(t2) {
|
|
2459
|
-
const e2 =
|
|
2467
|
+
const e2 = ue.filter((t3) => this.config[t3.configKey]), n2 = e2.filter((t3) => this.isToolbarVisible(t3.configKey)).at(-1);
|
|
2460
2468
|
for (const o2 of e2) {
|
|
2461
2469
|
const e3 = this.config.separatorAfter && o2 === n2;
|
|
2462
2470
|
this.registerMark(t2, o2, e3);
|
|
@@ -2464,35 +2472,35 @@
|
|
|
2464
2472
|
this.registerKeymaps(t2, e2), this.registerDisabledToolbarItems(t2);
|
|
2465
2473
|
}
|
|
2466
2474
|
registerMark(t2, e2, n2) {
|
|
2467
|
-
const o2 =
|
|
2475
|
+
const o2 = pe(e2.type), r2 = this.isToolbarVisible(e2.configKey);
|
|
2468
2476
|
t2.registerMarkSpec({ type: e2.type, rank: e2.rank, toDOM: () => document.createElement(e2.tag), toHTMLString: (t3, n3) => e2.toHTMLString(n3), parseHTML: e2.parseHTML, sanitize: e2.sanitize }), t2.registerCommand(o2, () => {
|
|
2469
2477
|
const n3 = yt(t2.getState(), e2.type);
|
|
2470
2478
|
return !!n3 && (t2.dispatch(n3), true);
|
|
2471
|
-
}), r2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, tooltip: `${e2.label} (${
|
|
2479
|
+
}), r2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, tooltip: `${e2.label} (${ae(e2.keyBinding)})`, command: o2, priority: 10 * e2.rank + 10, separatorAfter: n2, isActive: (t3) => zt(t3, e2.type) });
|
|
2472
2480
|
}
|
|
2473
2481
|
registerKeymaps(t2, e2) {
|
|
2474
2482
|
const n2 = {};
|
|
2475
2483
|
for (const o2 of e2) {
|
|
2476
|
-
const e3 =
|
|
2484
|
+
const e3 = pe(o2.type);
|
|
2477
2485
|
n2[o2.keyBinding] = () => t2.executeCommand(e3);
|
|
2478
2486
|
}
|
|
2479
2487
|
Object.keys(n2).length > 0 && t2.registerKeymap(n2);
|
|
2480
2488
|
}
|
|
2481
2489
|
registerDisabledToolbarItems(t2) {
|
|
2482
|
-
if (this.config.toolbar) for (const e2 of
|
|
2490
|
+
if (this.config.toolbar) for (const e2 of ue) {
|
|
2483
2491
|
const n2 = this.config[e2.configKey], o2 = this.config.toolbar[e2.configKey] ?? true;
|
|
2484
|
-
!n2 && o2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, command:
|
|
2492
|
+
!n2 && o2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, command: pe(e2.type), priority: 10 * e2.rank + 10, isEnabled: () => false });
|
|
2485
2493
|
}
|
|
2486
2494
|
}
|
|
2487
2495
|
isToolbarVisible(t2) {
|
|
2488
2496
|
return !this.config.toolbar || (this.config.toolbar[t2] ?? true);
|
|
2489
2497
|
}
|
|
2490
2498
|
}
|
|
2491
|
-
function
|
|
2499
|
+
function pe(t2) {
|
|
2492
2500
|
return `toggle${t2.charAt(0).toUpperCase()}${t2.slice(1)}`;
|
|
2493
2501
|
}
|
|
2494
|
-
const
|
|
2495
|
-
class
|
|
2502
|
+
const fe = { levels: [1, 2, 3, 4, 5, 6] }, ge = { 1: "h1", 2: "h2", 3: "h3", 4: "h4", 5: "h5", 6: "h6" }, me = { 1: "Heading 1", 2: "Heading 2", 3: "Heading 3", 4: "Heading 4", 5: "Heading 5", 6: "Heading 6" }, be = "Paragraph";
|
|
2503
|
+
class ke {
|
|
2496
2504
|
id = "heading";
|
|
2497
2505
|
name = "Heading";
|
|
2498
2506
|
priority = 30;
|
|
@@ -2500,7 +2508,7 @@
|
|
|
2500
2508
|
context = null;
|
|
2501
2509
|
comboLabel = null;
|
|
2502
2510
|
constructor(t2) {
|
|
2503
|
-
this.config = { ...
|
|
2511
|
+
this.config = { ...fe, ...t2 };
|
|
2504
2512
|
}
|
|
2505
2513
|
init(t2) {
|
|
2506
2514
|
t2.registerStyleSheet("\n/* Heading Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--heading {\n width: auto;\n min-width: 100px;\n max-width: 160px;\n padding: 0 8px;\n gap: 4px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n}\n\n.notectl-toolbar-btn--heading:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--heading.notectl-toolbar-btn--active {\n background: var(--notectl-bg);\n border-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--heading .notectl-toolbar-btn__icon {\n display: flex;\n align-items: center;\n gap: 4px;\n width: 100%;\n overflow: hidden;\n}\n\n.notectl-toolbar-btn--heading .notectl-toolbar-btn__icon svg {\n display: none;\n}\n\n.notectl-heading-select__label {\n flex: 1;\n font-size: 13px;\n font-weight: 500;\n color: var(--notectl-fg);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: left;\n line-height: 30px;\n}\n\n.notectl-heading-select__arrow {\n flex-shrink: 0;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n line-height: 30px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n min-width: 200px;\n max-height: 320px;\n overflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n padding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 7px 12px;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n text-align: left;\n white-space: nowrap;\n font-family: inherit;\n transition: background 0.1s;\n}\n\n.notectl-heading-picker__item:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-heading-picker__item--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__item--active:hover {\n background: var(--notectl-active-bg);\n}\n\n.notectl-heading-picker__check {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n flex-shrink: 0;\n font-size: 13px;\n font-weight: 600;\n color: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__label {\n flex: 1;\n}\n"), this.context = t2, this.registerNodeSpecs(t2), this.registerCommands(t2), this.registerKeymaps(t2), this.registerInputRules(t2), this.registerPickerEntries(t2), this.registerToolbarItem(t2);
|
|
@@ -2520,9 +2528,9 @@
|
|
|
2520
2528
|
return e2.classList.add("notectl-subtitle"), e2;
|
|
2521
2529
|
}, toHTML: (t3, e2) => `<h2>${e2 || "<br>"}</h2>`, sanitize: { tags: ["h2"] } }), t2.registerNodeSpec({ type: "heading", group: "block", content: { allow: ["text"] }, excludeMarks: ["fontSize"], attrs: { level: { default: 1 } }, toDOM(t3) {
|
|
2522
2530
|
const e2 = t3.attrs?.level ?? 1;
|
|
2523
|
-
return F(
|
|
2531
|
+
return F(ge[e2] ?? "h1", t3.id);
|
|
2524
2532
|
}, toHTML(t3, e2) {
|
|
2525
|
-
const n2 = t3.attrs?.level ?? 1, o2 =
|
|
2533
|
+
const n2 = t3.attrs?.level ?? 1, o2 = ge[n2] ?? "h1";
|
|
2526
2534
|
return `<${o2}>${e2 || "<br>"}</${o2}>`;
|
|
2527
2535
|
}, parseHTML: [{ tag: "h1", getAttrs: () => ({ level: 1 }) }, { tag: "h2", getAttrs: () => ({ level: 2 }) }, { tag: "h3", getAttrs: () => ({ level: 3 }) }, { tag: "h4", getAttrs: () => ({ level: 4 }) }, { tag: "h5", getAttrs: () => ({ level: 5 }) }, { tag: "h6", getAttrs: () => ({ level: 6 }) }], sanitize: { tags: ["h1", "h2", "h3", "h4", "h5", "h6"] } });
|
|
2528
2536
|
}
|
|
@@ -2544,12 +2552,12 @@
|
|
|
2544
2552
|
if (C(i2)) return null;
|
|
2545
2553
|
if (!_(i2)) return null;
|
|
2546
2554
|
const s2 = t3.getBlock(i2.anchor.blockId);
|
|
2547
|
-
return s2 && "paragraph" === s2.type ? t3.transaction("input").deleteTextAt(i2.anchor.blockId, o3, o3 + e2 + 1).setBlockType(i2.anchor.blockId, "heading", { level: e2 }).setSelection(
|
|
2555
|
+
return s2 && "paragraph" === s2.type ? t3.transaction("input").deleteTextAt(i2.anchor.blockId, o3, o3 + e2 + 1).setBlockType(i2.anchor.blockId, "heading", { level: e2 }).setSelection(A(i2.anchor.blockId, 0)).build() : null;
|
|
2548
2556
|
} });
|
|
2549
2557
|
}
|
|
2550
2558
|
}
|
|
2551
2559
|
registerPickerEntries(t2) {
|
|
2552
|
-
t2.registerBlockTypePickerEntry({ id: "paragraph", label:
|
|
2560
|
+
t2.registerBlockTypePickerEntry({ id: "paragraph", label: be, command: "setParagraph", priority: 10, isActive: (t3) => {
|
|
2553
2561
|
if (C(t3.selection)) return false;
|
|
2554
2562
|
const e2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
2555
2563
|
return "paragraph" === e2?.type;
|
|
@@ -2562,14 +2570,14 @@
|
|
|
2562
2570
|
const e2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
2563
2571
|
return "subtitle" === e2?.type;
|
|
2564
2572
|
} });
|
|
2565
|
-
for (const e2 of this.config.levels) t2.registerBlockTypePickerEntry({ id: `heading-${e2}`, label:
|
|
2573
|
+
for (const e2 of this.config.levels) t2.registerBlockTypePickerEntry({ id: `heading-${e2}`, label: me[e2], command: `setHeading${e2}`, priority: 100 + e2, style: { fontSize: 1.4 - 0.1 * e2 + "em", fontWeight: "600" }, isActive: (t3) => {
|
|
2566
2574
|
if (C(t3.selection)) return false;
|
|
2567
2575
|
const n2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
2568
2576
|
return "heading" === n2?.type && n2.attrs?.level === e2;
|
|
2569
2577
|
} });
|
|
2570
2578
|
}
|
|
2571
2579
|
registerToolbarItem(t2) {
|
|
2572
|
-
const e2 = `<span class="notectl-heading-select__label" data-heading-label>${
|
|
2580
|
+
const e2 = `<span class="notectl-heading-select__label" data-heading-label>${be}</span><span class="notectl-heading-select__arrow">▾</span>`;
|
|
2573
2581
|
t2.registerToolbarItem({ id: "heading", group: "block", icon: e2, label: "Block Type", tooltip: "Block Type", command: "setParagraph", priority: 50, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, e3) => {
|
|
2574
2582
|
this.renderHeadingPopup(t3, e3);
|
|
2575
2583
|
}, isActive: (e3) => t2.getSchemaRegistry().getBlockTypePickerEntries().some((t3) => "paragraph" !== t3.id && t3.isActive(e3)) });
|
|
@@ -2583,13 +2591,13 @@
|
|
|
2583
2591
|
this.comboLabel.textContent = this.getActiveLabel(t2);
|
|
2584
2592
|
}
|
|
2585
2593
|
getActiveLabel(t2) {
|
|
2586
|
-
if (C(t2.selection)) return
|
|
2594
|
+
if (C(t2.selection)) return be;
|
|
2587
2595
|
const e2 = this.context?.getSchemaRegistry().getBlockTypePickerEntries() ?? [];
|
|
2588
2596
|
for (const n2 of e2) if (n2.isActive(t2)) return n2.label;
|
|
2589
|
-
return
|
|
2597
|
+
return be;
|
|
2590
2598
|
}
|
|
2591
2599
|
dismissPopup() {
|
|
2592
|
-
const t2 = this.context?.getService(
|
|
2600
|
+
const t2 = this.context?.getService(ce);
|
|
2593
2601
|
t2?.closePopup();
|
|
2594
2602
|
}
|
|
2595
2603
|
renderHeadingPopup(t2, e2) {
|
|
@@ -2621,14 +2629,14 @@
|
|
|
2621
2629
|
if (C(n2)) return false;
|
|
2622
2630
|
if (!_(n2)) return false;
|
|
2623
2631
|
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
2624
|
-
if (!o2 || !
|
|
2632
|
+
if (!o2 || !ke.HEADING_TYPES.has(o2.type)) return false;
|
|
2625
2633
|
if ("" === g(o2)) {
|
|
2626
2634
|
const o3 = e2.transaction("input").setBlockType(n2.anchor.blockId, "paragraph").setSelection(n2).build();
|
|
2627
2635
|
return t2.dispatch(o3), true;
|
|
2628
2636
|
}
|
|
2629
2637
|
const r2 = m(o2);
|
|
2630
2638
|
if (n2.anchor.offset >= r2) {
|
|
2631
|
-
const o3 = d(), r3 = e2.transaction("input").splitBlock(n2.anchor.blockId, n2.anchor.offset, o3).setBlockType(o3, "paragraph").setSelection(
|
|
2639
|
+
const o3 = d(), r3 = e2.transaction("input").splitBlock(n2.anchor.blockId, n2.anchor.offset, o3).setBlockType(o3, "paragraph").setSelection(A(o3, 0)).build();
|
|
2632
2640
|
return t2.dispatch(r3), true;
|
|
2633
2641
|
}
|
|
2634
2642
|
return false;
|
|
@@ -2670,21 +2678,21 @@
|
|
|
2670
2678
|
r2.length !== e2.storedMarks.length && t2.setStoredMarks(r2.length > 0 ? r2 : null, e2.storedMarks);
|
|
2671
2679
|
}
|
|
2672
2680
|
}
|
|
2673
|
-
const
|
|
2674
|
-
const
|
|
2675
|
-
function
|
|
2681
|
+
const ye = { openInNewTab: true }, ve = { types: ["bullet", "ordered", "checklist"], maxIndent: 4 }, xe = [{ 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: "[ ] " }], we = {}, Se = {}, Ie = "\n/* Color Picker Popup */\n.notectl-color-picker {\n padding: 8px;\n min-width: 240px;\n}\n\n.notectl-color-picker__default {\n display: block;\n width: 100%;\n padding: 6px 12px;\n margin-bottom: 8px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n cursor: pointer;\n font-size: 13px;\n color: var(--notectl-fg);\n text-align: center;\n}\n\n.notectl-color-picker__default:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-color-picker__grid {\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n gap: 3px;\n}\n\n.notectl-color-picker__swatch {\n width: 22px;\n height: 22px;\n border: 1px solid transparent;\n border-radius: 3px;\n padding: 0;\n cursor: pointer;\n transition: transform 0.1s;\n}\n\n.notectl-color-picker__swatch:hover,\n.notectl-color-picker__swatch:focus-visible {\n transform: scale(1.25);\n z-index: 1;\n}\n\n.notectl-color-picker__swatch:focus-visible {\n outline: 2px solid var(--notectl-focus-ring);\n outline-offset: 1px;\n}\n\n.notectl-color-picker__swatch--active {\n border: 2px solid var(--notectl-primary-fg);\n border-radius: 3px;\n}\n\n.notectl-toolbar-btn--textColor .notectl-toolbar-btn__color-indicator {\n display: block;\n width: 16px;\n height: 3px;\n margin-top: 1px;\n border-radius: 1px;\n}\n", Ce = {}, Te = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
2682
|
+
const Be = ["#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"], Ee = {};
|
|
2683
|
+
function Me(t2) {
|
|
2676
2684
|
const e2 = t2.selection;
|
|
2677
2685
|
return C(e2) ? -1 : t2.doc.children.findIndex((t3) => t3.id === e2.anchor.blockId);
|
|
2678
2686
|
}
|
|
2679
|
-
const
|
|
2680
|
-
class
|
|
2687
|
+
const Ae = { alignments: ["left", "center", "right", "justify"], alignableTypes: ["paragraph", "heading", "title", "subtitle", "table_cell", "image"], defaults: { image: "center" } }, _e = { left: "Align Left", center: "Align Center", right: "Align Right", justify: "Justify" }, Le = { left: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"/></svg>', center: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"/></svg>', right: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"/></svg>', justify: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zM3 3v2h18V3H3z"/></svg>' };
|
|
2688
|
+
class Ne {
|
|
2681
2689
|
id = "alignment";
|
|
2682
2690
|
name = "Alignment";
|
|
2683
2691
|
priority = 90;
|
|
2684
2692
|
config;
|
|
2685
2693
|
alignableTypes;
|
|
2686
2694
|
constructor(t2) {
|
|
2687
|
-
this.config = { ...
|
|
2695
|
+
this.config = { ...Ae, ...t2, defaults: { ...Ae.defaults, ...t2?.defaults } };
|
|
2688
2696
|
}
|
|
2689
2697
|
init(t2) {
|
|
2690
2698
|
this.alignableTypes = new Set(this.config.alignableTypes), this.patchNodeSpecs(t2), this.registerCommands(t2), this.registerKeymaps(t2), this.registerToolbarItem(t2), this.registerMiddleware(t2);
|
|
@@ -2698,20 +2706,20 @@
|
|
|
2698
2706
|
const o2 = n2.toDOM, r2 = this.config.defaults[t3] ?? "left";
|
|
2699
2707
|
e2.removeNodeSpec(t3), e2.registerNodeSpec({ ...n2, attrs: { ...n2.attrs, align: { default: r2 } }, toDOM(t4) {
|
|
2700
2708
|
const e3 = o2.call(n2, t4);
|
|
2701
|
-
return
|
|
2709
|
+
return ze(e3, t4), e3;
|
|
2702
2710
|
} });
|
|
2703
2711
|
}
|
|
2704
2712
|
}
|
|
2705
2713
|
registerCommands(t2) {
|
|
2706
|
-
for (const e2 of this.config.alignments) t2.registerCommand(`align${
|
|
2714
|
+
for (const e2 of this.config.alignments) t2.registerCommand(`align${Pe(e2)}`, () => this.setAlignment(t2, e2));
|
|
2707
2715
|
}
|
|
2708
2716
|
registerKeymaps(t2) {
|
|
2709
2717
|
const e2 = {};
|
|
2710
2718
|
this.config.alignments.includes("left") && (e2["Mod-Shift-L"] = () => t2.executeCommand("alignLeft")), this.config.alignments.includes("center") && (e2["Mod-Shift-E"] = () => t2.executeCommand("alignCenter")), this.config.alignments.includes("right") && (e2["Mod-Shift-R"] = () => t2.executeCommand("alignRight")), this.config.alignments.includes("justify") && (e2["Mod-Shift-J"] = () => t2.executeCommand("alignJustify")), Object.keys(e2).length > 0 && t2.registerKeymap(e2);
|
|
2711
2719
|
}
|
|
2712
2720
|
registerToolbarItem(t2) {
|
|
2713
|
-
const e2 = this.config.alignments.map((t3) => ({ label:
|
|
2714
|
-
t2.registerToolbarItem({ id: "alignment", group: "block", icon:
|
|
2721
|
+
const e2 = this.config.alignments.map((t3) => ({ label: _e[t3], command: `align${Pe(t3)}`, icon: Le[t3] }));
|
|
2722
|
+
t2.registerToolbarItem({ id: "alignment", group: "block", icon: Le.left, label: "Alignment", tooltip: "Alignment", command: "alignLeft", priority: 60, popupType: "dropdown", popupConfig: { items: e2 }, separatorAfter: this.config.separatorAfter, isActive: (t3) => this.isNonDefaultAlignment(t3), isEnabled: (t3) => this.isAlignable(t3) });
|
|
2715
2723
|
}
|
|
2716
2724
|
registerMiddleware(t2) {
|
|
2717
2725
|
t2.registerMiddleware((t3, e2, n2) => {
|
|
@@ -2738,7 +2746,7 @@
|
|
|
2738
2746
|
if (!o2 || !this.alignableTypes.has(o2.type)) return false;
|
|
2739
2747
|
const r2 = this.getSelectedBlockId(n2);
|
|
2740
2748
|
if (!r2) return false;
|
|
2741
|
-
const i2 =
|
|
2749
|
+
const i2 = U(n2.doc, r2);
|
|
2742
2750
|
if (!i2) return false;
|
|
2743
2751
|
const s2 = { ...o2.attrs, align: e2 }, c2 = n2.transaction("command").setNodeAttr(i2, s2).setSelection(n2.selection).build();
|
|
2744
2752
|
return t2.dispatch(c2), true;
|
|
@@ -2754,19 +2762,91 @@
|
|
|
2754
2762
|
return null != e2 && this.alignableTypes.has(e2.type);
|
|
2755
2763
|
}
|
|
2756
2764
|
}
|
|
2757
|
-
function
|
|
2765
|
+
function ze(t2, e2) {
|
|
2758
2766
|
const n2 = e2.attrs?.align;
|
|
2759
2767
|
"string" == typeof n2 && "left" !== n2 && (t2.style.textAlign = n2);
|
|
2760
2768
|
}
|
|
2761
|
-
function
|
|
2769
|
+
function Pe(t2) {
|
|
2762
2770
|
return t2.charAt(0).toUpperCase() + t2.slice(1);
|
|
2763
2771
|
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2772
|
+
function Re(t2) {
|
|
2773
|
+
const e2 = t2.selection;
|
|
2774
|
+
if (C(e2)) return null;
|
|
2775
|
+
if (_(e2) && t2.storedMarks) return Ke(t2.storedMarks);
|
|
2776
|
+
const n2 = t2.getBlock(e2.anchor.blockId);
|
|
2777
|
+
return n2 ? Ke(b(n2, e2.anchor.offset)) : null;
|
|
2778
|
+
}
|
|
2779
|
+
function He(t2, e2) {
|
|
2780
|
+
const n2 = Re(t2);
|
|
2781
|
+
if (!n2) return e2;
|
|
2782
|
+
const o2 = Number.parseInt(n2, 10);
|
|
2783
|
+
return Number.isNaN(o2) ? e2 : o2;
|
|
2784
|
+
}
|
|
2785
|
+
function De(t2, e2, n2) {
|
|
2786
|
+
const o2 = e2.selection;
|
|
2787
|
+
if (C(o2)) return false;
|
|
2788
|
+
if (_(o2)) {
|
|
2789
|
+
const r3 = e2.getBlock(o2.anchor.blockId);
|
|
2790
|
+
if (!r3) return false;
|
|
2791
|
+
const i3 = [...(e2.storedMarks ?? b(r3, o2.anchor.offset)).filter((t3) => "fontSize" !== t3.type), { type: "fontSize", attrs: { size: n2 } }], s3 = e2.transaction("command").setStoredMarks(i3, e2.storedMarks).setSelection(o2).build();
|
|
2792
|
+
return t2.dispatch(s3), true;
|
|
2793
|
+
}
|
|
2794
|
+
const r2 = N(o2, e2.getBlockOrder()), i2 = e2.transaction("command"), s2 = { type: "fontSize", attrs: { size: n2 } };
|
|
2795
|
+
return kt(e2, r2, (t3, e3, n3) => {
|
|
2796
|
+
i2.removeMark(t3, e3, n3, { type: "fontSize" }), i2.addMark(t3, e3, n3, s2);
|
|
2797
|
+
}), i2.setSelection(o2), t2.dispatch(i2.build()), true;
|
|
2798
|
+
}
|
|
2799
|
+
function Oe(t2, e2) {
|
|
2800
|
+
const n2 = e2.selection;
|
|
2801
|
+
if (C(n2)) return false;
|
|
2802
|
+
if (_(n2)) {
|
|
2803
|
+
const o3 = e2.getBlock(n2.anchor.blockId);
|
|
2804
|
+
if (!o3) return false;
|
|
2805
|
+
const r3 = e2.storedMarks ?? b(o3, n2.anchor.offset);
|
|
2806
|
+
if (!y(r3, "fontSize")) return false;
|
|
2807
|
+
const i2 = r3.filter((t3) => "fontSize" !== t3.type), s2 = e2.transaction("command").setStoredMarks(i2, e2.storedMarks).setSelection(n2).build();
|
|
2808
|
+
return t2.dispatch(s2), true;
|
|
2809
|
+
}
|
|
2810
|
+
const o2 = N(n2, e2.getBlockOrder()), r2 = e2.transaction("command");
|
|
2811
|
+
return kt(e2, o2, (t3, e3, n3) => {
|
|
2812
|
+
r2.removeMark(t3, e3, n3, { type: "fontSize" });
|
|
2813
|
+
}), r2.setSelection(n2), t2.dispatch(r2.build()), true;
|
|
2814
|
+
}
|
|
2815
|
+
function $e(t2, e2, n2, o2, r2) {
|
|
2816
|
+
const i2 = (function(t3, e3, n3) {
|
|
2817
|
+
if ("up" === e3) {
|
|
2818
|
+
for (const e4 of n3) if (e4 > t3) return e4;
|
|
2819
|
+
return null;
|
|
2820
|
+
}
|
|
2821
|
+
for (let e4 = n3.length - 1; e4 >= 0; e4--) {
|
|
2822
|
+
const o3 = n3[e4];
|
|
2823
|
+
if (void 0 !== o3 && o3 < t3) return o3;
|
|
2824
|
+
}
|
|
2825
|
+
return null;
|
|
2826
|
+
})(He(e2, r2), n2, o2);
|
|
2827
|
+
return null !== i2 && (i2 === r2 ? Oe(t2, e2) : De(t2, e2, `${i2}px`));
|
|
2768
2828
|
}
|
|
2769
|
-
function
|
|
2829
|
+
function Fe(t2, e2, n2) {
|
|
2830
|
+
e2 === n2 ? t2.executeCommand("removeFontSize") : De(t2, t2.getState(), `${e2}px`);
|
|
2831
|
+
}
|
|
2832
|
+
function Ke(t2) {
|
|
2833
|
+
const e2 = t2.find((t3) => "fontSize" === t3.type);
|
|
2834
|
+
return e2 && $(e2, "fontSize") ? e2.attrs.size ?? null : null;
|
|
2835
|
+
}
|
|
2836
|
+
function Ve(t2, e2) {
|
|
2837
|
+
const n2 = document.createElement("button");
|
|
2838
|
+
n2.type = "button", n2.id = `notectl-font-size-option-${t2}`, n2.className = "notectl-font-size-picker__item", n2.setAttribute("role", "option"), n2.setAttribute("aria-selected", String(e2)), e2 && n2.classList.add("notectl-font-size-picker__item--active");
|
|
2839
|
+
const o2 = document.createElement("span");
|
|
2840
|
+
o2.className = "notectl-font-size-picker__check", o2.textContent = e2 ? "✓" : "", n2.appendChild(o2);
|
|
2841
|
+
const r2 = document.createElement("span");
|
|
2842
|
+
return r2.className = "notectl-font-size-picker__label", r2.textContent = String(t2), n2.appendChild(r2), n2;
|
|
2843
|
+
}
|
|
2844
|
+
const je = [8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96];
|
|
2845
|
+
function qe() {
|
|
2846
|
+
const t2 = h("paragraph", [p("")], d());
|
|
2847
|
+
return h("table_cell", [t2], d());
|
|
2848
|
+
}
|
|
2849
|
+
function Ue(t2, e2) {
|
|
2770
2850
|
const n2 = t2.getNodePath(e2);
|
|
2771
2851
|
if (!n2) return null;
|
|
2772
2852
|
let o2 = null, r2 = null, i2 = null, s2 = null;
|
|
@@ -2776,16 +2856,16 @@
|
|
|
2776
2856
|
}
|
|
2777
2857
|
const c2 = t2.getBlock(e2);
|
|
2778
2858
|
if ("table_cell" === c2?.type && (s2 = e2), !(o2 && r2 && s2 && i2)) return null;
|
|
2779
|
-
const l2 = t2.doc.children.findIndex((t3) => t3.id === o2), d2 = a(r2),
|
|
2780
|
-
if (-1 ===
|
|
2781
|
-
const
|
|
2782
|
-
if (!
|
|
2783
|
-
const p2 = a(
|
|
2859
|
+
const l2 = t2.doc.children.findIndex((t3) => t3.id === o2), d2 = a(r2), u2 = d2.findIndex((t3) => t3.id === i2);
|
|
2860
|
+
if (-1 === u2) return null;
|
|
2861
|
+
const h2 = d2[u2];
|
|
2862
|
+
if (!h2) return null;
|
|
2863
|
+
const p2 = a(h2), f2 = p2.findIndex((t3) => t3.id === s2);
|
|
2784
2864
|
if (-1 === f2) return null;
|
|
2785
2865
|
const g2 = p2.length, m2 = d2.length;
|
|
2786
|
-
return { tableId: o2, tableIndex: l2, rowId: i2, rowIndex:
|
|
2866
|
+
return { tableId: o2, tableIndex: l2, rowId: i2, rowIndex: u2, cellId: s2, colIndex: f2, totalRows: m2, totalCols: g2 };
|
|
2787
2867
|
}
|
|
2788
|
-
function
|
|
2868
|
+
function We(t2, e2, n2, o2) {
|
|
2789
2869
|
const r2 = t2.getBlock(e2);
|
|
2790
2870
|
if (!r2) return null;
|
|
2791
2871
|
const i2 = a(r2)[n2];
|
|
@@ -2793,7 +2873,7 @@
|
|
|
2793
2873
|
const s2 = a(i2)[o2];
|
|
2794
2874
|
return s2?.id ?? null;
|
|
2795
2875
|
}
|
|
2796
|
-
function
|
|
2876
|
+
function Ge(t2, e2) {
|
|
2797
2877
|
const n2 = t2.getBlock(e2);
|
|
2798
2878
|
if (!n2) return e2;
|
|
2799
2879
|
const o2 = a(n2)[0];
|
|
@@ -2805,7 +2885,7 @@
|
|
|
2805
2885
|
r2 = t3;
|
|
2806
2886
|
}
|
|
2807
2887
|
}
|
|
2808
|
-
function
|
|
2888
|
+
function Xe(t2, e2) {
|
|
2809
2889
|
const n2 = t2.getBlock(e2);
|
|
2810
2890
|
if (!n2) return e2;
|
|
2811
2891
|
const o2 = a(n2), r2 = o2[o2.length - 1];
|
|
@@ -2817,7 +2897,7 @@
|
|
|
2817
2897
|
i2 = e3;
|
|
2818
2898
|
}
|
|
2819
2899
|
}
|
|
2820
|
-
function
|
|
2900
|
+
function Ye(t2, e2) {
|
|
2821
2901
|
const n2 = t2.getNodePath(e2);
|
|
2822
2902
|
if (!n2) return false;
|
|
2823
2903
|
for (const e3 of n2) {
|
|
@@ -2826,65 +2906,65 @@
|
|
|
2826
2906
|
}
|
|
2827
2907
|
return false;
|
|
2828
2908
|
}
|
|
2829
|
-
function
|
|
2909
|
+
function Je(t2, e2, n2) {
|
|
2830
2910
|
const o2 = t2.getBlock(e2);
|
|
2831
2911
|
if (!o2) return null;
|
|
2832
2912
|
const r2 = a(o2), i2 = r2[0] ? a(r2[0]).length : 0;
|
|
2833
2913
|
if (0 === i2) return null;
|
|
2834
2914
|
const s2 = (function(t3) {
|
|
2835
2915
|
const e3 = [];
|
|
2836
|
-
for (let n3 = 0; n3 < t3; n3++) e3.push(
|
|
2837
|
-
return
|
|
2838
|
-
})(i2), c2 = t2.transaction("command").insertNode([e2], n2, s2), l2 = a(s2)[0],
|
|
2839
|
-
return
|
|
2916
|
+
for (let n3 = 0; n3 < t3; n3++) e3.push(qe());
|
|
2917
|
+
return h("table_row", e3, d());
|
|
2918
|
+
})(i2), c2 = t2.transaction("command").insertNode([e2], n2, s2), l2 = a(s2)[0], u2 = l2 ? a(l2)[0] : void 0;
|
|
2919
|
+
return u2 ? c2.setSelection(A(u2.id, 0)) : l2 && c2.setSelection(A(l2.id, 0)), c2.build();
|
|
2840
2920
|
}
|
|
2841
|
-
function
|
|
2921
|
+
function Ze(t2, e2, n2) {
|
|
2842
2922
|
const o2 = t2.getBlock(e2);
|
|
2843
2923
|
if (!o2) return null;
|
|
2844
2924
|
const r2 = a(o2), i2 = t2.transaction("command");
|
|
2845
2925
|
for (const t3 of r2) {
|
|
2846
|
-
const o3 =
|
|
2926
|
+
const o3 = qe();
|
|
2847
2927
|
i2.insertNode([e2, t3.id], n2, o3);
|
|
2848
2928
|
}
|
|
2849
2929
|
return i2.setSelection(t2.selection), i2.build();
|
|
2850
2930
|
}
|
|
2851
|
-
function
|
|
2931
|
+
function Qe(t2, e2, n2, o2 = 0) {
|
|
2852
2932
|
const r2 = t2.getBlock(e2);
|
|
2853
2933
|
if (!r2) return null;
|
|
2854
|
-
if (a(r2).length <= 1) return
|
|
2855
|
-
const i2 = t2.transaction("command").removeNode([e2], n2), s2 =
|
|
2934
|
+
if (a(r2).length <= 1) return en(t2, e2);
|
|
2935
|
+
const i2 = t2.transaction("command").removeNode([e2], n2), s2 = We(t2, e2, n2 > 0 ? n2 - 1 : 1, o2);
|
|
2856
2936
|
if (s2) {
|
|
2857
|
-
const e3 =
|
|
2858
|
-
i2.setSelection(
|
|
2937
|
+
const e3 = Ge(t2, s2);
|
|
2938
|
+
i2.setSelection(A(e3, 0));
|
|
2859
2939
|
}
|
|
2860
2940
|
return i2.build();
|
|
2861
2941
|
}
|
|
2862
|
-
function
|
|
2942
|
+
function tn(t2, e2, n2, o2 = 0) {
|
|
2863
2943
|
const r2 = t2.getBlock(e2);
|
|
2864
2944
|
if (!r2) return null;
|
|
2865
2945
|
const i2 = a(r2);
|
|
2866
|
-
if ((i2[0] ? a(i2[0]).length : 0) <= 1) return
|
|
2946
|
+
if ((i2[0] ? a(i2[0]).length : 0) <= 1) return en(t2, e2);
|
|
2867
2947
|
const s2 = t2.transaction("command");
|
|
2868
2948
|
for (let t3 = i2.length - 1; t3 >= 0; t3--) {
|
|
2869
2949
|
const o3 = i2[t3];
|
|
2870
2950
|
o3 && s2.removeNode([e2, o3.id], n2);
|
|
2871
2951
|
}
|
|
2872
|
-
const c2 =
|
|
2952
|
+
const c2 = We(t2, e2, o2, n2 > 0 ? n2 - 1 : 1);
|
|
2873
2953
|
if (c2) {
|
|
2874
|
-
const e3 =
|
|
2875
|
-
s2.setSelection(
|
|
2954
|
+
const e3 = Ge(t2, c2);
|
|
2955
|
+
s2.setSelection(A(e3, 0));
|
|
2876
2956
|
}
|
|
2877
2957
|
return s2.build();
|
|
2878
2958
|
}
|
|
2879
|
-
function
|
|
2959
|
+
function en(t2, e2) {
|
|
2880
2960
|
const n2 = t2.doc.children.findIndex((t3) => t3.id === e2);
|
|
2881
2961
|
if (-1 === n2) return null;
|
|
2882
2962
|
const o2 = t2.transaction("command").removeNode([], n2), r2 = t2.doc.children[n2 + 1];
|
|
2883
|
-
if (r2) return o2.setSelection(
|
|
2963
|
+
if (r2) return o2.setSelection(A(r2.id, 0)), o2.build();
|
|
2884
2964
|
const i2 = t2.doc.children[n2 - 1];
|
|
2885
|
-
return i2 && o2.setSelection(
|
|
2965
|
+
return i2 && o2.setSelection(A(i2.id, 0)), o2.build();
|
|
2886
2966
|
}
|
|
2887
|
-
function
|
|
2967
|
+
function nn(t2, e2, n2) {
|
|
2888
2968
|
const o2 = t2.getState(), r2 = o2.selection;
|
|
2889
2969
|
if (C(r2)) return false;
|
|
2890
2970
|
const i2 = r2.anchor.blockId;
|
|
@@ -2907,54 +2987,54 @@
|
|
|
2907
2987
|
const n3 = d(), o3 = [];
|
|
2908
2988
|
for (let n4 = 0; n4 < t3; n4++) {
|
|
2909
2989
|
const t4 = [];
|
|
2910
|
-
for (let n5 = 0; n5 < e3; n5++) t4.push(
|
|
2911
|
-
o3.push(
|
|
2990
|
+
for (let n5 = 0; n5 < e3; n5++) t4.push(qe());
|
|
2991
|
+
o3.push(h(H("table_row"), t4, d()));
|
|
2912
2992
|
}
|
|
2913
|
-
return
|
|
2914
|
-
})(e2, n2), l2 =
|
|
2915
|
-
return m2 ? p2.setSelection(
|
|
2993
|
+
return h("table", o3, n3);
|
|
2994
|
+
})(e2, n2), l2 = h("paragraph"), u2 = s2 + 1, p2 = o2.transaction("command").insertNode([], u2, c2).insertNode([], u2 + 1, l2), f2 = a(c2)[0], g2 = f2 ? a(f2)[0] : void 0, m2 = g2 ? a(g2)[0] : void 0;
|
|
2995
|
+
return m2 ? p2.setSelection(A(m2.id, 0)) : g2 && p2.setSelection(A(g2.id, 0)), t2.dispatch(p2.build()), true;
|
|
2916
2996
|
}
|
|
2917
|
-
function
|
|
2997
|
+
function on(t2) {
|
|
2918
2998
|
const e2 = t2.getState();
|
|
2919
2999
|
if (C(e2.selection)) return false;
|
|
2920
|
-
const n2 =
|
|
3000
|
+
const n2 = Ue(e2, e2.selection.anchor.blockId);
|
|
2921
3001
|
if (!n2) return false;
|
|
2922
|
-
const o2 =
|
|
3002
|
+
const o2 = Je(e2, n2.tableId, n2.rowIndex + 1);
|
|
2923
3003
|
return !!o2 && (t2.dispatch(o2), true);
|
|
2924
3004
|
}
|
|
2925
|
-
function
|
|
3005
|
+
function rn(t2, e2) {
|
|
2926
3006
|
const n2 = t2.getState();
|
|
2927
3007
|
if (C(n2.selection)) return false;
|
|
2928
|
-
const o2 =
|
|
3008
|
+
const o2 = Ue(n2, n2.selection.anchor.blockId);
|
|
2929
3009
|
if (!o2) return false;
|
|
2930
|
-
const r2 = "left" === e2 ? o2.colIndex : o2.colIndex + 1, i2 =
|
|
3010
|
+
const r2 = "left" === e2 ? o2.colIndex : o2.colIndex + 1, i2 = Ze(n2, o2.tableId, r2);
|
|
2931
3011
|
return !!i2 && (t2.dispatch(i2), true);
|
|
2932
3012
|
}
|
|
2933
|
-
function
|
|
2934
|
-
t2.registerCommand("insertTable", () =>
|
|
3013
|
+
function sn(t2) {
|
|
3014
|
+
t2.registerCommand("insertTable", () => nn(t2, 3, 3)), t2.registerCommand("addRowAbove", () => (function(t3) {
|
|
2935
3015
|
const e2 = t3.getState();
|
|
2936
3016
|
if (C(e2.selection)) return false;
|
|
2937
|
-
const n2 =
|
|
3017
|
+
const n2 = Ue(e2, e2.selection.anchor.blockId);
|
|
2938
3018
|
if (!n2) return false;
|
|
2939
|
-
const o2 =
|
|
3019
|
+
const o2 = Je(e2, n2.tableId, n2.rowIndex);
|
|
2940
3020
|
return !!o2 && (t3.dispatch(o2), true);
|
|
2941
|
-
})(t2)), t2.registerCommand("addRowBelow", () =>
|
|
2942
|
-
return
|
|
3021
|
+
})(t2)), t2.registerCommand("addRowBelow", () => on(t2)), t2.registerCommand("addColumnLeft", () => (function(t3) {
|
|
3022
|
+
return rn(t3, "left");
|
|
2943
3023
|
})(t2)), t2.registerCommand("addColumnRight", () => (function(t3) {
|
|
2944
|
-
return
|
|
3024
|
+
return rn(t3, "right");
|
|
2945
3025
|
})(t2)), t2.registerCommand("deleteRow", () => (function(t3) {
|
|
2946
3026
|
const e2 = t3.getState();
|
|
2947
3027
|
if (C(e2.selection)) return false;
|
|
2948
|
-
const n2 =
|
|
3028
|
+
const n2 = Ue(e2, e2.selection.anchor.blockId);
|
|
2949
3029
|
if (!n2) return false;
|
|
2950
|
-
const o2 =
|
|
3030
|
+
const o2 = Qe(e2, n2.tableId, n2.rowIndex, n2.colIndex);
|
|
2951
3031
|
return !!o2 && (t3.dispatch(o2), true);
|
|
2952
3032
|
})(t2)), t2.registerCommand("deleteColumn", () => (function(t3) {
|
|
2953
3033
|
const e2 = t3.getState();
|
|
2954
3034
|
if (C(e2.selection)) return false;
|
|
2955
|
-
const n2 =
|
|
3035
|
+
const n2 = Ue(e2, e2.selection.anchor.blockId);
|
|
2956
3036
|
if (!n2) return false;
|
|
2957
|
-
const o2 =
|
|
3037
|
+
const o2 = tn(e2, n2.tableId, n2.colIndex, n2.rowIndex);
|
|
2958
3038
|
return !!o2 && (t3.dispatch(o2), true);
|
|
2959
3039
|
})(t2)), t2.registerCommand("selectTable", () => (function(t3) {
|
|
2960
3040
|
const e2 = t3.getState(), n2 = e2.selection;
|
|
@@ -2962,7 +3042,7 @@
|
|
|
2962
3042
|
const t4 = e2.getBlock(n2.nodeId);
|
|
2963
3043
|
return "table" === t4?.type;
|
|
2964
3044
|
}
|
|
2965
|
-
const o2 =
|
|
3045
|
+
const o2 = Ue(e2, n2.anchor.blockId);
|
|
2966
3046
|
if (!o2) return false;
|
|
2967
3047
|
const r2 = e2.getNodePath(o2.tableId);
|
|
2968
3048
|
if (!r2) return false;
|
|
@@ -2974,89 +3054,89 @@
|
|
|
2974
3054
|
const e4 = t4.getBlock(t4.selection.nodeId);
|
|
2975
3055
|
return "table" !== e4?.type ? null : { tableId: e4.id };
|
|
2976
3056
|
}
|
|
2977
|
-
const e3 =
|
|
3057
|
+
const e3 = Ue(t4, t4.selection.anchor.blockId);
|
|
2978
3058
|
return e3 ? { tableId: e3.tableId } : null;
|
|
2979
3059
|
})(e2);
|
|
2980
3060
|
if (!n2) return false;
|
|
2981
|
-
const o2 =
|
|
3061
|
+
const o2 = en(e2, n2.tableId);
|
|
2982
3062
|
return !!o2 && (t3.dispatch(o2), true);
|
|
2983
3063
|
})(t2));
|
|
2984
3064
|
}
|
|
2985
|
-
function
|
|
3065
|
+
function cn(t2, e2) {
|
|
2986
3066
|
const n2 = t2.getState();
|
|
2987
3067
|
if (C(n2.selection)) return false;
|
|
2988
|
-
const o2 = n2.selection, r2 =
|
|
3068
|
+
const o2 = n2.selection, r2 = Ue(n2, o2.anchor.blockId);
|
|
2989
3069
|
return !!r2 && e2(n2, o2, r2);
|
|
2990
3070
|
}
|
|
2991
|
-
function
|
|
2992
|
-
return
|
|
3071
|
+
function ln(t2) {
|
|
3072
|
+
return cn(t2, (e2, n2, o2) => {
|
|
2993
3073
|
const r2 = o2.tableIndex + 1;
|
|
2994
3074
|
if (r2 >= e2.doc.children.length) return false;
|
|
2995
3075
|
const i2 = e2.doc.children[r2];
|
|
2996
3076
|
if (!i2) return false;
|
|
2997
|
-
const s2 = e2.transaction("command").setSelection(
|
|
3077
|
+
const s2 = e2.transaction("command").setSelection(A(i2.id, 0)).build();
|
|
2998
3078
|
return t2.dispatch(s2), true;
|
|
2999
3079
|
});
|
|
3000
3080
|
}
|
|
3001
|
-
function
|
|
3002
|
-
const r2 = t2.getState(), i2 =
|
|
3081
|
+
function an(t2, e2, n2, o2) {
|
|
3082
|
+
const r2 = t2.getState(), i2 = We(r2, e2, n2, o2);
|
|
3003
3083
|
if (!i2) return false;
|
|
3004
|
-
const s2 =
|
|
3084
|
+
const s2 = Ge(r2, i2), c2 = r2.transaction("command").setSelection(A(s2, 0)).build();
|
|
3005
3085
|
return t2.dispatch(c2), true;
|
|
3006
3086
|
}
|
|
3007
|
-
function
|
|
3008
|
-
const r2 = t2.getState(), i2 =
|
|
3087
|
+
function dn(t2, e2, n2, o2) {
|
|
3088
|
+
const r2 = t2.getState(), i2 = We(r2, e2, n2, o2);
|
|
3009
3089
|
if (!i2) return false;
|
|
3010
|
-
const s2 =
|
|
3090
|
+
const s2 = Xe(r2, i2), c2 = r2.getBlock(s2);
|
|
3011
3091
|
if (!c2) return false;
|
|
3012
|
-
const l2 = m(c2), a2 = r2.transaction("command").setSelection(
|
|
3092
|
+
const l2 = m(c2), a2 = r2.transaction("command").setSelection(A(s2, l2)).build();
|
|
3013
3093
|
return t2.dispatch(a2), true;
|
|
3014
3094
|
}
|
|
3015
|
-
function
|
|
3095
|
+
function un(t2, e2) {
|
|
3016
3096
|
const n2 = t2.getState(), o2 = n2.getNodePath(e2);
|
|
3017
3097
|
if (!o2) return false;
|
|
3018
3098
|
const r2 = n2.transaction("input").setSelection(I(e2, o2)).build();
|
|
3019
3099
|
return t2.dispatch(r2), true;
|
|
3020
3100
|
}
|
|
3021
|
-
const
|
|
3022
|
-
function
|
|
3101
|
+
const hn = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 1v10M1 6h10" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';
|
|
3102
|
+
function pn(t2, e2, n2) {
|
|
3023
3103
|
const o2 = document.createElement("button");
|
|
3024
3104
|
return o2.className = t2, o2.innerHTML = e2, o2.title = n2, o2.type = "button", o2.setAttribute("aria-label", n2), o2.setAttribute("contenteditable", "false"), o2.addEventListener("mousedown", (t3) => {
|
|
3025
3105
|
t3.preventDefault(), t3.stopPropagation();
|
|
3026
3106
|
}), o2;
|
|
3027
3107
|
}
|
|
3028
|
-
function
|
|
3108
|
+
function fn(t2) {
|
|
3029
3109
|
const e2 = document.createElement("div");
|
|
3030
|
-
e2.className = `ntbl-insert-line ntbl-insert-line--${t2}`, e2.setAttribute("contenteditable", "false");
|
|
3031
|
-
const n2 =
|
|
3110
|
+
e2.className = `ntbl-insert-line ntbl-insert-line--${t2}`, e2.setAttribute("contenteditable", "false"), e2.setAttribute("data-notectl-no-print", "");
|
|
3111
|
+
const n2 = pn("ntbl-insert-btn", hn, "horizontal" === t2 ? "Insert row" : "Insert column");
|
|
3032
3112
|
return e2.appendChild(n2), e2;
|
|
3033
3113
|
}
|
|
3034
|
-
function
|
|
3114
|
+
function gn(t2, e2) {
|
|
3035
3115
|
const n2 = document.createElement("button");
|
|
3036
|
-
n2.className = `ntbl-add-zone ${t2}`, n2.type = "button", n2.setAttribute("contenteditable", "false"), n2.setAttribute("aria-label", e2), n2.title = e2;
|
|
3116
|
+
n2.className = `ntbl-add-zone ${t2}`, n2.type = "button", n2.setAttribute("contenteditable", "false"), n2.setAttribute("aria-label", e2), n2.setAttribute("data-notectl-no-print", ""), n2.title = e2;
|
|
3037
3117
|
const o2 = document.createElement("span");
|
|
3038
|
-
return o2.className = "ntbl-add-icon", o2.innerHTML =
|
|
3118
|
+
return o2.className = "ntbl-add-icon", o2.innerHTML = hn, n2.appendChild(o2), n2.addEventListener("mousedown", (t3) => {
|
|
3039
3119
|
t3.preventDefault(), t3.stopPropagation();
|
|
3040
3120
|
}), n2;
|
|
3041
3121
|
}
|
|
3042
|
-
function
|
|
3122
|
+
function mn(t2) {
|
|
3043
3123
|
const e2 = document.createElement("div");
|
|
3044
|
-
return e2.className = t2, e2.setAttribute("contenteditable", "false"), e2;
|
|
3124
|
+
return e2.className = t2, e2.setAttribute("contenteditable", "false"), e2.setAttribute("data-notectl-no-print", ""), e2;
|
|
3045
3125
|
}
|
|
3046
|
-
function
|
|
3126
|
+
function bn(t2, e2, n2, o2) {
|
|
3047
3127
|
const r2 = document.createElement("div");
|
|
3048
3128
|
r2.className = `ntbl-handle ${t2}`, r2.dataset.index = String(e2);
|
|
3049
|
-
const i2 =
|
|
3129
|
+
const i2 = pn("ntbl-handle-delete", '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>', n2);
|
|
3050
3130
|
return i2.addEventListener("click", (t3) => {
|
|
3051
3131
|
t3.preventDefault(), t3.stopPropagation(), o2(e2);
|
|
3052
3132
|
}), r2.appendChild(i2), r2;
|
|
3053
3133
|
}
|
|
3054
|
-
function
|
|
3134
|
+
function kn(t2, e2) {
|
|
3055
3135
|
let n2 = 0, o2 = 0, r2 = t2;
|
|
3056
3136
|
for (; r2 && r2 !== e2; ) n2 += r2.offsetTop, o2 += r2.offsetLeft, r2 = r2.offsetParent;
|
|
3057
3137
|
return { top: n2, left: o2 };
|
|
3058
3138
|
}
|
|
3059
|
-
class
|
|
3139
|
+
class yn {
|
|
3060
3140
|
tableId;
|
|
3061
3141
|
numRows;
|
|
3062
3142
|
numCols;
|
|
@@ -3108,7 +3188,7 @@
|
|
|
3108
3188
|
this.hideInsertLines();
|
|
3109
3189
|
};
|
|
3110
3190
|
constructor(t2, e2, n2, o2, r2) {
|
|
3111
|
-
this.container = t2, this.tableEl = e2, this.getState = o2, this.dispatchFn = r2, this.tableId = n2.id, this.numRows = a(n2).length, this.numCols = this.countCols(n2), this.colBar =
|
|
3191
|
+
this.container = t2, this.tableEl = e2, this.getState = o2, this.dispatchFn = r2, this.tableId = n2.id, this.numRows = a(n2).length, this.numCols = this.countCols(n2), this.colBar = mn("ntbl-col-bar"), this.rowBar = mn("ntbl-row-bar"), this.insertLineH = fn("horizontal"), this.insertLineV = fn("vertical"), this.addRowZone = gn("ntbl-add-row", "Add row"), this.addColZone = gn("ntbl-add-col", "Add column"), this.deleteTableBtn = pn("ntbl-delete-table-btn", '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M9 3h6m-9 4h12M10 11v6m4-6v6m-9 3h14l-1-13H6L5 20z" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>', "Delete table"), this.deleteTableBtn.setAttribute("data-notectl-no-print", ""), t2.append(this.colBar, this.rowBar, this.insertLineH, this.insertLineV, this.addRowZone, this.addColZone, this.deleteTableBtn), this.rebuildColHandles(), this.rebuildRowHandles(), this.bindEventListeners(), this.observer = new ResizeObserver(() => {
|
|
3112
3192
|
this.positionControls();
|
|
3113
3193
|
}), this.observer.observe(e2), requestAnimationFrame(() => this.positionControls());
|
|
3114
3194
|
}
|
|
@@ -3123,15 +3203,15 @@
|
|
|
3123
3203
|
bindEventListeners() {
|
|
3124
3204
|
const t2 = this.insertLineH.querySelector(".ntbl-insert-btn"), e2 = this.insertLineV.querySelector(".ntbl-insert-btn");
|
|
3125
3205
|
t2.addEventListener("click", () => {
|
|
3126
|
-
this.activeRowIndex >= 0 && this.dispatchTransaction(
|
|
3206
|
+
this.activeRowIndex >= 0 && this.dispatchTransaction(Je(this.getState(), this.tableId, this.activeRowIndex));
|
|
3127
3207
|
}), e2.addEventListener("click", () => {
|
|
3128
|
-
this.activeColIndex >= 0 && this.dispatchTransaction(
|
|
3208
|
+
this.activeColIndex >= 0 && this.dispatchTransaction(Ze(this.getState(), this.tableId, this.activeColIndex));
|
|
3129
3209
|
}), this.addRowZone.addEventListener("click", () => {
|
|
3130
|
-
this.dispatchTransaction(
|
|
3210
|
+
this.dispatchTransaction(Je(this.getState(), this.tableId, this.numRows));
|
|
3131
3211
|
}), this.addColZone.addEventListener("click", () => {
|
|
3132
|
-
this.dispatchTransaction(
|
|
3212
|
+
this.dispatchTransaction(Ze(this.getState(), this.tableId, this.numCols));
|
|
3133
3213
|
}), this.deleteTableBtn.addEventListener("click", () => {
|
|
3134
|
-
this.dispatchTransaction(
|
|
3214
|
+
this.dispatchTransaction(en(this.getState(), this.tableId));
|
|
3135
3215
|
}), this.container.addEventListener("mousemove", this.onMouseMove), this.container.addEventListener("mouseleave", this.onMouseLeave);
|
|
3136
3216
|
}
|
|
3137
3217
|
dispatchTransaction(t2) {
|
|
@@ -3165,18 +3245,18 @@
|
|
|
3165
3245
|
}
|
|
3166
3246
|
t2.style.height = `${i2}px`;
|
|
3167
3247
|
})(this.rowBar, this.tableEl), (function(t2, e2, n2, o2) {
|
|
3168
|
-
const r2 =
|
|
3248
|
+
const r2 = kn(n2, o2), i2 = n2.offsetHeight, s2 = n2.offsetWidth;
|
|
3169
3249
|
t2.style.width = `${s2}px`, t2.style.left = `${r2.left}px`, e2.style.height = `${i2}px`, e2.style.top = `${r2.top}px`;
|
|
3170
3250
|
})(this.addRowZone, this.addColZone, this.tableEl, this.container);
|
|
3171
3251
|
}
|
|
3172
3252
|
showHorizontalLine(t2) {
|
|
3173
3253
|
this.activeRowIndex = t2.index;
|
|
3174
|
-
const e2 =
|
|
3254
|
+
const e2 = kn(this.tableEl, this.container);
|
|
3175
3255
|
this.insertLineH.style.top = e2.top + t2.position - 1 + "px", this.insertLineH.style.left = `${e2.left}px`, this.insertLineH.style.width = `${this.tableEl.offsetWidth}px`, this.insertLineH.classList.add("ntbl-insert-line--visible");
|
|
3176
3256
|
}
|
|
3177
3257
|
showVerticalLine(t2) {
|
|
3178
3258
|
this.activeColIndex = t2.index;
|
|
3179
|
-
const e2 =
|
|
3259
|
+
const e2 = kn(this.tableEl, this.container);
|
|
3180
3260
|
this.insertLineV.style.left = e2.left + t2.position - 1 + "px", this.insertLineV.style.top = `${e2.top}px`, this.insertLineV.style.height = `${this.tableEl.offsetHeight}px`, this.insertLineV.classList.add("ntbl-insert-line--visible");
|
|
3181
3261
|
}
|
|
3182
3262
|
hideInsertLines() {
|
|
@@ -3191,8 +3271,8 @@
|
|
|
3191
3271
|
rebuildColHandles() {
|
|
3192
3272
|
this.colBar.innerHTML = "";
|
|
3193
3273
|
for (let t2 = 0; t2 < this.numCols; t2++) {
|
|
3194
|
-
const e2 =
|
|
3195
|
-
this.dispatchTransaction(
|
|
3274
|
+
const e2 = bn("ntbl-col-handle", t2, "Delete column", (t3) => {
|
|
3275
|
+
this.dispatchTransaction(tn(this.getState(), this.tableId, t3));
|
|
3196
3276
|
});
|
|
3197
3277
|
this.colBar.appendChild(e2);
|
|
3198
3278
|
}
|
|
@@ -3200,20 +3280,20 @@
|
|
|
3200
3280
|
rebuildRowHandles() {
|
|
3201
3281
|
this.rowBar.innerHTML = "";
|
|
3202
3282
|
for (let t2 = 0; t2 < this.numRows; t2++) {
|
|
3203
|
-
const e2 =
|
|
3204
|
-
this.dispatchTransaction(
|
|
3283
|
+
const e2 = bn("ntbl-row-handle", t2, "Delete row", (t3) => {
|
|
3284
|
+
this.dispatchTransaction(Qe(this.getState(), this.tableId, t3));
|
|
3205
3285
|
});
|
|
3206
3286
|
this.rowBar.appendChild(e2);
|
|
3207
3287
|
}
|
|
3208
3288
|
}
|
|
3209
3289
|
}
|
|
3210
|
-
const
|
|
3211
|
-
const
|
|
3212
|
-
const
|
|
3213
|
-
function
|
|
3290
|
+
const vn = new Kt("tableSelection");
|
|
3291
|
+
const xn = { maxPickerRows: 8, maxPickerCols: 8 }, wn = {}, Sn = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
3292
|
+
const In = ["#fff176", "#aed581", "#4dd0e1", "#64b5f6", "#ce93d8", "#f48fb1", "#ffab91", "#ff8a65", "#e6ee9c", "#80cbc4", "#fff9c4", "#dcedc8", "#e0f7fa", "#e3f2fd", "#f3e5f5", "#fce4ec", "#fff3e0", "#fbe9e7", "#f9fbe7", "#e0f2f1", "#fff59d", "#c5e1a5", "#80deea", "#90caf9", "#e1bee7", "#f8bbd0", "#ffcc80", "#ffab91", "#e6ee9c", "#a5d6a7", "#ffee58", "#9ccc65", "#26c6da", "#42a5f5", "#ab47bc", "#ec407a", "#ffa726", "#ff7043", "#d4e157", "#66bb6a", "#ffffff", "#fafafa", "#f5f5f5", "#eeeeee", "#e0e0e0", "#bdbdbd", "#e8eaf6", "#efebe9", "#eceff1", "#fafafa"], Cn = { superscript: true, subscript: true }, Tn = [{ 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"] } }];
|
|
3293
|
+
function Bn(t2) {
|
|
3214
3294
|
return `toggle${t2.charAt(0).toUpperCase()}${t2.slice(1)}`;
|
|
3215
3295
|
}
|
|
3216
|
-
function
|
|
3296
|
+
function En(t2, e2) {
|
|
3217
3297
|
const n2 = t2.getState(), o2 = n2.selection, r2 = { src: e2.src, alt: e2.alt ?? "", align: e2.align ?? "center", ...void 0 !== e2.width ? { width: e2.width } : {}, ...void 0 !== e2.height ? { height: e2.height } : {} }, s2 = C(o2) ? o2.nodeId : o2.anchor.blockId, c2 = (function(t3, e3) {
|
|
3218
3298
|
const n3 = t3.getBlock(e3);
|
|
3219
3299
|
if ("table_cell" === n3?.type) return e3;
|
|
@@ -3226,7 +3306,7 @@
|
|
|
3226
3306
|
return c2 ? (function(t3, e3, n3, o3) {
|
|
3227
3307
|
const r3 = t3.getNodePath(n3);
|
|
3228
3308
|
if (!r3) return false;
|
|
3229
|
-
const s3 =
|
|
3309
|
+
const s3 = h("image", [], void 0, o3), c3 = t3.getBlock(n3);
|
|
3230
3310
|
if (!c3) return false;
|
|
3231
3311
|
const l2 = t3.transaction("command"), d2 = a(c3);
|
|
3232
3312
|
for (let t4 = d2.length - 1; t4 >= 0; t4--) {
|
|
@@ -3237,11 +3317,11 @@
|
|
|
3237
3317
|
})(n2, t2, c2, r2) : (function(t3, e3, n3, o3) {
|
|
3238
3318
|
const r3 = t3.doc.children.findIndex((t4) => t4.id === n3);
|
|
3239
3319
|
if (-1 === r3) return false;
|
|
3240
|
-
const i2 =
|
|
3320
|
+
const i2 = h("image", [], void 0, o3), s3 = h("paragraph"), c3 = t3.transaction("command").insertNode([], r3 + 1, i2).insertNode([], r3 + 2, s3).setSelection(I(i2.id, [])).build();
|
|
3241
3321
|
return e3.dispatch(c3), true;
|
|
3242
3322
|
})(n2, t2, s2, r2);
|
|
3243
3323
|
}
|
|
3244
|
-
function
|
|
3324
|
+
function Mn(t2, e2, n2) {
|
|
3245
3325
|
const o2 = t2.getState(), r2 = o2.selection;
|
|
3246
3326
|
if (!C(r2)) return false;
|
|
3247
3327
|
const i2 = o2.getBlock(r2.nodeId);
|
|
@@ -3260,12 +3340,12 @@
|
|
|
3260
3340
|
return t3.dispatch(c3), true;
|
|
3261
3341
|
})(t2, { width: a2, height: d2 });
|
|
3262
3342
|
}
|
|
3263
|
-
const
|
|
3264
|
-
let
|
|
3265
|
-
function
|
|
3266
|
-
|
|
3343
|
+
const An = { left: "notectl-image--left", center: "notectl-image--center", right: "notectl-image--right" }, _n = { nw: "nwse-resize", ne: "nesw-resize", sw: "nesw-resize", se: "nwse-resize" }, Ln = { nw: -1, ne: 1, sw: -1, se: 1 }, Nn = { nw: "Resize top-left", ne: "Resize top-right", sw: "Resize bottom-left", se: "Resize bottom-right" };
|
|
3344
|
+
let zn = null;
|
|
3345
|
+
function Pn() {
|
|
3346
|
+
zn && (zn.remove(), zn = null);
|
|
3267
3347
|
}
|
|
3268
|
-
function
|
|
3348
|
+
function Rn(t2, e2, n2) {
|
|
3269
3349
|
return (o2, r2, i2) => {
|
|
3270
3350
|
const s2 = document.createElement("figure");
|
|
3271
3351
|
s2.className = "notectl-image", s2.setAttribute("data-block-id", o2.id), s2.setAttribute("data-void", "true"), s2.setAttribute("data-selectable", "true");
|
|
@@ -3275,31 +3355,31 @@
|
|
|
3275
3355
|
l2.className = "notectl-image__img", l2.draggable = false;
|
|
3276
3356
|
const a2 = document.createElement("div");
|
|
3277
3357
|
a2.className = "notectl-image__overlay", c2.appendChild(l2), c2.appendChild(a2), s2.appendChild(c2);
|
|
3278
|
-
let d2 = o2.id,
|
|
3279
|
-
function
|
|
3358
|
+
let d2 = o2.id, u2 = null;
|
|
3359
|
+
function h2(t3) {
|
|
3280
3360
|
const n3 = t3.attrs?.src ?? "", o3 = t3.attrs?.alt ?? "", r3 = t3.attrs?.width, i3 = t3.attrs?.height, c3 = t3.attrs?.align ?? "center";
|
|
3281
3361
|
l2.src !== n3 && (l2.src = n3), l2.alt = o3, l2.style.width = void 0 !== r3 ? `${r3}px` : "", l2.style.height = void 0 !== i3 ? `${i3}px` : "";
|
|
3282
|
-
for (const t4 of Object.values(
|
|
3283
|
-
const d3 =
|
|
3362
|
+
for (const t4 of Object.values(An)) s2.classList.remove(t4);
|
|
3363
|
+
const d3 = An[c3];
|
|
3284
3364
|
d3 && s2.classList.add(d3);
|
|
3285
|
-
const
|
|
3286
|
-
a2.classList.toggle("notectl-image__overlay--uploading",
|
|
3365
|
+
const u3 = e2.get(t3.id) ?? "idle", h3 = "uploading" === u3;
|
|
3366
|
+
a2.classList.toggle("notectl-image__overlay--uploading", h3), a2.classList.toggle("notectl-image__overlay--error", "error" === u3), a2.textContent = h3 ? "Uploading..." : "error" === u3 ? "Upload failed" : "", h3 ? s2.setAttribute("aria-busy", "true") : s2.removeAttribute("aria-busy"), (function(t4) {
|
|
3287
3367
|
const e3 = t4.attrs?.alt ?? "", n4 = t4.attrs?.width, o4 = t4.attrs?.height, r4 = [];
|
|
3288
3368
|
e3 ? r4.push(e3) : r4.push("Image"), void 0 !== n4 && void 0 !== o4 && r4.push(`${n4} by ${o4} pixels`), s2.setAttribute("aria-label", r4.join(", "));
|
|
3289
3369
|
})(t3);
|
|
3290
3370
|
}
|
|
3291
|
-
|
|
3371
|
+
h2(o2);
|
|
3292
3372
|
let p2 = false;
|
|
3293
3373
|
function f2(e3, n3, o3, c3) {
|
|
3294
|
-
let a3 = 0, d3 = 0,
|
|
3295
|
-
const
|
|
3296
|
-
const o4 = e4.clientX - a3, r3 = (i3 = d3 + o4 *
|
|
3374
|
+
let a3 = 0, d3 = 0, u3 = 1;
|
|
3375
|
+
const h3 = (e4) => {
|
|
3376
|
+
const o4 = e4.clientX - a3, r3 = (i3 = d3 + o4 * Ln[n3], Math.max(50, Math.min(t2.maxWidth, i3)));
|
|
3297
3377
|
var i3;
|
|
3298
|
-
const s3 = Math.round(r3 /
|
|
3378
|
+
const s3 = Math.round(r3 / u3);
|
|
3299
3379
|
l2.style.width = `${r3}px`, l2.style.height = `${s3}px`, c3.textContent = `${Math.round(r3)} × ${s3}`;
|
|
3300
3380
|
}, p3 = (t3) => {
|
|
3301
|
-
document.removeEventListener("pointermove",
|
|
3302
|
-
const e4 = Math.round(l2.getBoundingClientRect().width), n4 = Math.round(e4 /
|
|
3381
|
+
document.removeEventListener("pointermove", h3), document.removeEventListener("pointerup", p3), s2.classList.remove("notectl-image--resizing"), c3.classList.remove("notectl-image__size-indicator--visible"), Pn();
|
|
3382
|
+
const e4 = Math.round(l2.getBoundingClientRect().width), n4 = Math.round(e4 / u3);
|
|
3303
3383
|
!(function(t4, e5, n5) {
|
|
3304
3384
|
const o4 = r2(), s3 = o4.getBlock(t4);
|
|
3305
3385
|
if (!s3) return;
|
|
@@ -3307,19 +3387,19 @@
|
|
|
3307
3387
|
if (c4 === e5 && l3 === n5) return;
|
|
3308
3388
|
const a4 = o4.getNodePath(t4);
|
|
3309
3389
|
if (!a4) return;
|
|
3310
|
-
const d4 = { ...s3.attrs ?? {}, width: e5, height: n5 },
|
|
3311
|
-
i2(
|
|
3390
|
+
const d4 = { ...s3.attrs ?? {}, width: e5, height: n5 }, u4 = o4.transaction("command").setNodeAttr(a4, d4).build();
|
|
3391
|
+
i2(u4);
|
|
3312
3392
|
})(o3, e4, n4), t3.target?.releasePointerCapture?.(t3.pointerId);
|
|
3313
3393
|
};
|
|
3314
3394
|
e3.addEventListener("pointerdown", (t3) => {
|
|
3315
3395
|
t3.preventDefault(), t3.stopPropagation(), a3 = t3.clientX, d3 = l2.getBoundingClientRect().width;
|
|
3316
3396
|
const e4 = l2.getBoundingClientRect().height;
|
|
3317
3397
|
var o4;
|
|
3318
|
-
|
|
3398
|
+
u3 = e4 > 0 ? d3 / e4 : 1, s2.classList.add("notectl-image--resizing"), c3.textContent = `${Math.round(d3)} × ${Math.round(e4)}`, c3.classList.add("notectl-image__size-indicator--visible"), o4 = _n[n3], Pn(), zn = document.createElement("style"), zn.textContent = `*{cursor:${o4}!important;user-select:none!important}`, document.head.appendChild(zn), t3.target.setPointerCapture(t3.pointerId), document.addEventListener("pointermove", h3), document.addEventListener("pointerup", p3);
|
|
3319
3399
|
});
|
|
3320
3400
|
}
|
|
3321
3401
|
function g2() {
|
|
3322
|
-
|
|
3402
|
+
Pn(), u2 && (u2.remove(), u2 = null);
|
|
3323
3403
|
}
|
|
3324
3404
|
return l2.addEventListener("load", () => {
|
|
3325
3405
|
if (p2) return;
|
|
@@ -3329,32 +3409,32 @@
|
|
|
3329
3409
|
if (o3 && s3) return void (p2 = true);
|
|
3330
3410
|
const c3 = l2.naturalWidth, a3 = l2.naturalHeight;
|
|
3331
3411
|
if (0 === c3 || 0 === a3) return;
|
|
3332
|
-
const
|
|
3412
|
+
const u3 = Math.min(c3, t2.maxWidth), h3 = c3 > 0 ? a3 / c3 : 1, f3 = Math.round(u3 * h3), g3 = e3.getNodePath(d2);
|
|
3333
3413
|
if (!g3) return;
|
|
3334
|
-
const m2 = { ...n3.attrs ?? {}, width:
|
|
3414
|
+
const m2 = { ...n3.attrs ?? {}, width: u3, height: f3 }, b2 = e3.transaction("command").setNodeAttr(g3, m2).build();
|
|
3335
3415
|
i2(b2), p2 = true;
|
|
3336
|
-
}), { dom: s2, contentDOM: null, update: (t3) => "image" === t3.type && (d2 = t3.id, s2.setAttribute("data-block-id", t3.id),
|
|
3416
|
+
}), { dom: s2, contentDOM: null, update: (t3) => "image" === t3.type && (d2 = t3.id, s2.setAttribute("data-block-id", t3.id), h2(t3), true), selectNode() {
|
|
3337
3417
|
s2.classList.add("notectl-image--selected"), (function(e3) {
|
|
3338
|
-
if (!t2.resizable ||
|
|
3339
|
-
|
|
3418
|
+
if (!t2.resizable || u2) return;
|
|
3419
|
+
u2 = document.createElement("div"), u2.className = "notectl-image__resize-overlay", u2.setAttribute("data-notectl-no-print", "");
|
|
3340
3420
|
const o3 = document.createElement("div");
|
|
3341
|
-
o3.className = "notectl-image__size-indicator",
|
|
3421
|
+
o3.className = "notectl-image__size-indicator", u2.appendChild(o3);
|
|
3342
3422
|
const r3 = ["nw", "ne", "sw", "se"];
|
|
3343
3423
|
for (const t3 of r3) {
|
|
3344
3424
|
const n3 = document.createElement("div");
|
|
3345
|
-
n3.className = `notectl-image__resize-handle notectl-image__resize-handle--${t3}`, n3.setAttribute("role", "separator"), n3.setAttribute("aria-label",
|
|
3425
|
+
n3.className = `notectl-image__resize-handle notectl-image__resize-handle--${t3}`, n3.setAttribute("role", "separator"), n3.setAttribute("aria-label", Nn[t3]), f2(n3, t3, e3, o3), u2.appendChild(n3);
|
|
3346
3426
|
}
|
|
3347
3427
|
if (n2) {
|
|
3348
3428
|
const t3 = (function(t4) {
|
|
3349
3429
|
const e4 = t4.shrinkWidth ?? null, n3 = t4.growWidth ?? null;
|
|
3350
|
-
return e4 && n3 ? `${
|
|
3430
|
+
return e4 && n3 ? `${ae(e4)} / ${ae(n3)} to resize` : "";
|
|
3351
3431
|
})(n2);
|
|
3352
3432
|
if (t3) {
|
|
3353
3433
|
const e4 = document.createElement("div");
|
|
3354
|
-
e4.className = "notectl-image__keyboard-hint", e4.setAttribute("aria-hidden", "true"), e4.textContent = t3,
|
|
3434
|
+
e4.className = "notectl-image__keyboard-hint", e4.setAttribute("aria-hidden", "true"), e4.textContent = t3, u2.appendChild(e4);
|
|
3355
3435
|
}
|
|
3356
3436
|
}
|
|
3357
|
-
c2.appendChild(
|
|
3437
|
+
c2.appendChild(u2);
|
|
3358
3438
|
})(d2);
|
|
3359
3439
|
}, deselectNode() {
|
|
3360
3440
|
s2.classList.remove("notectl-image--selected"), g2();
|
|
@@ -3363,20 +3443,72 @@
|
|
|
3363
3443
|
} };
|
|
3364
3444
|
};
|
|
3365
3445
|
}
|
|
3366
|
-
const
|
|
3367
|
-
function
|
|
3446
|
+
const Hn = new Kt("image:upload"), Dn = { growWidth: "Mod-Shift-ArrowRight", shrinkWidth: "Mod-Shift-ArrowLeft", growWidthLarge: "Mod-Shift-Alt-ArrowRight", shrinkWidthLarge: "Mod-Shift-Alt-ArrowLeft", resetSize: "Mod-Shift-0" }, On = { maxWidth: 800, maxFileSize: 10485760, acceptedTypes: ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"], resizable: true, resizeStep: 10, resizeStepLarge: 50 };
|
|
3447
|
+
function $n(t2, e2) {
|
|
3448
|
+
const n2 = t2.getState();
|
|
3449
|
+
if (C(n2.selection)) return false;
|
|
3450
|
+
const o2 = n2.selection, r2 = n2.getBlock(o2.anchor.blockId);
|
|
3451
|
+
return !(!r2 || "code_block" !== r2.type) && e2({ state: n2, block: r2, blockId: o2.anchor.blockId, offset: o2.anchor.offset });
|
|
3452
|
+
}
|
|
3453
|
+
function Fn(t2) {
|
|
3454
|
+
return $n(t2, ({ state: e2, blockId: n2 }) => {
|
|
3455
|
+
const o2 = e2.getBlockOrder(), r2 = o2.indexOf(n2);
|
|
3456
|
+
if (r2 < o2.length - 1) {
|
|
3457
|
+
const n3 = o2[r2 + 1], i2 = e2.transaction("command").setSelection(A(n3, 0)).build();
|
|
3458
|
+
t2.dispatch(i2);
|
|
3459
|
+
} else Kn(t2, n2);
|
|
3460
|
+
return true;
|
|
3461
|
+
});
|
|
3462
|
+
}
|
|
3463
|
+
function Kn(t2, e2) {
|
|
3464
|
+
const n2 = t2.getState(), o2 = n2.getBlock(e2);
|
|
3465
|
+
if (!o2) return;
|
|
3466
|
+
const r2 = m(o2), i2 = d(), s2 = n2.transaction("command").splitBlock(e2, r2, i2).setBlockType(i2, "paragraph").setSelection(A(i2, 0)).build();
|
|
3467
|
+
t2.dispatch(s2);
|
|
3468
|
+
}
|
|
3469
|
+
function Vn(t2, e2) {
|
|
3470
|
+
const n2 = t2.getState(), r2 = n2.selection;
|
|
3471
|
+
if (C(r2)) return false;
|
|
3472
|
+
const i2 = n2.getBlock(r2.anchor.blockId);
|
|
3473
|
+
if (!i2 || "code_block" === i2.type) return false;
|
|
3474
|
+
const s2 = { language: e2.defaultLanguage ?? "", backgroundColor: "" }, c2 = n2.transaction("command");
|
|
3475
|
+
return (function(t3, e3) {
|
|
3476
|
+
if (0 === m(e3)) return;
|
|
3477
|
+
const n3 = l(e3);
|
|
3478
|
+
let r3 = 0;
|
|
3479
|
+
for (const i3 of n3) if (o(i3)) {
|
|
3480
|
+
if (i3.text.length > 0) for (const n4 of i3.marks) t3.removeMark(e3.id, r3, r3 + i3.text.length, n4);
|
|
3481
|
+
r3 += i3.text.length;
|
|
3482
|
+
} else r3 += 1;
|
|
3483
|
+
})(c2, i2), c2.setBlockType(r2.anchor.blockId, "code_block", s2).setSelection(A(r2.anchor.blockId, 0)), t2.dispatch(c2.build()), true;
|
|
3484
|
+
}
|
|
3485
|
+
const jn = { insertAfter: "Mod-Enter", toggle: "Mod-Shift-M" }, qn = { defaultLanguage: "", useSpaces: false, spaceCount: 2, showCopyButton: true }, Un = new Kt("codeBlock");
|
|
3486
|
+
function Wn(t2, e2, n2, o2) {
|
|
3487
|
+
const r2 = t2.getState(), i2 = r2.getBlock(e2);
|
|
3488
|
+
if (!i2 || "code_block" !== i2.type) return;
|
|
3489
|
+
const s2 = U(r2.doc, e2);
|
|
3490
|
+
if (!s2) return;
|
|
3491
|
+
const c2 = { ...i2.attrs, [n2]: o2 }, l2 = r2.transaction("command").setNodeAttr(s2, c2).build();
|
|
3492
|
+
t2.dispatch(l2);
|
|
3493
|
+
}
|
|
3494
|
+
function Gn(t2) {
|
|
3495
|
+
return "function" == typeof t2 ? t2() : t2;
|
|
3496
|
+
}
|
|
3497
|
+
const Xn = new Kt("print"), Yn = new Ft("print:before"), Jn = new Ft("print:after"), Zn = { print() {
|
|
3498
|
+
}, toHTML: () => "" }, Qn = { Light: "light", Dark: "dark", System: "system" }, to = { name: "light", primitives: { background: "#ffffff", foreground: "#1a1a1a", mutedForeground: "#666666", border: "#d0d0d0", borderFocus: "#4a90d9", primary: "#4a90d9", primaryForeground: "#1a5fa0", primaryMuted: "#d0e0f0", surfaceRaised: "#f8f8f8", surfaceOverlay: "#ffffff", hoverBackground: "#e8e8e8", activeBackground: "#d0e0f0", danger: "#dc2626", dangerMuted: "#fee2e2", success: "#1a8c1a", shadow: "rgba(0, 0, 0, 0.15)", focusRing: "rgba(74, 144, 217, 0.2)" }, codeBlock: { background: "#f8fafc", foreground: "#334155", headerBackground: "#f1f5f9", headerForeground: "#64748b", headerBorder: "#e2e8f0" }, tooltip: { background: "#1a1a1a", foreground: "#ffffff" } }, eo = { name: "dark", primitives: { background: "#1e1e2e", foreground: "#cdd6f4", mutedForeground: "#7f849c", border: "#45475a", borderFocus: "#89b4fa", primary: "#89b4fa", primaryForeground: "#89b4fa", primaryMuted: "rgba(137, 180, 250, 0.15)", surfaceRaised: "#313244", surfaceOverlay: "#313244", hoverBackground: "#45475a", activeBackground: "rgba(137, 180, 250, 0.15)", danger: "#f38ba8", dangerMuted: "rgba(243, 139, 168, 0.15)", success: "#a6e3a1", shadow: "rgba(0, 0, 0, 0.4)", focusRing: "rgba(137, 180, 250, 0.25)" }, codeBlock: { background: "#11111b", foreground: "#cdd6f4", headerBackground: "#181825", headerForeground: "#7f849c", headerBorder: "rgba(205, 214, 244, 0.08)" }, tooltip: { background: "#585b70", foreground: "#cdd6f4" } };
|
|
3499
|
+
function no(t2) {
|
|
3368
3500
|
if ("object" == typeof t2) return t2;
|
|
3369
3501
|
switch (t2) {
|
|
3370
|
-
case
|
|
3371
|
-
return
|
|
3372
|
-
case
|
|
3373
|
-
return
|
|
3502
|
+
case Qn.Light:
|
|
3503
|
+
return to;
|
|
3504
|
+
case Qn.Dark:
|
|
3505
|
+
return eo;
|
|
3374
3506
|
default:
|
|
3375
|
-
return
|
|
3507
|
+
return to;
|
|
3376
3508
|
}
|
|
3377
3509
|
}
|
|
3378
|
-
const
|
|
3379
|
-
function
|
|
3510
|
+
const oo = [["primitives.background", "--notectl-bg"], ["primitives.foreground", "--notectl-fg"], ["primitives.mutedForeground", "--notectl-fg-muted"], ["primitives.border", "--notectl-border"], ["primitives.borderFocus", "--notectl-border-focus"], ["primitives.primary", "--notectl-primary"], ["primitives.primaryForeground", "--notectl-primary-fg"], ["primitives.primaryMuted", "--notectl-primary-muted"], ["primitives.surfaceRaised", "--notectl-surface-raised"], ["primitives.surfaceOverlay", "--notectl-surface-overlay"], ["primitives.hoverBackground", "--notectl-hover-bg"], ["primitives.activeBackground", "--notectl-active-bg"], ["primitives.danger", "--notectl-danger"], ["primitives.dangerMuted", "--notectl-danger-muted"], ["primitives.success", "--notectl-success"], ["primitives.shadow", "--notectl-shadow"], ["primitives.focusRing", "--notectl-focus-ring"], ["toolbar.background", "--notectl-toolbar-bg"], ["toolbar.borderColor", "--notectl-toolbar-border"], ["codeBlock.background", "--notectl-code-block-bg"], ["codeBlock.foreground", "--notectl-code-block-color"], ["codeBlock.headerBackground", "--notectl-code-block-header-bg"], ["codeBlock.headerForeground", "--notectl-code-block-header-color"], ["codeBlock.headerBorder", "--notectl-code-block-header-border"], ["tooltip.background", "--notectl-tooltip-bg"], ["tooltip.foreground", "--notectl-tooltip-fg"]], ro = /* @__PURE__ */ new Map([["--notectl-toolbar-bg", "var(--notectl-surface-raised)"], ["--notectl-toolbar-border", "var(--notectl-border)"], ["--notectl-code-block-bg", "var(--notectl-surface-raised)"], ["--notectl-code-block-color", "var(--notectl-fg)"], ["--notectl-code-block-header-bg", "var(--notectl-surface-raised)"], ["--notectl-code-block-header-color", "var(--notectl-fg-muted)"], ["--notectl-code-block-header-border", "var(--notectl-border)"], ["--notectl-tooltip-bg", "var(--notectl-fg)"], ["--notectl-tooltip-fg", "var(--notectl-bg)"]]);
|
|
3511
|
+
function io(t2, e2) {
|
|
3380
3512
|
const n2 = e2.split(".");
|
|
3381
3513
|
let o2 = t2;
|
|
3382
3514
|
for (const t3 of n2) {
|
|
@@ -3385,19 +3517,19 @@
|
|
|
3385
3517
|
}
|
|
3386
3518
|
return "string" == typeof o2 ? o2 : void 0;
|
|
3387
3519
|
}
|
|
3388
|
-
function
|
|
3520
|
+
function so(t2) {
|
|
3389
3521
|
const e2 = [":host {"];
|
|
3390
|
-
for (const [n2, o2] of
|
|
3391
|
-
const r2 =
|
|
3522
|
+
for (const [n2, o2] of oo) {
|
|
3523
|
+
const r2 = io(t2, n2);
|
|
3392
3524
|
if (void 0 !== r2) e2.push(` ${o2}: ${r2};`);
|
|
3393
3525
|
else {
|
|
3394
|
-
const t3 =
|
|
3526
|
+
const t3 = ro.get(o2);
|
|
3395
3527
|
t3 && e2.push(` ${o2}: ${t3};`);
|
|
3396
3528
|
}
|
|
3397
3529
|
}
|
|
3398
3530
|
return e2.push("}"), e2.join("\n");
|
|
3399
3531
|
}
|
|
3400
|
-
class
|
|
3532
|
+
class co {
|
|
3401
3533
|
constructor(t2, e2) {
|
|
3402
3534
|
this.element = t2, this.getState = e2.getState, this.dispatch = e2.dispatch, this.syncSelection = e2.syncSelection, this.schemaRegistry = e2.schemaRegistry, this.handleBeforeInput = this.onBeforeInput.bind(this), this.handleCompositionStart = this.onCompositionStart.bind(this), this.handleCompositionEnd = this.onCompositionEnd.bind(this), t2.addEventListener("beforeinput", this.handleBeforeInput), t2.addEventListener("compositionstart", this.handleCompositionStart), t2.addEventListener("compositionend", this.handleCompositionEnd);
|
|
3403
3535
|
}
|
|
@@ -3459,7 +3591,7 @@
|
|
|
3459
3591
|
}
|
|
3460
3592
|
return n4 + 1;
|
|
3461
3593
|
})(n3, e3.anchor.offset);
|
|
3462
|
-
return t3.transaction("input").deleteTextAt(n3.id, o2, e3.anchor.offset).setSelection(
|
|
3594
|
+
return t3.transaction("input").deleteTextAt(n3.id, o2, e3.anchor.offset).setSelection(A(n3.id, o2)).build();
|
|
3463
3595
|
})(e2);
|
|
3464
3596
|
break;
|
|
3465
3597
|
case "deleteWordForward":
|
|
@@ -3492,7 +3624,7 @@
|
|
|
3492
3624
|
}
|
|
3493
3625
|
return o3;
|
|
3494
3626
|
})(n3, e3.anchor.offset);
|
|
3495
|
-
return t3.transaction("input").deleteTextAt(n3.id, e3.anchor.offset, r2).setSelection(
|
|
3627
|
+
return t3.transaction("input").deleteTextAt(n3.id, e3.anchor.offset, r2).setSelection(A(n3.id, e3.anchor.offset)).build();
|
|
3496
3628
|
})(e2);
|
|
3497
3629
|
break;
|
|
3498
3630
|
case "deleteSoftLineBackward":
|
|
@@ -3501,7 +3633,7 @@
|
|
|
3501
3633
|
if (C(e3)) return bt(t3, e3);
|
|
3502
3634
|
if (!_(e3)) return St(t3);
|
|
3503
3635
|
const n3 = t3.getBlock(e3.anchor.blockId);
|
|
3504
|
-
return n3 ? 0 === e3.anchor.offset ? _t(t3) : t3.transaction("input").deleteTextAt(n3.id, 0, e3.anchor.offset).setSelection(
|
|
3636
|
+
return n3 ? 0 === e3.anchor.offset ? _t(t3) : t3.transaction("input").deleteTextAt(n3.id, 0, e3.anchor.offset).setSelection(A(n3.id, 0)).build() : null;
|
|
3505
3637
|
})(e2);
|
|
3506
3638
|
break;
|
|
3507
3639
|
case "deleteSoftLineForward":
|
|
@@ -3512,7 +3644,7 @@
|
|
|
3512
3644
|
const n3 = t3.getBlock(e3.anchor.blockId);
|
|
3513
3645
|
if (!n3) return null;
|
|
3514
3646
|
const o2 = m(n3);
|
|
3515
|
-
return e3.anchor.offset === o2 ? Lt(t3) : t3.transaction("input").deleteTextAt(n3.id, e3.anchor.offset, o2).setSelection(
|
|
3647
|
+
return e3.anchor.offset === o2 ? Lt(t3) : t3.transaction("input").deleteTextAt(n3.id, e3.anchor.offset, o2).setSelection(A(n3.id, e3.anchor.offset)).build();
|
|
3516
3648
|
})(e2);
|
|
3517
3649
|
}
|
|
3518
3650
|
n2 && (this.dispatch(n2), "insertText" === t2.inputType && this.checkInputRules());
|
|
@@ -3548,14 +3680,14 @@
|
|
|
3548
3680
|
this.element.removeEventListener("beforeinput", this.handleBeforeInput), this.element.removeEventListener("compositionstart", this.handleCompositionStart), this.element.removeEventListener("compositionend", this.handleCompositionEnd);
|
|
3549
3681
|
}
|
|
3550
3682
|
}
|
|
3551
|
-
function
|
|
3683
|
+
function lo(t2) {
|
|
3552
3684
|
return t2.reduce((t3, e2) => t3 + e2.text, "");
|
|
3553
3685
|
}
|
|
3554
|
-
function
|
|
3686
|
+
function ao(t2) {
|
|
3555
3687
|
return t2.reduce((t3, e2) => t3 + e2.text.length, 0);
|
|
3556
3688
|
}
|
|
3557
|
-
const
|
|
3558
|
-
class
|
|
3689
|
+
const uo = /* @__PURE__ */ new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "BLOCKQUOTE", "UL", "OL", "LI", "HR", "PRE", "TABLE", "THEAD", "TBODY", "TR"]), ho = /* @__PURE__ */ new Set(["STRONG", "B", "EM", "I", "U", "S", "STRIKE", "DEL", "A", "SPAN", "BR", "SUB", "SUP", "CODE"]);
|
|
3690
|
+
class po {
|
|
3559
3691
|
schema;
|
|
3560
3692
|
blockParseRules;
|
|
3561
3693
|
markParseRules;
|
|
@@ -3652,7 +3784,7 @@
|
|
|
3652
3784
|
if (t2.nodeType !== Node.ELEMENT_NODE) return [];
|
|
3653
3785
|
const n2 = t2, o2 = n2.tagName;
|
|
3654
3786
|
if ("BR" === o2) return [{ text: "\n", marks: this.resolveMarks(e2) }];
|
|
3655
|
-
if (this.isBlockElement(n2) && !
|
|
3787
|
+
if (this.isBlockElement(n2) && !ho.has(o2)) return this.parseInlineChildren(n2, e2);
|
|
3656
3788
|
const r2 = this.mergeMarks(e2, this.marksFromElement(n2));
|
|
3657
3789
|
return this.parseInlineChildren(n2, r2);
|
|
3658
3790
|
}
|
|
@@ -3724,7 +3856,7 @@
|
|
|
3724
3856
|
return null;
|
|
3725
3857
|
}
|
|
3726
3858
|
isBlockElement(t2) {
|
|
3727
|
-
if (
|
|
3859
|
+
if (uo.has(t2.tagName)) return true;
|
|
3728
3860
|
const e2 = t2.tagName.toLowerCase();
|
|
3729
3861
|
return this.blockParseRules.some((t3) => t3.rule.tag === e2);
|
|
3730
3862
|
}
|
|
@@ -3740,7 +3872,7 @@
|
|
|
3740
3872
|
0 !== n2.length && (n2.every((t3) => "" === t3.text.trim()) || t2.push({ type: this.resolveBlockType("paragraph"), segments: n2 }));
|
|
3741
3873
|
}
|
|
3742
3874
|
}
|
|
3743
|
-
class
|
|
3875
|
+
class fo {
|
|
3744
3876
|
constructor(t2, e2) {
|
|
3745
3877
|
this.element = t2, this.getState = e2.getState, this.dispatch = e2.dispatch, this.schemaRegistry = e2.schemaRegistry, this.handlePaste = this.onPaste.bind(this), t2.addEventListener("paste", this.handlePaste);
|
|
3746
3878
|
}
|
|
@@ -3768,7 +3900,7 @@
|
|
|
3768
3900
|
if (t3 && this.handleRichPasteFromJson(t3)) return;
|
|
3769
3901
|
const n3 = this.schemaRegistry ? this.schemaRegistry.getAllowedTags() : ["strong", "em", "u", "b", "i", "p", "br", "div", "span"], o3 = this.schemaRegistry ? this.schemaRegistry.getAllowedAttrs() : [], r3 = e.sanitize(s2, { ALLOWED_TAGS: n3, ALLOWED_ATTR: o3 });
|
|
3770
3902
|
if (this.schemaRegistry) {
|
|
3771
|
-
const t4 = z(this.schemaRegistry), e2 = new
|
|
3903
|
+
const t4 = z(this.schemaRegistry), e2 = new po({ schema: t4, schemaRegistry: this.schemaRegistry }), n4 = document.createElement("template");
|
|
3772
3904
|
n4.innerHTML = r3;
|
|
3773
3905
|
const o4 = (function(t5, e3) {
|
|
3774
3906
|
if (0 === e3.blocks.length) return t5.transaction("paste").setSelection(t5.selection).build();
|
|
@@ -3778,15 +3910,15 @@
|
|
|
3778
3910
|
if (C(n6)) return t6.transaction("paste").setSelection(n6).build();
|
|
3779
3911
|
const o5 = t6.transaction("paste"), r4 = _(n6) ? null : N(n6, t6.getBlockOrder());
|
|
3780
3912
|
_(n6) || Pt(t6, o5);
|
|
3781
|
-
const i3 = r4 ? r4.from.blockId : n6.anchor.blockId, s3 = r4 ? r4.from.offset : n6.anchor.offset, c2 =
|
|
3782
|
-
return o5.insertText(i3, s3, l2, [], e4), o5.setSelection(
|
|
3913
|
+
const i3 = r4 ? r4.from.blockId : n6.anchor.blockId, s3 = r4 ? r4.from.offset : n6.anchor.offset, c2 = ao(e4), l2 = lo(e4);
|
|
3914
|
+
return o5.insertText(i3, s3, l2, [], e4), o5.setSelection(A(i3, s3 + c2)), o5.build();
|
|
3783
3915
|
})(t5, n5.segments) : 1 === e3.blocks.length ? (function(t6, e4) {
|
|
3784
3916
|
const n6 = t6.selection;
|
|
3785
3917
|
if (C(n6)) return t6.transaction("paste").setSelection(n6).build();
|
|
3786
3918
|
const o5 = t6.transaction("paste"), r4 = _(n6) ? null : N(n6, t6.getBlockOrder());
|
|
3787
3919
|
_(n6) || Pt(t6, o5);
|
|
3788
|
-
const i3 = r4 ? r4.from.blockId : n6.anchor.blockId, s3 = r4 ? r4.from.offset : n6.anchor.offset, c2 =
|
|
3789
|
-
return o5.setBlockType(i3, e4.type, e4.attrs), o5.insertText(i3, s3, l2, [], e4.segments), o5.setSelection(
|
|
3920
|
+
const i3 = r4 ? r4.from.blockId : n6.anchor.blockId, s3 = r4 ? r4.from.offset : n6.anchor.offset, c2 = ao(e4.segments), l2 = lo(e4.segments);
|
|
3921
|
+
return o5.setBlockType(i3, e4.type, e4.attrs), o5.insertText(i3, s3, l2, [], e4.segments), o5.setSelection(A(i3, s3 + c2)), o5.build();
|
|
3790
3922
|
})(t5, n5) : (function(t6, e4) {
|
|
3791
3923
|
const n6 = t6.selection;
|
|
3792
3924
|
if (C(n6)) return t6.transaction("paste").setSelection(n6).build();
|
|
@@ -3794,17 +3926,17 @@
|
|
|
3794
3926
|
_(n6) || Pt(t6, o5);
|
|
3795
3927
|
const i3 = r4 ? r4.from.blockId : n6.anchor.blockId, s3 = r4 ? r4.from.offset : n6.anchor.offset, c2 = t6.getBlockOrder().indexOf(i3), l2 = e4.blocks[0], a2 = e4.blocks[e4.blocks.length - 1];
|
|
3796
3928
|
if (!l2 || !a2) return o5.build();
|
|
3797
|
-
const
|
|
3798
|
-
l2.segments.length > 0 && f2 > 0 && o5.insertText(i3, s3,
|
|
3929
|
+
const u2 = e4.blocks.slice(1, -1), f2 = ao(l2.segments);
|
|
3930
|
+
l2.segments.length > 0 && f2 > 0 && o5.insertText(i3, s3, lo(l2.segments), [], l2.segments), "paragraph" !== l2.type && o5.setBlockType(i3, l2.type, l2.attrs);
|
|
3799
3931
|
const g2 = s3 + f2, m2 = d();
|
|
3800
3932
|
o5.splitBlock(i3, g2, m2);
|
|
3801
3933
|
let b2 = c2 + 1;
|
|
3802
|
-
for (const t7 of
|
|
3803
|
-
const e5 = t7.segments.map((t8) => p(t8.text, [...t8.marks])), n7 =
|
|
3934
|
+
for (const t7 of u2) {
|
|
3935
|
+
const e5 = t7.segments.map((t8) => p(t8.text, [...t8.marks])), n7 = h(t7.type, e5.length > 0 ? e5 : void 0, d(), t7.attrs);
|
|
3804
3936
|
o5.insertNode([], b2, n7), b2++;
|
|
3805
3937
|
}
|
|
3806
|
-
const k2 =
|
|
3807
|
-
return a2.segments.length > 0 && k2 > 0 && o5.insertText(m2, 0,
|
|
3938
|
+
const k2 = ao(a2.segments);
|
|
3939
|
+
return a2.segments.length > 0 && k2 > 0 && o5.insertText(m2, 0, lo(a2.segments), [], a2.segments), "paragraph" !== a2.type && o5.setBlockType(m2, a2.type, a2.attrs), o5.setSelection(A(m2, k2)), o5.build();
|
|
3808
3940
|
})(t5, e3) : t5.transaction("paste").setSelection(t5.selection).build();
|
|
3809
3941
|
})(i2, e2.parse(n4.content));
|
|
3810
3942
|
this.dispatch(o4);
|
|
@@ -3832,16 +3964,16 @@
|
|
|
3832
3964
|
const n2 = e2.type;
|
|
3833
3965
|
if (!n2) return;
|
|
3834
3966
|
if (this.schemaRegistry && !this.schemaRegistry.getNodeSpec(n2)) return;
|
|
3835
|
-
const o2 = this.getState(), r2 = o2.selection, s2 = C(r2) ? r2.nodeId : r2.anchor.blockId, c2 = d(), l2 =
|
|
3967
|
+
const o2 = this.getState(), r2 = o2.selection, s2 = C(r2) ? r2.nodeId : r2.anchor.blockId, c2 = d(), l2 = h(n2, [], c2, e2.attrs ? e2.attrs : void 0), a2 = this.findTableCellAncestor(o2, s2);
|
|
3836
3968
|
if (a2) {
|
|
3837
|
-
const t3 =
|
|
3969
|
+
const t3 = U(o2.doc, a2);
|
|
3838
3970
|
if (!t3) return;
|
|
3839
3971
|
const e3 = o2.getBlock(a2);
|
|
3840
3972
|
if (!e3) return;
|
|
3841
3973
|
const n3 = o2.transaction("paste");
|
|
3842
3974
|
return n3.insertNode(t3, e3.children.length, l2), n3.setSelection(I(c2, [...t3, c2])), void this.dispatch(n3.build());
|
|
3843
3975
|
}
|
|
3844
|
-
const
|
|
3976
|
+
const u2 = U(o2.doc, s2), p2 = u2 && u2.length > 1 ? u2.slice(0, -1) : [], f2 = (0 === p2.length ? o2.doc.children : (() => {
|
|
3845
3977
|
const t3 = o2.getBlock(p2[p2.length - 1]);
|
|
3846
3978
|
return t3 ? t3.children : [];
|
|
3847
3979
|
})()).findIndex((t3) => i(t3) && t3.id === s2);
|
|
@@ -3865,42 +3997,42 @@
|
|
|
3865
3997
|
return r2 ? this.insertRichBlocksIntoCell(t2, e2, o2, r2) : this.insertRichBlocksAtRoot(t2, e2, o2);
|
|
3866
3998
|
}
|
|
3867
3999
|
insertRichBlocksIntoCell(t2, e2, n2, o2) {
|
|
3868
|
-
const r2 =
|
|
4000
|
+
const r2 = U(e2.doc, o2);
|
|
3869
4001
|
if (!r2) return false;
|
|
3870
4002
|
const s2 = e2.getBlock(o2);
|
|
3871
4003
|
if (!s2) return false;
|
|
3872
4004
|
const c2 = e2.getBlock(n2), l2 = s2.children.findIndex((t3) => i(t3) && t3.id === n2), a2 = void 0 !== c2 && "paragraph" === c2.type && "" === g(c2);
|
|
3873
|
-
let
|
|
4005
|
+
let u2 = l2 >= 0 ? l2 + 1 : s2.children.length;
|
|
3874
4006
|
const f2 = e2.transaction("paste");
|
|
3875
4007
|
let m2, b2 = 0;
|
|
3876
4008
|
for (const e3 of t2) {
|
|
3877
4009
|
if (!e3.type) continue;
|
|
3878
|
-
const t3 = d(), n3 = e3.text ?? "", o3 = n3 ? [p(n3)] : void 0, i2 = e3.attrs ? e3.attrs : void 0, s3 =
|
|
3879
|
-
f2.insertNode(r2,
|
|
4010
|
+
const t3 = d(), n3 = e3.text ?? "", o3 = n3 ? [p(n3)] : void 0, i2 = e3.attrs ? e3.attrs : void 0, s3 = h(H(e3.type), o3, t3, i2);
|
|
4011
|
+
f2.insertNode(r2, u2, s3), u2++, m2 = t3, b2 = n3.length;
|
|
3880
4012
|
}
|
|
3881
|
-
return a2 && l2 >= 0 && f2.removeNode(r2, l2), m2 && f2.setSelection(
|
|
4013
|
+
return a2 && l2 >= 0 && f2.removeNode(r2, l2), m2 && f2.setSelection(A(m2, b2)), this.dispatch(f2.build()), true;
|
|
3882
4014
|
}
|
|
3883
4015
|
insertRichBlocksAtRoot(t2, e2, n2) {
|
|
3884
|
-
const o2 =
|
|
4016
|
+
const o2 = U(e2.doc, n2), r2 = o2 && o2.length > 1 ? o2.slice(0, -1) : [], s2 = (0 === r2.length ? e2.doc.children : (() => {
|
|
3885
4017
|
const t3 = e2.getBlock(r2[r2.length - 1]);
|
|
3886
4018
|
return t3 ? t3.children : [];
|
|
3887
4019
|
})()).findIndex((t3) => i(t3) && t3.id === n2);
|
|
3888
4020
|
if (s2 < 0) return false;
|
|
3889
4021
|
const c2 = e2.getBlock(n2), l2 = void 0 !== c2 && "paragraph" === c2.type && "" === g(c2);
|
|
3890
4022
|
let a2 = s2 + 1;
|
|
3891
|
-
const
|
|
4023
|
+
const u2 = e2.transaction("paste");
|
|
3892
4024
|
let f2, m2 = 0;
|
|
3893
4025
|
for (const e3 of t2) {
|
|
3894
4026
|
if (!e3.type) continue;
|
|
3895
|
-
const t3 = d(), n3 = e3.text ?? "", o3 = n3 ? [p(n3)] : void 0, i2 = e3.attrs ? e3.attrs : void 0, s3 =
|
|
3896
|
-
|
|
4027
|
+
const t3 = d(), n3 = e3.text ?? "", o3 = n3 ? [p(n3)] : void 0, i2 = e3.attrs ? e3.attrs : void 0, s3 = h(H(e3.type), o3, t3, i2);
|
|
4028
|
+
u2.insertNode(r2, a2, s3), a2++, f2 = t3, m2 = n3.length;
|
|
3897
4029
|
}
|
|
3898
|
-
return l2 &&
|
|
4030
|
+
return l2 && u2.removeNode(r2, s2), f2 && u2.setSelection(A(f2, m2)), this.dispatch(u2.build()), true;
|
|
3899
4031
|
}
|
|
3900
4032
|
findTableCellAncestor(t2, e2) {
|
|
3901
4033
|
const n2 = t2.getBlock(e2);
|
|
3902
4034
|
if ("table_cell" === n2?.type) return e2;
|
|
3903
|
-
const o2 =
|
|
4035
|
+
const o2 = U(t2.doc, e2);
|
|
3904
4036
|
if (o2) for (const e3 of o2) {
|
|
3905
4037
|
const n3 = t2.getBlock(e3);
|
|
3906
4038
|
if ("table_cell" === n3?.type) return e3;
|
|
@@ -3941,7 +4073,7 @@
|
|
|
3941
4073
|
this.element.removeEventListener("paste", this.handlePaste);
|
|
3942
4074
|
}
|
|
3943
4075
|
}
|
|
3944
|
-
function
|
|
4076
|
+
function go(t2, e2, n2, o2) {
|
|
3945
4077
|
const r2 = e2?.doc.children ?? [], i2 = n2.doc.children, c2 = o2?.registry, l2 = o2?.nodeViews;
|
|
3946
4078
|
!(function(t3) {
|
|
3947
4079
|
const e3 = Array.from(t3.querySelectorAll(":scope > [data-block-wrapper]"));
|
|
@@ -3961,13 +4093,13 @@
|
|
|
3961
4093
|
const o3 = l2?.get(e3);
|
|
3962
4094
|
o3 && (o3.destroy?.(), l2?.delete(e3));
|
|
3963
4095
|
}
|
|
3964
|
-
const
|
|
3965
|
-
for (const t3 of r2)
|
|
3966
|
-
let
|
|
4096
|
+
const u2 = /* @__PURE__ */ new Map();
|
|
4097
|
+
for (const t3 of r2) u2.set(t3.id, t3);
|
|
4098
|
+
let h2 = null;
|
|
3967
4099
|
const p2 = o2?.selectedNodeId, f2 = o2?.previousSelectedNodeId;
|
|
3968
4100
|
for (const e3 of i2) {
|
|
3969
|
-
const n3 = a2.get(e3.id), r3 =
|
|
3970
|
-
if (n3 && r3 && !
|
|
4101
|
+
const n3 = a2.get(e3.id), r3 = u2.get(e3.id), i3 = o2?.oldDecorations?.find(e3.id), d3 = o2?.decorations?.find(e3.id);
|
|
4102
|
+
if (n3 && r3 && !mo(r3, e3, i3, d3)) h2 = n3;
|
|
3971
4103
|
else if (n3) {
|
|
3972
4104
|
const r4 = l2?.get(e3.id);
|
|
3973
4105
|
if (r4) {
|
|
@@ -3975,31 +4107,31 @@
|
|
|
3975
4107
|
if (s(e3) && r4.contentDOM) {
|
|
3976
4108
|
r4.contentDOM.textContent = "";
|
|
3977
4109
|
const t3 = o2?.decorations?.findInline(e3.id);
|
|
3978
|
-
|
|
4110
|
+
ko(r4.contentDOM, e3, c2, t3);
|
|
3979
4111
|
}
|
|
3980
|
-
|
|
4112
|
+
h2 = r4.dom;
|
|
3981
4113
|
continue;
|
|
3982
4114
|
}
|
|
3983
4115
|
r4.destroy?.(), l2?.delete(e3.id);
|
|
3984
4116
|
}
|
|
3985
|
-
const i4 =
|
|
3986
|
-
t2.replaceChild(i4, n3),
|
|
4117
|
+
const i4 = bo(e3, c2, l2, o2);
|
|
4118
|
+
t2.replaceChild(i4, n3), h2 = i4;
|
|
3987
4119
|
} else {
|
|
3988
|
-
const n4 =
|
|
3989
|
-
|
|
4120
|
+
const n4 = bo(e3, c2, l2, o2);
|
|
4121
|
+
h2?.nextSibling ? t2.insertBefore(n4, h2.nextSibling) : !h2 && t2.firstChild ? t2.insertBefore(n4, t2.firstChild) : t2.appendChild(n4), h2 = n4;
|
|
3990
4122
|
}
|
|
3991
4123
|
if (p2 === e3.id) {
|
|
3992
4124
|
const t3 = l2?.get(e3.id);
|
|
3993
4125
|
if (t3) t3.selectNode?.();
|
|
3994
4126
|
else {
|
|
3995
|
-
const t4 = a2.get(e3.id) ??
|
|
4127
|
+
const t4 = a2.get(e3.id) ?? h2;
|
|
3996
4128
|
t4 instanceof HTMLElement && t4.classList.add("notectl-node-selected");
|
|
3997
4129
|
}
|
|
3998
4130
|
} else if (f2 === e3.id) {
|
|
3999
4131
|
const t3 = l2?.get(e3.id);
|
|
4000
4132
|
if (t3) t3.deselectNode?.();
|
|
4001
4133
|
else {
|
|
4002
|
-
const t4 = a2.get(e3.id) ??
|
|
4134
|
+
const t4 = a2.get(e3.id) ?? h2;
|
|
4003
4135
|
t4 instanceof HTMLElement && t4.classList.remove("notectl-node-selected");
|
|
4004
4136
|
}
|
|
4005
4137
|
}
|
|
@@ -4012,9 +4144,9 @@
|
|
|
4012
4144
|
const t3 = l2?.get(p2);
|
|
4013
4145
|
t3 && t3.selectNode?.();
|
|
4014
4146
|
}
|
|
4015
|
-
|
|
4147
|
+
Bo(t2, i2, c2);
|
|
4016
4148
|
}
|
|
4017
|
-
function
|
|
4149
|
+
function mo(t2, e2, n2, i2) {
|
|
4018
4150
|
if (t2.type !== e2.type) return true;
|
|
4019
4151
|
if (t2.children.length !== e2.children.length) return true;
|
|
4020
4152
|
const s2 = t2.attrs, c2 = e2.attrs;
|
|
@@ -4032,16 +4164,16 @@
|
|
|
4032
4164
|
if (!k(i3.marks, s3.marks)) return true;
|
|
4033
4165
|
} else if (r(i3) && r(s3)) {
|
|
4034
4166
|
if (i3.inlineType !== s3.inlineType) return true;
|
|
4035
|
-
if (!
|
|
4167
|
+
if (!wo(i3.attrs, s3.attrs)) return true;
|
|
4036
4168
|
} else {
|
|
4037
4169
|
if (o(i3) || o(s3) || r(i3) || r(s3)) return true;
|
|
4038
|
-
if (
|
|
4170
|
+
if (mo(i3, s3)) return true;
|
|
4039
4171
|
}
|
|
4040
4172
|
}
|
|
4041
4173
|
const l2 = n2 ?? [], a2 = i2 ?? [];
|
|
4042
|
-
return l2 !== a2 && !
|
|
4174
|
+
return l2 !== a2 && !Xt(l2, a2);
|
|
4043
4175
|
}
|
|
4044
|
-
function
|
|
4176
|
+
function bo(t2, e2, n2, o2) {
|
|
4045
4177
|
const r2 = o2?.decorations?.findInline(t2.id);
|
|
4046
4178
|
if (e2 && n2 && o2?.getState && o2?.dispatch) {
|
|
4047
4179
|
const i2 = e2.getNodeViewFactory(t2.type);
|
|
@@ -4049,52 +4181,52 @@
|
|
|
4049
4181
|
const c2 = i2(t2, o2.getState, o2.dispatch);
|
|
4050
4182
|
n2.set(t2.id, c2);
|
|
4051
4183
|
const l2 = e2.getNodeSpec(t2.type);
|
|
4052
|
-
if (l2?.isVoid && c2.dom.setAttribute("data-void", "true"), l2?.selectable && c2.dom.setAttribute("data-selectable", "true"), c2.contentDOM && c2.contentDOM !== c2.dom && c2.contentDOM.setAttribute("data-content-dom", "true"), s(t2) && c2.contentDOM)
|
|
4184
|
+
if (l2?.isVoid && c2.dom.setAttribute("data-void", "true"), l2?.selectable && c2.dom.setAttribute("data-selectable", "true"), c2.contentDOM && c2.contentDOM !== c2.dom && c2.contentDOM.setAttribute("data-content-dom", "true"), s(t2) && c2.contentDOM) ko(c2.contentDOM, t2, e2, r2);
|
|
4053
4185
|
else {
|
|
4054
4186
|
const r3 = a(t2), i3 = /* @__PURE__ */ new Map();
|
|
4055
4187
|
for (const t3 of r3) {
|
|
4056
4188
|
const r4 = c2.getContentDOM?.(t3.id) ?? c2.contentDOM;
|
|
4057
4189
|
if (r4) {
|
|
4058
|
-
const s2 =
|
|
4190
|
+
const s2 = bo(t3, e2, n2, o2);
|
|
4059
4191
|
r4.appendChild(s2);
|
|
4060
4192
|
let c3 = i3.get(r4);
|
|
4061
4193
|
c3 || (c3 = [], i3.set(r4, c3)), c3.push(t3);
|
|
4062
4194
|
}
|
|
4063
4195
|
}
|
|
4064
|
-
for (const [t3, n3] of i3)
|
|
4196
|
+
for (const [t3, n3] of i3) Bo(t3, n3, e2);
|
|
4065
4197
|
}
|
|
4066
|
-
return
|
|
4198
|
+
return c2.dom.setAttribute("data-block-type", t2.type), To(c2.dom, t2.id, o2), c2.dom;
|
|
4067
4199
|
}
|
|
4068
4200
|
}
|
|
4069
4201
|
if (e2) {
|
|
4070
4202
|
const i2 = e2.getNodeSpec(t2.type);
|
|
4071
4203
|
if (i2) {
|
|
4072
4204
|
const c2 = i2.toDOM(t2);
|
|
4073
|
-
if (i2.isVoid && c2.setAttribute("data-void", "true"), i2.selectable && c2.setAttribute("data-selectable", "true"), !i2.isVoid) if (s(t2))
|
|
4205
|
+
if (i2.isVoid && c2.setAttribute("data-void", "true"), i2.selectable && c2.setAttribute("data-selectable", "true"), !i2.isVoid) if (s(t2)) ko(c2, t2, e2, r2);
|
|
4074
4206
|
else {
|
|
4075
4207
|
const r3 = a(t2);
|
|
4076
4208
|
for (const t3 of r3) {
|
|
4077
|
-
const r4 =
|
|
4209
|
+
const r4 = bo(t3, e2, n2, o2);
|
|
4078
4210
|
c2.appendChild(r4);
|
|
4079
4211
|
}
|
|
4080
|
-
|
|
4212
|
+
Bo(c2, r3, e2);
|
|
4081
4213
|
}
|
|
4082
|
-
return
|
|
4214
|
+
return c2.setAttribute("data-block-type", t2.type), To(c2, t2.id, o2), c2;
|
|
4083
4215
|
}
|
|
4084
4216
|
}
|
|
4085
4217
|
return (function(t3, e3, n3) {
|
|
4086
4218
|
const o3 = F("p", t3.id);
|
|
4087
|
-
return
|
|
4219
|
+
return o3.setAttribute("data-block-type", t3.type), ko(o3, t3, e3, n3), o3;
|
|
4088
4220
|
})(t2, e2, r2);
|
|
4089
4221
|
}
|
|
4090
|
-
function
|
|
4222
|
+
function ko(t2, e2, n2, i2) {
|
|
4091
4223
|
const s2 = l(e2);
|
|
4092
4224
|
if (1 === s2.length && o(s2[0]) && "" === s2[0].text) return void t2.appendChild(document.createElement("br"));
|
|
4093
4225
|
if (i2 && 0 !== i2.length) !(function(t3, e3, n3, o2) {
|
|
4094
4226
|
let i3 = 0;
|
|
4095
4227
|
for (const s3 of e3) {
|
|
4096
4228
|
if (r(s3)) {
|
|
4097
|
-
t3.appendChild(
|
|
4229
|
+
t3.appendChild(xo(s3, o2)), i3 += 1;
|
|
4098
4230
|
continue;
|
|
4099
4231
|
}
|
|
4100
4232
|
const e4 = i3, c3 = i3 + s3.text.length;
|
|
@@ -4112,20 +4244,20 @@
|
|
|
4112
4244
|
for (let r2 = 0; r2 < a2.length - 1; r2++) {
|
|
4113
4245
|
const i4 = a2[r2], c4 = a2[r2 + 1];
|
|
4114
4246
|
if (void 0 === i4 || void 0 === c4 || i4 >= c4) continue;
|
|
4115
|
-
const l3 = i4 - e4, d2 = c4 - e4,
|
|
4116
|
-
for (const t4 of n3) t4.from <= i4 && t4.to >= c4 &&
|
|
4117
|
-
let p2 = document.createTextNode(
|
|
4247
|
+
const l3 = i4 - e4, d2 = c4 - e4, u2 = s3.text.slice(l3, d2), h2 = [];
|
|
4248
|
+
for (const t4 of n3) t4.from <= i4 && t4.to >= c4 && h2.push(t4);
|
|
4249
|
+
let p2 = document.createTextNode(yo(u2));
|
|
4118
4250
|
if (s3.marks.length > 0) {
|
|
4119
|
-
const t4 = [...s3.marks].sort((t5, e5) =>
|
|
4251
|
+
const t4 = [...s3.marks].sort((t5, e5) => So(t5, o2) - So(e5, o2));
|
|
4120
4252
|
for (let e5 = t4.length - 1; e5 >= 0; e5--) {
|
|
4121
4253
|
const n4 = t4[e5];
|
|
4122
4254
|
if (!n4) continue;
|
|
4123
|
-
const r3 =
|
|
4255
|
+
const r3 = Io(n4, o2);
|
|
4124
4256
|
r3.appendChild(p2), p2 = r3;
|
|
4125
4257
|
}
|
|
4126
4258
|
}
|
|
4127
|
-
for (const t4 of
|
|
4128
|
-
const e5 =
|
|
4259
|
+
for (const t4 of h2) {
|
|
4260
|
+
const e5 = Co(t4.attrs);
|
|
4129
4261
|
e5.appendChild(p2), p2 = e5;
|
|
4130
4262
|
}
|
|
4131
4263
|
t3.appendChild(p2);
|
|
@@ -4133,29 +4265,29 @@
|
|
|
4133
4265
|
i3 = c3;
|
|
4134
4266
|
}
|
|
4135
4267
|
})(t2, s2, i2, n2);
|
|
4136
|
-
else for (const e3 of s2) o(e3) ? t2.appendChild(
|
|
4268
|
+
else for (const e3 of s2) o(e3) ? t2.appendChild(vo(e3, n2)) : t2.appendChild(xo(e3, n2));
|
|
4137
4269
|
const c2 = s2[s2.length - 1];
|
|
4138
4270
|
c2 && r(c2) && "hard_break" === c2.inlineType && t2.appendChild(document.createElement("br"));
|
|
4139
4271
|
}
|
|
4140
|
-
function
|
|
4272
|
+
function yo(t2) {
|
|
4141
4273
|
let e2 = t2.replace(/ {2}/g, " ");
|
|
4142
4274
|
return e2.endsWith(" ") && (e2 = `${e2.slice(0, -1)} `), e2.startsWith(" ") && (e2 = ` ${e2.slice(1)}`), e2;
|
|
4143
4275
|
}
|
|
4144
|
-
function
|
|
4276
|
+
function vo(t2, e2) {
|
|
4145
4277
|
if ("" === t2.text) return document.createTextNode("");
|
|
4146
|
-
const n2 = document.createTextNode(
|
|
4278
|
+
const n2 = document.createTextNode(yo(t2.text));
|
|
4147
4279
|
if (0 === t2.marks.length) return n2;
|
|
4148
|
-
const o2 = [...t2.marks].sort((t3, n3) =>
|
|
4280
|
+
const o2 = [...t2.marks].sort((t3, n3) => So(t3, e2) - So(n3, e2));
|
|
4149
4281
|
let r2 = n2;
|
|
4150
4282
|
for (let t3 = o2.length - 1; t3 >= 0; t3--) {
|
|
4151
4283
|
const n3 = o2[t3];
|
|
4152
4284
|
if (!n3) continue;
|
|
4153
|
-
const i2 =
|
|
4285
|
+
const i2 = Io(n3, e2);
|
|
4154
4286
|
i2.appendChild(r2), r2 = i2;
|
|
4155
4287
|
}
|
|
4156
4288
|
return r2;
|
|
4157
4289
|
}
|
|
4158
|
-
function
|
|
4290
|
+
function xo(t2, e2) {
|
|
4159
4291
|
if (e2) {
|
|
4160
4292
|
const n3 = e2.getInlineNodeSpec(t2.inlineType);
|
|
4161
4293
|
if (n3) {
|
|
@@ -4166,13 +4298,13 @@
|
|
|
4166
4298
|
const n2 = document.createElement("span");
|
|
4167
4299
|
return n2.setAttribute("data-inline-type", t2.inlineType), n2.setAttribute("contenteditable", "false"), n2;
|
|
4168
4300
|
}
|
|
4169
|
-
function
|
|
4301
|
+
function wo(t2, e2) {
|
|
4170
4302
|
const n2 = Object.keys(t2), o2 = Object.keys(e2);
|
|
4171
4303
|
if (n2.length !== o2.length) return false;
|
|
4172
4304
|
for (const o3 of n2) if (t2[o3] !== e2[o3]) return false;
|
|
4173
4305
|
return true;
|
|
4174
4306
|
}
|
|
4175
|
-
function
|
|
4307
|
+
function So(t2, e2) {
|
|
4176
4308
|
if (e2) {
|
|
4177
4309
|
const n2 = e2.getMarkSpec(t2.type);
|
|
4178
4310
|
if (n2) return n2.rank ?? 100;
|
|
@@ -4188,7 +4320,7 @@
|
|
|
4188
4320
|
return 100;
|
|
4189
4321
|
}
|
|
4190
4322
|
}
|
|
4191
|
-
function
|
|
4323
|
+
function Io(t2, e2) {
|
|
4192
4324
|
if (e2) {
|
|
4193
4325
|
const n2 = e2.getMarkSpec(t2.type);
|
|
4194
4326
|
if (n2) return n2.toDOM(t2);
|
|
@@ -4204,14 +4336,14 @@
|
|
|
4204
4336
|
return document.createElement("span");
|
|
4205
4337
|
}
|
|
4206
4338
|
}
|
|
4207
|
-
function
|
|
4339
|
+
function Co(t2) {
|
|
4208
4340
|
const e2 = t2.nodeName ?? "span", n2 = document.createElement(e2);
|
|
4209
4341
|
if (n2.setAttribute("data-decoration", "true"), t2.class) for (const e3 of t2.class.split(" ")) e3 && n2.classList.add(e3);
|
|
4210
4342
|
t2.style && (n2.style.cssText = t2.style);
|
|
4211
4343
|
for (const [e3, o2] of Object.entries(t2)) "class" !== e3 && "style" !== e3 && "nodeName" !== e3 && void 0 !== o2 && n2.setAttribute(e3, o2);
|
|
4212
4344
|
return n2;
|
|
4213
4345
|
}
|
|
4214
|
-
function
|
|
4346
|
+
function To(t2, e2, n2) {
|
|
4215
4347
|
const o2 = n2?.decorations?.findNode(e2);
|
|
4216
4348
|
if (o2 && 0 !== o2.length) for (const e3 of o2) {
|
|
4217
4349
|
if (e3.attrs.class) for (const n3 of e3.attrs.class.split(" ")) n3 && t2.classList.add(n3);
|
|
@@ -4221,7 +4353,7 @@
|
|
|
4221
4353
|
}
|
|
4222
4354
|
}
|
|
4223
4355
|
}
|
|
4224
|
-
function
|
|
4356
|
+
function Bo(t2, e2, n2) {
|
|
4225
4357
|
if (!n2) return;
|
|
4226
4358
|
const o2 = [];
|
|
4227
4359
|
let r2 = null, i2 = [];
|
|
@@ -4242,32 +4374,32 @@
|
|
|
4242
4374
|
}
|
|
4243
4375
|
}
|
|
4244
4376
|
}
|
|
4245
|
-
function
|
|
4377
|
+
function Eo(t2) {
|
|
4246
4378
|
const e2 = t2.getRootNode();
|
|
4247
4379
|
return e2 instanceof ShadowRoot && "getSelection" in e2 ? e2.getSelection() : window.getSelection();
|
|
4248
4380
|
}
|
|
4249
|
-
function
|
|
4250
|
-
const n2 =
|
|
4381
|
+
function Mo(t2, e2) {
|
|
4382
|
+
const n2 = Eo(t2);
|
|
4251
4383
|
if (!n2) return;
|
|
4252
4384
|
if (C(e2)) {
|
|
4253
4385
|
const o3 = t2.querySelector(`[data-block-id="${e2.nodeId}"]`);
|
|
4254
4386
|
if (!o3) return;
|
|
4255
4387
|
const r3 = o3.parentNode;
|
|
4256
4388
|
if (!r3) return;
|
|
4257
|
-
const i2 =
|
|
4389
|
+
const i2 = No(r3, o3);
|
|
4258
4390
|
try {
|
|
4259
4391
|
n2.setBaseAndExtent(r3, i2, r3, i2 + 1);
|
|
4260
4392
|
} catch {
|
|
4261
4393
|
}
|
|
4262
4394
|
return;
|
|
4263
4395
|
}
|
|
4264
|
-
const o2 =
|
|
4396
|
+
const o2 = Ao(t2, e2.anchor), r2 = Ao(t2, e2.head);
|
|
4265
4397
|
if (o2 && r2) try {
|
|
4266
4398
|
n2.setBaseAndExtent(o2.node, o2.offset, r2.node, r2.offset);
|
|
4267
4399
|
} catch {
|
|
4268
4400
|
}
|
|
4269
4401
|
}
|
|
4270
|
-
function
|
|
4402
|
+
function Ao(t2, e2) {
|
|
4271
4403
|
let n2 = null;
|
|
4272
4404
|
if (e2.path && e2.path.length > 0) {
|
|
4273
4405
|
let o3 = t2;
|
|
@@ -4279,10 +4411,10 @@
|
|
|
4279
4411
|
o3 !== t2 && o3.getAttribute("data-block-id") === e2.blockId && (n2 = o3);
|
|
4280
4412
|
}
|
|
4281
4413
|
if (n2 ??= t2.querySelector(`[data-block-id="${e2.blockId}"]`), !n2) return null;
|
|
4282
|
-
const o2 =
|
|
4414
|
+
const o2 = zo(n2);
|
|
4283
4415
|
if (1 === o2.childNodes.length && "BR" === o2.firstChild?.nodeName) return { node: o2, offset: 0 };
|
|
4284
4416
|
let r2 = e2.offset;
|
|
4285
|
-
const i2 =
|
|
4417
|
+
const i2 = Lo(o2);
|
|
4286
4418
|
let s2 = i2.nextNode();
|
|
4287
4419
|
for (; s2; ) {
|
|
4288
4420
|
if (s2.nodeType === Node.TEXT_NODE) {
|
|
@@ -4292,7 +4424,7 @@
|
|
|
4292
4424
|
} else if (s2 instanceof HTMLElement && "false" === s2.getAttribute("contenteditable")) {
|
|
4293
4425
|
if (0 === r2) {
|
|
4294
4426
|
const t3 = s2.parentNode;
|
|
4295
|
-
if (t3) return { node: t3, offset:
|
|
4427
|
+
if (t3) return { node: t3, offset: No(t3, s2) };
|
|
4296
4428
|
}
|
|
4297
4429
|
r2 -= 1;
|
|
4298
4430
|
}
|
|
@@ -4301,7 +4433,7 @@
|
|
|
4301
4433
|
const c2 = o2.lastChild;
|
|
4302
4434
|
return c2 ? c2.nodeType === Node.TEXT_NODE ? { node: c2, offset: c2.textContent?.length ?? 0 } : { node: o2, offset: o2.childNodes.length } : { node: o2, offset: 0 };
|
|
4303
4435
|
}
|
|
4304
|
-
function
|
|
4436
|
+
function _o(t2, e2, n2) {
|
|
4305
4437
|
const o2 = (function(t3, e3) {
|
|
4306
4438
|
let n3 = e3;
|
|
4307
4439
|
for (; n3 && n3 !== t3; ) {
|
|
@@ -4318,35 +4450,35 @@
|
|
|
4318
4450
|
let o3 = e3;
|
|
4319
4451
|
for (; o3 && o3 !== t3; ) o3.hasAttribute("data-block-id") && n3.unshift(R(o3.getAttribute("data-block-id") ?? "")), o3 = o3.parentElement;
|
|
4320
4452
|
return n3;
|
|
4321
|
-
})(t2, o2), c2 =
|
|
4453
|
+
})(t2, o2), c2 = zo(o2);
|
|
4322
4454
|
if (e2 === o2 || e2 === c2) {
|
|
4323
4455
|
const t3 = e2 === c2 ? c2 : o2;
|
|
4324
4456
|
let r3 = 0, l3 = 0;
|
|
4325
4457
|
for (const e3 of Array.from(t3.childNodes)) {
|
|
4326
4458
|
if (l3 >= n2) break;
|
|
4327
|
-
r3 +=
|
|
4459
|
+
r3 += Po(e3), l3++;
|
|
4328
4460
|
}
|
|
4329
|
-
return
|
|
4461
|
+
return E(i2, r3, s2.length > 1 ? s2 : void 0);
|
|
4330
4462
|
}
|
|
4331
|
-
if (c2 !== o2 && !c2.contains(e2)) return
|
|
4463
|
+
if (c2 !== o2 && !c2.contains(e2)) return E(i2, 0, s2.length > 1 ? s2 : void 0);
|
|
4332
4464
|
let l2 = 0;
|
|
4333
|
-
const a2 =
|
|
4465
|
+
const a2 = Lo(c2);
|
|
4334
4466
|
let d2 = a2.nextNode();
|
|
4335
4467
|
for (; d2; ) {
|
|
4336
|
-
if (d2 === e2) return d2.nodeType === Node.TEXT_NODE ?
|
|
4468
|
+
if (d2 === e2) return d2.nodeType === Node.TEXT_NODE ? E(i2, l2 + n2, s2.length > 1 ? s2 : void 0) : E(i2, l2, s2.length > 1 ? s2 : void 0);
|
|
4337
4469
|
d2.nodeType === Node.TEXT_NODE ? l2 += d2.textContent?.length ?? 0 : d2 instanceof HTMLElement && "false" === d2.getAttribute("contenteditable") && (l2 += 1), d2 = a2.nextNode();
|
|
4338
4470
|
}
|
|
4339
4471
|
if (e2.nodeType === Node.ELEMENT_NODE) {
|
|
4340
4472
|
let t3 = 0, o3 = 0;
|
|
4341
4473
|
for (const r3 of Array.from(e2.childNodes)) {
|
|
4342
4474
|
if (o3 >= n2) break;
|
|
4343
|
-
t3 +=
|
|
4475
|
+
t3 += Po(r3), o3++;
|
|
4344
4476
|
}
|
|
4345
|
-
return
|
|
4477
|
+
return E(i2, t3, s2.length > 1 ? s2 : void 0);
|
|
4346
4478
|
}
|
|
4347
|
-
return
|
|
4479
|
+
return E(i2, 0, s2.length > 1 ? s2 : void 0);
|
|
4348
4480
|
}
|
|
4349
|
-
function
|
|
4481
|
+
function Lo(t2) {
|
|
4350
4482
|
return document.createTreeWalker(t2, NodeFilter.SHOW_ALL, { acceptNode: (e2) => (function(t3, e3) {
|
|
4351
4483
|
let n2 = t3.parentNode;
|
|
4352
4484
|
for (; n2 && n2 !== e3; ) {
|
|
@@ -4356,7 +4488,7 @@
|
|
|
4356
4488
|
return false;
|
|
4357
4489
|
})(e2, t2) || e2 instanceof HTMLElement && e2.hasAttribute("data-block-id") && e2 !== t2 ? NodeFilter.FILTER_REJECT : e2.nodeType === Node.TEXT_NODE || e2 instanceof HTMLElement && "false" === e2.getAttribute("contenteditable") ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP });
|
|
4358
4490
|
}
|
|
4359
|
-
function
|
|
4491
|
+
function No(t2, e2) {
|
|
4360
4492
|
let n2 = 0;
|
|
4361
4493
|
for (const o2 of Array.from(t2.childNodes)) {
|
|
4362
4494
|
if (o2 === e2) return n2;
|
|
@@ -4364,17 +4496,17 @@
|
|
|
4364
4496
|
}
|
|
4365
4497
|
return n2;
|
|
4366
4498
|
}
|
|
4367
|
-
function
|
|
4499
|
+
function zo(t2) {
|
|
4368
4500
|
return t2.querySelector("[data-content-dom]") ?? t2;
|
|
4369
4501
|
}
|
|
4370
|
-
function
|
|
4502
|
+
function Po(t2) {
|
|
4371
4503
|
if (t2.nodeType === Node.TEXT_NODE) return t2.textContent?.length ?? 0;
|
|
4372
4504
|
if (t2 instanceof HTMLElement && "false" === t2.getAttribute("contenteditable")) return 1;
|
|
4373
4505
|
let e2 = 0;
|
|
4374
|
-
for (const n2 of Array.from(t2.childNodes)) e2 +=
|
|
4506
|
+
for (const n2 of Array.from(t2.childNodes)) e2 += Po(n2);
|
|
4375
4507
|
return e2;
|
|
4376
4508
|
}
|
|
4377
|
-
class
|
|
4509
|
+
class Ro {
|
|
4378
4510
|
state;
|
|
4379
4511
|
contentElement;
|
|
4380
4512
|
inputHandler;
|
|
@@ -4391,10 +4523,10 @@
|
|
|
4391
4523
|
pendingNodeSelectionClear = false;
|
|
4392
4524
|
schemaRegistry;
|
|
4393
4525
|
nodeViews = /* @__PURE__ */ new Map();
|
|
4394
|
-
decorations =
|
|
4526
|
+
decorations = Gt.empty;
|
|
4395
4527
|
getDecorations;
|
|
4396
4528
|
constructor(t2, e2) {
|
|
4397
|
-
this.state = e2.state, this.contentElement = t2, this.schemaRegistry = e2.schemaRegistry, this.getDecorations = e2.getDecorations, this.history = new ft({ maxDepth: e2.maxHistoryDepth ?? 100 }), e2.onStateChange && this.stateChangeCallbacks.push(e2.onStateChange), this.inputHandler = new
|
|
4529
|
+
this.state = e2.state, this.contentElement = t2, this.schemaRegistry = e2.schemaRegistry, this.getDecorations = e2.getDecorations, this.history = new ft({ maxDepth: e2.maxHistoryDepth ?? 100 }), e2.onStateChange && this.stateChangeCallbacks.push(e2.onStateChange), this.inputHandler = new co(t2, { getState: () => this.state, dispatch: (t3) => this.dispatch(t3), syncSelection: () => this.syncSelectionFromDOM(), schemaRegistry: this.schemaRegistry }), this.keyboardHandler = new Ht(t2, { getState: () => this.state, dispatch: (t3) => this.dispatch(t3), undo: () => this.undo(), redo: () => this.redo(), schemaRegistry: this.schemaRegistry }), this.pasteHandler = new fo(t2, { getState: () => this.state, dispatch: (t3) => this.dispatch(t3), schemaRegistry: this.schemaRegistry }), this.clipboardHandler = new $t(t2, { getState: () => this.state, dispatch: (t3) => this.dispatch(t3), schemaRegistry: this.schemaRegistry, syncSelection: () => this.syncSelectionFromDOM() }), this.handleSelectionChange = this.onSelectionChange.bind(this), document.addEventListener("selectionchange", this.handleSelectionChange), this.handleMousedown = this.onMousedown.bind(this), t2.addEventListener("mousedown", this.handleMousedown), this.handleDragover = this.onDragover.bind(this), t2.addEventListener("dragover", this.handleDragover), this.handleDrop = this.onDrop.bind(this), t2.addEventListener("drop", this.handleDrop), this.decorations = this.getDecorations?.(this.state) ?? Gt.empty, go(t2, null, this.state, { ...this.reconcileOptions(), decorations: this.decorations }), Mo(t2, this.state.selection);
|
|
4398
4530
|
}
|
|
4399
4531
|
getState() {
|
|
4400
4532
|
return this.state;
|
|
@@ -4405,8 +4537,8 @@
|
|
|
4405
4537
|
try {
|
|
4406
4538
|
const o2 = this.state;
|
|
4407
4539
|
this.state = t2, n2?.pushHistory && "history" !== e2.metadata.origin && this.history.push(e2);
|
|
4408
|
-
const r2 = this.decorations, i2 = this.getDecorations?.(t2, e2) ??
|
|
4409
|
-
this.decorations = i2,
|
|
4540
|
+
const r2 = this.decorations, i2 = this.getDecorations?.(t2, e2) ?? Gt.empty;
|
|
4541
|
+
this.decorations = i2, go(this.contentElement, o2, t2, { ...this.reconcileOptions(o2.selection), decorations: i2, oldDecorations: r2 }), Mo(this.contentElement, t2.selection);
|
|
4410
4542
|
for (const n3 of this.stateChangeCallbacks) n3(o2, t2, e2);
|
|
4411
4543
|
} finally {
|
|
4412
4544
|
this.isUpdating = false;
|
|
@@ -4439,8 +4571,8 @@
|
|
|
4439
4571
|
try {
|
|
4440
4572
|
const e2 = this.state;
|
|
4441
4573
|
this.state = t2, this.history.clear();
|
|
4442
|
-
const n2 = this.decorations, o2 = this.getDecorations?.(t2) ??
|
|
4443
|
-
this.decorations = o2,
|
|
4574
|
+
const n2 = this.decorations, o2 = this.getDecorations?.(t2) ?? Gt.empty;
|
|
4575
|
+
this.decorations = o2, go(this.contentElement, e2, t2, { ...this.reconcileOptions(e2.selection), decorations: o2, oldDecorations: n2 }), Mo(this.contentElement, t2.selection);
|
|
4444
4576
|
} finally {
|
|
4445
4577
|
this.isUpdating = false;
|
|
4446
4578
|
}
|
|
@@ -4450,13 +4582,13 @@
|
|
|
4450
4582
|
if (C(this.state.selection) && !this.pendingNodeSelectionClear) return;
|
|
4451
4583
|
this.pendingNodeSelectionClear = false;
|
|
4452
4584
|
const t2 = (function(t3) {
|
|
4453
|
-
const e3 =
|
|
4585
|
+
const e3 = Eo(t3);
|
|
4454
4586
|
if (!e3 || 0 === e3.rangeCount) return null;
|
|
4455
4587
|
const n3 = e3.anchorNode, o2 = e3.focusNode;
|
|
4456
4588
|
if (!n3 || !o2) return null;
|
|
4457
4589
|
if (!t3.contains(n3) || !t3.contains(o2)) return null;
|
|
4458
|
-
const r2 =
|
|
4459
|
-
return r2 && i2 ?
|
|
4590
|
+
const r2 = _o(t3, n3, e3.anchorOffset), i2 = _o(t3, o2, e3.focusOffset);
|
|
4591
|
+
return r2 && i2 ? M(r2, i2) : null;
|
|
4460
4592
|
})(this.contentElement);
|
|
4461
4593
|
if (!t2) return;
|
|
4462
4594
|
if (B(t2, this.state.selection)) return;
|
|
@@ -4485,11 +4617,11 @@
|
|
|
4485
4617
|
if (t2.clientY <= r2.bottom) return;
|
|
4486
4618
|
const i2 = this.state.getBlock(n2);
|
|
4487
4619
|
if ("paragraph" === i2?.type && 0 === m(i2)) {
|
|
4488
|
-
const e3 = this.state.transaction("input").setSelection(
|
|
4620
|
+
const e3 = this.state.transaction("input").setSelection(A(n2, 0)).build();
|
|
4489
4621
|
return this.dispatch(e3), void t2.preventDefault();
|
|
4490
4622
|
}
|
|
4491
4623
|
t2.preventDefault(), this.contentElement.focus();
|
|
4492
|
-
const s2 = d(), c2 = i2 ? m(i2) : 0, l2 = this.state.transaction("input").splitBlock(n2, c2, s2).setBlockType(s2, "paragraph").setSelection(
|
|
4624
|
+
const s2 = d(), c2 = i2 ? m(i2) : 0, l2 = this.state.transaction("input").splitBlock(n2, c2, s2).setBlockType(s2, "paragraph").setSelection(A(s2, 0)).build();
|
|
4493
4625
|
this.dispatch(l2);
|
|
4494
4626
|
}
|
|
4495
4627
|
buildBlockPath(t2) {
|
|
@@ -4527,7 +4659,7 @@
|
|
|
4527
4659
|
const i2 = n2.caretRangeFromPoint(t2, e2);
|
|
4528
4660
|
i2 && (o2 = i2.startContainer, r2 = i2.startOffset);
|
|
4529
4661
|
}
|
|
4530
|
-
return o2 && this.contentElement.contains(o2) ?
|
|
4662
|
+
return o2 && this.contentElement.contains(o2) ? _o(this.contentElement, o2, r2) : null;
|
|
4531
4663
|
}
|
|
4532
4664
|
onSelectionChange() {
|
|
4533
4665
|
if (this.isUpdating) return;
|
|
@@ -4544,15 +4676,15 @@
|
|
|
4544
4676
|
this.nodeViews.clear();
|
|
4545
4677
|
}
|
|
4546
4678
|
}
|
|
4547
|
-
const
|
|
4548
|
-
function
|
|
4549
|
-
return "heading" === t2 && e2?.level ? `Heading ${e2.level}` :
|
|
4679
|
+
const Ho = { paragraph: "Paragraph", heading: "Heading", code_block: "Code Block", blockquote: "Block Quote", list_item: "List Item", horizontal_rule: "Horizontal Rule", image: "Image", table: "Table" };
|
|
4680
|
+
function Do(t2, e2) {
|
|
4681
|
+
return "heading" === t2 && e2?.level ? `Heading ${e2.level}` : Ho[t2] ?? t2;
|
|
4550
4682
|
}
|
|
4551
|
-
function
|
|
4683
|
+
function Oo(t2, e2) {
|
|
4552
4684
|
const n2 = [];
|
|
4553
|
-
return
|
|
4685
|
+
return $o(t2, [], n2, e2?.getMarkParseRules() ?? []), n2.length > 0 ? n2 : [p("")];
|
|
4554
4686
|
}
|
|
4555
|
-
function
|
|
4687
|
+
function $o(t2, e2, n2, o2) {
|
|
4556
4688
|
if (t2.nodeType === Node.TEXT_NODE) {
|
|
4557
4689
|
const o3 = t2.textContent ?? "";
|
|
4558
4690
|
return void (o3 && n2.push(p(o3, [...e2])));
|
|
@@ -4564,9 +4696,9 @@
|
|
|
4564
4696
|
if (false === e3) continue;
|
|
4565
4697
|
s2.some((e4) => e4.type === t3.type) || (s2.push({ type: D(t3.type), ...Object.keys(e3).length > 0 ? { attrs: e3 } : {} }), c2.add(t3.type));
|
|
4566
4698
|
} else s2.some((e3) => e3.type === t3.type) || (s2.push({ type: D(t3.type) }), c2.add(t3.type));
|
|
4567
|
-
for (const t3 of Array.from(r2.childNodes))
|
|
4699
|
+
for (const t3 of Array.from(r2.childNodes)) $o(t3, s2, n2, o2);
|
|
4568
4700
|
}
|
|
4569
|
-
function
|
|
4701
|
+
function Fo(t2, e2) {
|
|
4570
4702
|
const n2 = t2.tagName.toLowerCase();
|
|
4571
4703
|
for (const o2 of e2) if (o2.rule.tag === n2) {
|
|
4572
4704
|
if (o2.rule.getAttrs) {
|
|
@@ -4578,13 +4710,13 @@
|
|
|
4578
4710
|
}
|
|
4579
4711
|
return null;
|
|
4580
4712
|
}
|
|
4581
|
-
function
|
|
4713
|
+
function Ko(t2, e2) {
|
|
4582
4714
|
const n2 = (function(t3, e3) {
|
|
4583
4715
|
const n3 = l(t3), o3 = [];
|
|
4584
4716
|
for (const t4 of n3) if (r(t4)) {
|
|
4585
4717
|
const n4 = e3?.getInlineNodeSpec(t4.inlineType);
|
|
4586
4718
|
n4?.toHTMLString && o3.push(n4.toHTMLString(t4));
|
|
4587
|
-
} else o3.push(
|
|
4719
|
+
} else o3.push(Vo(t4, e3));
|
|
4588
4720
|
return o3.join("");
|
|
4589
4721
|
})(t2, e2), o2 = e2?.getNodeSpec(t2.type);
|
|
4590
4722
|
let i2;
|
|
@@ -4592,7 +4724,7 @@
|
|
|
4592
4724
|
const s2 = t2.attrs?.align;
|
|
4593
4725
|
return s2 && "left" !== s2 && (i2 = i2.replace(/>/, ` style="text-align: ${s2}">`)), i2;
|
|
4594
4726
|
}
|
|
4595
|
-
function
|
|
4727
|
+
function Vo(t2, e2) {
|
|
4596
4728
|
if ("" === t2.text) return "";
|
|
4597
4729
|
let n2 = K(t2.text);
|
|
4598
4730
|
const o2 = (function(t3) {
|
|
@@ -4610,9 +4742,9 @@
|
|
|
4610
4742
|
}
|
|
4611
4743
|
return n2;
|
|
4612
4744
|
}
|
|
4613
|
-
const
|
|
4614
|
-
let
|
|
4615
|
-
class
|
|
4745
|
+
const jo = ["\n:host {\n display: block;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 16px;\n line-height: 1.6;\n color: var(--notectl-fg);\n}\n\n.notectl-editor {\n display: flex;\n flex-direction: column;\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n overflow: hidden;\n background: var(--notectl-bg);\n}\n\n.notectl-editor:focus-within {\n border-color: var(--notectl-border-focus);\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* Content Area */\n.notectl-content {\n flex: 1;\n padding: 12px 16px;\n outline: none;\n min-height: var(--notectl-content-min-height, 400px);\n cursor: text;\n position: relative;\n white-space: pre-wrap;\n word-wrap: break-word;\n -moz-tab-size: 4;\n tab-size: 4;\n}\n\n.notectl-content p {\n margin: 0;\n padding: 2px 0;\n min-height: 1.6em;\n}\n\n.notectl-content p + p {\n margin-top: 0;\n}\n\n/* Horizontal Rule */\n.notectl-content hr {\n border: none;\n border-top: 1px solid var(--notectl-border);\n margin: 8px 0;\n padding: 0;\n cursor: default;\n user-select: none;\n}\n\n/* Placeholder */\n.notectl-content.notectl-content--empty::before {\n content: attr(data-placeholder);\n color: var(--notectl-fg-muted);\n pointer-events: none;\n position: absolute;\n top: 12px;\n left: 16px;\n}\n\n/* Plugin container bottom */\n.notectl-plugin-container--bottom {\n border-top: 1px solid var(--notectl-border);\n}\n\n/* Screen reader announcements */\n.notectl-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n\n/* Node selection */\n.notectl-node-selected {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n}\n", "\n@media (prefers-reduced-motion: reduce) {\n .notectl-toolbar-btn,\n .notectl-image__resize-handle,\n .notectl-image__size-indicator,\n .notectl-color-picker__swatch,\n .notectl-font-picker__item,\n .notectl-heading-picker__item,\n .notectl-font-size-picker__item,\n .ntbl-handle,\n .ntbl-handle-delete,\n .ntbl-insert-line,\n .ntbl-insert-btn,\n .ntbl-add-zone,\n .ntbl-add-icon,\n .ntbl-col-bar,\n .ntbl-row-bar,\n .ntbl-delete-table-btn,\n .notectl-code-block__copy {\n transition: none !important;\n }\n}\n"].join("\n");
|
|
4746
|
+
let qo = null;
|
|
4747
|
+
class Uo {
|
|
4616
4748
|
themeStyleSheet = new CSSStyleSheet();
|
|
4617
4749
|
systemThemeQuery = null;
|
|
4618
4750
|
systemThemeHandler = null;
|
|
@@ -4622,11 +4754,11 @@
|
|
|
4622
4754
|
this.shadow = t2;
|
|
4623
4755
|
}
|
|
4624
4756
|
apply(t2) {
|
|
4625
|
-
if (this.cleanupSystemThemeListener(), t2 ===
|
|
4757
|
+
if (this.cleanupSystemThemeListener(), t2 === Qn.System) {
|
|
4626
4758
|
this.setupSystemThemeListener();
|
|
4627
|
-
const t3 =
|
|
4759
|
+
const t3 = no(this.getSystemTheme());
|
|
4628
4760
|
this.setThemeStyleSheet(t3);
|
|
4629
|
-
} else this.setThemeStyleSheet(
|
|
4761
|
+
} else this.setThemeStyleSheet(no(t2));
|
|
4630
4762
|
}
|
|
4631
4763
|
setPluginStyleSheets(t2) {
|
|
4632
4764
|
this.pluginSheets = t2, this.refreshAdoptedStyleSheets();
|
|
@@ -4635,14 +4767,14 @@
|
|
|
4635
4767
|
this.cleanupSystemThemeListener();
|
|
4636
4768
|
}
|
|
4637
4769
|
setThemeStyleSheet(t2) {
|
|
4638
|
-
this.themeStyleSheet.replaceSync(
|
|
4770
|
+
this.themeStyleSheet.replaceSync(so(t2)), this.refreshAdoptedStyleSheets();
|
|
4639
4771
|
}
|
|
4640
4772
|
refreshAdoptedStyleSheets() {
|
|
4641
|
-
this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (
|
|
4773
|
+
this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (qo || (qo = new CSSStyleSheet(), qo.replaceSync(jo)), qo), ...this.pluginSheets];
|
|
4642
4774
|
}
|
|
4643
4775
|
setupSystemThemeListener() {
|
|
4644
4776
|
this.systemThemeQuery = window.matchMedia("(prefers-color-scheme: dark)"), this.systemThemeHandler = (t2) => {
|
|
4645
|
-
const e2 =
|
|
4777
|
+
const e2 = no(this.getSystemTheme());
|
|
4646
4778
|
this.setThemeStyleSheet(e2);
|
|
4647
4779
|
}, this.systemThemeQuery.addEventListener("change", this.systemThemeHandler);
|
|
4648
4780
|
}
|
|
@@ -4650,10 +4782,10 @@
|
|
|
4650
4782
|
this.systemThemeQuery && this.systemThemeHandler && this.systemThemeQuery.removeEventListener("change", this.systemThemeHandler), this.systemThemeQuery = null, this.systemThemeHandler = null;
|
|
4651
4783
|
}
|
|
4652
4784
|
getSystemTheme() {
|
|
4653
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ?
|
|
4785
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? Qn.Dark : Qn.Light;
|
|
4654
4786
|
}
|
|
4655
4787
|
}
|
|
4656
|
-
class
|
|
4788
|
+
class Wo extends HTMLElement {
|
|
4657
4789
|
view = null;
|
|
4658
4790
|
pluginManager = null;
|
|
4659
4791
|
contentElement = null;
|
|
@@ -4687,7 +4819,7 @@
|
|
|
4687
4819
|
const t3 = null !== n2;
|
|
4688
4820
|
this.contentElement.contentEditable = t3 ? "false" : "true", t3 ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly");
|
|
4689
4821
|
}
|
|
4690
|
-
"theme" === t2 && this.themeController && this.themeController.apply(n2 ??
|
|
4822
|
+
"theme" === t2 && this.themeController && this.themeController.apply(n2 ?? Qn.Light);
|
|
4691
4823
|
}
|
|
4692
4824
|
registerPlugin(t2) {
|
|
4693
4825
|
if (this.initialized) throw new Error("Cannot register plugins after initialization. Register before calling init() or adding to DOM.");
|
|
@@ -4698,20 +4830,20 @@
|
|
|
4698
4830
|
this.initialized = true, t2 && (this.config = t2);
|
|
4699
4831
|
const e2 = this.shadowRoot;
|
|
4700
4832
|
if (!e2) return;
|
|
4701
|
-
this.themeController = new
|
|
4833
|
+
this.themeController = new Uo(e2), this.themeController.apply(this.config.theme ?? Qn.Light);
|
|
4702
4834
|
const n2 = (function(t3) {
|
|
4703
4835
|
const e3 = document.createElement("div");
|
|
4704
4836
|
e3.className = "notectl-editor";
|
|
4705
4837
|
const n3 = document.createElement("div");
|
|
4706
|
-
n3.className = "notectl-plugin-container--top";
|
|
4838
|
+
n3.className = "notectl-plugin-container--top", n3.setAttribute("data-notectl-no-print", "");
|
|
4707
4839
|
const o3 = document.createElement("div");
|
|
4708
4840
|
o3.className = "notectl-content", o3.contentEditable = t3.readonly ? "false" : "true", o3.setAttribute("role", "textbox"), o3.setAttribute("aria-multiline", "true"), o3.setAttribute("aria-label", "Rich text editor"), t3.readonly && o3.setAttribute("aria-readonly", "true"), o3.setAttribute("aria-description", "Press Escape to exit the editor"), o3.setAttribute("data-placeholder", t3.placeholder ?? "Start typing...");
|
|
4709
4841
|
const r3 = document.createElement("div");
|
|
4710
|
-
r3.className = "notectl-plugin-container--bottom";
|
|
4842
|
+
r3.className = "notectl-plugin-container--bottom", r3.setAttribute("data-notectl-no-print", "");
|
|
4711
4843
|
const i3 = document.createElement("div");
|
|
4712
|
-
return i3.className = "notectl-sr-only", i3.setAttribute("aria-live", "polite"), i3.setAttribute("aria-atomic", "true"), e3.appendChild(n3), e3.appendChild(o3), e3.appendChild(r3), e3.appendChild(i3), { wrapper: e3, content: o3, topPluginContainer: n3, bottomPluginContainer: r3, announcer: i3 };
|
|
4844
|
+
return i3.className = "notectl-sr-only", i3.setAttribute("data-notectl-no-print", ""), i3.setAttribute("aria-live", "polite"), i3.setAttribute("aria-atomic", "true"), e3.appendChild(n3), e3.appendChild(o3), e3.appendChild(r3), e3.appendChild(i3), { wrapper: e3, content: o3, topPluginContainer: n3, bottomPluginContainer: r3, announcer: i3 };
|
|
4713
4845
|
})({ readonly: this.config.readonly, placeholder: this.config.placeholder });
|
|
4714
|
-
this.editorWrapper = n2.wrapper, this.contentElement = n2.content, this.topPluginContainer = n2.topPluginContainer, this.bottomPluginContainer = n2.bottomPluginContainer, this.announcer = n2.announcer, e2.appendChild(this.editorWrapper), this.pluginManager = new
|
|
4846
|
+
this.editorWrapper = n2.wrapper, this.contentElement = n2.content, this.topPluginContainer = n2.topPluginContainer, this.bottomPluginContainer = n2.bottomPluginContainer, this.announcer = n2.announcer, e2.appendChild(this.editorWrapper), this.pluginManager = new Zt(), Z(this.pluginManager.schemaRegistry), this.processToolbarConfig();
|
|
4715
4847
|
for (const t3 of this.config.plugins ?? []) this.pluginManager.register(t3);
|
|
4716
4848
|
for (const t3 of this.preInitPlugins) this.pluginManager.register(t3);
|
|
4717
4849
|
this.preInitPlugins = [], this.ensureTextFormattingPlugin(), this.contentElement.addEventListener("focus", () => this.emit("focus", void 0)), this.contentElement.addEventListener("blur", () => this.emit("blur", void 0));
|
|
@@ -4724,8 +4856,8 @@
|
|
|
4724
4856
|
}, dispatch: (t3) => this.dispatch(t3), getContainer: () => o2, getPluginContainer: (t3) => "top" === t3 ? i2 : s2, announce: (t3) => {
|
|
4725
4857
|
c2 && (c2.textContent = t3);
|
|
4726
4858
|
}, onBeforeReady: () => {
|
|
4727
|
-
const t3 = z(r2.schemaRegistry), e3 =
|
|
4728
|
-
this.view = new
|
|
4859
|
+
const t3 = z(r2.schemaRegistry), e3 = ht.create({ schema: t3 });
|
|
4860
|
+
this.view = new Ro(o2, { state: e3, schemaRegistry: r2.schemaRegistry, maxHistoryDepth: this.config.maxHistoryDepth, getDecorations: (t4, e4) => this.pluginManager?.collectDecorations(t4, e4) ?? Gt.empty, onStateChange: (t4, e4, n4) => {
|
|
4729
4861
|
this.onStateChange(t4, e4, n4);
|
|
4730
4862
|
} }), this.updateEmptyState();
|
|
4731
4863
|
const n3 = r2.getPluginStyleSheets();
|
|
@@ -4737,7 +4869,7 @@
|
|
|
4737
4869
|
return this.view.getState().doc;
|
|
4738
4870
|
}
|
|
4739
4871
|
setJSON(t2) {
|
|
4740
|
-
const e2 = this.pluginManager ? z(this.pluginManager.schemaRegistry) : void 0, n2 =
|
|
4872
|
+
const e2 = this.pluginManager ? z(this.pluginManager.schemaRegistry) : void 0, n2 = ht.create({ doc: t2, schema: e2, selection: A(t2.children[0]?.id ?? "", 0) });
|
|
4741
4873
|
this.replaceState(n2);
|
|
4742
4874
|
}
|
|
4743
4875
|
getHTML() {
|
|
@@ -4747,8 +4879,8 @@
|
|
|
4747
4879
|
let r2 = null;
|
|
4748
4880
|
for (const e2 of t2.children) if (O(e2, "list_item")) {
|
|
4749
4881
|
const t3 = "ordered" === e2.attrs.listType ? "ol" : "ul";
|
|
4750
|
-
r2 !== t3 && (r2 && o2.push(`</${r2}>`), o2.push(`<${t3}>`), r2 = t3), o2.push(
|
|
4751
|
-
} else r2 && (o2.push(`</${r2}>`), r2 = null), o2.push(
|
|
4882
|
+
r2 !== t3 && (r2 && o2.push(`</${r2}>`), o2.push(`<${t3}>`), r2 = t3), o2.push(Ko(e2, n2));
|
|
4883
|
+
} else r2 && (o2.push(`</${r2}>`), r2 = null), o2.push(Ko(e2, n2));
|
|
4752
4884
|
r2 && o2.push(`</${r2}>`);
|
|
4753
4885
|
const i2 = n2 ? n2.getAllowedTags() : ["p", "br", "div", "span"], s2 = n2 ? n2.getAllowedAttrs() : ["style"];
|
|
4754
4886
|
return e.sanitize(o2.join(""), { ALLOWED_TAGS: i2, ALLOWED_ATTR: s2 });
|
|
@@ -4764,21 +4896,21 @@
|
|
|
4764
4896
|
if ("ul" === o3 || "ol" === o3) {
|
|
4765
4897
|
const t5 = "ol" === o3 ? "ordered" : "bullet";
|
|
4766
4898
|
for (const o4 of Array.from(e2.querySelectorAll("li"))) {
|
|
4767
|
-
const e3 =
|
|
4768
|
-
l2.push(
|
|
4899
|
+
const e3 = Oo(o4, n3);
|
|
4900
|
+
l2.push(h(H("list_item"), e3, void 0, { listType: t5, indent: 0, checked: false }));
|
|
4769
4901
|
}
|
|
4770
4902
|
continue;
|
|
4771
4903
|
}
|
|
4772
|
-
const r3 =
|
|
4904
|
+
const r3 = Fo(e2, c2);
|
|
4773
4905
|
if (r3) {
|
|
4774
|
-
const t5 =
|
|
4775
|
-
l2.push(
|
|
4906
|
+
const t5 = Oo(e2, n3);
|
|
4907
|
+
l2.push(h(H(r3.type), t5, void 0, r3.attrs));
|
|
4776
4908
|
continue;
|
|
4777
4909
|
}
|
|
4778
|
-
const i3 =
|
|
4779
|
-
l2.push(
|
|
4780
|
-
} else t4.nodeType === Node.TEXT_NODE && t4.textContent?.trim() && l2.push(
|
|
4781
|
-
return 0 === l2.length ?
|
|
4910
|
+
const i3 = Oo(e2, n3);
|
|
4911
|
+
l2.push(h(H("paragraph"), i3));
|
|
4912
|
+
} else t4.nodeType === Node.TEXT_NODE && t4.textContent?.trim() && l2.push(h(H("paragraph"), [p(t4.textContent.trim())]));
|
|
4913
|
+
return 0 === l2.length ? u() : u(l2);
|
|
4782
4914
|
})(t2, this.pluginManager?.schemaRegistry);
|
|
4783
4915
|
this.setJSON(n2);
|
|
4784
4916
|
}
|
|
@@ -4809,6 +4941,13 @@
|
|
|
4809
4941
|
configurePlugin(t2, e2) {
|
|
4810
4942
|
this.pluginManager?.configurePlugin(t2, e2);
|
|
4811
4943
|
}
|
|
4944
|
+
getService(t2) {
|
|
4945
|
+
return this.pluginManager?.getService(t2);
|
|
4946
|
+
}
|
|
4947
|
+
onPluginEvent(t2, e2) {
|
|
4948
|
+
return this.pluginManager?.onEvent(t2, e2) ?? (() => {
|
|
4949
|
+
});
|
|
4950
|
+
}
|
|
4812
4951
|
getState() {
|
|
4813
4952
|
if (!this.view) throw new Error("Editor not initialized");
|
|
4814
4953
|
return this.view.getState();
|
|
@@ -4832,7 +4971,7 @@
|
|
|
4832
4971
|
this.config = { ...this.config, theme: t2 }, this.themeController?.apply(t2);
|
|
4833
4972
|
}
|
|
4834
4973
|
getTheme() {
|
|
4835
|
-
return this.config.theme ??
|
|
4974
|
+
return this.config.theme ?? Qn.Light;
|
|
4836
4975
|
}
|
|
4837
4976
|
destroy() {
|
|
4838
4977
|
this.themeController?.destroy(), this.themeController = null, this.view?.destroy();
|
|
@@ -4848,7 +4987,7 @@
|
|
|
4848
4987
|
t2.push(n2);
|
|
4849
4988
|
}
|
|
4850
4989
|
const e2 = { groups: t2 };
|
|
4851
|
-
this.pluginManager.register(new
|
|
4990
|
+
this.pluginManager.register(new le(e2));
|
|
4852
4991
|
}
|
|
4853
4992
|
ensureTextFormattingPlugin() {
|
|
4854
4993
|
if (!this.pluginManager) return;
|
|
@@ -4865,7 +5004,7 @@
|
|
|
4865
5004
|
const o2 = (function(t3, e3, n3) {
|
|
4866
5005
|
if ("undo" === n3.metadata.historyDirection) return "Undo";
|
|
4867
5006
|
if ("redo" === n3.metadata.historyDirection) return "Redo";
|
|
4868
|
-
for (const t4 of n3.steps) if ("setBlockType" === t4.type) return
|
|
5007
|
+
for (const t4 of n3.steps) if ("setBlockType" === t4.type) return Do(t4.nodeType, t4.attrs);
|
|
4869
5008
|
for (const n4 of e3.schema.markTypes) {
|
|
4870
5009
|
const o3 = D(n4), r2 = zt(t3, o3), i2 = zt(e3, o3);
|
|
4871
5010
|
if (r2 !== i2) return `${n4} ${i2 ? "on" : "off"}`;
|
|
@@ -4882,13 +5021,13 @@
|
|
|
4882
5021
|
this.view && (this.view.replaceState(t2), this.updateEmptyState());
|
|
4883
5022
|
}
|
|
4884
5023
|
}
|
|
4885
|
-
"undefined" == typeof customElements || customElements.get("notectl-editor") || customElements.define("notectl-editor",
|
|
5024
|
+
"undefined" == typeof customElements || customElements.get("notectl-editor") || customElements.define("notectl-editor", Wo), t.AFTER_PRINT = Jn, t.ALIGNMENT_ICONS = Le, t.AlignmentPlugin = Ne, t.BEFORE_PRINT = Yn, t.BlockquotePlugin = class {
|
|
4886
5025
|
id = "blockquote";
|
|
4887
5026
|
name = "Blockquote";
|
|
4888
5027
|
priority = 35;
|
|
4889
5028
|
config;
|
|
4890
5029
|
constructor(t2) {
|
|
4891
|
-
this.config = { ...
|
|
5030
|
+
this.config = { ...we, ...t2 };
|
|
4892
5031
|
}
|
|
4893
5032
|
init(t2) {
|
|
4894
5033
|
this.registerNodeSpec(t2), this.registerCommands(t2), this.registerKeymap(t2), this.registerInputRule(t2), this.registerToolbarItem(t2);
|
|
@@ -4912,7 +5051,7 @@
|
|
|
4912
5051
|
} });
|
|
4913
5052
|
}
|
|
4914
5053
|
registerToolbarItem(t2) {
|
|
4915
|
-
t2.registerToolbarItem({ id: "blockquote", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"/></svg>', label: "Blockquote", tooltip: `Blockquote (${
|
|
5054
|
+
t2.registerToolbarItem({ id: "blockquote", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"/></svg>', label: "Blockquote", tooltip: `Blockquote (${ae("Mod-Shift->")})`, command: "toggleBlockquote", priority: 55, separatorAfter: this.config.separatorAfter, isActive: (t3) => {
|
|
4916
5055
|
if (C(t3.selection)) return false;
|
|
4917
5056
|
const e2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
4918
5057
|
return "blockquote" === e2?.type;
|
|
@@ -4930,7 +5069,7 @@
|
|
|
4930
5069
|
const i2 = o2.transaction("command").setBlockType(r2.anchor.blockId, e2, n2).setSelection(r2).build();
|
|
4931
5070
|
return t2.dispatch(i2), true;
|
|
4932
5071
|
}
|
|
4933
|
-
}, t.CODE_BLOCK_SERVICE_KEY =
|
|
5072
|
+
}, t.CODE_BLOCK_SERVICE_KEY = Un, t.ClipboardHandler = $t, t.CodeBlockPlugin = class {
|
|
4934
5073
|
id = "code-block";
|
|
4935
5074
|
name = "Code Block";
|
|
4936
5075
|
priority = 36;
|
|
@@ -4938,10 +5077,131 @@
|
|
|
4938
5077
|
resolvedKeymap;
|
|
4939
5078
|
context = null;
|
|
4940
5079
|
constructor(t2) {
|
|
4941
|
-
this.config = { ...
|
|
5080
|
+
this.config = { ...qn, ...t2 }, this.resolvedKeymap = { ...jn, ...t2?.keymap };
|
|
4942
5081
|
}
|
|
4943
5082
|
init(t2) {
|
|
4944
|
-
t2.registerStyleSheet("\n/* Code Block — uses theme custom properties */\n.notectl-code-block {\n position: relative;\n margin: 8px 0;\n border-radius: 6px;\n background: var(--notectl-code-block-bg);\n color: var(--notectl-code-block-color);\n font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;\n font-size: 14px;\n line-height: 1.5;\n overflow: hidden;\n}\n\n.notectl-code-block__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n background: var(--notectl-code-block-header-bg);\n border-bottom: 1px solid var(--notectl-code-block-header-border);\n font-size: 12px;\n color: var(--notectl-code-block-header-color);\n user-select: none;\n}\n\n.notectl-code-block__language {\n font-weight: 500;\n letter-spacing: 0.02em;\n}\n\n.notectl-code-block__copy {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--notectl-code-block-header-color);\n cursor: pointer;\n padding: 0;\n transition: background 0.15s, color 0.15s;\n}\n\n.notectl-code-block__copy:hover {\n background: rgba(128, 128, 128, 0.15);\n color: var(--notectl-code-block-color);\n}\n\n.notectl-code-block__copy svg {\n fill: currentColor;\n}\n\n.notectl-code-block__content {\n display: block;\n padding: 12px 16px;\n white-space: pre-wrap;\n word-wrap: break-word;\n tab-size: 4;\n -moz-tab-size: 4;\n outline: none;\n min-height: 1.5em;\n}\n\n.notectl-code-block--selected {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n}\n\n.notectl-code-block__esc-hint {\n display: none;\n position: absolute;\n bottom: 4px;\n right: 8px;\n font-size: 11px;\n color: var(--notectl-code-block-header-color);\n opacity: 0.5;\n pointer-events: none;\n user-select: none;\n font-family: system-ui, sans-serif;\n}\n\n.notectl-code-block--focused .notectl-code-block__esc-hint {\n display: block;\n}\n"), this.context = t2, this.registerNodeSpec(t2), this.registerNodeView(t2),
|
|
5083
|
+
t2.registerStyleSheet("\n/* Code Block — uses theme custom properties */\n.notectl-code-block {\n position: relative;\n margin: 8px 0;\n border-radius: 6px;\n background: var(--notectl-code-block-bg);\n color: var(--notectl-code-block-color);\n font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;\n font-size: 14px;\n line-height: 1.5;\n overflow: hidden;\n}\n\n.notectl-code-block__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n background: var(--notectl-code-block-header-bg);\n border-bottom: 1px solid var(--notectl-code-block-header-border);\n font-size: 12px;\n color: var(--notectl-code-block-header-color);\n user-select: none;\n}\n\n.notectl-code-block__language {\n font-weight: 500;\n letter-spacing: 0.02em;\n}\n\n.notectl-code-block__copy {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--notectl-code-block-header-color);\n cursor: pointer;\n padding: 0;\n transition: background 0.15s, color 0.15s;\n}\n\n.notectl-code-block__copy:hover {\n background: rgba(128, 128, 128, 0.15);\n color: var(--notectl-code-block-color);\n}\n\n.notectl-code-block__copy svg {\n fill: currentColor;\n}\n\n.notectl-code-block__content {\n display: block;\n padding: 12px 16px;\n white-space: pre-wrap;\n word-wrap: break-word;\n tab-size: 4;\n -moz-tab-size: 4;\n outline: none;\n min-height: 1.5em;\n}\n\n.notectl-code-block--selected {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n}\n\n.notectl-code-block__esc-hint {\n display: none;\n position: absolute;\n bottom: 4px;\n right: 8px;\n font-size: 11px;\n color: var(--notectl-code-block-header-color);\n opacity: 0.5;\n pointer-events: none;\n user-select: none;\n font-family: system-ui, sans-serif;\n}\n\n.notectl-code-block--focused .notectl-code-block__esc-hint {\n display: block;\n}\n"), this.context = t2, this.registerNodeSpec(t2), this.registerNodeView(t2), (function(t3, e2) {
|
|
5084
|
+
t3.registerCommand("toggleCodeBlock", () => (function(t4, e3) {
|
|
5085
|
+
const n2 = t4.getState();
|
|
5086
|
+
if (C(n2.selection)) return false;
|
|
5087
|
+
const o2 = n2.getBlock(n2.selection.anchor.blockId);
|
|
5088
|
+
if (!o2) return false;
|
|
5089
|
+
if ("code_block" === o2.type) {
|
|
5090
|
+
const e4 = n2.transaction("command").setBlockType(n2.selection.anchor.blockId, "paragraph").setSelection(n2.selection).build();
|
|
5091
|
+
return t4.dispatch(e4), true;
|
|
5092
|
+
}
|
|
5093
|
+
return Vn(t4, e3);
|
|
5094
|
+
})(t3, e2)), t3.registerCommand("insertCodeBlock", () => Vn(t3, e2)), t3.registerCommand("setCodeBlockLanguage", () => false), t3.registerCommand("setCodeBlockBackground", () => false), t3.registerCommand("exitCodeBlock", () => Fn(t3));
|
|
5095
|
+
})(t2, this.config), (function(t3, e2, n2) {
|
|
5096
|
+
const o2 = { Enter: () => (function(t4) {
|
|
5097
|
+
return $n(t4, ({ state: e3, block: n3, blockId: o3, offset: r3 }) => {
|
|
5098
|
+
if (!_(e3.selection)) return false;
|
|
5099
|
+
const i3 = g(n3);
|
|
5100
|
+
if (i3.endsWith("\n") && r3 === i3.length) return (function(t5, e4, n4) {
|
|
5101
|
+
const o4 = t5.getState(), r4 = n4.length - 1, i4 = d(), s3 = o4.transaction("input").deleteTextAt(e4, r4, n4.length).splitBlock(e4, r4, i4).setBlockType(i4, "paragraph").setSelection(A(i4, 0)).build();
|
|
5102
|
+
return t5.dispatch(s3), true;
|
|
5103
|
+
})(t4, o3, i3);
|
|
5104
|
+
const s2 = e3.transaction("input").insertText(o3, r3, "\n", []).setSelection(A(o3, r3 + 1)).build();
|
|
5105
|
+
return t4.dispatch(s2), true;
|
|
5106
|
+
});
|
|
5107
|
+
})(t3), Backspace: () => (function(t4) {
|
|
5108
|
+
return $n(t4, ({ state: e3, blockId: n3, offset: o3 }) => {
|
|
5109
|
+
if (!_(e3.selection)) return false;
|
|
5110
|
+
if (0 !== o3) return false;
|
|
5111
|
+
const r3 = e3.transaction("input").setBlockType(n3, "paragraph").setSelection(e3.selection).build();
|
|
5112
|
+
return t4.dispatch(r3), true;
|
|
5113
|
+
});
|
|
5114
|
+
})(t3), Tab: () => (function(t4, e3) {
|
|
5115
|
+
return $n(t4, ({ state: n3, blockId: o3, offset: r3 }) => {
|
|
5116
|
+
const i3 = e3.useSpaces ? " ".repeat(e3.spaceCount ?? 2) : " ", s2 = n3.transaction("input").insertText(o3, r3, i3, []).setSelection(A(o3, r3 + i3.length)).build();
|
|
5117
|
+
return t4.dispatch(s2), true;
|
|
5118
|
+
});
|
|
5119
|
+
})(t3, e2), "Shift-Tab": () => (function(t4, e3) {
|
|
5120
|
+
return $n(t4, ({ state: n3, block: o3, blockId: r3, offset: i3 }) => {
|
|
5121
|
+
const s2 = g(o3), c2 = s2.lastIndexOf("\n", i3 - 1) + 1;
|
|
5122
|
+
if (e3.useSpaces) {
|
|
5123
|
+
const o4 = e3.spaceCount ?? 2;
|
|
5124
|
+
if (s2.slice(c2, c2 + o4) === " ".repeat(o4)) {
|
|
5125
|
+
const e4 = n3.transaction("input").deleteTextAt(r3, c2, c2 + o4).setSelection(A(r3, Math.max(c2, i3 - o4))).build();
|
|
5126
|
+
return t4.dispatch(e4), true;
|
|
5127
|
+
}
|
|
5128
|
+
} else if (" " === s2[c2]) {
|
|
5129
|
+
const e4 = n3.transaction("input").deleteTextAt(r3, c2, c2 + 1).setSelection(A(r3, Math.max(c2, i3 - 1))).build();
|
|
5130
|
+
return t4.dispatch(e4), true;
|
|
5131
|
+
}
|
|
5132
|
+
return true;
|
|
5133
|
+
});
|
|
5134
|
+
})(t3, e2), Escape: () => Fn(t3), ArrowDown: () => (function(t4) {
|
|
5135
|
+
return $n(t4, ({ state: e3, block: n3, blockId: o3, offset: r3 }) => {
|
|
5136
|
+
if (!_(e3.selection)) return false;
|
|
5137
|
+
if (-1 !== g(n3).indexOf("\n", r3)) return false;
|
|
5138
|
+
const i3 = e3.getBlockOrder(), s2 = i3.indexOf(o3);
|
|
5139
|
+
if (s2 < i3.length - 1) {
|
|
5140
|
+
const n4 = i3[s2 + 1], o4 = e3.transaction("command").setSelection(A(n4, 0)).build();
|
|
5141
|
+
t4.dispatch(o4);
|
|
5142
|
+
} else Kn(t4, o3);
|
|
5143
|
+
return true;
|
|
5144
|
+
});
|
|
5145
|
+
})(t3), ArrowUp: () => (function(t4) {
|
|
5146
|
+
return $n(t4, ({ state: e3, block: n3, blockId: o3, offset: r3 }) => {
|
|
5147
|
+
if (!_(e3.selection)) return false;
|
|
5148
|
+
const i3 = g(n3).indexOf("\n");
|
|
5149
|
+
if (-1 !== i3 && r3 > i3) return false;
|
|
5150
|
+
const s2 = e3.getBlockOrder(), c2 = s2.indexOf(o3);
|
|
5151
|
+
if (c2 > 0) {
|
|
5152
|
+
const n4 = s2[c2 - 1], o4 = e3.getBlock(n4), r4 = o4 ? m(o4) : 0, i4 = e3.transaction("command").setSelection(A(n4, r4)).build();
|
|
5153
|
+
return t4.dispatch(i4), true;
|
|
5154
|
+
}
|
|
5155
|
+
return false;
|
|
5156
|
+
});
|
|
5157
|
+
})(t3), ArrowRight: () => (function(t4) {
|
|
5158
|
+
return $n(t4, ({ state: e3, block: n3, blockId: o3, offset: r3 }) => {
|
|
5159
|
+
if (!_(e3.selection)) return false;
|
|
5160
|
+
if (r3 !== g(n3).length) return false;
|
|
5161
|
+
const i3 = e3.getBlockOrder(), s2 = i3.indexOf(o3);
|
|
5162
|
+
if (s2 < i3.length - 1) {
|
|
5163
|
+
const n4 = i3[s2 + 1], o4 = e3.transaction("command").setSelection(A(n4, 0)).build();
|
|
5164
|
+
t4.dispatch(o4);
|
|
5165
|
+
} else Kn(t4, o3);
|
|
5166
|
+
return true;
|
|
5167
|
+
});
|
|
5168
|
+
})(t3), ArrowLeft: () => (function(t4) {
|
|
5169
|
+
return $n(t4, ({ state: e3, blockId: n3, offset: o3 }) => {
|
|
5170
|
+
if (!_(e3.selection)) return false;
|
|
5171
|
+
if (0 !== o3) return false;
|
|
5172
|
+
const r3 = e3.getBlockOrder(), i3 = r3.indexOf(n3);
|
|
5173
|
+
if (i3 > 0) {
|
|
5174
|
+
const n4 = r3[i3 - 1], o4 = e3.getBlock(n4), s2 = o4 ? m(o4) : 0, c2 = e3.transaction("command").setSelection(A(n4, s2)).build();
|
|
5175
|
+
return t4.dispatch(c2), true;
|
|
5176
|
+
}
|
|
5177
|
+
return false;
|
|
5178
|
+
});
|
|
5179
|
+
})(t3) }, { insertAfter: r2, toggle: i2 } = n2;
|
|
5180
|
+
r2 && (o2[r2] = () => (function(t4) {
|
|
5181
|
+
return $n(t4, ({ blockId: e3 }) => (Kn(t4, e3), true));
|
|
5182
|
+
})(t3)), i2 && (o2[i2] = () => t3.executeCommand("toggleCodeBlock")), t3.registerKeymap(o2);
|
|
5183
|
+
})(t2, this.config, this.resolvedKeymap), this.registerInputRule(t2), this.registerToolbarItem(t2), this.registerMiddleware(t2), (function(t3, e2, n2) {
|
|
5184
|
+
t3.registerService(Un, { setLanguage(e3, n3) {
|
|
5185
|
+
Wn(t3, e3, "language", n3);
|
|
5186
|
+
}, getLanguage(t4) {
|
|
5187
|
+
const e3 = n2();
|
|
5188
|
+
if (!e3) return "";
|
|
5189
|
+
const o2 = e3.getState().getBlock(t4);
|
|
5190
|
+
return o2 && "code_block" === o2.type ? o2.attrs?.language ?? "" : "";
|
|
5191
|
+
}, setBackground(e3, n3) {
|
|
5192
|
+
Wn(t3, e3, "backgroundColor", n3);
|
|
5193
|
+
}, getBackground(t4) {
|
|
5194
|
+
const e3 = n2();
|
|
5195
|
+
if (!e3) return "";
|
|
5196
|
+
const o2 = e3.getState().getBlock(t4);
|
|
5197
|
+
return o2 && "code_block" === o2.type ? o2.attrs?.backgroundColor ?? "" : "";
|
|
5198
|
+
}, isCodeBlock(t4) {
|
|
5199
|
+
const e3 = n2();
|
|
5200
|
+
if (!e3) return false;
|
|
5201
|
+
const o2 = e3.getState().getBlock(t4);
|
|
5202
|
+
return "code_block" === o2?.type;
|
|
5203
|
+
}, getSupportedLanguages: () => e2.highlighter ? e2.highlighter.getSupportedLanguages() : [] });
|
|
5204
|
+
})(t2, this.config, () => this.context), this.patchTableCellContent(t2);
|
|
4945
5205
|
}
|
|
4946
5206
|
destroy() {
|
|
4947
5207
|
this.context = null;
|
|
@@ -4952,7 +5212,7 @@
|
|
|
4952
5212
|
c2 && o2 && this.setBlockFocused(o2, false), l2 && r2 && this.setBlockFocused(r2, true), !c2 && l2 ? this.context.announce("Entered code block. Press Escape to exit.") : c2 && !l2 && this.context.announce("Left code block.");
|
|
4953
5213
|
}
|
|
4954
5214
|
decorations(t2) {
|
|
4955
|
-
if (!this.config.highlighter) return
|
|
5215
|
+
if (!this.config.highlighter) return Gt.empty;
|
|
4956
5216
|
const e2 = [], n2 = this.config.highlighter;
|
|
4957
5217
|
for (const o2 of t2.getBlockOrder()) {
|
|
4958
5218
|
const r2 = t2.getBlock(o2);
|
|
@@ -4962,9 +5222,9 @@
|
|
|
4962
5222
|
const s2 = g(r2);
|
|
4963
5223
|
if (!s2) continue;
|
|
4964
5224
|
const c2 = n2.tokenize(s2, i2);
|
|
4965
|
-
for (const t3 of c2) e2.push(
|
|
5225
|
+
for (const t3 of c2) e2.push(Wt(o2, t3.from, t3.to, { class: `notectl-token--${t3.type}` }));
|
|
4966
5226
|
}
|
|
4967
|
-
return
|
|
5227
|
+
return Gt.create(e2);
|
|
4968
5228
|
}
|
|
4969
5229
|
registerNodeSpec(t2) {
|
|
4970
5230
|
t2.registerNodeSpec({ type: "code_block", group: "block", content: { allow: ["text"] }, selectable: true, attrs: { language: { default: "" }, backgroundColor: { default: "" } }, toDOM(t3) {
|
|
@@ -4990,29 +5250,29 @@
|
|
|
4990
5250
|
const s2 = document.createElement("span");
|
|
4991
5251
|
s2.className = "notectl-code-block__language";
|
|
4992
5252
|
let c2 = null;
|
|
4993
|
-
false !== e2.showCopyButton && (c2 = document.createElement("button"), c2.className = "notectl-code-block__copy", c2.setAttribute("aria-label", "Copy code"), c2.type = "button", c2.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>');
|
|
5253
|
+
false !== e2.showCopyButton && (c2 = document.createElement("button"), c2.className = "notectl-code-block__copy", c2.setAttribute("aria-label", "Copy code"), c2.setAttribute("data-notectl-no-print", ""), c2.type = "button", c2.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>');
|
|
4994
5254
|
const l2 = document.createElement("span");
|
|
4995
5255
|
l2.className = "notectl-sr-only", l2.setAttribute("aria-live", "assertive"), l2.setAttribute("aria-atomic", "true"), i2.appendChild(s2), c2 && i2.appendChild(c2), i2.appendChild(l2);
|
|
4996
5256
|
const a2 = document.createElement("code");
|
|
4997
5257
|
a2.className = "notectl-code-block__content";
|
|
4998
5258
|
const d2 = document.createElement("div");
|
|
4999
|
-
d2.className = "notectl-code-block__esc-hint", d2.setAttribute("contenteditable", "false"), d2.setAttribute("aria-hidden", "true"), d2.textContent = "Esc to exit", r2.appendChild(i2), r2.appendChild(a2), r2.appendChild(d2), e2.background && r2.style.setProperty("--notectl-code-block-bg", e2.background), e2.headerBackground && r2.style.setProperty("--notectl-code-block-header-bg", e2.headerBackground), e2.textColor && r2.style.setProperty("--notectl-code-block-color", e2.textColor), e2.headerColor && r2.style.setProperty("--notectl-code-block-header-color", e2.headerColor);
|
|
5000
|
-
let
|
|
5001
|
-
function
|
|
5259
|
+
d2.className = "notectl-code-block__esc-hint", d2.setAttribute("contenteditable", "false"), d2.setAttribute("aria-hidden", "true"), d2.setAttribute("data-notectl-no-print", ""), d2.textContent = "Esc to exit", r2.appendChild(i2), r2.appendChild(a2), r2.appendChild(d2), e2.background && r2.style.setProperty("--notectl-code-block-bg", e2.background), e2.headerBackground && r2.style.setProperty("--notectl-code-block-header-bg", e2.headerBackground), e2.textColor && r2.style.setProperty("--notectl-code-block-color", e2.textColor), e2.headerColor && r2.style.setProperty("--notectl-code-block-header-color", e2.headerColor);
|
|
5260
|
+
let u2 = t3.id;
|
|
5261
|
+
function h2(t4) {
|
|
5002
5262
|
const e3 = t4.attrs?.language ?? "", n3 = e3 || "plain";
|
|
5003
5263
|
s2.textContent = n3, r2.setAttribute("aria-label", `${n3} code block. Press Escape to exit.`), e3 ? a2.setAttribute("data-language", e3) : a2.removeAttribute("data-language");
|
|
5004
5264
|
const o3 = t4.attrs?.backgroundColor ?? "";
|
|
5005
5265
|
r2.style.backgroundColor = o3 || "";
|
|
5006
5266
|
}
|
|
5007
|
-
return
|
|
5267
|
+
return h2(t3), c2 && c2.addEventListener("click", (t4) => {
|
|
5008
5268
|
t4.preventDefault(), t4.stopPropagation();
|
|
5009
|
-
const e3 = n2().getBlock(
|
|
5269
|
+
const e3 = n2().getBlock(u2);
|
|
5010
5270
|
if (!e3) return;
|
|
5011
5271
|
const o3 = g(e3);
|
|
5012
5272
|
navigator.clipboard.writeText(o3), l2.textContent = "Copied to clipboard", setTimeout(() => {
|
|
5013
5273
|
l2.textContent = "";
|
|
5014
5274
|
}, 1e3);
|
|
5015
|
-
}), { dom: r2, contentDOM: a2, update: (t4) => "code_block" === t4.type && (
|
|
5275
|
+
}), { dom: r2, contentDOM: a2, update: (t4) => "code_block" === t4.type && (u2 = t4.id, r2.setAttribute("data-block-id", t4.id), h2(t4), true), selectNode() {
|
|
5016
5276
|
r2.classList.add("notectl-code-block--selected");
|
|
5017
5277
|
}, deselectNode() {
|
|
5018
5278
|
r2.classList.remove("notectl-code-block--selected");
|
|
@@ -5020,13 +5280,6 @@
|
|
|
5020
5280
|
} };
|
|
5021
5281
|
}));
|
|
5022
5282
|
}
|
|
5023
|
-
registerCommands(t2) {
|
|
5024
|
-
t2.registerCommand("toggleCodeBlock", () => this.toggleCodeBlock(t2)), t2.registerCommand("insertCodeBlock", () => this.insertCodeBlock(t2)), t2.registerCommand("setCodeBlockLanguage", () => false), t2.registerCommand("setCodeBlockBackground", () => false), t2.registerCommand("exitCodeBlock", () => this.handleEscape(t2));
|
|
5025
|
-
}
|
|
5026
|
-
registerKeymaps(t2) {
|
|
5027
|
-
const e2 = { Enter: () => this.handleEnter(t2), Backspace: () => this.handleBackspace(t2), Tab: () => this.handleTab(t2), "Shift-Tab": () => this.handleShiftTab(t2), Escape: () => this.handleEscape(t2), ArrowDown: () => this.handleArrowDown(t2), ArrowUp: () => this.handleArrowUp(t2), ArrowRight: () => this.handleArrowRight(t2), ArrowLeft: () => this.handleArrowLeft(t2) }, { insertAfter: n2, toggle: o2 } = this.resolvedKeymap;
|
|
5028
|
-
n2 && (e2[n2] = () => this.handleModEnter(t2)), o2 && (e2[o2] = () => t2.executeCommand("toggleCodeBlock")), t2.registerKeymap(e2);
|
|
5029
|
-
}
|
|
5030
5283
|
registerInputRule(t2) {
|
|
5031
5284
|
t2.registerInputRule({ pattern: /^```(\w*) $/, handler: (t3, e2, n2, o2) => {
|
|
5032
5285
|
const r2 = t3.selection;
|
|
@@ -5035,11 +5288,11 @@
|
|
|
5035
5288
|
const i2 = t3.getBlock(r2.anchor.blockId);
|
|
5036
5289
|
if (!i2 || "paragraph" !== i2.type) return null;
|
|
5037
5290
|
const s2 = { language: e2[1] ?? "", backgroundColor: "" };
|
|
5038
|
-
return t3.transaction("input").deleteTextAt(r2.anchor.blockId, n2, n2 + e2[0].length).setBlockType(r2.anchor.blockId, "code_block", s2).setSelection(
|
|
5291
|
+
return t3.transaction("input").deleteTextAt(r2.anchor.blockId, n2, n2 + e2[0].length).setBlockType(r2.anchor.blockId, "code_block", s2).setSelection(A(r2.anchor.blockId, 0)).build();
|
|
5039
5292
|
} });
|
|
5040
5293
|
}
|
|
5041
5294
|
registerToolbarItem(t2) {
|
|
5042
|
-
t2.registerToolbarItem({ id: "code_block", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>', label: "Code Block", tooltip: this.resolvedKeymap.toggle ? `Code Block (${
|
|
5295
|
+
t2.registerToolbarItem({ id: "code_block", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>', label: "Code Block", tooltip: this.resolvedKeymap.toggle ? `Code Block (${ae(this.resolvedKeymap.toggle)})` : "Code Block", command: "toggleCodeBlock", priority: 56, separatorAfter: this.config.separatorAfter, isActive: (t3) => {
|
|
5043
5296
|
if (C(t3.selection)) return false;
|
|
5044
5297
|
const e2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
5045
5298
|
return "code_block" === e2?.type;
|
|
@@ -5060,213 +5313,18 @@
|
|
|
5060
5313
|
n2({ ...t3, steps: o2 });
|
|
5061
5314
|
}, 50);
|
|
5062
5315
|
}
|
|
5063
|
-
registerService(t2) {
|
|
5064
|
-
const e2 = this;
|
|
5065
|
-
t2.registerService(zn, { setLanguage(n2, o2) {
|
|
5066
|
-
e2.setAttr(t2, n2, "language", o2);
|
|
5067
|
-
}, getLanguage(t3) {
|
|
5068
|
-
const n2 = e2.context;
|
|
5069
|
-
if (!n2) return "";
|
|
5070
|
-
const o2 = n2.getState().getBlock(t3);
|
|
5071
|
-
return o2 && "code_block" === o2.type ? o2.attrs?.language ?? "" : "";
|
|
5072
|
-
}, setBackground(n2, o2) {
|
|
5073
|
-
e2.setAttr(t2, n2, "backgroundColor", o2);
|
|
5074
|
-
}, getBackground(t3) {
|
|
5075
|
-
const n2 = e2.context;
|
|
5076
|
-
if (!n2) return "";
|
|
5077
|
-
const o2 = n2.getState().getBlock(t3);
|
|
5078
|
-
return o2 && "code_block" === o2.type ? o2.attrs?.backgroundColor ?? "" : "";
|
|
5079
|
-
}, isCodeBlock(t3) {
|
|
5080
|
-
const n2 = e2.context;
|
|
5081
|
-
if (!n2) return false;
|
|
5082
|
-
const o2 = n2.getState().getBlock(t3);
|
|
5083
|
-
return "code_block" === o2?.type;
|
|
5084
|
-
}, getSupportedLanguages: () => e2.config.highlighter ? e2.config.highlighter.getSupportedLanguages() : [] });
|
|
5085
|
-
}
|
|
5086
5316
|
patchTableCellContent(t2) {
|
|
5087
5317
|
const e2 = t2.getSchemaRegistry(), n2 = e2.getNodeSpec("table_cell");
|
|
5088
5318
|
if (!n2?.content) return;
|
|
5089
5319
|
const o2 = n2.content.allow ?? [];
|
|
5090
5320
|
o2.includes("code_block") || (e2.removeNodeSpec("table_cell"), e2.registerNodeSpec({ ...n2, content: { ...n2.content, allow: [...o2, "code_block"] } }));
|
|
5091
5321
|
}
|
|
5092
|
-
handleBackspace(t2) {
|
|
5093
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5094
|
-
if (C(n2)) return false;
|
|
5095
|
-
if (!_(n2)) return false;
|
|
5096
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5097
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5098
|
-
if (0 !== n2.anchor.offset) return false;
|
|
5099
|
-
const r2 = e2.transaction("input").setBlockType(n2.anchor.blockId, "paragraph").setSelection(n2).build();
|
|
5100
|
-
return t2.dispatch(r2), true;
|
|
5101
|
-
}
|
|
5102
|
-
handleEnter(t2) {
|
|
5103
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5104
|
-
if (C(n2)) return false;
|
|
5105
|
-
if (!_(n2)) return false;
|
|
5106
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5107
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5108
|
-
const r2 = g(o2), i2 = n2.anchor.offset;
|
|
5109
|
-
if (r2.endsWith("\n") && i2 === r2.length) return this.exitOnDoubleEnter(t2, n2.anchor.blockId, r2);
|
|
5110
|
-
const s2 = e2.transaction("input").insertText(n2.anchor.blockId, i2, "\n", []).setSelection(M(n2.anchor.blockId, i2 + 1)).build();
|
|
5111
|
-
return t2.dispatch(s2), true;
|
|
5112
|
-
}
|
|
5113
|
-
handleTab(t2) {
|
|
5114
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5115
|
-
if (C(n2)) return false;
|
|
5116
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5117
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5118
|
-
const r2 = this.config.useSpaces ? " ".repeat(this.config.spaceCount ?? 2) : " ", i2 = n2.anchor.offset, s2 = e2.transaction("input").insertText(n2.anchor.blockId, i2, r2, []).setSelection(M(n2.anchor.blockId, i2 + r2.length)).build();
|
|
5119
|
-
return t2.dispatch(s2), true;
|
|
5120
|
-
}
|
|
5121
|
-
handleShiftTab(t2) {
|
|
5122
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5123
|
-
if (C(n2)) return false;
|
|
5124
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5125
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5126
|
-
const r2 = g(o2), i2 = n2.anchor.offset, s2 = r2.lastIndexOf("\n", i2 - 1) + 1;
|
|
5127
|
-
if (this.config.useSpaces) {
|
|
5128
|
-
const o3 = this.config.spaceCount ?? 2;
|
|
5129
|
-
if (r2.slice(s2, s2 + o3) === " ".repeat(o3)) {
|
|
5130
|
-
const r3 = e2.transaction("input").deleteTextAt(n2.anchor.blockId, s2, s2 + o3).setSelection(M(n2.anchor.blockId, Math.max(s2, i2 - o3))).build();
|
|
5131
|
-
return t2.dispatch(r3), true;
|
|
5132
|
-
}
|
|
5133
|
-
} else if (" " === r2[s2]) {
|
|
5134
|
-
const o3 = e2.transaction("input").deleteTextAt(n2.anchor.blockId, s2, s2 + 1).setSelection(M(n2.anchor.blockId, Math.max(s2, i2 - 1))).build();
|
|
5135
|
-
return t2.dispatch(o3), true;
|
|
5136
|
-
}
|
|
5137
|
-
return true;
|
|
5138
|
-
}
|
|
5139
|
-
handleEscape(t2) {
|
|
5140
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5141
|
-
if (C(n2)) return false;
|
|
5142
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5143
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5144
|
-
const r2 = e2.getBlockOrder(), i2 = r2.indexOf(n2.anchor.blockId);
|
|
5145
|
-
if (i2 < r2.length - 1) {
|
|
5146
|
-
const n3 = r2[i2 + 1], o3 = e2.transaction("command").setSelection(M(n3, 0)).build();
|
|
5147
|
-
t2.dispatch(o3);
|
|
5148
|
-
} else this.insertParagraphAfter(t2, n2.anchor.blockId);
|
|
5149
|
-
return true;
|
|
5150
|
-
}
|
|
5151
|
-
handleArrowDown(t2) {
|
|
5152
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5153
|
-
if (C(n2)) return false;
|
|
5154
|
-
if (!_(n2)) return false;
|
|
5155
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5156
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5157
|
-
const r2 = g(o2), i2 = n2.anchor.offset;
|
|
5158
|
-
if (-1 !== r2.indexOf("\n", i2)) return false;
|
|
5159
|
-
const s2 = e2.getBlockOrder(), c2 = s2.indexOf(n2.anchor.blockId);
|
|
5160
|
-
if (c2 < s2.length - 1) {
|
|
5161
|
-
const n3 = s2[c2 + 1], o3 = e2.transaction("command").setSelection(M(n3, 0)).build();
|
|
5162
|
-
t2.dispatch(o3);
|
|
5163
|
-
} else this.insertParagraphAfter(t2, n2.anchor.blockId);
|
|
5164
|
-
return true;
|
|
5165
|
-
}
|
|
5166
|
-
handleArrowUp(t2) {
|
|
5167
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5168
|
-
if (C(n2)) return false;
|
|
5169
|
-
if (!_(n2)) return false;
|
|
5170
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5171
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5172
|
-
const r2 = g(o2), i2 = n2.anchor.offset, s2 = r2.indexOf("\n");
|
|
5173
|
-
if (-1 !== s2 && i2 > s2) return false;
|
|
5174
|
-
const c2 = e2.getBlockOrder(), l2 = c2.indexOf(n2.anchor.blockId);
|
|
5175
|
-
if (l2 > 0) {
|
|
5176
|
-
const n3 = c2[l2 - 1], o3 = e2.getBlock(n3), r3 = o3 ? m(o3) : 0, i3 = e2.transaction("command").setSelection(M(n3, r3)).build();
|
|
5177
|
-
return t2.dispatch(i3), true;
|
|
5178
|
-
}
|
|
5179
|
-
return false;
|
|
5180
|
-
}
|
|
5181
|
-
handleArrowRight(t2) {
|
|
5182
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5183
|
-
if (C(n2)) return false;
|
|
5184
|
-
if (!_(n2)) return false;
|
|
5185
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5186
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5187
|
-
const r2 = g(o2);
|
|
5188
|
-
if (n2.anchor.offset !== r2.length) return false;
|
|
5189
|
-
const i2 = e2.getBlockOrder(), s2 = i2.indexOf(n2.anchor.blockId);
|
|
5190
|
-
if (s2 < i2.length - 1) {
|
|
5191
|
-
const n3 = i2[s2 + 1], o3 = e2.transaction("command").setSelection(M(n3, 0)).build();
|
|
5192
|
-
t2.dispatch(o3);
|
|
5193
|
-
} else this.insertParagraphAfter(t2, n2.anchor.blockId);
|
|
5194
|
-
return true;
|
|
5195
|
-
}
|
|
5196
|
-
handleArrowLeft(t2) {
|
|
5197
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5198
|
-
if (C(n2)) return false;
|
|
5199
|
-
if (!_(n2)) return false;
|
|
5200
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5201
|
-
if (!o2 || "code_block" !== o2.type) return false;
|
|
5202
|
-
if (0 !== n2.anchor.offset) return false;
|
|
5203
|
-
const r2 = e2.getBlockOrder(), i2 = r2.indexOf(n2.anchor.blockId);
|
|
5204
|
-
if (i2 > 0) {
|
|
5205
|
-
const n3 = r2[i2 - 1], o3 = e2.getBlock(n3), s2 = o3 ? m(o3) : 0, c2 = e2.transaction("command").setSelection(M(n3, s2)).build();
|
|
5206
|
-
return t2.dispatch(c2), true;
|
|
5207
|
-
}
|
|
5208
|
-
return false;
|
|
5209
|
-
}
|
|
5210
|
-
handleModEnter(t2) {
|
|
5211
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5212
|
-
if (C(n2)) return false;
|
|
5213
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5214
|
-
return !(!o2 || "code_block" !== o2.type || (this.insertParagraphAfter(t2, n2.anchor.blockId), 0));
|
|
5215
|
-
}
|
|
5216
5322
|
setBlockFocused(t2, e2) {
|
|
5217
5323
|
if (!this.context) return;
|
|
5218
5324
|
const n2 = this.context.getContainer().querySelector(`[data-block-id="${t2}"]`);
|
|
5219
5325
|
n2 && n2.classList.toggle("notectl-code-block--focused", e2);
|
|
5220
5326
|
}
|
|
5221
|
-
|
|
5222
|
-
const e2 = t2.getState();
|
|
5223
|
-
if (C(e2.selection)) return false;
|
|
5224
|
-
const n2 = e2.getBlock(e2.selection.anchor.blockId);
|
|
5225
|
-
if (!n2) return false;
|
|
5226
|
-
if ("code_block" === n2.type) {
|
|
5227
|
-
const n3 = e2.transaction("command").setBlockType(e2.selection.anchor.blockId, "paragraph").setSelection(e2.selection).build();
|
|
5228
|
-
return t2.dispatch(n3), true;
|
|
5229
|
-
}
|
|
5230
|
-
return this.insertCodeBlock(t2);
|
|
5231
|
-
}
|
|
5232
|
-
insertCodeBlock(t2) {
|
|
5233
|
-
const e2 = t2.getState(), n2 = e2.selection;
|
|
5234
|
-
if (C(n2)) return false;
|
|
5235
|
-
const o2 = e2.getBlock(n2.anchor.blockId);
|
|
5236
|
-
if (!o2 || "code_block" === o2.type) return false;
|
|
5237
|
-
const r2 = { language: this.config.defaultLanguage ?? "", backgroundColor: "" }, i2 = e2.transaction("command");
|
|
5238
|
-
return this.stripAllMarks(i2, o2), i2.setBlockType(n2.anchor.blockId, "code_block", r2).setSelection(M(n2.anchor.blockId, 0)), t2.dispatch(i2.build()), true;
|
|
5239
|
-
}
|
|
5240
|
-
exitOnDoubleEnter(t2, e2, n2) {
|
|
5241
|
-
const o2 = t2.getState(), r2 = n2.length - 1, i2 = d(), s2 = o2.transaction("input").deleteTextAt(e2, r2, n2.length).splitBlock(e2, r2, i2).setBlockType(i2, "paragraph").setSelection(M(i2, 0)).build();
|
|
5242
|
-
return t2.dispatch(s2), true;
|
|
5243
|
-
}
|
|
5244
|
-
insertParagraphAfter(t2, e2) {
|
|
5245
|
-
const n2 = t2.getState(), o2 = m(n2.getBlock(e2)), r2 = d(), i2 = n2.transaction("command").splitBlock(e2, o2, r2).setBlockType(r2, "paragraph").setSelection(M(r2, 0)).build();
|
|
5246
|
-
t2.dispatch(i2);
|
|
5247
|
-
}
|
|
5248
|
-
setAttr(t2, e2, n2, o2) {
|
|
5249
|
-
const r2 = t2.getState(), i2 = r2.getBlock(e2);
|
|
5250
|
-
if (!i2 || "code_block" !== i2.type) return;
|
|
5251
|
-
const s2 = q(r2.doc, e2);
|
|
5252
|
-
if (!s2) return;
|
|
5253
|
-
const c2 = { ...i2.attrs, [n2]: o2 }, l2 = r2.transaction("command").setNodeAttr(s2, c2).build();
|
|
5254
|
-
t2.dispatch(l2);
|
|
5255
|
-
}
|
|
5256
|
-
stripAllMarks(t2, e2) {
|
|
5257
|
-
if (0 === m(e2)) return;
|
|
5258
|
-
const n2 = l(e2);
|
|
5259
|
-
let r2 = 0;
|
|
5260
|
-
for (const i2 of n2) if (o(i2)) {
|
|
5261
|
-
if (i2.text.length > 0) for (const n3 of i2.marks) t2.removeMark(e2.id, r2, r2 + i2.text.length, n3);
|
|
5262
|
-
r2 += i2.text.length;
|
|
5263
|
-
} else r2 += 1;
|
|
5264
|
-
}
|
|
5265
|
-
}, t.DARK_THEME = Hn, t.DEFAULT_IMAGE_KEYMAP = Mn, t.DecorationSet = Wt, t.EditorState = ut, t.EventBus = Kt, t.EventKey = class {
|
|
5266
|
-
constructor(t2) {
|
|
5267
|
-
this.id = t2;
|
|
5268
|
-
}
|
|
5269
|
-
}, t.FontPlugin = class {
|
|
5327
|
+
}, t.DARK_THEME = eo, t.DEFAULT_IMAGE_KEYMAP = Dn, t.DecorationSet = Gt, t.EditorState = ht, t.EventBus = Vt, t.EventKey = Ft, t.FontPlugin = class {
|
|
5270
5328
|
id = "font";
|
|
5271
5329
|
name = "Font";
|
|
5272
5330
|
priority = 22;
|
|
@@ -5418,7 +5476,7 @@
|
|
|
5418
5476
|
e2.setAttribute("data-notectl-fonts", ""), e2.textContent = t2.join("\n\n"), document.head.appendChild(e2), this.injectedStyleElement = e2;
|
|
5419
5477
|
}
|
|
5420
5478
|
dismissPopup() {
|
|
5421
|
-
const t2 = this.context?.getService(
|
|
5479
|
+
const t2 = this.context?.getService(ce);
|
|
5422
5480
|
t2?.closePopup();
|
|
5423
5481
|
}
|
|
5424
5482
|
renderFontPopup(t2, e2) {
|
|
@@ -5452,10 +5510,10 @@
|
|
|
5452
5510
|
comboLabel = null;
|
|
5453
5511
|
constructor(t2) {
|
|
5454
5512
|
var e2;
|
|
5455
|
-
this.config = { ...
|
|
5456
|
-
if (!t3 || 0 === t3.length) return
|
|
5513
|
+
this.config = { ...t2 }, this.sizes = (function(t3) {
|
|
5514
|
+
if (!t3 || 0 === t3.length) return je;
|
|
5457
5515
|
const e3 = [...new Set(t3)].filter((t4) => Number.isInteger(t4) && t4 > 0);
|
|
5458
|
-
return e3.sort((t4, e4) => t4 - e4), e3.length > 0 ? e3 :
|
|
5516
|
+
return e3.sort((t4, e4) => t4 - e4), e3.length > 0 ? e3 : je;
|
|
5459
5517
|
})(t2?.sizes), this.defaultSize = (e2 = t2?.defaultSize, void 0 === e2 ? 16 : Number.isInteger(e2) && e2 > 0 ? e2 : 16);
|
|
5460
5518
|
}
|
|
5461
5519
|
init(t2) {
|
|
@@ -5480,175 +5538,87 @@
|
|
|
5480
5538
|
} }], sanitize: { tags: ["span"] } });
|
|
5481
5539
|
}
|
|
5482
5540
|
registerCommands(t2) {
|
|
5483
|
-
t2.registerCommand("removeFontSize", () =>
|
|
5484
|
-
const e2 = t2.getState();
|
|
5485
|
-
return this.removeFontSize(t2, e2);
|
|
5486
|
-
}), t2.registerCommand("setFontSize", () => false), t2.registerCommand("increaseFontSize", () => {
|
|
5487
|
-
const e2 = t2.getState();
|
|
5488
|
-
return this.stepFontSize(t2, e2, "up");
|
|
5489
|
-
}), t2.registerCommand("decreaseFontSize", () => {
|
|
5490
|
-
const e2 = t2.getState();
|
|
5491
|
-
return this.stepFontSize(t2, e2, "down");
|
|
5492
|
-
});
|
|
5541
|
+
t2.registerCommand("removeFontSize", () => Oe(t2, t2.getState())), t2.registerCommand("setFontSize", () => false), t2.registerCommand("increaseFontSize", () => $e(t2, t2.getState(), "up", this.sizes, this.defaultSize)), t2.registerCommand("decreaseFontSize", () => $e(t2, t2.getState(), "down", this.sizes, this.defaultSize));
|
|
5493
5542
|
}
|
|
5494
5543
|
registerKeymaps(t2) {
|
|
5495
|
-
t2.registerKeymap({ "Mod-Shift-+": () =>
|
|
5496
|
-
const e2 = t2.getState();
|
|
5497
|
-
return this.stepFontSize(t2, e2, "up");
|
|
5498
|
-
}, "Mod-Shift-_": () => {
|
|
5499
|
-
const e2 = t2.getState();
|
|
5500
|
-
return this.stepFontSize(t2, e2, "down");
|
|
5501
|
-
} });
|
|
5544
|
+
t2.registerKeymap({ "Mod-Shift-+": () => $e(t2, t2.getState(), "up", this.sizes, this.defaultSize), "Mod-Shift-_": () => $e(t2, t2.getState(), "down", this.sizes, this.defaultSize) });
|
|
5502
5545
|
}
|
|
5503
5546
|
registerToolbarItem(t2) {
|
|
5504
5547
|
const e2 = `<span class="notectl-font-size-select__label" data-font-size-label>${this.defaultSize}</span><span class="notectl-font-size-select__arrow">▾</span>`;
|
|
5505
5548
|
t2.registerToolbarItem({ id: "fontSize", group: "format", icon: e2, label: "Font Size", tooltip: "Font Size", command: "removeFontSize", priority: 6, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, e3) => {
|
|
5506
|
-
|
|
5507
|
-
|
|
5549
|
+
!(function(t4, e4, n2) {
|
|
5550
|
+
t4.classList.add("notectl-font-size-picker");
|
|
5551
|
+
const o2 = He(e4.getState(), n2.defaultSize), r2 = (function(t5) {
|
|
5552
|
+
const e5 = document.createElement("input");
|
|
5553
|
+
return e5.type = "number", e5.className = "notectl-font-size-picker__input", e5.min = String(1), e5.max = String(400), e5.value = String(t5), e5.setAttribute("aria-label", "Custom font size"), e5;
|
|
5554
|
+
})(o2);
|
|
5555
|
+
!(function(t5, e5) {
|
|
5556
|
+
const n3 = document.createElement("div");
|
|
5557
|
+
n3.className = "notectl-font-size-picker__input-wrapper", n3.appendChild(e5), t5.appendChild(n3);
|
|
5558
|
+
})(t4, r2);
|
|
5559
|
+
const { list: i2, items: s2 } = (function(t5, e5, n3, o3) {
|
|
5560
|
+
const r3 = document.createElement("div");
|
|
5561
|
+
r3.className = "notectl-font-size-picker__list", r3.setAttribute("role", "listbox"), r3.setAttribute("aria-label", "Font sizes");
|
|
5562
|
+
const i3 = [];
|
|
5563
|
+
for (const s3 of t5) {
|
|
5564
|
+
const t6 = Ve(s3, s3 === e5);
|
|
5565
|
+
t6.addEventListener("mousedown", (t7) => {
|
|
5566
|
+
t7.preventDefault(), t7.stopPropagation(), Fe(n3, s3, o3.defaultSize), o3.dismissPopup();
|
|
5567
|
+
}), i3.push(t6), r3.appendChild(t6);
|
|
5568
|
+
}
|
|
5569
|
+
return { list: r3, items: i3 };
|
|
5570
|
+
})(n2.sizes, o2, e4, n2);
|
|
5571
|
+
t4.appendChild(i2), (function(t5, e5, n3, o3) {
|
|
5572
|
+
const r3 = e5.indexOf(n3);
|
|
5573
|
+
if (r3 < 0) return;
|
|
5574
|
+
const i3 = t5[r3];
|
|
5575
|
+
i3 && (requestAnimationFrame(() => {
|
|
5576
|
+
i3.scrollIntoView({ block: "nearest" });
|
|
5577
|
+
}), o3.setAttribute("aria-activedescendant", i3.id));
|
|
5578
|
+
})(s2, n2.sizes, o2, i2), (function(t5, e5, n3, o3, r3) {
|
|
5579
|
+
let i3 = -1;
|
|
5580
|
+
const s3 = (t6) => {
|
|
5581
|
+
i3 >= 0 && i3 < n3.length && n3[i3]?.classList.remove("notectl-font-size-picker__item--focused"), i3 = t6;
|
|
5582
|
+
const o4 = n3[i3];
|
|
5583
|
+
i3 >= 0 && i3 < n3.length && o4 && (o4.classList.add("notectl-font-size-picker__item--focused"), o4.scrollIntoView({ block: "nearest" }), e5.setAttribute("aria-activedescendant", o4.id));
|
|
5584
|
+
};
|
|
5585
|
+
t5.addEventListener("keydown", (e6) => {
|
|
5586
|
+
if ("Enter" === e6.key) {
|
|
5587
|
+
e6.preventDefault();
|
|
5588
|
+
const n4 = Number.parseInt(t5.value, 10);
|
|
5589
|
+
!Number.isNaN(n4) && n4 >= 1 && n4 <= 400 && (Fe(o3, n4, r3.defaultSize), r3.dismissPopup());
|
|
5590
|
+
} else "ArrowDown" === e6.key ? (e6.preventDefault(), s3(0), n3[0]?.focus()) : "Escape" === e6.key && (e6.preventDefault(), r3.dismissPopup());
|
|
5591
|
+
}), e5.addEventListener("keydown", (e6) => {
|
|
5592
|
+
if ("ArrowDown" === e6.key) e6.preventDefault(), i3 < n3.length - 1 && (s3(i3 + 1), n3[i3]?.focus());
|
|
5593
|
+
else if ("ArrowUp" === e6.key) e6.preventDefault(), i3 > 0 ? (s3(i3 - 1), n3[i3]?.focus()) : (s3(-1), t5.focus());
|
|
5594
|
+
else if ("Enter" === e6.key) {
|
|
5595
|
+
e6.preventDefault();
|
|
5596
|
+
const t6 = r3.sizes[i3];
|
|
5597
|
+
i3 >= 0 && i3 < r3.sizes.length && void 0 !== t6 && (Fe(o3, t6, r3.defaultSize), r3.dismissPopup());
|
|
5598
|
+
} else "Escape" === e6.key && (e6.preventDefault(), r3.dismissPopup());
|
|
5599
|
+
});
|
|
5600
|
+
})(r2, i2, s2, e4, n2);
|
|
5601
|
+
})(t3, e3, { sizes: this.sizes, defaultSize: this.defaultSize, dismissPopup: () => this.dismissPopup() });
|
|
5602
|
+
}, isActive: (t3) => (function(t4) {
|
|
5603
|
+
return null !== Re(t4);
|
|
5604
|
+
})(t3) });
|
|
5508
5605
|
}
|
|
5509
5606
|
applyDefaultSizeToContainer(t2) {
|
|
5510
5607
|
t2.getContainer().style.fontSize = `${this.defaultSize}px`;
|
|
5511
5608
|
}
|
|
5609
|
+
dismissPopup() {
|
|
5610
|
+
const t2 = this.context?.getService(ce);
|
|
5611
|
+
t2?.closePopup();
|
|
5612
|
+
}
|
|
5512
5613
|
updateComboLabel(t2) {
|
|
5513
5614
|
if (!this.comboLabel) {
|
|
5514
5615
|
const t3 = this.context?.getPluginContainer("top");
|
|
5515
5616
|
if (!t3) return;
|
|
5516
5617
|
if (this.comboLabel = t3.querySelector("[data-font-size-label]") ?? null, !this.comboLabel) return;
|
|
5517
5618
|
}
|
|
5518
|
-
const e2 = this.
|
|
5619
|
+
const e2 = He(t2, this.defaultSize);
|
|
5519
5620
|
this.comboLabel.textContent = String(e2);
|
|
5520
5621
|
}
|
|
5521
|
-
isFontSizeActive(t2) {
|
|
5522
|
-
return null !== this.getActiveSize(t2);
|
|
5523
|
-
}
|
|
5524
|
-
getActiveSize(t2) {
|
|
5525
|
-
const e2 = t2.selection;
|
|
5526
|
-
if (C(e2)) return null;
|
|
5527
|
-
if (_(e2)) {
|
|
5528
|
-
if (t2.storedMarks) {
|
|
5529
|
-
const e3 = t2.storedMarks.find((t3) => "fontSize" === t3.type);
|
|
5530
|
-
return e3 && $(e3, "fontSize") ? e3.attrs.size ?? null : null;
|
|
5531
|
-
}
|
|
5532
|
-
const n3 = t2.getBlock(e2.anchor.blockId);
|
|
5533
|
-
if (!n3) return null;
|
|
5534
|
-
const o3 = b(n3, e2.anchor.offset).find((t3) => "fontSize" === t3.type);
|
|
5535
|
-
return o3 && $(o3, "fontSize") ? o3.attrs.size ?? null : null;
|
|
5536
|
-
}
|
|
5537
|
-
const n2 = t2.getBlock(e2.anchor.blockId);
|
|
5538
|
-
if (!n2) return null;
|
|
5539
|
-
const o2 = b(n2, e2.anchor.offset).find((t3) => "fontSize" === t3.type);
|
|
5540
|
-
return o2 && $(o2, "fontSize") ? o2.attrs.size ?? null : null;
|
|
5541
|
-
}
|
|
5542
|
-
getActiveSizeNumeric(t2) {
|
|
5543
|
-
const e2 = this.getActiveSize(t2);
|
|
5544
|
-
if (!e2) return this.defaultSize;
|
|
5545
|
-
const n2 = Number.parseInt(e2, 10);
|
|
5546
|
-
return Number.isNaN(n2) ? this.defaultSize : n2;
|
|
5547
|
-
}
|
|
5548
|
-
applyFontSize(t2, e2, n2) {
|
|
5549
|
-
const o2 = e2.selection;
|
|
5550
|
-
if (C(o2)) return false;
|
|
5551
|
-
if (_(o2)) {
|
|
5552
|
-
const r3 = e2.getBlock(o2.anchor.blockId);
|
|
5553
|
-
if (!r3) return false;
|
|
5554
|
-
const i3 = [...(e2.storedMarks ?? b(r3, o2.anchor.offset)).filter((t3) => "fontSize" !== t3.type), { type: "fontSize", attrs: { size: n2 } }], s3 = e2.transaction("command").setStoredMarks(i3, e2.storedMarks).setSelection(o2).build();
|
|
5555
|
-
return t2.dispatch(s3), true;
|
|
5556
|
-
}
|
|
5557
|
-
const r2 = N(o2, e2.getBlockOrder()), i2 = e2.transaction("command"), s2 = { type: "fontSize", attrs: { size: n2 } };
|
|
5558
|
-
return kt(e2, r2, (t3, e3, n3) => {
|
|
5559
|
-
i2.removeMark(t3, e3, n3, { type: "fontSize" }), i2.addMark(t3, e3, n3, s2);
|
|
5560
|
-
}), i2.setSelection(o2), t2.dispatch(i2.build()), true;
|
|
5561
|
-
}
|
|
5562
|
-
removeFontSize(t2, e2) {
|
|
5563
|
-
const n2 = e2.selection;
|
|
5564
|
-
if (C(n2)) return false;
|
|
5565
|
-
if (_(n2)) {
|
|
5566
|
-
const o3 = e2.getBlock(n2.anchor.blockId);
|
|
5567
|
-
if (!o3) return false;
|
|
5568
|
-
const r3 = e2.storedMarks ?? b(o3, n2.anchor.offset);
|
|
5569
|
-
if (!y(r3, "fontSize")) return false;
|
|
5570
|
-
const i2 = r3.filter((t3) => "fontSize" !== t3.type), s2 = e2.transaction("command").setStoredMarks(i2, e2.storedMarks).setSelection(n2).build();
|
|
5571
|
-
return t2.dispatch(s2), true;
|
|
5572
|
-
}
|
|
5573
|
-
const o2 = N(n2, e2.getBlockOrder()), r2 = e2.transaction("command");
|
|
5574
|
-
return kt(e2, o2, (t3, e3, n3) => {
|
|
5575
|
-
r2.removeMark(t3, e3, n3, { type: "fontSize" });
|
|
5576
|
-
}), r2.setSelection(n2), t2.dispatch(r2.build()), true;
|
|
5577
|
-
}
|
|
5578
|
-
stepFontSize(t2, e2, n2) {
|
|
5579
|
-
const o2 = this.getActiveSizeNumeric(e2), r2 = this.getNextPresetSize(o2, n2);
|
|
5580
|
-
return null !== r2 && (r2 === this.defaultSize ? this.removeFontSize(t2, e2) : this.applyFontSize(t2, e2, `${r2}px`));
|
|
5581
|
-
}
|
|
5582
|
-
getNextPresetSize(t2, e2) {
|
|
5583
|
-
if ("up" === e2) {
|
|
5584
|
-
for (const e3 of this.sizes) if (e3 > t2) return e3;
|
|
5585
|
-
return null;
|
|
5586
|
-
}
|
|
5587
|
-
for (let e3 = this.sizes.length - 1; e3 >= 0; e3--) {
|
|
5588
|
-
const n2 = this.sizes[e3];
|
|
5589
|
-
if (void 0 !== n2 && n2 < t2) return n2;
|
|
5590
|
-
}
|
|
5591
|
-
return null;
|
|
5592
|
-
}
|
|
5593
|
-
dismissPopup() {
|
|
5594
|
-
const t2 = this.context?.getService(se);
|
|
5595
|
-
t2?.closePopup();
|
|
5596
|
-
}
|
|
5597
|
-
renderFontSizePopup(t2, e2) {
|
|
5598
|
-
t2.classList.add("notectl-font-size-picker");
|
|
5599
|
-
const n2 = e2.getState(), o2 = this.getActiveSizeNumeric(n2);
|
|
5600
|
-
let r2 = -1;
|
|
5601
|
-
const i2 = document.createElement("div");
|
|
5602
|
-
i2.className = "notectl-font-size-picker__input-wrapper";
|
|
5603
|
-
const s2 = document.createElement("input");
|
|
5604
|
-
s2.type = "number", s2.className = "notectl-font-size-picker__input", s2.min = String(1), s2.max = String(400), s2.value = String(o2), s2.setAttribute("aria-label", "Custom font size"), i2.appendChild(s2), t2.appendChild(i2);
|
|
5605
|
-
const c2 = document.createElement("div");
|
|
5606
|
-
c2.className = "notectl-font-size-picker__list", c2.setAttribute("role", "listbox"), c2.setAttribute("aria-label", "Font sizes");
|
|
5607
|
-
const l2 = [];
|
|
5608
|
-
for (let t3 = 0; t3 < this.sizes.length; t3++) {
|
|
5609
|
-
const n3 = this.sizes[t3];
|
|
5610
|
-
if (void 0 === n3) continue;
|
|
5611
|
-
const r3 = n3 === o2, i3 = `notectl-font-size-option-${n3}`, s3 = document.createElement("button");
|
|
5612
|
-
s3.type = "button", s3.id = i3, s3.className = "notectl-font-size-picker__item", s3.setAttribute("role", "option"), s3.setAttribute("aria-selected", String(r3)), r3 && s3.classList.add("notectl-font-size-picker__item--active");
|
|
5613
|
-
const a3 = document.createElement("span");
|
|
5614
|
-
a3.className = "notectl-font-size-picker__check", a3.textContent = r3 ? "✓" : "", s3.appendChild(a3);
|
|
5615
|
-
const d3 = document.createElement("span");
|
|
5616
|
-
d3.className = "notectl-font-size-picker__label", d3.textContent = String(n3), s3.appendChild(d3), s3.addEventListener("mousedown", (t4) => {
|
|
5617
|
-
t4.preventDefault(), t4.stopPropagation(), this.selectSize(e2, n3), this.dismissPopup();
|
|
5618
|
-
}), l2.push(s3), c2.appendChild(s3);
|
|
5619
|
-
}
|
|
5620
|
-
t2.appendChild(c2);
|
|
5621
|
-
const a2 = this.sizes.indexOf(o2);
|
|
5622
|
-
if (a2 >= 0) {
|
|
5623
|
-
const t3 = l2[a2];
|
|
5624
|
-
t3 && (requestAnimationFrame(() => {
|
|
5625
|
-
t3.scrollIntoView({ block: "nearest" });
|
|
5626
|
-
}), c2.setAttribute("aria-activedescendant", t3.id));
|
|
5627
|
-
}
|
|
5628
|
-
const d2 = (t3) => {
|
|
5629
|
-
r2 >= 0 && r2 < l2.length && l2[r2]?.classList.remove("notectl-font-size-picker__item--focused"), r2 = t3;
|
|
5630
|
-
const e3 = l2[r2];
|
|
5631
|
-
r2 >= 0 && r2 < l2.length && e3 && (e3.classList.add("notectl-font-size-picker__item--focused"), e3.scrollIntoView({ block: "nearest" }), c2.setAttribute("aria-activedescendant", e3.id));
|
|
5632
|
-
};
|
|
5633
|
-
s2.addEventListener("keydown", (t3) => {
|
|
5634
|
-
if ("Enter" === t3.key) {
|
|
5635
|
-
t3.preventDefault();
|
|
5636
|
-
const n3 = Number.parseInt(s2.value, 10);
|
|
5637
|
-
!Number.isNaN(n3) && n3 >= 1 && n3 <= 400 && (this.selectSize(e2, n3), this.dismissPopup());
|
|
5638
|
-
} else "ArrowDown" === t3.key ? (t3.preventDefault(), d2(0), l2[0]?.focus()) : "Escape" === t3.key && (t3.preventDefault(), this.dismissPopup());
|
|
5639
|
-
}), c2.addEventListener("keydown", (t3) => {
|
|
5640
|
-
if ("ArrowDown" === t3.key) t3.preventDefault(), r2 < l2.length - 1 && (d2(r2 + 1), l2[r2]?.focus());
|
|
5641
|
-
else if ("ArrowUp" === t3.key) t3.preventDefault(), r2 > 0 ? (d2(r2 - 1), l2[r2]?.focus()) : (d2(-1), s2.focus());
|
|
5642
|
-
else if ("Enter" === t3.key) {
|
|
5643
|
-
t3.preventDefault();
|
|
5644
|
-
const n3 = this.sizes[r2];
|
|
5645
|
-
r2 >= 0 && r2 < this.sizes.length && void 0 !== n3 && (this.selectSize(e2, n3), this.dismissPopup());
|
|
5646
|
-
} else "Escape" === t3.key && (t3.preventDefault(), this.dismissPopup());
|
|
5647
|
-
});
|
|
5648
|
-
}
|
|
5649
|
-
selectSize(t2, e2) {
|
|
5650
|
-
e2 === this.defaultSize ? t2.executeCommand("removeFontSize") : this.applyFontSize(t2, t2.getState(), `${e2}px`);
|
|
5651
|
-
}
|
|
5652
5622
|
}, t.HardBreakPlugin = class {
|
|
5653
5623
|
id = "hard-break";
|
|
5654
5624
|
name = "Hard Break";
|
|
@@ -5671,17 +5641,17 @@
|
|
|
5671
5641
|
return !!e2 && (t2.dispatch(e2), true);
|
|
5672
5642
|
} });
|
|
5673
5643
|
}
|
|
5674
|
-
}, t.HeadingPlugin =
|
|
5644
|
+
}, t.HeadingPlugin = ke, t.HighlightPlugin = class {
|
|
5675
5645
|
id = "highlight";
|
|
5676
5646
|
name = "Highlight";
|
|
5677
5647
|
priority = 24;
|
|
5678
5648
|
config;
|
|
5679
5649
|
colors;
|
|
5680
5650
|
constructor(t2) {
|
|
5681
|
-
this.config = { ...
|
|
5682
|
-
if (!t3 || 0 === t3.length) return
|
|
5651
|
+
this.config = { ...wn, ...t2 }, this.colors = (function(t3) {
|
|
5652
|
+
if (!t3 || 0 === t3.length) return In;
|
|
5683
5653
|
const e2 = t3.filter((t4) => {
|
|
5684
|
-
return e3 = t4, !
|
|
5654
|
+
return e3 = t4, !Sn.test(e3);
|
|
5685
5655
|
var e3;
|
|
5686
5656
|
});
|
|
5687
5657
|
if (e2.length > 0) throw new Error(`HighlightPlugin: invalid hex color(s): ${e2.join(", ")}. Expected format: #RGB or #RRGGBB.`);
|
|
@@ -5694,7 +5664,7 @@
|
|
|
5694
5664
|
})(t2?.colors);
|
|
5695
5665
|
}
|
|
5696
5666
|
init(t2) {
|
|
5697
|
-
t2.registerStyleSheet(
|
|
5667
|
+
t2.registerStyleSheet(Ie), this.registerMarkSpec(t2), this.registerCommands(t2), this.registerToolbarItem(t2);
|
|
5698
5668
|
}
|
|
5699
5669
|
registerMarkSpec(t2) {
|
|
5700
5670
|
t2.registerMarkSpec({ type: "highlight", rank: 4, attrs: { color: { default: "" } }, toDOM(t3) {
|
|
@@ -5790,7 +5760,7 @@
|
|
|
5790
5760
|
priority = 40;
|
|
5791
5761
|
config;
|
|
5792
5762
|
constructor(t2) {
|
|
5793
|
-
this.config = { ...
|
|
5763
|
+
this.config = { ...Ee, ...t2 };
|
|
5794
5764
|
}
|
|
5795
5765
|
init(t2) {
|
|
5796
5766
|
this.registerNodeSpec(t2), this.registerCommands(t2), this.registerKeymap(t2), this.registerInputRule(t2), this.registerToolbarItem(t2);
|
|
@@ -5811,24 +5781,24 @@
|
|
|
5811
5781
|
if (!_(r2)) return null;
|
|
5812
5782
|
const i2 = t3.getBlock(r2.anchor.blockId);
|
|
5813
5783
|
if (!i2 || "paragraph" !== i2.type) return null;
|
|
5814
|
-
const s2 =
|
|
5784
|
+
const s2 = Me(t3);
|
|
5815
5785
|
if (-1 === s2) return null;
|
|
5816
|
-
const c2 =
|
|
5817
|
-
return t3.transaction("input").deleteTextAt(r2.anchor.blockId, 0, o2).setBlockType(r2.anchor.blockId, "horizontal_rule").insertNode([], s2 + 1, c2).setSelection(
|
|
5786
|
+
const c2 = h("paragraph");
|
|
5787
|
+
return t3.transaction("input").deleteTextAt(r2.anchor.blockId, 0, o2).setBlockType(r2.anchor.blockId, "horizontal_rule").insertNode([], s2 + 1, c2).setSelection(A(c2.id, 0)).build();
|
|
5818
5788
|
} });
|
|
5819
5789
|
}
|
|
5820
5790
|
registerToolbarItem(t2) {
|
|
5821
|
-
t2.registerToolbarItem({ id: "horizontal-rule", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11h16v2H4z"/></svg>', label: "Horizontal Rule", tooltip: `Horizontal Rule (${
|
|
5791
|
+
t2.registerToolbarItem({ id: "horizontal-rule", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11h16v2H4z"/></svg>', label: "Horizontal Rule", tooltip: `Horizontal Rule (${ae("Mod-Shift-H")})`, command: "insertHorizontalRule", priority: 60, separatorAfter: this.config.separatorAfter, isActive: () => false });
|
|
5822
5792
|
}
|
|
5823
5793
|
insertHorizontalRule(t2) {
|
|
5824
5794
|
const e2 = t2.getState();
|
|
5825
5795
|
if (C(e2.selection)) return false;
|
|
5826
|
-
const n2 =
|
|
5796
|
+
const n2 = Me(e2);
|
|
5827
5797
|
if (-1 === n2) return false;
|
|
5828
|
-
const o2 =
|
|
5798
|
+
const o2 = h("horizontal_rule"), r2 = h("paragraph"), i2 = e2.transaction("command").insertNode([], n2 + 1, o2).insertNode([], n2 + 2, r2).setSelection(A(r2.id, 0)).build();
|
|
5829
5799
|
return t2.dispatch(i2), true;
|
|
5830
5800
|
}
|
|
5831
|
-
}, t.IMAGE_UPLOAD_SERVICE =
|
|
5801
|
+
}, t.IMAGE_UPLOAD_SERVICE = Hn, t.ImagePlugin = class {
|
|
5832
5802
|
id = "image";
|
|
5833
5803
|
name = "Image";
|
|
5834
5804
|
priority = 45;
|
|
@@ -5838,11 +5808,11 @@
|
|
|
5838
5808
|
blobUrls = /* @__PURE__ */ new Set();
|
|
5839
5809
|
context = null;
|
|
5840
5810
|
constructor(t2) {
|
|
5841
|
-
this.config = { ...
|
|
5811
|
+
this.config = { ...On, ...t2 }, this.resolvedKeymap = { ...Dn, ...t2?.keymap };
|
|
5842
5812
|
}
|
|
5843
5813
|
init(t2) {
|
|
5844
5814
|
t2.registerStyleSheet("\n/* Image */\n.notectl-image {\n margin: 8px 0;\n user-select: none;\n line-height: 0;\n}\n\n.notectl-image--center {\n text-align: center;\n}\n\n.notectl-image--left {\n text-align: left;\n}\n\n.notectl-image--right {\n text-align: right;\n}\n\n.notectl-image__container {\n display: inline-block;\n position: relative;\n line-height: 0;\n}\n\n.notectl-image__img {\n display: block;\n max-width: 100%;\n border-radius: 4px;\n}\n\n.notectl-image--selected .notectl-image__container {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n border-radius: 6px;\n}\n\n/* Alignment toolbar (appears on image selection) */\n.notectl-image__align-toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n top: -36px;\n left: 50%;\n transform: translateX(-50%);\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n padding: 2px;\n box-shadow: 0 2px 8px var(--notectl-shadow);\n z-index: 10;\n}\n\n.notectl-image__align-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: none;\n background: transparent;\n border-radius: 4px;\n cursor: pointer;\n color: var(--notectl-fg);\n}\n\n.notectl-image__align-btn:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-image__align-btn--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-image__align-btn svg {\n width: 16px;\n height: 16px;\n fill: currentColor;\n}\n\n/* Upload overlay */\n.notectl-image__overlay {\n position: absolute;\n inset: 0;\n display: none;\n align-items: center;\n justify-content: center;\n background: rgba(255, 255, 255, 0.8);\n border-radius: 4px;\n font-size: 13px;\n color: var(--notectl-fg-muted);\n}\n\n.notectl-image__overlay--uploading {\n display: flex;\n}\n\n.notectl-image__overlay--error {\n display: flex;\n background: var(--notectl-danger-muted);\n color: var(--notectl-danger);\n}\n\n/* Resize overlay + handles */\n.notectl-image__resize-overlay {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n.notectl-image__resize-handle {\n position: absolute;\n width: 10px;\n height: 10px;\n background: var(--notectl-bg);\n border: 2px solid var(--notectl-primary);\n border-radius: 50%;\n pointer-events: all;\n z-index: 2;\n transition: transform 0.1s, background 0.1s;\n}\n\n.notectl-image__resize-handle:hover {\n background: var(--notectl-primary);\n transform: scale(1.3);\n}\n\n.notectl-image--resizing .notectl-image__resize-handle {\n background: var(--notectl-primary);\n}\n\n.notectl-image__resize-handle--nw {\n top: -5px;\n left: -5px;\n cursor: nwse-resize;\n}\n\n.notectl-image__resize-handle--ne {\n top: -5px;\n right: -5px;\n cursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--sw {\n bottom: -5px;\n left: -5px;\n cursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--se {\n bottom: -5px;\n right: -5px;\n cursor: nwse-resize;\n}\n\n/* Size indicator tooltip */\n.notectl-image__size-indicator {\n position: absolute;\n bottom: -28px;\n left: 50%;\n transform: translateX(-50%);\n padding: 2px 8px;\n background: var(--notectl-tooltip-bg);\n color: var(--notectl-tooltip-fg);\n font-size: 11px;\n font-weight: 500;\n border-radius: 4px;\n white-space: nowrap;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s;\n z-index: 3;\n}\n\n.notectl-image__size-indicator--visible {\n opacity: 1;\n}\n\n/* Keyboard resize hint (shown on selection, hidden during drag) */\n.notectl-image__keyboard-hint {\n display: none;\n position: absolute;\n bottom: -28px;\n left: 50%;\n transform: translateX(-50%);\n padding: 2px 8px;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n white-space: nowrap;\n pointer-events: none;\n z-index: 3;\n}\n\n.notectl-image--selected .notectl-image__keyboard-hint {\n display: block;\n}\n\n.notectl-image--resizing .notectl-image__keyboard-hint {\n display: none;\n}\n\n/* Resizing feedback */\n.notectl-image--resizing .notectl-image__img {\n opacity: 0.85;\n}\n"), this.context = t2, this.registerNodeSpec(t2), this.registerNodeView(t2), (function(t3) {
|
|
5845
|
-
t3.registerCommand("insertImage", () =>
|
|
5815
|
+
t3.registerCommand("insertImage", () => En(t3, { src: "" })), t3.registerCommand("removeImage", () => (function(t4) {
|
|
5846
5816
|
const e2 = t4.getState(), n2 = e2.selection;
|
|
5847
5817
|
if (!C(n2)) return false;
|
|
5848
5818
|
const o2 = e2.getBlock(n2.nodeId);
|
|
@@ -5867,7 +5837,7 @@
|
|
|
5867
5837
|
return e3[e3.length - 1];
|
|
5868
5838
|
})(e2, s2, n2.nodeId);
|
|
5869
5839
|
if (!a2) return false;
|
|
5870
|
-
const d2 = e2.transaction("command").removeNode(s2, l2).setSelection(
|
|
5840
|
+
const d2 = e2.transaction("command").removeNode(s2, l2).setSelection(A(a2, 0)).build();
|
|
5871
5841
|
return t4.dispatch(d2), true;
|
|
5872
5842
|
})(t3));
|
|
5873
5843
|
})(t2), this.registerResizeCommands(t2), this.registerResizeKeymaps(t2), this.registerFileHandler(t2), this.registerToolbarItem(t2);
|
|
@@ -5908,21 +5878,21 @@
|
|
|
5908
5878
|
} }], sanitize: { tags: ["figure", "img"], attrs: ["src", "alt", "width", "height", "class"] } });
|
|
5909
5879
|
}
|
|
5910
5880
|
registerNodeView(t2) {
|
|
5911
|
-
t2.registerNodeView("image",
|
|
5881
|
+
t2.registerNodeView("image", Rn(this.config, this.uploadStates, this.resolvedKeymap));
|
|
5912
5882
|
}
|
|
5913
5883
|
registerResizeCommands(t2) {
|
|
5914
5884
|
const e2 = this.config.resizeStep ?? 10, n2 = this.config.resizeStepLarge ?? 50, o2 = this.config.maxWidth;
|
|
5915
5885
|
t2.registerCommand("resizeImageGrow", () => {
|
|
5916
|
-
const n3 =
|
|
5886
|
+
const n3 = Mn(t2, e2, o2);
|
|
5917
5887
|
return n3 && this.announceCurrentSize(t2), n3;
|
|
5918
5888
|
}), t2.registerCommand("resizeImageShrink", () => {
|
|
5919
|
-
const n3 =
|
|
5889
|
+
const n3 = Mn(t2, -e2, o2);
|
|
5920
5890
|
return n3 && this.announceCurrentSize(t2), n3;
|
|
5921
5891
|
}), t2.registerCommand("resizeImageGrowLarge", () => {
|
|
5922
|
-
const e3 =
|
|
5892
|
+
const e3 = Mn(t2, n2, o2);
|
|
5923
5893
|
return e3 && this.announceCurrentSize(t2), e3;
|
|
5924
5894
|
}), t2.registerCommand("resizeImageShrinkLarge", () => {
|
|
5925
|
-
const e3 =
|
|
5895
|
+
const e3 = Mn(t2, -n2, o2);
|
|
5926
5896
|
return e3 && this.announceCurrentSize(t2), e3;
|
|
5927
5897
|
}), t2.registerCommand("resetImageSize", () => {
|
|
5928
5898
|
const e3 = (function(t3) {
|
|
@@ -5957,14 +5927,14 @@
|
|
|
5957
5927
|
handleFileInsert(t2, e2) {
|
|
5958
5928
|
if (e2.size > this.config.maxFileSize) return;
|
|
5959
5929
|
const n2 = URL.createObjectURL(e2);
|
|
5960
|
-
if (this.blobUrls.add(n2), !
|
|
5930
|
+
if (this.blobUrls.add(n2), !En(t2, { src: n2 })) return URL.revokeObjectURL(n2), void this.blobUrls.delete(n2);
|
|
5961
5931
|
const o2 = t2.getState().selection;
|
|
5962
5932
|
if (!C(o2)) return;
|
|
5963
5933
|
const r2 = o2.nodeId;
|
|
5964
|
-
this.uploadStates.set(r2, "uploading"), t2.getService(
|
|
5934
|
+
this.uploadStates.set(r2, "uploading"), t2.getService(Hn) ? this.uploadFile(t2, e2, r2, n2) : this.uploadStates.set(r2, "complete");
|
|
5965
5935
|
}
|
|
5966
5936
|
async uploadFile(t2, e2, n2, o2) {
|
|
5967
|
-
const r2 = t2.getService(
|
|
5937
|
+
const r2 = t2.getService(Hn);
|
|
5968
5938
|
if (r2) try {
|
|
5969
5939
|
const i2 = await r2.upload(e2);
|
|
5970
5940
|
this.uploadStates.set(n2, "complete");
|
|
@@ -6006,14 +5976,14 @@
|
|
|
6006
5976
|
a2.type = "url", a2.placeholder = "https://...", a2.setAttribute("aria-label", "Image URL"), a2.style.cssText = "width:100%;padding:6px 8px;box-sizing:border-box;border:1px solid var(--notectl-border);border-radius:4px;background:var(--notectl-bg);color:var(--notectl-fg);";
|
|
6007
5977
|
const d2 = document.createElement("button");
|
|
6008
5978
|
d2.type = "button", d2.textContent = "Insert", d2.setAttribute("aria-label", "Insert image"), d2.style.cssText = "width:100%;padding:8px 12px;margin-top:4px;cursor:pointer;border:1px solid var(--notectl-border);border-radius:4px;background:var(--notectl-surface-raised);color:var(--notectl-fg);";
|
|
6009
|
-
const
|
|
5979
|
+
const u2 = () => {
|
|
6010
5980
|
const t3 = a2.value.trim();
|
|
6011
|
-
t3 && (
|
|
5981
|
+
t3 && (En(e2, { src: t3 }), n2(), e2.getContainer().focus());
|
|
6012
5982
|
};
|
|
6013
5983
|
d2.addEventListener("mousedown", (t3) => {
|
|
6014
|
-
t3.preventDefault(), t3.stopPropagation(),
|
|
5984
|
+
t3.preventDefault(), t3.stopPropagation(), u2();
|
|
6015
5985
|
}), a2.addEventListener("keydown", (t3) => {
|
|
6016
|
-
"Enter" === t3.key && (t3.preventDefault(),
|
|
5986
|
+
"Enter" === t3.key && (t3.preventDefault(), u2());
|
|
6017
5987
|
}), t2.appendChild(a2), t2.appendChild(d2), requestAnimationFrame(() => a2.focus());
|
|
6018
5988
|
}
|
|
6019
5989
|
isAcceptedType(t2) {
|
|
@@ -6034,7 +6004,7 @@
|
|
|
6034
6004
|
const o2 = n2.attrs?.alt ?? "", r2 = n2.attrs?.width, i2 = n2.attrs?.height, s2 = ["Image selected."];
|
|
6035
6005
|
o2 && s2.push(`Alt text: ${o2}.`), void 0 !== r2 && void 0 !== i2 && s2.push(`Size: ${r2} by ${i2} pixels.`);
|
|
6036
6006
|
const c2 = this.resolvedKeymap.shrinkWidth ?? null, l2 = this.resolvedKeymap.growWidth ?? null;
|
|
6037
|
-
c2 && l2 && s2.push(`${
|
|
6007
|
+
c2 && l2 && s2.push(`${ae(c2)} / ${ae(l2)} to resize.`), this.context.announce(s2.join(" "));
|
|
6038
6008
|
}
|
|
6039
6009
|
announceCurrentSize(t2) {
|
|
6040
6010
|
const e2 = t2.getState(), n2 = e2.selection;
|
|
@@ -6044,13 +6014,13 @@
|
|
|
6044
6014
|
const r2 = o2.attrs?.width, i2 = o2.attrs?.height;
|
|
6045
6015
|
void 0 !== r2 && void 0 !== i2 && t2.announce(`Image resized to ${r2} by ${i2} pixels.`);
|
|
6046
6016
|
}
|
|
6047
|
-
}, t.LIGHT_THEME =
|
|
6017
|
+
}, t.LIGHT_THEME = to, t.LinkPlugin = class {
|
|
6048
6018
|
id = "link";
|
|
6049
6019
|
name = "Link";
|
|
6050
6020
|
priority = 25;
|
|
6051
6021
|
config;
|
|
6052
6022
|
constructor(t2) {
|
|
6053
|
-
this.config = { ...
|
|
6023
|
+
this.config = { ...ye, ...t2 };
|
|
6054
6024
|
}
|
|
6055
6025
|
init(t2) {
|
|
6056
6026
|
this.registerMarkSpec(t2), this.registerCommands(t2), this.registerKeymap(t2), this.registerToolbarItem(t2);
|
|
@@ -6075,7 +6045,7 @@
|
|
|
6075
6045
|
t2.registerKeymap({ "Mod-K": () => t2.executeCommand("toggleLink") });
|
|
6076
6046
|
}
|
|
6077
6047
|
registerToolbarItem(t2) {
|
|
6078
|
-
t2.registerToolbarItem({ id: "link", group: "insert", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>', label: "Link", tooltip: `Insert Link (${
|
|
6048
|
+
t2.registerToolbarItem({ id: "link", group: "insert", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>', label: "Link", tooltip: `Insert Link (${ae("Mod-K")})`, command: "toggleLink", priority: 60, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, e2) => {
|
|
6079
6049
|
this.renderLinkPopup(t3, e2);
|
|
6080
6050
|
}, isActive: (t3) => this.isLinkActive(t3), isEnabled: (t3) => !_(t3.selection) });
|
|
6081
6051
|
}
|
|
@@ -6121,10 +6091,10 @@
|
|
|
6121
6091
|
for (; l2 > 0 && o3[l2 - 1]?.hasLink; ) l2--;
|
|
6122
6092
|
let a2 = s2;
|
|
6123
6093
|
for (; a2 < o3.length - 1 && o3[a2 + 1]?.hasLink; ) a2++;
|
|
6124
|
-
const d2 = o3[l2],
|
|
6125
|
-
if (!d2 || !
|
|
6126
|
-
const
|
|
6127
|
-
i2.removeMark(n2.anchor.blockId,
|
|
6094
|
+
const d2 = o3[l2], u2 = o3[a2];
|
|
6095
|
+
if (!d2 || !u2) return false;
|
|
6096
|
+
const h2 = d2.pos, p2 = u2.end;
|
|
6097
|
+
i2.removeMark(n2.anchor.blockId, h2, p2, { type: "link" });
|
|
6128
6098
|
} else kt(e2, r2, (t3, e3, n3) => {
|
|
6129
6099
|
i2.removeMark(t3, e3, n3, { type: "link" });
|
|
6130
6100
|
});
|
|
@@ -6161,7 +6131,7 @@
|
|
|
6161
6131
|
priority = 35;
|
|
6162
6132
|
config;
|
|
6163
6133
|
constructor(t2) {
|
|
6164
|
-
this.config = { ...
|
|
6134
|
+
this.config = { ...ve, ...t2 };
|
|
6165
6135
|
}
|
|
6166
6136
|
init(t2) {
|
|
6167
6137
|
t2.registerStyleSheet(`
|
|
@@ -6255,7 +6225,7 @@
|
|
|
6255
6225
|
const s2 = t3.getBlock(i2.anchor.blockId);
|
|
6256
6226
|
if (!s2 || "paragraph" !== s2.type) return null;
|
|
6257
6227
|
const c2 = e3[0] ?? "", l2 = c2.length, a2 = { listType: n2.type, indent: 0 };
|
|
6258
|
-
return "checklist" === n2.type && (a2.checked = c2.includes("[x]")), t3.transaction("input").deleteTextAt(i2.anchor.blockId, o2, o2 + l2).setBlockType(i2.anchor.blockId, "list_item", a2).setSelection(
|
|
6228
|
+
return "checklist" === n2.type && (a2.checked = c2.includes("[x]")), t3.transaction("input").deleteTextAt(i2.anchor.blockId, o2, o2 + l2).setBlockType(i2.anchor.blockId, "list_item", a2).setSelection(A(i2.anchor.blockId, 0)).build();
|
|
6259
6229
|
} });
|
|
6260
6230
|
}
|
|
6261
6231
|
registerToolbarItems(t2) {
|
|
@@ -6326,7 +6296,7 @@
|
|
|
6326
6296
|
}
|
|
6327
6297
|
const r2 = d(), i2 = { listType: O(o2, "list_item") ? o2.attrs.listType : "bullet", indent: O(o2, "list_item") ? o2.attrs.indent : 0 };
|
|
6328
6298
|
"checklist" === i2.listType && (i2.checked = false);
|
|
6329
|
-
const s2 = e2.transaction("input").splitBlock(n2.anchor.blockId, n2.anchor.offset, r2).setBlockType(r2, "list_item", i2).setSelection(
|
|
6299
|
+
const s2 = e2.transaction("input").splitBlock(n2.anchor.blockId, n2.anchor.offset, r2).setBlockType(r2, "list_item", i2).setSelection(A(r2, 0)).build();
|
|
6330
6300
|
return t2.dispatch(s2), true;
|
|
6331
6301
|
}
|
|
6332
6302
|
isListActive(t2, e2) {
|
|
@@ -6335,15 +6305,129 @@
|
|
|
6335
6305
|
return "list_item" === n2?.type && n2.attrs?.listType === e2;
|
|
6336
6306
|
}
|
|
6337
6307
|
getEnabledTypes() {
|
|
6338
|
-
return
|
|
6308
|
+
return xe.filter((t2) => this.config.types.includes(t2.type));
|
|
6339
6309
|
}
|
|
6340
|
-
}, t.NotectlEditor =
|
|
6310
|
+
}, t.NotectlEditor = Wo, t.PRINT_SERVICE_KEY = Xn, t.PluginManager = Zt, t.PrintPlugin = class {
|
|
6311
|
+
id = "print";
|
|
6312
|
+
name = "Print";
|
|
6313
|
+
config;
|
|
6314
|
+
service = null;
|
|
6315
|
+
constructor(t2) {
|
|
6316
|
+
this.config = t2 ?? {};
|
|
6317
|
+
}
|
|
6318
|
+
init(t2) {
|
|
6319
|
+
const e2 = t2.getContainer(), n2 = e2.getRootNode();
|
|
6320
|
+
if (n2 instanceof ShadowRoot) {
|
|
6321
|
+
const o3 = n2.host, r3 = t2.getEventBus();
|
|
6322
|
+
this.service = /* @__PURE__ */ (function(t3, e3, n3, o4) {
|
|
6323
|
+
function r4(t4) {
|
|
6324
|
+
return t4 ?? {};
|
|
6325
|
+
}
|
|
6326
|
+
function i3(r5) {
|
|
6327
|
+
const i4 = { options: r5, cancelled: false };
|
|
6328
|
+
if (o4.emit(Yn, i4), i4.cancelled) return null;
|
|
6329
|
+
const s2 = i4.options, c2 = (function(t4, e4, n4, o5 = "en") {
|
|
6330
|
+
return ["<!DOCTYPE html>", `<html lang="${o5}">`, "<head>", '<meta charset="utf-8">', `<title>${n4.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</title>`, `<style>${t4}</style>`, "</head>", `<body>${e4}</body>`, "</html>"].join("\n");
|
|
6331
|
+
})((function(t4, e4, n4) {
|
|
6332
|
+
const o5 = [], r6 = (function(t5) {
|
|
6333
|
+
const e5 = [];
|
|
6334
|
+
for (const n5 of t5.adoptedStyleSheets) for (const t6 of n5.cssRules) e5.push(t6.cssText);
|
|
6335
|
+
return e5.join("\n");
|
|
6336
|
+
})(t4);
|
|
6337
|
+
r6 && o5.push(r6);
|
|
6338
|
+
const i5 = (function(t5) {
|
|
6339
|
+
const e5 = getComputedStyle(t5), n5 = [];
|
|
6340
|
+
for (let t6 = 0; t6 < e5.length; t6++) {
|
|
6341
|
+
const o6 = e5[t6] ?? "";
|
|
6342
|
+
if (o6.startsWith("--notectl-")) {
|
|
6343
|
+
const t7 = e5.getPropertyValue(o6).trim();
|
|
6344
|
+
t7 && n5.push(` ${o6}: ${t7};`);
|
|
6345
|
+
}
|
|
6346
|
+
}
|
|
6347
|
+
return 0 === n5.length ? "" : `:root {
|
|
6348
|
+
${n5.join("\n")}
|
|
6349
|
+
}`;
|
|
6350
|
+
})(e4);
|
|
6351
|
+
i5 && o5.push(i5);
|
|
6352
|
+
const s3 = (function(t5) {
|
|
6353
|
+
const e5 = [], n5 = [];
|
|
6354
|
+
t5.margin && n5.push(` margin: ${t5.margin};`), t5.orientation && n5.push(` size: A4 ${t5.orientation};`), n5.length > 0 && e5.push(`@page {
|
|
6355
|
+
${n5.join("\n")}
|
|
6356
|
+
}`);
|
|
6357
|
+
const o6 = [];
|
|
6358
|
+
return o6.push("[data-notectl-no-print] { display: none !important; }"), o6.push(".notectl-code-block { white-space: pre-wrap !important; word-break: break-all !important; page-break-inside: avoid; }"), o6.push("img { page-break-inside: avoid; }"), o6.push(".notectl-table { break-inside: avoid; }"), t5.printBackground && o6.push("* { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }"), e5.push(`@media print {
|
|
6359
|
+
${o6.join("\n ")}
|
|
6360
|
+
}`), e5.join("\n\n");
|
|
6361
|
+
})(n4);
|
|
6362
|
+
return s3 && o5.push(s3), n4.customCSS && o5.push(n4.customCSS), o5.join("\n\n");
|
|
6363
|
+
})(t3, e3, s2), (function(t4, e4) {
|
|
6364
|
+
const n4 = (function(t5) {
|
|
6365
|
+
return (t5.querySelector(".notectl-content") ?? t5).cloneNode(true);
|
|
6366
|
+
})(t4);
|
|
6367
|
+
return (function(t5) {
|
|
6368
|
+
t5.removeAttribute("contenteditable");
|
|
6369
|
+
const e5 = ["notectl-node-selected", "notectl-content--empty"];
|
|
6370
|
+
for (const n5 of e5) {
|
|
6371
|
+
t5.classList.remove(n5);
|
|
6372
|
+
for (const e6 of t5.querySelectorAll(`.${n5}`)) e6.classList.remove(n5);
|
|
6373
|
+
}
|
|
6374
|
+
t5.removeAttribute("data-placeholder");
|
|
6375
|
+
})(n4), (function(t5, e5) {
|
|
6376
|
+
if (e5.excludeBlockTypes) for (const n5 of e5.excludeBlockTypes) {
|
|
6377
|
+
const e6 = t5.querySelectorAll(`[data-block-type="${n5}"]`);
|
|
6378
|
+
for (const t6 of e6) t6.remove();
|
|
6379
|
+
}
|
|
6380
|
+
if (e5.pageBreakBefore) for (const n5 of e5.pageBreakBefore) {
|
|
6381
|
+
const e6 = t5.querySelectorAll(`[data-block-type="${n5}"]`);
|
|
6382
|
+
for (const t6 of e6) t6.style.breakBefore = "page", t6.style.pageBreakBefore = "always";
|
|
6383
|
+
}
|
|
6384
|
+
})(n4, e4), (function(t5, e5) {
|
|
6385
|
+
if (e5.header) {
|
|
6386
|
+
const n5 = document.createElement("div");
|
|
6387
|
+
n5.className = "notectl-print-header", n5.innerHTML = Gn(e5.header), t5.insertBefore(n5, t5.firstChild);
|
|
6388
|
+
}
|
|
6389
|
+
if (e5.footer) {
|
|
6390
|
+
const n5 = document.createElement("div");
|
|
6391
|
+
n5.className = "notectl-print-footer", n5.innerHTML = Gn(e5.footer), t5.appendChild(n5);
|
|
6392
|
+
}
|
|
6393
|
+
})(n4, e4), n4;
|
|
6394
|
+
})(n3, s2).outerHTML, s2.title ?? "", e3.closest("[lang]")?.getAttribute("lang") ?? (document.documentElement.lang || "en")), l2 = { html: c2 };
|
|
6395
|
+
return o4.emit(Jn, l2), c2;
|
|
6396
|
+
}
|
|
6397
|
+
return { print(t4) {
|
|
6398
|
+
const e4 = i3(r4(t4));
|
|
6399
|
+
if (!e4) return;
|
|
6400
|
+
const n4 = document.createElement("iframe");
|
|
6401
|
+
n4.style.cssText = "position:fixed;left:-9999px;width:0;height:0;border:none;", document.body.appendChild(n4);
|
|
6402
|
+
const o5 = n4.contentDocument;
|
|
6403
|
+
if (!o5) return void document.body.removeChild(n4);
|
|
6404
|
+
o5.open(), o5.write(e4), o5.close();
|
|
6405
|
+
const s2 = () => {
|
|
6406
|
+
n4.remove();
|
|
6407
|
+
};
|
|
6408
|
+
n4.contentWindow ? (n4.contentWindow.addEventListener("afterprint", s2, { once: true }), n4.contentWindow.print()) : s2();
|
|
6409
|
+
}, toHTML: (t4) => i3(r4(t4)) ?? "" };
|
|
6410
|
+
})(n2, o3, e2, r3);
|
|
6411
|
+
} else this.service = Zn;
|
|
6412
|
+
t2.registerService(Xn, this.service);
|
|
6413
|
+
const o2 = this.config.defaults ?? {}, r2 = this.service;
|
|
6414
|
+
t2.registerCommand("print", () => (t2.announce("Printing"), r2.print(o2), true));
|
|
6415
|
+
const i2 = this.config.keyBinding ?? "Mod-P";
|
|
6416
|
+
if (t2.registerKeymap({ [i2]: () => (t2.executeCommand("print"), true) }), false !== this.config.showToolbarItem) {
|
|
6417
|
+
const e3 = ae(i2);
|
|
6418
|
+
t2.registerToolbarItem({ id: "print", group: "actions", label: "Print", tooltip: `Print (${e3})`, icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"/></svg>', command: "print", priority: 900 });
|
|
6419
|
+
}
|
|
6420
|
+
}
|
|
6421
|
+
destroy() {
|
|
6422
|
+
this.service = null;
|
|
6423
|
+
}
|
|
6424
|
+
}, t.SchemaRegistry = V, t.ServiceKey = Kt, t.StrikethroughPlugin = class {
|
|
6341
6425
|
id = "strikethrough";
|
|
6342
6426
|
name = "Strikethrough";
|
|
6343
6427
|
priority = 22;
|
|
6344
6428
|
config;
|
|
6345
6429
|
constructor(t2) {
|
|
6346
|
-
this.config = { ...
|
|
6430
|
+
this.config = { ...Se, ...t2 };
|
|
6347
6431
|
}
|
|
6348
6432
|
init(t2) {
|
|
6349
6433
|
this.registerMarkSpec(t2), this.registerCommand(t2), this.registerKeymap(t2), this.registerToolbarItem(t2);
|
|
@@ -6361,7 +6445,7 @@
|
|
|
6361
6445
|
t2.registerKeymap({ "Mod-Shift-X": () => t2.executeCommand("toggleStrikethrough") });
|
|
6362
6446
|
}
|
|
6363
6447
|
registerToolbarItem(t2) {
|
|
6364
|
-
t2.registerToolbarItem({ id: "strikethrough", group: "format", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"/></svg>', label: "Strikethrough", tooltip: `Strikethrough (${
|
|
6448
|
+
t2.registerToolbarItem({ id: "strikethrough", group: "format", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"/></svg>', label: "Strikethrough", tooltip: `Strikethrough (${ae("Mod-Shift-X")})`, command: "toggleStrikethrough", priority: 40, separatorAfter: this.config.separatorAfter, isActive: (t3) => zt(t3, "strikethrough") });
|
|
6365
6449
|
}
|
|
6366
6450
|
}, t.SuperSubPlugin = class {
|
|
6367
6451
|
id = "super-sub";
|
|
@@ -6369,10 +6453,10 @@
|
|
|
6369
6453
|
priority = 23;
|
|
6370
6454
|
config;
|
|
6371
6455
|
constructor(t2) {
|
|
6372
|
-
this.config = { ...
|
|
6456
|
+
this.config = { ...Cn, ...t2 };
|
|
6373
6457
|
}
|
|
6374
6458
|
init(t2) {
|
|
6375
|
-
const e2 =
|
|
6459
|
+
const e2 = Tn.filter((t3) => this.config[t3.configKey]), n2 = e2.filter((t3) => this.isToolbarVisible(t3.configKey)).at(-1);
|
|
6376
6460
|
for (const o2 of e2) {
|
|
6377
6461
|
const e3 = !!this.config.separatorAfter && o2 === n2;
|
|
6378
6462
|
this.registerMark(t2, o2, e3);
|
|
@@ -6380,16 +6464,16 @@
|
|
|
6380
6464
|
this.registerKeymaps(t2, e2), this.registerExclusivityMiddleware(t2, e2), this.registerDisabledToolbarItems(t2);
|
|
6381
6465
|
}
|
|
6382
6466
|
registerMark(t2, e2, n2) {
|
|
6383
|
-
const o2 =
|
|
6467
|
+
const o2 = Bn(e2.type), r2 = this.isToolbarVisible(e2.configKey);
|
|
6384
6468
|
t2.registerMarkSpec({ type: e2.type, rank: e2.rank, toDOM: () => document.createElement(e2.tag), toHTMLString: (t3, n3) => e2.toHTMLString(n3), parseHTML: e2.parseHTML, sanitize: e2.sanitize }), t2.registerCommand(o2, () => {
|
|
6385
6469
|
const n3 = yt(t2.getState(), e2.type);
|
|
6386
6470
|
return !!n3 && (t2.dispatch(n3), true);
|
|
6387
|
-
}), r2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, tooltip: `${e2.label} (${
|
|
6471
|
+
}), r2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, tooltip: `${e2.label} (${ae(e2.keyBinding)})`, command: o2, priority: e2.toolbarPriority, separatorAfter: n2, isActive: (t3) => zt(t3, e2.type) });
|
|
6388
6472
|
}
|
|
6389
6473
|
registerKeymaps(t2, e2) {
|
|
6390
6474
|
const n2 = {};
|
|
6391
6475
|
for (const o2 of e2) {
|
|
6392
|
-
const e3 =
|
|
6476
|
+
const e3 = Bn(o2.type);
|
|
6393
6477
|
n2[o2.keyBinding] = () => t2.executeCommand(e3);
|
|
6394
6478
|
}
|
|
6395
6479
|
Object.keys(n2).length > 0 && t2.registerKeymap(n2);
|
|
@@ -6403,7 +6487,7 @@
|
|
|
6403
6487
|
r2.push(e4);
|
|
6404
6488
|
continue;
|
|
6405
6489
|
}
|
|
6406
|
-
const t4 = e4.mark.type, n3 =
|
|
6490
|
+
const t4 = e4.mark.type, n3 = Tn.find((e5) => e5.type === t4);
|
|
6407
6491
|
if (!n3) {
|
|
6408
6492
|
r2.push(e4);
|
|
6409
6493
|
continue;
|
|
@@ -6424,9 +6508,9 @@
|
|
|
6424
6508
|
});
|
|
6425
6509
|
}
|
|
6426
6510
|
registerDisabledToolbarItems(t2) {
|
|
6427
|
-
if (this.config.toolbar) for (const e2 of
|
|
6511
|
+
if (this.config.toolbar) for (const e2 of Tn) {
|
|
6428
6512
|
const n2 = this.config[e2.configKey], o2 = this.config.toolbar[e2.configKey] ?? true;
|
|
6429
|
-
!n2 && o2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, command:
|
|
6513
|
+
!n2 && o2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, command: Bn(e2.type), priority: e2.toolbarPriority, isEnabled: () => false });
|
|
6430
6514
|
}
|
|
6431
6515
|
}
|
|
6432
6516
|
isToolbarVisible(t2) {
|
|
@@ -6441,68 +6525,68 @@
|
|
|
6441
6525
|
cleanupMouseSelection = null;
|
|
6442
6526
|
context = null;
|
|
6443
6527
|
constructor(t2) {
|
|
6444
|
-
this.config = { ...
|
|
6528
|
+
this.config = { ...xn, ...t2 };
|
|
6445
6529
|
}
|
|
6446
6530
|
init(t2) {
|
|
6447
|
-
t2.registerStyleSheet("\n/* Table */\n.notectl-table-wrapper {\n margin: 8px 0;\n overflow-x: auto;\n position: relative;\n}\n\n.notectl-table {\n width: 100%;\n border-collapse: collapse;\n table-layout: fixed;\n}\n\n.notectl-table td {\n border: 1px solid var(--notectl-border);\n padding: 8px 12px;\n min-width: 60px;\n vertical-align: top;\n min-height: 1.6em;\n}\n\n.notectl-table td:focus-within {\n outline: 2px solid var(--notectl-primary);\n outline-offset: -2px;\n}\n\n.notectl-table-cell--selected {\n background: var(--notectl-primary-muted);\n}\n\n/* Table Context Menu */\n.notectl-table-context-menu {\n position: fixed;\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px var(--notectl-shadow);\n padding: 4px 0;\n min-width: 180px;\n z-index: 10000;\n}\n\n.notectl-table-context-menu button {\n display: block;\n width: 100%;\n padding: 8px 12px;\n text-align: left;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n font-family: inherit;\n}\n\n.notectl-table-context-menu button:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-table-context-menu hr {\n border: none;\n border-top: 1px solid var(--notectl-border);\n margin: 4px 0;\n}\n\n/* === Table Controls === */\n\n/* Outer container for table + controls */\n.ntbl-container {\n position: relative;\n margin: 8px 0;\n padding: 24px 0 0 24px;\n}\n\n.ntbl-container .notectl-table-wrapper {\n margin: 0;\n}\n\n.ntbl-container.notectl-table--selected .notectl-table-wrapper {\n outline: 2px solid var(--notectl-primary-fg);\n outline-offset: 2px;\n border-radius: 6px;\n}\n\n/* --- Column Handle Bar --- */\n.ntbl-col-bar {\n position: absolute;\n top: 0;\n left: 24px;\n height: 20px;\n display: flex;\n opacity: 0;\n transition: opacity 0.2s ease;\n z-index: 3;\n pointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-col-bar,\n.ntbl-container:focus-within .ntbl-col-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-col-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* --- Row Handle Bar --- */\n.ntbl-row-bar {\n position: absolute;\n top: 24px;\n left: 0;\n width: 20px;\n display: flex;\n flex-direction: column;\n opacity: 0;\n transition: opacity 0.2s ease;\n z-index: 3;\n pointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-row-bar,\n.ntbl-container:focus-within .ntbl-row-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-row-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* --- Handle (shared base) --- */\n.ntbl-handle {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: background 0.15s ease;\n border-radius: 3px;\n}\n\n.ntbl-col-handle {\n height: 100%;\n background: var(--notectl-hover-bg);\n border-radius: 4px 4px 0 0;\n}\n\n.ntbl-col-handle:hover {\n background: var(--notectl-border);\n}\n\n.ntbl-row-handle {\n width: 100%;\n background: var(--notectl-hover-bg);\n border-radius: 4px 0 0 4px;\n}\n\n.ntbl-row-handle:hover {\n background: var(--notectl-border);\n}\n\n/* --- Handle Delete Button --- */\n.ntbl-handle-delete {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n border: none;\n background: transparent;\n color: var(--notectl-fg-muted);\n cursor: pointer;\n border-radius: 3px;\n padding: 0;\n opacity: 0;\n transform: scale(0.7);\n transition: opacity 0.15s, transform 0.15s,\n background 0.15s, color 0.15s;\n}\n\n.ntbl-handle:hover .ntbl-handle-delete,\n.ntbl-handle:focus-within .ntbl-handle-delete {\n opacity: 1;\n transform: scale(1);\n}\n\n.ntbl-handle-delete:hover,\n.ntbl-handle-delete:focus-visible {\n background: var(--notectl-danger-muted);\n color: var(--notectl-danger);\n}\n\n.ntbl-handle-delete:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Insert Lines --- */\n.ntbl-insert-line {\n position: absolute;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s ease;\n z-index: 6;\n}\n\n.ntbl-insert-line--visible {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-insert-line--horizontal {\n height: 2px;\n background: linear-gradient(\n 90deg,\n transparent,\n var(--notectl-primary) 8%,\n var(--notectl-primary) 92%,\n transparent\n );\n box-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--vertical {\n width: 2px;\n background: linear-gradient(\n 180deg,\n transparent,\n var(--notectl-primary) 8%,\n var(--notectl-primary) 92%,\n transparent\n );\n box-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n/* --- Insert Button on Line --- */\n.ntbl-insert-btn {\n position: absolute;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background: var(--notectl-bg);\n border: 2px solid var(--notectl-primary);\n color: var(--notectl-primary);\n cursor: pointer;\n pointer-events: all;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n box-shadow: 0 2px 8px var(--notectl-focus-ring);\n transition: background 0.15s, color 0.15s,\n transform 0.15s, box-shadow 0.15s;\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn {\n left: 50%;\n top: -9px;\n transform: translateX(-50%);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn {\n top: 50%;\n left: -9px;\n transform: translateY(-50%);\n}\n\n.ntbl-insert-btn:hover,\n.ntbl-insert-btn:focus-visible {\n background: var(--notectl-primary);\n color: var(--notectl-bg);\n box-shadow: 0 2px 12px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn:hover {\n transform: translateX(-50%) scale(1.2);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn:hover {\n transform: translateY(-50%) scale(1.2);\n}\n\n/* --- Add Row / Add Column Zones --- */\n.ntbl-add-zone {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.2s ease,\n border-color 0.2s ease;\n}\n\n.ntbl-container:hover .ntbl-add-zone,\n.ntbl-container:focus-within .ntbl-add-zone {\n opacity: 1;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-add-zone {\n opacity: 1;\n}\n\n.ntbl-delete-table-btn {\n position: absolute;\n top: 0;\n left: 0;\n width: 20px;\n height: 20px;\n border: 1px solid var(--notectl-danger);\n border-radius: 4px;\n background: var(--notectl-bg);\n color: var(--notectl-danger);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n z-index: 7;\n}\n\n.ntbl-container:hover .ntbl-delete-table-btn,\n.ntbl-container:focus-within .ntbl-delete-table-btn,\n.ntbl-container.notectl-table--selected .ntbl-delete-table-btn {\n opacity: 1;\n}\n\n.ntbl-delete-table-btn:hover,\n.ntbl-delete-table-btn:focus-visible {\n background: var(--notectl-danger-muted);\n border-color: var(--notectl-danger);\n}\n\n.ntbl-delete-table-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-row {\n bottom: 0;\n height: 24px;\n border: 1px dashed var(--notectl-border);\n border-radius: 0 0 6px 6px;\n border-top: none;\n color: var(--notectl-fg-muted);\n transform: translateY(100%);\n}\n\n.ntbl-add-row:hover,\n.ntbl-add-row:focus-visible {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n color: var(--notectl-primary);\n}\n\n.ntbl-add-row:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-col {\n right: 0;\n top: 24px;\n width: 24px;\n border: 1px dashed var(--notectl-border);\n border-radius: 0 6px 6px 0;\n border-left: none;\n color: var(--notectl-fg-muted);\n transform: translateX(100%);\n}\n\n.ntbl-add-col:hover,\n.ntbl-add-col:focus-visible {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n color: var(--notectl-primary);\n}\n\n.ntbl-add-col:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 0.2s ease;\n}\n\n.ntbl-add-zone:hover .ntbl-add-icon {\n transform: scale(1.15);\n}\n"), this.context = t2, this.registerNodeSpecs(t2), this.registerNodeViews(t2),
|
|
6531
|
+
t2.registerStyleSheet("\n/* Table */\n.notectl-table-wrapper {\n margin: 8px 0;\n overflow-x: auto;\n position: relative;\n}\n\n.notectl-table {\n width: 100%;\n border-collapse: collapse;\n table-layout: fixed;\n}\n\n.notectl-table td {\n border: 1px solid var(--notectl-border);\n padding: 8px 12px;\n min-width: 60px;\n vertical-align: top;\n min-height: 1.6em;\n}\n\n.notectl-table td:focus-within {\n outline: 2px solid var(--notectl-primary);\n outline-offset: -2px;\n}\n\n.notectl-table-cell--selected {\n background: var(--notectl-primary-muted);\n}\n\n/* Table Context Menu */\n.notectl-table-context-menu {\n position: fixed;\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px var(--notectl-shadow);\n padding: 4px 0;\n min-width: 180px;\n z-index: 10000;\n}\n\n.notectl-table-context-menu button {\n display: block;\n width: 100%;\n padding: 8px 12px;\n text-align: left;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n font-family: inherit;\n}\n\n.notectl-table-context-menu button:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-table-context-menu hr {\n border: none;\n border-top: 1px solid var(--notectl-border);\n margin: 4px 0;\n}\n\n/* === Table Controls === */\n\n/* Outer container for table + controls */\n.ntbl-container {\n position: relative;\n margin: 8px 0;\n padding: 24px 0 0 24px;\n}\n\n.ntbl-container .notectl-table-wrapper {\n margin: 0;\n}\n\n.ntbl-container.notectl-table--selected .notectl-table-wrapper {\n outline: 2px solid var(--notectl-primary-fg);\n outline-offset: 2px;\n border-radius: 6px;\n}\n\n/* --- Column Handle Bar --- */\n.ntbl-col-bar {\n position: absolute;\n top: 0;\n left: 24px;\n height: 20px;\n display: flex;\n opacity: 0;\n transition: opacity 0.2s ease;\n z-index: 3;\n pointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-col-bar,\n.ntbl-container:focus-within .ntbl-col-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-col-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* --- Row Handle Bar --- */\n.ntbl-row-bar {\n position: absolute;\n top: 24px;\n left: 0;\n width: 20px;\n display: flex;\n flex-direction: column;\n opacity: 0;\n transition: opacity 0.2s ease;\n z-index: 3;\n pointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-row-bar,\n.ntbl-container:focus-within .ntbl-row-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-row-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* --- Handle (shared base) --- */\n.ntbl-handle {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: background 0.15s ease;\n border-radius: 3px;\n}\n\n.ntbl-col-handle {\n height: 100%;\n background: var(--notectl-hover-bg);\n border-radius: 4px 4px 0 0;\n}\n\n.ntbl-col-handle:hover {\n background: var(--notectl-border);\n}\n\n.ntbl-row-handle {\n width: 100%;\n background: var(--notectl-hover-bg);\n border-radius: 4px 0 0 4px;\n}\n\n.ntbl-row-handle:hover {\n background: var(--notectl-border);\n}\n\n/* --- Handle Delete Button --- */\n.ntbl-handle-delete {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n border: none;\n background: transparent;\n color: var(--notectl-fg-muted);\n cursor: pointer;\n border-radius: 3px;\n padding: 0;\n opacity: 0;\n transform: scale(0.7);\n transition: opacity 0.15s, transform 0.15s,\n background 0.15s, color 0.15s;\n}\n\n.ntbl-handle:hover .ntbl-handle-delete,\n.ntbl-handle:focus-within .ntbl-handle-delete {\n opacity: 1;\n transform: scale(1);\n}\n\n.ntbl-handle-delete:hover,\n.ntbl-handle-delete:focus-visible {\n background: var(--notectl-danger-muted);\n color: var(--notectl-danger);\n}\n\n.ntbl-handle-delete:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Insert Lines --- */\n.ntbl-insert-line {\n position: absolute;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s ease;\n z-index: 6;\n}\n\n.ntbl-insert-line--visible {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-insert-line--horizontal {\n height: 2px;\n background: linear-gradient(\n 90deg,\n transparent,\n var(--notectl-primary) 8%,\n var(--notectl-primary) 92%,\n transparent\n );\n box-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--vertical {\n width: 2px;\n background: linear-gradient(\n 180deg,\n transparent,\n var(--notectl-primary) 8%,\n var(--notectl-primary) 92%,\n transparent\n );\n box-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n/* --- Insert Button on Line --- */\n.ntbl-insert-btn {\n position: absolute;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background: var(--notectl-bg);\n border: 2px solid var(--notectl-primary);\n color: var(--notectl-primary);\n cursor: pointer;\n pointer-events: all;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n box-shadow: 0 2px 8px var(--notectl-focus-ring);\n transition: background 0.15s, color 0.15s,\n transform 0.15s, box-shadow 0.15s;\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn {\n left: 50%;\n top: -9px;\n transform: translateX(-50%);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn {\n top: 50%;\n left: -9px;\n transform: translateY(-50%);\n}\n\n.ntbl-insert-btn:hover,\n.ntbl-insert-btn:focus-visible {\n background: var(--notectl-primary);\n color: var(--notectl-bg);\n box-shadow: 0 2px 12px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn:hover {\n transform: translateX(-50%) scale(1.2);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn:hover {\n transform: translateY(-50%) scale(1.2);\n}\n\n/* --- Add Row / Add Column Zones --- */\n.ntbl-add-zone {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.2s ease,\n border-color 0.2s ease;\n}\n\n.ntbl-container:hover .ntbl-add-zone,\n.ntbl-container:focus-within .ntbl-add-zone {\n opacity: 1;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-add-zone {\n opacity: 1;\n}\n\n.ntbl-delete-table-btn {\n position: absolute;\n top: 0;\n left: 0;\n width: 20px;\n height: 20px;\n border: 1px solid var(--notectl-danger);\n border-radius: 4px;\n background: var(--notectl-bg);\n color: var(--notectl-danger);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n z-index: 7;\n}\n\n.ntbl-container:hover .ntbl-delete-table-btn,\n.ntbl-container:focus-within .ntbl-delete-table-btn,\n.ntbl-container.notectl-table--selected .ntbl-delete-table-btn {\n opacity: 1;\n}\n\n.ntbl-delete-table-btn:hover,\n.ntbl-delete-table-btn:focus-visible {\n background: var(--notectl-danger-muted);\n border-color: var(--notectl-danger);\n}\n\n.ntbl-delete-table-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-row {\n bottom: 0;\n height: 24px;\n border: 1px dashed var(--notectl-border);\n border-radius: 0 0 6px 6px;\n border-top: none;\n color: var(--notectl-fg-muted);\n transform: translateY(100%);\n}\n\n.ntbl-add-row:hover,\n.ntbl-add-row:focus-visible {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n color: var(--notectl-primary);\n}\n\n.ntbl-add-row:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-col {\n right: 0;\n top: 24px;\n width: 24px;\n border: 1px dashed var(--notectl-border);\n border-radius: 0 6px 6px 0;\n border-left: none;\n color: var(--notectl-fg-muted);\n transform: translateX(100%);\n}\n\n.ntbl-add-col:hover,\n.ntbl-add-col:focus-visible {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n color: var(--notectl-primary);\n}\n\n.ntbl-add-col:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 0.2s ease;\n}\n\n.ntbl-add-zone:hover .ntbl-add-icon {\n transform: scale(1.15);\n}\n"), this.context = t2, this.registerNodeSpecs(t2), this.registerNodeViews(t2), sn(t2), (function(t3) {
|
|
6448
6532
|
const e2 = { Tab: () => (function(t4) {
|
|
6449
|
-
return
|
|
6533
|
+
return cn(t4, (e3, n2, o2) => o2.colIndex < o2.totalCols - 1 ? an(t4, o2.tableId, o2.rowIndex, o2.colIndex + 1) : o2.rowIndex < o2.totalRows - 1 ? an(t4, o2.tableId, o2.rowIndex + 1, 0) : (on(t4), true));
|
|
6450
6534
|
})(t3), "Shift-Tab": () => (function(t4) {
|
|
6451
|
-
return
|
|
6535
|
+
return cn(t4, (e3, n2, o2) => o2.colIndex > 0 ? an(t4, o2.tableId, o2.rowIndex, o2.colIndex - 1) : !(o2.rowIndex > 0) || an(t4, o2.tableId, o2.rowIndex - 1, o2.totalCols - 1));
|
|
6452
6536
|
})(t3), Enter: () => (function(t4) {
|
|
6453
6537
|
const e3 = t4.getState();
|
|
6454
6538
|
if (C(e3.selection)) return false;
|
|
6455
6539
|
const n2 = e3.getBlock(e3.selection.anchor.blockId);
|
|
6456
6540
|
if (n2 && "paragraph" !== n2.type) return false;
|
|
6457
|
-
const o2 =
|
|
6458
|
-
return !!o2 && (!(o2.rowIndex < o2.totalRows - 1) ||
|
|
6541
|
+
const o2 = Ue(e3, e3.selection.anchor.blockId);
|
|
6542
|
+
return !!o2 && (!(o2.rowIndex < o2.totalRows - 1) || an(t4, o2.tableId, o2.rowIndex + 1, o2.colIndex));
|
|
6459
6543
|
})(t3), Backspace: () => (function(t4) {
|
|
6460
|
-
return
|
|
6544
|
+
return cn(t4, (e3, n2, o2) => {
|
|
6461
6545
|
if (!_(n2)) return false;
|
|
6462
6546
|
if (0 !== n2.anchor.offset) return false;
|
|
6463
6547
|
if (0 !== o2.rowIndex || 0 !== o2.colIndex) return false;
|
|
6464
|
-
const r2 =
|
|
6465
|
-
return n2.anchor.blockId === r2 &&
|
|
6548
|
+
const r2 = Ge(e3, o2.cellId);
|
|
6549
|
+
return n2.anchor.blockId === r2 && un(t4, o2.tableId);
|
|
6466
6550
|
});
|
|
6467
6551
|
})(t3), Delete: () => (function(t4) {
|
|
6468
|
-
return
|
|
6552
|
+
return cn(t4, (e3, n2, o2) => {
|
|
6469
6553
|
if (!_(n2)) return false;
|
|
6470
6554
|
const r2 = e3.getBlock(n2.anchor.blockId);
|
|
6471
6555
|
if (!r2) return false;
|
|
6472
6556
|
const i2 = m(r2);
|
|
6473
6557
|
if (n2.anchor.offset !== i2) return false;
|
|
6474
6558
|
if (o2.rowIndex !== o2.totalRows - 1 || o2.colIndex !== o2.totalCols - 1) return false;
|
|
6475
|
-
const s2 =
|
|
6476
|
-
return n2.anchor.blockId === s2 &&
|
|
6559
|
+
const s2 = Xe(e3, o2.cellId);
|
|
6560
|
+
return n2.anchor.blockId === s2 && un(t4, o2.tableId);
|
|
6477
6561
|
});
|
|
6478
6562
|
})(t3), ArrowDown: () => (function(t4) {
|
|
6479
|
-
return
|
|
6480
|
-
const r2 =
|
|
6481
|
-
return n2.anchor.blockId === r2 && (o2.rowIndex >= o2.totalRows - 1 ?
|
|
6563
|
+
return cn(t4, (e3, n2, o2) => {
|
|
6564
|
+
const r2 = Xe(e3, o2.cellId);
|
|
6565
|
+
return n2.anchor.blockId === r2 && (o2.rowIndex >= o2.totalRows - 1 ? ln(t4) : an(t4, o2.tableId, o2.rowIndex + 1, o2.colIndex));
|
|
6482
6566
|
});
|
|
6483
6567
|
})(t3), ArrowUp: () => (function(t4) {
|
|
6484
|
-
return
|
|
6485
|
-
const r2 =
|
|
6486
|
-
return n2.anchor.blockId === r2 && !(o2.rowIndex <= 0) &&
|
|
6568
|
+
return cn(t4, (e3, n2, o2) => {
|
|
6569
|
+
const r2 = Ge(e3, o2.cellId);
|
|
6570
|
+
return n2.anchor.blockId === r2 && !(o2.rowIndex <= 0) && an(t4, o2.tableId, o2.rowIndex - 1, o2.colIndex);
|
|
6487
6571
|
});
|
|
6488
6572
|
})(t3), ArrowRight: () => (function(t4) {
|
|
6489
|
-
return
|
|
6573
|
+
return cn(t4, (e3, n2, o2) => {
|
|
6490
6574
|
if (!_(n2)) return false;
|
|
6491
6575
|
const r2 = e3.getBlock(n2.anchor.blockId);
|
|
6492
6576
|
if (!r2) return false;
|
|
6493
6577
|
const i2 = m(r2);
|
|
6494
6578
|
if (n2.anchor.offset !== i2) return false;
|
|
6495
|
-
const s2 =
|
|
6496
|
-
return n2.anchor.blockId === s2 && (o2.colIndex < o2.totalCols - 1 ?
|
|
6579
|
+
const s2 = Xe(e3, o2.cellId);
|
|
6580
|
+
return n2.anchor.blockId === s2 && (o2.colIndex < o2.totalCols - 1 ? an(t4, o2.tableId, o2.rowIndex, o2.colIndex + 1) : !(o2.rowIndex < o2.totalRows - 1) || an(t4, o2.tableId, o2.rowIndex + 1, 0));
|
|
6497
6581
|
});
|
|
6498
6582
|
})(t3), ArrowLeft: () => (function(t4) {
|
|
6499
|
-
return
|
|
6583
|
+
return cn(t4, (e3, n2, o2) => {
|
|
6500
6584
|
if (!_(n2)) return false;
|
|
6501
6585
|
if (0 !== n2.anchor.offset) return false;
|
|
6502
|
-
const r2 =
|
|
6503
|
-
return n2.anchor.blockId === r2 && (o2.colIndex > 0 ?
|
|
6586
|
+
const r2 = Ge(e3, o2.cellId);
|
|
6587
|
+
return n2.anchor.blockId === r2 && (o2.colIndex > 0 ? dn(t4, o2.tableId, o2.rowIndex, o2.colIndex - 1) : !(o2.rowIndex > 0) || dn(t4, o2.tableId, o2.rowIndex - 1, o2.totalCols - 1));
|
|
6504
6588
|
});
|
|
6505
|
-
})(t3), Escape: () =>
|
|
6589
|
+
})(t3), Escape: () => ln(t3) };
|
|
6506
6590
|
t3.registerKeymap(e2);
|
|
6507
6591
|
})(t2), this.registerToolbarItem(t2), this.selectionService = (function(t3) {
|
|
6508
6592
|
let e2 = null, n2 = [], o2 = /* @__PURE__ */ new Set();
|
|
@@ -6511,7 +6595,7 @@
|
|
|
6511
6595
|
if (!e2) return n2 = [], void (o2 = /* @__PURE__ */ new Set());
|
|
6512
6596
|
const r4 = t3.getState(), i2 = [], s2 = Math.min(e2.fromRow, e2.toRow), c2 = Math.max(e2.fromRow, e2.toRow), l2 = Math.min(e2.fromCol, e2.toCol), a2 = Math.max(e2.fromCol, e2.toCol);
|
|
6513
6597
|
for (let t4 = s2; t4 <= c2; t4++) for (let n3 = l2; n3 <= a2; n3++) {
|
|
6514
|
-
const o3 =
|
|
6598
|
+
const o3 = We(r4, e2.tableId, t4, n3);
|
|
6515
6599
|
o3 && i2.push(o3);
|
|
6516
6600
|
}
|
|
6517
6601
|
n2 = i2, o2 = new Set(i2);
|
|
@@ -6523,7 +6607,7 @@
|
|
|
6523
6607
|
}
|
|
6524
6608
|
})(t3, o2);
|
|
6525
6609
|
}, getSelectedCellIds: () => n2, isSelected: (t4) => o2.has(t4) };
|
|
6526
|
-
return t3.registerService(
|
|
6610
|
+
return t3.registerService(vn, r2), r2;
|
|
6527
6611
|
})(t2);
|
|
6528
6612
|
}
|
|
6529
6613
|
onReady() {
|
|
@@ -6534,13 +6618,13 @@
|
|
|
6534
6618
|
const i3 = n3.target.closest("td[data-block-id]");
|
|
6535
6619
|
if (i3) if (n3.shiftKey) {
|
|
6536
6620
|
if (o2) {
|
|
6537
|
-
const r3 =
|
|
6621
|
+
const r3 = Ue(t2.getState(), i3.getAttribute("data-block-id"));
|
|
6538
6622
|
if (!r3 || r3.tableId !== o2.tableId) return;
|
|
6539
6623
|
n3.preventDefault(), e2.setSelectedRange({ tableId: o2.tableId, fromRow: o2.row, fromCol: o2.col, toRow: r3.rowIndex, toCol: r3.colIndex });
|
|
6540
6624
|
}
|
|
6541
6625
|
} else {
|
|
6542
6626
|
e2.setSelectedRange(null);
|
|
6543
|
-
const n4 =
|
|
6627
|
+
const n4 = Ue(t2.getState(), i3.getAttribute("data-block-id"));
|
|
6544
6628
|
if (!n4) return;
|
|
6545
6629
|
o2 = { tableId: n4.tableId, row: n4.rowIndex, col: n4.colIndex }, r2 = true;
|
|
6546
6630
|
}
|
|
@@ -6550,7 +6634,7 @@
|
|
|
6550
6634
|
if (!r2 || !o2) return;
|
|
6551
6635
|
const i3 = n3.target.closest("td[data-block-id]");
|
|
6552
6636
|
if (!i3) return;
|
|
6553
|
-
const s3 =
|
|
6637
|
+
const s3 = Ue(t2.getState(), i3.getAttribute("data-block-id"));
|
|
6554
6638
|
s3 && s3.tableId === o2.tableId && (s3.rowIndex === o2.row && s3.colIndex === o2.col || (n3.preventDefault(), e2.setSelectedRange({ tableId: o2.tableId, fromRow: o2.row, fromCol: o2.col, toRow: s3.rowIndex, toCol: s3.colIndex })));
|
|
6555
6639
|
}
|
|
6556
6640
|
function c2() {
|
|
@@ -6567,7 +6651,7 @@
|
|
|
6567
6651
|
onStateChange(t2, e2, n2) {
|
|
6568
6652
|
if (this.selectionService?.getSelectedRange()) {
|
|
6569
6653
|
const t3 = e2.selection;
|
|
6570
|
-
!C(t3) &&
|
|
6654
|
+
!C(t3) && Ye(e2, t3.anchor.blockId) || this.selectionService.setSelectedRange(null);
|
|
6571
6655
|
}
|
|
6572
6656
|
}
|
|
6573
6657
|
registerNodeSpecs(t2) {
|
|
@@ -6594,18 +6678,18 @@
|
|
|
6594
6678
|
i2.setAttribute("aria-label", `Table with ${c2} rows and ${l2} columns`);
|
|
6595
6679
|
const d2 = document.createElement("tbody");
|
|
6596
6680
|
i2.appendChild(d2), r2.appendChild(i2), o2.appendChild(r2);
|
|
6597
|
-
const
|
|
6598
|
-
|
|
6599
|
-
const
|
|
6600
|
-
return new
|
|
6681
|
+
const u2 = document.createElement("div");
|
|
6682
|
+
u2.className = "notectl-sr-only", u2.setAttribute("aria-live", "polite"), u2.setAttribute("aria-atomic", "true"), o2.appendChild(u2);
|
|
6683
|
+
const h2 = (function(t4, e3, n3, o3, r3) {
|
|
6684
|
+
return new yn(t4, e3, n3, o3, r3);
|
|
6601
6685
|
})(o2, i2, t3, e2, n2);
|
|
6602
6686
|
return { dom: o2, contentDOM: d2, update(t4) {
|
|
6603
6687
|
if ("table" !== t4.type) return false;
|
|
6604
6688
|
o2.setAttribute("data-block-id", t4.id), o2.setAttribute("data-selectable", "true");
|
|
6605
6689
|
const e3 = a(t4), n3 = e3.length, r3 = e3[0] ? a(e3[0]).length : 0;
|
|
6606
|
-
return i2.setAttribute("aria-label", `Table with ${n3} rows and ${r3} columns`),
|
|
6690
|
+
return i2.setAttribute("aria-label", `Table with ${n3} rows and ${r3} columns`), h2.update(t4), false;
|
|
6607
6691
|
}, destroy() {
|
|
6608
|
-
|
|
6692
|
+
h2.destroy();
|
|
6609
6693
|
}, selectNode() {
|
|
6610
6694
|
o2.classList.add("notectl-table--selected");
|
|
6611
6695
|
}, deselectNode() {
|
|
@@ -6633,20 +6717,20 @@
|
|
|
6633
6717
|
registerToolbarItem(t2) {
|
|
6634
6718
|
const e2 = this.config.maxPickerRows ?? 8, n2 = this.config.maxPickerCols ?? 8;
|
|
6635
6719
|
t2.registerToolbarItem({ id: "table", group: "insert", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 3h18v18H3V3zm2 2v4h6V5H5zm8 0v4h6V5h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6z"/></svg>', label: "Insert Table", tooltip: "Insert Table", command: "insertTable", priority: 80, separatorAfter: this.config.separatorAfter, popupType: "gridPicker", popupConfig: { maxRows: e2, maxCols: n2, onSelect: (e3, n3) => {
|
|
6636
|
-
|
|
6637
|
-
} }, isActive: (t3) => !C(t3.selection) &&
|
|
6720
|
+
nn(t2, e3, n3);
|
|
6721
|
+
} }, isActive: (t3) => !C(t3.selection) && Ye(t3, t3.selection.anchor.blockId) });
|
|
6638
6722
|
}
|
|
6639
|
-
}, t.TableSelectionServiceKey =
|
|
6723
|
+
}, t.TableSelectionServiceKey = vn, t.TextAlignmentPlugin = Ne, t.TextColorPlugin = class {
|
|
6640
6724
|
id = "textColor";
|
|
6641
6725
|
name = "Text Color";
|
|
6642
6726
|
priority = 23;
|
|
6643
6727
|
config;
|
|
6644
6728
|
colors;
|
|
6645
6729
|
constructor(t2) {
|
|
6646
|
-
this.config = { ...
|
|
6647
|
-
if (!t3 || 0 === t3.length) return
|
|
6730
|
+
this.config = { ...Ce, ...t2 }, this.colors = (function(t3) {
|
|
6731
|
+
if (!t3 || 0 === t3.length) return Be;
|
|
6648
6732
|
const e2 = t3.filter((t4) => {
|
|
6649
|
-
return e3 = t4, !
|
|
6733
|
+
return e3 = t4, !Te.test(e3);
|
|
6650
6734
|
var e3;
|
|
6651
6735
|
});
|
|
6652
6736
|
if (e2.length > 0) throw new Error(`TextColorPlugin: invalid hex color(s): ${e2.join(", ")}. Expected format: #RGB or #RRGGBB.`);
|
|
@@ -6659,7 +6743,7 @@
|
|
|
6659
6743
|
})(t2?.colors);
|
|
6660
6744
|
}
|
|
6661
6745
|
init(t2) {
|
|
6662
|
-
t2.registerStyleSheet(
|
|
6746
|
+
t2.registerStyleSheet(Ie), this.registerMarkSpec(t2), this.registerCommands(t2), this.registerToolbarItem(t2);
|
|
6663
6747
|
}
|
|
6664
6748
|
registerMarkSpec(t2) {
|
|
6665
6749
|
t2.registerMarkSpec({ type: "textColor", rank: 5, attrs: { color: { default: "" } }, toDOM(t3) {
|
|
@@ -6749,46 +6833,46 @@
|
|
|
6749
6833
|
}
|
|
6750
6834
|
t2.appendChild(i2);
|
|
6751
6835
|
}
|
|
6752
|
-
}, t.TextFormattingPlugin = he, t.ThemePreset =
|
|
6836
|
+
}, t.TextFormattingPlugin = he, t.ThemePreset = Qn, t.ToolbarPlugin = le, t.ToolbarServiceKey = ce, t.TransactionBuilder = ut, t.applyStep = Q, t.blockId = R, t.canContain = J, t.commandName = function(t2) {
|
|
6753
6837
|
return t2;
|
|
6754
|
-
}, t.createBlockElement = F, t.createBlockNode =
|
|
6838
|
+
}, t.createBlockElement = F, t.createBlockNode = h, t.createCollapsedSelection = A, t.createDocument = u, t.createEditor = async function(t2) {
|
|
6755
6839
|
const e2 = document.createElement("notectl-editor");
|
|
6756
6840
|
return await e2.init(t2), e2;
|
|
6757
|
-
}, t.createInlineNode = f, t.createNodeSelection = I, t.createPosition =
|
|
6841
|
+
}, t.createInlineNode = f, t.createNodeSelection = I, t.createPosition = E, t.createSelection = M, t.createTextNode = p, t.createTheme = function(t2, e2) {
|
|
6758
6842
|
return { name: e2.name, primitives: { ...t2.primitives, ...e2.primitives }, toolbar: e2.toolbar ? { ...t2.toolbar, ...e2.toolbar } : t2.toolbar, codeBlock: e2.codeBlock ? { ...t2.codeBlock, ...e2.codeBlock } : t2.codeBlock, tooltip: e2.tooltip ? { ...t2.tooltip, ...e2.tooltip } : t2.tooltip };
|
|
6759
6843
|
}, t.createThemeStyleSheet = function(t2) {
|
|
6760
6844
|
const e2 = new CSSStyleSheet();
|
|
6761
|
-
return e2.replaceSync(
|
|
6845
|
+
return e2.replaceSync(so(t2)), e2;
|
|
6762
6846
|
}, t.defaultSchema = function() {
|
|
6763
6847
|
return { nodeTypes: ["paragraph"], markTypes: ["bold", "italic", "underline"], getNodeSpec: () => {
|
|
6764
6848
|
} };
|
|
6765
|
-
}, t.deleteBackward = It, t.deleteForward = Ct, t.deleteNodeSelection = bt, t.deleteSelectionCommand = St, t.escapeHTML = K, t.findNode = X, t.findNodePath =
|
|
6766
|
-
const n2 =
|
|
6849
|
+
}, t.deleteBackward = It, t.deleteForward = Ct, t.deleteNodeSelection = bt, t.deleteSelectionCommand = St, t.escapeHTML = K, t.findNode = X, t.findNodePath = U, t.findNodeWithPath = function(t2, e2) {
|
|
6850
|
+
const n2 = U(t2, e2);
|
|
6767
6851
|
if (!n2) return;
|
|
6768
|
-
const o2 =
|
|
6852
|
+
const o2 = q(t2, n2);
|
|
6769
6853
|
return o2 ? { node: o2, path: n2 } : void 0;
|
|
6770
|
-
}, t.findTableContext =
|
|
6854
|
+
}, t.findTableContext = Ue, t.forEachBlockInRange = kt, t.formatShortcut = ae, t.generateThemeCSS = so, t.getBlockChildren = a, t.getBlockLength = m, t.getBlockMarksAtOffset = b, t.getBlockText = g, t.getContentAtOffset = S, t.getInlineChildren = l, t.getTextChildren = c, t.hasMark = y, t.inlineDecoration = Wt, t.inlineType = function(t2) {
|
|
6771
6855
|
return t2;
|
|
6772
6856
|
}, t.insertHardBreakCommand = Bt, t.insertTextCommand = wt, t.invertStep = at, t.invertTransaction = dt, t.isBlockNode = i, t.isCollapsed = _, t.isForward = L, t.isInlineNode = r, t.isInlineNodeOfType = function(t2, e2) {
|
|
6773
6857
|
return r(t2) && t2.inlineType === e2;
|
|
6774
|
-
}, t.isInsideIsolating =
|
|
6858
|
+
}, t.isInsideIsolating = Mt, t.isInsideTable = Ye, t.isLeafBlock = s, t.isMarkActive = zt, t.isMarkAllowed = P, t.isMarkOfType = $, t.isNodeOfType = O, t.isNodeSelection = C, t.isTextNode = o, t.isTextSelection = T, t.isVoidBlock = mt, t.markSetsEqual = k, t.markType = D, t.mergeBlockBackward = _t, t.navigateArrowIntoVoid = Rt, t.nodeDecoration = function(t2, e2) {
|
|
6775
6859
|
return { type: "node", blockId: t2, attrs: e2 };
|
|
6776
6860
|
}, t.nodeType = H, t.normalizeKeyDescriptor = Dt, t.pluginId = function(t2) {
|
|
6777
6861
|
return t2;
|
|
6778
|
-
}, t.registerBuiltinSpecs = Z, t.resolveNodeByPath =
|
|
6862
|
+
}, t.registerBuiltinSpecs = Z, t.resolveNodeByPath = q, t.resolveParentByPath = function(t2, e2) {
|
|
6779
6863
|
if (0 === e2.length) return;
|
|
6780
6864
|
if (1 === e2.length) {
|
|
6781
6865
|
const n3 = t2.children.findIndex((t3) => t3.id === e2[0]);
|
|
6782
6866
|
if (-1 === n3) return;
|
|
6783
6867
|
return { parent: t2, index: n3 };
|
|
6784
6868
|
}
|
|
6785
|
-
const n2 =
|
|
6869
|
+
const n2 = q(t2, e2.slice(0, -1));
|
|
6786
6870
|
if (!n2) return;
|
|
6787
6871
|
const o2 = e2[e2.length - 1];
|
|
6788
6872
|
if (!o2) return;
|
|
6789
6873
|
const r2 = n2.children.findIndex((t3) => i(t3) && t3.id === o2);
|
|
6790
6874
|
return -1 !== r2 ? { parent: n2, index: r2 } : void 0;
|
|
6791
|
-
}, t.resolveTheme =
|
|
6875
|
+
}, t.resolveTheme = no, t.schemaFromRegistry = z, t.selectAll = Nt, t.selectionRange = N, t.selectionsEqual = B, t.sharesParent = Et, t.splitBlockCommand = Tt, t.toggleBold = function(t2, e2) {
|
|
6792
6876
|
return yt(t2, "bold", e2);
|
|
6793
6877
|
}, t.toggleItalic = function(t2, e2) {
|
|
6794
6878
|
return yt(t2, "italic", e2);
|