@notectl/core 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/ToolbarPlugin-DFkl1uYO.mjs +818 -0
- package/dist/chunks/ToolbarPlugin-DFkl1uYO.mjs.map +1 -0
- package/dist/chunks/{index-CxiWyUho.mjs → index-BCvuDpVr.mjs} +2 -2
- package/dist/chunks/{index-CxiWyUho.mjs.map → index-BCvuDpVr.mjs.map} +1 -1
- package/dist/chunks/{index-C2GQoHot.mjs → index-BFsYGsBR.mjs} +2 -2
- package/dist/chunks/{index-C2GQoHot.mjs.map → index-BFsYGsBR.mjs.map} +1 -1
- package/dist/chunks/{index-B_3qDrUN.mjs → index-BIL37LSL.mjs} +23 -14
- package/dist/chunks/index-BIL37LSL.mjs.map +1 -0
- package/dist/chunks/{index-Ct0ivLhO.mjs → index-BL56fbXt.mjs} +214 -219
- package/dist/chunks/{index-Ct0ivLhO.mjs.map → index-BL56fbXt.mjs.map} +1 -1
- package/dist/chunks/{index-BYgspns5.mjs → index-BQ8iIYLn.mjs} +2 -2
- package/dist/chunks/{index-BYgspns5.mjs.map → index-BQ8iIYLn.mjs.map} +1 -1
- package/dist/chunks/index-BTJfyJlJ.mjs +187 -0
- package/dist/chunks/index-BTJfyJlJ.mjs.map +1 -0
- package/dist/chunks/{index-D3CQWJiw.mjs → index-DA8TG2S8.mjs} +39 -19
- package/dist/chunks/index-DA8TG2S8.mjs.map +1 -0
- package/dist/chunks/{index-C-YWHOcC.mjs → index-DAFCISBN.mjs} +21 -21
- package/dist/chunks/{index-C-YWHOcC.mjs.map → index-DAFCISBN.mjs.map} +1 -1
- package/dist/chunks/{index-BAk1EG1x.mjs → index-DGrRWMlW.mjs} +2 -2
- package/dist/chunks/{index-BAk1EG1x.mjs.map → index-DGrRWMlW.mjs.map} +1 -1
- package/dist/chunks/{index-CT3HGdQt.mjs → index-DfO_fKw6.mjs} +6 -6
- package/dist/chunks/{index-CT3HGdQt.mjs.map → index-DfO_fKw6.mjs.map} +1 -1
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -1
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +27 -5
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/styles/list.d.ts +2 -0
- package/dist/editor/styles/list.d.ts.map +1 -1
- package/dist/editor/styles/toolbar.d.ts +1 -1
- package/dist/editor/styles/toolbar.d.ts.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +2 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts +2 -0
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/KeyboardHandler.d.ts +2 -0
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/LegacyHTMLNormalizer.d.ts +18 -0
- package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +4 -0
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/model/HTMLParser.d.ts +13 -0
- package/dist/model/HTMLParser.d.ts.map +1 -1
- package/dist/model/SchemaRegistry.d.ts +2 -2
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/notectl-core.mjs +546 -394
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +1772 -1161
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/Plugin.d.ts +17 -2
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +17 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +14 -0
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingCommands.d.ts +5 -0
- package/dist/plugins/heading/HeadingCommands.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts +5 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts +5 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +1 -41
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/list/ListPlugin.d.ts +9 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts +1 -0
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts +23 -0
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +56 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +17 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/state/ReadonlyGuard.d.ts +6 -0
- package/dist/state/ReadonlyGuard.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +4 -0
- package/dist/state/Transaction.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts +2 -0
- package/dist/view/EditorView.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs +0 -368
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +0 -1
- package/dist/chunks/index-B_3qDrUN.mjs.map +0 -1
- package/dist/chunks/index-D3CQWJiw.mjs.map +0 -1
- package/dist/chunks/index-Dh76rR13.mjs +0 -196
- package/dist/chunks/index-Dh76rR13.mjs.map +0 -1
- package/dist/input/SourceNormalizer.d.ts +0 -7
- package/dist/input/SourceNormalizer.d.ts.map +0 -1
package/dist/notectl-core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as t, n as s, g as r, c as o, a as m, i as E, d as N, k as M, m as
|
|
1
|
+
import { j as t, n as s, g as r, c as o, a as m, i as E, d as N, k as M, m as R, r as O, o as P, p as _, e as $, l as U, q as K, s as W, b as V, t as q, u as G } from "./chunks/Document-CI3iCwEP.mjs";
|
|
2
2
|
import { f, v, h } from "./chunks/Document-CI3iCwEP.mjs";
|
|
3
3
|
import { b as X, c as J, i as Q, d as Y, e as Z, f as ee, a as te, s as ne, g as se } from "./chunks/Selection-D5ZjXoB7.mjs";
|
|
4
4
|
import { h as h2 } from "./chunks/Selection-D5ZjXoB7.mjs";
|
|
@@ -6,34 +6,34 @@ import { d as re, s as oe, n as ie, a as ae, b as ce, i as le, c as he, e as de,
|
|
|
6
6
|
import { f as f2, u, v as v2, w, x, y, z, A, B } from "./chunks/Commands-CSpSwGXv.mjs";
|
|
7
7
|
import { b as Ee, n as Te, m as xe } from "./chunks/TypeBrands-C09nE2qO.mjs";
|
|
8
8
|
import { c, i, p } from "./chunks/TypeBrands-C09nE2qO.mjs";
|
|
9
|
-
import { a as
|
|
9
|
+
import { a as Ce } from "./chunks/AttrRegistry-D-przlzb.mjs";
|
|
10
10
|
import { b, i as i2 } from "./chunks/AttrRegistry-D-przlzb.mjs";
|
|
11
|
-
import { c as
|
|
12
|
-
import { e as
|
|
13
|
-
import { a as
|
|
11
|
+
import { c as Ne } from "./chunks/NodeSpec-NZVvcCuH.mjs";
|
|
12
|
+
import { e as Ae } from "./chunks/HTMLUtils-0wvCRvJc.mjs";
|
|
13
|
+
import { a as Le, r as Me, f as Ie } from "./chunks/NodeResolver-D68ZLXti.mjs";
|
|
14
14
|
import { b as b2, c as c2, w as w2 } from "./chunks/NodeResolver-D68ZLXti.mjs";
|
|
15
|
-
import { E as
|
|
16
|
-
import { D as De, d as He } from "./chunks/index-
|
|
17
|
-
import { C, a, b as b3, c as c3, i as i3, n, w as w3 } from "./chunks/index-
|
|
18
|
-
import { T as ze } from "./chunks/ToolbarPlugin-
|
|
19
|
-
import { b as b4, c as c4, a as a2 } from "./chunks/ToolbarPlugin-
|
|
15
|
+
import { E as Re, S as Oe, r as Be, L as Pe, a as _e } from "./chunks/resolvePluginLocale-B4w1OkPy.mjs";
|
|
16
|
+
import { D as De, d as He } from "./chunks/index-DGrRWMlW.mjs";
|
|
17
|
+
import { C, a, b as b3, c as c3, i as i3, n, w as w3 } from "./chunks/index-DGrRWMlW.mjs";
|
|
18
|
+
import { T as ze } from "./chunks/ToolbarPlugin-DFkl1uYO.mjs";
|
|
19
|
+
import { b as b4, c as c4, d, a as a2 } from "./chunks/ToolbarPlugin-DFkl1uYO.mjs";
|
|
20
20
|
import { f as $e } from "./chunks/ToolbarItem-ugDymuXi.mjs";
|
|
21
|
-
import { T as je } from "./chunks/index-
|
|
22
|
-
import { a as a3, b as b5 } from "./chunks/index-
|
|
23
|
-
import { H, a as a4, b as b6 } from "./chunks/index-
|
|
21
|
+
import { T as je } from "./chunks/index-BIL37LSL.mjs";
|
|
22
|
+
import { a as a3, b as b5 } from "./chunks/index-BIL37LSL.mjs";
|
|
23
|
+
import { H, a as a4, b as b6 } from "./chunks/index-BTJfyJlJ.mjs";
|
|
24
24
|
import { L, a as a5, b as b7 } from "./chunks/index-Bsp4LC5t.mjs";
|
|
25
|
-
import { L as L2, a as a6, b as b8 } from "./chunks/index-
|
|
25
|
+
import { L as L2, a as a6, b as b8 } from "./chunks/index-DA8TG2S8.mjs";
|
|
26
26
|
import { B as B2, a as a7, b as b9 } from "./chunks/index-uTnc9y7M.mjs";
|
|
27
|
-
import { S, a as a8, b as b10 } from "./chunks/index-
|
|
27
|
+
import { S, a as a8, b as b10 } from "./chunks/index-DfO_fKw6.mjs";
|
|
28
28
|
import { T, a as a9, b as b11 } from "./chunks/index-DC1EK22F.mjs";
|
|
29
29
|
import { H as H2, a as a10, b as b12 } from "./chunks/index-BRYzYOYC.mjs";
|
|
30
|
-
import { A as A2, a as a11, b as b13, c as c5, d, d as
|
|
31
|
-
import { F, a as a12, b as b14 } from "./chunks/index-
|
|
32
|
-
import { F as F2, a as a13, b as b15 } from "./chunks/index-
|
|
33
|
-
import { T as T2, a as a14, b as b16, c as c6, d as
|
|
30
|
+
import { A as A2, a as a11, b as b13, c as c5, d as d2, d as d3 } from "./chunks/index-DAFCISBN.mjs";
|
|
31
|
+
import { F, a as a12, b as b14 } from "./chunks/index-BCvuDpVr.mjs";
|
|
32
|
+
import { F as F2, a as a13, b as b15 } from "./chunks/index-BQ8iIYLn.mjs";
|
|
33
|
+
import { T as T2, a as a14, b as b16, c as c6, d as d4, e, f as f3, g, h as h3, i as i4, j, k, l } from "./chunks/index-BSFLNveF.mjs";
|
|
34
34
|
import { H as H3, a as a15, b as b17 } from "./chunks/index-o6hDR07y.mjs";
|
|
35
|
-
import { S as S2, a as a16, b as b18 } from "./chunks/index-
|
|
36
|
-
import { D, I, a as a17, b as b19, c as c7 } from "./chunks/index-
|
|
35
|
+
import { S as S2, a as a16, b as b18 } from "./chunks/index-BFsYGsBR.mjs";
|
|
36
|
+
import { D, I, a as a17, b as b19, c as c7 } from "./chunks/index-BL56fbXt.mjs";
|
|
37
37
|
import { HardBreakPlugin } from "./plugins/hard-break.mjs";
|
|
38
38
|
import Fe from "dompurify";
|
|
39
39
|
class Ue {
|
|
@@ -218,7 +218,7 @@ function Ke(e2, t2) {
|
|
|
218
218
|
}
|
|
219
219
|
return false;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function We(e2, t2, n2) {
|
|
222
222
|
const s2 = e2.getNodeSpec(t2);
|
|
223
223
|
if (!s2?.content) return true;
|
|
224
224
|
const r2 = e2.getNodeSpec(n2), o2 = r2?.group;
|
|
@@ -228,16 +228,16 @@ function Ve(e2, t2, n2) {
|
|
|
228
228
|
}
|
|
229
229
|
return false;
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Ve(e2, t2, n2) {
|
|
232
232
|
const s2 = e2.getNodeSpec(t2);
|
|
233
233
|
if (!s2?.content) return true;
|
|
234
234
|
const { min: r2 = 0, max: o2 = Number.POSITIVE_INFINITY } = s2.content, i5 = n2.filter((e3) => "text" !== e3);
|
|
235
235
|
if (i5.length < r2 || i5.length > o2) return false;
|
|
236
|
-
for (const n3 of i5) if (!
|
|
236
|
+
for (const n3 of i5) if (!We(e2, t2, n3)) return false;
|
|
237
237
|
return true;
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
e2.registerNodeSpec({ type: "paragraph", group: "block", content: { allow: ["text"] }, toDOM: (e3) =>
|
|
239
|
+
function qe(e2) {
|
|
240
|
+
e2.registerNodeSpec({ type: "paragraph", group: "block", content: { allow: ["text"] }, toDOM: (e3) => Ne("p", e3.id), toHTML: (e3, t2) => `<p>${t2 || "<br>"}</p>`, parseHTML: [{ tag: "p" }, { tag: "div", priority: 10 }], sanitize: { tags: ["p"] } });
|
|
241
241
|
}
|
|
242
242
|
function Ge(e2, n2) {
|
|
243
243
|
switch (n2.type) {
|
|
@@ -318,7 +318,7 @@ function Ge(e2, n2) {
|
|
|
318
318
|
if (-1 !== i5) {
|
|
319
319
|
const a18 = e3.children[i5];
|
|
320
320
|
if (!a18) return e3;
|
|
321
|
-
const c8 = t(a18), l2 = r(a18), h4 = et(c8, 0, n3.offset),
|
|
321
|
+
const c8 = t(a18), l2 = r(a18), h4 = et(c8, 0, n3.offset), d5 = et(c8, n3.offset, l2), u2 = { ...a18, children: s(h4) }, p2 = o(a18.type, s(d5), n3.newBlockId, a18.attrs), f4 = [...e3.children];
|
|
322
322
|
return f4.splice(i5, 1, u2, p2), { children: f4 };
|
|
323
323
|
}
|
|
324
324
|
return { children: e3.children.map((e4) => Xe(e4, n3) ?? e4) };
|
|
@@ -329,8 +329,8 @@ function Ge(e2, n2) {
|
|
|
329
329
|
if (-1 !== r2 && -1 !== o2) {
|
|
330
330
|
const i5 = e3.children[r2], a18 = e3.children[o2];
|
|
331
331
|
if (!i5 || !a18) return e3;
|
|
332
|
-
const c8 = t(i5), l2 = t(a18), h4 = s([...c8, ...l2]),
|
|
333
|
-
return { children: e3.children.filter((e4) => e4.id !== n3.sourceBlockId).map((e4) => e4.id === n3.targetBlockId ?
|
|
332
|
+
const c8 = t(i5), l2 = t(a18), h4 = s([...c8, ...l2]), d5 = { ...i5, children: h4 };
|
|
333
|
+
return { children: e3.children.filter((e4) => e4.id !== n3.sourceBlockId).map((e4) => e4.id === n3.targetBlockId ? d5 : e4) };
|
|
334
334
|
}
|
|
335
335
|
return { children: e3.children.map((e4) => Je(e4, n3) ?? e4) };
|
|
336
336
|
})(e2, n2);
|
|
@@ -433,7 +433,7 @@ function Ge(e2, n2) {
|
|
|
433
433
|
function Xe(e2, n2) {
|
|
434
434
|
const i5 = e2.children.findIndex((e3) => m(e3) && e3.id === n2.blockId);
|
|
435
435
|
if (-1 !== i5) {
|
|
436
|
-
const a19 = e2.children[i5], c9 = t(a19), l2 = r(a19), h4 = et(c9, 0, n2.offset),
|
|
436
|
+
const a19 = e2.children[i5], c9 = t(a19), l2 = r(a19), h4 = et(c9, 0, n2.offset), d5 = et(c9, n2.offset, l2), u2 = { ...a19, children: s(h4) }, p2 = o(a19.type, s(d5), n2.newBlockId, a19.attrs), f4 = [...e2.children];
|
|
437
437
|
return f4.splice(i5, 1, u2, p2), { ...e2, children: f4 };
|
|
438
438
|
}
|
|
439
439
|
let a18 = false;
|
|
@@ -447,7 +447,7 @@ function Xe(e2, n2) {
|
|
|
447
447
|
function Je(e2, n2) {
|
|
448
448
|
const r2 = e2.children.findIndex((e3) => m(e3) && e3.id === n2.targetBlockId), o2 = e2.children.findIndex((e3) => m(e3) && e3.id === n2.sourceBlockId);
|
|
449
449
|
if (-1 !== r2 && -1 !== o2) {
|
|
450
|
-
const i6 = e2.children[r2], a19 = e2.children[o2], c8 = t(i6), l2 = t(a19), h4 = s([...c8, ...l2]),
|
|
450
|
+
const i6 = e2.children[r2], a19 = e2.children[o2], c8 = t(i6), l2 = t(a19), h4 = s([...c8, ...l2]), d5 = { ...i6, children: h4 }, u2 = e2.children.filter((e3) => !m(e3) || e3.id !== n2.sourceBlockId).map((e3) => m(e3) && e3.id === n2.targetBlockId ? d5 : e3);
|
|
451
451
|
return { ...e2, children: u2 };
|
|
452
452
|
}
|
|
453
453
|
let i5 = false;
|
|
@@ -504,15 +504,15 @@ function tt(e2, t2, n2, s2, r2) {
|
|
|
504
504
|
const e3 = i5 + a18.text.length;
|
|
505
505
|
if (e3 <= t2 || i5 >= n2) o2.push(a18);
|
|
506
506
|
else if (i5 >= t2 && e3 <= n2) {
|
|
507
|
-
const e4 = r2 ?
|
|
507
|
+
const e4 = r2 ? R(a18.marks, s2) : O(a18.marks, s2.type);
|
|
508
508
|
o2.push(N(a18.text, e4));
|
|
509
509
|
} else {
|
|
510
|
-
const e4 = Math.max(0, t2 - i5), c8 = Math.min(a18.text.length, n2 - i5), l2 = a18.text.slice(0, e4), h4 = a18.text.slice(e4, c8),
|
|
510
|
+
const e4 = Math.max(0, t2 - i5), c8 = Math.min(a18.text.length, n2 - i5), l2 = a18.text.slice(0, e4), h4 = a18.text.slice(e4, c8), d5 = a18.text.slice(c8);
|
|
511
511
|
if (l2 && o2.push(N(l2, a18.marks)), h4) {
|
|
512
|
-
const e5 = r2 ?
|
|
512
|
+
const e5 = r2 ? R(a18.marks, s2) : O(a18.marks, s2.type);
|
|
513
513
|
o2.push(N(h4, e5));
|
|
514
514
|
}
|
|
515
|
-
|
|
515
|
+
d5 && o2.push(N(d5, a18.marks));
|
|
516
516
|
}
|
|
517
517
|
i5 = e3;
|
|
518
518
|
}
|
|
@@ -571,6 +571,7 @@ class it {
|
|
|
571
571
|
selectionBefore;
|
|
572
572
|
origin;
|
|
573
573
|
workingDoc;
|
|
574
|
+
_readonlyAllowed = false;
|
|
574
575
|
constructor(e2, t2, n2 = "api", s2) {
|
|
575
576
|
this.selection = e2, this.selectionBefore = e2, this.storedMarks = t2, this.origin = n2, this.workingDoc = s2 ?? null;
|
|
576
577
|
}
|
|
@@ -582,8 +583,8 @@ class it {
|
|
|
582
583
|
let i5;
|
|
583
584
|
if (o2) i5 = o2;
|
|
584
585
|
else if (this.workingDoc) {
|
|
585
|
-
const o3 =
|
|
586
|
-
i5 = o3 ?
|
|
586
|
+
const o3 = Le(this.workingDoc, e2);
|
|
587
|
+
i5 = o3 ? P(o3, t2, n2) : [{ text: s2, marks: [...r2] }];
|
|
587
588
|
} else i5 = [{ text: s2, marks: [...r2] }];
|
|
588
589
|
const a18 = { type: "deleteText", blockId: e2, from: t2, to: n2, deletedText: s2, deletedMarks: r2, deletedSegments: i5 };
|
|
589
590
|
return this.steps.push(a18), this.advanceDoc(a18), this;
|
|
@@ -591,9 +592,9 @@ class it {
|
|
|
591
592
|
deleteTextAt(e2, t2, n2) {
|
|
592
593
|
const s2 = this.workingDoc;
|
|
593
594
|
if (!s2) throw new Error("deleteTextAt requires a document. Use state.transaction() or provide doc to constructor.");
|
|
594
|
-
const r2 =
|
|
595
|
+
const r2 = Le(s2, e2);
|
|
595
596
|
if (!r2) throw new Error(`Block "${e2}" not found in working document.`);
|
|
596
|
-
const o2 =
|
|
597
|
+
const o2 = _(r2).slice(t2, n2), i5 = $(r2, t2), a18 = P(r2, t2, n2);
|
|
597
598
|
return this.deleteText(e2, t2, n2, o2, i5, a18);
|
|
598
599
|
}
|
|
599
600
|
splitBlock(e2, t2, n2) {
|
|
@@ -607,7 +608,7 @@ class it {
|
|
|
607
608
|
mergeBlocksAt(e2, t2) {
|
|
608
609
|
const n2 = this.workingDoc;
|
|
609
610
|
if (!n2) throw new Error("mergeBlocksAt requires a document. Use state.transaction() or provide doc to constructor.");
|
|
610
|
-
const s2 =
|
|
611
|
+
const s2 = Le(n2, e2);
|
|
611
612
|
if (!s2) throw new Error(`Target block "${e2}" not found in working document.`);
|
|
612
613
|
const o2 = r(s2);
|
|
613
614
|
return this.mergeBlocks(e2, t2, o2);
|
|
@@ -623,7 +624,7 @@ class it {
|
|
|
623
624
|
setBlockType(e2, t2, n2) {
|
|
624
625
|
const s2 = this.workingDoc;
|
|
625
626
|
if (!s2) throw new Error("setBlockType requires a document. Use state.transaction() or provide doc to constructor.");
|
|
626
|
-
const r2 =
|
|
627
|
+
const r2 = Le(s2, e2);
|
|
627
628
|
if (!r2) throw new Error(`Block "${e2}" not found in working document.`);
|
|
628
629
|
const o2 = { type: "setBlockType", blockId: e2, nodeType: t2, ...n2 ? { attrs: n2 } : {}, previousNodeType: r2.type, ...r2.attrs ? { previousAttrs: r2.attrs } : {} };
|
|
629
630
|
return this.steps.push(o2), this.advanceDoc(o2), this;
|
|
@@ -640,7 +641,7 @@ class it {
|
|
|
640
641
|
const t4 = e3.children[n3];
|
|
641
642
|
return t4 && m(t4) ? t4 : void 0;
|
|
642
643
|
}
|
|
643
|
-
const s3 =
|
|
644
|
+
const s3 = Me(e3, t3);
|
|
644
645
|
if (!s3) return;
|
|
645
646
|
const r3 = s3.children[n3];
|
|
646
647
|
return r3 && m(r3) ? r3 : void 0;
|
|
@@ -652,7 +653,7 @@ class it {
|
|
|
652
653
|
setNodeAttr(e2, t2) {
|
|
653
654
|
const n2 = this.workingDoc;
|
|
654
655
|
if (!n2) throw new Error("setNodeAttr requires a document. Use state.transaction() or provide doc to constructor.");
|
|
655
|
-
const s2 =
|
|
656
|
+
const s2 = Me(n2, e2);
|
|
656
657
|
if (!s2) throw new Error(`Node not found at path [${e2.join(", ")}].`);
|
|
657
658
|
const r2 = { type: "setNodeAttr", path: e2, attrs: t2, ...s2.attrs ? { previousAttrs: s2.attrs } : {} };
|
|
658
659
|
return this.steps.push(r2), this.advanceDoc(r2), this;
|
|
@@ -664,7 +665,7 @@ class it {
|
|
|
664
665
|
removeInlineNode(e2, t2) {
|
|
665
666
|
const n2 = this.workingDoc;
|
|
666
667
|
if (!n2) throw new Error("removeInlineNode requires a document. Use state.transaction() or provide doc.");
|
|
667
|
-
const s2 =
|
|
668
|
+
const s2 = Le(n2, e2);
|
|
668
669
|
if (!s2) throw new Error(`Block "${e2}" not found in working document.`);
|
|
669
670
|
const r2 = U(s2, t2);
|
|
670
671
|
if (!r2 || "inline" !== r2.kind) throw new Error(`No InlineNode at offset ${t2} in block "${e2}".`);
|
|
@@ -674,7 +675,7 @@ class it {
|
|
|
674
675
|
setInlineNodeAttr(e2, n2, s2) {
|
|
675
676
|
const r2 = this.workingDoc;
|
|
676
677
|
if (!r2) throw new Error("setInlineNodeAttr requires a document. Use state.transaction() or provide doc.");
|
|
677
|
-
const o2 =
|
|
678
|
+
const o2 = Le(r2, e2);
|
|
678
679
|
if (!o2) throw new Error(`Block "${e2}" not found in working document.`);
|
|
679
680
|
const i5 = t(o2);
|
|
680
681
|
let a18 = 0;
|
|
@@ -687,6 +688,9 @@ class it {
|
|
|
687
688
|
}
|
|
688
689
|
throw new Error(`No InlineNode at offset ${n2} in block "${e2}".`);
|
|
689
690
|
}
|
|
691
|
+
readonlyAllowed() {
|
|
692
|
+
return this._readonlyAllowed = true, this;
|
|
693
|
+
}
|
|
690
694
|
setSelection(e2) {
|
|
691
695
|
return this.selection = e2, this;
|
|
692
696
|
}
|
|
@@ -697,7 +701,7 @@ class it {
|
|
|
697
701
|
return this.steps.push({ type: "setStoredMarks", marks: e2, previousMarks: t2 }), this.storedMarks = e2, this;
|
|
698
702
|
}
|
|
699
703
|
build() {
|
|
700
|
-
return { steps: [...this.steps], selectionBefore: this.selectionBefore, selectionAfter: this.selection, storedMarksAfter: this.storedMarks, metadata: { origin: this.origin, timestamp: Date.now() } };
|
|
704
|
+
return { steps: [...this.steps], selectionBefore: this.selectionBefore, selectionAfter: this.selection, storedMarksAfter: this.storedMarks, metadata: { origin: this.origin, timestamp: Date.now(), ...this._readonlyAllowed ? { readonlyAllowed: true } : {} } };
|
|
701
705
|
}
|
|
702
706
|
advanceDoc(e2) {
|
|
703
707
|
this.workingDoc && (this.workingDoc = Ge(this.workingDoc, e2));
|
|
@@ -725,7 +729,7 @@ class at {
|
|
|
725
729
|
for (const n3 of e2.steps) t2 = Ge(t2, n3);
|
|
726
730
|
const n2 = (function(e3, t3) {
|
|
727
731
|
if (Q(t3)) {
|
|
728
|
-
if (
|
|
732
|
+
if (Le(e3, t3.nodeId)) return t3;
|
|
729
733
|
const n4 = e3.children[0];
|
|
730
734
|
return n4 ? J(n4.id, 0) : t3;
|
|
731
735
|
}
|
|
@@ -746,18 +750,18 @@ class at {
|
|
|
746
750
|
return this._blockOrder ??= (function(e2) {
|
|
747
751
|
const t2 = [];
|
|
748
752
|
return (function e3(n2) {
|
|
749
|
-
for (const s2 of n2) m(s2) && (
|
|
753
|
+
for (const s2 of n2) m(s2) && (W(s2) ? t2.push(s2.id) : e3(s2.children));
|
|
750
754
|
})(e2.children), t2;
|
|
751
755
|
})(this.doc), this._blockOrder;
|
|
752
756
|
}
|
|
753
757
|
getNodePath(e2) {
|
|
754
|
-
return
|
|
758
|
+
return Ie(this.doc, e2);
|
|
755
759
|
}
|
|
756
760
|
getParent(e2) {
|
|
757
|
-
const t2 =
|
|
761
|
+
const t2 = Ie(this.doc, e2);
|
|
758
762
|
if (!t2 || t2.length <= 1) return;
|
|
759
763
|
const n2 = t2[t2.length - 2];
|
|
760
|
-
return n2 ?
|
|
764
|
+
return n2 ? Le(this.doc, n2) : void 0;
|
|
761
765
|
}
|
|
762
766
|
toJSON() {
|
|
763
767
|
return { doc: this.doc, selection: this.selection };
|
|
@@ -767,7 +771,7 @@ class at {
|
|
|
767
771
|
}
|
|
768
772
|
}
|
|
769
773
|
function ct(e2, t2) {
|
|
770
|
-
const n2 =
|
|
774
|
+
const n2 = Le(e2, t2.blockId);
|
|
771
775
|
if (n2) {
|
|
772
776
|
const e3 = r(n2);
|
|
773
777
|
return t2.offset > e3 ? Z(t2.blockId, e3, t2.path) : t2;
|
|
@@ -775,7 +779,14 @@ function ct(e2, t2) {
|
|
|
775
779
|
const s2 = e2.children[0];
|
|
776
780
|
return s2 ? Z(s2.id, 0) : t2;
|
|
777
781
|
}
|
|
778
|
-
|
|
782
|
+
function lt(e2) {
|
|
783
|
+
for (const t2 of e2.steps) if ("setStoredMarks" !== t2.type) return false;
|
|
784
|
+
return true;
|
|
785
|
+
}
|
|
786
|
+
function ht(e2) {
|
|
787
|
+
return !!e2.metadata.readonlyAllowed || lt(e2);
|
|
788
|
+
}
|
|
789
|
+
class dt {
|
|
779
790
|
undoStack = [];
|
|
780
791
|
redoStack = [];
|
|
781
792
|
groupTimeoutMs;
|
|
@@ -826,22 +837,23 @@ class lt {
|
|
|
826
837
|
return s2 === r2;
|
|
827
838
|
}
|
|
828
839
|
}
|
|
829
|
-
class
|
|
840
|
+
class ut {
|
|
830
841
|
constructor(e2, t2) {
|
|
831
|
-
this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.undo = t2.undo, this.redo = t2.redo, this.schemaRegistry = t2.schemaRegistry, this.handleKeydown = this.onKeydown.bind(this), e2.addEventListener("keydown", this.handleKeydown);
|
|
842
|
+
this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.undo = t2.undo, this.redo = t2.redo, this.schemaRegistry = t2.schemaRegistry, this.isReadOnly = t2.isReadOnly ?? (() => false), this.handleKeydown = this.onKeydown.bind(this), e2.addEventListener("keydown", this.handleKeydown);
|
|
832
843
|
}
|
|
833
844
|
getState;
|
|
834
845
|
dispatch;
|
|
835
846
|
undo;
|
|
836
847
|
redo;
|
|
837
848
|
schemaRegistry;
|
|
849
|
+
isReadOnly;
|
|
838
850
|
handleKeydown;
|
|
839
851
|
onKeydown(e2) {
|
|
840
852
|
if (this.handleNodeSelectionKeys(e2)) return;
|
|
841
853
|
if (this.handleArrowIntoVoid(e2)) return;
|
|
842
|
-
if (
|
|
854
|
+
if (this.isReadOnly()) return void this.handleEscape(e2);
|
|
843
855
|
if (this.schemaRegistry) {
|
|
844
|
-
const t3 =
|
|
856
|
+
const t3 = pt(e2), n3 = this.schemaRegistry.getKeymaps();
|
|
845
857
|
for (let s3 = n3.length - 1; s3 >= 0; s3--) {
|
|
846
858
|
const r2 = n3[s3]?.[t3];
|
|
847
859
|
if (r2?.()) return void e2.preventDefault();
|
|
@@ -863,13 +875,13 @@ class ht {
|
|
|
863
875
|
return !!n3 && (e2.preventDefault(), this.dispatch(n3), true);
|
|
864
876
|
}
|
|
865
877
|
if ("Backspace" === s2 || "Delete" === s2) {
|
|
866
|
-
if (
|
|
878
|
+
if (this.isReadOnly()) return true;
|
|
867
879
|
e2.preventDefault();
|
|
868
880
|
const s3 = ae(t2, n2);
|
|
869
881
|
return s3 && this.dispatch(s3), true;
|
|
870
882
|
}
|
|
871
883
|
if ("Enter" === s2) {
|
|
872
|
-
if (
|
|
884
|
+
if (this.isReadOnly()) return true;
|
|
873
885
|
e2.preventDefault();
|
|
874
886
|
const n3 = ce(t2);
|
|
875
887
|
return n3 && this.dispatch(n3), true;
|
|
@@ -902,21 +914,22 @@ class ht {
|
|
|
902
914
|
this.element.removeEventListener("keydown", this.handleKeydown);
|
|
903
915
|
}
|
|
904
916
|
}
|
|
905
|
-
function
|
|
917
|
+
function pt(e2) {
|
|
906
918
|
const t2 = [];
|
|
907
919
|
(e2.metaKey || e2.ctrlKey) && t2.push("Mod"), e2.shiftKey && t2.push("Shift"), e2.altKey && t2.push("Alt");
|
|
908
920
|
let n2 = e2.key;
|
|
909
921
|
return " " === n2 ? n2 = "Space" : 1 === n2.length && (n2 = n2.toUpperCase()), t2.push(n2), t2.join("-");
|
|
910
922
|
}
|
|
911
|
-
let
|
|
912
|
-
class
|
|
923
|
+
let ft;
|
|
924
|
+
class gt {
|
|
913
925
|
constructor(e2, t2) {
|
|
914
|
-
this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.schemaRegistry = t2.schemaRegistry, this.syncSelection = t2.syncSelection, this.handleCopy = this.onCopy.bind(this), this.handleCut = this.onCut.bind(this), e2.addEventListener("copy", this.handleCopy), e2.addEventListener("cut", this.handleCut);
|
|
926
|
+
this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.schemaRegistry = t2.schemaRegistry, this.syncSelection = t2.syncSelection, this.isReadOnly = t2.isReadOnly ?? (() => false), this.handleCopy = this.onCopy.bind(this), this.handleCut = this.onCut.bind(this), e2.addEventListener("copy", this.handleCopy), e2.addEventListener("cut", this.handleCut);
|
|
915
927
|
}
|
|
916
928
|
getState;
|
|
917
929
|
dispatch;
|
|
918
930
|
schemaRegistry;
|
|
919
931
|
syncSelection;
|
|
932
|
+
isReadOnly;
|
|
920
933
|
handleCopy;
|
|
921
934
|
handleCut;
|
|
922
935
|
onCopy(e2) {
|
|
@@ -928,7 +941,7 @@ class pt {
|
|
|
928
941
|
s2 && (Q(n2) ? this.writeNodeSelectionToClipboard(s2, t2) : this.writeTextSelectionToClipboard(s2, t2));
|
|
929
942
|
}
|
|
930
943
|
onCut(e2) {
|
|
931
|
-
if (
|
|
944
|
+
if (this.isReadOnly()) return;
|
|
932
945
|
this.syncSelection?.();
|
|
933
946
|
const t2 = this.getState(), n2 = t2.selection;
|
|
934
947
|
if (ee(n2) && te(n2)) return;
|
|
@@ -966,7 +979,7 @@ class pt {
|
|
|
966
979
|
if (!n3) continue;
|
|
967
980
|
const h5 = t2.getBlock(n3);
|
|
968
981
|
if (!h5) continue;
|
|
969
|
-
const
|
|
982
|
+
const d5 = _(h5), u2 = r(h5), p2 = e3 === i5 ? o2.from.offset : 0, f4 = e3 === a18 ? o2.to.offset : u2, g2 = d5.slice(p2, f4);
|
|
970
983
|
c8.push(g2), l2.push({ type: h5.type, text: g2, ...h5.attrs ? { attrs: { ...h5.attrs } } : {} });
|
|
971
984
|
}
|
|
972
985
|
const h4 = c8.join("\n");
|
|
@@ -977,13 +990,13 @@ class pt {
|
|
|
977
990
|
if (!c9) continue;
|
|
978
991
|
const l3 = t2.getBlock(c9);
|
|
979
992
|
if (!l3) continue;
|
|
980
|
-
const h5 = e3 === i5 ? o2.from.offset : 0,
|
|
981
|
-
n3.push(this.serializeBlockRangeToHTML(l3, h5,
|
|
993
|
+
const h5 = e3 === i5 ? o2.from.offset : 0, d5 = e3 === a18 ? o2.to.offset : r(l3);
|
|
994
|
+
n3.push(this.serializeBlockRangeToHTML(l3, h5, d5));
|
|
982
995
|
}
|
|
983
996
|
e2.setData("text/html", n3.join(""));
|
|
984
997
|
}
|
|
985
998
|
!(function(e3, t3) {
|
|
986
|
-
|
|
999
|
+
ft = { plainText: e3, blocks: t3 };
|
|
987
1000
|
})(h4, l2);
|
|
988
1001
|
}
|
|
989
1002
|
serializeBlockRangeToHTML(e2, n2, s2) {
|
|
@@ -1003,12 +1016,12 @@ class pt {
|
|
|
1003
1016
|
return o2.join("");
|
|
1004
1017
|
}
|
|
1005
1018
|
serializeTextWithMarks(e2, t2) {
|
|
1006
|
-
if (0 === t2.length || !this.schemaRegistry) return
|
|
1019
|
+
if (0 === t2.length || !this.schemaRegistry) return Ae(e2);
|
|
1007
1020
|
const n2 = [...t2].sort((e3, t3) => {
|
|
1008
1021
|
const n3 = this.schemaRegistry?.getMarkSpec(e3.type), s3 = this.schemaRegistry?.getMarkSpec(t3.type);
|
|
1009
1022
|
return (n3?.rank ?? 100) - (s3?.rank ?? 100);
|
|
1010
1023
|
});
|
|
1011
|
-
let s2 =
|
|
1024
|
+
let s2 = Ae(e2);
|
|
1012
1025
|
for (const e3 of n2) {
|
|
1013
1026
|
const t3 = this.schemaRegistry?.getMarkSpec(e3.type);
|
|
1014
1027
|
t3?.toHTMLString && (s2 = t3.toHTMLString(e3, s2));
|
|
@@ -1019,7 +1032,7 @@ class pt {
|
|
|
1019
1032
|
this.element.removeEventListener("copy", this.handleCopy), this.element.removeEventListener("cut", this.handleCut);
|
|
1020
1033
|
}
|
|
1021
1034
|
}
|
|
1022
|
-
class
|
|
1035
|
+
class mt {
|
|
1023
1036
|
listeners = /* @__PURE__ */ new Map();
|
|
1024
1037
|
emit(e2, t2) {
|
|
1025
1038
|
const n2 = this.listeners.get(e2.id);
|
|
@@ -1045,19 +1058,21 @@ class ft {
|
|
|
1045
1058
|
this.listeners.clear();
|
|
1046
1059
|
}
|
|
1047
1060
|
}
|
|
1048
|
-
class
|
|
1061
|
+
class yt {
|
|
1049
1062
|
plugins = /* @__PURE__ */ new Map();
|
|
1050
1063
|
commands = /* @__PURE__ */ new Map();
|
|
1051
1064
|
services = /* @__PURE__ */ new Map();
|
|
1052
1065
|
middlewares = [];
|
|
1053
1066
|
registrations = /* @__PURE__ */ new Map();
|
|
1054
|
-
eventBus = new
|
|
1067
|
+
eventBus = new mt();
|
|
1055
1068
|
pluginStyleSheets = [];
|
|
1056
1069
|
schemaRegistry = new Ue();
|
|
1057
1070
|
middlewareSorted = null;
|
|
1058
1071
|
initOrder = [];
|
|
1059
1072
|
initialized = false;
|
|
1060
1073
|
initializing = false;
|
|
1074
|
+
readOnly = false;
|
|
1075
|
+
readonlyBypassActive = false;
|
|
1061
1076
|
registerService(e2, t2) {
|
|
1062
1077
|
if (this.services.has(e2.id)) throw new Error(`Service "${e2.id}" is already registered.`);
|
|
1063
1078
|
this.services.set(e2.id, t2);
|
|
@@ -1130,7 +1145,7 @@ class gt {
|
|
|
1130
1145
|
try {
|
|
1131
1146
|
n3.middleware(e3, t2, a18);
|
|
1132
1147
|
} catch (t3) {
|
|
1133
|
-
console.error(
|
|
1148
|
+
console.error(`[PluginManager] Middleware "${n3.name}" error:`, t3), a18(e3);
|
|
1134
1149
|
}
|
|
1135
1150
|
} else o2 || (o2 = true, n2(e3));
|
|
1136
1151
|
};
|
|
@@ -1139,12 +1154,20 @@ class gt {
|
|
|
1139
1154
|
executeCommand(e2) {
|
|
1140
1155
|
const t2 = this.commands.get(e2);
|
|
1141
1156
|
if (!t2) return false;
|
|
1157
|
+
if (this.readOnly && !t2.readonlyAllowed) return false;
|
|
1158
|
+
const n2 = this.readOnly && t2.readonlyAllowed;
|
|
1159
|
+
n2 && (this.readonlyBypassActive = true);
|
|
1142
1160
|
try {
|
|
1143
1161
|
return t2.handler();
|
|
1144
1162
|
} catch (t3) {
|
|
1145
1163
|
return console.error(`[PluginManager] Command "${e2}" error:`, t3), false;
|
|
1164
|
+
} finally {
|
|
1165
|
+
n2 && (this.readonlyBypassActive = false);
|
|
1146
1166
|
}
|
|
1147
1167
|
}
|
|
1168
|
+
isReadonlyBypassed() {
|
|
1169
|
+
return this.readonlyBypassActive;
|
|
1170
|
+
}
|
|
1148
1171
|
configurePlugin(e2, t2) {
|
|
1149
1172
|
const n2 = this.plugins.get(e2);
|
|
1150
1173
|
if (!n2) throw new Error(`Plugin "${e2}" not found.`);
|
|
@@ -1154,9 +1177,28 @@ class gt {
|
|
|
1154
1177
|
console.error(`[PluginManager] Plugin "${e2}" error in onConfigure:`, t3);
|
|
1155
1178
|
}
|
|
1156
1179
|
}
|
|
1180
|
+
isReadOnly() {
|
|
1181
|
+
return this.readOnly;
|
|
1182
|
+
}
|
|
1183
|
+
setReadOnly(e2) {
|
|
1184
|
+
if (this.readOnly !== e2) {
|
|
1185
|
+
this.readOnly = e2;
|
|
1186
|
+
for (const t2 of this.initOrder) {
|
|
1187
|
+
const n2 = this.plugins.get(t2);
|
|
1188
|
+
if (n2?.onReadOnlyChange) try {
|
|
1189
|
+
n2.onReadOnlyChange(e2);
|
|
1190
|
+
} catch (e3) {
|
|
1191
|
+
console.error(`[PluginManager] Plugin "${t2}" error in onReadOnlyChange:`, e3);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1157
1196
|
getPluginIds() {
|
|
1158
1197
|
return [...this.plugins.keys()];
|
|
1159
1198
|
}
|
|
1199
|
+
getMiddlewareChain() {
|
|
1200
|
+
return this.getSortedMiddleware().map((e2) => ({ name: e2.name, priority: e2.priority, pluginId: e2.pluginId }));
|
|
1201
|
+
}
|
|
1160
1202
|
get(e2) {
|
|
1161
1203
|
return this.plugins.get(e2);
|
|
1162
1204
|
}
|
|
@@ -1219,15 +1261,16 @@ class gt {
|
|
|
1219
1261
|
const s3 = this.eventBus.on(e3, t3);
|
|
1220
1262
|
return n2.unsubscribers.push(s3), s3;
|
|
1221
1263
|
}, off: (e3, t3) => this.eventBus.off(e3, t3) };
|
|
1222
|
-
return { getState: t2.getState, dispatch: t2.dispatch, getContainer: t2.getContainer, getPluginContainer: t2.getPluginContainer, registerCommand: (t3, s3) => {
|
|
1264
|
+
return { getState: t2.getState, dispatch: t2.dispatch, getContainer: t2.getContainer, getPluginContainer: t2.getPluginContainer, isReadOnly: () => this.readOnly, registerCommand: (t3, s3, r2) => {
|
|
1223
1265
|
if (this.commands.has(t3)) {
|
|
1224
1266
|
const e3 = this.commands.get(t3);
|
|
1225
1267
|
throw new Error(`Command "${t3}" is already registered by plugin "${e3?.pluginId}".`);
|
|
1226
1268
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1269
|
+
const o2 = r2?.readonlyAllowed ?? false;
|
|
1270
|
+
this.commands.set(t3, { name: t3, handler: s3, pluginId: e2, readonlyAllowed: o2 }), n2.commands.push(t3);
|
|
1271
|
+
}, executeCommand: (e3) => this.executeCommand(e3), getEventBus: () => s2, registerMiddleware: (t3, s3) => {
|
|
1272
|
+
const r2 = { name: s3?.name ?? (t3.name || "anonymous"), pluginId: e2, middleware: t3, priority: s3?.priority ?? 100 };
|
|
1273
|
+
this.middlewares.push(r2), n2.middlewares.push(r2), this.middlewareSorted = null;
|
|
1231
1274
|
}, registerService: (e3, t3) => {
|
|
1232
1275
|
if (this.services.has(e3.id)) throw new Error(`Service "${e3.id}" is already registered by another plugin.`);
|
|
1233
1276
|
this.services.set(e3.id, t3), n2.services.push(e3.id);
|
|
@@ -1301,32 +1344,32 @@ class gt {
|
|
|
1301
1344
|
return r2;
|
|
1302
1345
|
}
|
|
1303
1346
|
}
|
|
1304
|
-
const
|
|
1305
|
-
function
|
|
1347
|
+
const kt = { label: "Print", tooltip: (e2) => `Print (${e2})`, printingAnnouncement: "Printing" }, bt = { en: kt, de: { label: "Drucken", tooltip: (e2) => `Drucken (${e2})`, printingAnnouncement: "Druckvorgang" }, es: { label: "Imprimir", tooltip: (e2) => `Imprimir (${e2})`, printingAnnouncement: "Imprimiendo" }, fr: { label: "Imprimer", tooltip: (e2) => `Imprimer (${e2})`, printingAnnouncement: "Impression" }, zh: { label: "打印", tooltip: (e2) => `打印 (${e2})`, printingAnnouncement: "正在打印" }, ru: { label: "Печать", tooltip: (e2) => `Печать (${e2})`, printingAnnouncement: "Печать" }, ar: { label: "طباعة", tooltip: (e2) => `طباعة (${e2})`, printingAnnouncement: "جارٍ الطباعة" }, hi: { label: "प्रिंट", tooltip: (e2) => `प्रिंट (${e2})`, printingAnnouncement: "प्रिंट हो रहा है" } };
|
|
1348
|
+
function St(e2) {
|
|
1306
1349
|
return "function" == typeof e2 ? e2() : e2;
|
|
1307
1350
|
}
|
|
1308
|
-
const
|
|
1309
|
-
function
|
|
1310
|
-
return Math.round(e2 *
|
|
1351
|
+
const vt = 96 / 25.4, wt = { DINA4: "din-a4", DINA5: "din-a5", USLetter: "us-letter", USLegal: "us-legal" };
|
|
1352
|
+
function Et(e2) {
|
|
1353
|
+
return Math.round(e2 * vt);
|
|
1311
1354
|
}
|
|
1312
|
-
const
|
|
1313
|
-
function
|
|
1314
|
-
const t2 =
|
|
1355
|
+
const Tt = /* @__PURE__ */ new Map([[wt.DINA4, { widthMm: 210, heightMm: 297, widthPx: Et(210), heightPx: Et(297) }], [wt.DINA5, { widthMm: 148, heightMm: 210, widthPx: Et(148), heightPx: Et(210) }], [wt.USLetter, { widthMm: 215.9, heightMm: 279.4, widthPx: Et(215.9), heightPx: Et(279.4) }], [wt.USLegal, { widthMm: 215.9, heightMm: 355.6, widthPx: Et(215.9), heightPx: Et(355.6) }]]), xt = /* @__PURE__ */ new Map([[wt.DINA4, "A4"], [wt.DINA5, "A5"], [wt.USLetter, "letter"], [wt.USLegal, "legal"]]);
|
|
1356
|
+
function Ct(e2) {
|
|
1357
|
+
const t2 = Tt.get(e2);
|
|
1315
1358
|
if (!t2) throw new Error(`Unknown paper size: ${e2}`);
|
|
1316
1359
|
return t2;
|
|
1317
1360
|
}
|
|
1318
|
-
const
|
|
1319
|
-
function
|
|
1320
|
-
return Object.values(
|
|
1361
|
+
const Nt = 48, At = 56, Lt = 24;
|
|
1362
|
+
function Mt(e2) {
|
|
1363
|
+
return Object.values(wt).includes(e2);
|
|
1321
1364
|
}
|
|
1322
|
-
function
|
|
1323
|
-
const t2 =
|
|
1365
|
+
function It(e2) {
|
|
1366
|
+
const t2 = xt.get(e2);
|
|
1324
1367
|
if (!t2) throw new Error(`Unknown paper size: ${e2}`);
|
|
1325
1368
|
return t2;
|
|
1326
1369
|
}
|
|
1327
|
-
const
|
|
1370
|
+
const Rt = new Oe("print"), Ot = new Re("print:before"), Bt = new Re("print:after"), Pt = { print() {
|
|
1328
1371
|
}, toHTML: () => "" };
|
|
1329
|
-
class
|
|
1372
|
+
class _t {
|
|
1330
1373
|
id = "print";
|
|
1331
1374
|
name = "Print";
|
|
1332
1375
|
config;
|
|
@@ -1336,7 +1379,7 @@ class Rt {
|
|
|
1336
1379
|
this.config = e2 ?? {};
|
|
1337
1380
|
}
|
|
1338
1381
|
init(e2) {
|
|
1339
|
-
this.locale =
|
|
1382
|
+
this.locale = Be(bt, e2, this.config.locale);
|
|
1340
1383
|
const t2 = e2.getContainer(), n2 = t2.getRootNode();
|
|
1341
1384
|
if (n2 instanceof ShadowRoot) {
|
|
1342
1385
|
const s3 = n2.host, r3 = e2.getEventBus();
|
|
@@ -1346,7 +1389,7 @@ class Rt {
|
|
|
1346
1389
|
}
|
|
1347
1390
|
function o3(r5) {
|
|
1348
1391
|
const o4 = { options: r5, cancelled: false };
|
|
1349
|
-
if (s4.emit(
|
|
1392
|
+
if (s4.emit(Ot, o4), o4.cancelled) return null;
|
|
1350
1393
|
const i6 = o4.options, a18 = (function(e4, t4, n4, s5 = "en") {
|
|
1351
1394
|
return ["<!DOCTYPE html>", `<html lang="${s5}">`, "<head>", '<meta charset="utf-8">', `<title>${n4.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</title>`, `<style>${e4}</style>`, "</head>", `<body>${t4}</body>`, "</html>"].join("\n");
|
|
1352
1395
|
})((function(e4, t4, n4) {
|
|
@@ -1382,7 +1425,7 @@ ${s6.join("\n")}
|
|
|
1382
1425
|
const i7 = (function(e5) {
|
|
1383
1426
|
const t5 = [], n5 = [];
|
|
1384
1427
|
if (e5.margin ? n5.push(` margin: ${e5.margin};`) : e5.paperSize && n5.push(" margin: 0;"), e5.paperSize || e5.orientation) {
|
|
1385
|
-
const t6 = [e5.paperSize ?
|
|
1428
|
+
const t6 = [e5.paperSize ? It(e5.paperSize) : "A4"];
|
|
1386
1429
|
e5.orientation && t6.push(e5.orientation), n5.push(` size: ${t6.join(" ")};`);
|
|
1387
1430
|
}
|
|
1388
1431
|
n5.length > 0 && t5.push(`@page {
|
|
@@ -1418,11 +1461,11 @@ ${n5.join("\n")}
|
|
|
1418
1461
|
})(n4, t4), (function(e5, t5) {
|
|
1419
1462
|
if (t5.header) {
|
|
1420
1463
|
const n5 = document.createElement("div");
|
|
1421
|
-
n5.className = "notectl-print-header", n5.innerHTML =
|
|
1464
|
+
n5.className = "notectl-print-header", n5.innerHTML = St(t5.header), e5.insertBefore(n5, e5.firstChild);
|
|
1422
1465
|
}
|
|
1423
1466
|
if (t5.footer) {
|
|
1424
1467
|
const n5 = document.createElement("div");
|
|
1425
|
-
n5.className = "notectl-print-footer", n5.innerHTML =
|
|
1468
|
+
n5.className = "notectl-print-footer", n5.innerHTML = St(t5.footer), e5.appendChild(n5);
|
|
1426
1469
|
}
|
|
1427
1470
|
})(n4, t4), n4;
|
|
1428
1471
|
})(n3, i6).outerHTML, i6.title ?? "", t3.closest("[lang]")?.getAttribute("lang") ?? (document.documentElement.lang || "en")), c8 = { html: a18 };
|
|
@@ -1443,7 +1486,7 @@ ${n5.join("\n")}
|
|
|
1443
1486
|
}, toHTML: (e4) => o3(r4(e4)) ?? "" };
|
|
1444
1487
|
})(n2, s3, t2, r3);
|
|
1445
1488
|
} else this.service = Pt;
|
|
1446
|
-
e2.registerService(
|
|
1489
|
+
e2.registerService(Rt, this.service);
|
|
1447
1490
|
const s2 = this.config.defaults ?? {}, r2 = this.service, o2 = this.locale;
|
|
1448
1491
|
e2.registerCommand("print", () => (e2.announce(o2.printingAnnouncement), r2.print(s2), true));
|
|
1449
1492
|
const i5 = this.config.keyBinding ?? "Mod-P";
|
|
@@ -1456,23 +1499,23 @@ ${n5.join("\n")}
|
|
|
1456
1499
|
this.service = null;
|
|
1457
1500
|
}
|
|
1458
1501
|
}
|
|
1459
|
-
const
|
|
1460
|
-
function
|
|
1502
|
+
const Dt = { Light: "light", Dark: "dark", System: "system" }, Ht = { 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" } }, zt = { 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" } };
|
|
1503
|
+
function $t(e2, t2) {
|
|
1461
1504
|
return { name: t2.name, primitives: { ...e2.primitives, ...t2.primitives }, toolbar: t2.toolbar ? { ...e2.toolbar, ...t2.toolbar } : e2.toolbar, codeBlock: t2.codeBlock ? { ...e2.codeBlock, ...t2.codeBlock } : e2.codeBlock, tooltip: t2.tooltip ? { ...e2.tooltip, ...t2.tooltip } : e2.tooltip };
|
|
1462
1505
|
}
|
|
1463
|
-
function
|
|
1506
|
+
function jt(e2) {
|
|
1464
1507
|
if ("object" == typeof e2) return e2;
|
|
1465
1508
|
switch (e2) {
|
|
1466
|
-
case
|
|
1467
|
-
return
|
|
1468
|
-
case
|
|
1469
|
-
return
|
|
1509
|
+
case Dt.Light:
|
|
1510
|
+
return Ht;
|
|
1511
|
+
case Dt.Dark:
|
|
1512
|
+
return zt;
|
|
1470
1513
|
default:
|
|
1471
|
-
return
|
|
1514
|
+
return Ht;
|
|
1472
1515
|
}
|
|
1473
1516
|
}
|
|
1474
|
-
const
|
|
1475
|
-
function
|
|
1517
|
+
const Ft = [["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"]], Ut = /* @__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)"]]);
|
|
1518
|
+
function Kt(e2, t2) {
|
|
1476
1519
|
const n2 = t2.split(".");
|
|
1477
1520
|
let s2 = e2;
|
|
1478
1521
|
for (const e3 of n2) {
|
|
@@ -1482,37 +1525,38 @@ function Ft(e2, t2) {
|
|
|
1482
1525
|
}
|
|
1483
1526
|
return "string" == typeof s2 ? s2 : void 0;
|
|
1484
1527
|
}
|
|
1485
|
-
function
|
|
1528
|
+
function Wt(e2) {
|
|
1486
1529
|
const t2 = [":host {"];
|
|
1487
|
-
for (const [n2, s2] of
|
|
1488
|
-
const r2 =
|
|
1530
|
+
for (const [n2, s2] of Ft) {
|
|
1531
|
+
const r2 = Kt(e2, n2);
|
|
1489
1532
|
if (void 0 !== r2) t2.push(` ${s2}: ${r2};`);
|
|
1490
1533
|
else {
|
|
1491
|
-
const e3 =
|
|
1534
|
+
const e3 = Ut.get(s2);
|
|
1492
1535
|
e3 && t2.push(` ${s2}: ${e3};`);
|
|
1493
1536
|
}
|
|
1494
1537
|
}
|
|
1495
1538
|
return t2.push("}"), t2.join("\n");
|
|
1496
1539
|
}
|
|
1497
|
-
function
|
|
1540
|
+
function Vt(e2) {
|
|
1498
1541
|
const t2 = new CSSStyleSheet();
|
|
1499
|
-
return t2.replaceSync(
|
|
1542
|
+
return t2.replaceSync(Wt(e2)), t2;
|
|
1500
1543
|
}
|
|
1501
|
-
const
|
|
1502
|
-
class
|
|
1544
|
+
const qt = { EN: "en", DE: "de", ES: "es", FR: "fr", ZH: "zh", RU: "ru", AR: "ar", HI: "hi", BROWSER: "browser" };
|
|
1545
|
+
class Gt {
|
|
1503
1546
|
constructor(e2, t2) {
|
|
1504
|
-
this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.syncSelection = t2.syncSelection, this.schemaRegistry = t2.schemaRegistry, this.handleBeforeInput = this.onBeforeInput.bind(this), this.handleCompositionStart = this.onCompositionStart.bind(this), this.handleCompositionEnd = this.onCompositionEnd.bind(this), e2.addEventListener("beforeinput", this.handleBeforeInput), e2.addEventListener("compositionstart", this.handleCompositionStart), e2.addEventListener("compositionend", this.handleCompositionEnd);
|
|
1547
|
+
this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.syncSelection = t2.syncSelection, this.schemaRegistry = t2.schemaRegistry, this.isReadOnly = t2.isReadOnly ?? (() => false), this.handleBeforeInput = this.onBeforeInput.bind(this), this.handleCompositionStart = this.onCompositionStart.bind(this), this.handleCompositionEnd = this.onCompositionEnd.bind(this), e2.addEventListener("beforeinput", this.handleBeforeInput), e2.addEventListener("compositionstart", this.handleCompositionStart), e2.addEventListener("compositionend", this.handleCompositionEnd);
|
|
1505
1548
|
}
|
|
1506
1549
|
getState;
|
|
1507
1550
|
dispatch;
|
|
1508
1551
|
syncSelection;
|
|
1509
1552
|
schemaRegistry;
|
|
1553
|
+
isReadOnly;
|
|
1510
1554
|
composing = false;
|
|
1511
1555
|
handleBeforeInput;
|
|
1512
1556
|
handleCompositionStart;
|
|
1513
1557
|
handleCompositionEnd;
|
|
1514
1558
|
onBeforeInput(e2) {
|
|
1515
|
-
if (
|
|
1559
|
+
if (this.isReadOnly()) return;
|
|
1516
1560
|
if (this.composing && "insertCompositionText" === e2.inputType) return;
|
|
1517
1561
|
e2.preventDefault(), "insertText" !== e2.inputType && "insertCompositionText" !== e2.inputType && this.syncSelection();
|
|
1518
1562
|
const t2 = this.getState();
|
|
@@ -1552,7 +1596,7 @@ class qt {
|
|
|
1552
1596
|
this.composing = true;
|
|
1553
1597
|
}
|
|
1554
1598
|
onCompositionEnd(e2) {
|
|
1555
|
-
if (this.composing = false,
|
|
1599
|
+
if (this.composing = false, this.isReadOnly()) return;
|
|
1556
1600
|
const t2 = e2.data;
|
|
1557
1601
|
if (!t2) return;
|
|
1558
1602
|
const n2 = this.getState(), s2 = le(n2, t2, "input");
|
|
@@ -1566,7 +1610,7 @@ class qt {
|
|
|
1566
1610
|
if (Q(t2.selection)) return;
|
|
1567
1611
|
const { anchor: n2 } = t2.selection, s2 = t2.getBlock(n2.blockId);
|
|
1568
1612
|
if (!s2) return;
|
|
1569
|
-
const r2 =
|
|
1613
|
+
const r2 = _(s2).slice(0, n2.offset);
|
|
1570
1614
|
for (const n3 of e2) {
|
|
1571
1615
|
const e3 = n3.pattern.exec(r2);
|
|
1572
1616
|
if (e3) {
|
|
@@ -1579,14 +1623,14 @@ class qt {
|
|
|
1579
1623
|
this.element.removeEventListener("beforeinput", this.handleBeforeInput), this.element.removeEventListener("compositionstart", this.handleCompositionStart), this.element.removeEventListener("compositionend", this.handleCompositionEnd);
|
|
1580
1624
|
}
|
|
1581
1625
|
}
|
|
1582
|
-
function
|
|
1626
|
+
function Xt(e2) {
|
|
1583
1627
|
return e2.reduce((e3, t2) => e3 + t2.text, "");
|
|
1584
1628
|
}
|
|
1585
|
-
function
|
|
1629
|
+
function Jt(e2) {
|
|
1586
1630
|
return e2.reduce((e3, t2) => e3 + t2.text.length, 0);
|
|
1587
1631
|
}
|
|
1588
|
-
const
|
|
1589
|
-
class
|
|
1632
|
+
const Qt = /* @__PURE__ */ new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "BLOCKQUOTE", "UL", "OL", "LI", "HR", "PRE", "TABLE", "THEAD", "TBODY", "TR"]), Yt = /* @__PURE__ */ new Set(["STRONG", "B", "EM", "I", "U", "S", "STRIKE", "DEL", "A", "SPAN", "BR", "SUB", "SUP", "CODE"]);
|
|
1633
|
+
class Zt {
|
|
1590
1634
|
schema;
|
|
1591
1635
|
blockParseRules;
|
|
1592
1636
|
markParseRules;
|
|
@@ -1602,7 +1646,7 @@ class Qt {
|
|
|
1602
1646
|
let n2 = [];
|
|
1603
1647
|
for (const s2 of Array.from(e2.childNodes)) if (s2.nodeType === Node.ELEMENT_NODE) {
|
|
1604
1648
|
const e3 = s2;
|
|
1605
|
-
this.isBlockElement(e3) ? (this.flushPendingSegments(t2, n2), n2 = [], t2.push(...this.parseBlockElement(e3))) : n2.push(...this.parseInlineNode(s2, []));
|
|
1649
|
+
this.isBlockElement(e3) ? (this.flushPendingSegments(t2, n2), n2 = [], t2.push(...this.parseBlockElement(e3))) : e3.children.length > 0 && this.containsBlockDescendants(e3) ? (this.flushPendingSegments(t2, n2), n2 = [], t2.push(...this.parseContainerWithMarks(e3, this.marksFromElement(e3)))) : n2.push(...this.parseInlineNode(s2, []));
|
|
1606
1650
|
} else if (s2.nodeType === Node.TEXT_NODE) {
|
|
1607
1651
|
const e3 = s2.textContent ?? "";
|
|
1608
1652
|
e3 && n2.push({ text: e3, marks: [] });
|
|
@@ -1618,7 +1662,7 @@ class Qt {
|
|
|
1618
1662
|
switch (t2) {
|
|
1619
1663
|
case "P":
|
|
1620
1664
|
case "DIV":
|
|
1621
|
-
return
|
|
1665
|
+
return this.parseBlockWithLineBreaks(e2, this.resolveBlockType(Te("paragraph")));
|
|
1622
1666
|
case "BLOCKQUOTE":
|
|
1623
1667
|
return this.parseBlockquote(e2);
|
|
1624
1668
|
case "UL":
|
|
@@ -1683,7 +1727,7 @@ class Qt {
|
|
|
1683
1727
|
if (e2.nodeType !== Node.ELEMENT_NODE) return [];
|
|
1684
1728
|
const n2 = e2, s2 = n2.tagName;
|
|
1685
1729
|
if ("BR" === s2) return [{ text: "\n", marks: this.resolveMarks(t2) }];
|
|
1686
|
-
if (this.isBlockElement(n2) && !
|
|
1730
|
+
if (this.isBlockElement(n2) && !Yt.has(s2)) return this.parseInlineChildren(n2, t2);
|
|
1687
1731
|
const r2 = this.mergeMarks(t2, this.marksFromElement(n2));
|
|
1688
1732
|
return this.parseInlineChildren(n2, r2);
|
|
1689
1733
|
}
|
|
@@ -1711,7 +1755,11 @@ class Qt {
|
|
|
1711
1755
|
if (s3.size > 0) return t2;
|
|
1712
1756
|
}
|
|
1713
1757
|
const s2 = e2.tagName;
|
|
1714
|
-
if ("STRONG"
|
|
1758
|
+
if ("STRONG" === s2 || "B" === s2) {
|
|
1759
|
+
const n3 = e2.style.fontWeight, s3 = Number.parseInt(n3, 10);
|
|
1760
|
+
"normal" === n3 || !Number.isNaN(s3) && s3 < 700 || t2.push({ type: xe("bold") });
|
|
1761
|
+
}
|
|
1762
|
+
if ("EM" !== s2 && "I" !== s2 || t2.push({ type: xe("italic") }), "U" === s2 && t2.push({ type: xe("underline") }), "S" !== s2 && "STRIKE" !== s2 && "DEL" !== s2 || t2.push({ type: xe("strikethrough") }), "A" === s2) {
|
|
1715
1763
|
const n3 = e2.getAttribute("href") ?? "";
|
|
1716
1764
|
t2.push({ type: xe("link"), attrs: { href: n3 } });
|
|
1717
1765
|
}
|
|
@@ -1733,7 +1781,7 @@ class Qt {
|
|
|
1733
1781
|
const t2 = [];
|
|
1734
1782
|
for (const n2 of e2) {
|
|
1735
1783
|
const e3 = t2[t2.length - 1];
|
|
1736
|
-
e3 &&
|
|
1784
|
+
e3 && q(e3.marks, n2.marks) ? t2[t2.length - 1] = { text: e3.text + n2.text, marks: e3.marks } : n2.text.length > 0 && t2.push(n2);
|
|
1737
1785
|
}
|
|
1738
1786
|
return t2;
|
|
1739
1787
|
}
|
|
@@ -1753,7 +1801,7 @@ class Qt {
|
|
|
1753
1801
|
return null;
|
|
1754
1802
|
}
|
|
1755
1803
|
isBlockElement(e2) {
|
|
1756
|
-
if (
|
|
1804
|
+
if (Qt.has(e2.tagName)) return true;
|
|
1757
1805
|
const t2 = e2.tagName.toLowerCase();
|
|
1758
1806
|
return this.blockParseRules.some((e3) => e3.rule.tag === t2);
|
|
1759
1807
|
}
|
|
@@ -1764,21 +1812,75 @@ class Qt {
|
|
|
1764
1812
|
const t2 = e2.querySelector('input[type="checkbox"]');
|
|
1765
1813
|
return t2?.hasAttribute("checked") ?? false;
|
|
1766
1814
|
}
|
|
1815
|
+
containsBlockDescendants(e2) {
|
|
1816
|
+
for (const t2 of Array.from(e2.children)) {
|
|
1817
|
+
if (this.isBlockElement(t2)) return true;
|
|
1818
|
+
if (this.containsBlockDescendants(t2)) return true;
|
|
1819
|
+
}
|
|
1820
|
+
return false;
|
|
1821
|
+
}
|
|
1822
|
+
parseContainerWithMarks(e2, t2) {
|
|
1823
|
+
const n2 = this.parseContainer(e2);
|
|
1824
|
+
return 0 === t2.length ? n2 : n2.map((e3) => ({ ...e3, segments: this.prependMarks(e3.segments, t2) }));
|
|
1825
|
+
}
|
|
1826
|
+
prependMarks(e2, t2) {
|
|
1827
|
+
return e2.map((e3) => ({ text: e3.text, marks: this.mergeMarks(t2, e3.marks) }));
|
|
1828
|
+
}
|
|
1829
|
+
parseBlockWithLineBreaks(e2, t2) {
|
|
1830
|
+
const n2 = this.parseInlineChildren(e2, []);
|
|
1831
|
+
if (!n2.some((e3) => e3.text.includes("\n"))) return [{ type: t2, segments: this.ensureSegments(n2) }];
|
|
1832
|
+
const s2 = [];
|
|
1833
|
+
let r2 = [];
|
|
1834
|
+
for (const e3 of n2) {
|
|
1835
|
+
const n3 = e3.text.split("\n");
|
|
1836
|
+
for (let o2 = 0; o2 < n3.length; o2++) {
|
|
1837
|
+
o2 > 0 && (s2.push({ type: t2, segments: this.ensureSegments(this.normalizeSegments(r2)) }), r2 = []);
|
|
1838
|
+
const i5 = n3[o2] ?? "";
|
|
1839
|
+
i5 && r2.push({ text: i5, marks: e3.marks });
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
return s2.push({ type: t2, segments: this.ensureSegments(this.normalizeSegments(r2)) }), s2;
|
|
1843
|
+
}
|
|
1767
1844
|
flushPendingSegments(e2, t2) {
|
|
1768
1845
|
const n2 = this.normalizeSegments(t2);
|
|
1769
1846
|
0 !== n2.length && (n2.every((e3) => "" === e3.text.trim()) || e2.push({ type: this.resolveBlockType(Te("paragraph")), segments: n2 }));
|
|
1770
1847
|
}
|
|
1771
1848
|
}
|
|
1772
|
-
|
|
1849
|
+
const en = { 1: "x-small", 2: "small", 3: "medium", 4: "large", 5: "x-large", 6: "xx-large", 7: "xxx-large" };
|
|
1850
|
+
function tn(e2) {
|
|
1851
|
+
return e2.toLowerCase().includes("font-size");
|
|
1852
|
+
}
|
|
1853
|
+
function nn(e2, t2) {
|
|
1854
|
+
for (; e2.firstChild; ) t2.appendChild(e2.firstChild);
|
|
1855
|
+
}
|
|
1856
|
+
function sn(e2) {
|
|
1857
|
+
const t2 = e2.parentNode;
|
|
1858
|
+
if (t2) {
|
|
1859
|
+
for (; e2.firstChild; ) t2.insertBefore(e2.firstChild, e2);
|
|
1860
|
+
t2.removeChild(e2);
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
function rn(e2, t2) {
|
|
1864
|
+
if (!t2) return;
|
|
1865
|
+
const n2 = {};
|
|
1866
|
+
let s2 = false;
|
|
1867
|
+
for (const r2 of Object.keys(t2)) {
|
|
1868
|
+
const o2 = t2[r2], i5 = e2?.[r2];
|
|
1869
|
+
"string" == typeof i5 || "number" == typeof i5 || "boolean" == typeof i5 ? n2[r2] = i5 : void 0 !== o2.default && (n2[r2] = o2.default), r2 in n2 && (s2 = true);
|
|
1870
|
+
}
|
|
1871
|
+
return s2 ? n2 : void 0;
|
|
1872
|
+
}
|
|
1873
|
+
class on {
|
|
1773
1874
|
constructor(e2, t2) {
|
|
1774
|
-
this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.schemaRegistry = t2.schemaRegistry, this.handlePaste = this.onPaste.bind(this), e2.addEventListener("paste", this.handlePaste);
|
|
1875
|
+
this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.schemaRegistry = t2.schemaRegistry, this.isReadOnly = t2.isReadOnly ?? (() => false), this.handlePaste = this.onPaste.bind(this), e2.addEventListener("paste", this.handlePaste);
|
|
1775
1876
|
}
|
|
1776
1877
|
getState;
|
|
1777
1878
|
dispatch;
|
|
1778
1879
|
schemaRegistry;
|
|
1880
|
+
isReadOnly;
|
|
1779
1881
|
handlePaste;
|
|
1780
1882
|
onPaste(e2) {
|
|
1781
|
-
if (e2.preventDefault(),
|
|
1883
|
+
if (e2.preventDefault(), this.isReadOnly()) return;
|
|
1782
1884
|
const t2 = e2.clipboardData;
|
|
1783
1885
|
if (!t2) return;
|
|
1784
1886
|
const n2 = t2.getData("application/x-notectl-block");
|
|
@@ -1787,7 +1889,7 @@ class Yt {
|
|
|
1787
1889
|
const s2 = t2.getData("text/plain");
|
|
1788
1890
|
if (s2) {
|
|
1789
1891
|
const e3 = (function(e4) {
|
|
1790
|
-
if (
|
|
1892
|
+
if (ft && ft.plainText === e4) return ft.blocks;
|
|
1791
1893
|
})(s2);
|
|
1792
1894
|
if (e3 && this.handleRichPaste(e3)) return;
|
|
1793
1895
|
}
|
|
@@ -1795,50 +1897,67 @@ class Yt {
|
|
|
1795
1897
|
if (i5) {
|
|
1796
1898
|
const e3 = this.extractRichData(i5);
|
|
1797
1899
|
if (e3 && this.handleRichPasteFromJson(e3)) return;
|
|
1798
|
-
const t3 =
|
|
1900
|
+
const t3 = document.createElement("template");
|
|
1901
|
+
t3.innerHTML = i5, (function(e4) {
|
|
1902
|
+
const t4 = Array.from(e4.querySelectorAll("font"));
|
|
1903
|
+
for (const e5 of t4) {
|
|
1904
|
+
const t5 = e5.getAttribute("color"), n4 = e5.getAttribute("face"), s4 = e5.getAttribute("size"), r3 = e5.getAttribute("style") ?? "";
|
|
1905
|
+
if (!(null !== t5 || null !== n4 || null !== s4 || r3.length > 0)) {
|
|
1906
|
+
sn(e5);
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
const o2 = document.createElement("span"), i6 = [];
|
|
1910
|
+
if (r3 && i6.push(r3.endsWith(";") ? r3 : `${r3};`), t5 && i6.push(`color: ${t5};`), n4 && i6.push(`font-family: ${n4};`), s4 && !tn(r3)) {
|
|
1911
|
+
const e6 = en[s4];
|
|
1912
|
+
e6 && i6.push(`font-size: ${e6};`);
|
|
1913
|
+
}
|
|
1914
|
+
o2.setAttribute("style", i6.join(" ")), nn(e5, o2), e5.parentNode?.replaceChild(o2, e5);
|
|
1915
|
+
}
|
|
1916
|
+
})(t3.content);
|
|
1917
|
+
const n3 = t3.innerHTML, s3 = this.schemaRegistry ? this.schemaRegistry.getAllowedTags() : ["strong", "em", "u", "b", "i", "p", "br", "div", "span"], a18 = this.schemaRegistry ? this.schemaRegistry.getAllowedAttrs() : [], c8 = Fe.sanitize(n3, { ALLOWED_TAGS: s3, ALLOWED_ATTR: a18 });
|
|
1799
1918
|
if (this.schemaRegistry) {
|
|
1800
|
-
const e4 = ve(this.schemaRegistry), t4 = new
|
|
1801
|
-
n4.innerHTML =
|
|
1802
|
-
const
|
|
1919
|
+
const e4 = ve(this.schemaRegistry), t4 = new Zt({ schema: e4, schemaRegistry: this.schemaRegistry }), n4 = document.createElement("template");
|
|
1920
|
+
n4.innerHTML = c8;
|
|
1921
|
+
const s4 = (function(e5, t5) {
|
|
1803
1922
|
if (0 === t5.blocks.length) return e5.transaction("paste").setSelection(e5.selection).build();
|
|
1804
1923
|
const n5 = t5.blocks[0];
|
|
1805
1924
|
return n5 ? 1 === t5.blocks.length && n5.type === Te("paragraph") ? (function(e6, t6) {
|
|
1806
1925
|
const n6 = e6.selection;
|
|
1807
1926
|
if (Q(n6)) return e6.transaction("paste").setSelection(n6).build();
|
|
1808
|
-
const
|
|
1809
|
-
te(n6) || ke(e6,
|
|
1810
|
-
const o2 = r3 ? r3.from.blockId : n6.anchor.blockId,
|
|
1811
|
-
return
|
|
1927
|
+
const s5 = e6.transaction("paste"), r3 = te(n6) ? null : ne(n6, e6.getBlockOrder());
|
|
1928
|
+
te(n6) || ke(e6, s5);
|
|
1929
|
+
const o2 = r3 ? r3.from.blockId : n6.anchor.blockId, i6 = r3 ? r3.from.offset : n6.anchor.offset, a19 = Jt(t6), c9 = Xt(t6);
|
|
1930
|
+
return s5.insertText(o2, i6, c9, [], t6), s5.setSelection(J(o2, i6 + a19)), s5.build();
|
|
1812
1931
|
})(e5, n5.segments) : 1 === t5.blocks.length ? (function(e6, t6) {
|
|
1813
1932
|
const n6 = e6.selection;
|
|
1814
1933
|
if (Q(n6)) return e6.transaction("paste").setSelection(n6).build();
|
|
1815
|
-
const
|
|
1816
|
-
te(n6) || ke(e6,
|
|
1817
|
-
const o2 = r3 ? r3.from.blockId : n6.anchor.blockId,
|
|
1818
|
-
return
|
|
1934
|
+
const s5 = e6.transaction("paste"), r3 = te(n6) ? null : ne(n6, e6.getBlockOrder());
|
|
1935
|
+
te(n6) || ke(e6, s5);
|
|
1936
|
+
const o2 = r3 ? r3.from.blockId : n6.anchor.blockId, i6 = r3 ? r3.from.offset : n6.anchor.offset, a19 = Jt(t6.segments), c9 = Xt(t6.segments);
|
|
1937
|
+
return s5.setBlockType(o2, t6.type, t6.attrs), s5.insertText(o2, i6, c9, [], t6.segments), s5.setSelection(J(o2, i6 + a19)), s5.build();
|
|
1819
1938
|
})(e5, n5) : (function(e6, t6) {
|
|
1820
1939
|
const n6 = e6.selection;
|
|
1821
1940
|
if (Q(n6)) return e6.transaction("paste").setSelection(n6).build();
|
|
1822
|
-
const
|
|
1823
|
-
te(n6) || ke(e6,
|
|
1824
|
-
const
|
|
1825
|
-
if (!l2 || !h4) return
|
|
1826
|
-
const
|
|
1827
|
-
l2.segments.length > 0 && u2 > 0 &&
|
|
1828
|
-
const p2 =
|
|
1829
|
-
|
|
1830
|
-
let g2 =
|
|
1831
|
-
for (const e7 of
|
|
1832
|
-
const t7 = e7.segments.map((e8) => N(e8.text, [...e8.marks])), n7 = o(e7.type, t7.length > 0 ? t7 : void 0,
|
|
1833
|
-
|
|
1941
|
+
const s5 = e6.transaction("paste"), r3 = te(n6) ? null : ne(n6, e6.getBlockOrder());
|
|
1942
|
+
te(n6) || ke(e6, s5);
|
|
1943
|
+
const i6 = r3 ? r3.from.blockId : n6.anchor.blockId, a19 = r3 ? r3.from.offset : n6.anchor.offset, c9 = e6.getBlockOrder().indexOf(i6), l2 = t6.blocks[0], h4 = t6.blocks[t6.blocks.length - 1];
|
|
1944
|
+
if (!l2 || !h4) return s5.build();
|
|
1945
|
+
const d5 = t6.blocks.slice(1, -1), u2 = Jt(l2.segments);
|
|
1946
|
+
l2.segments.length > 0 && u2 > 0 && s5.insertText(i6, a19, Xt(l2.segments), [], l2.segments), l2.type !== Te("paragraph") && s5.setBlockType(i6, l2.type, l2.attrs);
|
|
1947
|
+
const p2 = a19 + u2, f4 = V();
|
|
1948
|
+
s5.splitBlock(i6, p2, f4);
|
|
1949
|
+
let g2 = c9 + 1;
|
|
1950
|
+
for (const e7 of d5) {
|
|
1951
|
+
const t7 = e7.segments.map((e8) => N(e8.text, [...e8.marks])), n7 = o(e7.type, t7.length > 0 ? t7 : void 0, V(), e7.attrs);
|
|
1952
|
+
s5.insertNode([], g2, n7), g2++;
|
|
1834
1953
|
}
|
|
1835
|
-
const m2 =
|
|
1836
|
-
return h4.segments.length > 0 && m2 > 0 &&
|
|
1954
|
+
const m2 = Jt(h4.segments);
|
|
1955
|
+
return h4.segments.length > 0 && m2 > 0 && s5.insertText(f4, 0, Xt(h4.segments), [], h4.segments), h4.type !== Te("paragraph") && s5.setBlockType(f4, h4.type, h4.attrs), s5.setSelection(J(f4, m2)), s5.build();
|
|
1837
1956
|
})(e5, t5) : e5.transaction("paste").setSelection(e5.selection).build();
|
|
1838
1957
|
})(r2, t4.parse(n4.content));
|
|
1839
|
-
this.dispatch(
|
|
1958
|
+
this.dispatch(s4);
|
|
1840
1959
|
} else {
|
|
1841
|
-
const e4 = this.extractTextFromHTML(
|
|
1960
|
+
const e4 = this.extractTextFromHTML(c8);
|
|
1842
1961
|
if (e4) {
|
|
1843
1962
|
const t4 = le(r2, e4, "paste");
|
|
1844
1963
|
this.dispatch(t4);
|
|
@@ -1860,23 +1979,24 @@ class Yt {
|
|
|
1860
1979
|
}
|
|
1861
1980
|
const n2 = t2.type;
|
|
1862
1981
|
if (!n2) return;
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1982
|
+
const s2 = this.schemaRegistry?.getNodeSpec(n2);
|
|
1983
|
+
if (this.schemaRegistry && !s2) return;
|
|
1984
|
+
const r2 = this.getState(), i5 = r2.selection, a18 = Q(i5) ? i5.nodeId : i5.anchor.blockId, c8 = V(), l2 = rn(t2.attrs, s2?.attrs), h4 = o(Te(n2), [], c8, l2), d5 = this.findTableCellAncestor(r2, a18);
|
|
1985
|
+
if (d5) {
|
|
1986
|
+
const e3 = Ie(r2.doc, d5);
|
|
1867
1987
|
if (!e3) return;
|
|
1868
|
-
const t3 =
|
|
1988
|
+
const t3 = r2.getBlock(d5);
|
|
1869
1989
|
if (!t3) return;
|
|
1870
|
-
const n3 =
|
|
1871
|
-
return n3.insertNode(e3, t3.children.length,
|
|
1990
|
+
const n3 = r2.transaction("paste");
|
|
1991
|
+
return n3.insertNode(e3, t3.children.length, h4), n3.setSelection(X(c8, [...e3, c8])), void this.dispatch(n3.build());
|
|
1872
1992
|
}
|
|
1873
|
-
const
|
|
1874
|
-
const e3 =
|
|
1993
|
+
const u2 = Ie(r2.doc, a18), p2 = u2 && u2.length > 1 ? u2.slice(0, -1) : [], f4 = (0 === p2.length ? r2.doc.children : (() => {
|
|
1994
|
+
const e3 = r2.getBlock(p2[p2.length - 1]);
|
|
1875
1995
|
return e3 ? e3.children : [];
|
|
1876
|
-
})()).findIndex((e3) => m(e3) && e3.id ===
|
|
1877
|
-
if (
|
|
1878
|
-
const
|
|
1879
|
-
|
|
1996
|
+
})()).findIndex((e3) => m(e3) && e3.id === a18);
|
|
1997
|
+
if (f4 < 0) return;
|
|
1998
|
+
const g2 = r2.transaction("paste");
|
|
1999
|
+
g2.insertNode(p2, f4 + 1, h4), g2.setSelection(X(c8, [...p2, c8])), this.dispatch(g2.build());
|
|
1880
2000
|
}
|
|
1881
2001
|
handleRichPasteFromJson(e2) {
|
|
1882
2002
|
let t2;
|
|
@@ -1894,42 +2014,52 @@ class Yt {
|
|
|
1894
2014
|
return r2 ? this.insertRichBlocksIntoCell(e2, t2, s2, r2) : this.insertRichBlocksAtRoot(e2, t2, s2);
|
|
1895
2015
|
}
|
|
1896
2016
|
insertRichBlocksIntoCell(e2, t2, n2, s2) {
|
|
1897
|
-
const r2 =
|
|
2017
|
+
const r2 = Ie(t2.doc, s2);
|
|
1898
2018
|
if (!r2) return false;
|
|
1899
2019
|
const i5 = t2.getBlock(s2);
|
|
1900
2020
|
if (!i5) return false;
|
|
1901
|
-
const a18 = t2.getBlock(n2), c8 = i5.children.findIndex((e3) => m(e3) && e3.id === n2), l2 = void 0 !== a18 && "paragraph" === a18.type && "" ===
|
|
2021
|
+
const a18 = t2.getBlock(n2), c8 = i5.children.findIndex((e3) => m(e3) && e3.id === n2), l2 = void 0 !== a18 && "paragraph" === a18.type && "" === _(a18);
|
|
1902
2022
|
let h4 = c8 >= 0 ? c8 + 1 : i5.children.length;
|
|
1903
|
-
const
|
|
2023
|
+
const d5 = t2.transaction("paste");
|
|
1904
2024
|
let u2, p2 = 0;
|
|
1905
2025
|
for (const t3 of e2) {
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2026
|
+
const e3 = this.validateRichBlockData(t3);
|
|
2027
|
+
if (!e3) continue;
|
|
2028
|
+
const n3 = V(), s3 = e3.text ?? "", i6 = s3 ? [N(s3)] : void 0, a19 = e3.attrs ? e3.attrs : void 0, c9 = o(Te(e3.type), i6, n3, a19);
|
|
2029
|
+
d5.insertNode(r2, h4, c9), h4++, u2 = n3, p2 = s3.length;
|
|
1909
2030
|
}
|
|
1910
|
-
return l2 && c8 >= 0 &&
|
|
2031
|
+
return l2 && c8 >= 0 && d5.removeNode(r2, c8), u2 && d5.setSelection(J(u2, p2)), this.dispatch(d5.build()), true;
|
|
1911
2032
|
}
|
|
1912
2033
|
insertRichBlocksAtRoot(e2, t2, n2) {
|
|
1913
|
-
const s2 =
|
|
2034
|
+
const s2 = Ie(t2.doc, n2), r2 = s2 && s2.length > 1 ? s2.slice(0, -1) : [], i5 = (0 === r2.length ? t2.doc.children : (() => {
|
|
1914
2035
|
const e3 = t2.getBlock(r2[r2.length - 1]);
|
|
1915
2036
|
return e3 ? e3.children : [];
|
|
1916
2037
|
})()).findIndex((e3) => m(e3) && e3.id === n2);
|
|
1917
2038
|
if (i5 < 0) return false;
|
|
1918
|
-
const a18 = t2.getBlock(n2), c8 = void 0 !== a18 && "paragraph" === a18.type && "" ===
|
|
2039
|
+
const a18 = t2.getBlock(n2), c8 = void 0 !== a18 && "paragraph" === a18.type && "" === _(a18);
|
|
1919
2040
|
let l2 = i5 + 1;
|
|
1920
2041
|
const h4 = t2.transaction("paste");
|
|
1921
|
-
let
|
|
2042
|
+
let d5, u2 = 0;
|
|
1922
2043
|
for (const t3 of e2) {
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2044
|
+
const e3 = this.validateRichBlockData(t3);
|
|
2045
|
+
if (!e3) continue;
|
|
2046
|
+
const n3 = V(), s3 = e3.text ?? "", i6 = s3 ? [N(s3)] : void 0, a19 = e3.attrs ? e3.attrs : void 0, c9 = o(Te(e3.type), i6, n3, a19);
|
|
2047
|
+
h4.insertNode(r2, l2, c9), l2++, d5 = n3, u2 = s3.length;
|
|
1926
2048
|
}
|
|
1927
|
-
return c8 && h4.removeNode(r2, i5),
|
|
2049
|
+
return c8 && h4.removeNode(r2, i5), d5 && h4.setSelection(J(d5, u2)), this.dispatch(h4.build()), true;
|
|
2050
|
+
}
|
|
2051
|
+
validateRichBlockData(e2) {
|
|
2052
|
+
if (!e2.type) return;
|
|
2053
|
+
if (!this.schemaRegistry) return e2;
|
|
2054
|
+
const t2 = this.schemaRegistry.getNodeSpec(e2.type);
|
|
2055
|
+
if (!t2) return;
|
|
2056
|
+
const n2 = rn(e2.attrs, t2.attrs);
|
|
2057
|
+
return { ...e2, attrs: n2 };
|
|
1928
2058
|
}
|
|
1929
2059
|
findTableCellAncestor(e2, t2) {
|
|
1930
2060
|
const n2 = e2.getBlock(t2);
|
|
1931
2061
|
if ("table_cell" === n2?.type) return t2;
|
|
1932
|
-
const s2 =
|
|
2062
|
+
const s2 = Ie(e2.doc, t2);
|
|
1933
2063
|
if (s2) for (const t3 of s2) {
|
|
1934
2064
|
const n3 = e2.getBlock(t3);
|
|
1935
2065
|
if ("table_cell" === n3?.type) return t3;
|
|
@@ -1938,23 +2068,26 @@ class Yt {
|
|
|
1938
2068
|
handleFilePaste(e2) {
|
|
1939
2069
|
if (!this.schemaRegistry) return false;
|
|
1940
2070
|
const t2 = Array.from(e2.files);
|
|
1941
|
-
if (0 === t2.length) for (let
|
|
1942
|
-
const s2 = e2.items[
|
|
2071
|
+
if (0 === t2.length) for (let n3 = 0; n3 < e2.items.length; n3++) {
|
|
2072
|
+
const s2 = e2.items[n3];
|
|
1943
2073
|
if (s2 && "file" === s2.kind) {
|
|
1944
2074
|
const e3 = s2.getAsFile();
|
|
1945
2075
|
e3 && t2.push(e3);
|
|
1946
2076
|
}
|
|
1947
2077
|
}
|
|
1948
2078
|
if (0 === t2.length) return false;
|
|
2079
|
+
let n2 = false;
|
|
1949
2080
|
for (const e3 of t2) {
|
|
1950
|
-
const
|
|
1951
|
-
for (const
|
|
1952
|
-
const
|
|
1953
|
-
if (true ===
|
|
1954
|
-
|
|
2081
|
+
const t3 = this.schemaRegistry.matchFileHandlers(e3.type);
|
|
2082
|
+
for (const s2 of t3) {
|
|
2083
|
+
const t4 = s2(e3, null);
|
|
2084
|
+
if (true === t4 || t4 instanceof Promise) {
|
|
2085
|
+
n2 = true;
|
|
2086
|
+
break;
|
|
2087
|
+
}
|
|
1955
2088
|
}
|
|
1956
2089
|
}
|
|
1957
|
-
return
|
|
2090
|
+
return n2;
|
|
1958
2091
|
}
|
|
1959
2092
|
extractRichData(e2) {
|
|
1960
2093
|
const t2 = document.createElement("template");
|
|
@@ -1970,7 +2103,7 @@ class Yt {
|
|
|
1970
2103
|
this.element.removeEventListener("paste", this.handlePaste);
|
|
1971
2104
|
}
|
|
1972
2105
|
}
|
|
1973
|
-
function
|
|
2106
|
+
function an(e2, t2, n2, s2) {
|
|
1974
2107
|
const r2 = t2?.doc.children ?? [], o2 = n2.doc.children, i5 = s2?.registry, a18 = s2?.nodeViews;
|
|
1975
2108
|
!(function(e3) {
|
|
1976
2109
|
const t3 = Array.from(e3.querySelectorAll(":scope > [data-block-wrapper]"));
|
|
@@ -1992,43 +2125,43 @@ function Zt(e2, t2, n2, s2) {
|
|
|
1992
2125
|
}
|
|
1993
2126
|
const h4 = /* @__PURE__ */ new Map();
|
|
1994
2127
|
for (const e3 of r2) h4.set(e3.id, e3);
|
|
1995
|
-
let
|
|
2128
|
+
let d5 = null;
|
|
1996
2129
|
const u2 = s2?.selectedNodeId, p2 = s2?.previousSelectedNodeId;
|
|
1997
2130
|
for (const t3 of o2) {
|
|
1998
2131
|
const n3 = c8.get(t3.id), r3 = h4.get(t3.id), o3 = s2?.oldDecorations?.find(t3.id), l3 = s2?.decorations?.find(t3.id);
|
|
1999
|
-
if (n3 && r3 && !
|
|
2132
|
+
if (n3 && r3 && !cn(r3, t3, o3, l3)) d5 = n3;
|
|
2000
2133
|
else if (n3) {
|
|
2001
2134
|
const r4 = a18?.get(t3.id);
|
|
2002
2135
|
if (r4) {
|
|
2003
2136
|
if (r4.update?.(t3)) {
|
|
2004
|
-
if (
|
|
2137
|
+
if (W(t3) && r4.contentDOM) {
|
|
2005
2138
|
r4.contentDOM.textContent = "";
|
|
2006
2139
|
const e3 = s2?.decorations?.findInline(t3.id);
|
|
2007
|
-
|
|
2140
|
+
hn(r4.contentDOM, t3, i5, e3);
|
|
2008
2141
|
}
|
|
2009
|
-
|
|
2142
|
+
d5 = r4.dom;
|
|
2010
2143
|
continue;
|
|
2011
2144
|
}
|
|
2012
2145
|
r4.destroy?.(), a18?.delete(t3.id);
|
|
2013
2146
|
}
|
|
2014
|
-
const o4 =
|
|
2015
|
-
e2.replaceChild(o4, n3),
|
|
2147
|
+
const o4 = ln(t3, i5, a18, s2);
|
|
2148
|
+
e2.replaceChild(o4, n3), d5 = o4;
|
|
2016
2149
|
} else {
|
|
2017
|
-
const n4 =
|
|
2018
|
-
|
|
2150
|
+
const n4 = ln(t3, i5, a18, s2);
|
|
2151
|
+
d5?.nextSibling ? e2.insertBefore(n4, d5.nextSibling) : !d5 && e2.firstChild ? e2.insertBefore(n4, e2.firstChild) : e2.appendChild(n4), d5 = n4;
|
|
2019
2152
|
}
|
|
2020
2153
|
if (u2 === t3.id) {
|
|
2021
2154
|
const e3 = a18?.get(t3.id);
|
|
2022
2155
|
if (e3) e3.selectNode?.();
|
|
2023
2156
|
else {
|
|
2024
|
-
const e4 = c8.get(t3.id) ??
|
|
2157
|
+
const e4 = c8.get(t3.id) ?? d5;
|
|
2025
2158
|
e4 instanceof HTMLElement && e4.classList.add("notectl-node-selected");
|
|
2026
2159
|
}
|
|
2027
2160
|
} else if (p2 === t3.id) {
|
|
2028
2161
|
const e3 = a18?.get(t3.id);
|
|
2029
2162
|
if (e3) e3.deselectNode?.();
|
|
2030
2163
|
else {
|
|
2031
|
-
const e4 = c8.get(t3.id) ??
|
|
2164
|
+
const e4 = c8.get(t3.id) ?? d5;
|
|
2032
2165
|
e4 instanceof HTMLElement && e4.classList.remove("notectl-node-selected");
|
|
2033
2166
|
}
|
|
2034
2167
|
}
|
|
@@ -2041,9 +2174,9 @@ function Zt(e2, t2, n2, s2) {
|
|
|
2041
2174
|
const e3 = a18?.get(u2);
|
|
2042
2175
|
e3 && e3.selectNode?.();
|
|
2043
2176
|
}
|
|
2044
|
-
|
|
2177
|
+
bn(e2, o2, i5);
|
|
2045
2178
|
}
|
|
2046
|
-
function
|
|
2179
|
+
function cn(e2, t2, n2, s2) {
|
|
2047
2180
|
if (e2.type !== t2.type) return true;
|
|
2048
2181
|
if (e2.children.length !== t2.children.length) return true;
|
|
2049
2182
|
const r2 = e2.attrs, o2 = t2.attrs;
|
|
@@ -2058,19 +2191,19 @@ function en(e2, t2, n2, s2) {
|
|
|
2058
2191
|
if (!s3 || !r3) return true;
|
|
2059
2192
|
if (M(s3) && M(r3)) {
|
|
2060
2193
|
if (s3.text !== r3.text) return true;
|
|
2061
|
-
if (!
|
|
2194
|
+
if (!q(s3.marks, r3.marks)) return true;
|
|
2062
2195
|
} else if (E(s3) && E(r3)) {
|
|
2063
2196
|
if (s3.inlineType !== r3.inlineType) return true;
|
|
2064
|
-
if (!
|
|
2197
|
+
if (!fn(s3.attrs, r3.attrs)) return true;
|
|
2065
2198
|
} else {
|
|
2066
2199
|
if (M(s3) || M(r3) || E(s3) || E(r3)) return true;
|
|
2067
|
-
if (
|
|
2200
|
+
if (cn(s3, r3)) return true;
|
|
2068
2201
|
}
|
|
2069
2202
|
}
|
|
2070
2203
|
const i5 = n2 ?? [], a18 = s2 ?? [];
|
|
2071
2204
|
return i5 !== a18 && !He(i5, a18);
|
|
2072
2205
|
}
|
|
2073
|
-
function
|
|
2206
|
+
function ln(e2, t2, n2, s2) {
|
|
2074
2207
|
const r2 = s2?.decorations?.findInline(e2.id);
|
|
2075
2208
|
if (t2 && n2 && s2?.getState && s2?.dispatch) {
|
|
2076
2209
|
const o2 = t2.getNodeViewFactory(e2.type);
|
|
@@ -2078,52 +2211,52 @@ function tn(e2, t2, n2, s2) {
|
|
|
2078
2211
|
const i5 = o2(e2, s2.getState, s2.dispatch);
|
|
2079
2212
|
n2.set(e2.id, i5);
|
|
2080
2213
|
const a18 = t2.getNodeSpec(e2.type);
|
|
2081
|
-
if (a18?.isVoid && i5.dom.setAttribute("data-void", "true"), a18?.selectable && i5.dom.setAttribute("data-selectable", "true"), i5.contentDOM && i5.contentDOM !== i5.dom && i5.contentDOM.setAttribute("data-content-dom", "true"),
|
|
2214
|
+
if (a18?.isVoid && i5.dom.setAttribute("data-void", "true"), a18?.selectable && i5.dom.setAttribute("data-selectable", "true"), i5.contentDOM && i5.contentDOM !== i5.dom && i5.contentDOM.setAttribute("data-content-dom", "true"), W(e2) && i5.contentDOM) hn(i5.contentDOM, e2, t2, r2);
|
|
2082
2215
|
else {
|
|
2083
2216
|
const r3 = G(e2), o3 = /* @__PURE__ */ new Map();
|
|
2084
2217
|
for (const e3 of r3) {
|
|
2085
2218
|
const r4 = i5.getContentDOM?.(e3.id) ?? i5.contentDOM;
|
|
2086
2219
|
if (r4) {
|
|
2087
|
-
const i6 =
|
|
2220
|
+
const i6 = ln(e3, t2, n2, s2);
|
|
2088
2221
|
r4.appendChild(i6);
|
|
2089
2222
|
let a19 = o3.get(r4);
|
|
2090
2223
|
a19 || (a19 = [], o3.set(r4, a19)), a19.push(e3);
|
|
2091
2224
|
}
|
|
2092
2225
|
}
|
|
2093
|
-
for (const [e3, n3] of o3)
|
|
2226
|
+
for (const [e3, n3] of o3) bn(e3, n3, t2);
|
|
2094
2227
|
}
|
|
2095
|
-
return i5.dom.setAttribute("data-block-type", e2.type),
|
|
2228
|
+
return i5.dom.setAttribute("data-block-type", e2.type), kn(i5.dom, e2.id, s2), i5.dom;
|
|
2096
2229
|
}
|
|
2097
2230
|
}
|
|
2098
2231
|
if (t2) {
|
|
2099
2232
|
const o2 = t2.getNodeSpec(e2.type);
|
|
2100
2233
|
if (o2) {
|
|
2101
2234
|
const i5 = o2.toDOM(e2);
|
|
2102
|
-
if (o2.isVoid && i5.setAttribute("data-void", "true"), o2.selectable && i5.setAttribute("data-selectable", "true"), !o2.isVoid) if (
|
|
2235
|
+
if (o2.isVoid && i5.setAttribute("data-void", "true"), o2.selectable && i5.setAttribute("data-selectable", "true"), !o2.isVoid) if (W(e2)) hn(i5, e2, t2, r2);
|
|
2103
2236
|
else {
|
|
2104
2237
|
const r3 = G(e2);
|
|
2105
2238
|
for (const e3 of r3) {
|
|
2106
|
-
const r4 =
|
|
2239
|
+
const r4 = ln(e3, t2, n2, s2);
|
|
2107
2240
|
i5.appendChild(r4);
|
|
2108
2241
|
}
|
|
2109
|
-
|
|
2242
|
+
bn(i5, r3, t2);
|
|
2110
2243
|
}
|
|
2111
|
-
return i5.setAttribute("data-block-type", e2.type),
|
|
2244
|
+
return i5.setAttribute("data-block-type", e2.type), kn(i5, e2.id, s2), i5;
|
|
2112
2245
|
}
|
|
2113
2246
|
}
|
|
2114
2247
|
return (function(e3, t3, n3) {
|
|
2115
|
-
const s3 =
|
|
2116
|
-
return s3.setAttribute("data-block-type", e3.type),
|
|
2248
|
+
const s3 = Ne("p", e3.id);
|
|
2249
|
+
return s3.setAttribute("data-block-type", e3.type), hn(s3, e3, t3, n3), s3;
|
|
2117
2250
|
})(e2, t2, r2);
|
|
2118
2251
|
}
|
|
2119
|
-
function
|
|
2252
|
+
function hn(e2, n2, s2, r2) {
|
|
2120
2253
|
const o2 = t(n2);
|
|
2121
2254
|
if (1 === o2.length && M(o2[0]) && "" === o2[0].text) return void e2.appendChild(document.createElement("br"));
|
|
2122
2255
|
if (r2 && 0 !== r2.length) !(function(e3, t2, n3, s3) {
|
|
2123
2256
|
let r3 = 0;
|
|
2124
2257
|
for (const o3 of t2) {
|
|
2125
2258
|
if (E(o3)) {
|
|
2126
|
-
e3.appendChild(
|
|
2259
|
+
e3.appendChild(pn(o3, s3)), r3 += 1;
|
|
2127
2260
|
continue;
|
|
2128
2261
|
}
|
|
2129
2262
|
const t3 = r3, i6 = r3 + o3.text.length;
|
|
@@ -2141,20 +2274,20 @@ function nn(e2, n2, s2, r2) {
|
|
|
2141
2274
|
for (let r4 = 0; r4 < c8.length - 1; r4++) {
|
|
2142
2275
|
const i7 = c8[r4], a19 = c8[r4 + 1];
|
|
2143
2276
|
if (void 0 === i7 || void 0 === a19 || i7 >= a19) continue;
|
|
2144
|
-
const l2 = i7 - t3, h4 = a19 - t3,
|
|
2277
|
+
const l2 = i7 - t3, h4 = a19 - t3, d5 = o3.text.slice(l2, h4), u2 = [];
|
|
2145
2278
|
for (const e4 of n3) e4.from <= i7 && e4.to >= a19 && u2.push(e4);
|
|
2146
|
-
let p2 = document.createTextNode(
|
|
2279
|
+
let p2 = document.createTextNode(dn(d5));
|
|
2147
2280
|
if (o3.marks.length > 0) {
|
|
2148
|
-
const e4 = [...o3.marks].sort((e5, t4) =>
|
|
2281
|
+
const e4 = [...o3.marks].sort((e5, t4) => gn(e5, s3) - gn(t4, s3));
|
|
2149
2282
|
for (let t4 = e4.length - 1; t4 >= 0; t4--) {
|
|
2150
2283
|
const n4 = e4[t4];
|
|
2151
2284
|
if (!n4) continue;
|
|
2152
|
-
const r5 =
|
|
2285
|
+
const r5 = mn(n4, s3);
|
|
2153
2286
|
r5.appendChild(p2), p2 = r5;
|
|
2154
2287
|
}
|
|
2155
2288
|
}
|
|
2156
2289
|
for (const e4 of u2) {
|
|
2157
|
-
const t4 =
|
|
2290
|
+
const t4 = yn(e4.attrs);
|
|
2158
2291
|
t4.appendChild(p2), p2 = t4;
|
|
2159
2292
|
}
|
|
2160
2293
|
e3.appendChild(p2);
|
|
@@ -2162,29 +2295,29 @@ function nn(e2, n2, s2, r2) {
|
|
|
2162
2295
|
r3 = i6;
|
|
2163
2296
|
}
|
|
2164
2297
|
})(e2, o2, r2, s2);
|
|
2165
|
-
else for (const t2 of o2) M(t2) ? e2.appendChild(
|
|
2298
|
+
else for (const t2 of o2) M(t2) ? e2.appendChild(un(t2, s2)) : e2.appendChild(pn(t2, s2));
|
|
2166
2299
|
const i5 = o2[o2.length - 1];
|
|
2167
2300
|
i5 && E(i5) && "hard_break" === i5.inlineType && e2.appendChild(document.createElement("br"));
|
|
2168
2301
|
}
|
|
2169
|
-
function
|
|
2302
|
+
function dn(e2) {
|
|
2170
2303
|
let t2 = e2.replace(/ {2}/g, " ");
|
|
2171
2304
|
return t2.endsWith(" ") && (t2 = `${t2.slice(0, -1)} `), t2.startsWith(" ") && (t2 = ` ${t2.slice(1)}`), t2;
|
|
2172
2305
|
}
|
|
2173
|
-
function
|
|
2306
|
+
function un(e2, t2) {
|
|
2174
2307
|
if ("" === e2.text) return document.createTextNode("");
|
|
2175
|
-
const n2 = document.createTextNode(
|
|
2308
|
+
const n2 = document.createTextNode(dn(e2.text));
|
|
2176
2309
|
if (0 === e2.marks.length) return n2;
|
|
2177
|
-
const s2 = [...e2.marks].sort((e3, n3) =>
|
|
2310
|
+
const s2 = [...e2.marks].sort((e3, n3) => gn(e3, t2) - gn(n3, t2));
|
|
2178
2311
|
let r2 = n2;
|
|
2179
2312
|
for (let e3 = s2.length - 1; e3 >= 0; e3--) {
|
|
2180
2313
|
const n3 = s2[e3];
|
|
2181
2314
|
if (!n3) continue;
|
|
2182
|
-
const o2 =
|
|
2315
|
+
const o2 = mn(n3, t2);
|
|
2183
2316
|
o2.appendChild(r2), r2 = o2;
|
|
2184
2317
|
}
|
|
2185
2318
|
return r2;
|
|
2186
2319
|
}
|
|
2187
|
-
function
|
|
2320
|
+
function pn(e2, t2) {
|
|
2188
2321
|
if (t2) {
|
|
2189
2322
|
const n3 = t2.getInlineNodeSpec(e2.inlineType);
|
|
2190
2323
|
if (n3) {
|
|
@@ -2195,13 +2328,13 @@ function on(e2, t2) {
|
|
|
2195
2328
|
const n2 = document.createElement("span");
|
|
2196
2329
|
return n2.setAttribute("data-inline-type", e2.inlineType), n2.setAttribute("contenteditable", "false"), n2;
|
|
2197
2330
|
}
|
|
2198
|
-
function
|
|
2331
|
+
function fn(e2, t2) {
|
|
2199
2332
|
const n2 = Object.keys(e2), s2 = Object.keys(t2);
|
|
2200
2333
|
if (n2.length !== s2.length) return false;
|
|
2201
2334
|
for (const s3 of n2) if (e2[s3] !== t2[s3]) return false;
|
|
2202
2335
|
return true;
|
|
2203
2336
|
}
|
|
2204
|
-
function
|
|
2337
|
+
function gn(e2, t2) {
|
|
2205
2338
|
if (t2) {
|
|
2206
2339
|
const n2 = t2.getMarkSpec(e2.type);
|
|
2207
2340
|
if (n2) return n2.rank ?? 100;
|
|
@@ -2217,7 +2350,7 @@ function cn(e2, t2) {
|
|
|
2217
2350
|
return 100;
|
|
2218
2351
|
}
|
|
2219
2352
|
}
|
|
2220
|
-
function
|
|
2353
|
+
function mn(e2, t2) {
|
|
2221
2354
|
if (t2) {
|
|
2222
2355
|
const n2 = t2.getMarkSpec(e2.type);
|
|
2223
2356
|
if (n2) return n2.toDOM(e2);
|
|
@@ -2233,14 +2366,14 @@ function ln(e2, t2) {
|
|
|
2233
2366
|
return document.createElement("span");
|
|
2234
2367
|
}
|
|
2235
2368
|
}
|
|
2236
|
-
function
|
|
2369
|
+
function yn(e2) {
|
|
2237
2370
|
const t2 = e2.nodeName ?? "span", n2 = document.createElement(t2);
|
|
2238
2371
|
if (n2.setAttribute("data-decoration", "true"), e2.class) for (const t3 of e2.class.split(" ")) t3 && n2.classList.add(t3);
|
|
2239
2372
|
e2.style && (n2.style.cssText = e2.style);
|
|
2240
2373
|
for (const [t3, s2] of Object.entries(e2)) "class" !== t3 && "style" !== t3 && "nodeName" !== t3 && void 0 !== s2 && n2.setAttribute(t3, s2);
|
|
2241
2374
|
return n2;
|
|
2242
2375
|
}
|
|
2243
|
-
function
|
|
2376
|
+
function kn(e2, t2, n2) {
|
|
2244
2377
|
const s2 = n2?.decorations?.findNode(t2);
|
|
2245
2378
|
if (s2 && 0 !== s2.length) for (const t3 of s2) {
|
|
2246
2379
|
if (t3.attrs.class) for (const n3 of t3.attrs.class.split(" ")) n3 && e2.classList.add(n3);
|
|
@@ -2250,7 +2383,7 @@ function dn(e2, t2, n2) {
|
|
|
2250
2383
|
}
|
|
2251
2384
|
}
|
|
2252
2385
|
}
|
|
2253
|
-
function
|
|
2386
|
+
function bn(e2, t2, n2) {
|
|
2254
2387
|
if (!n2) return;
|
|
2255
2388
|
const s2 = [];
|
|
2256
2389
|
let r2 = null, o2 = [];
|
|
@@ -2271,32 +2404,32 @@ function un(e2, t2, n2) {
|
|
|
2271
2404
|
}
|
|
2272
2405
|
}
|
|
2273
2406
|
}
|
|
2274
|
-
function
|
|
2407
|
+
function Sn(e2) {
|
|
2275
2408
|
const t2 = e2.getRootNode();
|
|
2276
2409
|
return t2 instanceof ShadowRoot && "getSelection" in t2 ? t2.getSelection() : window.getSelection();
|
|
2277
2410
|
}
|
|
2278
|
-
function
|
|
2279
|
-
const n2 =
|
|
2411
|
+
function vn(e2, t2) {
|
|
2412
|
+
const n2 = Sn(e2);
|
|
2280
2413
|
if (!n2) return;
|
|
2281
2414
|
if (Q(t2)) {
|
|
2282
2415
|
const s3 = e2.querySelector(`[data-block-id="${t2.nodeId}"]`);
|
|
2283
2416
|
if (!s3) return;
|
|
2284
2417
|
const r3 = s3.parentNode;
|
|
2285
2418
|
if (!r3) return;
|
|
2286
|
-
const o2 =
|
|
2419
|
+
const o2 = xn(r3, s3);
|
|
2287
2420
|
try {
|
|
2288
2421
|
n2.setBaseAndExtent(r3, o2, r3, o2 + 1);
|
|
2289
2422
|
} catch {
|
|
2290
2423
|
}
|
|
2291
2424
|
return;
|
|
2292
2425
|
}
|
|
2293
|
-
const s2 =
|
|
2426
|
+
const s2 = wn(e2, t2.anchor), r2 = wn(e2, t2.head);
|
|
2294
2427
|
if (s2 && r2) try {
|
|
2295
2428
|
n2.setBaseAndExtent(s2.node, s2.offset, r2.node, r2.offset);
|
|
2296
2429
|
} catch {
|
|
2297
2430
|
}
|
|
2298
2431
|
}
|
|
2299
|
-
function
|
|
2432
|
+
function wn(e2, t2) {
|
|
2300
2433
|
let n2 = null;
|
|
2301
2434
|
if (t2.path && t2.path.length > 0) {
|
|
2302
2435
|
let s3 = e2;
|
|
@@ -2308,10 +2441,10 @@ function gn(e2, t2) {
|
|
|
2308
2441
|
s3 !== e2 && s3.getAttribute("data-block-id") === t2.blockId && (n2 = s3);
|
|
2309
2442
|
}
|
|
2310
2443
|
if (n2 ??= e2.querySelector(`[data-block-id="${t2.blockId}"]`), !n2) return null;
|
|
2311
|
-
const s2 =
|
|
2444
|
+
const s2 = Cn(n2);
|
|
2312
2445
|
if (1 === s2.childNodes.length && "BR" === s2.firstChild?.nodeName) return { node: s2, offset: 0 };
|
|
2313
2446
|
let r2 = t2.offset;
|
|
2314
|
-
const o2 =
|
|
2447
|
+
const o2 = Tn(s2);
|
|
2315
2448
|
let i5 = o2.nextNode();
|
|
2316
2449
|
for (; i5; ) {
|
|
2317
2450
|
if (i5.nodeType === Node.TEXT_NODE) {
|
|
@@ -2321,7 +2454,7 @@ function gn(e2, t2) {
|
|
|
2321
2454
|
} else if (i5 instanceof HTMLElement && "false" === i5.getAttribute("contenteditable")) {
|
|
2322
2455
|
if (0 === r2) {
|
|
2323
2456
|
const e3 = i5.parentNode;
|
|
2324
|
-
if (e3) return { node: e3, offset:
|
|
2457
|
+
if (e3) return { node: e3, offset: xn(e3, i5) };
|
|
2325
2458
|
}
|
|
2326
2459
|
r2 -= 1;
|
|
2327
2460
|
}
|
|
@@ -2330,7 +2463,7 @@ function gn(e2, t2) {
|
|
|
2330
2463
|
const a18 = s2.lastChild;
|
|
2331
2464
|
return a18 ? a18.nodeType === Node.TEXT_NODE ? { node: a18, offset: a18.textContent?.length ?? 0 } : { node: s2, offset: s2.childNodes.length } : { node: s2, offset: 0 };
|
|
2332
2465
|
}
|
|
2333
|
-
function
|
|
2466
|
+
function En(e2, t2, n2) {
|
|
2334
2467
|
const s2 = (function(e3, t3) {
|
|
2335
2468
|
let n3 = t3;
|
|
2336
2469
|
for (; n3 && n3 !== e3; ) {
|
|
@@ -2347,19 +2480,19 @@ function mn(e2, t2, n2) {
|
|
|
2347
2480
|
let s3 = t3;
|
|
2348
2481
|
for (; s3 && s3 !== e3; ) s3.hasAttribute("data-block-id") && n3.unshift(Ee(s3.getAttribute("data-block-id") ?? "")), s3 = s3.parentElement;
|
|
2349
2482
|
return n3;
|
|
2350
|
-
})(e2, s2), a18 =
|
|
2483
|
+
})(e2, s2), a18 = Cn(s2);
|
|
2351
2484
|
if (t2 === s2 || t2 === a18) {
|
|
2352
2485
|
const e3 = t2 === a18 ? a18 : s2;
|
|
2353
2486
|
let r3 = 0, c9 = 0;
|
|
2354
2487
|
for (const t3 of Array.from(e3.childNodes)) {
|
|
2355
2488
|
if (c9 >= n2) break;
|
|
2356
|
-
r3 +=
|
|
2489
|
+
r3 += Nn(t3), c9++;
|
|
2357
2490
|
}
|
|
2358
2491
|
return Z(o2, r3, i5.length > 1 ? i5 : void 0);
|
|
2359
2492
|
}
|
|
2360
2493
|
if (a18 !== s2 && !a18.contains(t2)) return Z(o2, 0, i5.length > 1 ? i5 : void 0);
|
|
2361
2494
|
let c8 = 0;
|
|
2362
|
-
const l2 =
|
|
2495
|
+
const l2 = Tn(a18);
|
|
2363
2496
|
let h4 = l2.nextNode();
|
|
2364
2497
|
for (; h4; ) {
|
|
2365
2498
|
if (h4 === t2) return h4.nodeType === Node.TEXT_NODE ? Z(o2, c8 + n2, i5.length > 1 ? i5 : void 0) : Z(o2, c8, i5.length > 1 ? i5 : void 0);
|
|
@@ -2369,13 +2502,13 @@ function mn(e2, t2, n2) {
|
|
|
2369
2502
|
let e3 = 0, s3 = 0;
|
|
2370
2503
|
for (const r3 of Array.from(t2.childNodes)) {
|
|
2371
2504
|
if (s3 >= n2) break;
|
|
2372
|
-
e3 +=
|
|
2505
|
+
e3 += Nn(r3), s3++;
|
|
2373
2506
|
}
|
|
2374
2507
|
return Z(o2, e3, i5.length > 1 ? i5 : void 0);
|
|
2375
2508
|
}
|
|
2376
2509
|
return Z(o2, 0, i5.length > 1 ? i5 : void 0);
|
|
2377
2510
|
}
|
|
2378
|
-
function
|
|
2511
|
+
function Tn(e2) {
|
|
2379
2512
|
return document.createTreeWalker(e2, NodeFilter.SHOW_ALL, { acceptNode: (t2) => (function(e3, t3) {
|
|
2380
2513
|
let n2 = e3.parentNode;
|
|
2381
2514
|
for (; n2 && n2 !== t3; ) {
|
|
@@ -2385,7 +2518,7 @@ function yn(e2) {
|
|
|
2385
2518
|
return false;
|
|
2386
2519
|
})(t2, e2) || t2 instanceof HTMLElement && t2.hasAttribute("data-block-id") && t2 !== e2 ? NodeFilter.FILTER_REJECT : t2.nodeType === Node.TEXT_NODE || t2 instanceof HTMLElement && "false" === t2.getAttribute("contenteditable") ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP });
|
|
2387
2520
|
}
|
|
2388
|
-
function
|
|
2521
|
+
function xn(e2, t2) {
|
|
2389
2522
|
let n2 = 0;
|
|
2390
2523
|
for (const s2 of Array.from(e2.childNodes)) {
|
|
2391
2524
|
if (s2 === t2) return n2;
|
|
@@ -2393,17 +2526,17 @@ function kn(e2, t2) {
|
|
|
2393
2526
|
}
|
|
2394
2527
|
return n2;
|
|
2395
2528
|
}
|
|
2396
|
-
function
|
|
2529
|
+
function Cn(e2) {
|
|
2397
2530
|
return e2.querySelector("[data-content-dom]") ?? e2;
|
|
2398
2531
|
}
|
|
2399
|
-
function
|
|
2532
|
+
function Nn(e2) {
|
|
2400
2533
|
if (e2.nodeType === Node.TEXT_NODE) return e2.textContent?.length ?? 0;
|
|
2401
2534
|
if (e2 instanceof HTMLElement && "false" === e2.getAttribute("contenteditable")) return 1;
|
|
2402
2535
|
let t2 = 0;
|
|
2403
|
-
for (const n2 of Array.from(e2.childNodes)) t2 +=
|
|
2536
|
+
for (const n2 of Array.from(e2.childNodes)) t2 += Nn(n2);
|
|
2404
2537
|
return t2;
|
|
2405
2538
|
}
|
|
2406
|
-
class
|
|
2539
|
+
class An {
|
|
2407
2540
|
state;
|
|
2408
2541
|
contentElement;
|
|
2409
2542
|
inputHandler;
|
|
@@ -2422,8 +2555,9 @@ class vn {
|
|
|
2422
2555
|
nodeViews = /* @__PURE__ */ new Map();
|
|
2423
2556
|
decorations = De.empty;
|
|
2424
2557
|
getDecorations;
|
|
2558
|
+
isReadOnly;
|
|
2425
2559
|
constructor(e2, t2) {
|
|
2426
|
-
this.state = t2.state, this.contentElement = e2, this.schemaRegistry = t2.schemaRegistry, this.getDecorations = t2.getDecorations, this.history = new
|
|
2560
|
+
this.state = t2.state, this.contentElement = e2, this.schemaRegistry = t2.schemaRegistry, this.getDecorations = t2.getDecorations, this.isReadOnly = t2.isReadOnly ?? (() => false), this.history = new dt({ maxDepth: t2.maxHistoryDepth ?? 100 }), t2.onStateChange && this.stateChangeCallbacks.push(t2.onStateChange), this.inputHandler = new Gt(e2, { getState: () => this.state, dispatch: (e3) => this.dispatch(e3), syncSelection: () => this.syncSelectionFromDOM(), schemaRegistry: this.schemaRegistry, isReadOnly: this.isReadOnly }), this.keyboardHandler = new ut(e2, { getState: () => this.state, dispatch: (e3) => this.dispatch(e3), undo: () => this.undo(), redo: () => this.redo(), schemaRegistry: this.schemaRegistry, isReadOnly: this.isReadOnly }), this.pasteHandler = new on(e2, { getState: () => this.state, dispatch: (e3) => this.dispatch(e3), schemaRegistry: this.schemaRegistry, isReadOnly: this.isReadOnly }), this.clipboardHandler = new gt(e2, { getState: () => this.state, dispatch: (e3) => this.dispatch(e3), schemaRegistry: this.schemaRegistry, syncSelection: () => this.syncSelectionFromDOM(), isReadOnly: this.isReadOnly }), this.handleSelectionChange = this.onSelectionChange.bind(this), document.addEventListener("selectionchange", this.handleSelectionChange), this.handleMousedown = this.onMousedown.bind(this), e2.addEventListener("mousedown", this.handleMousedown), this.handleDragover = this.onDragover.bind(this), e2.addEventListener("dragover", this.handleDragover), this.handleDrop = this.onDrop.bind(this), e2.addEventListener("drop", this.handleDrop), this.decorations = this.getDecorations?.(this.state) ?? De.empty, an(e2, null, this.state, { ...this.reconcileOptions(), decorations: this.decorations }), vn(e2, this.state.selection);
|
|
2427
2561
|
}
|
|
2428
2562
|
getState() {
|
|
2429
2563
|
return this.state;
|
|
@@ -2435,7 +2569,7 @@ class vn {
|
|
|
2435
2569
|
const s2 = this.state;
|
|
2436
2570
|
this.state = e2, n2?.pushHistory && "history" !== t2.metadata.origin && this.history.push(t2);
|
|
2437
2571
|
const r2 = this.decorations, o2 = this.getDecorations?.(e2, t2) ?? De.empty;
|
|
2438
|
-
this.decorations = o2,
|
|
2572
|
+
this.decorations = o2, an(this.contentElement, s2, e2, { ...this.reconcileOptions(s2.selection), decorations: o2, oldDecorations: r2 }), vn(this.contentElement, e2.selection);
|
|
2439
2573
|
for (const n3 of this.stateChangeCallbacks) n3(s2, e2, t2);
|
|
2440
2574
|
} finally {
|
|
2441
2575
|
this.isUpdating = false;
|
|
@@ -2447,12 +2581,12 @@ class vn {
|
|
|
2447
2581
|
this.applyUpdate(t2, e2, { pushHistory: true });
|
|
2448
2582
|
}
|
|
2449
2583
|
undo() {
|
|
2450
|
-
if (this.isUpdating) return;
|
|
2584
|
+
if (this.isUpdating || this.isReadOnly()) return;
|
|
2451
2585
|
const e2 = this.history.undo(this.state);
|
|
2452
2586
|
e2 && this.applyUpdate(e2.state, e2.transaction);
|
|
2453
2587
|
}
|
|
2454
2588
|
redo() {
|
|
2455
|
-
if (this.isUpdating) return;
|
|
2589
|
+
if (this.isUpdating || this.isReadOnly()) return;
|
|
2456
2590
|
const e2 = this.history.redo(this.state);
|
|
2457
2591
|
e2 && this.applyUpdate(e2.state, e2.transaction);
|
|
2458
2592
|
}
|
|
@@ -2469,7 +2603,7 @@ class vn {
|
|
|
2469
2603
|
const t2 = this.state;
|
|
2470
2604
|
this.state = e2, this.history.clear();
|
|
2471
2605
|
const n2 = this.decorations, s2 = this.getDecorations?.(e2) ?? De.empty;
|
|
2472
|
-
this.decorations = s2,
|
|
2606
|
+
this.decorations = s2, an(this.contentElement, t2, e2, { ...this.reconcileOptions(t2.selection), decorations: s2, oldDecorations: n2 }), vn(this.contentElement, e2.selection);
|
|
2473
2607
|
} finally {
|
|
2474
2608
|
this.isUpdating = false;
|
|
2475
2609
|
}
|
|
@@ -2479,12 +2613,12 @@ class vn {
|
|
|
2479
2613
|
if (Q(this.state.selection) && !this.pendingNodeSelectionClear) return;
|
|
2480
2614
|
this.pendingNodeSelectionClear = false;
|
|
2481
2615
|
const e2 = (function(e3) {
|
|
2482
|
-
const t3 =
|
|
2616
|
+
const t3 = Sn(e3);
|
|
2483
2617
|
if (!t3 || 0 === t3.rangeCount) return null;
|
|
2484
2618
|
const n3 = t3.anchorNode, s2 = t3.focusNode;
|
|
2485
2619
|
if (!n3 || !s2) return null;
|
|
2486
2620
|
if (!e3.contains(n3) || !e3.contains(s2)) return null;
|
|
2487
|
-
const r2 =
|
|
2621
|
+
const r2 = En(e3, n3, t3.anchorOffset), o2 = En(e3, s2, t3.focusOffset);
|
|
2488
2622
|
return r2 && o2 ? Y(r2, o2) : null;
|
|
2489
2623
|
})(this.contentElement);
|
|
2490
2624
|
if (!e2) return;
|
|
@@ -2506,7 +2640,7 @@ class vn {
|
|
|
2506
2640
|
this.applyUpdate(c8, a18);
|
|
2507
2641
|
}
|
|
2508
2642
|
handleClickBelowContent(e2) {
|
|
2509
|
-
if (
|
|
2643
|
+
if (this.isReadOnly()) return;
|
|
2510
2644
|
const t2 = this.state.getBlockOrder(), n2 = t2[t2.length - 1];
|
|
2511
2645
|
if (!n2) return;
|
|
2512
2646
|
const s2 = this.contentElement.querySelector(`[data-block-id="${n2}"]`);
|
|
@@ -2519,7 +2653,7 @@ class vn {
|
|
|
2519
2653
|
return this.dispatch(t3), void e2.preventDefault();
|
|
2520
2654
|
}
|
|
2521
2655
|
e2.preventDefault(), this.contentElement.focus();
|
|
2522
|
-
const a18 =
|
|
2656
|
+
const a18 = V(), c8 = i5 ? r(i5) : 0, l2 = this.state.transaction("input").splitBlock(n2, c8, a18).setBlockType(a18, Te("paragraph")).setSelection(J(a18, 0)).build();
|
|
2523
2657
|
this.dispatch(l2);
|
|
2524
2658
|
}
|
|
2525
2659
|
buildBlockPath(e2) {
|
|
@@ -2532,19 +2666,24 @@ class vn {
|
|
|
2532
2666
|
this.schemaRegistry && e2.dataTransfer && e2.dataTransfer.types.includes("Files") && e2.preventDefault();
|
|
2533
2667
|
}
|
|
2534
2668
|
onDrop(e2) {
|
|
2669
|
+
if (this.isReadOnly()) return;
|
|
2535
2670
|
if (!this.schemaRegistry) return;
|
|
2536
2671
|
if (!e2.dataTransfer) return;
|
|
2537
2672
|
const t2 = Array.from(e2.dataTransfer.files);
|
|
2538
2673
|
if (0 === t2.length) return;
|
|
2539
2674
|
const n2 = this.getPositionFromPoint(e2.clientX, e2.clientY);
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
if (
|
|
2675
|
+
let s2 = false;
|
|
2676
|
+
for (const e3 of t2) {
|
|
2677
|
+
const t3 = this.schemaRegistry.matchFileHandlers(e3.type);
|
|
2678
|
+
for (const r2 of t3) {
|
|
2679
|
+
const t4 = r2(e3, n2);
|
|
2680
|
+
if (true === t4 || t4 instanceof Promise) {
|
|
2681
|
+
s2 = true;
|
|
2682
|
+
break;
|
|
2683
|
+
}
|
|
2546
2684
|
}
|
|
2547
2685
|
}
|
|
2686
|
+
s2 && e2.preventDefault();
|
|
2548
2687
|
}
|
|
2549
2688
|
getPositionFromPoint(e2, t2) {
|
|
2550
2689
|
const n2 = this.contentElement.getRootNode();
|
|
@@ -2557,7 +2696,7 @@ class vn {
|
|
|
2557
2696
|
const o2 = n2.caretRangeFromPoint(e2, t2);
|
|
2558
2697
|
o2 && (s2 = o2.startContainer, r2 = o2.startOffset);
|
|
2559
2698
|
}
|
|
2560
|
-
return s2 && this.contentElement.contains(s2) ?
|
|
2699
|
+
return s2 && this.contentElement.contains(s2) ? En(this.contentElement, s2, r2) : null;
|
|
2561
2700
|
}
|
|
2562
2701
|
onSelectionChange() {
|
|
2563
2702
|
if (this.isUpdating) return;
|
|
@@ -2574,15 +2713,15 @@ class vn {
|
|
|
2574
2713
|
this.nodeViews.clear();
|
|
2575
2714
|
}
|
|
2576
2715
|
}
|
|
2577
|
-
const
|
|
2578
|
-
function
|
|
2579
|
-
return "heading" === e2 && t2?.level ? `Heading ${t2.level}` :
|
|
2716
|
+
const Ln = { paragraph: "Paragraph", heading: "Heading", code_block: "Code Block", blockquote: "Block Quote", list_item: "List Item", horizontal_rule: "Horizontal Rule", image: "Image", table: "Table" };
|
|
2717
|
+
function Mn(e2, t2) {
|
|
2718
|
+
return "heading" === e2 && t2?.level ? `Heading ${t2.level}` : Ln[e2] ?? e2;
|
|
2580
2719
|
}
|
|
2581
|
-
function
|
|
2720
|
+
function In(e2, t2) {
|
|
2582
2721
|
const n2 = [];
|
|
2583
|
-
return
|
|
2722
|
+
return Rn(e2, [], n2, t2?.getMarkParseRules() ?? []), n2.length > 0 ? n2 : [N("")];
|
|
2584
2723
|
}
|
|
2585
|
-
function
|
|
2724
|
+
function Rn(e2, t2, n2, s2) {
|
|
2586
2725
|
if (e2.nodeType === Node.TEXT_NODE) {
|
|
2587
2726
|
const s3 = e2.textContent ?? "";
|
|
2588
2727
|
return void (s3 && n2.push(N(s3, [...t2])));
|
|
@@ -2594,9 +2733,9 @@ function xn(e2, t2, n2, s2) {
|
|
|
2594
2733
|
if (false === t3) continue;
|
|
2595
2734
|
i5.some((t4) => t4.type === e3.type) || (i5.push({ type: xe(e3.type), ...Object.keys(t3).length > 0 ? { attrs: t3 } : {} }), a18.add(e3.type));
|
|
2596
2735
|
} else i5.some((t3) => t3.type === e3.type) || (i5.push({ type: xe(e3.type) }), a18.add(e3.type));
|
|
2597
|
-
for (const e3 of Array.from(r2.childNodes))
|
|
2736
|
+
for (const e3 of Array.from(r2.childNodes)) Rn(e3, i5, n2, s2);
|
|
2598
2737
|
}
|
|
2599
|
-
function
|
|
2738
|
+
function On(e2, t2) {
|
|
2600
2739
|
const n2 = e2.tagName.toLowerCase();
|
|
2601
2740
|
for (const s2 of t2) if (s2.rule.tag === n2) {
|
|
2602
2741
|
if (s2.rule.getAttrs) {
|
|
@@ -2608,23 +2747,24 @@ function Nn(e2, t2) {
|
|
|
2608
2747
|
}
|
|
2609
2748
|
return null;
|
|
2610
2749
|
}
|
|
2611
|
-
|
|
2750
|
+
const Bn = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]);
|
|
2751
|
+
function Pn(e2, n2) {
|
|
2612
2752
|
const s2 = (function(e3, n3) {
|
|
2613
2753
|
const s3 = t(e3), r3 = [];
|
|
2614
2754
|
for (const e4 of s3) if (E(e4)) {
|
|
2615
2755
|
const t2 = n3?.getInlineNodeSpec(e4.inlineType);
|
|
2616
2756
|
t2?.toHTMLString && r3.push(t2.toHTMLString(e4));
|
|
2617
|
-
} else r3.push(
|
|
2757
|
+
} else r3.push(_n(e4, n3));
|
|
2618
2758
|
return r3.join("");
|
|
2619
2759
|
})(e2, n2), r2 = n2?.getNodeSpec(e2.type);
|
|
2620
2760
|
let o2;
|
|
2621
2761
|
o2 = r2?.toHTML ? r2.toHTML(e2, s2) : `<p>${s2 || "<br>"}</p>`;
|
|
2622
2762
|
const i5 = e2.attrs?.align;
|
|
2623
|
-
return i5 && "left" !== i5 && (o2 = o2.replace(/>/, ` style="text-align: ${i5}">`)), o2;
|
|
2763
|
+
return i5 && "left" !== i5 && Bn.has(i5) && (o2 = o2.replace(/>/, ` style="text-align: ${i5}">`)), o2;
|
|
2624
2764
|
}
|
|
2625
|
-
function
|
|
2765
|
+
function _n(e2, t2) {
|
|
2626
2766
|
if ("" === e2.text) return "";
|
|
2627
|
-
let n2 =
|
|
2767
|
+
let n2 = Ae(e2.text);
|
|
2628
2768
|
const s2 = (function(e3) {
|
|
2629
2769
|
if (!e3) return /* @__PURE__ */ new Map();
|
|
2630
2770
|
const t3 = e3.getMarkTypes(), n3 = /* @__PURE__ */ new Map();
|
|
@@ -2640,9 +2780,9 @@ function Ln(e2, t2) {
|
|
|
2640
2780
|
}
|
|
2641
2781
|
return n2;
|
|
2642
2782
|
}
|
|
2643
|
-
const
|
|
2644
|
-
let
|
|
2645
|
-
class
|
|
2783
|
+
const Dn = ["\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", '\n/* Paper viewport: scroll container with centered gray background */\n.notectl-paper-viewport {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n background: var(--notectl-paper-viewport-bg, #e8e8e8);\n padding: 24px 0;\n}\n\n/* Paper surface: white page with shadow, centered */\n.notectl-paper-surface {\n margin: 0 auto;\n background: var(--notectl-bg);\n border-radius: 2px;\n box-shadow: 0 2px 8px var(--notectl-shadow, rgba(0, 0, 0, 0.15));\n transform-origin: top center;\n transition: transform 0.15s ease-out;\n}\n\n/* Content overrides in paper mode: wider document margins */\n.notectl-editor[data-paper-mode] .notectl-content {\n flex: none;\n padding: 48px 56px;\n min-height: auto;\n}\n\n/* Placeholder position override for paper mode */\n.notectl-editor[data-paper-mode] .notectl-content.notectl-content--empty::before {\n top: 48px;\n left: 56px;\n}\n\n/* Dark mode: darker viewport background */\n:host([theme="dark"]) .notectl-paper-viewport {\n --notectl-paper-viewport-bg: #181825;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .notectl-paper-surface {\n transition: none !important;\n }\n}\n'].join("\n");
|
|
2784
|
+
let Hn = null;
|
|
2785
|
+
class zn {
|
|
2646
2786
|
themeStyleSheet = new CSSStyleSheet();
|
|
2647
2787
|
systemThemeQuery = null;
|
|
2648
2788
|
systemThemeHandler = null;
|
|
@@ -2652,11 +2792,11 @@ class Mn {
|
|
|
2652
2792
|
this.shadow = e2;
|
|
2653
2793
|
}
|
|
2654
2794
|
apply(e2) {
|
|
2655
|
-
if (this.cleanupSystemThemeListener(), e2 ===
|
|
2795
|
+
if (this.cleanupSystemThemeListener(), e2 === Dt.System) {
|
|
2656
2796
|
this.setupSystemThemeListener();
|
|
2657
|
-
const e3 =
|
|
2797
|
+
const e3 = jt(this.getSystemTheme());
|
|
2658
2798
|
this.setThemeStyleSheet(e3);
|
|
2659
|
-
} else this.setThemeStyleSheet(
|
|
2799
|
+
} else this.setThemeStyleSheet(jt(e2));
|
|
2660
2800
|
}
|
|
2661
2801
|
setPluginStyleSheets(e2) {
|
|
2662
2802
|
this.pluginSheets = e2, this.refreshAdoptedStyleSheets();
|
|
@@ -2665,14 +2805,14 @@ class Mn {
|
|
|
2665
2805
|
this.cleanupSystemThemeListener();
|
|
2666
2806
|
}
|
|
2667
2807
|
setThemeStyleSheet(e2) {
|
|
2668
|
-
this.themeStyleSheet.replaceSync(
|
|
2808
|
+
this.themeStyleSheet.replaceSync(Wt(e2)), this.refreshAdoptedStyleSheets();
|
|
2669
2809
|
}
|
|
2670
2810
|
refreshAdoptedStyleSheets() {
|
|
2671
|
-
this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (
|
|
2811
|
+
this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (Hn || (Hn = new CSSStyleSheet(), Hn.replaceSync(Dn)), Hn), ...this.pluginSheets];
|
|
2672
2812
|
}
|
|
2673
2813
|
setupSystemThemeListener() {
|
|
2674
2814
|
this.systemThemeQuery = window.matchMedia("(prefers-color-scheme: dark)"), this.systemThemeHandler = (e2) => {
|
|
2675
|
-
const t2 =
|
|
2815
|
+
const t2 = jt(this.getSystemTheme());
|
|
2676
2816
|
this.setThemeStyleSheet(t2);
|
|
2677
2817
|
}, this.systemThemeQuery.addEventListener("change", this.systemThemeHandler);
|
|
2678
2818
|
}
|
|
@@ -2680,10 +2820,10 @@ class Mn {
|
|
|
2680
2820
|
this.systemThemeQuery && this.systemThemeHandler && this.systemThemeQuery.removeEventListener("change", this.systemThemeHandler), this.systemThemeQuery = null, this.systemThemeHandler = null;
|
|
2681
2821
|
}
|
|
2682
2822
|
getSystemTheme() {
|
|
2683
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ?
|
|
2823
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? Dt.Dark : Dt.Light;
|
|
2684
2824
|
}
|
|
2685
2825
|
}
|
|
2686
|
-
class
|
|
2826
|
+
class $n {
|
|
2687
2827
|
wrapper;
|
|
2688
2828
|
content;
|
|
2689
2829
|
viewport = null;
|
|
@@ -2699,7 +2839,7 @@ class Bn {
|
|
|
2699
2839
|
}
|
|
2700
2840
|
apply(e2) {
|
|
2701
2841
|
if (null === e2) return void this.disable();
|
|
2702
|
-
const t2 =
|
|
2842
|
+
const t2 = Ct(e2);
|
|
2703
2843
|
this.currentPaperWidthPx = t2.widthPx, this.currentPaperHeightPx = t2.heightPx, this.currentSize = e2, this.viewport || this.enable(), this.updateSurfaceDimensions(), this.wrapper.setAttribute("data-paper-mode", e2);
|
|
2704
2844
|
}
|
|
2705
2845
|
destroy() {
|
|
@@ -2743,7 +2883,7 @@ class Bn {
|
|
|
2743
2883
|
this.surface.style.marginBottom = `${n2}px`;
|
|
2744
2884
|
}
|
|
2745
2885
|
}
|
|
2746
|
-
class
|
|
2886
|
+
class jn extends HTMLElement {
|
|
2747
2887
|
view = null;
|
|
2748
2888
|
pluginManager = null;
|
|
2749
2889
|
contentElement = null;
|
|
@@ -2771,14 +2911,16 @@ class Pn extends HTMLElement {
|
|
|
2771
2911
|
this.initialized || this.init();
|
|
2772
2912
|
}
|
|
2773
2913
|
disconnectedCallback() {
|
|
2774
|
-
|
|
2914
|
+
setTimeout(() => {
|
|
2915
|
+
this.isConnected || this.destroy();
|
|
2916
|
+
}, 0);
|
|
2775
2917
|
}
|
|
2776
2918
|
attributeChangedCallback(e2, t2, n2) {
|
|
2777
2919
|
if ("placeholder" === e2 && this.contentElement && this.contentElement.setAttribute("data-placeholder", n2 ?? ""), "readonly" === e2 && this.contentElement) {
|
|
2778
2920
|
const e3 = null !== n2;
|
|
2779
|
-
this.contentElement.contentEditable = e3 ? "false" : "true", e3 ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly");
|
|
2921
|
+
this.contentElement.contentEditable = e3 ? "false" : "true", e3 ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly"), this.config = { ...this.config, readonly: e3 }, this.pluginManager?.setReadOnly(e3);
|
|
2780
2922
|
}
|
|
2781
|
-
"theme" === e2 && this.themeController && this.themeController.apply(n2 ??
|
|
2923
|
+
"theme" === e2 && this.themeController && this.themeController.apply(n2 ?? Dt.Light), "paper-size" === e2 && (null === n2 ? this.configure({ paperSize: void 0 }) : Mt(n2) && this.configure({ paperSize: n2 }));
|
|
2782
2924
|
}
|
|
2783
2925
|
registerPlugin(e2) {
|
|
2784
2926
|
if (this.initialized) throw new Error("Cannot register plugins after initialization. Register before calling init() or adding to DOM.");
|
|
@@ -2789,7 +2931,7 @@ class Pn extends HTMLElement {
|
|
|
2789
2931
|
this.initialized = true, e2 && (this.config = e2);
|
|
2790
2932
|
const t2 = this.shadowRoot;
|
|
2791
2933
|
if (!t2) return;
|
|
2792
|
-
this.themeController = new
|
|
2934
|
+
this.themeController = new zn(t2), this.themeController.apply(this.config.theme ?? Dt.Light);
|
|
2793
2935
|
const n2 = (function(e3) {
|
|
2794
2936
|
const t3 = document.createElement("div");
|
|
2795
2937
|
t3.className = "notectl-editor";
|
|
@@ -2802,9 +2944,9 @@ class Pn extends HTMLElement {
|
|
|
2802
2944
|
const o3 = document.createElement("div");
|
|
2803
2945
|
return o3.className = "notectl-sr-only", o3.setAttribute("data-notectl-no-print", ""), o3.setAttribute("aria-live", "polite"), o3.setAttribute("aria-atomic", "true"), t3.appendChild(n3), t3.appendChild(s3), t3.appendChild(r3), t3.appendChild(o3), { wrapper: t3, content: s3, topPluginContainer: n3, bottomPluginContainer: r3, announcer: o3 };
|
|
2804
2946
|
})({ readonly: this.config.readonly, placeholder: this.config.placeholder });
|
|
2805
|
-
this.editorWrapper = n2.wrapper, this.contentElement = n2.content, this.topPluginContainer = n2.topPluginContainer, this.bottomPluginContainer = n2.bottomPluginContainer, this.announcer = n2.announcer, t2.appendChild(this.editorWrapper), this.config.paperSize && (this.paperLayout = new
|
|
2806
|
-
const s2 = new
|
|
2807
|
-
this.pluginManager.registerService(
|
|
2947
|
+
this.editorWrapper = n2.wrapper, this.contentElement = n2.content, this.topPluginContainer = n2.topPluginContainer, this.bottomPluginContainer = n2.bottomPluginContainer, this.announcer = n2.announcer, t2.appendChild(this.editorWrapper), this.config.paperSize && (this.paperLayout = new $n(this.editorWrapper, this.contentElement), this.paperLayout.apply(this.config.paperSize)), this.pluginManager = new yt();
|
|
2948
|
+
const s2 = new Pe(this.config.locale ?? "browser");
|
|
2949
|
+
this.pluginManager.registerService(_e, s2), qe(this.pluginManager.schemaRegistry), this.processToolbarConfig();
|
|
2808
2950
|
for (const e3 of this.config.plugins ?? []) this.pluginManager.register(e3);
|
|
2809
2951
|
for (const e3 of this.preInitPlugins) this.pluginManager.register(e3);
|
|
2810
2952
|
this.preInitPlugins = [], this.ensureTextFormattingPlugin(), this.contentElement.addEventListener("focus", () => this.emit("focus", void 0)), this.contentElement.addEventListener("blur", () => this.emit("blur", void 0));
|
|
@@ -2818,15 +2960,18 @@ class Pn extends HTMLElement {
|
|
|
2818
2960
|
c8 && (c8.textContent = e3);
|
|
2819
2961
|
}, onBeforeReady: () => {
|
|
2820
2962
|
const e3 = ve(o2.schemaRegistry), t3 = at.create({ schema: e3 });
|
|
2821
|
-
this.view = new
|
|
2963
|
+
this.view = new An(r2, { state: t3, schemaRegistry: o2.schemaRegistry, maxHistoryDepth: this.config.maxHistoryDepth, getDecorations: (e4, t4) => this.pluginManager?.collectDecorations(e4, t4) ?? De.empty, onStateChange: (e4, t4, n4) => {
|
|
2822
2964
|
this.onStateChange(e4, t4, n4);
|
|
2823
|
-
} }), this.updateEmptyState();
|
|
2965
|
+
}, isReadOnly: () => this.config.readonly ?? false }), this.updateEmptyState();
|
|
2824
2966
|
const n3 = o2.getPluginStyleSheets();
|
|
2825
2967
|
n3.length > 0 && this.themeController?.setPluginStyleSheets(n3);
|
|
2826
|
-
} }), this.pluginManager && (this.pluginManager.onEvent(
|
|
2968
|
+
} }), this.pluginManager && (this.config.readonly && this.pluginManager.setReadOnly(true), this.pluginManager.onEvent(Ot, (e3) => {
|
|
2827
2969
|
!e3.options.paperSize && this.config.paperSize && (e3.options = { ...e3.options, paperSize: this.config.paperSize });
|
|
2828
2970
|
}), this.config.autofocus && requestAnimationFrame(() => this.contentElement?.focus()), this.readyPromiseResolve?.(), this.emit("ready", void 0));
|
|
2829
2971
|
}
|
|
2972
|
+
get isReadOnly() {
|
|
2973
|
+
return this.config.readonly ?? false;
|
|
2974
|
+
}
|
|
2830
2975
|
getJSON() {
|
|
2831
2976
|
if (!this.view) throw new Error("Editor not initialized");
|
|
2832
2977
|
return this.view.getState().doc;
|
|
@@ -2840,10 +2985,10 @@ class Pn extends HTMLElement {
|
|
|
2840
2985
|
return (function(e2, t2) {
|
|
2841
2986
|
const n2 = [];
|
|
2842
2987
|
let s2 = null;
|
|
2843
|
-
for (const r3 of e2.children) if (
|
|
2988
|
+
for (const r3 of e2.children) if (Ce(r3, "list_item")) {
|
|
2844
2989
|
const e3 = "ordered" === r3.attrs.listType ? "ol" : "ul";
|
|
2845
|
-
s2 !== e3 && (s2 && n2.push(`</${s2}>`), n2.push(`<${e3}>`), s2 = e3), n2.push(
|
|
2846
|
-
} else s2 && (n2.push(`</${s2}>`), s2 = null), n2.push(
|
|
2990
|
+
s2 !== e3 && (s2 && n2.push(`</${s2}>`), n2.push(`<${e3}>`), s2 = e3), n2.push(Pn(r3, t2));
|
|
2991
|
+
} else s2 && (n2.push(`</${s2}>`), s2 = null), n2.push(Pn(r3, t2));
|
|
2847
2992
|
s2 && n2.push(`</${s2}>`);
|
|
2848
2993
|
const r2 = t2 ? t2.getAllowedTags() : ["p", "br", "div", "span"], o2 = t2 ? t2.getAllowedAttrs() : ["style"];
|
|
2849
2994
|
return Fe.sanitize(n2.join(""), { ALLOWED_TAGS: r2, ALLOWED_ATTR: o2 });
|
|
@@ -2859,18 +3004,18 @@ class Pn extends HTMLElement {
|
|
|
2859
3004
|
if ("ul" === s3 || "ol" === s3) {
|
|
2860
3005
|
const e5 = "ol" === s3 ? "ordered" : "bullet";
|
|
2861
3006
|
for (const s4 of Array.from(n3.querySelectorAll("li"))) {
|
|
2862
|
-
const n4 =
|
|
3007
|
+
const n4 = In(s4, t3);
|
|
2863
3008
|
c8.push(o(Te("list_item"), n4, void 0, { listType: e5, indent: 0, checked: false }));
|
|
2864
3009
|
}
|
|
2865
3010
|
continue;
|
|
2866
3011
|
}
|
|
2867
|
-
const r3 =
|
|
3012
|
+
const r3 = On(n3, a18);
|
|
2868
3013
|
if (r3) {
|
|
2869
|
-
const e5 =
|
|
3014
|
+
const e5 = In(n3, t3);
|
|
2870
3015
|
c8.push(o(Te(r3.type), e5, void 0, r3.attrs));
|
|
2871
3016
|
continue;
|
|
2872
3017
|
}
|
|
2873
|
-
const i6 =
|
|
3018
|
+
const i6 = In(n3, t3);
|
|
2874
3019
|
c8.push(o(Te("paragraph"), i6));
|
|
2875
3020
|
} else e4.nodeType === Node.TEXT_NODE && e4.textContent?.trim() && c8.push(o(Te("paragraph"), [N(e4.textContent.trim())]));
|
|
2876
3021
|
return 0 === c8.length ? K() : K(c8);
|
|
@@ -2879,7 +3024,7 @@ class Pn extends HTMLElement {
|
|
|
2879
3024
|
}
|
|
2880
3025
|
getText() {
|
|
2881
3026
|
if (!this.view) throw new Error("Editor not initialized");
|
|
2882
|
-
return this.view.getState().doc.children.map((e2) =>
|
|
3027
|
+
return this.view.getState().doc.children.map((e2) => _(e2)).join("\n");
|
|
2883
3028
|
}
|
|
2884
3029
|
isEmpty() {
|
|
2885
3030
|
if (!this.view) return true;
|
|
@@ -2887,16 +3032,20 @@ class Pn extends HTMLElement {
|
|
|
2887
3032
|
if (0 === e2.children.length) return true;
|
|
2888
3033
|
if (e2.children.length > 1) return false;
|
|
2889
3034
|
const t2 = e2.children[0];
|
|
2890
|
-
return !t2 || "paragraph" === t2.type && "" ===
|
|
3035
|
+
return !t2 || "paragraph" === t2.type && "" === _(t2);
|
|
2891
3036
|
}
|
|
2892
|
-
commands = { toggleBold: () => this.executeCommand("toggleBold"), toggleItalic: () => this.executeCommand("toggleItalic"), toggleUnderline: () => this.executeCommand("toggleUnderline"), undo: () =>
|
|
3037
|
+
commands = { toggleBold: () => this.executeCommand("toggleBold"), toggleItalic: () => this.executeCommand("toggleItalic"), toggleUnderline: () => this.executeCommand("toggleUnderline"), undo: () => {
|
|
3038
|
+
this.config.readonly || this.view?.undo();
|
|
3039
|
+
}, redo: () => {
|
|
3040
|
+
this.config.readonly || this.view?.redo();
|
|
3041
|
+
}, selectAll: () => {
|
|
2893
3042
|
if (!this.view) return;
|
|
2894
3043
|
const e2 = oe(this.view.getState());
|
|
2895
3044
|
this.dispatch(e2);
|
|
2896
3045
|
} };
|
|
2897
3046
|
can() {
|
|
2898
|
-
const e2 = this.view?.getState().schema;
|
|
2899
|
-
return { toggleBold: () => !!e2 && be(e2, "bold"), toggleItalic: () => !!e2 && be(e2, "italic"), toggleUnderline: () => !!e2 && be(e2, "underline"), undo: () => this.view?.history.canUndo() ?? false, redo: () => this.view?.history.canRedo() ?? false };
|
|
3047
|
+
const e2 = this.view?.getState().schema, t2 = this.config.readonly ?? false;
|
|
3048
|
+
return { toggleBold: () => !t2 && !!e2 && be(e2, "bold"), toggleItalic: () => !t2 && !!e2 && be(e2, "italic"), toggleUnderline: () => !t2 && !!e2 && be(e2, "underline"), undo: () => !t2 && (this.view?.history.canUndo() ?? false), redo: () => !t2 && (this.view?.history.canRedo() ?? false) };
|
|
2900
3049
|
}
|
|
2901
3050
|
executeCommand(e2) {
|
|
2902
3051
|
return this.pluginManager?.executeCommand(e2) ?? false;
|
|
@@ -2916,7 +3065,7 @@ class Pn extends HTMLElement {
|
|
|
2916
3065
|
return this.view.getState();
|
|
2917
3066
|
}
|
|
2918
3067
|
dispatch(e2) {
|
|
2919
|
-
this.view && this.pluginManager && this.pluginManager.dispatchWithMiddleware(e2, this.view.getState(), (e3) => this.view?.dispatch(e3));
|
|
3068
|
+
this.view && this.pluginManager && (!this.config.readonly || ht(e2) || this.pluginManager.isReadonlyBypassed()) && this.pluginManager.dispatchWithMiddleware(e2, this.view.getState(), (e3) => this.view?.dispatch(e3));
|
|
2920
3069
|
}
|
|
2921
3070
|
on(e2, t2) {
|
|
2922
3071
|
this.eventListeners.has(e2) || this.eventListeners.set(e2, /* @__PURE__ */ new Set()), this.eventListeners.get(e2)?.add(t2);
|
|
@@ -2928,13 +3077,13 @@ class Pn extends HTMLElement {
|
|
|
2928
3077
|
return this.readyPromise;
|
|
2929
3078
|
}
|
|
2930
3079
|
configure(e2) {
|
|
2931
|
-
void 0 !== e2.placeholder && this.contentElement && this.contentElement.setAttribute("data-placeholder", e2.placeholder), void 0 !== e2.readonly && this.contentElement && (this.contentElement.contentEditable = e2.readonly ? "false" : "true", e2.readonly ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly")), "paperSize" in e2 && this.applyPaperSize(e2.paperSize), this.config = { ...this.config, ...e2 };
|
|
3080
|
+
void 0 !== e2.placeholder && this.contentElement && this.contentElement.setAttribute("data-placeholder", e2.placeholder), void 0 !== e2.readonly && this.contentElement && (this.contentElement.contentEditable = e2.readonly ? "false" : "true", e2.readonly ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly"), this.pluginManager?.setReadOnly(e2.readonly)), "paperSize" in e2 && this.applyPaperSize(e2.paperSize), this.config = { ...this.config, ...e2 };
|
|
2932
3081
|
}
|
|
2933
3082
|
setTheme(e2) {
|
|
2934
3083
|
this.config = { ...this.config, theme: e2 }, this.themeController?.apply(e2);
|
|
2935
3084
|
}
|
|
2936
3085
|
getTheme() {
|
|
2937
|
-
return this.config.theme ??
|
|
3086
|
+
return this.config.theme ?? Dt.Light;
|
|
2938
3087
|
}
|
|
2939
3088
|
getPaperSize() {
|
|
2940
3089
|
return this.config.paperSize;
|
|
@@ -2942,18 +3091,18 @@ class Pn extends HTMLElement {
|
|
|
2942
3091
|
destroy() {
|
|
2943
3092
|
this.paperLayout?.destroy(), this.paperLayout = null, this.themeController?.destroy(), this.themeController = null, this.view?.destroy();
|
|
2944
3093
|
const e2 = this.pluginManager?.destroy() ?? Promise.resolve();
|
|
2945
|
-
return this.view = null, this.pluginManager = null, this.initialized = false, e2;
|
|
3094
|
+
return this.view = null, this.pluginManager = null, this.initialized = false, this.editorWrapper?.remove(), this.editorWrapper = null, this.contentElement = null, this.topPluginContainer = null, this.bottomPluginContainer = null, this.announcer = null, e2;
|
|
2946
3095
|
}
|
|
2947
3096
|
processToolbarConfig() {
|
|
2948
3097
|
if (!this.pluginManager || !this.config.toolbar) return;
|
|
2949
|
-
const e2 = [];
|
|
2950
|
-
for (const
|
|
2951
|
-
const
|
|
2952
|
-
for (const
|
|
2953
|
-
|
|
3098
|
+
const e2 = this.config.toolbar, t2 = Array.isArray(e2), n2 = t2 ? e2 : e2.groups, s2 = t2 ? void 0 : e2.overflow, r2 = [];
|
|
3099
|
+
for (const e3 of n2) {
|
|
3100
|
+
const t3 = [];
|
|
3101
|
+
for (const n3 of e3) t3.push(n3.id), this.pluginManager.register(n3);
|
|
3102
|
+
r2.push(t3);
|
|
2954
3103
|
}
|
|
2955
|
-
const
|
|
2956
|
-
this.pluginManager.register(new ze(
|
|
3104
|
+
const o2 = { groups: r2, overflow: s2 };
|
|
3105
|
+
this.pluginManager.register(new ze(o2));
|
|
2957
3106
|
}
|
|
2958
3107
|
ensureTextFormattingPlugin() {
|
|
2959
3108
|
if (!this.pluginManager) return;
|
|
@@ -2962,7 +3111,7 @@ class Pn extends HTMLElement {
|
|
|
2962
3111
|
this.pluginManager.register(new je(e2));
|
|
2963
3112
|
}
|
|
2964
3113
|
applyPaperSize(e2) {
|
|
2965
|
-
this.editorWrapper && this.contentElement && (e2 ? (this.paperLayout || (this.paperLayout = new
|
|
3114
|
+
this.editorWrapper && this.contentElement && (e2 ? (this.paperLayout || (this.paperLayout = new $n(this.editorWrapper, this.contentElement)), this.paperLayout.apply(e2)) : this.paperLayout?.apply(null));
|
|
2966
3115
|
}
|
|
2967
3116
|
emit(e2, t2) {
|
|
2968
3117
|
const n2 = this.eventListeners.get(e2);
|
|
@@ -2973,7 +3122,7 @@ class Pn extends HTMLElement {
|
|
|
2973
3122
|
const s2 = (function(e3, t3, n3) {
|
|
2974
3123
|
if ("undo" === n3.metadata.historyDirection) return "Undo";
|
|
2975
3124
|
if ("redo" === n3.metadata.historyDirection) return "Redo";
|
|
2976
|
-
for (const e4 of n3.steps) if ("setBlockType" === e4.type) return
|
|
3125
|
+
for (const e4 of n3.steps) if ("setBlockType" === e4.type) return Mn(e4.nodeType, e4.attrs);
|
|
2977
3126
|
for (const n4 of t3.schema.markTypes) {
|
|
2978
3127
|
const s3 = xe(n4), r2 = we(e3, s3), o2 = we(t3, s3);
|
|
2979
3128
|
if (r2 !== o2) return `${n4} ${o2 ? "on" : "off"}`;
|
|
@@ -2990,33 +3139,33 @@ class Pn extends HTMLElement {
|
|
|
2990
3139
|
this.view && (this.view.replaceState(e2), this.updateEmptyState());
|
|
2991
3140
|
}
|
|
2992
3141
|
}
|
|
2993
|
-
async function
|
|
3142
|
+
async function Fn(e2) {
|
|
2994
3143
|
const t2 = document.createElement("notectl-editor");
|
|
2995
3144
|
return await t2.init(e2), t2;
|
|
2996
3145
|
}
|
|
2997
|
-
"undefined" == typeof customElements || customElements.get("notectl-editor") || customElements.define("notectl-editor",
|
|
3146
|
+
"undefined" == typeof customElements || customElements.get("notectl-editor") || customElements.define("notectl-editor", jn);
|
|
2998
3147
|
export {
|
|
2999
3148
|
Bt as AFTER_PRINT,
|
|
3000
3149
|
A2 as ALIGNMENT_ICONS,
|
|
3001
3150
|
a11 as ALIGNMENT_LOCALES,
|
|
3002
3151
|
b13 as ALIGNMENT_LOCALE_DE,
|
|
3003
3152
|
c5 as ALIGNMENT_LOCALE_EN,
|
|
3004
|
-
|
|
3005
|
-
|
|
3153
|
+
d2 as AlignmentPlugin,
|
|
3154
|
+
Ot as BEFORE_PRINT,
|
|
3006
3155
|
B2 as BLOCKQUOTE_LOCALES,
|
|
3007
3156
|
a7 as BLOCKQUOTE_LOCALE_EN,
|
|
3008
3157
|
b9 as BlockquotePlugin,
|
|
3009
3158
|
C as CODE_BLOCK_LOCALES,
|
|
3010
3159
|
a as CODE_BLOCK_LOCALE_EN,
|
|
3011
3160
|
b3 as CODE_BLOCK_SERVICE_KEY,
|
|
3012
|
-
|
|
3161
|
+
gt as ClipboardHandler,
|
|
3013
3162
|
c3 as CodeBlockPlugin,
|
|
3014
|
-
|
|
3163
|
+
zt as DARK_THEME,
|
|
3015
3164
|
D as DEFAULT_IMAGE_KEYMAP,
|
|
3016
3165
|
De as DecorationSet,
|
|
3017
3166
|
at as EditorState,
|
|
3018
|
-
|
|
3019
|
-
|
|
3167
|
+
mt as EventBus,
|
|
3168
|
+
Re as EventKey,
|
|
3020
3169
|
F as FONT_LOCALES,
|
|
3021
3170
|
a12 as FONT_LOCALE_EN,
|
|
3022
3171
|
F2 as FONT_SIZE_LOCALES,
|
|
@@ -3032,45 +3181,45 @@ export {
|
|
|
3032
3181
|
HardBreakPlugin,
|
|
3033
3182
|
b6 as HeadingPlugin,
|
|
3034
3183
|
b17 as HighlightPlugin,
|
|
3035
|
-
|
|
3184
|
+
dt as HistoryManager,
|
|
3036
3185
|
b12 as HorizontalRulePlugin,
|
|
3037
3186
|
I as IMAGE_LOCALES,
|
|
3038
3187
|
a17 as IMAGE_LOCALE_EN,
|
|
3039
3188
|
b19 as IMAGE_UPLOAD_SERVICE,
|
|
3040
3189
|
c7 as ImagePlugin,
|
|
3041
|
-
|
|
3190
|
+
Ht as LIGHT_THEME,
|
|
3042
3191
|
L as LINK_LOCALES,
|
|
3043
3192
|
a5 as LINK_LOCALE_EN,
|
|
3044
3193
|
L2 as LIST_LOCALES,
|
|
3045
3194
|
a6 as LIST_LOCALE_EN,
|
|
3046
3195
|
b7 as LinkPlugin,
|
|
3047
3196
|
b8 as ListPlugin,
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3197
|
+
qt as Locale,
|
|
3198
|
+
Pe as LocaleService,
|
|
3199
|
+
_e as LocaleServiceKey,
|
|
3200
|
+
jn as NotectlEditor,
|
|
3201
|
+
At as PAPER_MARGIN_HORIZONTAL_PX,
|
|
3202
|
+
Nt as PAPER_MARGIN_TOP_PX,
|
|
3203
|
+
Lt as PAPER_VIEWPORT_PADDING_PX,
|
|
3204
|
+
bt as PRINT_LOCALES,
|
|
3205
|
+
kt as PRINT_LOCALE_EN,
|
|
3206
|
+
Rt as PRINT_SERVICE_KEY,
|
|
3207
|
+
wt as PaperSize,
|
|
3208
|
+
yt as PluginManager,
|
|
3209
|
+
_t as PrintPlugin,
|
|
3061
3210
|
S as STRIKETHROUGH_LOCALES,
|
|
3062
3211
|
a8 as STRIKETHROUGH_LOCALE_EN,
|
|
3063
3212
|
S2 as SUPER_SUB_LOCALES,
|
|
3064
3213
|
a16 as SUPER_SUB_LOCALE_EN,
|
|
3065
3214
|
Ue as SchemaRegistry,
|
|
3066
|
-
|
|
3215
|
+
Oe as ServiceKey,
|
|
3067
3216
|
b10 as StrikethroughPlugin,
|
|
3068
3217
|
b18 as SuperSubPlugin,
|
|
3069
3218
|
T2 as TABLE_LOCALES,
|
|
3070
3219
|
a14 as TABLE_LOCALE_AR,
|
|
3071
3220
|
b16 as TABLE_LOCALE_DE,
|
|
3072
3221
|
c6 as TABLE_LOCALE_EN,
|
|
3073
|
-
|
|
3222
|
+
d4 as TABLE_LOCALE_ES,
|
|
3074
3223
|
e as TABLE_LOCALE_FR,
|
|
3075
3224
|
f3 as TABLE_LOCALE_HI,
|
|
3076
3225
|
g as TABLE_LOCALE_RU,
|
|
@@ -3083,50 +3232,51 @@ export {
|
|
|
3083
3232
|
c4 as TOOLBAR_LOCALE_EN,
|
|
3084
3233
|
i4 as TablePlugin,
|
|
3085
3234
|
j as TableSelectionServiceKey,
|
|
3086
|
-
|
|
3235
|
+
d3 as TextAlignmentPlugin,
|
|
3087
3236
|
b11 as TextColorPlugin,
|
|
3088
3237
|
je as TextFormattingPlugin,
|
|
3089
|
-
|
|
3238
|
+
Dt as ThemePreset,
|
|
3239
|
+
d as ToolbarOverflowBehavior,
|
|
3090
3240
|
ze as ToolbarPlugin,
|
|
3091
3241
|
a2 as ToolbarServiceKey,
|
|
3092
3242
|
it as TransactionBuilder,
|
|
3093
3243
|
Ge as applyStep,
|
|
3094
3244
|
Ee as blockId,
|
|
3095
|
-
|
|
3245
|
+
We as canContain,
|
|
3096
3246
|
c as commandName,
|
|
3097
|
-
|
|
3247
|
+
Ne as createBlockElement,
|
|
3098
3248
|
o as createBlockNode,
|
|
3099
3249
|
J as createCollapsedSelection,
|
|
3100
3250
|
K as createDocument,
|
|
3101
|
-
|
|
3251
|
+
Fn as createEditor,
|
|
3102
3252
|
f as createInlineNode,
|
|
3103
3253
|
X as createNodeSelection,
|
|
3104
3254
|
Z as createPosition,
|
|
3105
3255
|
Y as createSelection,
|
|
3106
3256
|
N as createTextNode,
|
|
3107
|
-
|
|
3108
|
-
|
|
3257
|
+
$t as createTheme,
|
|
3258
|
+
Vt as createThemeStyleSheet,
|
|
3109
3259
|
re as defaultSchema,
|
|
3110
3260
|
de as deleteBackward,
|
|
3111
3261
|
me as deleteForward,
|
|
3112
3262
|
ae as deleteNodeSelection,
|
|
3113
3263
|
he as deleteSelectionCommand,
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3264
|
+
Ae as escapeHTML,
|
|
3265
|
+
Le as findNode,
|
|
3266
|
+
Ie as findNodePath,
|
|
3117
3267
|
b2 as findNodeWithPath,
|
|
3118
3268
|
k as findTableContext,
|
|
3119
3269
|
f2 as forEachBlockInRange,
|
|
3120
3270
|
$e as formatShortcut,
|
|
3121
|
-
|
|
3271
|
+
Wt as generateThemeCSS,
|
|
3122
3272
|
G as getBlockChildren,
|
|
3123
3273
|
r as getBlockLength,
|
|
3124
3274
|
$ as getBlockMarksAtOffset,
|
|
3125
|
-
|
|
3275
|
+
_ as getBlockText,
|
|
3126
3276
|
U as getContentAtOffset,
|
|
3127
3277
|
t as getInlineChildren,
|
|
3128
|
-
|
|
3129
|
-
|
|
3278
|
+
It as getPaperCSSSize,
|
|
3279
|
+
Ct as getPaperDimensions,
|
|
3130
3280
|
v as getTextChildren,
|
|
3131
3281
|
h as hasMark,
|
|
3132
3282
|
i3 as inlineDecoration,
|
|
@@ -3135,6 +3285,7 @@ export {
|
|
|
3135
3285
|
le as insertTextCommand,
|
|
3136
3286
|
rt as invertStep,
|
|
3137
3287
|
ot as invertTransaction,
|
|
3288
|
+
ht as isAllowedInReadonly,
|
|
3138
3289
|
m as isBlockNode,
|
|
3139
3290
|
te as isCollapsed,
|
|
3140
3291
|
h2 as isForward,
|
|
@@ -3142,29 +3293,30 @@ export {
|
|
|
3142
3293
|
b as isInlineNodeOfType,
|
|
3143
3294
|
u as isInsideIsolating,
|
|
3144
3295
|
l as isInsideTable,
|
|
3145
|
-
|
|
3296
|
+
W as isLeafBlock,
|
|
3146
3297
|
we as isMarkActive,
|
|
3147
3298
|
be as isMarkAllowed,
|
|
3148
3299
|
i2 as isMarkOfType,
|
|
3149
|
-
|
|
3300
|
+
Ce as isNodeOfType,
|
|
3150
3301
|
Q as isNodeSelection,
|
|
3302
|
+
lt as isSelectionOnlyTransaction,
|
|
3151
3303
|
M as isTextNode,
|
|
3152
3304
|
ee as isTextSelection,
|
|
3153
|
-
|
|
3305
|
+
Mt as isValidPaperSize,
|
|
3154
3306
|
v2 as isVoidBlock,
|
|
3155
|
-
|
|
3307
|
+
q as markSetsEqual,
|
|
3156
3308
|
xe as markType,
|
|
3157
3309
|
w as mergeBlockBackward,
|
|
3158
3310
|
ie as navigateArrowIntoVoid,
|
|
3159
3311
|
n as nodeDecoration,
|
|
3160
3312
|
Te as nodeType,
|
|
3161
|
-
|
|
3313
|
+
pt as normalizeKeyDescriptor,
|
|
3162
3314
|
p as pluginId,
|
|
3163
|
-
|
|
3164
|
-
|
|
3315
|
+
qe as registerBuiltinSpecs,
|
|
3316
|
+
Me as resolveNodeByPath,
|
|
3165
3317
|
c2 as resolveParentByPath,
|
|
3166
|
-
|
|
3167
|
-
|
|
3318
|
+
Be as resolvePluginLocale,
|
|
3319
|
+
jt as resolveTheme,
|
|
3168
3320
|
ve as schemaFromRegistry,
|
|
3169
3321
|
oe as selectAll,
|
|
3170
3322
|
ne as selectionRange,
|
|
@@ -3175,7 +3327,7 @@ export {
|
|
|
3175
3327
|
z as toggleItalic,
|
|
3176
3328
|
A as toggleMark,
|
|
3177
3329
|
B as toggleUnderline,
|
|
3178
|
-
|
|
3330
|
+
Ve as validateContent,
|
|
3179
3331
|
w2 as walkNodes,
|
|
3180
3332
|
w3 as widgetDecoration
|
|
3181
3333
|
};
|