@one2x/medeo-rte 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -46
- package/dist/chunks/{types-I0yc5X7i.js → types-Hb-uu8xL.js} +2 -2
- package/dist/chunks/{types-I0yc5X7i.js.map → types-Hb-uu8xL.js.map} +1 -1
- package/dist/formula.js +1 -1
- package/dist/index.js +122 -122
- package/dist/index.js.map +1 -1
- package/dist/types/model/types.d.ts +5 -4
- package/dist/types/model/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var vs = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var p = (s, t, e) =>
|
|
4
|
-
import { e as Y, E as ce, a as on, b as an, c as ln, p as Es } from "./chunks/types-
|
|
2
|
+
var bs = (s, t, e) => t in s ? vs(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var p = (s, t, e) => bs(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { e as Y, E as ce, a as on, b as an, c as ln, p as Es } from "./chunks/types-Hb-uu8xL.js";
|
|
5
5
|
import { prepareWithSegments as cn, measureNaturalWidth as Is, setLocale as As, layoutNextLine as hn } from "@chenglou/pretext";
|
|
6
6
|
const Ms = ["plain", "javascript", "typescript", "python", "json", "html", "css"], Cs = 28, xs = 18, Ts = 12;
|
|
7
7
|
function Bs(s, t) {
|
|
@@ -268,7 +268,7 @@ function _s(s, t) {
|
|
|
268
268
|
}
|
|
269
269
|
return e += m.TABLE_END, e;
|
|
270
270
|
}
|
|
271
|
-
const
|
|
271
|
+
const be = "#2374d1", Oe = 1920 / 1080;
|
|
272
272
|
function D(s) {
|
|
273
273
|
return Math.min(s.anchor, s.focus);
|
|
274
274
|
}
|
|
@@ -330,9 +330,9 @@ function Us(s, t) {
|
|
|
330
330
|
return s.start < t.end && t.start < s.end;
|
|
331
331
|
}
|
|
332
332
|
function Ks(s, t) {
|
|
333
|
-
return Us(s, t) && !
|
|
333
|
+
return Us(s, t) && !St(s, t) && !St(t, s);
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function St(s, t) {
|
|
336
336
|
return s.start <= t.start && s.end >= t.end;
|
|
337
337
|
}
|
|
338
338
|
function ue(s, t) {
|
|
@@ -426,7 +426,7 @@ function Zs(s, t) {
|
|
|
426
426
|
}
|
|
427
427
|
function Qs(s) {
|
|
428
428
|
for (let t = s.length - 1; t >= 0; t--)
|
|
429
|
-
if (s[t].kind === "
|
|
429
|
+
if (s[t].kind === "virtualSlot" && s[t].empty) return s[t];
|
|
430
430
|
return null;
|
|
431
431
|
}
|
|
432
432
|
function yt(s, t, e) {
|
|
@@ -441,19 +441,19 @@ function yt(s, t, e) {
|
|
|
441
441
|
fontSize: o.fontSize ?? a.fontSize ?? ((e.heading ?? 0) > 0 ? n.fontSize : void 0) ?? ((c = s.textDefaults) == null ? void 0 : c.fontSize) ?? Lt.fontSize,
|
|
442
442
|
fontFamily: o.fontFamily ?? a.fontFamily ?? ((h = s.textDefaults) == null ? void 0 : h.fontFamily),
|
|
443
443
|
fontWeight: o.fontWeight ?? a.fontWeight ?? ((d = s.textDefaults) == null ? void 0 : d.fontWeight),
|
|
444
|
-
color: o.color ?? a.color ?? (l ?
|
|
444
|
+
color: o.color ?? a.color ?? (l ? be : ((u = s.textDefaults) == null ? void 0 : u.color) ?? Lt.color),
|
|
445
445
|
fill: o.fill
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
const yn = 120, ti = 24;
|
|
449
449
|
function $t(s, t) {
|
|
450
|
-
const e = s.kind === "
|
|
450
|
+
const e = s.kind === "hostSlot";
|
|
451
451
|
let n = s.width > 0 ? s.width : e ? yn : 0;
|
|
452
452
|
const i = s.height > 0 ? s.height : e ? ti : s.height;
|
|
453
453
|
return t != null && t > 0 && n > t && (n = t), { width: n, height: i };
|
|
454
454
|
}
|
|
455
455
|
function kn(s, t) {
|
|
456
|
-
return s.float ? !1 : (s.width > 0 ? s.width : s.kind === "
|
|
456
|
+
return s.float ? !1 : (s.width > 0 ? s.width : s.kind === "hostSlot" ? yn : 0) >= t - 0.5 ? !0 : s.kind === "hostSlot" ? !1 : (s.height > 0, s.height) > 36;
|
|
457
457
|
}
|
|
458
458
|
const He = /* @__PURE__ */ new Map();
|
|
459
459
|
function Ee(s, t) {
|
|
@@ -493,7 +493,7 @@ function wn(s, t, e, n) {
|
|
|
493
493
|
}
|
|
494
494
|
return i;
|
|
495
495
|
}
|
|
496
|
-
function
|
|
496
|
+
function Sn(s, t, e) {
|
|
497
497
|
if (!s) return "";
|
|
498
498
|
if (J(s, t) <= e) return s;
|
|
499
499
|
let n = 1, i = s.length, r = 1;
|
|
@@ -528,7 +528,7 @@ function ei(s, t, e, n, i) {
|
|
|
528
528
|
}
|
|
529
529
|
const E = a.length > 0 ? Math.max(1, y) : Math.max(1, i), A = hn(g, { segmentIndex: 0, graphemeIndex: 0 }, E);
|
|
530
530
|
let w = A != null && A.text ? u.slice(0, Math.min(A.text.length, u.length)) : u;
|
|
531
|
-
if (w =
|
|
531
|
+
if (w = Sn(w, d.style, E), w || (w = u[0] ?? ""), a.length > 0 && J(w, d.style) > y + 0.5 && y < i) {
|
|
532
532
|
h(f);
|
|
533
533
|
continue;
|
|
534
534
|
}
|
|
@@ -594,7 +594,7 @@ function ai(s, t) {
|
|
|
594
594
|
if (e.length > 0 && r <= 0) break;
|
|
595
595
|
const a = e.length > 0 ? Math.max(1, r) : Math.max(1, t), l = Ee(o, i.style), c = hn(l, { segmentIndex: 0, graphemeIndex: 0 }, a);
|
|
596
596
|
let h = c != null && c.text ? o.slice(0, Math.min(c.text.length, o.length)) : o;
|
|
597
|
-
if (h =
|
|
597
|
+
if (h = Sn(h, i.style, a), h || (h = o[0] ?? ""), e.length > 0 && J(h, i.style) > r + 0.5 && r < t) break;
|
|
598
598
|
const d = J(h, i.style);
|
|
599
599
|
if (e.push({ kind: "text", index: i.index + s.off, length: h.length, text: h, style: i.style }), n += d, s.off += h.length, s.off >= i.text.length && (s.i += 1, s.off = 0), s.off > 0) break;
|
|
600
600
|
}
|
|
@@ -608,16 +608,16 @@ function vn(s, t, e, n, i, r, o, a = []) {
|
|
|
608
608
|
const l = { ...O, ...s.paragraphPropsAt(t) }, c = (l.indent ?? 0) * Xs, h = li(l, o), d = l.list && l.list !== "none" ? mn : 0, u = n + c + d, f = Math.max(80, r - c - d), g = l.align ?? "left", y = [], E = [...a], A = E.length > 0 || ci(s, t, e), w = [];
|
|
609
609
|
let R = i;
|
|
610
610
|
if (A) {
|
|
611
|
-
const
|
|
611
|
+
const b = ii(s, t, e, l, !1);
|
|
612
612
|
let k = 0;
|
|
613
613
|
do {
|
|
614
|
-
const
|
|
615
|
-
if ((
|
|
616
|
-
const $ =
|
|
617
|
-
y.push(Mt), E.push({ x: Mt.x, y: Mt.y, w: Mt.w, h: Mt.h, side: $ }), oi(
|
|
614
|
+
const S = ri(b);
|
|
615
|
+
if ((S == null ? void 0 : S.kind) === "image" && S.entity.float) {
|
|
616
|
+
const $ = S.entity.float, se = $t(S.entity, r), Ss = $ === "left" ? n : n + r - se.width, Mt = { index: S.index, x: Ss, y: R, w: se.width, h: se.height, entity: S.entity };
|
|
617
|
+
y.push(Mt), E.push({ x: Mt.x, y: Mt.y, w: Mt.w, h: Mt.h, side: $ }), oi(b);
|
|
618
618
|
continue;
|
|
619
619
|
}
|
|
620
|
-
const I = ni(u, f, R, 28, E), T = Ge(
|
|
620
|
+
const I = ni(u, f, R, 28, E), T = Ge(b, t), K = Kt(b) ? [] : ai(b, I.w), F = Kt(b) ? e : Ge(b, e), H = Ue(
|
|
621
621
|
s,
|
|
622
622
|
l,
|
|
623
623
|
K,
|
|
@@ -632,21 +632,21 @@ function vn(s, t, e, n, i, r, o, a = []) {
|
|
|
632
632
|
n + c
|
|
633
633
|
);
|
|
634
634
|
w.push(H), R += H.h, k += 1;
|
|
635
|
-
} while (!Kt(
|
|
635
|
+
} while (!Kt(b));
|
|
636
636
|
} else {
|
|
637
|
-
const
|
|
638
|
-
for (let k = 0; k <
|
|
639
|
-
const
|
|
637
|
+
const b = ei(s, t, e, l, f);
|
|
638
|
+
for (let k = 0; k < b.length; k++) {
|
|
639
|
+
const S = b[k], I = Ue(
|
|
640
640
|
s,
|
|
641
641
|
l,
|
|
642
|
-
|
|
642
|
+
S.items,
|
|
643
643
|
u,
|
|
644
644
|
R,
|
|
645
645
|
f,
|
|
646
646
|
g,
|
|
647
647
|
t,
|
|
648
|
-
|
|
649
|
-
|
|
648
|
+
S.start,
|
|
649
|
+
S.end,
|
|
650
650
|
h && k === 0 ? h : "",
|
|
651
651
|
n + c
|
|
652
652
|
);
|
|
@@ -671,7 +671,7 @@ function ci(s, t, e) {
|
|
|
671
671
|
if (s.spacers[i] === m.IMAGE && ((n = s.imageAt(i)) != null && n.float)) return !0;
|
|
672
672
|
return !1;
|
|
673
673
|
}
|
|
674
|
-
function
|
|
674
|
+
function bn(s, t) {
|
|
675
675
|
if (t.list !== "ol")
|
|
676
676
|
return t.list === "none" && s.clear(), 1;
|
|
677
677
|
const e = t.indent ?? 0, n = (s.get(e) ?? 0) + 1;
|
|
@@ -682,44 +682,44 @@ function Sn(s, t) {
|
|
|
682
682
|
}
|
|
683
683
|
function Ue(s, t, e, n, i, r, o, a, l, c, h, d) {
|
|
684
684
|
let u = 0, f = 20;
|
|
685
|
-
for (const
|
|
686
|
-
if (
|
|
687
|
-
const k = $t(
|
|
685
|
+
for (const b of e)
|
|
686
|
+
if (b.kind === "image") {
|
|
687
|
+
const k = $t(b.entity, r);
|
|
688
688
|
u += k.width, f = Math.max(f, k.height);
|
|
689
689
|
} else
|
|
690
|
-
u += J(
|
|
690
|
+
u += J(b.text, b.style), f = Math.max(f, Xt(b.style));
|
|
691
691
|
if (e.length === 0) {
|
|
692
|
-
const
|
|
693
|
-
f = Xt(
|
|
692
|
+
const b = yt(s, l, t);
|
|
693
|
+
f = Xt(b);
|
|
694
694
|
}
|
|
695
695
|
let g = 0;
|
|
696
696
|
o === "center" && (g = Math.max(0, (r - u) / 2)), o === "right" && (g = Math.max(0, r - u));
|
|
697
697
|
const y = [], E = [], A = [{ index: l, x: n + g }];
|
|
698
698
|
let w = n + g;
|
|
699
|
-
for (const
|
|
700
|
-
if (
|
|
701
|
-
const k = $t(
|
|
699
|
+
for (const b of e)
|
|
700
|
+
if (b.kind === "image") {
|
|
701
|
+
const k = $t(b.entity, r);
|
|
702
702
|
E.push({
|
|
703
|
-
index:
|
|
703
|
+
index: b.index,
|
|
704
704
|
x: w,
|
|
705
705
|
y: i + Math.max(0, (f - k.height) / 2),
|
|
706
706
|
w: k.width,
|
|
707
707
|
h: k.height,
|
|
708
|
-
entity:
|
|
709
|
-
}), w += k.width, A.push({ index:
|
|
708
|
+
entity: b.entity
|
|
709
|
+
}), w += k.width, A.push({ index: b.index + 1, x: w });
|
|
710
710
|
} else {
|
|
711
711
|
let k = w;
|
|
712
|
-
for (let
|
|
713
|
-
const I =
|
|
712
|
+
for (let S = 0; S < b.text.length; S++) {
|
|
713
|
+
const I = b.text[S], T = J(I, b.style);
|
|
714
714
|
y.push({
|
|
715
|
-
index:
|
|
715
|
+
index: b.index + S,
|
|
716
716
|
x: k,
|
|
717
717
|
y: i,
|
|
718
718
|
w: T,
|
|
719
719
|
h: f,
|
|
720
720
|
text: I,
|
|
721
|
-
style:
|
|
722
|
-
}), k += T, A.push({ index:
|
|
721
|
+
style: b.style
|
|
722
|
+
}), k += T, A.push({ index: b.index + S + 1, x: k });
|
|
723
723
|
}
|
|
724
724
|
w = k;
|
|
725
725
|
}
|
|
@@ -787,15 +787,15 @@ function di(s, t, e, n, i) {
|
|
|
787
787
|
const f = t.rows[u], g = [];
|
|
788
788
|
let y = 32, E = e;
|
|
789
789
|
for (let A = 0; A < r; A++) {
|
|
790
|
-
const w = f.cells[A], R = c[A],
|
|
791
|
-
let
|
|
790
|
+
const w = f.cells[A], R = c[A], b = Math.max(1, R - _t * 2), k = [];
|
|
791
|
+
let S = d + _t;
|
|
792
792
|
const I = /* @__PURE__ */ new Map();
|
|
793
793
|
if (w)
|
|
794
794
|
for (const K of w.paragraphs) {
|
|
795
|
-
const F = vn(s, K.start, K.end, E + _t,
|
|
796
|
-
k.push(F),
|
|
795
|
+
const F = vn(s, K.start, K.end, E + _t, S, b, bn(I, s.paragraphPropsAt(K.start)));
|
|
796
|
+
k.push(F), S += F.h;
|
|
797
797
|
}
|
|
798
|
-
const T = Math.max(32,
|
|
798
|
+
const T = Math.max(32, S - d + _t);
|
|
799
799
|
y = Math.max(y, T), g.push({
|
|
800
800
|
row: u,
|
|
801
801
|
col: A,
|
|
@@ -828,7 +828,7 @@ function ui(s, t) {
|
|
|
828
828
|
return e ? `${e.slice.text}:${e.slice.styles.length}:${e.slice.entities.length}` : t;
|
|
829
829
|
}
|
|
830
830
|
function fi(s) {
|
|
831
|
-
if (s.kind !== "
|
|
831
|
+
if (s.kind !== "hostSlot") return "";
|
|
832
832
|
try {
|
|
833
833
|
return `${s.hostType ?? ""}:${JSON.stringify(s.data ?? null)}`;
|
|
834
834
|
} catch {
|
|
@@ -955,8 +955,8 @@ function Q(s, t = Ut, e, n = { x: fe, y: pe }, i = 0) {
|
|
|
955
955
|
let c = o;
|
|
956
956
|
const h = /* @__PURE__ */ new Map();
|
|
957
957
|
let d = [], u = 1 / 0, f = -1 / 0;
|
|
958
|
-
const g = (k,
|
|
959
|
-
u = Math.min(u, k), f = Math.max(f,
|
|
958
|
+
const g = (k, S) => {
|
|
959
|
+
u = Math.min(u, k), f = Math.max(f, S);
|
|
960
960
|
};
|
|
961
961
|
(!e || e.contentWidth !== t) && g(0, 1 / 0);
|
|
962
962
|
const y = new pi(s.styles), E = /* @__PURE__ */ new Map();
|
|
@@ -968,7 +968,7 @@ function Q(s, t = Ut, e, n = { x: fe, y: pe }, i = 0) {
|
|
|
968
968
|
}
|
|
969
969
|
for (const k of V(s.spacers))
|
|
970
970
|
if (k.kind === "paragraph") {
|
|
971
|
-
const
|
|
971
|
+
const S = s.paragraphPropsAt(k.start), I = bn(h, S);
|
|
972
972
|
d = d.filter(($) => $.y + $.h > c + 0.5);
|
|
973
973
|
const T = d.map(($) => `${$.side}:${Math.round($.w)}x${Math.round(Math.max(0, $.y + $.h - c))}`).join(","), K = gi(s, y, k.start, k.end, t, I, T), F = E.get(K);
|
|
974
974
|
let H;
|
|
@@ -978,15 +978,15 @@ function Q(s, t = Ut, e, n = { x: fe, y: pe }, i = 0) {
|
|
|
978
978
|
a.push(H), c += H.h;
|
|
979
979
|
} else {
|
|
980
980
|
h.clear();
|
|
981
|
-
const
|
|
981
|
+
const S = ki(s, y, k, t), I = E.get(S);
|
|
982
982
|
let T;
|
|
983
|
-
I && "cells" in I && I.hash ===
|
|
983
|
+
I && "cells" in I && I.hash === S ? (T = wi(I, c - I.y, k.start - I.start), T.hash = S, Ct.reused++, Math.abs(I.y - c) > 0.5 && g(Math.min(I.y, c), Math.max(I.y + I.h, c + T.h))) : (T = di(s, k, r, c, t), T.hash = S, Ct.laidOut++, g(c, c + T.h)), l.push(T), c += T.h + 12;
|
|
984
984
|
}
|
|
985
985
|
if (e) {
|
|
986
|
-
const k = new Map(Ke(a).map((
|
|
987
|
-
for (const
|
|
988
|
-
const I = k.get(
|
|
989
|
-
(!I || I.x !==
|
|
986
|
+
const k = new Map(Ke(a).map((S) => [S.entity.id, S]));
|
|
987
|
+
for (const S of Ke(e.paragraphs)) {
|
|
988
|
+
const I = k.get(S.entity.id);
|
|
989
|
+
(!I || I.x !== S.x || I.y !== S.y || I.w !== S.w || I.h !== S.h) && g(S.y, S.y + S.h);
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
992
|
const A = c + n.y;
|
|
@@ -994,19 +994,19 @@ function Q(s, t = Ut, e, n = { x: fe, y: pe }, i = 0) {
|
|
|
994
994
|
const w = u < f ? {
|
|
995
995
|
top: Math.max(0, u),
|
|
996
996
|
bottom: Number.isFinite(f) ? f : Math.max(A, (e == null ? void 0 : e.height) ?? 0)
|
|
997
|
-
} : { top: 0, bottom: 0 }, R = [],
|
|
997
|
+
} : { top: 0, bottom: 0 }, R = [], b = [];
|
|
998
998
|
for (const k of a) {
|
|
999
999
|
R.push(...k.lines);
|
|
1000
|
-
for (const
|
|
1001
|
-
|
|
1002
|
-
k.floats && (k.floats = oe(s, k.floats, i),
|
|
1000
|
+
for (const S of k.lines)
|
|
1001
|
+
S.images = oe(s, S.images, i), b.push(...S.images);
|
|
1002
|
+
k.floats && (k.floats = oe(s, k.floats, i), b.push(...k.floats));
|
|
1003
1003
|
}
|
|
1004
1004
|
for (const k of l)
|
|
1005
|
-
for (const
|
|
1006
|
-
for (const I of
|
|
1005
|
+
for (const S of k.cells)
|
|
1006
|
+
for (const I of S.paragraphs) {
|
|
1007
1007
|
R.push(...I.lines);
|
|
1008
1008
|
for (const T of I.lines)
|
|
1009
|
-
T.images = oe(s, T.images, i),
|
|
1009
|
+
T.images = oe(s, T.images, i), b.push(...T.images);
|
|
1010
1010
|
}
|
|
1011
1011
|
return {
|
|
1012
1012
|
width: t + n.x * 2,
|
|
@@ -1017,7 +1017,7 @@ function Q(s, t = Ut, e, n = { x: fe, y: pe }, i = 0) {
|
|
|
1017
1017
|
paragraphs: a,
|
|
1018
1018
|
tables: l,
|
|
1019
1019
|
lines: R,
|
|
1020
|
-
images:
|
|
1020
|
+
images: b,
|
|
1021
1021
|
dirty: w
|
|
1022
1022
|
};
|
|
1023
1023
|
}
|
|
@@ -1078,7 +1078,7 @@ function qe(s, t, e) {
|
|
|
1078
1078
|
function ae(s, t) {
|
|
1079
1079
|
const e = D(t), n = N(t);
|
|
1080
1080
|
if (e === n) return [];
|
|
1081
|
-
const i =
|
|
1081
|
+
const i = bi(s, e, n);
|
|
1082
1082
|
if (i) return i;
|
|
1083
1083
|
const r = [];
|
|
1084
1084
|
for (const o of s.lines) {
|
|
@@ -1087,9 +1087,9 @@ function ae(s, t) {
|
|
|
1087
1087
|
const a = o.caretStops, l = a.find((f) => f.index >= e) ?? a[0], c = a.filter((f) => f.index <= n), h = c[c.length - 1] ?? a[a.length - 1], d = Math.min(l.x, h.x), u = Math.max(l.x, h.x);
|
|
1088
1088
|
u > d && r.push({ x: d, y: o.y, w: u - d, h: o.h });
|
|
1089
1089
|
}
|
|
1090
|
-
return
|
|
1090
|
+
return Si(r, s.images);
|
|
1091
1091
|
}
|
|
1092
|
-
function
|
|
1092
|
+
function Si(s, t) {
|
|
1093
1093
|
let e = s;
|
|
1094
1094
|
for (const n of t) {
|
|
1095
1095
|
const i = [];
|
|
@@ -1108,7 +1108,7 @@ function bi(s, t) {
|
|
|
1108
1108
|
function vi(s, t) {
|
|
1109
1109
|
return s.images.find((e) => e.index === t) ?? null;
|
|
1110
1110
|
}
|
|
1111
|
-
function
|
|
1111
|
+
function bi(s, t, e) {
|
|
1112
1112
|
let n = null, i = null;
|
|
1113
1113
|
for (const r of s.tables) {
|
|
1114
1114
|
for (const o of r.cells)
|
|
@@ -1379,7 +1379,7 @@ function Je(s, t) {
|
|
|
1379
1379
|
r && (r.hidden = i, r.innerHTML = Oi[e]), o && (o.hidden = i, o.textContent = Ie(t)), a && (a.hidden = !i, i && t.src ? a.src = t.src : a.removeAttribute("src")), l && (l.hidden = !0);
|
|
1380
1380
|
}
|
|
1381
1381
|
const Hi = {
|
|
1382
|
-
kind: "
|
|
1382
|
+
kind: "internalSlot",
|
|
1383
1383
|
keepAspectRatio: !1,
|
|
1384
1384
|
interactive: !0,
|
|
1385
1385
|
overlayOnCanvas: !0,
|
|
@@ -1549,7 +1549,7 @@ function Qe(s, t, e) {
|
|
|
1549
1549
|
Zt.set(s, i), zt.set(e.entity.id, i), Ui(t, e.entity.id, i);
|
|
1550
1550
|
}
|
|
1551
1551
|
const ji = {
|
|
1552
|
-
kind: "
|
|
1552
|
+
kind: "hostSlot",
|
|
1553
1553
|
keepAspectRatio: !1,
|
|
1554
1554
|
interactive: !0,
|
|
1555
1555
|
overlayOnCanvas: !0,
|
|
@@ -1559,7 +1559,7 @@ const ji = {
|
|
|
1559
1559
|
},
|
|
1560
1560
|
create(s) {
|
|
1561
1561
|
const t = document.createElement("span");
|
|
1562
|
-
t.className = "mini-embed mini-host mini-embed-interactive", t.dataset.kind = "
|
|
1562
|
+
t.className = "mini-embed mini-host mini-embed-interactive", t.dataset.kind = "hostSlot";
|
|
1563
1563
|
const e = document.createElement("span");
|
|
1564
1564
|
return e.className = "mini-host-inner", t.appendChild(e), Yt && Qe(t, e, s), t;
|
|
1565
1565
|
},
|
|
@@ -2046,7 +2046,7 @@ function wr(s, t) {
|
|
|
2046
2046
|
}
|
|
2047
2047
|
};
|
|
2048
2048
|
}
|
|
2049
|
-
function
|
|
2049
|
+
function Sr(s) {
|
|
2050
2050
|
return {
|
|
2051
2051
|
mutations: s.inverse,
|
|
2052
2052
|
inverse: Zi(s.mutations),
|
|
@@ -2129,7 +2129,7 @@ function jn(s, t, e) {
|
|
|
2129
2129
|
}
|
|
2130
2130
|
return r;
|
|
2131
2131
|
}
|
|
2132
|
-
function
|
|
2132
|
+
function br(s, t, e, n) {
|
|
2133
2133
|
return s.styles.find((i) => i.type === t && i.start <= e && i.end >= n) ?? null;
|
|
2134
2134
|
}
|
|
2135
2135
|
function Xn(s) {
|
|
@@ -2212,10 +2212,10 @@ function qt(s, t, e) {
|
|
|
2212
2212
|
let o = i, a = r;
|
|
2213
2213
|
for (const l of n.doc.styles)
|
|
2214
2214
|
l.type !== "link" || l.start >= r || l.end <= i || (o = Math.min(o, l.start), a = Math.max(a, l.end));
|
|
2215
|
-
Z(n, "link", o, a, null), Z(n, "link", i, r, { url: e }), At(n, i, r, { color:
|
|
2215
|
+
Z(n, "link", o, a, null), Z(n, "link", i, r, { url: e }), At(n, i, r, { color: be, underline: !0 });
|
|
2216
2216
|
};
|
|
2217
2217
|
}
|
|
2218
|
-
function
|
|
2218
|
+
function Se(s) {
|
|
2219
2219
|
return (t) => {
|
|
2220
2220
|
const e = t.doc.linkSpanAt(s);
|
|
2221
2221
|
if (!e) return;
|
|
@@ -2501,14 +2501,14 @@ class Zn {
|
|
|
2501
2501
|
innermostSlotAt(t) {
|
|
2502
2502
|
const e = this.blocksAt(t);
|
|
2503
2503
|
for (let n = e.length - 1; n >= 0; n--)
|
|
2504
|
-
if (e[n].kind === "
|
|
2504
|
+
if (e[n].kind === "virtualSlot") return e[n];
|
|
2505
2505
|
return null;
|
|
2506
2506
|
}
|
|
2507
2507
|
/** 含槽尾光标:`start <= i <= end` 的最内层 slot。 */
|
|
2508
2508
|
slotAtCaret(t) {
|
|
2509
2509
|
const e = this.clamp(t), n = this.innermostSlotAt(e);
|
|
2510
2510
|
if (n) return n;
|
|
2511
|
-
const i = [...this.virtualBlocks.values()].filter((o) => o.kind === "
|
|
2511
|
+
const i = [...this.virtualBlocks.values()].filter((o) => o.kind === "virtualSlot" && o.end === e);
|
|
2512
2512
|
if (!i.length) return null;
|
|
2513
2513
|
const r = gt(i, this.virtualBlocks);
|
|
2514
2514
|
return M(r[r.length - 1]);
|
|
@@ -2612,7 +2612,7 @@ function $r(s, t) {
|
|
|
2612
2612
|
}
|
|
2613
2613
|
return i.endsWith(m.PARAGRAPH) || (i += m.PARAGRAPH), { text: i, styles: r, entities: o };
|
|
2614
2614
|
}
|
|
2615
|
-
function
|
|
2615
|
+
function bt(s, t) {
|
|
2616
2616
|
return (e) => {
|
|
2617
2617
|
const n = e.doc.clamp(s), i = L({
|
|
2618
2618
|
...t,
|
|
@@ -2639,15 +2639,15 @@ function ts(s, t) {
|
|
|
2639
2639
|
if (t.parentId) {
|
|
2640
2640
|
const e = s.virtualBlocks.get(t.parentId);
|
|
2641
2641
|
if (!e) return "missing-parent";
|
|
2642
|
-
if (!
|
|
2643
|
-
if (e.kind === "
|
|
2642
|
+
if (!St(e, t)) return "outside-parent";
|
|
2643
|
+
if (e.kind === "virtualSlot") return "virtualSlot-parent";
|
|
2644
2644
|
}
|
|
2645
2645
|
for (const e of s.virtualBlocks.values())
|
|
2646
2646
|
if (e.id !== t.id && Ks(t, e))
|
|
2647
2647
|
return "cross";
|
|
2648
|
-
if (t.kind === "
|
|
2648
|
+
if (t.kind === "virtualSlot") {
|
|
2649
2649
|
for (const e of s.virtualBlocks.values())
|
|
2650
|
-
if (e.id !== t.id && (e.parentId === t.id ||
|
|
2650
|
+
if (e.id !== t.id && (e.parentId === t.id || St(t, e) && e.id !== t.parentId))
|
|
2651
2651
|
return "slot-child";
|
|
2652
2652
|
}
|
|
2653
2653
|
return null;
|
|
@@ -2656,14 +2656,14 @@ function Dr(s, t, e, n) {
|
|
|
2656
2656
|
const i = { start: t, end: e };
|
|
2657
2657
|
let r = null;
|
|
2658
2658
|
for (const o of s.virtualBlocks.values())
|
|
2659
|
-
n && o.id === n ||
|
|
2659
|
+
n && o.id === n || St(o, i) && (!r || o.end - o.start < r.end - r.start) && (r = o);
|
|
2660
2660
|
return (r == null ? void 0 : r.id) ?? null;
|
|
2661
2661
|
}
|
|
2662
2662
|
function Le(s) {
|
|
2663
2663
|
return (t) => {
|
|
2664
2664
|
const e = t.doc, n = e.clamp(Math.min(s.start, s.end)), i = e.clamp(Math.max(s.start, s.end));
|
|
2665
2665
|
if (i <= n) return null;
|
|
2666
|
-
const r = s.id && !e.virtualBlocks.has(s.id) ? s.id : Yn(), o = s.parentId !== void 0 ? s.parentId : Dr(e, n, i, r), a = s.kind === "
|
|
2666
|
+
const r = s.id && !e.virtualBlocks.has(s.id) ? s.id : Yn(), o = s.parentId !== void 0 ? s.parentId : Dr(e, n, i, r), a = s.kind === "virtualSlot" ? s.placeholder ?? e.spacers.slice(n, i) : s.placeholder, l = s.kind === "virtualSlot" ? s.empty ?? (a != null && e.spacers.slice(n, i) === a) : s.empty, c = {
|
|
2667
2667
|
id: r,
|
|
2668
2668
|
parentId: o,
|
|
2669
2669
|
kind: s.kind,
|
|
@@ -2676,7 +2676,7 @@ function Le(s) {
|
|
|
2676
2676
|
if (ts(e, c)) return null;
|
|
2677
2677
|
t.emit(Bt(c));
|
|
2678
2678
|
for (const d of [...e.virtualBlocks.values()])
|
|
2679
|
-
d.id !== r && d.parentId === o &&
|
|
2679
|
+
d.id !== r && d.parentId === o && St(c, d) && d.id !== r && t.emit(It(d.id, { ...d, parentId: r }));
|
|
2680
2680
|
return r;
|
|
2681
2681
|
};
|
|
2682
2682
|
}
|
|
@@ -2709,7 +2709,7 @@ function ss(s, t, e, n, i, r) {
|
|
|
2709
2709
|
function ct(s) {
|
|
2710
2710
|
return (t) => {
|
|
2711
2711
|
const e = t.doc.blockById(s);
|
|
2712
|
-
if (!e || e.kind !== "
|
|
2712
|
+
if (!e || e.kind !== "virtualSlot") return !1;
|
|
2713
2713
|
const n = e.placeholder ?? "";
|
|
2714
2714
|
if (!n) return !1;
|
|
2715
2715
|
const i = e.start, r = e.end, o = fn(e, Re(t.doc));
|
|
@@ -2724,7 +2724,7 @@ function Nt(s) {
|
|
|
2724
2724
|
function et(s, t, e) {
|
|
2725
2725
|
return (n) => {
|
|
2726
2726
|
const i = n.doc.blockById(s);
|
|
2727
|
-
if (!i || i.kind !== "
|
|
2727
|
+
if (!i || i.kind !== "virtualSlot") return null;
|
|
2728
2728
|
const r = Nt(t), o = i.start, a = i.end, l = fn(i, Re(n.doc)), c = e ?? {
|
|
2729
2729
|
...xe(n.doc, o),
|
|
2730
2730
|
...Ws(i.chrome)
|
|
@@ -2755,7 +2755,7 @@ function is(s, t, e) {
|
|
|
2755
2755
|
...o,
|
|
2756
2756
|
start: Math.min(o.start, t),
|
|
2757
2757
|
end: Math.max(o.end, e),
|
|
2758
|
-
empty: o.kind === "
|
|
2758
|
+
empty: o.kind === "virtualSlot" ? !1 : o.empty
|
|
2759
2759
|
};
|
|
2760
2760
|
(a.start !== o.start || a.end !== o.end || a.empty !== o.empty) && n.emit(It(o.id, a));
|
|
2761
2761
|
}
|
|
@@ -2909,7 +2909,7 @@ function ls(s) {
|
|
|
2909
2909
|
if (r.kind === "list")
|
|
2910
2910
|
return dt(e, i.start).list === r.list ? n : o(r.consume, { list: r.list, heading: 0 });
|
|
2911
2911
|
if (r.kind === "code-block")
|
|
2912
|
-
return P(t, i.start, i.start + r.consume), C(t),
|
|
2912
|
+
return P(t, i.start, i.start + r.consume), C(t), bt(i.start, {
|
|
2913
2913
|
kind: "code",
|
|
2914
2914
|
width: 680,
|
|
2915
2915
|
height: 80,
|
|
@@ -2918,7 +2918,7 @@ function ls(s) {
|
|
|
2918
2918
|
})(t);
|
|
2919
2919
|
if (r.kind === "formula") {
|
|
2920
2920
|
const l = i.start + r.matchStart;
|
|
2921
|
-
return P(t, l, i.start + r.matchEnd), C(t),
|
|
2921
|
+
return P(t, l, i.start + r.matchEnd), C(t), bt(l, {
|
|
2922
2922
|
kind: "formula",
|
|
2923
2923
|
width: 200,
|
|
2924
2924
|
height: 48,
|
|
@@ -3024,7 +3024,7 @@ function Vr(s) {
|
|
|
3024
3024
|
const t = [], e = /(\*\*\*(.+?)\*\*\*|\*\*(.+?)\*\*|\*(.+?)\*|~~(.+?)~~|__(.+?)__|\[([^\]]+)\]\(([^)]+)\))/g;
|
|
3025
3025
|
let n = 0, i;
|
|
3026
3026
|
for (; i = e.exec(s); )
|
|
3027
|
-
i.index > n && t.push({ text: s.slice(n, i.index), style: {} }), i[2] !== void 0 ? t.push({ text: i[2], style: { bold: !0, italic: !0 } }) : i[3] !== void 0 ? t.push({ text: i[3], style: { bold: !0 } }) : i[4] !== void 0 ? t.push({ text: i[4], style: { italic: !0 } }) : i[5] !== void 0 ? t.push({ text: i[5], style: { strikethrough: !0 } }) : i[6] !== void 0 ? t.push({ text: i[6], style: { underline: !0 } }) : i[7] !== void 0 && t.push({ text: i[7], style: { color:
|
|
3027
|
+
i.index > n && t.push({ text: s.slice(n, i.index), style: {} }), i[2] !== void 0 ? t.push({ text: i[2], style: { bold: !0, italic: !0 } }) : i[3] !== void 0 ? t.push({ text: i[3], style: { bold: !0 } }) : i[4] !== void 0 ? t.push({ text: i[4], style: { italic: !0 } }) : i[5] !== void 0 ? t.push({ text: i[5], style: { strikethrough: !0 } }) : i[6] !== void 0 ? t.push({ text: i[6], style: { underline: !0 } }) : i[7] !== void 0 && t.push({ text: i[7], style: { color: be, underline: !0 }, url: i[8] }), n = i.index + i[0].length;
|
|
3028
3028
|
return n < s.length && t.push({ text: s.slice(n), style: {} }), t.filter((r) => r.text.length > 0);
|
|
3029
3029
|
}
|
|
3030
3030
|
function _r(s) {
|
|
@@ -3197,7 +3197,7 @@ function ms(s, t) {
|
|
|
3197
3197
|
};
|
|
3198
3198
|
}
|
|
3199
3199
|
function Fe(s, t) {
|
|
3200
|
-
return (e) => e.doc.fragments.has(t) ?
|
|
3200
|
+
return (e) => e.doc.fragments.has(t) ? bt(s, {
|
|
3201
3201
|
kind: "ref",
|
|
3202
3202
|
fragmentId: t,
|
|
3203
3203
|
width: 680,
|
|
@@ -3234,7 +3234,7 @@ const ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3234
3234
|
ensureParagraphAfter: Jn,
|
|
3235
3235
|
expectedParagraphSpans: Xn,
|
|
3236
3236
|
fillSlot: et,
|
|
3237
|
-
insertImage:
|
|
3237
|
+
insertImage: bt,
|
|
3238
3238
|
insertMarkdown: fs,
|
|
3239
3239
|
insertParagraph: wt,
|
|
3240
3240
|
insertRef: Fe,
|
|
@@ -3248,7 +3248,7 @@ const ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3248
3248
|
pasteText: ps,
|
|
3249
3249
|
promoteRange: ms,
|
|
3250
3250
|
rangeIsOnlyMarkers: Kn,
|
|
3251
|
-
removeLink:
|
|
3251
|
+
removeLink: Se,
|
|
3252
3252
|
removeVirtualBlock: es,
|
|
3253
3253
|
resolveParagraphProps: dt,
|
|
3254
3254
|
resolveTextProps: xe,
|
|
@@ -3256,7 +3256,7 @@ const ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3256
3256
|
scopeContext: Un,
|
|
3257
3257
|
setTableColWidths: jt,
|
|
3258
3258
|
slotInlineText: Nt,
|
|
3259
|
-
spanCovering:
|
|
3259
|
+
spanCovering: br,
|
|
3260
3260
|
textSegments: jn,
|
|
3261
3261
|
unlinkRef: gs,
|
|
3262
3262
|
updateImage: G,
|
|
@@ -3325,7 +3325,7 @@ class Kr {
|
|
|
3325
3325
|
for (let i = t - 1; i >= 0; i--)
|
|
3326
3326
|
e = this.rebase(e, i);
|
|
3327
3327
|
this.undos.splice(t, 1);
|
|
3328
|
-
const n =
|
|
3328
|
+
const n = Sr(e);
|
|
3329
3329
|
return this.redos.unshift(e), this.batchOpen = !1, n;
|
|
3330
3330
|
}
|
|
3331
3331
|
popForRedo() {
|
|
@@ -3649,7 +3649,7 @@ class no {
|
|
|
3649
3649
|
t.fill();
|
|
3650
3650
|
}
|
|
3651
3651
|
paintVBlock(t, e) {
|
|
3652
|
-
const n = e.chrome, i = n.radius ?? (e.kind === "
|
|
3652
|
+
const n = e.chrome, i = n.radius ?? (e.kind === "virtualSlot" ? 4 : 6);
|
|
3653
3653
|
n.background && (t.beginPath(), t.roundRect(e.x, e.y, e.w, e.h, i), t.fillStyle = n.background, t.fill()), n.borderWidth && n.borderColor && (t.beginPath(), t.roundRect(e.x + 0.5, e.y + 0.5, Math.max(0, e.w - 1), Math.max(0, e.h - 1), i), t.strokeStyle = n.borderColor, t.lineWidth = n.borderWidth, t.stroke());
|
|
3654
3654
|
}
|
|
3655
3655
|
strokeVBlockOutline(t, e) {
|
|
@@ -3790,7 +3790,7 @@ function ro(s) {
|
|
|
3790
3790
|
function oo(s) {
|
|
3791
3791
|
const t = document.createElement("span");
|
|
3792
3792
|
t.className = "mini-vblock", t.dataset.id = s.id;
|
|
3793
|
-
const e = s.chrome, n = e.radius ?? (s.kind === "
|
|
3793
|
+
const e = s.chrome, n = e.radius ?? (s.kind === "virtualSlot" ? 4 : 6), i = e.borderWidth ? `${e.borderWidth}px solid ${e.borderColor ?? "transparent"}` : "none";
|
|
3794
3794
|
return t.style.cssText = [
|
|
3795
3795
|
`left:${s.x}px`,
|
|
3796
3796
|
`top:${s.y}px`,
|
|
@@ -3810,7 +3810,7 @@ function ao(s) {
|
|
|
3810
3810
|
}
|
|
3811
3811
|
return t;
|
|
3812
3812
|
}
|
|
3813
|
-
class
|
|
3813
|
+
class So {
|
|
3814
3814
|
constructor(t, e = {}) {
|
|
3815
3815
|
/** 编辑器根节点,已挂载到构造时传入的容器下。 */
|
|
3816
3816
|
p(this, "root");
|
|
@@ -4021,7 +4021,7 @@ class bo {
|
|
|
4021
4021
|
p(this, "onResizeStart", (t) => {
|
|
4022
4022
|
t.preventDefault(), t.stopPropagation();
|
|
4023
4023
|
const e = this.selectedImage();
|
|
4024
|
-
!e || e.entity.kind === "
|
|
4024
|
+
!e || e.entity.kind === "internalSlot" || e.entity.kind === "ref" || (this.resizing = { id: e.entity.id, startX: t.clientX, startW: e.entity.width, startH: e.entity.height });
|
|
4025
4025
|
});
|
|
4026
4026
|
p(this, "onCopy", (t) => {
|
|
4027
4027
|
!this.isFocused() || this.isEmbedChromeFocused() || x(this.sel) || (t.preventDefault(), this.writeClipboard(t.clipboardData));
|
|
@@ -4239,7 +4239,7 @@ class bo {
|
|
|
4239
4239
|
this.insertEmbed(
|
|
4240
4240
|
{
|
|
4241
4241
|
id: tt(),
|
|
4242
|
-
kind: "
|
|
4242
|
+
kind: "hostSlot",
|
|
4243
4243
|
hostType: t,
|
|
4244
4244
|
data: e,
|
|
4245
4245
|
width: (n == null ? void 0 : n.width) ?? 120,
|
|
@@ -4490,7 +4490,7 @@ class bo {
|
|
|
4490
4490
|
const r = this.selectedVblock();
|
|
4491
4491
|
if (!this.refEdit && ((a = this.stackTop()) == null ? void 0 : a.mode) === "selected" && (r == null ? void 0 : r.kind) === "region")
|
|
4492
4492
|
return;
|
|
4493
|
-
if (!this.refEdit && ((l = this.stackTop()) == null ? void 0 : l.mode) === "selected" && (r == null ? void 0 : r.kind) === "
|
|
4493
|
+
if (!this.refEdit && ((l = this.stackTop()) == null ? void 0 : l.mode) === "selected" && (r == null ? void 0 : r.kind) === "virtualSlot") {
|
|
4494
4494
|
ct(r.id)(t);
|
|
4495
4495
|
const c = t.doc.blockById(r.id);
|
|
4496
4496
|
t.select(c ? { anchor: c.start, focus: c.end } : v(n));
|
|
@@ -4574,7 +4574,7 @@ class bo {
|
|
|
4574
4574
|
((n = this.stackTop()) == null ? void 0 : n.mode) === "selected" && (e == null ? void 0 : e.kind) === "region" || (this.runEdit("insert.text", (r) => {
|
|
4575
4575
|
var f;
|
|
4576
4576
|
const o = r.doc.blockById((e == null ? void 0 : e.id) ?? "");
|
|
4577
|
-
if (((f = this.stackTop()) == null ? void 0 : f.mode) === "selected" && (o == null ? void 0 : o.kind) === "
|
|
4577
|
+
if (((f = this.stackTop()) == null ? void 0 : f.mode) === "selected" && (o == null ? void 0 : o.kind) === "virtualSlot") {
|
|
4578
4578
|
const g = et(o.id, t)(r);
|
|
4579
4579
|
g != null && r.select(v(g));
|
|
4580
4580
|
return;
|
|
@@ -4589,7 +4589,7 @@ class bo {
|
|
|
4589
4589
|
const h = this.typingStyle ?? r.doc.textPropsAt(r.selection().focus), d = r.selection().focus;
|
|
4590
4590
|
let u = Rt(d, t, h)(r);
|
|
4591
4591
|
!this.refEdit && Cr(t) && (u = ls(u)(r)), r.select(v(u));
|
|
4592
|
-
}), ((i = this.stackTop()) == null ? void 0 : i.mode) === "selected" && (e == null ? void 0 : e.kind) === "
|
|
4592
|
+
}), ((i = this.stackTop()) == null ? void 0 : i.mode) === "selected" && (e == null ? void 0 : e.kind) === "virtualSlot" && this.selectVblock(e.id, "editing"));
|
|
4593
4593
|
}
|
|
4594
4594
|
pasteText(t) {
|
|
4595
4595
|
this.pasteClipboard(t ? ho(t) : null);
|
|
@@ -4612,7 +4612,7 @@ class bo {
|
|
|
4612
4612
|
}
|
|
4613
4613
|
const d = this.typingStyle ?? a.doc.textPropsAt(a.selection().focus), u = ps(a.selection().focus, n, d)(a);
|
|
4614
4614
|
a.select(v(u));
|
|
4615
|
-
}), ((i = this.stackTop()) == null ? void 0 : i.mode) === "selected" && ((r = this.selectedVblock()) == null ? void 0 : r.kind) === "
|
|
4615
|
+
}), ((i = this.stackTop()) == null ? void 0 : i.mode) === "selected" && ((r = this.selectedVblock()) == null ? void 0 : r.kind) === "virtualSlot")) {
|
|
4616
4616
|
const a = (o = this.selectedVblock()) == null ? void 0 : o.id;
|
|
4617
4617
|
a && this.selectVblock(a, "editing");
|
|
4618
4618
|
}
|
|
@@ -4620,7 +4620,7 @@ class bo {
|
|
|
4620
4620
|
insertParagraph(t) {
|
|
4621
4621
|
if (this.disabled || this.enterSelectedVblock() || this.selectedRegion()) return;
|
|
4622
4622
|
const e = this.editingSlot(), n = this.selectedImage();
|
|
4623
|
-
if ((n == null ? void 0 : n.entity.kind) === "formula" && this.beginFormulaEdit(n.entity.id) || (n == null ? void 0 : n.entity.kind) === "
|
|
4623
|
+
if ((n == null ? void 0 : n.entity.kind) === "formula" && this.beginFormulaEdit(n.entity.id) || (n == null ? void 0 : n.entity.kind) === "internalSlot" && this.beginSlotActivate(n.entity.id) || (n == null ? void 0 : n.entity.kind) === "ref" && this.beginRefEdit(n.entity.id) || (n == null ? void 0 : n.entity.kind) === "hostSlot" && !(t != null && t.shift) && Xi(n.entity.id, { key: "Enter", shift: !1 }))
|
|
4624
4624
|
return;
|
|
4625
4625
|
const i = this.typingStyle ? { ...this.typingStyle } : null, r = { ...this.currentTextStyle() }, a = this.targetDoc().paragraphPropsAt(this.targetSel().focus).heading ?? 0;
|
|
4626
4626
|
this.runEdit("insert.paragraph", (l) => {
|
|
@@ -4710,7 +4710,7 @@ class bo {
|
|
|
4710
4710
|
const l = window.prompt("编辑链接,留空则移除", t.props.url);
|
|
4711
4711
|
if (l === null) return;
|
|
4712
4712
|
this.runEdit("style.link", (c) => {
|
|
4713
|
-
l.trim() ? qt(t.start, t.end, l.trim())(c) :
|
|
4713
|
+
l.trim() ? qt(t.start, t.end, l.trim())(c) : Se(c.selection().focus)(c);
|
|
4714
4714
|
});
|
|
4715
4715
|
return;
|
|
4716
4716
|
}
|
|
@@ -4718,7 +4718,7 @@ class bo {
|
|
|
4718
4718
|
if (o === null) return;
|
|
4719
4719
|
const a = o.trim();
|
|
4720
4720
|
if (!a) {
|
|
4721
|
-
t && this.runEdit("style.link", (l) =>
|
|
4721
|
+
t && this.runEdit("style.link", (l) => Se(l.selection().focus)(l));
|
|
4722
4722
|
return;
|
|
4723
4723
|
}
|
|
4724
4724
|
this.runEdit("style.link", (l) => {
|
|
@@ -4742,7 +4742,7 @@ class bo {
|
|
|
4742
4742
|
const n = this.targetDoc(), i = { ...t, ...kt(t.kind).measure(t, this.innerContentWidth(), n) };
|
|
4743
4743
|
this.runEdit("embed.insert", (r) => {
|
|
4744
4744
|
e === "cursor" ? this.deleteSelectionIfNeeded(r) : r.select(v(this.resolveInsertIndex(e, r.doc)));
|
|
4745
|
-
const o =
|
|
4745
|
+
const o = bt(r.selection().focus, i)(r);
|
|
4746
4746
|
r.select({ anchor: o - 1, focus: o });
|
|
4747
4747
|
});
|
|
4748
4748
|
}
|
|
@@ -4780,7 +4780,7 @@ class bo {
|
|
|
4780
4780
|
const e = tt();
|
|
4781
4781
|
this.insertEmbed({
|
|
4782
4782
|
id: e,
|
|
4783
|
-
kind: "
|
|
4783
|
+
kind: "internalSlot",
|
|
4784
4784
|
slotKind: t,
|
|
4785
4785
|
label: Tn(t),
|
|
4786
4786
|
slotOptions: t === "select" ? ["小美", "阿力"] : void 0,
|
|
@@ -4886,7 +4886,7 @@ class bo {
|
|
|
4886
4886
|
};
|
|
4887
4887
|
this.runEdit("embed.insert", (f) => {
|
|
4888
4888
|
this.deleteSelectionIfNeeded(f);
|
|
4889
|
-
const g =
|
|
4889
|
+
const g = bt(f.selection().focus, u)(f);
|
|
4890
4890
|
f.select({ anchor: g - 1, focus: g });
|
|
4891
4891
|
});
|
|
4892
4892
|
};
|
|
@@ -5065,7 +5065,7 @@ class bo {
|
|
|
5065
5065
|
this.embedFrame.style.display = "none", this.handle.style.display = "none";
|
|
5066
5066
|
return;
|
|
5067
5067
|
}
|
|
5068
|
-
const e = t.entity.kind === "
|
|
5068
|
+
const e = t.entity.kind === "internalSlot", n = t.entity.kind === "ref", i = t.entity.kind === "hostSlot";
|
|
5069
5069
|
this.embedFrame.classList.toggle("is-slot", e), this.embedFrame.classList.toggle("is-ref", n), this.embedFrame.classList.toggle("is-image", e && t.entity.slotKind === "image"), this.embedFrame.style.display = this.refEdit || i ? "none" : "block", this.embedFrame.style.left = `${t.x}px`, this.embedFrame.style.top = `${t.y}px`, this.embedFrame.style.width = `${t.w}px`, this.embedFrame.style.height = `${t.h}px`, this.handle.style.display = e || n || i ? "none" : "block", this.handle.style.left = `${t.x + t.w - 5}px`, this.handle.style.top = `${t.y + t.h - 5}px`;
|
|
5070
5070
|
}
|
|
5071
5071
|
writeClipboard(t) {
|
|
@@ -5213,13 +5213,13 @@ class bo {
|
|
|
5213
5213
|
const t = this.stackTop();
|
|
5214
5214
|
if (!t || t.mode !== "editing") return null;
|
|
5215
5215
|
const e = this.doc.blockById(t.id);
|
|
5216
|
-
return (e == null ? void 0 : e.kind) === "
|
|
5216
|
+
return (e == null ? void 0 : e.kind) === "virtualSlot" ? e : null;
|
|
5217
5217
|
}
|
|
5218
5218
|
editingSlotIn(t) {
|
|
5219
5219
|
const e = this.stackTop();
|
|
5220
5220
|
if (!e || e.mode !== "editing") return null;
|
|
5221
5221
|
const n = t.blockById(e.id);
|
|
5222
|
-
return (n == null ? void 0 : n.kind) === "
|
|
5222
|
+
return (n == null ? void 0 : n.kind) === "virtualSlot" ? n : null;
|
|
5223
5223
|
}
|
|
5224
5224
|
selectionCoversSlot(t, e) {
|
|
5225
5225
|
const n = t.selection();
|
|
@@ -5230,7 +5230,7 @@ class bo {
|
|
|
5230
5230
|
var i, r;
|
|
5231
5231
|
if (this.selectedRegion()) return null;
|
|
5232
5232
|
const e = t.doc.blockById(((i = this.selectedVblock()) == null ? void 0 : i.id) ?? "");
|
|
5233
|
-
if (((r = this.stackTop()) == null ? void 0 : r.mode) === "selected" && (e == null ? void 0 : e.kind) === "
|
|
5233
|
+
if (((r = this.stackTop()) == null ? void 0 : r.mode) === "selected" && (e == null ? void 0 : e.kind) === "virtualSlot") return e;
|
|
5234
5234
|
const n = this.editingSlotIn(t.doc);
|
|
5235
5235
|
return n && (n.empty || this.selectionCoversSlot(t, n)) ? n : null;
|
|
5236
5236
|
}
|
|
@@ -5275,12 +5275,12 @@ class bo {
|
|
|
5275
5275
|
const t = this.stackTop(), e = t ? this.doc.blockById(t.id) : null;
|
|
5276
5276
|
if (!t || t.mode !== "selected" || !e) return !1;
|
|
5277
5277
|
const n = this.doc.listVirtualBlocks().filter((i) => i.parentId === e.id).sort((i, r) => i.start - r.start);
|
|
5278
|
-
return e.kind === "
|
|
5278
|
+
return e.kind === "virtualSlot" ? (this.selectVblock(e.id, "editing"), !0) : (n[0] && this.selectVblock(n[0].id, "selected"), !0);
|
|
5279
5279
|
}
|
|
5280
5280
|
handleVblockBackspace(t) {
|
|
5281
5281
|
const e = this.selectedVblock(), n = this.stackTop();
|
|
5282
5282
|
if ((n == null ? void 0 : n.mode) === "selected" && e)
|
|
5283
|
-
return e.kind === "
|
|
5283
|
+
return e.kind === "virtualSlot" && this.runEdit("delete.backward", (c) => {
|
|
5284
5284
|
ct(e.id)(c);
|
|
5285
5285
|
const h = c.doc.blockById(e.id);
|
|
5286
5286
|
h && c.select({ anchor: h.start, focus: h.end });
|
|
@@ -5375,7 +5375,7 @@ class bo {
|
|
|
5375
5375
|
w: i.w,
|
|
5376
5376
|
h: i.h,
|
|
5377
5377
|
outline: !0,
|
|
5378
|
-
radius: i.chrome.radius ?? (i.kind === "
|
|
5378
|
+
radius: i.chrome.radius ?? (i.kind === "virtualSlot" ? 4 : 6)
|
|
5379
5379
|
});
|
|
5380
5380
|
return e;
|
|
5381
5381
|
}
|
|
@@ -5460,7 +5460,7 @@ function fo(s) {
|
|
|
5460
5460
|
export {
|
|
5461
5461
|
no as CanvasPainter,
|
|
5462
5462
|
Zn as DocumentModel,
|
|
5463
|
-
|
|
5463
|
+
So as Editor,
|
|
5464
5464
|
pn as FONT_FAMILY,
|
|
5465
5465
|
io as HtmlPainter,
|
|
5466
5466
|
sn as INPUT_SHORTCUTS,
|