reactive-md 0.5.2 → 0.6.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/CHANGELOG-ch.md +47 -15
- package/CHANGELOG.md +47 -15
- package/CONTRIBUTING-ch.md +10 -5
- package/CONTRIBUTING.md +10 -5
- package/README-ch.md +38 -36
- package/README-en.md +45 -42
- package/README.md +45 -42
- package/SECURITY-ch.md +1 -1
- package/SECURITY.md +1 -1
- package/THIRD_PARTY_NOTICES.md +481 -1
- package/cli/build.mjs +1 -1
- package/cli/package.mjs +1 -0
- package/dist-library/authoring-DSC0VsNK.js +842 -0
- package/dist-library/{runtime-UiQPz5ZV.js → compiler-CRD88BMt.js} +8944 -5847
- package/dist-library/react-Dk94rcOp.js +59658 -0
- package/dist-library/reactive-md-authoring.js +1514 -0
- package/dist-library/reactive-md-editor.js +589 -570
- package/dist-library/reactive-md-print.css +284 -0
- package/dist-library/reactive-md-react-unstyled.js +1 -0
- package/dist-library/reactive-md-react.js +1 -13208
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +308 -1126
- package/dist-library/runtime-D8KbnCd0.js +498 -0
- package/dist-library/types/authoring/index.d.ts +24 -0
- package/dist-library/types/editor/command-types.d.ts +10 -0
- package/dist-library/types/editor/editor-commands.d.ts +2 -2
- package/dist-library/types/editor/editor-i18n.d.ts +1 -1
- package/dist-library/types/editor/native-components.d.ts +1 -1
- package/dist-library/types/editor/source-authoring.d.ts +5 -3
- package/dist-library/types/editor/types.d.ts +7 -10
- package/dist-library/types/local/LocalDocumentView.d.ts +4 -2
- package/dist-library/types/local/authoring.d.ts +9 -5
- package/dist-library/types/local/code-block.d.ts +3 -1
- package/dist-library/types/local/code-languages.d.ts +7 -0
- package/dist-library/types/local/compiled-data.d.ts +6 -0
- package/dist-library/types/local/compiler.d.ts +1 -0
- package/dist-library/types/local/diagnostics.d.ts +71 -0
- package/dist-library/types/local/diagram-layout.d.ts +69 -0
- package/dist-library/types/local/html-names.d.ts +6 -0
- package/dist-library/types/local/html-table.d.ts +25 -0
- package/dist-library/types/local/index.d.ts +1 -0
- package/dist-library/types/local/math-display.d.ts +73 -0
- package/dist-library/types/local/math-view.d.ts +2 -0
- package/dist-library/types/local/options.d.ts +3 -1
- package/dist-library/types/local/table-surface.d.ts +10 -0
- package/dist-library/types/local/types.d.ts +12 -0
- package/dist-library/types/local/visuals.d.ts +9 -0
- package/dist-library/types/local/worker.d.ts +3 -2
- package/dist-library/types/react/index.d.ts +1 -1
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +79 -51
- package/docs/README.md +84 -0
- package/docs/{compatibility-ch.md → compatibility/compatibility-ch.md} +28 -18
- package/docs/{compatibility-en.md → compatibility/compatibility-en.md} +28 -18
- package/docs/{source-versioning-ch.md → compatibility/source-versioning-ch.md} +2 -2
- package/docs/{source-versioning-en.md → compatibility/source-versioning-en.md} +2 -2
- package/docs/{component-development-ch.md → development/component-development-ch.md} +7 -7
- package/docs/{component-development-en.md → development/component-development-en.md} +7 -7
- package/docs/{component-protocol-ch.md → development/component-protocol-ch.md} +17 -17
- package/docs/{component-protocol-en.md → development/component-protocol-en.md} +17 -17
- package/docs/{performance-ch.md → development/performance-ch.md} +2 -2
- package/docs/{performance-en.md → development/performance-en.md} +2 -2
- package/docs/{releasing-ch.md → development/releasing-ch.md} +12 -12
- package/docs/{releasing-en.md → development/releasing-en.md} +12 -12
- package/docs/guides/local-guide-ch.md +513 -0
- package/docs/guides/local-guide-en.md +513 -0
- package/docs/{author-tools-ch.md → integration/author-tools-ch.md} +13 -7
- package/docs/{author-tools-en.md → integration/author-tools-en.md} +13 -7
- package/docs/{editor-ch.md → integration/editor-ch.md} +238 -235
- package/docs/{editor-en.md → integration/editor-en.md} +238 -235
- package/docs/{local-integration-ch.md → integration/local-integration-ch.md} +410 -390
- package/docs/{local-integration-en.md → integration/local-integration-en.md} +410 -390
- package/docs/{shareable-export-ch.md → integration/shareable-export-ch.md} +16 -4
- package/docs/{shareable-export-en.md → integration/shareable-export-en.md} +16 -4
- package/docs/{computations-formatting-ch.md → reference/computations-formatting-ch.md} +2 -2
- package/docs/{computations-formatting-en.md → reference/computations-formatting-en.md} +2 -2
- package/docs/{constraints-collections-ch.md → reference/constraints-collections-ch.md} +2 -2
- package/docs/{constraints-collections-en.md → reference/constraints-collections-en.md} +2 -2
- package/docs/{diagnostics-counting-ch.md → reference/diagnostics-counting-ch.md} +22 -2
- package/docs/{diagnostics-counting-en.md → reference/diagnostics-counting-en.md} +22 -2
- package/docs/{html-compatibility-ch.md → reference/html-compatibility-ch.md} +42 -4
- package/docs/{html-compatibility-en.md → reference/html-compatibility-en.md} +42 -4
- package/docs/{local-components-v2-ch.md → reference/local-components-v2-ch.md} +2 -2
- package/docs/{local-components-v2-en.md → reference/local-components-v2-en.md} +2 -2
- package/docs/{local-interaction-syntax-ch.md → reference/local-interaction-syntax-ch.md} +26 -7
- package/docs/{local-interaction-syntax-en.md → reference/local-interaction-syntax-en.md} +26 -7
- package/docs/{theme-protocol-ch.md → reference/theme-protocol-ch.md} +1 -1
- package/docs/{theme-protocol-en.md → reference/theme-protocol-en.md} +1 -1
- package/docs/{release-0.4.0-ch.md → releases/release-0.4.0-ch.md} +6 -6
- package/docs/{release-0.4.0-en.md → releases/release-0.4.0-en.md} +6 -6
- package/docs/{release-0.4.1-ch.md → releases/release-0.4.1-ch.md} +2 -2
- package/docs/{release-0.4.1-en.md → releases/release-0.4.1-en.md} +2 -2
- package/docs/{release-0.5.0-ch.md → releases/release-0.5.0-ch.md} +4 -4
- package/docs/{release-0.5.0-en.md → releases/release-0.5.0-en.md} +4 -4
- package/docs/{release-0.5.1-ch.md → releases/release-0.5.1-ch.md} +4 -4
- package/docs/{release-0.5.1-en.md → releases/release-0.5.1-en.md} +4 -4
- package/docs/{release-0.5.2-ch.md → releases/release-0.5.2-ch.md} +3 -3
- package/docs/{release-0.5.2-en.md → releases/release-0.5.2-en.md} +3 -3
- package/docs/releases/release-0.5.3-ch.md +25 -0
- package/docs/releases/release-0.5.3-en.md +25 -0
- package/docs/releases/release-0.6.0-ch.md +57 -0
- package/docs/releases/release-0.6.0-en.md +57 -0
- package/examples/conformance/README.md +4 -4
- package/examples/integration/README.md +10 -8
- package/examples/integration/worker/package.json +1 -1
- package/examples/local/README.md +5 -5
- package/examples/local/html-compat.reactive.md +19 -0
- package/package.json +20 -3
- package/docs/local-guide-ch.md +0 -967
- package/docs/local-guide-en.md +0 -967
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext as e, forwardRef as t, memo as n, useCallback as r, useContext as i, useEffect as a, useId as o, useImperativeHandle as s, useLayoutEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
2
2
|
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
3
|
-
import { analyzeLocalSource as
|
|
3
|
+
import { analyzeLocalSource as h, completeLocalSource as ee, formatLocalSource as g, renameLocalBinding as te } from "reactive-md";
|
|
4
4
|
// src/editor/extended-native-components.ts
|
|
5
5
|
var _ = [
|
|
6
6
|
{
|
|
@@ -117,7 +117,7 @@ var _ = [
|
|
|
117
117
|
],
|
|
118
118
|
template: "<steps label=\"Learning path\" bind=\"{{bind:lesson}}\">\n<step label=\"Observe\">\nChange a parameter.\n</step>\n<step label=\"Practice\">\nCheck an answer.\n</step>\n</steps>"
|
|
119
119
|
}
|
|
120
|
-
],
|
|
120
|
+
], v = {
|
|
121
121
|
jump: {
|
|
122
122
|
label: "跳转与锚点",
|
|
123
123
|
description: "跳到当前文档中的指定位置。",
|
|
@@ -208,7 +208,7 @@ var _ = [
|
|
|
208
208
|
],
|
|
209
209
|
template: "<steps label=\"学习路线\" bind=\"{{bind:lesson}}\">\n<step label=\"观察\">\n调整参数。\n</step>\n<step label=\"练习\">\n检查答案。\n</step>\n</steps>"
|
|
210
210
|
}
|
|
211
|
-
},
|
|
211
|
+
}, ne = {
|
|
212
212
|
en: {
|
|
213
213
|
sourceLabel: "Reactive MD source",
|
|
214
214
|
region: "Source editor",
|
|
@@ -231,7 +231,7 @@ var _ = [
|
|
|
231
231
|
split: "并排",
|
|
232
232
|
preview: "预览"
|
|
233
233
|
}
|
|
234
|
-
},
|
|
234
|
+
}, re = {
|
|
235
235
|
en: {
|
|
236
236
|
boldPlaceholder: "bold text",
|
|
237
237
|
italicPlaceholder: "italic text",
|
|
@@ -278,7 +278,7 @@ var _ = [
|
|
|
278
278
|
"示例 6"
|
|
279
279
|
]]
|
|
280
280
|
}
|
|
281
|
-
},
|
|
281
|
+
}, ie = {
|
|
282
282
|
en: {
|
|
283
283
|
toolbarLabel: "Document editing toolbar",
|
|
284
284
|
headingLabels: [
|
|
@@ -397,7 +397,7 @@ var _ = [
|
|
|
397
397
|
moreMenuLabel: "更多操作",
|
|
398
398
|
linkMenuItem: "链接"
|
|
399
399
|
}
|
|
400
|
-
},
|
|
400
|
+
}, y = {
|
|
401
401
|
en: {
|
|
402
402
|
groups: {
|
|
403
403
|
input: "Input controls",
|
|
@@ -417,7 +417,7 @@ var _ = [
|
|
|
417
417
|
hint: "提示反馈"
|
|
418
418
|
},
|
|
419
419
|
components: {
|
|
420
|
-
...
|
|
420
|
+
...v,
|
|
421
421
|
slider: {
|
|
422
422
|
label: "滑块",
|
|
423
423
|
description: "拖动滑块在指定范围内选择一个数值。",
|
|
@@ -715,22 +715,22 @@ var _ = [
|
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
},
|
|
719
|
-
function
|
|
720
|
-
return /* @__PURE__ */ p(
|
|
718
|
+
}, b = e("en");
|
|
719
|
+
function x({ locale: e, children: t }) {
|
|
720
|
+
return /* @__PURE__ */ p(b.Provider, {
|
|
721
721
|
value: e,
|
|
722
722
|
children: t
|
|
723
723
|
});
|
|
724
724
|
}
|
|
725
|
-
function
|
|
726
|
-
return i(
|
|
725
|
+
function ae() {
|
|
726
|
+
return i(b);
|
|
727
727
|
}
|
|
728
728
|
// src/editor/editor-commands.ts
|
|
729
|
-
function
|
|
729
|
+
function S(e, t) {
|
|
730
730
|
return typeof e != "number" || Number.isNaN(e) ? 0 : Math.min(Math.max(Math.trunc(e), 0), t);
|
|
731
731
|
}
|
|
732
|
-
function
|
|
733
|
-
let n =
|
|
732
|
+
function C(e, t) {
|
|
733
|
+
let n = S(t.start, e.length), r = S(t.end, e.length);
|
|
734
734
|
return n <= r ? {
|
|
735
735
|
start: n,
|
|
736
736
|
end: r
|
|
@@ -739,14 +739,14 @@ function S(e, t) {
|
|
|
739
739
|
end: n
|
|
740
740
|
};
|
|
741
741
|
}
|
|
742
|
-
function
|
|
743
|
-
return
|
|
742
|
+
function w(e) {
|
|
743
|
+
return re[e] ?? re.en;
|
|
744
744
|
}
|
|
745
|
-
function
|
|
745
|
+
function T(e, t) {
|
|
746
746
|
return t <= 0 ? 0 : e.lastIndexOf("\n", t - 1) + 1;
|
|
747
747
|
}
|
|
748
|
-
function
|
|
749
|
-
let n =
|
|
748
|
+
function E(e, t) {
|
|
749
|
+
let n = T(e, t.start), r = t.end > t.start && e[t.end - 1] === "\n" ? t.end - 1 : t.end, i = e.indexOf("\n", r), a = i === -1 ? e.length : i, o = [], s = n;
|
|
750
750
|
for (;;) {
|
|
751
751
|
let t = e.indexOf("\n", s), n = t === -1 || t > a ? a : t;
|
|
752
752
|
if (o.push({
|
|
@@ -758,7 +758,7 @@ function T(e, t) {
|
|
|
758
758
|
}
|
|
759
759
|
return o;
|
|
760
760
|
}
|
|
761
|
-
function
|
|
761
|
+
function D(e, t, n) {
|
|
762
762
|
if (n.length === 0) return {
|
|
763
763
|
value: e,
|
|
764
764
|
selection: t
|
|
@@ -792,7 +792,7 @@ function E(e, t, n) {
|
|
|
792
792
|
}
|
|
793
793
|
};
|
|
794
794
|
}
|
|
795
|
-
function
|
|
795
|
+
function O(e, t, n, r) {
|
|
796
796
|
return t === e.text ? null : {
|
|
797
797
|
start: e.start,
|
|
798
798
|
end: e.end,
|
|
@@ -801,13 +801,13 @@ function D(e, t, n, r) {
|
|
|
801
801
|
newPrefixLength: r
|
|
802
802
|
};
|
|
803
803
|
}
|
|
804
|
-
function
|
|
804
|
+
function k(e, t, n, r) {
|
|
805
805
|
return n === "*" ? r ? e[t.start - 1] !== "*" && e[t.end] !== "*" : e[t.start - n.length - 1] !== "*" && e[t.end + n.length] !== "*" : !0;
|
|
806
806
|
}
|
|
807
|
-
function
|
|
808
|
-
let i =
|
|
807
|
+
function A(e, t, n, r) {
|
|
808
|
+
let i = C(e, t), a = n.length, { start: o, end: s } = i, c = e.slice(o, s);
|
|
809
809
|
if (o !== s) {
|
|
810
|
-
if (c.length >= a * 2 && c.startsWith(n) && c.endsWith(n) && (n !== "*" || !c.startsWith("**") && !c.endsWith("**")) &&
|
|
810
|
+
if (c.length >= a * 2 && c.startsWith(n) && c.endsWith(n) && (n !== "*" || !c.startsWith("**") && !c.endsWith("**")) && k(e, i, n, !0)) {
|
|
811
811
|
let t = c.slice(a, c.length - a);
|
|
812
812
|
return {
|
|
813
813
|
value: e.slice(0, o) + t + e.slice(s),
|
|
@@ -818,7 +818,7 @@ function k(e, t, n, r) {
|
|
|
818
818
|
};
|
|
819
819
|
}
|
|
820
820
|
let t = o - a, r = s + a;
|
|
821
|
-
return t >= 0 && r <= e.length && e.slice(t, o) === n && e.slice(s, r) === n &&
|
|
821
|
+
return t >= 0 && r <= e.length && e.slice(t, o) === n && e.slice(s, r) === n && k(e, i, n, !1) ? {
|
|
822
822
|
value: e.slice(0, t) + c + e.slice(r),
|
|
823
823
|
selection: {
|
|
824
824
|
start: t,
|
|
@@ -841,39 +841,39 @@ function k(e, t, n, r) {
|
|
|
841
841
|
}
|
|
842
842
|
};
|
|
843
843
|
}
|
|
844
|
-
function
|
|
845
|
-
return
|
|
844
|
+
function j(e, t, n = "en") {
|
|
845
|
+
return A(e, t, "**", w(n).boldPlaceholder);
|
|
846
846
|
}
|
|
847
|
-
function
|
|
848
|
-
return
|
|
847
|
+
function M(e, t, n = "en") {
|
|
848
|
+
return A(e, t, "*", w(n).italicPlaceholder);
|
|
849
849
|
}
|
|
850
|
-
function
|
|
851
|
-
return
|
|
850
|
+
function oe(e, t, n = "en") {
|
|
851
|
+
return A(e, t, "~~", w(n).strikePlaceholder);
|
|
852
852
|
}
|
|
853
|
-
function
|
|
853
|
+
function N(e) {
|
|
854
854
|
let t = 0;
|
|
855
855
|
for (let n of e.match(/`+/g) ?? []) t = Math.max(t, n.length);
|
|
856
856
|
return t;
|
|
857
857
|
}
|
|
858
|
-
function
|
|
858
|
+
function P(e, t, n) {
|
|
859
859
|
let r = 0;
|
|
860
860
|
for (; e[t] === "`";) r += 1, t += n;
|
|
861
861
|
return r;
|
|
862
862
|
}
|
|
863
|
-
function
|
|
864
|
-
let { start: n, end: r } = t, i = e.slice(n, r), a =
|
|
863
|
+
function se(e, t) {
|
|
864
|
+
let { start: n, end: r } = t, i = e.slice(n, r), a = P(e, n - 1, -1), o = P(e, r, 1), s = a > 0 && a === o ? {
|
|
865
865
|
run: a,
|
|
866
866
|
padding: 0
|
|
867
|
-
} : null, c =
|
|
867
|
+
} : null, c = P(e, n - 2, -1), l = P(e, r + 1, 1), u = e[n - 1] === " " && e[r] === " " && c > 0 && c === l ? {
|
|
868
868
|
run: c,
|
|
869
869
|
padding: 1
|
|
870
870
|
} : null, d = s ?? u;
|
|
871
|
-
return !d ||
|
|
871
|
+
return !d || N(i) >= d.run ? null : d;
|
|
872
872
|
}
|
|
873
|
-
function
|
|
874
|
-
let r =
|
|
873
|
+
function ce(e, t, n = "en") {
|
|
874
|
+
let r = C(e, t), { start: i, end: a } = r, o = e.slice(i, a);
|
|
875
875
|
if (i === a) {
|
|
876
|
-
let t =
|
|
876
|
+
let t = w(n).inlineCodePlaceholder, r = `\`${t}\``;
|
|
877
877
|
return {
|
|
878
878
|
value: e.slice(0, i) + r + e.slice(a),
|
|
879
879
|
selection: {
|
|
@@ -882,8 +882,8 @@ function le(e, t, n = "en") {
|
|
|
882
882
|
}
|
|
883
883
|
};
|
|
884
884
|
}
|
|
885
|
-
let s =
|
|
886
|
-
if (s > 0 && s === c && o.length >= s * 2 &&
|
|
885
|
+
let s = P(o, 0, 1), c = P(o, o.length - 1, -1);
|
|
886
|
+
if (s > 0 && s === c && o.length >= s * 2 && N(o.slice(s, o.length - s)) < s) {
|
|
887
887
|
let t = o.slice(s, o.length - s);
|
|
888
888
|
return t.startsWith(" ") && t.endsWith(" ") && t.trim().length > 0 && (t = t.slice(1, -1)), {
|
|
889
889
|
value: e.slice(0, i) + t + e.slice(a),
|
|
@@ -893,7 +893,7 @@ function le(e, t, n = "en") {
|
|
|
893
893
|
}
|
|
894
894
|
};
|
|
895
895
|
}
|
|
896
|
-
let l =
|
|
896
|
+
let l = se(e, r);
|
|
897
897
|
if (l) {
|
|
898
898
|
let t = l.run + l.padding;
|
|
899
899
|
return {
|
|
@@ -904,7 +904,7 @@ function le(e, t, n = "en") {
|
|
|
904
904
|
}
|
|
905
905
|
};
|
|
906
906
|
}
|
|
907
|
-
let u = "`".repeat(
|
|
907
|
+
let u = "`".repeat(N(o) + 1), d = /^[` ]|[` ]$/.test(o) ? " " : "", f = u + d;
|
|
908
908
|
return {
|
|
909
909
|
value: e.slice(0, i) + f + o + d + u + e.slice(a),
|
|
910
910
|
selection: {
|
|
@@ -913,16 +913,16 @@ function le(e, t, n = "en") {
|
|
|
913
913
|
}
|
|
914
914
|
};
|
|
915
915
|
}
|
|
916
|
-
var
|
|
916
|
+
var le = /^(#{1,6})[ \t]+/;
|
|
917
917
|
function F(e, t, n) {
|
|
918
|
-
let r =
|
|
919
|
-
for (let t of
|
|
920
|
-
let e =
|
|
918
|
+
let r = C(e, t), i = [];
|
|
919
|
+
for (let t of E(e, r)) {
|
|
920
|
+
let e = le.exec(t.text), r = e ? e[0].length : 0;
|
|
921
921
|
if (n === 0 && !e) continue;
|
|
922
|
-
let a = t.text.slice(r), o = n === 0 ? "" : `${"#".repeat(n)} `, s =
|
|
922
|
+
let a = t.text.slice(r), o = n === 0 ? "" : `${"#".repeat(n)} `, s = O(t, o + a, r, o.length);
|
|
923
923
|
s && i.push(s);
|
|
924
924
|
}
|
|
925
|
-
return
|
|
925
|
+
return D(e, r, i);
|
|
926
926
|
}
|
|
927
927
|
var I = /^([ \t]*)([-*+] )/, L = /^([ \t]*)(\d+[.)] )/, R = /^([ \t]*)([-*+] \[[ xX]\] )/, z = /^([ \t]*)(> ?)/;
|
|
928
928
|
function B(e, t) {
|
|
@@ -935,12 +935,12 @@ function B(e, t) {
|
|
|
935
935
|
prefixLength: r.length + i.length
|
|
936
936
|
};
|
|
937
937
|
}
|
|
938
|
-
function
|
|
938
|
+
function ue(e) {
|
|
939
939
|
let t = /^[ \t]*/.exec(e);
|
|
940
940
|
return t ? t[0] : "";
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
let i =
|
|
942
|
+
function V(e, t, n, r) {
|
|
943
|
+
let i = C(e, t), a = E(e, i), o = a.map((e) => n(e.text)), s = 0, c = !0;
|
|
944
944
|
for (let e = 0; e < a.length; e += 1) {
|
|
945
945
|
let t = a[e];
|
|
946
946
|
(o[e] || t.text.trim().length > 0) && (s += 1, o[e] || (c = !1));
|
|
@@ -950,30 +950,30 @@ function H(e, t, n, r) {
|
|
|
950
950
|
let t = a[e], n = o[e] ?? null;
|
|
951
951
|
if (l) {
|
|
952
952
|
if (!n) continue;
|
|
953
|
-
let e =
|
|
953
|
+
let e = O(t, n.indent + t.text.slice(n.prefixLength), n.prefixLength, n.indent.length);
|
|
954
954
|
e && u.push(e);
|
|
955
955
|
continue;
|
|
956
956
|
}
|
|
957
|
-
let i = n ? n.indent :
|
|
957
|
+
let i = n ? n.indent : ue(t.text), s = t.text.slice(n ? n.prefixLength : i.length), c = r(i, e + 1), d = O(t, i + c + s, n ? n.prefixLength : i.length, i.length + c.length);
|
|
958
958
|
d && u.push(d);
|
|
959
959
|
}
|
|
960
|
-
return
|
|
960
|
+
return D(e, i, u);
|
|
961
|
+
}
|
|
962
|
+
function H(e, t) {
|
|
963
|
+
return V(e, t, (e) => B(e, I), () => "- ");
|
|
961
964
|
}
|
|
962
965
|
function U(e, t) {
|
|
963
|
-
return
|
|
966
|
+
return V(e, t, (e) => B(e, L), (e, t) => `${t}. `);
|
|
964
967
|
}
|
|
965
968
|
function W(e, t) {
|
|
966
|
-
return
|
|
967
|
-
}
|
|
968
|
-
function ue(e, t) {
|
|
969
|
-
return H(e, t, (e) => B(e, R), () => "- [ ] ");
|
|
969
|
+
return V(e, t, (e) => B(e, R), () => "- [ ] ");
|
|
970
970
|
}
|
|
971
971
|
function G(e, t) {
|
|
972
|
-
return
|
|
972
|
+
return V(e, t, (e) => B(e, z), () => "> ");
|
|
973
973
|
}
|
|
974
974
|
function de(e, t) {
|
|
975
|
-
let n =
|
|
976
|
-
return
|
|
975
|
+
let n = C(e, t);
|
|
976
|
+
return D(e, n, E(e, n).map((e) => ({
|
|
977
977
|
start: e.start,
|
|
978
978
|
end: e.end,
|
|
979
979
|
text: ` ${e.text}`,
|
|
@@ -981,7 +981,7 @@ function de(e, t) {
|
|
|
981
981
|
newPrefixLength: 2
|
|
982
982
|
})));
|
|
983
983
|
}
|
|
984
|
-
function
|
|
984
|
+
function K(e) {
|
|
985
985
|
if (e.startsWith(" ")) return {
|
|
986
986
|
text: e.slice(1),
|
|
987
987
|
removed: 1
|
|
@@ -993,18 +993,18 @@ function fe(e) {
|
|
|
993
993
|
removed: t
|
|
994
994
|
};
|
|
995
995
|
}
|
|
996
|
-
function
|
|
997
|
-
let n =
|
|
998
|
-
for (let t of
|
|
999
|
-
let e =
|
|
996
|
+
function q(e, t) {
|
|
997
|
+
let n = C(e, t), r = [];
|
|
998
|
+
for (let t of E(e, n)) {
|
|
999
|
+
let e = K(t.text);
|
|
1000
1000
|
if (e.removed === 0) continue;
|
|
1001
|
-
let n =
|
|
1001
|
+
let n = O(t, e.text, e.removed, 0);
|
|
1002
1002
|
n && r.push(n);
|
|
1003
1003
|
}
|
|
1004
|
-
return
|
|
1004
|
+
return D(e, n, r);
|
|
1005
1005
|
}
|
|
1006
|
-
function
|
|
1007
|
-
let { start: r, end: i } =
|
|
1006
|
+
function fe(e, t, n = "en") {
|
|
1007
|
+
let { start: r, end: i } = C(e, t), a = e.slice(r, i), o = "https://example.com";
|
|
1008
1008
|
if (a.length > 0) {
|
|
1009
1009
|
let t = `[${a}](${o})`, n = r + 1 + a.length + 2;
|
|
1010
1010
|
return {
|
|
@@ -1015,7 +1015,7 @@ function pe(e, t, n = "en") {
|
|
|
1015
1015
|
}
|
|
1016
1016
|
};
|
|
1017
1017
|
}
|
|
1018
|
-
let s =
|
|
1018
|
+
let s = w(n).linkText, c = `[${s}](${o})`;
|
|
1019
1019
|
return {
|
|
1020
1020
|
value: e.slice(0, r) + c + e.slice(i),
|
|
1021
1021
|
selection: {
|
|
@@ -1024,8 +1024,8 @@ function pe(e, t, n = "en") {
|
|
|
1024
1024
|
}
|
|
1025
1025
|
};
|
|
1026
1026
|
}
|
|
1027
|
-
function
|
|
1028
|
-
let { start: r, end: i } =
|
|
1027
|
+
function pe(e, t, n = "en") {
|
|
1028
|
+
let { start: r, end: i } = C(e, t), a = e.slice(r, i), o = "images/example.png";
|
|
1029
1029
|
if (a.length > 0) {
|
|
1030
1030
|
let t = ``, n = r + 2 + a.length + 2;
|
|
1031
1031
|
return {
|
|
@@ -1036,7 +1036,7 @@ function me(e, t, n = "en") {
|
|
|
1036
1036
|
}
|
|
1037
1037
|
};
|
|
1038
1038
|
}
|
|
1039
|
-
let s =
|
|
1039
|
+
let s = w(n).imageAlt, c = ``;
|
|
1040
1040
|
return {
|
|
1041
1041
|
value: e.slice(0, r) + c + e.slice(i),
|
|
1042
1042
|
selection: {
|
|
@@ -1045,25 +1045,25 @@ function me(e, t, n = "en") {
|
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1049
|
-
let r =
|
|
1050
|
-
return
|
|
1048
|
+
function me(e, t, n = "en") {
|
|
1049
|
+
let r = C(e, t), i = e.slice(r.start, r.end), a = i.length > 0 ? i : w(n).codeBlockPlaceholder, o = "`".repeat(Math.max(3, N(a) + 1)), s = `${o}text\n`;
|
|
1050
|
+
return _e(e, r, `${s}${a}\n${o}`, {
|
|
1051
1051
|
start: s.length,
|
|
1052
1052
|
end: s.length + a.length
|
|
1053
1053
|
});
|
|
1054
1054
|
}
|
|
1055
|
-
function
|
|
1055
|
+
function he(e) {
|
|
1056
1056
|
return [
|
|
1057
1057
|
`| ${e.tableHeaders.join(" | ")} |`,
|
|
1058
1058
|
`| ${e.tableHeaders.map(() => "---").join(" | ")} |`,
|
|
1059
1059
|
...e.tableRows.map((e) => `| ${e.join(" | ")} |`)
|
|
1060
1060
|
].join("\n");
|
|
1061
1061
|
}
|
|
1062
|
-
function
|
|
1063
|
-
let n =
|
|
1062
|
+
function ge(e, t) {
|
|
1063
|
+
let n = T(e, t.start), r = e.slice(n, t.start), i = e.indexOf("\n", t.end), a = i === -1 ? e.length : i, o = e.slice(t.end, a), s = "";
|
|
1064
1064
|
if (/\S/.test(r)) s = "\n\n";
|
|
1065
1065
|
else if (n > 0) {
|
|
1066
|
-
let t =
|
|
1066
|
+
let t = T(e, n - 1);
|
|
1067
1067
|
/\S/.test(e.slice(t, n - 1)) && (s = "\n");
|
|
1068
1068
|
}
|
|
1069
1069
|
return {
|
|
@@ -1071,8 +1071,8 @@ function _e(e, t) {
|
|
|
1071
1071
|
suffix: /\S/.test(o) ? "\n\n" : ""
|
|
1072
1072
|
};
|
|
1073
1073
|
}
|
|
1074
|
-
function
|
|
1075
|
-
let { prefix: i, suffix: a } =
|
|
1074
|
+
function _e(e, t, n, r) {
|
|
1075
|
+
let { prefix: i, suffix: a } = ge(e, t), o = t.start + i.length;
|
|
1076
1076
|
return {
|
|
1077
1077
|
value: e.slice(0, t.start) + i + n + a + e.slice(t.end),
|
|
1078
1078
|
selection: {
|
|
@@ -1081,21 +1081,21 @@ function ve(e, t, n, r) {
|
|
|
1081
1081
|
}
|
|
1082
1082
|
};
|
|
1083
1083
|
}
|
|
1084
|
-
function
|
|
1085
|
-
let r =
|
|
1086
|
-
return
|
|
1084
|
+
function ve(e, t, n = "en") {
|
|
1085
|
+
let r = C(e, t), i = w(n), a = he(i), o = i.tableRows[0][0], s = a.indexOf(o);
|
|
1086
|
+
return _e(e, r, a, {
|
|
1087
1087
|
start: s,
|
|
1088
1088
|
end: s + o.length
|
|
1089
1089
|
});
|
|
1090
1090
|
}
|
|
1091
|
-
function
|
|
1092
|
-
return
|
|
1091
|
+
function ye(e, t) {
|
|
1092
|
+
return _e(e, C(e, t), "---", {
|
|
1093
1093
|
start: 3,
|
|
1094
1094
|
end: 3
|
|
1095
1095
|
});
|
|
1096
1096
|
}
|
|
1097
1097
|
function be(e, t, n) {
|
|
1098
|
-
let r =
|
|
1098
|
+
let r = C(e, t), i = r.start + n.length;
|
|
1099
1099
|
return {
|
|
1100
1100
|
value: e.slice(0, r.start) + n + e.slice(r.end),
|
|
1101
1101
|
selection: {
|
|
@@ -1105,7 +1105,7 @@ function be(e, t, n) {
|
|
|
1105
1105
|
};
|
|
1106
1106
|
}
|
|
1107
1107
|
var xe = /\{\{(selection(?::[^{}]*)?|caret|select:[^{}]*)\}\}/g;
|
|
1108
|
-
function
|
|
1108
|
+
function Se(e, t) {
|
|
1109
1109
|
let n = "", r = 0, i = null, a = null, o = null;
|
|
1110
1110
|
xe.lastIndex = 0;
|
|
1111
1111
|
for (let s = xe.exec(e); s; s = xe.exec(e)) {
|
|
@@ -1139,8 +1139,8 @@ function J(e, t) {
|
|
|
1139
1139
|
caret: o
|
|
1140
1140
|
};
|
|
1141
1141
|
}
|
|
1142
|
-
function
|
|
1143
|
-
let i =
|
|
1142
|
+
function Ce(e, t, n, r = {}) {
|
|
1143
|
+
let i = C(e, t), a = Se(n, e.slice(i.start, i.end)), o = r.block === !0 && a.text.length > 0 ? ge(e, i) : {
|
|
1144
1144
|
prefix: "",
|
|
1145
1145
|
suffix: ""
|
|
1146
1146
|
}, s = i.start + o.prefix.length, c;
|
|
@@ -1161,7 +1161,7 @@ function Se(e, t, n, r = {}) {
|
|
|
1161
1161
|
selection: c
|
|
1162
1162
|
};
|
|
1163
1163
|
}
|
|
1164
|
-
function
|
|
1164
|
+
function we(e, t) {
|
|
1165
1165
|
let n = [], r = 0;
|
|
1166
1166
|
for (; r < e.length;) {
|
|
1167
1167
|
if (e[r] !== t) {
|
|
@@ -1178,18 +1178,18 @@ function Ce(e, t) {
|
|
|
1178
1178
|
}
|
|
1179
1179
|
return n;
|
|
1180
1180
|
}
|
|
1181
|
-
function
|
|
1182
|
-
if (t === "inlineCode") return
|
|
1183
|
-
let n =
|
|
1181
|
+
function Te(e, t) {
|
|
1182
|
+
if (t === "inlineCode") return we(e, "`");
|
|
1183
|
+
let n = we(e, t === "strike" ? "~" : "*");
|
|
1184
1184
|
return t === "italic" ? n.filter((e) => e.length % 2 == 1) : n.filter((e) => e.length >= 2);
|
|
1185
1185
|
}
|
|
1186
|
-
function
|
|
1186
|
+
function Ee(e, t, n) {
|
|
1187
1187
|
return e >= t ? !1 : n.some((r) => r.start === e && n.some((e) => e.end === t && e.length === r.length && e.start >= r.end));
|
|
1188
1188
|
}
|
|
1189
|
-
function
|
|
1189
|
+
function De(e, t, n) {
|
|
1190
1190
|
return e >= t ? !1 : n.some((r) => r.end === e && n.some((e) => e.start === t && e.length === r.length && e.start >= r.end));
|
|
1191
1191
|
}
|
|
1192
|
-
function
|
|
1192
|
+
function Oe(e, t) {
|
|
1193
1193
|
let n = 0;
|
|
1194
1194
|
for (; n < t.length;) {
|
|
1195
1195
|
let r = t[n], i = n + 1;
|
|
@@ -1203,14 +1203,14 @@ function De(e, t) {
|
|
|
1203
1203
|
}
|
|
1204
1204
|
return !1;
|
|
1205
1205
|
}
|
|
1206
|
-
function
|
|
1206
|
+
function J(e, t, n, r) {
|
|
1207
1207
|
if (t.start !== t.end) {
|
|
1208
|
-
let n =
|
|
1209
|
-
return
|
|
1208
|
+
let n = Te(e, r);
|
|
1209
|
+
return Ee(t.start, t.end, n) || De(t.start, t.end, n);
|
|
1210
1210
|
}
|
|
1211
|
-
return
|
|
1211
|
+
return Oe(Math.min(Math.max(t.start - n.start, 0), n.text.length), Te(n.text, r).filter((e) => e.start >= Y(n.text)));
|
|
1212
1212
|
}
|
|
1213
|
-
function
|
|
1213
|
+
function Y(e) {
|
|
1214
1214
|
let t = 0;
|
|
1215
1215
|
for (;;) {
|
|
1216
1216
|
let n = e.slice(t), r = B(n, R) ?? B(n, I) ?? B(n, L) ?? B(n, z);
|
|
@@ -1222,16 +1222,16 @@ function ke(e) {
|
|
|
1222
1222
|
return B(e, R) ? "task" : B(e, I) ? "bullet" : B(e, L) ? "ordered" : null;
|
|
1223
1223
|
}
|
|
1224
1224
|
function Ae(e, t) {
|
|
1225
|
-
let n =
|
|
1225
|
+
let n = C(e, t), r = E(e, {
|
|
1226
1226
|
start: n.start,
|
|
1227
1227
|
end: n.start
|
|
1228
|
-
})[0], i = r.text, a =
|
|
1228
|
+
})[0], i = r.text, a = le.exec(i);
|
|
1229
1229
|
return {
|
|
1230
1230
|
headingLevel: a ? a[1].length : 0,
|
|
1231
|
-
bold:
|
|
1232
|
-
italic:
|
|
1233
|
-
strike:
|
|
1234
|
-
inlineCode:
|
|
1231
|
+
bold: J(e, n, r, "bold"),
|
|
1232
|
+
italic: J(e, n, r, "italic"),
|
|
1233
|
+
strike: J(e, n, r, "strike"),
|
|
1234
|
+
inlineCode: J(e, n, r, "inlineCode"),
|
|
1235
1235
|
list: ke(i),
|
|
1236
1236
|
quote: B(i, z) !== null
|
|
1237
1237
|
};
|
|
@@ -1620,12 +1620,12 @@ function Fe(e, t) {
|
|
|
1620
1620
|
}
|
|
1621
1621
|
var Ie = je.map((e) => ({
|
|
1622
1622
|
...e,
|
|
1623
|
-
label:
|
|
1623
|
+
label: y.zh.groups[e.id]
|
|
1624
1624
|
})), Le = Me.map((e) => ({
|
|
1625
1625
|
...e,
|
|
1626
|
-
keywords: Fe(e.keywords,
|
|
1626
|
+
keywords: Fe(e.keywords, y.zh.components[e.id]?.keywords ?? [])
|
|
1627
1627
|
})), Re = Me.map((e) => {
|
|
1628
|
-
let t =
|
|
1628
|
+
let t = y.zh.components[e.id];
|
|
1629
1629
|
return t ? {
|
|
1630
1630
|
...e,
|
|
1631
1631
|
label: t.label,
|
|
@@ -1699,22 +1699,22 @@ var We = /* @__PURE__ */ "😀.😄.😁.😊.🙂.😉.😍.🤔.😎.😅.😂
|
|
|
1699
1699
|
{
|
|
1700
1700
|
type: "bullet",
|
|
1701
1701
|
icon: "bulletList",
|
|
1702
|
-
command:
|
|
1702
|
+
command: H
|
|
1703
1703
|
},
|
|
1704
1704
|
{
|
|
1705
1705
|
type: "ordered",
|
|
1706
1706
|
icon: "orderedList",
|
|
1707
|
-
command:
|
|
1707
|
+
command: U
|
|
1708
1708
|
},
|
|
1709
1709
|
{
|
|
1710
1710
|
type: "task",
|
|
1711
1711
|
icon: "taskList",
|
|
1712
|
-
command:
|
|
1712
|
+
command: W
|
|
1713
1713
|
}
|
|
1714
1714
|
], qe = [{
|
|
1715
1715
|
labelKey: "decreaseIndent",
|
|
1716
1716
|
icon: "outdent",
|
|
1717
|
-
command:
|
|
1717
|
+
command: q
|
|
1718
1718
|
}, {
|
|
1719
1719
|
labelKey: "increaseIndent",
|
|
1720
1720
|
icon: "indent",
|
|
@@ -1723,32 +1723,32 @@ var We = /* @__PURE__ */ "😀.😄.😁.😊.🙂.😉.😍.🤔.😎.😅.😂
|
|
|
1723
1723
|
{
|
|
1724
1724
|
labelKey: "image",
|
|
1725
1725
|
icon: "image",
|
|
1726
|
-
command:
|
|
1726
|
+
command: pe
|
|
1727
1727
|
},
|
|
1728
1728
|
{
|
|
1729
1729
|
labelKey: "table",
|
|
1730
1730
|
icon: "table",
|
|
1731
|
-
command:
|
|
1731
|
+
command: ve
|
|
1732
1732
|
},
|
|
1733
1733
|
{
|
|
1734
1734
|
labelKey: "divider",
|
|
1735
1735
|
icon: "divider",
|
|
1736
|
-
command:
|
|
1736
|
+
command: ye
|
|
1737
1737
|
},
|
|
1738
1738
|
{
|
|
1739
1739
|
labelKey: "codeBlock",
|
|
1740
1740
|
icon: "codeBlock",
|
|
1741
|
-
command:
|
|
1741
|
+
command: me
|
|
1742
1742
|
},
|
|
1743
1743
|
{
|
|
1744
1744
|
labelKey: "inlineCode",
|
|
1745
1745
|
icon: "inlineCode",
|
|
1746
|
-
command:
|
|
1746
|
+
command: ce
|
|
1747
1747
|
},
|
|
1748
1748
|
{
|
|
1749
1749
|
labelKey: "strikethrough",
|
|
1750
1750
|
icon: "strike",
|
|
1751
|
-
command:
|
|
1751
|
+
command: oe
|
|
1752
1752
|
},
|
|
1753
1753
|
{
|
|
1754
1754
|
labelKey: "quote",
|
|
@@ -2023,45 +2023,45 @@ function it(e, t) {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
e.preventDefault(), n[a]?.focus();
|
|
2025
2025
|
}
|
|
2026
|
-
function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo: f, onExport:
|
|
2027
|
-
let
|
|
2026
|
+
function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo: f, onExport: h, showExport: ee = !1, disabled: g = !1 }) {
|
|
2027
|
+
let te = u(null), _ = u(null), v = u(null), ne = u(null), re = u(null), y = u(null), [b, x] = d(null), [S, C] = d("heading"), [w, T] = d(""), [E, D] = d(Xe), [O, k] = d(null), A = o(), oe = `${A}-emoji-menu`, N = `${A}-heading-menu`, P = `${A}-list-menu`, se = `${A}-insert-menu`, ce = `${A}-more-menu`, le = `${A}-native-menu`, I = ae(), L = ie[I], R = l(() => ze(I), [I]), z = Ge.map((e) => ({
|
|
2028
2028
|
...e,
|
|
2029
2029
|
label: L.headingLabels[e.level]
|
|
2030
2030
|
})), B = Ke.map((e) => ({
|
|
2031
2031
|
...e,
|
|
2032
2032
|
label: L.listLabels[e.type]
|
|
2033
|
-
})),
|
|
2033
|
+
})), ue = qe.map((e) => ({
|
|
2034
2034
|
...e,
|
|
2035
2035
|
label: L[e.labelKey]
|
|
2036
|
-
})),
|
|
2036
|
+
})), V = Je.map((e) => ({
|
|
2037
2037
|
...e,
|
|
2038
2038
|
label: L.insertItems[e.labelKey]
|
|
2039
|
-
})),
|
|
2040
|
-
let e =
|
|
2039
|
+
})), H = l(() => {
|
|
2040
|
+
let e = w.trim().toLowerCase();
|
|
2041
2041
|
return R.groups.map((t) => ({
|
|
2042
2042
|
group: t,
|
|
2043
2043
|
components: R.components.filter((n) => n.group === t.id && $e(n, e))
|
|
2044
2044
|
})).filter((e) => e.components.length > 0);
|
|
2045
|
-
}, [R,
|
|
2045
|
+
}, [R, w]), U = r(() => {
|
|
2046
2046
|
let t = e.current;
|
|
2047
2047
|
if (!t) {
|
|
2048
|
-
|
|
2048
|
+
D(Xe);
|
|
2049
2049
|
return;
|
|
2050
2050
|
}
|
|
2051
2051
|
let n = Ae(t.value, {
|
|
2052
2052
|
start: t.selectionStart,
|
|
2053
2053
|
end: t.selectionEnd
|
|
2054
2054
|
});
|
|
2055
|
-
|
|
2056
|
-
}, [e]),
|
|
2057
|
-
|
|
2058
|
-
|
|
2055
|
+
D((e) => et(e, n) ? e : n);
|
|
2056
|
+
}, [e]), W = r(() => {
|
|
2057
|
+
y.current !== null && window.cancelAnimationFrame(y.current), y.current = window.requestAnimationFrame(() => {
|
|
2058
|
+
y.current = null, U();
|
|
2059
2059
|
});
|
|
2060
|
-
}, [
|
|
2060
|
+
}, [U]);
|
|
2061
2061
|
a(() => {
|
|
2062
2062
|
let t = e.current;
|
|
2063
2063
|
if (!t) return;
|
|
2064
|
-
let n = () =>
|
|
2064
|
+
let n = () => U(), r = [
|
|
2065
2065
|
"select",
|
|
2066
2066
|
"keyup",
|
|
2067
2067
|
"click",
|
|
@@ -2070,113 +2070,113 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2070
2070
|
];
|
|
2071
2071
|
for (let e of r) t.addEventListener(e, n);
|
|
2072
2072
|
let i = () => {
|
|
2073
|
-
document.activeElement === t &&
|
|
2073
|
+
document.activeElement === t && U();
|
|
2074
2074
|
};
|
|
2075
|
-
return document.addEventListener("selectionchange", i),
|
|
2075
|
+
return document.addEventListener("selectionchange", i), U(), () => {
|
|
2076
2076
|
for (let e of r) t.removeEventListener(e, n);
|
|
2077
2077
|
document.removeEventListener("selectionchange", i);
|
|
2078
2078
|
};
|
|
2079
|
-
}, [e,
|
|
2080
|
-
|
|
2079
|
+
}, [e, U]), a(() => () => {
|
|
2080
|
+
y.current !== null && window.cancelAnimationFrame(y.current);
|
|
2081
2081
|
}, []);
|
|
2082
2082
|
let G = r((e) => {
|
|
2083
2083
|
let t = e === "emoji" ? "insert" : e === "native" ? "components" : e;
|
|
2084
|
-
return
|
|
2084
|
+
return te.current?.querySelector(`[data-toolbar-id="${t}"]`) ?? null;
|
|
2085
2085
|
}, []);
|
|
2086
2086
|
c(() => {
|
|
2087
|
-
if (!
|
|
2088
|
-
|
|
2087
|
+
if (!b || b === "native" || b === "emoji") {
|
|
2088
|
+
k(null);
|
|
2089
2089
|
return;
|
|
2090
2090
|
}
|
|
2091
2091
|
let e = window.matchMedia("(max-width: 640px)"), t = () => {
|
|
2092
2092
|
if (!e.matches) {
|
|
2093
|
-
|
|
2093
|
+
k(null);
|
|
2094
2094
|
return;
|
|
2095
2095
|
}
|
|
2096
|
-
let t = G(
|
|
2096
|
+
let t = G(b);
|
|
2097
2097
|
if (!t) return;
|
|
2098
|
-
let n = t.getBoundingClientRect(), r = Ye[
|
|
2099
|
-
i >= a ? (o.bottom = window.innerHeight - n.top + 6, o.top = "auto", o.maxHeight = Math.max(80, i)) : (o.top = n.bottom + 6, o.bottom = "auto", o.maxHeight = Math.max(80, a)),
|
|
2098
|
+
let n = t.getBoundingClientRect(), r = Ye[b] ?? 216, i = n.top - 6 - 8, a = window.innerHeight - n.bottom - 6 - 8, o = {};
|
|
2099
|
+
i >= a ? (o.bottom = window.innerHeight - n.top + 6, o.top = "auto", o.maxHeight = Math.max(80, i)) : (o.top = n.bottom + 6, o.bottom = "auto", o.maxHeight = Math.max(80, a)), b === "heading" || b === "list" ? (o.left = Math.min(Math.max(8, n.left), window.innerWidth - 8 - r), o.right = "auto") : (o.right = Math.min(Math.max(8, window.innerWidth - n.right), window.innerWidth - 8 - r), o.left = "auto"), k(o);
|
|
2100
2100
|
};
|
|
2101
2101
|
return t(), e.addEventListener("change", t), window.addEventListener("resize", t), window.addEventListener("scroll", t, !0), () => {
|
|
2102
2102
|
e.removeEventListener("change", t), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
|
|
2103
2103
|
};
|
|
2104
|
-
}, [
|
|
2105
|
-
if (!
|
|
2104
|
+
}, [b, G]), a(() => {
|
|
2105
|
+
if (!b) return;
|
|
2106
2106
|
let e = (e) => {
|
|
2107
|
-
|
|
2107
|
+
te.current && !te.current.contains(e.target) && x(null);
|
|
2108
2108
|
}, t = (e) => {
|
|
2109
2109
|
if (e.key !== "Escape") return;
|
|
2110
2110
|
e.preventDefault(), e.stopPropagation();
|
|
2111
|
-
let t =
|
|
2112
|
-
|
|
2111
|
+
let t = b;
|
|
2112
|
+
x(null), G(t)?.focus();
|
|
2113
2113
|
};
|
|
2114
2114
|
return document.addEventListener("pointerdown", e, !0), document.addEventListener("keydown", t, !0), () => {
|
|
2115
2115
|
document.removeEventListener("pointerdown", e, !0), document.removeEventListener("keydown", t, !0);
|
|
2116
2116
|
};
|
|
2117
|
-
}, [
|
|
2118
|
-
if (!
|
|
2119
|
-
let e =
|
|
2120
|
-
|
|
2117
|
+
}, [b, G]), a(() => {
|
|
2118
|
+
if (!b) return;
|
|
2119
|
+
let e = re.current;
|
|
2120
|
+
re.current = null;
|
|
2121
2121
|
let t = window.requestAnimationFrame(() => {
|
|
2122
2122
|
let t = _.current;
|
|
2123
2123
|
if (e) {
|
|
2124
2124
|
let n = nt(t);
|
|
2125
2125
|
(e === "first" ? n[0] : n[n.length - 1])?.focus();
|
|
2126
|
-
} else
|
|
2126
|
+
} else b === "native" ? v.current?.focus() : b === "emoji" && nt(t)[0]?.focus();
|
|
2127
2127
|
});
|
|
2128
2128
|
return () => window.cancelAnimationFrame(t);
|
|
2129
|
-
}, [
|
|
2129
|
+
}, [b]);
|
|
2130
2130
|
let de = r(() => {
|
|
2131
|
-
let e = tt(
|
|
2132
|
-
e.length !== 0 &&
|
|
2131
|
+
let e = tt(te.current);
|
|
2132
|
+
e.length !== 0 && C((t) => e.some((e) => e.dataset.toolbarId === t) ? t : e[0]?.dataset.toolbarId ?? "heading");
|
|
2133
2133
|
}, []);
|
|
2134
2134
|
a(() => (de(), window.addEventListener("resize", de), () => window.removeEventListener("resize", de)), [de]), a(() => {
|
|
2135
2135
|
de();
|
|
2136
2136
|
}, [
|
|
2137
|
-
|
|
2137
|
+
b,
|
|
2138
2138
|
s,
|
|
2139
2139
|
f,
|
|
2140
2140
|
de
|
|
2141
2141
|
]);
|
|
2142
|
-
let
|
|
2143
|
-
|
|
2142
|
+
let K = r((e) => {
|
|
2143
|
+
g || (x(null), t(e), W());
|
|
2144
2144
|
}, [
|
|
2145
|
-
|
|
2145
|
+
g,
|
|
2146
2146
|
t,
|
|
2147
|
-
|
|
2148
|
-
]),
|
|
2149
|
-
if (
|
|
2147
|
+
W
|
|
2148
|
+
]), q = (t) => {
|
|
2149
|
+
if (g) return;
|
|
2150
|
+
let { value: n, selection: r } = Qe(e);
|
|
2151
|
+
K(t(n, r, I));
|
|
2152
|
+
}, pe = (t) => {
|
|
2153
|
+
if (g) return;
|
|
2150
2154
|
let { value: n, selection: r } = Qe(e);
|
|
2151
|
-
|
|
2155
|
+
K(F(n, r, t));
|
|
2152
2156
|
}, me = (t) => {
|
|
2153
|
-
if (
|
|
2157
|
+
if (g) return;
|
|
2154
2158
|
let { value: n, selection: r } = Qe(e);
|
|
2155
|
-
|
|
2159
|
+
K(be(n, r, t));
|
|
2156
2160
|
}, he = (t) => {
|
|
2157
|
-
if (
|
|
2158
|
-
let { value: n, selection: r } = Qe(e);
|
|
2159
|
-
fe(be(n, r, t));
|
|
2160
|
-
}, ge = (t) => {
|
|
2161
|
-
if (h) return;
|
|
2161
|
+
if (g) return;
|
|
2162
2162
|
let { value: n, selection: r, selectedText: i } = Qe(e), a = Ue(t, n, i);
|
|
2163
|
-
|
|
2163
|
+
K(Ce(n, r, a, { block: !t.inline }));
|
|
2164
|
+
}, ge = () => {
|
|
2165
|
+
g || (x(null), n(), W());
|
|
2164
2166
|
}, _e = () => {
|
|
2165
|
-
|
|
2167
|
+
g || (x(null), i(), W());
|
|
2166
2168
|
}, ve = () => {
|
|
2167
|
-
|
|
2168
|
-
}, ye = () => {
|
|
2169
|
-
|
|
2170
|
-
}, q = (e) => {
|
|
2171
|
-
b((t) => t === e ? null : e), e === "native" && w("");
|
|
2169
|
+
x(null), ee && h?.();
|
|
2170
|
+
}, ye = (e) => {
|
|
2171
|
+
x((t) => t === e ? null : e), e === "native" && T("");
|
|
2172
2172
|
}, xe = (e, t, n) => {
|
|
2173
|
-
if (t.preventDefault(), e === "native" &&
|
|
2173
|
+
if (t.preventDefault(), e === "native" && T(""), b === e) {
|
|
2174
2174
|
let e = nt(_.current);
|
|
2175
2175
|
(n === "first" ? e[0] : e[e.length - 1])?.focus();
|
|
2176
|
-
} else
|
|
2177
|
-
},
|
|
2176
|
+
} else re.current = n, x(e);
|
|
2177
|
+
}, Se = (e, t) => {
|
|
2178
2178
|
(t.key === "ArrowDown" || t.key === "ArrowUp") && xe(e, t, t.key === "ArrowDown" ? "first" : "last");
|
|
2179
|
-
},
|
|
2179
|
+
}, we = (e) => {
|
|
2180
2180
|
if (e.altKey || e.ctrlKey || e.metaKey || ![
|
|
2181
2181
|
"ArrowLeft",
|
|
2182
2182
|
"ArrowRight",
|
|
@@ -2187,7 +2187,7 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2187
2187
|
if (!(t instanceof HTMLElement)) return;
|
|
2188
2188
|
let n = t.closest("[data-toolbar-item]");
|
|
2189
2189
|
if (!n || n !== t) return;
|
|
2190
|
-
let r = tt(
|
|
2190
|
+
let r = tt(te.current), i = r.indexOf(n);
|
|
2191
2191
|
if (i < 0) return;
|
|
2192
2192
|
let a = i;
|
|
2193
2193
|
switch (e.key) {
|
|
@@ -2205,65 +2205,65 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2205
2205
|
break;
|
|
2206
2206
|
default: return;
|
|
2207
2207
|
}
|
|
2208
|
-
e.preventDefault(),
|
|
2209
|
-
},
|
|
2210
|
-
|
|
2211
|
-
},
|
|
2208
|
+
e.preventDefault(), b && x(null), r[a]?.focus();
|
|
2209
|
+
}, Te = () => {
|
|
2210
|
+
x(null), G("native")?.focus();
|
|
2211
|
+
}, Ee = z.find((e) => e.level === E.headingLevel)?.label ?? L.headingLabels[0], De = E.headingLevel === 0 ? "¶" : `H${E.headingLevel}`, Oe = L.headingLevelLabel(Ee), J = E.list ? L.listLabels[E.list] : null, Y = J ? L.listLabelWithType(J) : L.listLabel, ke = E.list === "ordered" ? "orderedList" : E.list === "task" ? "taskList" : "bulletList";
|
|
2212
2212
|
return /* @__PURE__ */ m("div", {
|
|
2213
|
-
className: `editor-toolbar${
|
|
2213
|
+
className: `editor-toolbar${b ? " is-menu-open" : ""}`,
|
|
2214
2214
|
role: "toolbar",
|
|
2215
2215
|
"aria-label": L.toolbarLabel,
|
|
2216
2216
|
"aria-orientation": "horizontal",
|
|
2217
|
-
"aria-disabled":
|
|
2218
|
-
ref:
|
|
2219
|
-
onKeyDown:
|
|
2217
|
+
"aria-disabled": g || void 0,
|
|
2218
|
+
ref: te,
|
|
2219
|
+
onKeyDown: we,
|
|
2220
2220
|
children: [
|
|
2221
2221
|
/* @__PURE__ */ m("div", {
|
|
2222
2222
|
className: "editor-toolbar-slot",
|
|
2223
2223
|
children: [/* @__PURE__ */ m(Q, {
|
|
2224
2224
|
toolbarId: "heading",
|
|
2225
|
-
label:
|
|
2225
|
+
label: Oe,
|
|
2226
2226
|
className: "editor-toolbar-heading-trigger",
|
|
2227
|
-
active:
|
|
2228
|
-
tabStop:
|
|
2229
|
-
onFocus: () =>
|
|
2230
|
-
disabled:
|
|
2227
|
+
active: E.headingLevel > 0,
|
|
2228
|
+
tabStop: S === "heading",
|
|
2229
|
+
onFocus: () => C("heading"),
|
|
2230
|
+
disabled: g,
|
|
2231
2231
|
popup: "menu",
|
|
2232
|
-
expanded:
|
|
2233
|
-
controls:
|
|
2234
|
-
onClick: () =>
|
|
2235
|
-
onKeyDown: (e) =>
|
|
2232
|
+
expanded: b === "heading",
|
|
2233
|
+
controls: N,
|
|
2234
|
+
onClick: () => ye("heading"),
|
|
2235
|
+
onKeyDown: (e) => Se("heading", e),
|
|
2236
2236
|
children: [
|
|
2237
2237
|
/* @__PURE__ */ p("span", {
|
|
2238
2238
|
className: "editor-toolbar-heading-label editor-toolbar-heading-label-full",
|
|
2239
|
-
children:
|
|
2239
|
+
children: Ee
|
|
2240
2240
|
}),
|
|
2241
2241
|
/* @__PURE__ */ p("span", {
|
|
2242
2242
|
className: "editor-toolbar-heading-label editor-toolbar-heading-label-compact",
|
|
2243
2243
|
"aria-hidden": "true",
|
|
2244
|
-
children:
|
|
2244
|
+
children: De
|
|
2245
2245
|
}),
|
|
2246
2246
|
/* @__PURE__ */ p(X, {
|
|
2247
2247
|
name: "chevron",
|
|
2248
2248
|
className: "editor-toolbar-chevron"
|
|
2249
2249
|
})
|
|
2250
2250
|
]
|
|
2251
|
-
}),
|
|
2252
|
-
id:
|
|
2251
|
+
}), b === "heading" ? /* @__PURE__ */ p("div", {
|
|
2252
|
+
id: N,
|
|
2253
2253
|
ref: _,
|
|
2254
2254
|
className: "editor-toolbar-popover editor-toolbar-heading-menu",
|
|
2255
2255
|
role: "menu",
|
|
2256
2256
|
"aria-label": L.headingMenuLabel,
|
|
2257
|
-
style:
|
|
2257
|
+
style: O ?? void 0,
|
|
2258
2258
|
onKeyDown: (e) => rt(e, _.current),
|
|
2259
2259
|
children: z.map((e) => /* @__PURE__ */ m("button", {
|
|
2260
2260
|
type: "button",
|
|
2261
2261
|
role: "menuitemradio",
|
|
2262
|
-
"aria-checked":
|
|
2262
|
+
"aria-checked": E.headingLevel === e.level,
|
|
2263
2263
|
tabIndex: -1,
|
|
2264
2264
|
className: "editor-toolbar-menu-item editor-toolbar-heading-item",
|
|
2265
2265
|
onMouseDown: Z,
|
|
2266
|
-
onClick: () =>
|
|
2266
|
+
onClick: () => pe(e.level),
|
|
2267
2267
|
children: [/* @__PURE__ */ p("span", {
|
|
2268
2268
|
className: `editor-toolbar-heading-sample is-level-${e.level}`,
|
|
2269
2269
|
"aria-hidden": "true",
|
|
@@ -2275,12 +2275,12 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2275
2275
|
/* @__PURE__ */ p(Q, {
|
|
2276
2276
|
toolbarId: "bold",
|
|
2277
2277
|
label: L.bold,
|
|
2278
|
-
tabStop:
|
|
2279
|
-
onFocus: () =>
|
|
2280
|
-
disabled:
|
|
2281
|
-
onClick: () =>
|
|
2282
|
-
pressed:
|
|
2283
|
-
active:
|
|
2278
|
+
tabStop: S === "bold",
|
|
2279
|
+
onFocus: () => C("bold"),
|
|
2280
|
+
disabled: g,
|
|
2281
|
+
onClick: () => q(j),
|
|
2282
|
+
pressed: E.bold,
|
|
2283
|
+
active: E.bold,
|
|
2284
2284
|
children: /* @__PURE__ */ p("span", {
|
|
2285
2285
|
className: "editor-toolbar-glyph is-bold",
|
|
2286
2286
|
"aria-hidden": "true",
|
|
@@ -2290,12 +2290,12 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2290
2290
|
/* @__PURE__ */ p(Q, {
|
|
2291
2291
|
toolbarId: "italic",
|
|
2292
2292
|
label: L.italic,
|
|
2293
|
-
tabStop:
|
|
2294
|
-
onFocus: () =>
|
|
2295
|
-
disabled:
|
|
2296
|
-
onClick: () =>
|
|
2297
|
-
pressed:
|
|
2298
|
-
active:
|
|
2293
|
+
tabStop: S === "italic",
|
|
2294
|
+
onFocus: () => C("italic"),
|
|
2295
|
+
disabled: g,
|
|
2296
|
+
onClick: () => q(M),
|
|
2297
|
+
pressed: E.italic,
|
|
2298
|
+
active: E.italic,
|
|
2299
2299
|
children: /* @__PURE__ */ p("span", {
|
|
2300
2300
|
className: "editor-toolbar-glyph is-italic",
|
|
2301
2301
|
"aria-hidden": "true",
|
|
@@ -2306,38 +2306,38 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2306
2306
|
className: "editor-toolbar-slot",
|
|
2307
2307
|
children: [/* @__PURE__ */ m(Q, {
|
|
2308
2308
|
toolbarId: "list",
|
|
2309
|
-
label:
|
|
2309
|
+
label: Y,
|
|
2310
2310
|
className: "editor-toolbar-list-trigger",
|
|
2311
|
-
tabStop:
|
|
2312
|
-
onFocus: () =>
|
|
2313
|
-
disabled:
|
|
2311
|
+
tabStop: S === "list",
|
|
2312
|
+
onFocus: () => C("list"),
|
|
2313
|
+
disabled: g,
|
|
2314
2314
|
popup: "menu",
|
|
2315
|
-
expanded:
|
|
2316
|
-
controls:
|
|
2317
|
-
active:
|
|
2318
|
-
onClick: () =>
|
|
2319
|
-
onKeyDown: (e) =>
|
|
2315
|
+
expanded: b === "list",
|
|
2316
|
+
controls: P,
|
|
2317
|
+
active: E.list !== null,
|
|
2318
|
+
onClick: () => ye("list"),
|
|
2319
|
+
onKeyDown: (e) => Se("list", e),
|
|
2320
2320
|
children: [/* @__PURE__ */ p(X, { name: ke }), /* @__PURE__ */ p(X, {
|
|
2321
2321
|
name: "chevron",
|
|
2322
2322
|
className: "editor-toolbar-chevron"
|
|
2323
2323
|
})]
|
|
2324
|
-
}),
|
|
2325
|
-
id:
|
|
2324
|
+
}), b === "list" ? /* @__PURE__ */ m("div", {
|
|
2325
|
+
id: P,
|
|
2326
2326
|
ref: _,
|
|
2327
2327
|
className: "editor-toolbar-popover editor-toolbar-list-menu",
|
|
2328
2328
|
role: "menu",
|
|
2329
2329
|
"aria-label": L.listMenuLabel,
|
|
2330
|
-
style:
|
|
2330
|
+
style: O ?? void 0,
|
|
2331
2331
|
onKeyDown: (e) => rt(e, _.current),
|
|
2332
2332
|
children: [
|
|
2333
2333
|
B.map((e) => /* @__PURE__ */ m("button", {
|
|
2334
2334
|
type: "button",
|
|
2335
2335
|
role: "menuitemradio",
|
|
2336
|
-
"aria-checked":
|
|
2336
|
+
"aria-checked": E.list === e.type,
|
|
2337
2337
|
tabIndex: -1,
|
|
2338
2338
|
className: "editor-toolbar-menu-item editor-toolbar-list-item",
|
|
2339
2339
|
onMouseDown: Z,
|
|
2340
|
-
onClick: () =>
|
|
2340
|
+
onClick: () => q(e.command),
|
|
2341
2341
|
children: [/* @__PURE__ */ p(X, {
|
|
2342
2342
|
name: e.icon,
|
|
2343
2343
|
className: "editor-toolbar-menu-icon"
|
|
@@ -2347,13 +2347,13 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2347
2347
|
className: "editor-toolbar-menu-divider",
|
|
2348
2348
|
role: "separator"
|
|
2349
2349
|
}),
|
|
2350
|
-
|
|
2350
|
+
ue.map((e) => /* @__PURE__ */ m("button", {
|
|
2351
2351
|
type: "button",
|
|
2352
2352
|
role: "menuitem",
|
|
2353
2353
|
tabIndex: -1,
|
|
2354
2354
|
className: "editor-toolbar-menu-item editor-toolbar-list-item",
|
|
2355
2355
|
onMouseDown: Z,
|
|
2356
|
-
onClick: () =>
|
|
2356
|
+
onClick: () => q(e.command),
|
|
2357
2357
|
children: [/* @__PURE__ */ p(X, {
|
|
2358
2358
|
name: e.icon,
|
|
2359
2359
|
className: "editor-toolbar-menu-icon"
|
|
@@ -2366,10 +2366,10 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2366
2366
|
toolbarId: "link",
|
|
2367
2367
|
label: L.insertLink,
|
|
2368
2368
|
className: "editor-toolbar-desktop-only",
|
|
2369
|
-
tabStop:
|
|
2370
|
-
onFocus: () =>
|
|
2371
|
-
disabled:
|
|
2372
|
-
onClick: () =>
|
|
2369
|
+
tabStop: S === "link",
|
|
2370
|
+
onFocus: () => C("link"),
|
|
2371
|
+
disabled: g,
|
|
2372
|
+
onClick: () => q(fe),
|
|
2373
2373
|
children: /* @__PURE__ */ p(X, { name: "link" })
|
|
2374
2374
|
}),
|
|
2375
2375
|
/* @__PURE__ */ m("div", {
|
|
@@ -2379,14 +2379,14 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2379
2379
|
toolbarId: "insert",
|
|
2380
2380
|
label: L.insert,
|
|
2381
2381
|
className: "editor-toolbar-insert-trigger",
|
|
2382
|
-
tabStop:
|
|
2383
|
-
onFocus: () =>
|
|
2384
|
-
disabled:
|
|
2382
|
+
tabStop: S === "insert",
|
|
2383
|
+
onFocus: () => C("insert"),
|
|
2384
|
+
disabled: g,
|
|
2385
2385
|
popup: "menu",
|
|
2386
|
-
expanded:
|
|
2387
|
-
controls:
|
|
2388
|
-
onClick: () =>
|
|
2389
|
-
onKeyDown: (e) =>
|
|
2386
|
+
expanded: b === "insert" || b === "emoji",
|
|
2387
|
+
controls: b === "emoji" ? oe : se,
|
|
2388
|
+
onClick: () => ye("insert"),
|
|
2389
|
+
onKeyDown: (e) => Se("insert", e),
|
|
2390
2390
|
children: [
|
|
2391
2391
|
/* @__PURE__ */ p(X, { name: "plus" }),
|
|
2392
2392
|
/* @__PURE__ */ p("span", {
|
|
@@ -2399,21 +2399,21 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2399
2399
|
})
|
|
2400
2400
|
]
|
|
2401
2401
|
}),
|
|
2402
|
-
|
|
2403
|
-
id:
|
|
2402
|
+
b === "insert" ? /* @__PURE__ */ m("div", {
|
|
2403
|
+
id: se,
|
|
2404
2404
|
ref: _,
|
|
2405
2405
|
className: "editor-toolbar-popover editor-toolbar-insert-menu",
|
|
2406
2406
|
role: "menu",
|
|
2407
2407
|
"aria-label": L.insertMenuLabel,
|
|
2408
|
-
style:
|
|
2408
|
+
style: O ?? void 0,
|
|
2409
2409
|
onKeyDown: (e) => rt(e, _.current),
|
|
2410
|
-
children: [
|
|
2410
|
+
children: [V.map((e) => /* @__PURE__ */ m("button", {
|
|
2411
2411
|
type: "button",
|
|
2412
2412
|
role: "menuitem",
|
|
2413
2413
|
tabIndex: -1,
|
|
2414
2414
|
className: "editor-toolbar-menu-item editor-toolbar-insert-item",
|
|
2415
2415
|
onMouseDown: Z,
|
|
2416
|
-
onClick: () =>
|
|
2416
|
+
onClick: () => q(e.command),
|
|
2417
2417
|
children: [/* @__PURE__ */ p(X, {
|
|
2418
2418
|
name: e.icon,
|
|
2419
2419
|
className: "editor-toolbar-menu-icon"
|
|
@@ -2424,23 +2424,23 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2424
2424
|
tabIndex: -1,
|
|
2425
2425
|
className: "editor-toolbar-menu-item editor-toolbar-insert-item",
|
|
2426
2426
|
onMouseDown: Z,
|
|
2427
|
-
onClick: () =>
|
|
2427
|
+
onClick: () => x("emoji"),
|
|
2428
2428
|
children: [/* @__PURE__ */ p(X, {
|
|
2429
2429
|
name: "smile",
|
|
2430
2430
|
className: "editor-toolbar-menu-icon"
|
|
2431
2431
|
}), /* @__PURE__ */ p("span", { children: L.emoji })]
|
|
2432
2432
|
})]
|
|
2433
2433
|
}) : null,
|
|
2434
|
-
|
|
2435
|
-
id:
|
|
2434
|
+
b === "emoji" ? /* @__PURE__ */ p("div", {
|
|
2435
|
+
id: oe,
|
|
2436
2436
|
ref: _,
|
|
2437
2437
|
className: "editor-toolbar-popover editor-toolbar-emoji-menu",
|
|
2438
2438
|
role: "menu",
|
|
2439
2439
|
"aria-label": L.insertEmojiMenuLabel,
|
|
2440
|
-
onKeyDown: (e) => it(e,
|
|
2440
|
+
onKeyDown: (e) => it(e, ne.current),
|
|
2441
2441
|
children: /* @__PURE__ */ p("div", {
|
|
2442
2442
|
className: "editor-toolbar-emoji-grid",
|
|
2443
|
-
ref:
|
|
2443
|
+
ref: ne,
|
|
2444
2444
|
children: We.map((e) => /* @__PURE__ */ p("button", {
|
|
2445
2445
|
type: "button",
|
|
2446
2446
|
role: "menuitem",
|
|
@@ -2448,7 +2448,7 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2448
2448
|
className: "editor-toolbar-emoji",
|
|
2449
2449
|
"aria-label": L.insertEmojiLabel(e),
|
|
2450
2450
|
onMouseDown: Z,
|
|
2451
|
-
onClick: () =>
|
|
2451
|
+
onClick: () => me(e),
|
|
2452
2452
|
children: e
|
|
2453
2453
|
}, e))
|
|
2454
2454
|
})
|
|
@@ -2461,14 +2461,14 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2461
2461
|
toolbarId: "components",
|
|
2462
2462
|
label: L.componentsTriggerLabel,
|
|
2463
2463
|
className: "editor-toolbar-components-trigger",
|
|
2464
|
-
tabStop:
|
|
2465
|
-
onFocus: () =>
|
|
2466
|
-
disabled:
|
|
2464
|
+
tabStop: S === "components",
|
|
2465
|
+
onFocus: () => C("components"),
|
|
2466
|
+
disabled: g,
|
|
2467
2467
|
popup: "dialog",
|
|
2468
|
-
expanded:
|
|
2469
|
-
controls:
|
|
2470
|
-
onClick: () =>
|
|
2471
|
-
onKeyDown: (e) =>
|
|
2468
|
+
expanded: b === "native",
|
|
2469
|
+
controls: le,
|
|
2470
|
+
onClick: () => ye("native"),
|
|
2471
|
+
onKeyDown: (e) => Se("native", e),
|
|
2472
2472
|
children: [
|
|
2473
2473
|
/* @__PURE__ */ p(X, { name: "sparkle" }),
|
|
2474
2474
|
/* @__PURE__ */ p("span", {
|
|
@@ -2480,8 +2480,8 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2480
2480
|
children: L.componentsCompactLabel
|
|
2481
2481
|
})
|
|
2482
2482
|
]
|
|
2483
|
-
}),
|
|
2484
|
-
id:
|
|
2483
|
+
}), b === "native" ? /* @__PURE__ */ m("div", {
|
|
2484
|
+
id: le,
|
|
2485
2485
|
ref: _,
|
|
2486
2486
|
className: "editor-toolbar-popover editor-toolbar-native-menu",
|
|
2487
2487
|
role: "dialog",
|
|
@@ -2498,7 +2498,7 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2498
2498
|
className: "editor-toolbar-close",
|
|
2499
2499
|
"aria-label": L.closeNativeLabel,
|
|
2500
2500
|
onMouseDown: Z,
|
|
2501
|
-
onClick:
|
|
2501
|
+
onClick: Te,
|
|
2502
2502
|
children: /* @__PURE__ */ p(X, { name: "close" })
|
|
2503
2503
|
})]
|
|
2504
2504
|
}),
|
|
@@ -2508,25 +2508,25 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2508
2508
|
name: "search",
|
|
2509
2509
|
className: "editor-toolbar-search-icon"
|
|
2510
2510
|
}), /* @__PURE__ */ p("input", {
|
|
2511
|
-
ref:
|
|
2511
|
+
ref: v,
|
|
2512
2512
|
type: "search",
|
|
2513
2513
|
className: "editor-toolbar-search-input",
|
|
2514
|
-
value:
|
|
2514
|
+
value: w,
|
|
2515
2515
|
placeholder: L.searchPlaceholder,
|
|
2516
2516
|
"aria-label": L.searchLabel,
|
|
2517
2517
|
autoComplete: "off",
|
|
2518
2518
|
spellCheck: !1,
|
|
2519
|
-
onChange: (e) =>
|
|
2519
|
+
onChange: (e) => T(e.target.value)
|
|
2520
2520
|
})]
|
|
2521
2521
|
}),
|
|
2522
2522
|
/* @__PURE__ */ p("div", {
|
|
2523
2523
|
className: "editor-toolbar-native-scroll",
|
|
2524
2524
|
role: "menu",
|
|
2525
2525
|
"aria-label": L.nativeListLabel,
|
|
2526
|
-
children:
|
|
2526
|
+
children: H.length === 0 ? /* @__PURE__ */ p("p", {
|
|
2527
2527
|
className: "editor-toolbar-menu-empty",
|
|
2528
2528
|
children: L.noMatchingComponents
|
|
2529
|
-
}) :
|
|
2529
|
+
}) : H.map(({ group: e, components: t }) => /* @__PURE__ */ m("div", {
|
|
2530
2530
|
className: "editor-toolbar-native-group",
|
|
2531
2531
|
role: "group",
|
|
2532
2532
|
"aria-label": e.label,
|
|
@@ -2540,7 +2540,7 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2540
2540
|
tabIndex: -1,
|
|
2541
2541
|
className: "editor-toolbar-native-item",
|
|
2542
2542
|
onMouseDown: Z,
|
|
2543
|
-
onClick: () =>
|
|
2543
|
+
onClick: () => he(e),
|
|
2544
2544
|
children: [/* @__PURE__ */ m("span", {
|
|
2545
2545
|
className: "editor-toolbar-native-copy",
|
|
2546
2546
|
children: [/* @__PURE__ */ m("span", {
|
|
@@ -2572,30 +2572,30 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2572
2572
|
toolbarId: "undo",
|
|
2573
2573
|
label: L.undo,
|
|
2574
2574
|
className: "editor-toolbar-desktop-only",
|
|
2575
|
-
tabStop:
|
|
2576
|
-
onFocus: () =>
|
|
2577
|
-
disabled:
|
|
2578
|
-
onClick:
|
|
2575
|
+
tabStop: S === "undo",
|
|
2576
|
+
onFocus: () => C("undo"),
|
|
2577
|
+
disabled: g || !s,
|
|
2578
|
+
onClick: ge,
|
|
2579
2579
|
children: /* @__PURE__ */ p(X, { name: "undo" })
|
|
2580
2580
|
}),
|
|
2581
2581
|
/* @__PURE__ */ p(Q, {
|
|
2582
2582
|
toolbarId: "redo",
|
|
2583
2583
|
label: L.redo,
|
|
2584
2584
|
className: "editor-toolbar-desktop-only",
|
|
2585
|
-
tabStop:
|
|
2586
|
-
onFocus: () =>
|
|
2587
|
-
disabled:
|
|
2588
|
-
onClick:
|
|
2585
|
+
tabStop: S === "redo",
|
|
2586
|
+
onFocus: () => C("redo"),
|
|
2587
|
+
disabled: g || !f,
|
|
2588
|
+
onClick: _e,
|
|
2589
2589
|
children: /* @__PURE__ */ p(X, { name: "redo" })
|
|
2590
2590
|
}),
|
|
2591
|
-
|
|
2591
|
+
ee ? /* @__PURE__ */ p(Q, {
|
|
2592
2592
|
toolbarId: "download",
|
|
2593
2593
|
label: L.download,
|
|
2594
2594
|
className: "editor-toolbar-desktop-only",
|
|
2595
|
-
tabStop:
|
|
2596
|
-
onFocus: () =>
|
|
2597
|
-
disabled:
|
|
2598
|
-
onClick:
|
|
2595
|
+
tabStop: S === "download",
|
|
2596
|
+
onFocus: () => C("download"),
|
|
2597
|
+
disabled: g,
|
|
2598
|
+
onClick: ve,
|
|
2599
2599
|
children: /* @__PURE__ */ p(X, { name: "download" })
|
|
2600
2600
|
}) : null,
|
|
2601
2601
|
/* @__PURE__ */ m("div", {
|
|
@@ -2604,22 +2604,22 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2604
2604
|
toolbarId: "more",
|
|
2605
2605
|
label: L.more,
|
|
2606
2606
|
className: "editor-toolbar-more-trigger",
|
|
2607
|
-
tabStop:
|
|
2608
|
-
onFocus: () =>
|
|
2609
|
-
disabled:
|
|
2607
|
+
tabStop: S === "more",
|
|
2608
|
+
onFocus: () => C("more"),
|
|
2609
|
+
disabled: g,
|
|
2610
2610
|
popup: "menu",
|
|
2611
|
-
expanded:
|
|
2612
|
-
controls:
|
|
2613
|
-
onClick: () =>
|
|
2614
|
-
onKeyDown: (e) =>
|
|
2611
|
+
expanded: b === "more",
|
|
2612
|
+
controls: ce,
|
|
2613
|
+
onClick: () => ye("more"),
|
|
2614
|
+
onKeyDown: (e) => Se("more", e),
|
|
2615
2615
|
children: /* @__PURE__ */ p(X, { name: "more" })
|
|
2616
|
-
}),
|
|
2617
|
-
id:
|
|
2616
|
+
}), b === "more" ? /* @__PURE__ */ m("div", {
|
|
2617
|
+
id: ce,
|
|
2618
2618
|
ref: _,
|
|
2619
2619
|
className: "editor-toolbar-popover editor-toolbar-more-menu",
|
|
2620
2620
|
role: "menu",
|
|
2621
2621
|
"aria-label": L.moreMenuLabel,
|
|
2622
|
-
style:
|
|
2622
|
+
style: O ?? void 0,
|
|
2623
2623
|
onKeyDown: (e) => rt(e, _.current),
|
|
2624
2624
|
children: [
|
|
2625
2625
|
/* @__PURE__ */ m("button", {
|
|
@@ -2628,7 +2628,7 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2628
2628
|
tabIndex: -1,
|
|
2629
2629
|
className: "editor-toolbar-menu-item editor-toolbar-more-item editor-toolbar-more-link",
|
|
2630
2630
|
onMouseDown: Z,
|
|
2631
|
-
onClick: () =>
|
|
2631
|
+
onClick: () => q(fe),
|
|
2632
2632
|
children: [/* @__PURE__ */ p(X, {
|
|
2633
2633
|
name: "link",
|
|
2634
2634
|
className: "editor-toolbar-menu-icon"
|
|
@@ -2641,7 +2641,7 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2641
2641
|
className: "editor-toolbar-menu-item editor-toolbar-more-item",
|
|
2642
2642
|
disabled: !s,
|
|
2643
2643
|
onMouseDown: Z,
|
|
2644
|
-
onClick:
|
|
2644
|
+
onClick: ge,
|
|
2645
2645
|
children: [/* @__PURE__ */ p(X, {
|
|
2646
2646
|
name: "undo",
|
|
2647
2647
|
className: "editor-toolbar-menu-icon"
|
|
@@ -2654,19 +2654,19 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2654
2654
|
className: "editor-toolbar-menu-item editor-toolbar-more-item",
|
|
2655
2655
|
disabled: !f,
|
|
2656
2656
|
onMouseDown: Z,
|
|
2657
|
-
onClick:
|
|
2657
|
+
onClick: _e,
|
|
2658
2658
|
children: [/* @__PURE__ */ p(X, {
|
|
2659
2659
|
name: "redo",
|
|
2660
2660
|
className: "editor-toolbar-menu-icon"
|
|
2661
2661
|
}), /* @__PURE__ */ p("span", { children: L.redo })]
|
|
2662
2662
|
}),
|
|
2663
|
-
|
|
2663
|
+
ee ? /* @__PURE__ */ m("button", {
|
|
2664
2664
|
type: "button",
|
|
2665
2665
|
role: "menuitem",
|
|
2666
2666
|
tabIndex: -1,
|
|
2667
2667
|
className: "editor-toolbar-menu-item editor-toolbar-more-item",
|
|
2668
2668
|
onMouseDown: Z,
|
|
2669
|
-
onClick:
|
|
2669
|
+
onClick: ve,
|
|
2670
2670
|
children: [/* @__PURE__ */ p(X, {
|
|
2671
2671
|
name: "download",
|
|
2672
2672
|
className: "editor-toolbar-menu-icon"
|
|
@@ -2682,7 +2682,7 @@ function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2682
2682
|
}
|
|
2683
2683
|
// src/editor/editor-view-bar.tsx
|
|
2684
2684
|
function ot({ source: e, mode: t, onModeChange: n, sourceId: r, previewId: i, hasPreview: a, allowSplit: o, toolbar: s }) {
|
|
2685
|
-
let c =
|
|
2685
|
+
let c = ae(), u = ne[c], d = l(() => Array.from(e).length, [e]);
|
|
2686
2686
|
return /* @__PURE__ */ m("div", {
|
|
2687
2687
|
className: "editor-status-bar",
|
|
2688
2688
|
role: "group",
|
|
@@ -2772,11 +2772,11 @@ function dt(e, t) {
|
|
|
2772
2772
|
}
|
|
2773
2773
|
return n;
|
|
2774
2774
|
}
|
|
2775
|
-
function ft(e, t = !0) {
|
|
2775
|
+
function ft(e, t = !0, n) {
|
|
2776
2776
|
return l(() => {
|
|
2777
2777
|
if (!t) return st;
|
|
2778
2778
|
try {
|
|
2779
|
-
let t =
|
|
2779
|
+
let t = h(e, n);
|
|
2780
2780
|
return {
|
|
2781
2781
|
tokens: dt(e, t.tokens),
|
|
2782
2782
|
bindings: t.bindings,
|
|
@@ -2785,7 +2785,11 @@ function ft(e, t = !0) {
|
|
|
2785
2785
|
} catch {
|
|
2786
2786
|
return st;
|
|
2787
2787
|
}
|
|
2788
|
-
}, [
|
|
2788
|
+
}, [
|
|
2789
|
+
e,
|
|
2790
|
+
t,
|
|
2791
|
+
n
|
|
2792
|
+
]);
|
|
2789
2793
|
}
|
|
2790
2794
|
function pt(e, t) {
|
|
2791
2795
|
let n = [], r = 0;
|
|
@@ -3009,12 +3013,12 @@ function Et(e, t) {
|
|
|
3009
3013
|
column: n - r + 1
|
|
3010
3014
|
};
|
|
3011
3015
|
}
|
|
3012
|
-
function Dt({ source: e, analysis: t, bindingDocument: n,
|
|
3013
|
-
let
|
|
3014
|
-
|
|
3015
|
-
let e =
|
|
3016
|
+
function Dt({ source: e, analysis: t, bindingDocument: n, compileOptions: i, editorRef: s, onEdit: c, onLocate: f, disabled: h = !1 }) {
|
|
3017
|
+
let _ = ae(), v = ht[_], ne = o(), re = o(), ie = u(null), y = u(null), [b, x] = d(0), [S, C] = d(null), [w, T] = d(""), [E, D] = d(null), [O, k] = d(null), [A, j] = d(!1), [M, oe] = d([]), [N, P] = d(0), se = u(A), ce = u(M), le = u(N);
|
|
3018
|
+
se.current = A, ce.current = M, le.current = N, a(() => {
|
|
3019
|
+
let e = s.current;
|
|
3016
3020
|
if (!e) return;
|
|
3017
|
-
let t = () =>
|
|
3021
|
+
let t = () => x(e.selectionStart);
|
|
3018
3022
|
t();
|
|
3019
3023
|
let n = [
|
|
3020
3024
|
"select",
|
|
@@ -3027,36 +3031,37 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3027
3031
|
return () => {
|
|
3028
3032
|
for (let r of n) e.removeEventListener(r, t);
|
|
3029
3033
|
};
|
|
3030
|
-
}, [
|
|
3031
|
-
|
|
3034
|
+
}, [s]), a(() => {
|
|
3035
|
+
j(!1);
|
|
3032
3036
|
}, [e]), a(() => {
|
|
3033
|
-
|
|
3034
|
-
}, [
|
|
3035
|
-
let
|
|
3037
|
+
k(null), D(null);
|
|
3038
|
+
}, [_]);
|
|
3039
|
+
let F = l(() => vt(t.bindings, b), [t.bindings, b]);
|
|
3036
3040
|
a(() => {
|
|
3037
|
-
|
|
3038
|
-
}, [
|
|
3039
|
-
let
|
|
3041
|
+
F && C(F.binding.name);
|
|
3042
|
+
}, [F]);
|
|
3043
|
+
let I = l(() => (S ? t.bindings.find((e) => e.name === S) : void 0) ?? t.bindings[0] ?? null, [t.bindings, S]);
|
|
3040
3044
|
a(() => {
|
|
3041
|
-
|
|
3042
|
-
}, [
|
|
3043
|
-
let
|
|
3044
|
-
if (
|
|
3045
|
-
let t =
|
|
3045
|
+
T(""), D(null);
|
|
3046
|
+
}, [I?.name]);
|
|
3047
|
+
let L = I && n ? n.bindings[I.name]?.type ?? n.computations?.[I.name]?.type : void 0, R = F && n ? n.bindings[F.binding.name]?.type ?? n.computations?.[F.binding.name]?.type : void 0, z = R ? v.typeNames[R] ?? R : v.unknownType, B = L ? v.typeNames[L] ?? L : v.unknownType, ue = r(() => {
|
|
3048
|
+
if (h) return;
|
|
3049
|
+
let t = s.current, n = ut(t?.selectionStart ?? 0, 0, e.length), r = [];
|
|
3046
3050
|
try {
|
|
3047
|
-
r =
|
|
3051
|
+
r = ee(e, n, i) ?? [];
|
|
3048
3052
|
} catch {
|
|
3049
3053
|
r = [];
|
|
3050
3054
|
}
|
|
3051
|
-
|
|
3055
|
+
oe(r), P(0), j(!0), k(null);
|
|
3052
3056
|
}, [
|
|
3053
|
-
f,
|
|
3054
3057
|
i,
|
|
3058
|
+
h,
|
|
3059
|
+
s,
|
|
3055
3060
|
e
|
|
3056
3061
|
]), V = r((t) => {
|
|
3057
|
-
if (
|
|
3062
|
+
if (h) return;
|
|
3058
3063
|
let n = ut(t.range.start, 0, e.length), r = ut(t.range.end, n, e.length), i = e.slice(0, n) + t.insertText + e.slice(r), a = n + t.insertText.length;
|
|
3059
|
-
|
|
3064
|
+
j(!1), c({
|
|
3060
3065
|
value: i,
|
|
3061
3066
|
selection: {
|
|
3062
3067
|
start: a,
|
|
@@ -3064,167 +3069,167 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3064
3069
|
}
|
|
3065
3070
|
});
|
|
3066
3071
|
}, [
|
|
3067
|
-
|
|
3068
|
-
|
|
3072
|
+
h,
|
|
3073
|
+
c,
|
|
3069
3074
|
e
|
|
3070
3075
|
]);
|
|
3071
3076
|
a(() => {
|
|
3072
|
-
let e =
|
|
3077
|
+
let e = s.current;
|
|
3073
3078
|
if (!e) return;
|
|
3074
3079
|
let t = (e) => {
|
|
3075
3080
|
if (Tt(e)) return;
|
|
3076
|
-
if (
|
|
3077
|
-
|
|
3081
|
+
if (h) {
|
|
3082
|
+
se.current && j(!1);
|
|
3078
3083
|
return;
|
|
3079
3084
|
}
|
|
3080
3085
|
let t = e.key;
|
|
3081
|
-
if ((e.ctrlKey || e.metaKey) && !e.altKey && (t === " " || t === "Spacebar")) e.preventDefault(), e.stopPropagation(),
|
|
3082
|
-
else if (
|
|
3086
|
+
if ((e.ctrlKey || e.metaKey) && !e.altKey && (t === " " || t === "Spacebar")) e.preventDefault(), e.stopPropagation(), ue();
|
|
3087
|
+
else if (se.current) {
|
|
3083
3088
|
if (t === "ArrowDown" || t === "ArrowUp") {
|
|
3084
3089
|
e.preventDefault(), e.stopPropagation();
|
|
3085
3090
|
let n = ce.current.length;
|
|
3086
|
-
|
|
3091
|
+
P((e) => n === 0 ? 0 : (e + (t === "ArrowDown" ? 1 : -1) + n) % n);
|
|
3087
3092
|
} else if (t === "Enter") {
|
|
3088
3093
|
e.preventDefault(), e.stopPropagation();
|
|
3089
3094
|
let t = ce.current[le.current];
|
|
3090
|
-
t ? V(t) :
|
|
3091
|
-
} else t === "Escape" && (e.preventDefault(), e.stopPropagation(),
|
|
3095
|
+
t ? V(t) : j(!1);
|
|
3096
|
+
} else t === "Escape" && (e.preventDefault(), e.stopPropagation(), j(!1));
|
|
3092
3097
|
}
|
|
3093
3098
|
};
|
|
3094
3099
|
return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
|
|
3095
3100
|
}, [
|
|
3096
3101
|
V,
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3102
|
+
h,
|
|
3103
|
+
s,
|
|
3104
|
+
ue
|
|
3100
3105
|
]), a(() => {
|
|
3101
|
-
if (!
|
|
3106
|
+
if (!A) return;
|
|
3102
3107
|
let e = (e) => {
|
|
3103
|
-
ie.current?.contains(e.target) ||
|
|
3108
|
+
ie.current?.contains(e.target) || j(!1);
|
|
3104
3109
|
}, t = (e) => {
|
|
3105
|
-
e.key === "Escape" && !Tt(e) &&
|
|
3110
|
+
e.key === "Escape" && !Tt(e) && j(!1);
|
|
3106
3111
|
};
|
|
3107
3112
|
return document.addEventListener("pointerdown", e, !0), document.addEventListener("keydown", t, !0), () => {
|
|
3108
3113
|
document.removeEventListener("pointerdown", e, !0), document.removeEventListener("keydown", t, !0);
|
|
3109
3114
|
};
|
|
3110
|
-
}, [
|
|
3111
|
-
|
|
3112
|
-
}, [
|
|
3115
|
+
}, [A]), a(() => {
|
|
3116
|
+
A && y.current?.querySelector(`[data-completion-index="${N}"]`)?.scrollIntoView({ block: "nearest" });
|
|
3117
|
+
}, [N, A]);
|
|
3113
3118
|
let H = () => {
|
|
3114
|
-
if (
|
|
3119
|
+
if (h) return;
|
|
3115
3120
|
let t;
|
|
3116
3121
|
try {
|
|
3117
|
-
t =
|
|
3122
|
+
t = g(e, i);
|
|
3118
3123
|
} catch (e) {
|
|
3119
|
-
|
|
3124
|
+
k(v.formatFailed(e instanceof Error ? e.message : String(e)));
|
|
3120
3125
|
return;
|
|
3121
3126
|
}
|
|
3122
3127
|
if (t === e) {
|
|
3123
|
-
|
|
3128
|
+
k(v.formatUnchanged);
|
|
3124
3129
|
return;
|
|
3125
3130
|
}
|
|
3126
|
-
let n = yt(
|
|
3127
|
-
|
|
3131
|
+
let n = yt(s);
|
|
3132
|
+
c({
|
|
3128
3133
|
value: t,
|
|
3129
3134
|
selection: {
|
|
3130
3135
|
start: St(e, t, n.start),
|
|
3131
3136
|
end: St(e, t, n.end)
|
|
3132
3137
|
}
|
|
3133
|
-
}),
|
|
3138
|
+
}), k(v.formatApplied);
|
|
3134
3139
|
}, U = () => {
|
|
3135
|
-
if (
|
|
3136
|
-
let t =
|
|
3137
|
-
if (!t)
|
|
3138
|
-
else if (t ===
|
|
3140
|
+
if (h || !I) return;
|
|
3141
|
+
let t = w.trim();
|
|
3142
|
+
if (!t) D(v.renameEmpty);
|
|
3143
|
+
else if (t === I.name) D(v.renameSame);
|
|
3139
3144
|
else try {
|
|
3140
|
-
let n =
|
|
3141
|
-
|
|
3145
|
+
let n = te(e, I.name, t, i), r = yt(s);
|
|
3146
|
+
c({
|
|
3142
3147
|
value: n.source,
|
|
3143
3148
|
selection: {
|
|
3144
3149
|
start: Ct(r.start, n.edits),
|
|
3145
3150
|
end: Ct(r.end, n.edits)
|
|
3146
3151
|
}
|
|
3147
|
-
}),
|
|
3152
|
+
}), C(t), T(""), D(null), k(v.renameDone(I.name, t));
|
|
3148
3153
|
} catch (e) {
|
|
3149
|
-
|
|
3154
|
+
D(v.renameFailed(e instanceof Error ? e.message : String(e)));
|
|
3150
3155
|
}
|
|
3151
|
-
}, W =
|
|
3156
|
+
}, W = M[N], G = I ? [...I.declarations.map((e, t) => ({
|
|
3152
3157
|
range: e,
|
|
3153
3158
|
role: "declaration",
|
|
3154
3159
|
index: t
|
|
3155
|
-
})), ...
|
|
3160
|
+
})), ...I.references.map((e, t) => ({
|
|
3156
3161
|
range: e,
|
|
3157
3162
|
role: "reference",
|
|
3158
3163
|
index: t
|
|
3159
3164
|
}))] : [];
|
|
3160
3165
|
return /* @__PURE__ */ m("section", {
|
|
3161
3166
|
className: "source-authoring",
|
|
3162
|
-
"aria-label":
|
|
3167
|
+
"aria-label": v.region,
|
|
3163
3168
|
ref: ie,
|
|
3164
3169
|
children: [
|
|
3165
3170
|
/* @__PURE__ */ m("div", {
|
|
3166
3171
|
className: "authoring-bar",
|
|
3167
3172
|
children: [/* @__PURE__ */ p("span", {
|
|
3168
3173
|
className: "authoring-title",
|
|
3169
|
-
children:
|
|
3174
|
+
children: v.title
|
|
3170
3175
|
}), /* @__PURE__ */ m("div", {
|
|
3171
3176
|
className: "authoring-actions",
|
|
3172
3177
|
children: [/* @__PURE__ */ p("button", {
|
|
3173
3178
|
type: "button",
|
|
3174
3179
|
className: "authoring-button",
|
|
3175
3180
|
"data-authoring-action": "format",
|
|
3176
|
-
title:
|
|
3177
|
-
disabled:
|
|
3181
|
+
title: v.formatTitle,
|
|
3182
|
+
disabled: h,
|
|
3178
3183
|
onMouseDown: wt,
|
|
3179
3184
|
onClick: H,
|
|
3180
|
-
children:
|
|
3185
|
+
children: v.format
|
|
3181
3186
|
}), /* @__PURE__ */ p("button", {
|
|
3182
3187
|
type: "button",
|
|
3183
3188
|
className: "authoring-button",
|
|
3184
3189
|
"data-authoring-action": "suggest",
|
|
3185
|
-
title:
|
|
3186
|
-
"aria-expanded":
|
|
3190
|
+
title: v.suggestionsTitle,
|
|
3191
|
+
"aria-expanded": A,
|
|
3187
3192
|
"aria-controls": re,
|
|
3188
|
-
disabled:
|
|
3193
|
+
disabled: h,
|
|
3189
3194
|
onMouseDown: wt,
|
|
3190
|
-
onClick:
|
|
3191
|
-
children:
|
|
3195
|
+
onClick: ue,
|
|
3196
|
+
children: v.suggestions
|
|
3192
3197
|
})]
|
|
3193
3198
|
})]
|
|
3194
3199
|
}),
|
|
3195
|
-
|
|
3200
|
+
A ? /* @__PURE__ */ m("div", {
|
|
3196
3201
|
className: "authoring-completion",
|
|
3197
|
-
"aria-label":
|
|
3202
|
+
"aria-label": v.completionLabel,
|
|
3198
3203
|
children: [
|
|
3199
3204
|
/* @__PURE__ */ m("div", {
|
|
3200
3205
|
className: "authoring-completion-head",
|
|
3201
|
-
children: [/* @__PURE__ */ p("span", { children:
|
|
3206
|
+
children: [/* @__PURE__ */ p("span", { children: v.completionLabel }), /* @__PURE__ */ p("span", {
|
|
3202
3207
|
className: "authoring-completion-count",
|
|
3203
|
-
children:
|
|
3208
|
+
children: v.completionCount(M.length)
|
|
3204
3209
|
})]
|
|
3205
3210
|
}),
|
|
3206
3211
|
/* @__PURE__ */ p("div", {
|
|
3207
3212
|
id: re,
|
|
3208
3213
|
className: "authoring-completion-list",
|
|
3209
3214
|
role: "listbox",
|
|
3210
|
-
"aria-label":
|
|
3211
|
-
ref:
|
|
3212
|
-
children:
|
|
3215
|
+
"aria-label": v.completionLabel,
|
|
3216
|
+
ref: y,
|
|
3217
|
+
children: M.length === 0 ? /* @__PURE__ */ p("p", {
|
|
3213
3218
|
className: "authoring-empty",
|
|
3214
|
-
children:
|
|
3215
|
-
}) :
|
|
3219
|
+
children: v.completionEmpty
|
|
3220
|
+
}) : M.map((e, t) => /* @__PURE__ */ m("button", {
|
|
3216
3221
|
type: "button",
|
|
3217
3222
|
role: "option",
|
|
3218
3223
|
"data-completion-index": t,
|
|
3219
|
-
"aria-selected": t ===
|
|
3220
|
-
className: `authoring-completion-item${t ===
|
|
3224
|
+
"aria-selected": t === N,
|
|
3225
|
+
className: `authoring-completion-item${t === N ? " is-active" : ""}`,
|
|
3221
3226
|
onMouseDown: wt,
|
|
3222
|
-
onMouseEnter: () =>
|
|
3227
|
+
onMouseEnter: () => P(t),
|
|
3223
3228
|
onClick: () => V(e),
|
|
3224
3229
|
children: [
|
|
3225
3230
|
/* @__PURE__ */ p("span", {
|
|
3226
3231
|
className: `authoring-kind is-${e.kind}`,
|
|
3227
|
-
children:
|
|
3232
|
+
children: v.kinds[e.kind] ?? e.kind
|
|
3228
3233
|
}),
|
|
3229
3234
|
/* @__PURE__ */ p("span", {
|
|
3230
3235
|
className: "authoring-completion-label",
|
|
@@ -3240,7 +3245,7 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3240
3245
|
/* @__PURE__ */ p("p", {
|
|
3241
3246
|
className: "reactive-md-editor-sr-only",
|
|
3242
3247
|
"aria-live": "polite",
|
|
3243
|
-
children: W ? `${
|
|
3248
|
+
children: W ? `${v.kinds[W.kind] ?? W.kind} ${W.label}` : ""
|
|
3244
3249
|
})
|
|
3245
3250
|
]
|
|
3246
3251
|
}) : null,
|
|
@@ -3249,48 +3254,48 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3249
3254
|
children: [
|
|
3250
3255
|
/* @__PURE__ */ m("p", {
|
|
3251
3256
|
className: "authoring-caret",
|
|
3252
|
-
"data-binding-caret":
|
|
3257
|
+
"data-binding-caret": F?.binding.name ?? "",
|
|
3253
3258
|
children: [/* @__PURE__ */ p("span", {
|
|
3254
3259
|
className: "authoring-label",
|
|
3255
|
-
children:
|
|
3256
|
-
}),
|
|
3260
|
+
children: v.caretLabel
|
|
3261
|
+
}), F ? /* @__PURE__ */ m("span", {
|
|
3257
3262
|
className: "authoring-caret-value",
|
|
3258
3263
|
children: [
|
|
3259
|
-
/* @__PURE__ */ p("strong", { children:
|
|
3264
|
+
/* @__PURE__ */ p("strong", { children: F.binding.name }),
|
|
3260
3265
|
/* @__PURE__ */ m("span", {
|
|
3261
3266
|
className: "authoring-type",
|
|
3262
3267
|
children: [
|
|
3263
|
-
|
|
3268
|
+
v.typeLabel,
|
|
3264
3269
|
": ",
|
|
3265
|
-
|
|
3270
|
+
z
|
|
3266
3271
|
]
|
|
3267
3272
|
}),
|
|
3268
|
-
/* @__PURE__ */ p("span", { children:
|
|
3269
|
-
/* @__PURE__ */ p("span", { children:
|
|
3273
|
+
/* @__PURE__ */ p("span", { children: v.declarationCount(F.binding.declarations.length) }),
|
|
3274
|
+
/* @__PURE__ */ p("span", { children: v.referenceCount(F.binding.references.length) })
|
|
3270
3275
|
]
|
|
3271
3276
|
}) : /* @__PURE__ */ p("span", {
|
|
3272
3277
|
className: "authoring-muted",
|
|
3273
|
-
children:
|
|
3278
|
+
children: v.noBindingAtCaret
|
|
3274
3279
|
})]
|
|
3275
3280
|
}),
|
|
3276
3281
|
/* @__PURE__ */ m("div", {
|
|
3277
3282
|
className: "authoring-row",
|
|
3278
3283
|
children: [/* @__PURE__ */ p("span", {
|
|
3279
3284
|
className: "authoring-label",
|
|
3280
|
-
children:
|
|
3285
|
+
children: v.bindingsLabel
|
|
3281
3286
|
}), /* @__PURE__ */ p("div", {
|
|
3282
3287
|
className: "authoring-binding-list",
|
|
3283
3288
|
children: t.bindings.length === 0 ? /* @__PURE__ */ p("span", {
|
|
3284
3289
|
className: "authoring-muted",
|
|
3285
|
-
children:
|
|
3290
|
+
children: v.noBindings
|
|
3286
3291
|
}) : t.bindings.map((e) => /* @__PURE__ */ m("button", {
|
|
3287
3292
|
type: "button",
|
|
3288
3293
|
"data-binding-name": e.name,
|
|
3289
3294
|
className: "authoring-binding-chip",
|
|
3290
|
-
"aria-pressed": e.name ===
|
|
3291
|
-
title: `${
|
|
3295
|
+
"aria-pressed": e.name === I?.name,
|
|
3296
|
+
title: `${v.declarationCount(e.declarations.length)} · ${v.referenceCount(e.references.length)}`,
|
|
3292
3297
|
onClick: () => {
|
|
3293
|
-
|
|
3298
|
+
C(e.name), k(null);
|
|
3294
3299
|
},
|
|
3295
3300
|
children: [/* @__PURE__ */ p("span", { children: e.name }), /* @__PURE__ */ m("span", {
|
|
3296
3301
|
className: "authoring-binding-count",
|
|
@@ -3303,20 +3308,20 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3303
3308
|
}, e.name))
|
|
3304
3309
|
})]
|
|
3305
3310
|
}),
|
|
3306
|
-
|
|
3311
|
+
I ? /* @__PURE__ */ m("div", {
|
|
3307
3312
|
className: "authoring-row",
|
|
3308
3313
|
children: [/* @__PURE__ */ m("span", {
|
|
3309
3314
|
className: "authoring-label",
|
|
3310
3315
|
children: [
|
|
3311
|
-
|
|
3316
|
+
I.name,
|
|
3312
3317
|
" · ",
|
|
3313
|
-
|
|
3318
|
+
v.typeLabel,
|
|
3314
3319
|
": ",
|
|
3315
|
-
|
|
3320
|
+
B
|
|
3316
3321
|
]
|
|
3317
3322
|
}), /* @__PURE__ */ p("div", {
|
|
3318
3323
|
className: "authoring-locations",
|
|
3319
|
-
children:
|
|
3324
|
+
children: G.map(({ range: t, role: n, index: r }) => {
|
|
3320
3325
|
let i = Et(e, t.start);
|
|
3321
3326
|
return /* @__PURE__ */ m("button", {
|
|
3322
3327
|
type: "button",
|
|
@@ -3324,17 +3329,17 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3324
3329
|
"data-binding-location": n,
|
|
3325
3330
|
"data-start": t.start,
|
|
3326
3331
|
"data-end": t.end,
|
|
3327
|
-
title:
|
|
3332
|
+
title: v.locateTitle,
|
|
3328
3333
|
onClick: () => {
|
|
3329
|
-
|
|
3334
|
+
C(I.name), f(t);
|
|
3330
3335
|
},
|
|
3331
3336
|
children: [/* @__PURE__ */ m("span", { children: [
|
|
3332
|
-
n === "declaration" ?
|
|
3337
|
+
n === "declaration" ? v.declaration : v.reference,
|
|
3333
3338
|
" ",
|
|
3334
3339
|
r + 1
|
|
3335
3340
|
] }), /* @__PURE__ */ p("span", {
|
|
3336
3341
|
className: "authoring-location-position",
|
|
3337
|
-
children:
|
|
3342
|
+
children: v.position(i.line, i.column)
|
|
3338
3343
|
})]
|
|
3339
3344
|
}, `${n}-${t.start}-${t.end}`);
|
|
3340
3345
|
})
|
|
@@ -3346,7 +3351,7 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3346
3351
|
/* @__PURE__ */ p("label", {
|
|
3347
3352
|
className: "authoring-label",
|
|
3348
3353
|
htmlFor: ne,
|
|
3349
|
-
children:
|
|
3354
|
+
children: v.renameLabel
|
|
3350
3355
|
}),
|
|
3351
3356
|
/* @__PURE__ */ m("div", {
|
|
3352
3357
|
className: "authoring-rename-row",
|
|
@@ -3355,13 +3360,13 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3355
3360
|
type: "text",
|
|
3356
3361
|
className: "authoring-rename-input",
|
|
3357
3362
|
"data-authoring-action": "rename-input",
|
|
3358
|
-
value:
|
|
3359
|
-
placeholder:
|
|
3363
|
+
value: w,
|
|
3364
|
+
placeholder: v.renamePlaceholder,
|
|
3360
3365
|
autoComplete: "off",
|
|
3361
3366
|
spellCheck: !1,
|
|
3362
|
-
disabled:
|
|
3367
|
+
disabled: h || !I,
|
|
3363
3368
|
onChange: (e) => {
|
|
3364
|
-
|
|
3369
|
+
T(e.target.value), D(null);
|
|
3365
3370
|
},
|
|
3366
3371
|
onKeyDown: (e) => {
|
|
3367
3372
|
e.key === "Enter" && Tt(e.nativeEvent) && e.preventDefault();
|
|
@@ -3370,29 +3375,29 @@ function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3370
3375
|
type: "button",
|
|
3371
3376
|
className: "authoring-button authoring-primary",
|
|
3372
3377
|
"data-authoring-action": "rename",
|
|
3373
|
-
disabled:
|
|
3378
|
+
disabled: h || !I,
|
|
3374
3379
|
onMouseDown: wt,
|
|
3375
3380
|
onClick: U,
|
|
3376
|
-
title:
|
|
3377
|
-
children:
|
|
3381
|
+
title: v.renameTitle,
|
|
3382
|
+
children: v.renameAction
|
|
3378
3383
|
})]
|
|
3379
3384
|
}),
|
|
3380
|
-
|
|
3385
|
+
E ? /* @__PURE__ */ p("p", {
|
|
3381
3386
|
className: "authoring-error",
|
|
3382
3387
|
role: "alert",
|
|
3383
|
-
children:
|
|
3388
|
+
children: E
|
|
3384
3389
|
}) : null,
|
|
3385
3390
|
/* @__PURE__ */ p("p", {
|
|
3386
3391
|
className: "authoring-hint",
|
|
3387
|
-
children:
|
|
3392
|
+
children: v.renameHint
|
|
3388
3393
|
})
|
|
3389
3394
|
]
|
|
3390
3395
|
}),
|
|
3391
|
-
|
|
3396
|
+
O ? /* @__PURE__ */ p("p", {
|
|
3392
3397
|
className: "authoring-status",
|
|
3393
3398
|
"data-authoring-status": "true",
|
|
3394
3399
|
role: "status",
|
|
3395
|
-
children:
|
|
3400
|
+
children: O
|
|
3396
3401
|
}) : null
|
|
3397
3402
|
]
|
|
3398
3403
|
})
|
|
@@ -3518,71 +3523,71 @@ function It(e, t) {
|
|
|
3518
3523
|
function Lt(e, t) {
|
|
3519
3524
|
e && (e.current = t);
|
|
3520
3525
|
}
|
|
3521
|
-
var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto", preview: a, viewMode: f, defaultViewMode:
|
|
3522
|
-
let
|
|
3526
|
+
var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto", preview: a, viewMode: f, defaultViewMode: h = "edit", onViewModeChange: ee, id: g, className: te, style: _, height: v = 560, minHeight: re = 280, placeholder: ie, ariaLabel: y, readOnly: b = !1, disabled: ae = !1, documentKey: S, diagnostics: C, compileOptions: w, document: T = null, toolbar: E = !0, authoring: D = !0, onExport: O, textareaRef: k }, A) {
|
|
3527
|
+
let j = o(), M = g ?? `reactive-md-editor-${j.replace(/:/g, "")}`, oe = ne[n], N = u(null), [P, se] = d(!1);
|
|
3523
3528
|
c(() => {
|
|
3524
|
-
let e =
|
|
3529
|
+
let e = N.current;
|
|
3525
3530
|
if (!e) return;
|
|
3526
|
-
let t = () =>
|
|
3531
|
+
let t = () => se(e.clientWidth <= 600);
|
|
3527
3532
|
if (t(), typeof ResizeObserver > "u") return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
3528
3533
|
let n = new ResizeObserver(t);
|
|
3529
3534
|
return n.observe(e), () => n.disconnect();
|
|
3530
3535
|
}, []);
|
|
3531
|
-
let [ce, le] = d(
|
|
3532
|
-
f === void 0 && le(e),
|
|
3533
|
-
},
|
|
3536
|
+
let [ce, le] = d(h), F = a != null, I = F ? f ?? ce : "edit", L = P && I === "split" ? "edit" : I, R = (e) => {
|
|
3537
|
+
f === void 0 && le(e), ee?.(e);
|
|
3538
|
+
}, z = u(null), B = u(null), ue = u(null), V = u({
|
|
3534
3539
|
start: 0,
|
|
3535
3540
|
end: 0
|
|
3536
|
-
}), H = u(null), U = u(e), W = u(
|
|
3537
|
-
|
|
3538
|
-
let
|
|
3539
|
-
pe.current =
|
|
3540
|
-
let [me, he] = d(!1), [ge, _e] = d(1), { canUndo: ve, canRedo: ye, record:
|
|
3541
|
+
}), H = u(null), U = u(e), W = u(S), G = u(!1), K = u(!1), q = u(e);
|
|
3542
|
+
q.current = e;
|
|
3543
|
+
let fe = b || ae, pe = u(fe);
|
|
3544
|
+
pe.current = fe;
|
|
3545
|
+
let [me, he] = d(!1), [ge, _e] = d(1), { canUndo: ve, canRedo: ye, record: be, undo: xe, redo: Se, reset: Ce } = Pt(e), we = r(() => {
|
|
3541
3546
|
V.current = {
|
|
3542
3547
|
start: 0,
|
|
3543
3548
|
end: 0
|
|
3544
3549
|
};
|
|
3545
|
-
let e =
|
|
3546
|
-
e && (e.setSelectionRange(0, 0), e.scrollTop = 0, e.scrollLeft = 0),
|
|
3550
|
+
let e = z.current;
|
|
3551
|
+
e && (e.setSelectionRange(0, 0), e.scrollTop = 0, e.scrollLeft = 0), B.current && (B.current.scrollTop = 0), _e(1);
|
|
3547
3552
|
}, []);
|
|
3548
3553
|
c(() => {
|
|
3549
|
-
e !== U.current && (U.current = e, H.current = null,
|
|
3554
|
+
e !== U.current && (U.current = e, H.current = null, Ce(e), we());
|
|
3550
3555
|
}, [
|
|
3551
3556
|
e,
|
|
3552
|
-
|
|
3553
|
-
|
|
3557
|
+
Ce,
|
|
3558
|
+
we
|
|
3554
3559
|
]), c(() => {
|
|
3555
|
-
W.current !==
|
|
3560
|
+
W.current !== S && (W.current = S, U.current = e, H.current = null, Ce(e), we());
|
|
3556
3561
|
}, [
|
|
3557
|
-
|
|
3562
|
+
S,
|
|
3558
3563
|
e,
|
|
3559
|
-
|
|
3560
|
-
|
|
3564
|
+
Ce,
|
|
3565
|
+
we
|
|
3561
3566
|
]);
|
|
3562
|
-
let
|
|
3567
|
+
let Te = ft(e, D, w), Ee = l(() => e.split("\n"), [e]), De = kt(Ee, ue, z), Oe = l(() => {
|
|
3563
3568
|
let e = /* @__PURE__ */ new Set();
|
|
3564
|
-
for (let t of
|
|
3569
|
+
for (let t of C ?? []) Number.isInteger(t.line) && t.line > 0 && e.add(t.line);
|
|
3565
3570
|
return e;
|
|
3566
|
-
}, [
|
|
3571
|
+
}, [C]), J = r((e) => {
|
|
3567
3572
|
let t = e.value.length, n = $(e.selectionStart, t), r = $(e.selectionEnd, t);
|
|
3568
3573
|
V.current = {
|
|
3569
3574
|
start: n,
|
|
3570
3575
|
end: r
|
|
3571
3576
|
}, _e(e.value.slice(0, n).split("\n").length);
|
|
3572
3577
|
}, []), Y = r((e, n) => {
|
|
3573
|
-
let r = e !==
|
|
3574
|
-
|
|
3575
|
-
}, [t]),
|
|
3576
|
-
pe.current || (
|
|
3577
|
-
}, [Y, q]), ke = r(() => {
|
|
3578
|
-
if (pe.current) return;
|
|
3579
|
-
let e = be();
|
|
3580
|
-
e && Y(e.value, e.selection);
|
|
3578
|
+
let r = e !== q.current;
|
|
3579
|
+
q.current = e, U.current = e, n && r && (H.current = n), t(e);
|
|
3580
|
+
}, [t]), ke = r((e) => {
|
|
3581
|
+
pe.current || (be(e.value, e.selection, "separate"), Y(e.value, e.selection));
|
|
3581
3582
|
}, [Y, be]), Ae = r(() => {
|
|
3582
3583
|
if (pe.current) return;
|
|
3583
3584
|
let e = xe();
|
|
3584
3585
|
e && Y(e.value, e.selection);
|
|
3585
|
-
}, [Y, xe])
|
|
3586
|
+
}, [Y, xe]), je = r(() => {
|
|
3587
|
+
if (pe.current) return;
|
|
3588
|
+
let e = Se();
|
|
3589
|
+
e && Y(e.value, e.selection);
|
|
3590
|
+
}, [Y, Se]);
|
|
3586
3591
|
c(() => {
|
|
3587
3592
|
let t = H.current;
|
|
3588
3593
|
if (!t) return;
|
|
@@ -3591,23 +3596,23 @@ var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto"
|
|
|
3591
3596
|
return;
|
|
3592
3597
|
}
|
|
3593
3598
|
H.current = null;
|
|
3594
|
-
let n =
|
|
3599
|
+
let n = z.current;
|
|
3595
3600
|
if (!n) return;
|
|
3596
3601
|
let r = It(n.value, t);
|
|
3597
3602
|
n.setSelectionRange(r.start, r.end), n.focus({ preventScroll: !0 }), V.current = r, _e(n.value.slice(0, r.start).split("\n").length);
|
|
3598
3603
|
}, [e]);
|
|
3599
|
-
let
|
|
3600
|
-
let t =
|
|
3604
|
+
let Me = r((e) => {
|
|
3605
|
+
let t = z.current;
|
|
3601
3606
|
if (t && (t.focus({ preventScroll: !0 }), e)) {
|
|
3602
3607
|
let n = It(t.value, e);
|
|
3603
3608
|
t.setSelectionRange(n.start, n.end), V.current = n, _e(t.value.slice(0, n.start).split("\n").length);
|
|
3604
3609
|
}
|
|
3605
|
-
}, []),
|
|
3606
|
-
let t =
|
|
3610
|
+
}, []), Ne = r((e) => {
|
|
3611
|
+
let t = z.current;
|
|
3607
3612
|
if (!t) return;
|
|
3608
3613
|
let n = It(t.value, e);
|
|
3609
|
-
|
|
3610
|
-
let r = t.value.slice(0, n.start).split("\n").length, i =
|
|
3614
|
+
Me(n);
|
|
3615
|
+
let r = t.value.slice(0, n.start).split("\n").length, i = B.current, a = i?.children[r - 1];
|
|
3611
3616
|
if (i && a) {
|
|
3612
3617
|
let e = a.getBoundingClientRect().top - i.getBoundingClientRect().top + i.scrollTop;
|
|
3613
3618
|
t.scrollTop = Math.max(0, e - t.clientHeight / 3);
|
|
@@ -3616,16 +3621,16 @@ var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto"
|
|
|
3616
3621
|
t.scrollTop = Math.max(0, (r - 1) * n - t.clientHeight / 3);
|
|
3617
3622
|
}
|
|
3618
3623
|
i && (i.scrollTop = t.scrollTop);
|
|
3619
|
-
}, [
|
|
3620
|
-
s(
|
|
3624
|
+
}, [Me]);
|
|
3625
|
+
s(A, () => ({
|
|
3621
3626
|
focus(e) {
|
|
3622
|
-
|
|
3627
|
+
Me(e);
|
|
3623
3628
|
},
|
|
3624
3629
|
selectRange(e) {
|
|
3625
|
-
|
|
3630
|
+
Me(e);
|
|
3626
3631
|
},
|
|
3627
3632
|
getSelection() {
|
|
3628
|
-
let e =
|
|
3633
|
+
let e = z.current;
|
|
3629
3634
|
if (!e) return V.current;
|
|
3630
3635
|
let t = e.value.length;
|
|
3631
3636
|
return {
|
|
@@ -3634,33 +3639,46 @@ var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto"
|
|
|
3634
3639
|
};
|
|
3635
3640
|
},
|
|
3636
3641
|
getTextarea() {
|
|
3637
|
-
return
|
|
3642
|
+
return z.current;
|
|
3638
3643
|
},
|
|
3639
|
-
|
|
3640
|
-
|
|
3644
|
+
insertText(e) {
|
|
3645
|
+
let t = z.current;
|
|
3646
|
+
if (!t || pe.current) return;
|
|
3647
|
+
let n = q.current, r = $(t.selectionStart, n.length), i = $(t.selectionEnd, n.length), a = n.slice(0, r) + e + n.slice(i), o = r + e.length;
|
|
3648
|
+
ke({
|
|
3649
|
+
value: a,
|
|
3650
|
+
selection: {
|
|
3651
|
+
start: o,
|
|
3652
|
+
end: o
|
|
3653
|
+
}
|
|
3654
|
+
});
|
|
3655
|
+
},
|
|
3656
|
+
undo: Ae,
|
|
3657
|
+
redo: je
|
|
3641
3658
|
}), [
|
|
3642
|
-
|
|
3659
|
+
Me,
|
|
3643
3660
|
ke,
|
|
3644
|
-
Ae
|
|
3661
|
+
Ae,
|
|
3662
|
+
je
|
|
3645
3663
|
]);
|
|
3646
|
-
let
|
|
3647
|
-
|
|
3648
|
-
}, [
|
|
3664
|
+
let Pe = r((e) => {
|
|
3665
|
+
z.current = e, Lt(k, e);
|
|
3666
|
+
}, [k]), Fe = (e) => {
|
|
3649
3667
|
if (pe.current) return;
|
|
3650
3668
|
let t = e.currentTarget, n = {
|
|
3651
3669
|
start: $(t.selectionStart, t.value.length),
|
|
3652
3670
|
end: $(t.selectionEnd, t.value.length)
|
|
3653
3671
|
};
|
|
3654
|
-
|
|
3655
|
-
},
|
|
3656
|
-
if (
|
|
3672
|
+
be(t.value, n, "merge"), Y(t.value);
|
|
3673
|
+
}, Ie = (e) => {
|
|
3674
|
+
if (G.current || e.nativeEvent.isComposing) return;
|
|
3657
3675
|
if (e.key === "Escape") {
|
|
3658
|
-
|
|
3676
|
+
K.current = E;
|
|
3659
3677
|
return;
|
|
3660
3678
|
}
|
|
3661
|
-
let t =
|
|
3662
|
-
if (
|
|
3663
|
-
let t =
|
|
3679
|
+
let t = K.current && e.key === "Tab" && !e.shiftKey;
|
|
3680
|
+
if (K.current = !1, t) {
|
|
3681
|
+
let t = z.current?.closest(".reactive-md-editor")?.querySelector(".editor-toolbar [tabindex=\"0\"]:not(:disabled)");
|
|
3664
3682
|
if (t) {
|
|
3665
3683
|
e.preventDefault(), t.focus({ preventScroll: !0 });
|
|
3666
3684
|
return;
|
|
@@ -3669,18 +3687,18 @@ var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto"
|
|
|
3669
3687
|
if (pe.current) return;
|
|
3670
3688
|
let n = e.metaKey || e.ctrlKey, r = e.key.toLowerCase();
|
|
3671
3689
|
if (n && !e.altKey && r === "z") {
|
|
3672
|
-
e.preventDefault(), e.shiftKey ?
|
|
3690
|
+
e.preventDefault(), e.shiftKey ? je() : Ae();
|
|
3673
3691
|
return;
|
|
3674
3692
|
}
|
|
3675
3693
|
if (n && !e.altKey && r === "y") {
|
|
3676
|
-
e.preventDefault(),
|
|
3694
|
+
e.preventDefault(), je();
|
|
3677
3695
|
return;
|
|
3678
3696
|
}
|
|
3679
3697
|
if (e.key !== "Tab" || e.shiftKey) return;
|
|
3680
3698
|
e.preventDefault();
|
|
3681
3699
|
let i = e.currentTarget, a = $(i.selectionStart, i.value.length), o = $(i.selectionEnd, i.value.length);
|
|
3682
3700
|
if (a !== o) {
|
|
3683
|
-
|
|
3701
|
+
ke(de(i.value, {
|
|
3684
3702
|
start: a,
|
|
3685
3703
|
end: o
|
|
3686
3704
|
}));
|
|
@@ -3690,67 +3708,67 @@ var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto"
|
|
|
3690
3708
|
start: a + 2,
|
|
3691
3709
|
end: a + 2
|
|
3692
3710
|
};
|
|
3693
|
-
|
|
3694
|
-
},
|
|
3695
|
-
|
|
3696
|
-
}, Le = (e) => {
|
|
3697
|
-
ue.current = !1, he(!1), De(e.currentTarget);
|
|
3711
|
+
be(s, c, "separate"), Y(s, c);
|
|
3712
|
+
}, Le = () => {
|
|
3713
|
+
K.current = !1, G.current = !0, he(!0);
|
|
3698
3714
|
}, Re = (e) => {
|
|
3699
|
-
|
|
3700
|
-
}, ze =
|
|
3701
|
-
|
|
3715
|
+
G.current = !1, he(!1), J(e.currentTarget);
|
|
3716
|
+
}, ze = (e) => {
|
|
3717
|
+
B.current && (B.current.scrollTop = e.currentTarget.scrollTop);
|
|
3718
|
+
}, Be = E, Ve = `reactive-md-editor${te ? ` ${te}` : ""}`;
|
|
3719
|
+
return /* @__PURE__ */ p(x, {
|
|
3702
3720
|
locale: n,
|
|
3703
3721
|
children: /* @__PURE__ */ m("div", {
|
|
3704
|
-
className:
|
|
3722
|
+
className: Ve,
|
|
3705
3723
|
"data-editor-theme": i,
|
|
3706
3724
|
lang: n === "zh" ? "zh-CN" : "en",
|
|
3707
3725
|
style: _,
|
|
3708
3726
|
role: "group",
|
|
3709
|
-
"aria-label":
|
|
3710
|
-
"aria-disabled":
|
|
3711
|
-
inert:
|
|
3727
|
+
"aria-label": oe.region,
|
|
3728
|
+
"aria-disabled": fe || void 0,
|
|
3729
|
+
inert: ae || void 0,
|
|
3712
3730
|
children: [/* @__PURE__ */ m("div", {
|
|
3713
3731
|
className: "editor-frame",
|
|
3714
|
-
ref:
|
|
3715
|
-
"data-editor-view":
|
|
3732
|
+
ref: N,
|
|
3733
|
+
"data-editor-view": L,
|
|
3716
3734
|
style: {
|
|
3717
|
-
height: Ft(
|
|
3718
|
-
minHeight: Ft(
|
|
3735
|
+
height: Ft(v),
|
|
3736
|
+
minHeight: Ft(re)
|
|
3719
3737
|
},
|
|
3720
3738
|
children: [
|
|
3721
|
-
|
|
3722
|
-
editorRef:
|
|
3723
|
-
onEdit:
|
|
3724
|
-
onUndo:
|
|
3725
|
-
onRedo:
|
|
3739
|
+
Be ? /* @__PURE__ */ p(at, {
|
|
3740
|
+
editorRef: z,
|
|
3741
|
+
onEdit: ke,
|
|
3742
|
+
onUndo: Ae,
|
|
3743
|
+
onRedo: je,
|
|
3726
3744
|
canUndo: ve,
|
|
3727
3745
|
canRedo: ye,
|
|
3728
|
-
onExport:
|
|
3729
|
-
showExport: typeof
|
|
3730
|
-
disabled:
|
|
3746
|
+
onExport: O,
|
|
3747
|
+
showExport: typeof O == "function",
|
|
3748
|
+
disabled: fe
|
|
3731
3749
|
}) : null,
|
|
3732
3750
|
/* @__PURE__ */ p("label", {
|
|
3733
3751
|
className: "reactive-md-editor-sr-only",
|
|
3734
|
-
htmlFor:
|
|
3735
|
-
children:
|
|
3752
|
+
htmlFor: M,
|
|
3753
|
+
children: oe.sourceLabel
|
|
3736
3754
|
}),
|
|
3737
3755
|
/* @__PURE__ */ m("div", {
|
|
3738
3756
|
className: "editor-workspace",
|
|
3739
|
-
"data-view":
|
|
3757
|
+
"data-view": L,
|
|
3740
3758
|
children: [/* @__PURE__ */ m("div", {
|
|
3741
|
-
id: `${
|
|
3742
|
-
hidden:
|
|
3759
|
+
id: `${M}-source`,
|
|
3760
|
+
hidden: L === "preview",
|
|
3743
3761
|
className: `editor-shell${me ? " is-composing" : ""}`,
|
|
3744
3762
|
children: [
|
|
3745
3763
|
/* @__PURE__ */ p("div", {
|
|
3746
3764
|
className: "editor-gutter",
|
|
3747
|
-
ref:
|
|
3765
|
+
ref: B,
|
|
3748
3766
|
"aria-hidden": "true",
|
|
3749
|
-
children:
|
|
3767
|
+
children: Ee.map((e, t) => {
|
|
3750
3768
|
let n = t + 1;
|
|
3751
3769
|
return /* @__PURE__ */ p("span", {
|
|
3752
|
-
className: `gutter-line ${ge === n ? "is-active" : ""} ${
|
|
3753
|
-
style:
|
|
3770
|
+
className: `gutter-line ${ge === n ? "is-active" : ""} ${Oe.has(n) ? "is-diagnostic" : ""}`,
|
|
3771
|
+
style: De.heights[t] ? { height: `${De.heights[t]}px` } : void 0,
|
|
3754
3772
|
children: n
|
|
3755
3773
|
}, n);
|
|
3756
3774
|
})
|
|
@@ -3759,73 +3777,74 @@ var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto"
|
|
|
3759
3777
|
className: "editor-input-wrap",
|
|
3760
3778
|
children: [/* @__PURE__ */ p(mt, {
|
|
3761
3779
|
source: e,
|
|
3762
|
-
tokens:
|
|
3763
|
-
width:
|
|
3764
|
-
editorRef:
|
|
3780
|
+
tokens: Te.tokens,
|
|
3781
|
+
width: De.width,
|
|
3782
|
+
editorRef: z
|
|
3765
3783
|
}), /* @__PURE__ */ p("textarea", {
|
|
3766
|
-
id:
|
|
3767
|
-
ref:
|
|
3784
|
+
id: M,
|
|
3785
|
+
ref: Pe,
|
|
3768
3786
|
className: "editor-input",
|
|
3769
3787
|
value: e,
|
|
3770
3788
|
wrap: "soft",
|
|
3771
3789
|
spellCheck: !1,
|
|
3772
3790
|
autoCapitalize: "off",
|
|
3773
3791
|
autoCorrect: "off",
|
|
3774
|
-
placeholder:
|
|
3775
|
-
"aria-label":
|
|
3776
|
-
readOnly:
|
|
3777
|
-
disabled:
|
|
3778
|
-
onScroll:
|
|
3779
|
-
onChange:
|
|
3780
|
-
onKeyDown:
|
|
3792
|
+
placeholder: ie,
|
|
3793
|
+
"aria-label": y,
|
|
3794
|
+
readOnly: b,
|
|
3795
|
+
disabled: ae,
|
|
3796
|
+
onScroll: ze,
|
|
3797
|
+
onChange: Fe,
|
|
3798
|
+
onKeyDown: Ie,
|
|
3781
3799
|
onBlur: () => {
|
|
3782
|
-
|
|
3800
|
+
K.current = !1;
|
|
3783
3801
|
},
|
|
3784
|
-
onCompositionStart:
|
|
3785
|
-
onCompositionEnd:
|
|
3786
|
-
onSelect: (e) =>
|
|
3787
|
-
onKeyUp: (e) =>
|
|
3788
|
-
onClick: (e) =>
|
|
3802
|
+
onCompositionStart: Le,
|
|
3803
|
+
onCompositionEnd: Re,
|
|
3804
|
+
onSelect: (e) => J(e.currentTarget),
|
|
3805
|
+
onKeyUp: (e) => J(e.currentTarget),
|
|
3806
|
+
onClick: (e) => J(e.currentTarget)
|
|
3789
3807
|
})]
|
|
3790
3808
|
}),
|
|
3791
3809
|
/* @__PURE__ */ p("div", {
|
|
3792
3810
|
className: "editor-mirror",
|
|
3793
|
-
ref:
|
|
3811
|
+
ref: ue,
|
|
3794
3812
|
"aria-hidden": "true",
|
|
3795
|
-
style:
|
|
3796
|
-
children:
|
|
3813
|
+
style: De.width ? { width: De.width } : void 0,
|
|
3814
|
+
children: Ee.map((e, t) => /* @__PURE__ */ p("div", { children: e.replace(/\r$/, "") || "" }, t))
|
|
3797
3815
|
})
|
|
3798
3816
|
]
|
|
3799
|
-
}),
|
|
3800
|
-
id: `${
|
|
3817
|
+
}), F ? /* @__PURE__ */ p("div", {
|
|
3818
|
+
id: `${M}-preview`,
|
|
3801
3819
|
className: "editor-preview",
|
|
3802
3820
|
role: "region",
|
|
3803
|
-
"aria-label":
|
|
3804
|
-
hidden:
|
|
3821
|
+
"aria-label": oe.previewRegion,
|
|
3822
|
+
hidden: L === "edit",
|
|
3805
3823
|
children: a
|
|
3806
3824
|
}) : null]
|
|
3807
3825
|
}),
|
|
3808
3826
|
/* @__PURE__ */ p(ot, {
|
|
3809
3827
|
source: e,
|
|
3810
|
-
mode:
|
|
3811
|
-
onModeChange:
|
|
3812
|
-
sourceId: `${
|
|
3813
|
-
previewId: `${
|
|
3814
|
-
hasPreview:
|
|
3815
|
-
allowSplit: !
|
|
3816
|
-
toolbar:
|
|
3828
|
+
mode: L,
|
|
3829
|
+
onModeChange: R,
|
|
3830
|
+
sourceId: `${M}-source`,
|
|
3831
|
+
previewId: `${M}-preview`,
|
|
3832
|
+
hasPreview: F,
|
|
3833
|
+
allowSplit: !P,
|
|
3834
|
+
toolbar: E && !fe
|
|
3817
3835
|
})
|
|
3818
3836
|
]
|
|
3819
|
-
}),
|
|
3820
|
-
hidden:
|
|
3837
|
+
}), D ? /* @__PURE__ */ p("div", {
|
|
3838
|
+
hidden: L === "preview",
|
|
3821
3839
|
children: /* @__PURE__ */ p(Dt, {
|
|
3822
3840
|
source: e,
|
|
3823
|
-
analysis:
|
|
3824
|
-
bindingDocument:
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3841
|
+
analysis: Te,
|
|
3842
|
+
bindingDocument: T,
|
|
3843
|
+
compileOptions: w,
|
|
3844
|
+
editorRef: z,
|
|
3845
|
+
onEdit: ke,
|
|
3846
|
+
onLocate: Ne,
|
|
3847
|
+
disabled: fe
|
|
3829
3848
|
})
|
|
3830
3849
|
}) : null]
|
|
3831
3850
|
})
|