reactive-md 0.5.0 → 0.5.2
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 +34 -0
- package/CHANGELOG.md +34 -0
- package/README-ch.md +10 -7
- package/README-en.md +12 -7
- package/README.md +12 -7
- package/SECURITY-ch.md +4 -3
- package/SECURITY.md +4 -3
- package/THIRD_PARTY_NOTICES.md +45 -1
- package/dist-library/reactive-md-editor.css +1 -1
- package/dist-library/reactive-md-editor.js +739 -615
- package/dist-library/reactive-md-react.js +2111 -1903
- package/dist-library/reactive-md.js +462 -326
- package/dist-library/{runtime-DPuMxM_y.js → runtime-UiQPz5ZV.js} +8780 -2718
- package/dist-library/types/editor/editor-i18n.d.ts +7 -0
- package/dist-library/types/editor/editor-view-bar.d.ts +11 -0
- package/dist-library/types/editor/index.d.ts +1 -1
- package/dist-library/types/editor/types.d.ts +8 -1
- package/dist-library/types/local/LocalDocumentView.d.ts +19 -4
- package/dist-library/types/local/code-block.d.ts +3 -1
- package/dist-library/types/local/diagnostics.d.ts +65 -0
- package/dist-library/types/local/heading-anchors.d.ts +2 -0
- package/dist-library/types/local/html-names.d.ts +6 -0
- package/dist-library/types/local/html.d.ts +16 -0
- package/dist-library/types/local/image-view.d.ts +3 -1
- package/dist-library/types/local/index.d.ts +1 -1
- package/dist-library/types/local/limits.d.ts +8 -0
- package/dist-library/types/local/options.d.ts +34 -0
- package/dist-library/types/local/render-types.d.ts +11 -0
- package/dist-library/types/local/types.d.ts +53 -1
- package/dist-library/types/local/worker.d.ts +21 -6
- package/dist-library/types/react/index.d.ts +1 -1
- package/dist-library/types/shareable.d.ts +9 -1
- package/dist-standalone/reactive-md-standalone.js +49 -49
- package/docs/compatibility-ch.md +8 -6
- package/docs/compatibility-en.md +8 -6
- package/docs/component-development-ch.md +4 -4
- package/docs/component-development-en.md +3 -3
- package/docs/component-protocol-ch.md +48 -11
- package/docs/component-protocol-en.md +48 -11
- package/docs/editor-ch.md +235 -216
- package/docs/editor-en.md +235 -216
- package/docs/html-compatibility-ch.md +98 -0
- package/docs/html-compatibility-en.md +98 -0
- package/docs/local-integration-ch.md +29 -2
- package/docs/local-integration-en.md +29 -2
- package/docs/local-interaction-syntax-ch.md +3 -1
- package/docs/local-interaction-syntax-en.md +1 -1
- package/docs/release-0.5.1-ch.md +39 -0
- package/docs/release-0.5.1-en.md +39 -0
- package/docs/release-0.5.2-ch.md +35 -0
- package/docs/release-0.5.2-en.md +35 -0
- package/docs/releasing-ch.md +7 -7
- package/docs/releasing-en.md +8 -8
- package/docs/shareable-export-ch.md +2 -0
- package/docs/shareable-export-en.md +2 -0
- package/examples/conformance/README.md +1 -1
- package/examples/local/README.md +2 -0
- package/examples/local/html-compat.reactive.md +24 -0
- package/package.json +3 -1
|
@@ -1,8 +1,8 @@
|
|
|
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 ee, completeLocalSource as te, formatLocalSource as h, renameLocalBinding as
|
|
3
|
+
import { analyzeLocalSource as ee, completeLocalSource as te, formatLocalSource as h, renameLocalBinding as g } from "reactive-md";
|
|
4
4
|
// src/editor/extended-native-components.ts
|
|
5
|
-
var
|
|
5
|
+
var _ = [
|
|
6
6
|
{
|
|
7
7
|
id: "jump",
|
|
8
8
|
label: "Jump and anchor",
|
|
@@ -117,7 +117,7 @@ var g = [
|
|
|
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
|
+
], ne = {
|
|
121
121
|
jump: {
|
|
122
122
|
label: "跳转与锚点",
|
|
123
123
|
description: "跳到当前文档中的指定位置。",
|
|
@@ -208,16 +208,30 @@ var g = [
|
|
|
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
|
+
}, re = {
|
|
212
212
|
en: {
|
|
213
213
|
sourceLabel: "Reactive MD source",
|
|
214
|
-
region: "Source editor"
|
|
214
|
+
region: "Source editor",
|
|
215
|
+
previewRegion: "Document preview",
|
|
216
|
+
viewLabel: "Editor view",
|
|
217
|
+
count: (e) => `${e} ${e === "1" ? "character" : "characters"}`,
|
|
218
|
+
keyboardHint: "Press Esc, then Tab to reach the toolbar",
|
|
219
|
+
edit: "Edit",
|
|
220
|
+
split: "Split",
|
|
221
|
+
preview: "Preview"
|
|
215
222
|
},
|
|
216
223
|
zh: {
|
|
217
224
|
sourceLabel: "Reactive MD 源码",
|
|
218
|
-
region: "源码编辑器"
|
|
225
|
+
region: "源码编辑器",
|
|
226
|
+
previewRegion: "文档预览",
|
|
227
|
+
viewLabel: "编辑器视图",
|
|
228
|
+
count: (e) => `${e} 字`,
|
|
229
|
+
keyboardHint: "按 Esc 再 Tab 可到工具条",
|
|
230
|
+
edit: "编辑",
|
|
231
|
+
split: "并排",
|
|
232
|
+
preview: "预览"
|
|
219
233
|
}
|
|
220
|
-
},
|
|
234
|
+
}, ie = {
|
|
221
235
|
en: {
|
|
222
236
|
boldPlaceholder: "bold text",
|
|
223
237
|
italicPlaceholder: "italic text",
|
|
@@ -403,7 +417,7 @@ var g = [
|
|
|
403
417
|
hint: "提示反馈"
|
|
404
418
|
},
|
|
405
419
|
components: {
|
|
406
|
-
...
|
|
420
|
+
...ne,
|
|
407
421
|
slider: {
|
|
408
422
|
label: "滑块",
|
|
409
423
|
description: "拖动滑块在指定范围内选择一个数值。",
|
|
@@ -726,7 +740,7 @@ function S(e, t) {
|
|
|
726
740
|
};
|
|
727
741
|
}
|
|
728
742
|
function C(e) {
|
|
729
|
-
return
|
|
743
|
+
return ie[e] ?? ie.en;
|
|
730
744
|
}
|
|
731
745
|
function w(e, t) {
|
|
732
746
|
return t <= 0 ? 0 : e.lastIndexOf("\n", t - 1) + 1;
|
|
@@ -846,7 +860,7 @@ function N(e, t, n) {
|
|
|
846
860
|
for (; e[t] === "`";) r += 1, t += n;
|
|
847
861
|
return r;
|
|
848
862
|
}
|
|
849
|
-
function
|
|
863
|
+
function ce(e, t) {
|
|
850
864
|
let { start: n, end: r } = t, i = e.slice(n, r), a = N(e, n - 1, -1), o = N(e, r, 1), s = a > 0 && a === o ? {
|
|
851
865
|
run: a,
|
|
852
866
|
padding: 0
|
|
@@ -856,7 +870,7 @@ function P(e, t) {
|
|
|
856
870
|
} : null, d = s ?? u;
|
|
857
871
|
return !d || M(i) >= d.run ? null : d;
|
|
858
872
|
}
|
|
859
|
-
function
|
|
873
|
+
function le(e, t, n = "en") {
|
|
860
874
|
let r = S(e, t), { start: i, end: a } = r, o = e.slice(i, a);
|
|
861
875
|
if (i === a) {
|
|
862
876
|
let t = C(n).inlineCodePlaceholder, r = `\`${t}\``;
|
|
@@ -879,7 +893,7 @@ function ce(e, t, n = "en") {
|
|
|
879
893
|
}
|
|
880
894
|
};
|
|
881
895
|
}
|
|
882
|
-
let l =
|
|
896
|
+
let l = ce(e, r);
|
|
883
897
|
if (l) {
|
|
884
898
|
let t = l.run + l.padding;
|
|
885
899
|
return {
|
|
@@ -899,18 +913,18 @@ function ce(e, t, n = "en") {
|
|
|
899
913
|
}
|
|
900
914
|
};
|
|
901
915
|
}
|
|
902
|
-
var
|
|
903
|
-
function
|
|
916
|
+
var P = /^(#{1,6})[ \t]+/;
|
|
917
|
+
function F(e, t, n) {
|
|
904
918
|
let r = S(e, t), i = [];
|
|
905
919
|
for (let t of T(e, r)) {
|
|
906
|
-
let e =
|
|
920
|
+
let e = P.exec(t.text), r = e ? e[0].length : 0;
|
|
907
921
|
if (n === 0 && !e) continue;
|
|
908
922
|
let a = t.text.slice(r), o = n === 0 ? "" : `${"#".repeat(n)} `, s = D(t, o + a, r, o.length);
|
|
909
923
|
s && i.push(s);
|
|
910
924
|
}
|
|
911
925
|
return E(e, r, i);
|
|
912
926
|
}
|
|
913
|
-
var
|
|
927
|
+
var I = /^([ \t]*)([-*+] )/, L = /^([ \t]*)(\d+[.)] )/, R = /^([ \t]*)([-*+] \[[ xX]\] )/, z = /^([ \t]*)(> ?)/;
|
|
914
928
|
function B(e, t) {
|
|
915
929
|
let n = t.exec(e);
|
|
916
930
|
if (!n) return null;
|
|
@@ -921,11 +935,11 @@ function B(e, t) {
|
|
|
921
935
|
prefixLength: r.length + i.length
|
|
922
936
|
};
|
|
923
937
|
}
|
|
924
|
-
function
|
|
938
|
+
function V(e) {
|
|
925
939
|
let t = /^[ \t]*/.exec(e);
|
|
926
940
|
return t ? t[0] : "";
|
|
927
941
|
}
|
|
928
|
-
function
|
|
942
|
+
function H(e, t, n, r) {
|
|
929
943
|
let i = S(e, t), a = T(e, i), o = a.map((e) => n(e.text)), s = 0, c = !0;
|
|
930
944
|
for (let e = 0; e < a.length; e += 1) {
|
|
931
945
|
let t = a[e];
|
|
@@ -940,24 +954,24 @@ function V(e, t, n, r) {
|
|
|
940
954
|
e && u.push(e);
|
|
941
955
|
continue;
|
|
942
956
|
}
|
|
943
|
-
let i = n ? n.indent :
|
|
957
|
+
let i = n ? n.indent : V(t.text), s = t.text.slice(n ? n.prefixLength : i.length), c = r(i, e + 1), d = D(t, i + c + s, n ? n.prefixLength : i.length, i.length + c.length);
|
|
944
958
|
d && u.push(d);
|
|
945
959
|
}
|
|
946
960
|
return E(e, i, u);
|
|
947
961
|
}
|
|
948
|
-
function de(e, t) {
|
|
949
|
-
return V(e, t, (e) => B(e, L), () => "- ");
|
|
950
|
-
}
|
|
951
|
-
function H(e, t) {
|
|
952
|
-
return V(e, t, (e) => B(e, R), (e, t) => `${t}. `);
|
|
953
|
-
}
|
|
954
962
|
function U(e, t) {
|
|
955
|
-
return
|
|
963
|
+
return H(e, t, (e) => B(e, I), () => "- ");
|
|
956
964
|
}
|
|
957
965
|
function W(e, t) {
|
|
958
|
-
return
|
|
966
|
+
return H(e, t, (e) => B(e, L), (e, t) => `${t}. `);
|
|
967
|
+
}
|
|
968
|
+
function ue(e, t) {
|
|
969
|
+
return H(e, t, (e) => B(e, R), () => "- [ ] ");
|
|
959
970
|
}
|
|
960
|
-
function
|
|
971
|
+
function G(e, t) {
|
|
972
|
+
return H(e, t, (e) => B(e, z), () => "> ");
|
|
973
|
+
}
|
|
974
|
+
function de(e, t) {
|
|
961
975
|
let n = S(e, t);
|
|
962
976
|
return E(e, n, T(e, n).map((e) => ({
|
|
963
977
|
start: e.start,
|
|
@@ -967,7 +981,7 @@ function fe(e, t) {
|
|
|
967
981
|
newPrefixLength: 2
|
|
968
982
|
})));
|
|
969
983
|
}
|
|
970
|
-
function
|
|
984
|
+
function fe(e) {
|
|
971
985
|
if (e.startsWith(" ")) return {
|
|
972
986
|
text: e.slice(1),
|
|
973
987
|
removed: 1
|
|
@@ -979,17 +993,17 @@ function pe(e) {
|
|
|
979
993
|
removed: t
|
|
980
994
|
};
|
|
981
995
|
}
|
|
982
|
-
function
|
|
996
|
+
function K(e, t) {
|
|
983
997
|
let n = S(e, t), r = [];
|
|
984
998
|
for (let t of T(e, n)) {
|
|
985
|
-
let e =
|
|
999
|
+
let e = fe(t.text);
|
|
986
1000
|
if (e.removed === 0) continue;
|
|
987
1001
|
let n = D(t, e.text, e.removed, 0);
|
|
988
1002
|
n && r.push(n);
|
|
989
1003
|
}
|
|
990
1004
|
return E(e, n, r);
|
|
991
1005
|
}
|
|
992
|
-
function
|
|
1006
|
+
function pe(e, t, n = "en") {
|
|
993
1007
|
let { start: r, end: i } = S(e, t), a = e.slice(r, i), o = "https://example.com";
|
|
994
1008
|
if (a.length > 0) {
|
|
995
1009
|
let t = `[${a}](${o})`, n = r + 1 + a.length + 2;
|
|
@@ -1010,7 +1024,7 @@ function me(e, t, n = "en") {
|
|
|
1010
1024
|
}
|
|
1011
1025
|
};
|
|
1012
1026
|
}
|
|
1013
|
-
function
|
|
1027
|
+
function me(e, t, n = "en") {
|
|
1014
1028
|
let { start: r, end: i } = S(e, t), a = e.slice(r, i), o = "images/example.png";
|
|
1015
1029
|
if (a.length > 0) {
|
|
1016
1030
|
let t = ``, n = r + 2 + a.length + 2;
|
|
@@ -1031,14 +1045,14 @@ function he(e, t, n = "en") {
|
|
|
1031
1045
|
}
|
|
1032
1046
|
};
|
|
1033
1047
|
}
|
|
1034
|
-
function
|
|
1048
|
+
function he(e, t, n = "en") {
|
|
1035
1049
|
let r = S(e, t), i = e.slice(r.start, r.end), a = i.length > 0 ? i : C(n).codeBlockPlaceholder, o = "`".repeat(Math.max(3, M(a) + 1)), s = `${o}text\n`;
|
|
1036
|
-
return
|
|
1050
|
+
return ve(e, r, `${s}${a}\n${o}`, {
|
|
1037
1051
|
start: s.length,
|
|
1038
1052
|
end: s.length + a.length
|
|
1039
1053
|
});
|
|
1040
1054
|
}
|
|
1041
|
-
function
|
|
1055
|
+
function ge(e) {
|
|
1042
1056
|
return [
|
|
1043
1057
|
`| ${e.tableHeaders.join(" | ")} |`,
|
|
1044
1058
|
`| ${e.tableHeaders.map(() => "---").join(" | ")} |`,
|
|
@@ -1057,7 +1071,7 @@ function _e(e, t) {
|
|
|
1057
1071
|
suffix: /\S/.test(o) ? "\n\n" : ""
|
|
1058
1072
|
};
|
|
1059
1073
|
}
|
|
1060
|
-
function
|
|
1074
|
+
function ve(e, t, n, r) {
|
|
1061
1075
|
let { prefix: i, suffix: a } = _e(e, t), o = t.start + i.length;
|
|
1062
1076
|
return {
|
|
1063
1077
|
value: e.slice(0, t.start) + i + n + a + e.slice(t.end),
|
|
@@ -1067,20 +1081,20 @@ function q(e, t, n, r) {
|
|
|
1067
1081
|
}
|
|
1068
1082
|
};
|
|
1069
1083
|
}
|
|
1070
|
-
function
|
|
1071
|
-
let r = S(e, t), i = C(n), a =
|
|
1072
|
-
return
|
|
1084
|
+
function ye(e, t, n = "en") {
|
|
1085
|
+
let r = S(e, t), i = C(n), a = ge(i), o = i.tableRows[0][0], s = a.indexOf(o);
|
|
1086
|
+
return ve(e, r, a, {
|
|
1073
1087
|
start: s,
|
|
1074
1088
|
end: s + o.length
|
|
1075
1089
|
});
|
|
1076
1090
|
}
|
|
1077
|
-
function
|
|
1078
|
-
return
|
|
1091
|
+
function q(e, t) {
|
|
1092
|
+
return ve(e, S(e, t), "---", {
|
|
1079
1093
|
start: 3,
|
|
1080
1094
|
end: 3
|
|
1081
1095
|
});
|
|
1082
1096
|
}
|
|
1083
|
-
function
|
|
1097
|
+
function be(e, t, n) {
|
|
1084
1098
|
let r = S(e, t), i = r.start + n.length;
|
|
1085
1099
|
return {
|
|
1086
1100
|
value: e.slice(0, r.start) + n + e.slice(r.end),
|
|
@@ -1090,11 +1104,11 @@ function ye(e, t, n) {
|
|
|
1090
1104
|
}
|
|
1091
1105
|
};
|
|
1092
1106
|
}
|
|
1093
|
-
var
|
|
1094
|
-
function
|
|
1107
|
+
var xe = /\{\{(selection(?::[^{}]*)?|caret|select:[^{}]*)\}\}/g;
|
|
1108
|
+
function J(e, t) {
|
|
1095
1109
|
let n = "", r = 0, i = null, a = null, o = null;
|
|
1096
|
-
|
|
1097
|
-
for (let s =
|
|
1110
|
+
xe.lastIndex = 0;
|
|
1111
|
+
for (let s = xe.exec(e); s; s = xe.exec(e)) {
|
|
1098
1112
|
let c = s.index;
|
|
1099
1113
|
n += e.slice(r, c), r = c + s[0].length;
|
|
1100
1114
|
let l = s[1] ?? "";
|
|
@@ -1126,7 +1140,7 @@ function xe(e, t) {
|
|
|
1126
1140
|
};
|
|
1127
1141
|
}
|
|
1128
1142
|
function Se(e, t, n, r = {}) {
|
|
1129
|
-
let i = S(e, t), a =
|
|
1143
|
+
let i = S(e, t), a = J(n, e.slice(i.start, i.end)), o = r.block === !0 && a.text.length > 0 ? _e(e, i) : {
|
|
1130
1144
|
prefix: "",
|
|
1131
1145
|
suffix: ""
|
|
1132
1146
|
}, s = i.start + o.prefix.length, c;
|
|
@@ -1189,41 +1203,41 @@ function De(e, t) {
|
|
|
1189
1203
|
}
|
|
1190
1204
|
return !1;
|
|
1191
1205
|
}
|
|
1192
|
-
function
|
|
1206
|
+
function Y(e, t, n, r) {
|
|
1193
1207
|
if (t.start !== t.end) {
|
|
1194
1208
|
let n = we(e, r);
|
|
1195
1209
|
return Te(t.start, t.end, n) || Ee(t.start, t.end, n);
|
|
1196
1210
|
}
|
|
1197
|
-
return De(Math.min(Math.max(t.start - n.start, 0), n.text.length), we(n.text, r).filter((e) => e.start >=
|
|
1211
|
+
return De(Math.min(Math.max(t.start - n.start, 0), n.text.length), we(n.text, r).filter((e) => e.start >= Oe(n.text)));
|
|
1198
1212
|
}
|
|
1199
|
-
function
|
|
1213
|
+
function Oe(e) {
|
|
1200
1214
|
let t = 0;
|
|
1201
1215
|
for (;;) {
|
|
1202
|
-
let n = e.slice(t), r = B(n,
|
|
1216
|
+
let n = e.slice(t), r = B(n, R) ?? B(n, I) ?? B(n, L) ?? B(n, z);
|
|
1203
1217
|
if (!r) return t;
|
|
1204
1218
|
t += r.prefixLength;
|
|
1205
1219
|
}
|
|
1206
1220
|
}
|
|
1207
|
-
function
|
|
1208
|
-
return B(e,
|
|
1221
|
+
function ke(e) {
|
|
1222
|
+
return B(e, R) ? "task" : B(e, I) ? "bullet" : B(e, L) ? "ordered" : null;
|
|
1209
1223
|
}
|
|
1210
|
-
function
|
|
1224
|
+
function Ae(e, t) {
|
|
1211
1225
|
let n = S(e, t), r = T(e, {
|
|
1212
1226
|
start: n.start,
|
|
1213
1227
|
end: n.start
|
|
1214
|
-
})[0], i = r.text, a =
|
|
1228
|
+
})[0], i = r.text, a = P.exec(i);
|
|
1215
1229
|
return {
|
|
1216
1230
|
headingLevel: a ? a[1].length : 0,
|
|
1217
|
-
bold:
|
|
1218
|
-
italic:
|
|
1219
|
-
strike:
|
|
1220
|
-
inlineCode:
|
|
1221
|
-
list:
|
|
1231
|
+
bold: Y(e, n, r, "bold"),
|
|
1232
|
+
italic: Y(e, n, r, "italic"),
|
|
1233
|
+
strike: Y(e, n, r, "strike"),
|
|
1234
|
+
inlineCode: Y(e, n, r, "inlineCode"),
|
|
1235
|
+
list: ke(i),
|
|
1222
1236
|
quote: B(i, z) !== null
|
|
1223
1237
|
};
|
|
1224
1238
|
}
|
|
1225
1239
|
// src/editor/native-components.ts
|
|
1226
|
-
var
|
|
1240
|
+
var je = [
|
|
1227
1241
|
{
|
|
1228
1242
|
id: "input",
|
|
1229
1243
|
label: "Input controls"
|
|
@@ -1244,8 +1258,8 @@ var Me = [
|
|
|
1244
1258
|
id: "hint",
|
|
1245
1259
|
label: "Feedback"
|
|
1246
1260
|
}
|
|
1247
|
-
],
|
|
1248
|
-
...
|
|
1261
|
+
], Me = [
|
|
1262
|
+
..._,
|
|
1249
1263
|
{
|
|
1250
1264
|
id: "slider",
|
|
1251
1265
|
label: "Slider",
|
|
@@ -1595,8 +1609,8 @@ var Me = [
|
|
|
1595
1609
|
inline: !0,
|
|
1596
1610
|
template: "<tooltip text=\"Extra details appear here.\">Hover to view</tooltip>"
|
|
1597
1611
|
}
|
|
1598
|
-
],
|
|
1599
|
-
function
|
|
1612
|
+
], Ne = /\{\{bind:([^{}]+)\}\}/g, Pe = /[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1613
|
+
function Fe(e, t) {
|
|
1600
1614
|
let n = [...e];
|
|
1601
1615
|
for (let e of t) {
|
|
1602
1616
|
let t = e.toLowerCase();
|
|
@@ -1604,55 +1618,55 @@ function Ie(e, t) {
|
|
|
1604
1618
|
}
|
|
1605
1619
|
return n;
|
|
1606
1620
|
}
|
|
1607
|
-
var
|
|
1621
|
+
var Ie = je.map((e) => ({
|
|
1608
1622
|
...e,
|
|
1609
1623
|
label: v.zh.groups[e.id]
|
|
1610
|
-
})),
|
|
1624
|
+
})), Le = Me.map((e) => ({
|
|
1611
1625
|
...e,
|
|
1612
|
-
keywords:
|
|
1613
|
-
})),
|
|
1626
|
+
keywords: Fe(e.keywords, v.zh.components[e.id]?.keywords ?? [])
|
|
1627
|
+
})), Re = Me.map((e) => {
|
|
1614
1628
|
let t = v.zh.components[e.id];
|
|
1615
1629
|
return t ? {
|
|
1616
1630
|
...e,
|
|
1617
1631
|
label: t.label,
|
|
1618
1632
|
description: t.description,
|
|
1619
|
-
keywords:
|
|
1633
|
+
keywords: Fe(e.keywords, t.keywords),
|
|
1620
1634
|
template: t.template
|
|
1621
1635
|
} : e;
|
|
1622
1636
|
});
|
|
1623
|
-
function
|
|
1637
|
+
function ze(e = "en") {
|
|
1624
1638
|
return e === "zh" ? {
|
|
1625
|
-
groups:
|
|
1626
|
-
components: ze
|
|
1627
|
-
} : {
|
|
1628
|
-
groups: Me,
|
|
1639
|
+
groups: Ie,
|
|
1629
1640
|
components: Re
|
|
1641
|
+
} : {
|
|
1642
|
+
groups: je,
|
|
1643
|
+
components: Le
|
|
1630
1644
|
};
|
|
1631
1645
|
}
|
|
1632
|
-
function
|
|
1633
|
-
return new Set(e.match(
|
|
1646
|
+
function Be(e) {
|
|
1647
|
+
return new Set(e.match(Pe) ?? []);
|
|
1634
1648
|
}
|
|
1635
|
-
function
|
|
1649
|
+
function Ve(e) {
|
|
1636
1650
|
let t = e.trim().replace(/[^A-Za-z0-9_]/g, "_");
|
|
1637
1651
|
return t ? /^[0-9]/.test(t) ? `_${t}` : t : "value";
|
|
1638
1652
|
}
|
|
1639
|
-
function
|
|
1653
|
+
function He(e, t) {
|
|
1640
1654
|
if (!t.has(e)) return e;
|
|
1641
1655
|
let n = 2;
|
|
1642
1656
|
for (; t.has(`${e}${n}`);) n += 1;
|
|
1643
1657
|
return `${e}${n}`;
|
|
1644
1658
|
}
|
|
1645
|
-
function
|
|
1646
|
-
let r =
|
|
1647
|
-
return e.template.replace(
|
|
1659
|
+
function Ue(e, t, n) {
|
|
1660
|
+
let r = Be(t), i = /* @__PURE__ */ new Map();
|
|
1661
|
+
return e.template.replace(Ne, (e, t) => {
|
|
1648
1662
|
let n = t.trim(), a = i.get(n);
|
|
1649
1663
|
if (a) return a;
|
|
1650
|
-
let o =
|
|
1664
|
+
let o = He(Ve(n), r);
|
|
1651
1665
|
return r.add(o), i.set(n, o), o;
|
|
1652
1666
|
});
|
|
1653
1667
|
}
|
|
1654
1668
|
// src/editor/editor-toolbar.tsx
|
|
1655
|
-
var
|
|
1669
|
+
var We = /* @__PURE__ */ "😀.😄.😁.😊.🙂.😉.😍.🤔.😎.😅.😂.🥳.👍.👎.👏.🙏.💡.✅.❌.⚠️.🔥.⭐.🎉.❤️.💬.📌.🚀.📈.📉.🧩.⚙️.🔍.📎.🗂️.🕒.✨".split("."), Ge = [
|
|
1656
1670
|
{
|
|
1657
1671
|
level: 0,
|
|
1658
1672
|
sample: "¶"
|
|
@@ -1681,55 +1695,55 @@ var Ge = /* @__PURE__ */ "😀.😄.😁.😊.🙂.😉.😍.🤔.😎.😅.😂
|
|
|
1681
1695
|
level: 6,
|
|
1682
1696
|
sample: "H6"
|
|
1683
1697
|
}
|
|
1684
|
-
],
|
|
1698
|
+
], Ke = [
|
|
1685
1699
|
{
|
|
1686
1700
|
type: "bullet",
|
|
1687
1701
|
icon: "bulletList",
|
|
1688
|
-
command:
|
|
1702
|
+
command: U
|
|
1689
1703
|
},
|
|
1690
1704
|
{
|
|
1691
1705
|
type: "ordered",
|
|
1692
1706
|
icon: "orderedList",
|
|
1693
|
-
command:
|
|
1707
|
+
command: W
|
|
1694
1708
|
},
|
|
1695
1709
|
{
|
|
1696
1710
|
type: "task",
|
|
1697
1711
|
icon: "taskList",
|
|
1698
|
-
command:
|
|
1712
|
+
command: ue
|
|
1699
1713
|
}
|
|
1700
|
-
],
|
|
1714
|
+
], qe = [{
|
|
1701
1715
|
labelKey: "decreaseIndent",
|
|
1702
1716
|
icon: "outdent",
|
|
1703
|
-
command:
|
|
1717
|
+
command: K
|
|
1704
1718
|
}, {
|
|
1705
1719
|
labelKey: "increaseIndent",
|
|
1706
1720
|
icon: "indent",
|
|
1707
|
-
command:
|
|
1708
|
-
}],
|
|
1721
|
+
command: de
|
|
1722
|
+
}], Je = [
|
|
1709
1723
|
{
|
|
1710
1724
|
labelKey: "image",
|
|
1711
1725
|
icon: "image",
|
|
1712
|
-
command:
|
|
1726
|
+
command: me
|
|
1713
1727
|
},
|
|
1714
1728
|
{
|
|
1715
1729
|
labelKey: "table",
|
|
1716
1730
|
icon: "table",
|
|
1717
|
-
command:
|
|
1731
|
+
command: ye
|
|
1718
1732
|
},
|
|
1719
1733
|
{
|
|
1720
1734
|
labelKey: "divider",
|
|
1721
1735
|
icon: "divider",
|
|
1722
|
-
command:
|
|
1736
|
+
command: q
|
|
1723
1737
|
},
|
|
1724
1738
|
{
|
|
1725
1739
|
labelKey: "codeBlock",
|
|
1726
1740
|
icon: "codeBlock",
|
|
1727
|
-
command:
|
|
1741
|
+
command: he
|
|
1728
1742
|
},
|
|
1729
1743
|
{
|
|
1730
1744
|
labelKey: "inlineCode",
|
|
1731
1745
|
icon: "inlineCode",
|
|
1732
|
-
command:
|
|
1746
|
+
command: le
|
|
1733
1747
|
},
|
|
1734
1748
|
{
|
|
1735
1749
|
labelKey: "strikethrough",
|
|
@@ -1739,14 +1753,14 @@ var Ge = /* @__PURE__ */ "😀.😄.😁.😊.🙂.😉.😍.🤔.😎.😅.😂
|
|
|
1739
1753
|
{
|
|
1740
1754
|
labelKey: "quote",
|
|
1741
1755
|
icon: "quote",
|
|
1742
|
-
command:
|
|
1756
|
+
command: G
|
|
1743
1757
|
}
|
|
1744
|
-
],
|
|
1758
|
+
], Ye = {
|
|
1745
1759
|
heading: 200,
|
|
1746
1760
|
list: 208,
|
|
1747
1761
|
insert: 216,
|
|
1748
1762
|
more: 188
|
|
1749
|
-
},
|
|
1763
|
+
}, Xe = {
|
|
1750
1764
|
headingLevel: 0,
|
|
1751
1765
|
bold: !1,
|
|
1752
1766
|
italic: !1,
|
|
@@ -1754,7 +1768,7 @@ var Ge = /* @__PURE__ */ "😀.😄.😁.😊.🙂.😉.😍.🤔.😎.😅.😂
|
|
|
1754
1768
|
inlineCode: !1,
|
|
1755
1769
|
list: null,
|
|
1756
1770
|
quote: !1
|
|
1757
|
-
},
|
|
1771
|
+
}, Ze = {
|
|
1758
1772
|
smile: /* @__PURE__ */ m(f, { children: [
|
|
1759
1773
|
/* @__PURE__ */ p("circle", {
|
|
1760
1774
|
cx: "12",
|
|
@@ -1895,7 +1909,7 @@ var Ge = /* @__PURE__ */ "😀.😄.😁.😊.🙂.😉.😍.🤔.😎.😅.😂
|
|
|
1895
1909
|
] }),
|
|
1896
1910
|
close: /* @__PURE__ */ p("path", { d: "M6.5 6.5l11 11M17.5 6.5l-11 11" })
|
|
1897
1911
|
};
|
|
1898
|
-
function
|
|
1912
|
+
function X({ name: e, className: t }) {
|
|
1899
1913
|
return /* @__PURE__ */ p("svg", {
|
|
1900
1914
|
className: t ? `editor-toolbar-icon ${t}` : "editor-toolbar-icon",
|
|
1901
1915
|
viewBox: "0 0 24 24",
|
|
@@ -1908,13 +1922,13 @@ function Y({ name: e, className: t }) {
|
|
|
1908
1922
|
strokeLinejoin: "round",
|
|
1909
1923
|
"aria-hidden": "true",
|
|
1910
1924
|
focusable: "false",
|
|
1911
|
-
children:
|
|
1925
|
+
children: Ze[e]
|
|
1912
1926
|
});
|
|
1913
1927
|
}
|
|
1914
|
-
function
|
|
1928
|
+
function Z(e) {
|
|
1915
1929
|
e.preventDefault();
|
|
1916
1930
|
}
|
|
1917
|
-
function
|
|
1931
|
+
function Q({ toolbarId: e, label: t, tabStop: n, onFocus: r, onClick: i, children: a, className: o, disabled: s, expanded: c, popup: l, controls: u, pressed: d, active: f, onKeyDown: m }) {
|
|
1918
1932
|
return /* @__PURE__ */ p("button", {
|
|
1919
1933
|
type: "button",
|
|
1920
1934
|
"data-toolbar-item": "true",
|
|
@@ -1929,13 +1943,13 @@ function Z({ toolbarId: e, label: t, tabStop: n, onFocus: r, onClick: i, childre
|
|
|
1929
1943
|
disabled: s,
|
|
1930
1944
|
tabIndex: n ? 0 : -1,
|
|
1931
1945
|
onFocus: r,
|
|
1932
|
-
onMouseDown: l ? void 0 :
|
|
1946
|
+
onMouseDown: l ? void 0 : Z,
|
|
1933
1947
|
onClick: i,
|
|
1934
1948
|
onKeyDown: m,
|
|
1935
1949
|
children: a
|
|
1936
1950
|
});
|
|
1937
1951
|
}
|
|
1938
|
-
function
|
|
1952
|
+
function Qe(e) {
|
|
1939
1953
|
let t = e.current, n = t?.value ?? "", r = Math.max(0, Math.min(t?.selectionStart ?? 0, n.length)), i = Math.max(r, Math.min(t?.selectionEnd ?? 0, n.length));
|
|
1940
1954
|
return {
|
|
1941
1955
|
value: n,
|
|
@@ -1946,20 +1960,20 @@ function $e(e) {
|
|
|
1946
1960
|
selectedText: n.slice(r, i)
|
|
1947
1961
|
};
|
|
1948
1962
|
}
|
|
1949
|
-
function
|
|
1963
|
+
function $e(e, t) {
|
|
1950
1964
|
return !t || e.label.toLowerCase().includes(t) || e.description.toLowerCase().includes(t) || e.keywords.some((e) => e.toLowerCase().includes(t));
|
|
1951
1965
|
}
|
|
1952
|
-
function
|
|
1966
|
+
function et(e, t) {
|
|
1953
1967
|
return e.headingLevel === t.headingLevel && e.bold === t.bold && e.italic === t.italic && e.strike === t.strike && e.inlineCode === t.inlineCode && e.list === t.list && e.quote === t.quote;
|
|
1954
1968
|
}
|
|
1955
|
-
function
|
|
1969
|
+
function tt(e) {
|
|
1956
1970
|
return e ? Array.from(e.querySelectorAll("[data-toolbar-item]")).filter((e) => !e.disabled && e.getClientRects().length > 0) : [];
|
|
1957
1971
|
}
|
|
1958
|
-
function
|
|
1972
|
+
function nt(e) {
|
|
1959
1973
|
return e ? Array.from(e.querySelectorAll("[role=\"menuitem\"], [role=\"menuitemradio\"]")).filter((e) => !e.disabled && e.getClientRects().length > 0) : [];
|
|
1960
1974
|
}
|
|
1961
|
-
function
|
|
1962
|
-
let n =
|
|
1975
|
+
function rt(e, t) {
|
|
1976
|
+
let n = nt(t);
|
|
1963
1977
|
if (n.length === 0) return;
|
|
1964
1978
|
let r = document.activeElement, i = r ? n.indexOf(r) : -1, a = i;
|
|
1965
1979
|
switch (e.key) {
|
|
@@ -1979,7 +1993,7 @@ function it(e, t) {
|
|
|
1979
1993
|
}
|
|
1980
1994
|
e.preventDefault(), n[a]?.focus();
|
|
1981
1995
|
}
|
|
1982
|
-
function
|
|
1996
|
+
function it(e, t) {
|
|
1983
1997
|
if (!t) return;
|
|
1984
1998
|
let n = Array.from(t.querySelectorAll(".editor-toolbar-emoji"));
|
|
1985
1999
|
if (n.length === 0) return;
|
|
@@ -2009,45 +2023,45 @@ function at(e, t) {
|
|
|
2009
2023
|
}
|
|
2010
2024
|
e.preventDefault(), n[a]?.focus();
|
|
2011
2025
|
}
|
|
2012
|
-
function
|
|
2013
|
-
let
|
|
2026
|
+
function at({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo: f, onExport: ee, showExport: te = !1, disabled: h = !1 }) {
|
|
2027
|
+
let g = u(null), _ = u(null), ne = u(null), re = u(null), ie = u(null), v = u(null), [y, b] = d(null), [x, S] = d("heading"), [C, w] = d(""), [T, E] = d(Xe), [D, O] = d(null), k = o(), j = `${k}-emoji-menu`, M = `${k}-heading-menu`, N = `${k}-list-menu`, ce = `${k}-insert-menu`, le = `${k}-more-menu`, P = `${k}-native-menu`, I = oe(), L = ae[I], R = l(() => ze(I), [I]), z = Ge.map((e) => ({
|
|
2014
2028
|
...e,
|
|
2015
|
-
label:
|
|
2016
|
-
})), B =
|
|
2029
|
+
label: L.headingLabels[e.level]
|
|
2030
|
+
})), B = Ke.map((e) => ({
|
|
2017
2031
|
...e,
|
|
2018
|
-
label:
|
|
2019
|
-
})),
|
|
2032
|
+
label: L.listLabels[e.type]
|
|
2033
|
+
})), V = qe.map((e) => ({
|
|
2020
2034
|
...e,
|
|
2021
|
-
label:
|
|
2022
|
-
})),
|
|
2035
|
+
label: L[e.labelKey]
|
|
2036
|
+
})), H = Je.map((e) => ({
|
|
2023
2037
|
...e,
|
|
2024
|
-
label:
|
|
2025
|
-
})),
|
|
2038
|
+
label: L.insertItems[e.labelKey]
|
|
2039
|
+
})), U = l(() => {
|
|
2026
2040
|
let e = C.trim().toLowerCase();
|
|
2027
|
-
return
|
|
2041
|
+
return R.groups.map((t) => ({
|
|
2028
2042
|
group: t,
|
|
2029
|
-
components:
|
|
2043
|
+
components: R.components.filter((n) => n.group === t.id && $e(n, e))
|
|
2030
2044
|
})).filter((e) => e.components.length > 0);
|
|
2031
|
-
}, [
|
|
2045
|
+
}, [R, C]), W = r(() => {
|
|
2032
2046
|
let t = e.current;
|
|
2033
2047
|
if (!t) {
|
|
2034
|
-
E(
|
|
2048
|
+
E(Xe);
|
|
2035
2049
|
return;
|
|
2036
2050
|
}
|
|
2037
|
-
let n =
|
|
2051
|
+
let n = Ae(t.value, {
|
|
2038
2052
|
start: t.selectionStart,
|
|
2039
2053
|
end: t.selectionEnd
|
|
2040
2054
|
});
|
|
2041
|
-
E((e) =>
|
|
2042
|
-
}, [e]),
|
|
2055
|
+
E((e) => et(e, n) ? e : n);
|
|
2056
|
+
}, [e]), ue = r(() => {
|
|
2043
2057
|
v.current !== null && window.cancelAnimationFrame(v.current), v.current = window.requestAnimationFrame(() => {
|
|
2044
|
-
v.current = null,
|
|
2058
|
+
v.current = null, W();
|
|
2045
2059
|
});
|
|
2046
|
-
}, [
|
|
2060
|
+
}, [W]);
|
|
2047
2061
|
a(() => {
|
|
2048
2062
|
let t = e.current;
|
|
2049
2063
|
if (!t) return;
|
|
2050
|
-
let n = () =>
|
|
2064
|
+
let n = () => W(), r = [
|
|
2051
2065
|
"select",
|
|
2052
2066
|
"keyup",
|
|
2053
2067
|
"click",
|
|
@@ -2056,18 +2070,18 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2056
2070
|
];
|
|
2057
2071
|
for (let e of r) t.addEventListener(e, n);
|
|
2058
2072
|
let i = () => {
|
|
2059
|
-
document.activeElement === t &&
|
|
2073
|
+
document.activeElement === t && W();
|
|
2060
2074
|
};
|
|
2061
|
-
return document.addEventListener("selectionchange", i),
|
|
2075
|
+
return document.addEventListener("selectionchange", i), W(), () => {
|
|
2062
2076
|
for (let e of r) t.removeEventListener(e, n);
|
|
2063
2077
|
document.removeEventListener("selectionchange", i);
|
|
2064
2078
|
};
|
|
2065
|
-
}, [e,
|
|
2079
|
+
}, [e, W]), a(() => () => {
|
|
2066
2080
|
v.current !== null && window.cancelAnimationFrame(v.current);
|
|
2067
2081
|
}, []);
|
|
2068
|
-
let
|
|
2082
|
+
let G = r((e) => {
|
|
2069
2083
|
let t = e === "emoji" ? "insert" : e === "native" ? "components" : e;
|
|
2070
|
-
return
|
|
2084
|
+
return g.current?.querySelector(`[data-toolbar-id="${t}"]`) ?? null;
|
|
2071
2085
|
}, []);
|
|
2072
2086
|
c(() => {
|
|
2073
2087
|
if (!y || y === "native" || y === "emoji") {
|
|
@@ -2079,89 +2093,89 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2079
2093
|
O(null);
|
|
2080
2094
|
return;
|
|
2081
2095
|
}
|
|
2082
|
-
let t =
|
|
2096
|
+
let t = G(y);
|
|
2083
2097
|
if (!t) return;
|
|
2084
|
-
let n = t.getBoundingClientRect(), r =
|
|
2098
|
+
let n = t.getBoundingClientRect(), r = Ye[y] ?? 216, i = n.top - 6 - 8, a = window.innerHeight - n.bottom - 6 - 8, o = {};
|
|
2085
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)), y === "heading" || y === "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"), O(o);
|
|
2086
2100
|
};
|
|
2087
2101
|
return t(), e.addEventListener("change", t), window.addEventListener("resize", t), window.addEventListener("scroll", t, !0), () => {
|
|
2088
2102
|
e.removeEventListener("change", t), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
|
|
2089
2103
|
};
|
|
2090
|
-
}, [y,
|
|
2104
|
+
}, [y, G]), a(() => {
|
|
2091
2105
|
if (!y) return;
|
|
2092
2106
|
let e = (e) => {
|
|
2093
|
-
|
|
2107
|
+
g.current && !g.current.contains(e.target) && b(null);
|
|
2094
2108
|
}, t = (e) => {
|
|
2095
2109
|
if (e.key !== "Escape") return;
|
|
2096
2110
|
e.preventDefault(), e.stopPropagation();
|
|
2097
2111
|
let t = y;
|
|
2098
|
-
b(null),
|
|
2112
|
+
b(null), G(t)?.focus();
|
|
2099
2113
|
};
|
|
2100
2114
|
return document.addEventListener("pointerdown", e, !0), document.addEventListener("keydown", t, !0), () => {
|
|
2101
2115
|
document.removeEventListener("pointerdown", e, !0), document.removeEventListener("keydown", t, !0);
|
|
2102
2116
|
};
|
|
2103
|
-
}, [y,
|
|
2117
|
+
}, [y, G]), a(() => {
|
|
2104
2118
|
if (!y) return;
|
|
2105
|
-
let e =
|
|
2106
|
-
|
|
2119
|
+
let e = ie.current;
|
|
2120
|
+
ie.current = null;
|
|
2107
2121
|
let t = window.requestAnimationFrame(() => {
|
|
2108
|
-
let t =
|
|
2122
|
+
let t = _.current;
|
|
2109
2123
|
if (e) {
|
|
2110
|
-
let n =
|
|
2124
|
+
let n = nt(t);
|
|
2111
2125
|
(e === "first" ? n[0] : n[n.length - 1])?.focus();
|
|
2112
|
-
} else y === "native" ?
|
|
2126
|
+
} else y === "native" ? ne.current?.focus() : y === "emoji" && nt(t)[0]?.focus();
|
|
2113
2127
|
});
|
|
2114
2128
|
return () => window.cancelAnimationFrame(t);
|
|
2115
2129
|
}, [y]);
|
|
2116
|
-
let
|
|
2117
|
-
let e =
|
|
2130
|
+
let de = r(() => {
|
|
2131
|
+
let e = tt(g.current);
|
|
2118
2132
|
e.length !== 0 && S((t) => e.some((e) => e.dataset.toolbarId === t) ? t : e[0]?.dataset.toolbarId ?? "heading");
|
|
2119
2133
|
}, []);
|
|
2120
|
-
a(() => (
|
|
2121
|
-
|
|
2134
|
+
a(() => (de(), window.addEventListener("resize", de), () => window.removeEventListener("resize", de)), [de]), a(() => {
|
|
2135
|
+
de();
|
|
2122
2136
|
}, [
|
|
2123
2137
|
y,
|
|
2124
2138
|
s,
|
|
2125
2139
|
f,
|
|
2126
|
-
|
|
2140
|
+
de
|
|
2127
2141
|
]);
|
|
2128
|
-
let
|
|
2129
|
-
h || (b(null), t(e),
|
|
2142
|
+
let fe = r((e) => {
|
|
2143
|
+
h || (b(null), t(e), ue());
|
|
2130
2144
|
}, [
|
|
2131
2145
|
h,
|
|
2132
2146
|
t,
|
|
2133
|
-
|
|
2134
|
-
]),
|
|
2147
|
+
ue
|
|
2148
|
+
]), K = (t) => {
|
|
2135
2149
|
if (h) return;
|
|
2136
|
-
let { value: n, selection: r } =
|
|
2137
|
-
|
|
2150
|
+
let { value: n, selection: r } = Qe(e);
|
|
2151
|
+
fe(t(n, r, I));
|
|
2152
|
+
}, me = (t) => {
|
|
2153
|
+
if (h) return;
|
|
2154
|
+
let { value: n, selection: r } = Qe(e);
|
|
2155
|
+
fe(F(n, r, t));
|
|
2138
2156
|
}, he = (t) => {
|
|
2139
2157
|
if (h) return;
|
|
2140
|
-
let { value: n, selection: r } =
|
|
2141
|
-
|
|
2158
|
+
let { value: n, selection: r } = Qe(e);
|
|
2159
|
+
fe(be(n, r, t));
|
|
2142
2160
|
}, ge = (t) => {
|
|
2143
2161
|
if (h) return;
|
|
2144
|
-
let { value: n, selection: r } =
|
|
2145
|
-
|
|
2146
|
-
}, K = (t) => {
|
|
2147
|
-
if (h) return;
|
|
2148
|
-
let { value: n, selection: r, selectedText: i } = $e(e), a = We(t, n, i);
|
|
2149
|
-
pe(Se(n, r, a, { block: !t.inline }));
|
|
2162
|
+
let { value: n, selection: r, selectedText: i } = Qe(e), a = Ue(t, n, i);
|
|
2163
|
+
fe(Se(n, r, a, { block: !t.inline }));
|
|
2150
2164
|
}, _e = () => {
|
|
2151
|
-
h || (b(null), n(),
|
|
2152
|
-
}, q = () => {
|
|
2153
|
-
h || (b(null), i(), U());
|
|
2165
|
+
h || (b(null), n(), ue());
|
|
2154
2166
|
}, ve = () => {
|
|
2167
|
+
h || (b(null), i(), ue());
|
|
2168
|
+
}, ye = () => {
|
|
2155
2169
|
b(null), te && ee?.();
|
|
2156
|
-
},
|
|
2170
|
+
}, q = (e) => {
|
|
2157
2171
|
b((t) => t === e ? null : e), e === "native" && w("");
|
|
2158
|
-
},
|
|
2172
|
+
}, xe = (e, t, n) => {
|
|
2159
2173
|
if (t.preventDefault(), e === "native" && w(""), y === e) {
|
|
2160
|
-
let e =
|
|
2174
|
+
let e = nt(_.current);
|
|
2161
2175
|
(n === "first" ? e[0] : e[e.length - 1])?.focus();
|
|
2162
|
-
} else
|
|
2163
|
-
},
|
|
2164
|
-
(t.key === "ArrowDown" || t.key === "ArrowUp") &&
|
|
2176
|
+
} else ie.current = n, b(e);
|
|
2177
|
+
}, J = (e, t) => {
|
|
2178
|
+
(t.key === "ArrowDown" || t.key === "ArrowUp") && xe(e, t, t.key === "ArrowDown" ? "first" : "last");
|
|
2165
2179
|
}, Ce = (e) => {
|
|
2166
2180
|
if (e.altKey || e.ctrlKey || e.metaKey || ![
|
|
2167
2181
|
"ArrowLeft",
|
|
@@ -2173,7 +2187,7 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2173
2187
|
if (!(t instanceof HTMLElement)) return;
|
|
2174
2188
|
let n = t.closest("[data-toolbar-item]");
|
|
2175
2189
|
if (!n || n !== t) return;
|
|
2176
|
-
let r =
|
|
2190
|
+
let r = tt(g.current), i = r.indexOf(n);
|
|
2177
2191
|
if (i < 0) return;
|
|
2178
2192
|
let a = i;
|
|
2179
2193
|
switch (e.key) {
|
|
@@ -2193,20 +2207,20 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2193
2207
|
}
|
|
2194
2208
|
e.preventDefault(), y && b(null), r[a]?.focus();
|
|
2195
2209
|
}, we = () => {
|
|
2196
|
-
b(null),
|
|
2197
|
-
}, Te = z.find((e) => e.level === T.headingLevel)?.label ??
|
|
2210
|
+
b(null), G("native")?.focus();
|
|
2211
|
+
}, Te = z.find((e) => e.level === T.headingLevel)?.label ?? L.headingLabels[0], Ee = T.headingLevel === 0 ? "¶" : `H${T.headingLevel}`, De = L.headingLevelLabel(Te), Y = T.list ? L.listLabels[T.list] : null, Oe = Y ? L.listLabelWithType(Y) : L.listLabel, ke = T.list === "ordered" ? "orderedList" : T.list === "task" ? "taskList" : "bulletList";
|
|
2198
2212
|
return /* @__PURE__ */ m("div", {
|
|
2199
2213
|
className: `editor-toolbar${y ? " is-menu-open" : ""}`,
|
|
2200
2214
|
role: "toolbar",
|
|
2201
|
-
"aria-label":
|
|
2215
|
+
"aria-label": L.toolbarLabel,
|
|
2202
2216
|
"aria-orientation": "horizontal",
|
|
2203
2217
|
"aria-disabled": h || void 0,
|
|
2204
|
-
ref:
|
|
2218
|
+
ref: g,
|
|
2205
2219
|
onKeyDown: Ce,
|
|
2206
2220
|
children: [
|
|
2207
2221
|
/* @__PURE__ */ m("div", {
|
|
2208
2222
|
className: "editor-toolbar-slot",
|
|
2209
|
-
children: [/* @__PURE__ */ m(
|
|
2223
|
+
children: [/* @__PURE__ */ m(Q, {
|
|
2210
2224
|
toolbarId: "heading",
|
|
2211
2225
|
label: De,
|
|
2212
2226
|
className: "editor-toolbar-heading-trigger",
|
|
@@ -2217,8 +2231,8 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2217
2231
|
popup: "menu",
|
|
2218
2232
|
expanded: y === "heading",
|
|
2219
2233
|
controls: M,
|
|
2220
|
-
onClick: () =>
|
|
2221
|
-
onKeyDown: (e) =>
|
|
2234
|
+
onClick: () => q("heading"),
|
|
2235
|
+
onKeyDown: (e) => J("heading", e),
|
|
2222
2236
|
children: [
|
|
2223
2237
|
/* @__PURE__ */ p("span", {
|
|
2224
2238
|
className: "editor-toolbar-heading-label editor-toolbar-heading-label-full",
|
|
@@ -2229,27 +2243,27 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2229
2243
|
"aria-hidden": "true",
|
|
2230
2244
|
children: Ee
|
|
2231
2245
|
}),
|
|
2232
|
-
/* @__PURE__ */ p(
|
|
2246
|
+
/* @__PURE__ */ p(X, {
|
|
2233
2247
|
name: "chevron",
|
|
2234
2248
|
className: "editor-toolbar-chevron"
|
|
2235
2249
|
})
|
|
2236
2250
|
]
|
|
2237
2251
|
}), y === "heading" ? /* @__PURE__ */ p("div", {
|
|
2238
2252
|
id: M,
|
|
2239
|
-
ref:
|
|
2253
|
+
ref: _,
|
|
2240
2254
|
className: "editor-toolbar-popover editor-toolbar-heading-menu",
|
|
2241
2255
|
role: "menu",
|
|
2242
|
-
"aria-label":
|
|
2256
|
+
"aria-label": L.headingMenuLabel,
|
|
2243
2257
|
style: D ?? void 0,
|
|
2244
|
-
onKeyDown: (e) =>
|
|
2258
|
+
onKeyDown: (e) => rt(e, _.current),
|
|
2245
2259
|
children: z.map((e) => /* @__PURE__ */ m("button", {
|
|
2246
2260
|
type: "button",
|
|
2247
2261
|
role: "menuitemradio",
|
|
2248
2262
|
"aria-checked": T.headingLevel === e.level,
|
|
2249
2263
|
tabIndex: -1,
|
|
2250
2264
|
className: "editor-toolbar-menu-item editor-toolbar-heading-item",
|
|
2251
|
-
onMouseDown:
|
|
2252
|
-
onClick: () =>
|
|
2265
|
+
onMouseDown: Z,
|
|
2266
|
+
onClick: () => me(e.level),
|
|
2253
2267
|
children: [/* @__PURE__ */ p("span", {
|
|
2254
2268
|
className: `editor-toolbar-heading-sample is-level-${e.level}`,
|
|
2255
2269
|
"aria-hidden": "true",
|
|
@@ -2258,13 +2272,13 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2258
2272
|
}, e.level))
|
|
2259
2273
|
}) : null]
|
|
2260
2274
|
}),
|
|
2261
|
-
/* @__PURE__ */ p(
|
|
2275
|
+
/* @__PURE__ */ p(Q, {
|
|
2262
2276
|
toolbarId: "bold",
|
|
2263
|
-
label:
|
|
2277
|
+
label: L.bold,
|
|
2264
2278
|
tabStop: x === "bold",
|
|
2265
2279
|
onFocus: () => S("bold"),
|
|
2266
2280
|
disabled: h,
|
|
2267
|
-
onClick: () =>
|
|
2281
|
+
onClick: () => K(A),
|
|
2268
2282
|
pressed: T.bold,
|
|
2269
2283
|
active: T.bold,
|
|
2270
2284
|
children: /* @__PURE__ */ p("span", {
|
|
@@ -2273,13 +2287,13 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2273
2287
|
children: "B"
|
|
2274
2288
|
})
|
|
2275
2289
|
}),
|
|
2276
|
-
/* @__PURE__ */ p(
|
|
2290
|
+
/* @__PURE__ */ p(Q, {
|
|
2277
2291
|
toolbarId: "italic",
|
|
2278
|
-
label:
|
|
2292
|
+
label: L.italic,
|
|
2279
2293
|
tabStop: x === "italic",
|
|
2280
2294
|
onFocus: () => S("italic"),
|
|
2281
2295
|
disabled: h,
|
|
2282
|
-
onClick: () =>
|
|
2296
|
+
onClick: () => K(se),
|
|
2283
2297
|
pressed: T.italic,
|
|
2284
2298
|
active: T.italic,
|
|
2285
2299
|
children: /* @__PURE__ */ p("span", {
|
|
@@ -2290,9 +2304,9 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2290
2304
|
}),
|
|
2291
2305
|
/* @__PURE__ */ m("div", {
|
|
2292
2306
|
className: "editor-toolbar-slot",
|
|
2293
|
-
children: [/* @__PURE__ */ m(
|
|
2307
|
+
children: [/* @__PURE__ */ m(Q, {
|
|
2294
2308
|
toolbarId: "list",
|
|
2295
|
-
label:
|
|
2309
|
+
label: Oe,
|
|
2296
2310
|
className: "editor-toolbar-list-trigger",
|
|
2297
2311
|
tabStop: x === "list",
|
|
2298
2312
|
onFocus: () => S("list"),
|
|
@@ -2301,20 +2315,20 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2301
2315
|
expanded: y === "list",
|
|
2302
2316
|
controls: N,
|
|
2303
2317
|
active: T.list !== null,
|
|
2304
|
-
onClick: () =>
|
|
2305
|
-
onKeyDown: (e) =>
|
|
2306
|
-
children: [/* @__PURE__ */ p(
|
|
2318
|
+
onClick: () => q("list"),
|
|
2319
|
+
onKeyDown: (e) => J("list", e),
|
|
2320
|
+
children: [/* @__PURE__ */ p(X, { name: ke }), /* @__PURE__ */ p(X, {
|
|
2307
2321
|
name: "chevron",
|
|
2308
2322
|
className: "editor-toolbar-chevron"
|
|
2309
2323
|
})]
|
|
2310
2324
|
}), y === "list" ? /* @__PURE__ */ m("div", {
|
|
2311
2325
|
id: N,
|
|
2312
|
-
ref:
|
|
2326
|
+
ref: _,
|
|
2313
2327
|
className: "editor-toolbar-popover editor-toolbar-list-menu",
|
|
2314
2328
|
role: "menu",
|
|
2315
|
-
"aria-label":
|
|
2329
|
+
"aria-label": L.listMenuLabel,
|
|
2316
2330
|
style: D ?? void 0,
|
|
2317
|
-
onKeyDown: (e) =>
|
|
2331
|
+
onKeyDown: (e) => rt(e, _.current),
|
|
2318
2332
|
children: [
|
|
2319
2333
|
B.map((e) => /* @__PURE__ */ m("button", {
|
|
2320
2334
|
type: "button",
|
|
@@ -2322,9 +2336,9 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2322
2336
|
"aria-checked": T.list === e.type,
|
|
2323
2337
|
tabIndex: -1,
|
|
2324
2338
|
className: "editor-toolbar-menu-item editor-toolbar-list-item",
|
|
2325
|
-
onMouseDown:
|
|
2326
|
-
onClick: () =>
|
|
2327
|
-
children: [/* @__PURE__ */ p(
|
|
2339
|
+
onMouseDown: Z,
|
|
2340
|
+
onClick: () => K(e.command),
|
|
2341
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2328
2342
|
name: e.icon,
|
|
2329
2343
|
className: "editor-toolbar-menu-icon"
|
|
2330
2344
|
}), /* @__PURE__ */ p("span", { children: e.label })]
|
|
@@ -2333,14 +2347,14 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2333
2347
|
className: "editor-toolbar-menu-divider",
|
|
2334
2348
|
role: "separator"
|
|
2335
2349
|
}),
|
|
2336
|
-
|
|
2350
|
+
V.map((e) => /* @__PURE__ */ m("button", {
|
|
2337
2351
|
type: "button",
|
|
2338
2352
|
role: "menuitem",
|
|
2339
2353
|
tabIndex: -1,
|
|
2340
2354
|
className: "editor-toolbar-menu-item editor-toolbar-list-item",
|
|
2341
|
-
onMouseDown:
|
|
2342
|
-
onClick: () =>
|
|
2343
|
-
children: [/* @__PURE__ */ p(
|
|
2355
|
+
onMouseDown: Z,
|
|
2356
|
+
onClick: () => K(e.command),
|
|
2357
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2344
2358
|
name: e.icon,
|
|
2345
2359
|
className: "editor-toolbar-menu-icon"
|
|
2346
2360
|
}), /* @__PURE__ */ p("span", { children: e.label })]
|
|
@@ -2348,59 +2362,59 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2348
2362
|
]
|
|
2349
2363
|
}) : null]
|
|
2350
2364
|
}),
|
|
2351
|
-
/* @__PURE__ */ p(
|
|
2365
|
+
/* @__PURE__ */ p(Q, {
|
|
2352
2366
|
toolbarId: "link",
|
|
2353
|
-
label:
|
|
2367
|
+
label: L.insertLink,
|
|
2354
2368
|
className: "editor-toolbar-desktop-only",
|
|
2355
2369
|
tabStop: x === "link",
|
|
2356
2370
|
onFocus: () => S("link"),
|
|
2357
2371
|
disabled: h,
|
|
2358
|
-
onClick: () =>
|
|
2359
|
-
children: /* @__PURE__ */ p(
|
|
2372
|
+
onClick: () => K(pe),
|
|
2373
|
+
children: /* @__PURE__ */ p(X, { name: "link" })
|
|
2360
2374
|
}),
|
|
2361
2375
|
/* @__PURE__ */ m("div", {
|
|
2362
2376
|
className: "editor-toolbar-slot",
|
|
2363
2377
|
children: [
|
|
2364
|
-
/* @__PURE__ */ m(
|
|
2378
|
+
/* @__PURE__ */ m(Q, {
|
|
2365
2379
|
toolbarId: "insert",
|
|
2366
|
-
label:
|
|
2380
|
+
label: L.insert,
|
|
2367
2381
|
className: "editor-toolbar-insert-trigger",
|
|
2368
2382
|
tabStop: x === "insert",
|
|
2369
2383
|
onFocus: () => S("insert"),
|
|
2370
2384
|
disabled: h,
|
|
2371
2385
|
popup: "menu",
|
|
2372
2386
|
expanded: y === "insert" || y === "emoji",
|
|
2373
|
-
controls: y === "emoji" ? j :
|
|
2374
|
-
onClick: () =>
|
|
2375
|
-
onKeyDown: (e) =>
|
|
2387
|
+
controls: y === "emoji" ? j : ce,
|
|
2388
|
+
onClick: () => q("insert"),
|
|
2389
|
+
onKeyDown: (e) => J("insert", e),
|
|
2376
2390
|
children: [
|
|
2377
|
-
/* @__PURE__ */ p(
|
|
2391
|
+
/* @__PURE__ */ p(X, { name: "plus" }),
|
|
2378
2392
|
/* @__PURE__ */ p("span", {
|
|
2379
2393
|
className: "editor-toolbar-insert-label",
|
|
2380
|
-
children:
|
|
2394
|
+
children: L.insert
|
|
2381
2395
|
}),
|
|
2382
|
-
/* @__PURE__ */ p(
|
|
2396
|
+
/* @__PURE__ */ p(X, {
|
|
2383
2397
|
name: "chevron",
|
|
2384
2398
|
className: "editor-toolbar-chevron"
|
|
2385
2399
|
})
|
|
2386
2400
|
]
|
|
2387
2401
|
}),
|
|
2388
2402
|
y === "insert" ? /* @__PURE__ */ m("div", {
|
|
2389
|
-
id:
|
|
2390
|
-
ref:
|
|
2403
|
+
id: ce,
|
|
2404
|
+
ref: _,
|
|
2391
2405
|
className: "editor-toolbar-popover editor-toolbar-insert-menu",
|
|
2392
2406
|
role: "menu",
|
|
2393
|
-
"aria-label":
|
|
2407
|
+
"aria-label": L.insertMenuLabel,
|
|
2394
2408
|
style: D ?? void 0,
|
|
2395
|
-
onKeyDown: (e) =>
|
|
2396
|
-
children: [
|
|
2409
|
+
onKeyDown: (e) => rt(e, _.current),
|
|
2410
|
+
children: [H.map((e) => /* @__PURE__ */ m("button", {
|
|
2397
2411
|
type: "button",
|
|
2398
2412
|
role: "menuitem",
|
|
2399
2413
|
tabIndex: -1,
|
|
2400
2414
|
className: "editor-toolbar-menu-item editor-toolbar-insert-item",
|
|
2401
|
-
onMouseDown:
|
|
2402
|
-
onClick: () =>
|
|
2403
|
-
children: [/* @__PURE__ */ p(
|
|
2415
|
+
onMouseDown: Z,
|
|
2416
|
+
onClick: () => K(e.command),
|
|
2417
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2404
2418
|
name: e.icon,
|
|
2405
2419
|
className: "editor-toolbar-menu-icon"
|
|
2406
2420
|
}), /* @__PURE__ */ p("span", { children: e.label })]
|
|
@@ -2409,32 +2423,32 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2409
2423
|
role: "menuitem",
|
|
2410
2424
|
tabIndex: -1,
|
|
2411
2425
|
className: "editor-toolbar-menu-item editor-toolbar-insert-item",
|
|
2412
|
-
onMouseDown:
|
|
2426
|
+
onMouseDown: Z,
|
|
2413
2427
|
onClick: () => b("emoji"),
|
|
2414
|
-
children: [/* @__PURE__ */ p(
|
|
2428
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2415
2429
|
name: "smile",
|
|
2416
2430
|
className: "editor-toolbar-menu-icon"
|
|
2417
|
-
}), /* @__PURE__ */ p("span", { children:
|
|
2431
|
+
}), /* @__PURE__ */ p("span", { children: L.emoji })]
|
|
2418
2432
|
})]
|
|
2419
2433
|
}) : null,
|
|
2420
2434
|
y === "emoji" ? /* @__PURE__ */ p("div", {
|
|
2421
2435
|
id: j,
|
|
2422
|
-
ref:
|
|
2436
|
+
ref: _,
|
|
2423
2437
|
className: "editor-toolbar-popover editor-toolbar-emoji-menu",
|
|
2424
2438
|
role: "menu",
|
|
2425
|
-
"aria-label":
|
|
2426
|
-
onKeyDown: (e) =>
|
|
2439
|
+
"aria-label": L.insertEmojiMenuLabel,
|
|
2440
|
+
onKeyDown: (e) => it(e, re.current),
|
|
2427
2441
|
children: /* @__PURE__ */ p("div", {
|
|
2428
2442
|
className: "editor-toolbar-emoji-grid",
|
|
2429
|
-
ref:
|
|
2430
|
-
children:
|
|
2443
|
+
ref: re,
|
|
2444
|
+
children: We.map((e) => /* @__PURE__ */ p("button", {
|
|
2431
2445
|
type: "button",
|
|
2432
2446
|
role: "menuitem",
|
|
2433
2447
|
tabIndex: -1,
|
|
2434
2448
|
className: "editor-toolbar-emoji",
|
|
2435
|
-
"aria-label":
|
|
2436
|
-
onMouseDown:
|
|
2437
|
-
onClick: () =>
|
|
2449
|
+
"aria-label": L.insertEmojiLabel(e),
|
|
2450
|
+
onMouseDown: Z,
|
|
2451
|
+
onClick: () => he(e),
|
|
2438
2452
|
children: e
|
|
2439
2453
|
}, e))
|
|
2440
2454
|
})
|
|
@@ -2443,63 +2457,63 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2443
2457
|
}),
|
|
2444
2458
|
/* @__PURE__ */ m("div", {
|
|
2445
2459
|
className: "editor-toolbar-slot editor-toolbar-slot-native",
|
|
2446
|
-
children: [/* @__PURE__ */ m(
|
|
2460
|
+
children: [/* @__PURE__ */ m(Q, {
|
|
2447
2461
|
toolbarId: "components",
|
|
2448
|
-
label:
|
|
2462
|
+
label: L.componentsTriggerLabel,
|
|
2449
2463
|
className: "editor-toolbar-components-trigger",
|
|
2450
2464
|
tabStop: x === "components",
|
|
2451
2465
|
onFocus: () => S("components"),
|
|
2452
2466
|
disabled: h,
|
|
2453
2467
|
popup: "dialog",
|
|
2454
2468
|
expanded: y === "native",
|
|
2455
|
-
controls:
|
|
2456
|
-
onClick: () =>
|
|
2457
|
-
onKeyDown: (e) =>
|
|
2469
|
+
controls: P,
|
|
2470
|
+
onClick: () => q("native"),
|
|
2471
|
+
onKeyDown: (e) => J("native", e),
|
|
2458
2472
|
children: [
|
|
2459
|
-
/* @__PURE__ */ p(
|
|
2473
|
+
/* @__PURE__ */ p(X, { name: "sparkle" }),
|
|
2460
2474
|
/* @__PURE__ */ p("span", {
|
|
2461
2475
|
className: "editor-toolbar-components-label editor-toolbar-components-label-full",
|
|
2462
|
-
children:
|
|
2476
|
+
children: L.componentsLabel
|
|
2463
2477
|
}),
|
|
2464
2478
|
/* @__PURE__ */ p("span", {
|
|
2465
2479
|
className: "editor-toolbar-components-label editor-toolbar-components-label-compact",
|
|
2466
|
-
children:
|
|
2480
|
+
children: L.componentsCompactLabel
|
|
2467
2481
|
})
|
|
2468
2482
|
]
|
|
2469
2483
|
}), y === "native" ? /* @__PURE__ */ m("div", {
|
|
2470
|
-
id:
|
|
2471
|
-
ref:
|
|
2484
|
+
id: P,
|
|
2485
|
+
ref: _,
|
|
2472
2486
|
className: "editor-toolbar-popover editor-toolbar-native-menu",
|
|
2473
2487
|
role: "dialog",
|
|
2474
|
-
"aria-label":
|
|
2475
|
-
onKeyDown: (e) =>
|
|
2488
|
+
"aria-label": L.nativeMenuLabel,
|
|
2489
|
+
onKeyDown: (e) => rt(e, _.current),
|
|
2476
2490
|
children: [
|
|
2477
2491
|
/* @__PURE__ */ m("div", {
|
|
2478
2492
|
className: "editor-toolbar-native-head",
|
|
2479
2493
|
children: [/* @__PURE__ */ p("span", {
|
|
2480
2494
|
className: "editor-toolbar-native-title",
|
|
2481
|
-
children:
|
|
2495
|
+
children: L.nativeTitle
|
|
2482
2496
|
}), /* @__PURE__ */ p("button", {
|
|
2483
2497
|
type: "button",
|
|
2484
2498
|
className: "editor-toolbar-close",
|
|
2485
|
-
"aria-label":
|
|
2486
|
-
onMouseDown:
|
|
2499
|
+
"aria-label": L.closeNativeLabel,
|
|
2500
|
+
onMouseDown: Z,
|
|
2487
2501
|
onClick: we,
|
|
2488
|
-
children: /* @__PURE__ */ p(
|
|
2502
|
+
children: /* @__PURE__ */ p(X, { name: "close" })
|
|
2489
2503
|
})]
|
|
2490
2504
|
}),
|
|
2491
2505
|
/* @__PURE__ */ m("div", {
|
|
2492
2506
|
className: "editor-toolbar-search",
|
|
2493
|
-
children: [/* @__PURE__ */ p(
|
|
2507
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2494
2508
|
name: "search",
|
|
2495
2509
|
className: "editor-toolbar-search-icon"
|
|
2496
2510
|
}), /* @__PURE__ */ p("input", {
|
|
2497
|
-
ref:
|
|
2511
|
+
ref: ne,
|
|
2498
2512
|
type: "search",
|
|
2499
2513
|
className: "editor-toolbar-search-input",
|
|
2500
2514
|
value: C,
|
|
2501
|
-
placeholder:
|
|
2502
|
-
"aria-label":
|
|
2515
|
+
placeholder: L.searchPlaceholder,
|
|
2516
|
+
"aria-label": L.searchLabel,
|
|
2503
2517
|
autoComplete: "off",
|
|
2504
2518
|
spellCheck: !1,
|
|
2505
2519
|
onChange: (e) => w(e.target.value)
|
|
@@ -2508,11 +2522,11 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2508
2522
|
/* @__PURE__ */ p("div", {
|
|
2509
2523
|
className: "editor-toolbar-native-scroll",
|
|
2510
2524
|
role: "menu",
|
|
2511
|
-
"aria-label":
|
|
2512
|
-
children:
|
|
2525
|
+
"aria-label": L.nativeListLabel,
|
|
2526
|
+
children: U.length === 0 ? /* @__PURE__ */ p("p", {
|
|
2513
2527
|
className: "editor-toolbar-menu-empty",
|
|
2514
|
-
children:
|
|
2515
|
-
}) :
|
|
2528
|
+
children: L.noMatchingComponents
|
|
2529
|
+
}) : U.map(({ group: e, components: t }) => /* @__PURE__ */ m("div", {
|
|
2516
2530
|
className: "editor-toolbar-native-group",
|
|
2517
2531
|
role: "group",
|
|
2518
2532
|
"aria-label": e.label,
|
|
@@ -2525,21 +2539,21 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2525
2539
|
role: "menuitem",
|
|
2526
2540
|
tabIndex: -1,
|
|
2527
2541
|
className: "editor-toolbar-native-item",
|
|
2528
|
-
onMouseDown:
|
|
2529
|
-
onClick: () =>
|
|
2542
|
+
onMouseDown: Z,
|
|
2543
|
+
onClick: () => ge(e),
|
|
2530
2544
|
children: [/* @__PURE__ */ m("span", {
|
|
2531
2545
|
className: "editor-toolbar-native-copy",
|
|
2532
2546
|
children: [/* @__PURE__ */ m("span", {
|
|
2533
2547
|
className: "editor-toolbar-native-label",
|
|
2534
2548
|
children: [e.label, e.inline ? /* @__PURE__ */ p("span", {
|
|
2535
2549
|
className: "editor-toolbar-native-badge",
|
|
2536
|
-
children:
|
|
2550
|
+
children: L.inlineBadge
|
|
2537
2551
|
}) : null]
|
|
2538
2552
|
}), /* @__PURE__ */ p("span", {
|
|
2539
2553
|
className: "editor-toolbar-native-description",
|
|
2540
2554
|
children: e.description
|
|
2541
2555
|
})]
|
|
2542
|
-
}), /* @__PURE__ */ p(
|
|
2556
|
+
}), /* @__PURE__ */ p(X, {
|
|
2543
2557
|
name: "plus",
|
|
2544
2558
|
className: "editor-toolbar-native-add"
|
|
2545
2559
|
})]
|
|
@@ -2552,73 +2566,73 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2552
2566
|
/* @__PURE__ */ m("div", {
|
|
2553
2567
|
className: "editor-toolbar-history",
|
|
2554
2568
|
role: "group",
|
|
2555
|
-
"aria-label":
|
|
2569
|
+
"aria-label": L.historyLabel,
|
|
2556
2570
|
children: [
|
|
2557
|
-
/* @__PURE__ */ p(
|
|
2571
|
+
/* @__PURE__ */ p(Q, {
|
|
2558
2572
|
toolbarId: "undo",
|
|
2559
|
-
label:
|
|
2573
|
+
label: L.undo,
|
|
2560
2574
|
className: "editor-toolbar-desktop-only",
|
|
2561
2575
|
tabStop: x === "undo",
|
|
2562
2576
|
onFocus: () => S("undo"),
|
|
2563
2577
|
disabled: h || !s,
|
|
2564
2578
|
onClick: _e,
|
|
2565
|
-
children: /* @__PURE__ */ p(
|
|
2579
|
+
children: /* @__PURE__ */ p(X, { name: "undo" })
|
|
2566
2580
|
}),
|
|
2567
|
-
/* @__PURE__ */ p(
|
|
2581
|
+
/* @__PURE__ */ p(Q, {
|
|
2568
2582
|
toolbarId: "redo",
|
|
2569
|
-
label:
|
|
2583
|
+
label: L.redo,
|
|
2570
2584
|
className: "editor-toolbar-desktop-only",
|
|
2571
2585
|
tabStop: x === "redo",
|
|
2572
2586
|
onFocus: () => S("redo"),
|
|
2573
2587
|
disabled: h || !f,
|
|
2574
|
-
onClick:
|
|
2575
|
-
children: /* @__PURE__ */ p(
|
|
2588
|
+
onClick: ve,
|
|
2589
|
+
children: /* @__PURE__ */ p(X, { name: "redo" })
|
|
2576
2590
|
}),
|
|
2577
|
-
te ? /* @__PURE__ */ p(
|
|
2591
|
+
te ? /* @__PURE__ */ p(Q, {
|
|
2578
2592
|
toolbarId: "download",
|
|
2579
|
-
label:
|
|
2593
|
+
label: L.download,
|
|
2580
2594
|
className: "editor-toolbar-desktop-only",
|
|
2581
2595
|
tabStop: x === "download",
|
|
2582
2596
|
onFocus: () => S("download"),
|
|
2583
2597
|
disabled: h,
|
|
2584
|
-
onClick:
|
|
2585
|
-
children: /* @__PURE__ */ p(
|
|
2598
|
+
onClick: ye,
|
|
2599
|
+
children: /* @__PURE__ */ p(X, { name: "download" })
|
|
2586
2600
|
}) : null,
|
|
2587
2601
|
/* @__PURE__ */ m("div", {
|
|
2588
2602
|
className: "editor-toolbar-slot editor-toolbar-mobile-only",
|
|
2589
|
-
children: [/* @__PURE__ */ p(
|
|
2603
|
+
children: [/* @__PURE__ */ p(Q, {
|
|
2590
2604
|
toolbarId: "more",
|
|
2591
|
-
label:
|
|
2605
|
+
label: L.more,
|
|
2592
2606
|
className: "editor-toolbar-more-trigger",
|
|
2593
2607
|
tabStop: x === "more",
|
|
2594
2608
|
onFocus: () => S("more"),
|
|
2595
2609
|
disabled: h,
|
|
2596
2610
|
popup: "menu",
|
|
2597
2611
|
expanded: y === "more",
|
|
2598
|
-
controls:
|
|
2599
|
-
onClick: () =>
|
|
2600
|
-
onKeyDown: (e) =>
|
|
2601
|
-
children: /* @__PURE__ */ p(
|
|
2612
|
+
controls: le,
|
|
2613
|
+
onClick: () => q("more"),
|
|
2614
|
+
onKeyDown: (e) => J("more", e),
|
|
2615
|
+
children: /* @__PURE__ */ p(X, { name: "more" })
|
|
2602
2616
|
}), y === "more" ? /* @__PURE__ */ m("div", {
|
|
2603
|
-
id:
|
|
2604
|
-
ref:
|
|
2617
|
+
id: le,
|
|
2618
|
+
ref: _,
|
|
2605
2619
|
className: "editor-toolbar-popover editor-toolbar-more-menu",
|
|
2606
2620
|
role: "menu",
|
|
2607
|
-
"aria-label":
|
|
2621
|
+
"aria-label": L.moreMenuLabel,
|
|
2608
2622
|
style: D ?? void 0,
|
|
2609
|
-
onKeyDown: (e) =>
|
|
2623
|
+
onKeyDown: (e) => rt(e, _.current),
|
|
2610
2624
|
children: [
|
|
2611
2625
|
/* @__PURE__ */ m("button", {
|
|
2612
2626
|
type: "button",
|
|
2613
2627
|
role: "menuitem",
|
|
2614
2628
|
tabIndex: -1,
|
|
2615
2629
|
className: "editor-toolbar-menu-item editor-toolbar-more-item editor-toolbar-more-link",
|
|
2616
|
-
onMouseDown:
|
|
2617
|
-
onClick: () =>
|
|
2618
|
-
children: [/* @__PURE__ */ p(
|
|
2630
|
+
onMouseDown: Z,
|
|
2631
|
+
onClick: () => K(pe),
|
|
2632
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2619
2633
|
name: "link",
|
|
2620
2634
|
className: "editor-toolbar-menu-icon"
|
|
2621
|
-
}), /* @__PURE__ */ p("span", { children:
|
|
2635
|
+
}), /* @__PURE__ */ p("span", { children: L.linkMenuItem })]
|
|
2622
2636
|
}),
|
|
2623
2637
|
/* @__PURE__ */ m("button", {
|
|
2624
2638
|
type: "button",
|
|
@@ -2626,12 +2640,12 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2626
2640
|
tabIndex: -1,
|
|
2627
2641
|
className: "editor-toolbar-menu-item editor-toolbar-more-item",
|
|
2628
2642
|
disabled: !s,
|
|
2629
|
-
onMouseDown:
|
|
2643
|
+
onMouseDown: Z,
|
|
2630
2644
|
onClick: _e,
|
|
2631
|
-
children: [/* @__PURE__ */ p(
|
|
2645
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2632
2646
|
name: "undo",
|
|
2633
2647
|
className: "editor-toolbar-menu-icon"
|
|
2634
|
-
}), /* @__PURE__ */ p("span", { children:
|
|
2648
|
+
}), /* @__PURE__ */ p("span", { children: L.undo })]
|
|
2635
2649
|
}),
|
|
2636
2650
|
/* @__PURE__ */ m("button", {
|
|
2637
2651
|
type: "button",
|
|
@@ -2639,24 +2653,24 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2639
2653
|
tabIndex: -1,
|
|
2640
2654
|
className: "editor-toolbar-menu-item editor-toolbar-more-item",
|
|
2641
2655
|
disabled: !f,
|
|
2642
|
-
onMouseDown:
|
|
2643
|
-
onClick:
|
|
2644
|
-
children: [/* @__PURE__ */ p(
|
|
2656
|
+
onMouseDown: Z,
|
|
2657
|
+
onClick: ve,
|
|
2658
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2645
2659
|
name: "redo",
|
|
2646
2660
|
className: "editor-toolbar-menu-icon"
|
|
2647
|
-
}), /* @__PURE__ */ p("span", { children:
|
|
2661
|
+
}), /* @__PURE__ */ p("span", { children: L.redo })]
|
|
2648
2662
|
}),
|
|
2649
2663
|
te ? /* @__PURE__ */ m("button", {
|
|
2650
2664
|
type: "button",
|
|
2651
2665
|
role: "menuitem",
|
|
2652
2666
|
tabIndex: -1,
|
|
2653
2667
|
className: "editor-toolbar-menu-item editor-toolbar-more-item",
|
|
2654
|
-
onMouseDown:
|
|
2655
|
-
onClick:
|
|
2656
|
-
children: [/* @__PURE__ */ p(
|
|
2668
|
+
onMouseDown: Z,
|
|
2669
|
+
onClick: ye,
|
|
2670
|
+
children: [/* @__PURE__ */ p(X, {
|
|
2657
2671
|
name: "download",
|
|
2658
2672
|
className: "editor-toolbar-menu-icon"
|
|
2659
|
-
}), /* @__PURE__ */ p("span", { children:
|
|
2673
|
+
}), /* @__PURE__ */ p("span", { children: L.download })]
|
|
2660
2674
|
}) : null
|
|
2661
2675
|
]
|
|
2662
2676
|
}) : null]
|
|
@@ -2666,6 +2680,61 @@ function ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo
|
|
|
2666
2680
|
]
|
|
2667
2681
|
});
|
|
2668
2682
|
}
|
|
2683
|
+
// src/editor/editor-view-bar.tsx
|
|
2684
|
+
function ot({ source: e, mode: t, onModeChange: n, sourceId: r, previewId: i, hasPreview: a, allowSplit: o, toolbar: s }) {
|
|
2685
|
+
let c = oe(), u = re[c], d = l(() => Array.from(e).length, [e]);
|
|
2686
|
+
return /* @__PURE__ */ m("div", {
|
|
2687
|
+
className: "editor-status-bar",
|
|
2688
|
+
role: "group",
|
|
2689
|
+
"aria-label": u.viewLabel,
|
|
2690
|
+
children: [
|
|
2691
|
+
/* @__PURE__ */ p("span", {
|
|
2692
|
+
className: "editor-status-count",
|
|
2693
|
+
children: u.count(d.toLocaleString(c))
|
|
2694
|
+
}),
|
|
2695
|
+
/* @__PURE__ */ p("span", {
|
|
2696
|
+
className: "editor-status-hint",
|
|
2697
|
+
children: t !== "preview" && s ? u.keyboardHint : ""
|
|
2698
|
+
}),
|
|
2699
|
+
a ? /* @__PURE__ */ p("div", {
|
|
2700
|
+
className: "editor-view-modes",
|
|
2701
|
+
children: [
|
|
2702
|
+
"edit",
|
|
2703
|
+
"split",
|
|
2704
|
+
"preview"
|
|
2705
|
+
].filter((e) => e !== "split" || o).map((e) => /* @__PURE__ */ m("button", {
|
|
2706
|
+
type: "button",
|
|
2707
|
+
"data-editor-view-option": e,
|
|
2708
|
+
"aria-pressed": t === e,
|
|
2709
|
+
"aria-controls": e === "edit" ? r : e === "preview" ? i : `${r} ${i}`,
|
|
2710
|
+
onClick: () => n(e),
|
|
2711
|
+
children: [/* @__PURE__ */ p("svg", {
|
|
2712
|
+
viewBox: "0 0 24 24",
|
|
2713
|
+
width: "18",
|
|
2714
|
+
height: "18",
|
|
2715
|
+
fill: "none",
|
|
2716
|
+
stroke: "currentColor",
|
|
2717
|
+
strokeWidth: "1.7",
|
|
2718
|
+
strokeLinecap: "round",
|
|
2719
|
+
strokeLinejoin: "round",
|
|
2720
|
+
"aria-hidden": "true",
|
|
2721
|
+
children: e === "edit" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("path", { d: "m16 3 5 5-12 12-6 1 1-6Z" }), /* @__PURE__ */ p("path", { d: "m13 6 5 5" })] }) : e === "split" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("rect", {
|
|
2722
|
+
x: "3",
|
|
2723
|
+
y: "4",
|
|
2724
|
+
width: "18",
|
|
2725
|
+
height: "16",
|
|
2726
|
+
rx: "2"
|
|
2727
|
+
}), /* @__PURE__ */ p("path", { d: "M12 4v16" })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("path", { d: "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z" }), /* @__PURE__ */ p("circle", {
|
|
2728
|
+
cx: "12",
|
|
2729
|
+
cy: "12",
|
|
2730
|
+
r: "3"
|
|
2731
|
+
})] })
|
|
2732
|
+
}), /* @__PURE__ */ p("span", { children: u[e] })]
|
|
2733
|
+
}, e))
|
|
2734
|
+
}) : null
|
|
2735
|
+
]
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2669
2738
|
// src/editor/source-authoring.tsx
|
|
2670
2739
|
var st = {
|
|
2671
2740
|
tokens: [],
|
|
@@ -2686,13 +2755,13 @@ function lt(e) {
|
|
|
2686
2755
|
let t = e.toLowerCase();
|
|
2687
2756
|
return ct[t] || (t.includes("tag") ? "tag" : t.includes("attr") ? "attribute" : t.includes("string") || t.includes("quote") ? "string" : t.includes("expr") || t.includes("interp") ? "expression" : t.includes("bind") ? "binding" : t.includes("math") || t.includes("latex") ? "math" : t.includes("code") || t.includes("fence") ? "code" : t.includes("comment") ? "comment" : t.includes("markdown") || t.includes("heading") || t.includes("emphasis") || t.includes("link") ? "markdown" : "plain");
|
|
2688
2757
|
}
|
|
2689
|
-
function
|
|
2758
|
+
function ut(e, t, n) {
|
|
2690
2759
|
return Math.min(Math.max(e, t), n);
|
|
2691
2760
|
}
|
|
2692
|
-
function
|
|
2761
|
+
function dt(e, t) {
|
|
2693
2762
|
let n = [], r = 0, i = [...t].sort((e, t) => e.range.start - t.range.start);
|
|
2694
2763
|
for (let t of i) {
|
|
2695
|
-
let i =
|
|
2764
|
+
let i = ut(Math.max(t.range.start, r), 0, e.length), a = ut(t.range.end, i, e.length);
|
|
2696
2765
|
r = a, a > i && n.push({
|
|
2697
2766
|
kind: t.kind,
|
|
2698
2767
|
range: {
|
|
@@ -2703,13 +2772,13 @@ function ut(e, t) {
|
|
|
2703
2772
|
}
|
|
2704
2773
|
return n;
|
|
2705
2774
|
}
|
|
2706
|
-
function
|
|
2775
|
+
function ft(e, t = !0) {
|
|
2707
2776
|
return l(() => {
|
|
2708
2777
|
if (!t) return st;
|
|
2709
2778
|
try {
|
|
2710
2779
|
let t = ee(e);
|
|
2711
2780
|
return {
|
|
2712
|
-
tokens:
|
|
2781
|
+
tokens: dt(e, t.tokens),
|
|
2713
2782
|
bindings: t.bindings,
|
|
2714
2783
|
diagnostics: t.diagnostics
|
|
2715
2784
|
};
|
|
@@ -2718,7 +2787,7 @@ function dt(e, t = !0) {
|
|
|
2718
2787
|
}
|
|
2719
2788
|
}, [e, t]);
|
|
2720
2789
|
}
|
|
2721
|
-
function
|
|
2790
|
+
function pt(e, t) {
|
|
2722
2791
|
let n = [], r = 0;
|
|
2723
2792
|
return t.forEach((t, i) => {
|
|
2724
2793
|
t.range.start > r && n.push(e.slice(r, t.range.start)), n.push(/* @__PURE__ */ p("span", {
|
|
@@ -2728,7 +2797,7 @@ function ft(e, t) {
|
|
|
2728
2797
|
}, `${i}-${t.range.start}`)), r = t.range.end;
|
|
2729
2798
|
}), r < e.length && n.push(e.slice(r)), n;
|
|
2730
2799
|
}
|
|
2731
|
-
var
|
|
2800
|
+
var mt = n(function({ source: e, tokens: t, width: n, editorRef: r }) {
|
|
2732
2801
|
let i = u(null);
|
|
2733
2802
|
return a(() => {
|
|
2734
2803
|
let e = r.current, t = i.current;
|
|
@@ -2762,10 +2831,10 @@ var pt = n(function({ source: e, tokens: t, width: n, editorRef: r }) {
|
|
|
2762
2831
|
children: /* @__PURE__ */ p("div", {
|
|
2763
2832
|
className: "author-highlight-content",
|
|
2764
2833
|
ref: i,
|
|
2765
|
-
children:
|
|
2834
|
+
children: pt(e, t)
|
|
2766
2835
|
})
|
|
2767
2836
|
});
|
|
2768
|
-
}),
|
|
2837
|
+
}), ht = {
|
|
2769
2838
|
en: {
|
|
2770
2839
|
region: "Source authoring tools",
|
|
2771
2840
|
title: "Authoring",
|
|
@@ -2865,16 +2934,16 @@ var pt = n(function({ source: e, tokens: t, width: n, editorRef: r }) {
|
|
|
2865
2934
|
position: (e, t) => `第 ${e} 行 ${t} 列`
|
|
2866
2935
|
}
|
|
2867
2936
|
};
|
|
2868
|
-
function
|
|
2937
|
+
function gt(e, t) {
|
|
2869
2938
|
return t >= e.start && t <= e.end;
|
|
2870
2939
|
}
|
|
2871
|
-
function
|
|
2940
|
+
function _t(e) {
|
|
2872
2941
|
return e.end - e.start;
|
|
2873
2942
|
}
|
|
2874
|
-
function
|
|
2943
|
+
function vt(e, t) {
|
|
2875
2944
|
let n = null, r = Infinity, i = (e, i, a) => {
|
|
2876
|
-
if (!
|
|
2877
|
-
let o =
|
|
2945
|
+
if (!gt(i, t)) return;
|
|
2946
|
+
let o = _t(i);
|
|
2878
2947
|
o >= r || (n = {
|
|
2879
2948
|
binding: e,
|
|
2880
2949
|
role: a
|
|
@@ -2886,63 +2955,63 @@ function _t(e, t) {
|
|
|
2886
2955
|
}
|
|
2887
2956
|
return n;
|
|
2888
2957
|
}
|
|
2889
|
-
function
|
|
2958
|
+
function yt(e) {
|
|
2890
2959
|
let t = e.current;
|
|
2891
2960
|
if (!t) return {
|
|
2892
2961
|
start: 0,
|
|
2893
2962
|
end: 0
|
|
2894
2963
|
};
|
|
2895
|
-
let n = t.value.length, r =
|
|
2964
|
+
let n = t.value.length, r = ut(t.selectionStart, 0, n);
|
|
2896
2965
|
return {
|
|
2897
2966
|
start: r,
|
|
2898
|
-
end:
|
|
2967
|
+
end: ut(t.selectionEnd, r, n)
|
|
2899
2968
|
};
|
|
2900
2969
|
}
|
|
2901
|
-
function
|
|
2970
|
+
function bt(e, t) {
|
|
2902
2971
|
let n = Math.min(e.length, t.length), r = 0;
|
|
2903
2972
|
for (; r < n && e[r] === t[r];) r += 1;
|
|
2904
2973
|
return r;
|
|
2905
2974
|
}
|
|
2906
|
-
function
|
|
2975
|
+
function xt(e, t, n) {
|
|
2907
2976
|
let r = Math.min(e.length, t.length) - n, i = 0;
|
|
2908
2977
|
for (; i < r && e[e.length - 1 - i] === t[t.length - 1 - i];) i += 1;
|
|
2909
2978
|
return i;
|
|
2910
2979
|
}
|
|
2911
|
-
function
|
|
2912
|
-
let r =
|
|
2980
|
+
function St(e, t, n) {
|
|
2981
|
+
let r = ut(n, 0, e.length), i = bt(e, t);
|
|
2913
2982
|
if (r <= i) return r;
|
|
2914
|
-
let a =
|
|
2983
|
+
let a = xt(e, t, i), o = e.length - a;
|
|
2915
2984
|
if (r >= o) return t.length - a + (r - o);
|
|
2916
2985
|
let s = o - i, c = t.length - a - i;
|
|
2917
2986
|
if (s <= 0) return t.length - a;
|
|
2918
2987
|
let l = (r - i) / s;
|
|
2919
2988
|
return Math.round(i + l * c);
|
|
2920
2989
|
}
|
|
2921
|
-
function
|
|
2990
|
+
function Ct(e, t) {
|
|
2922
2991
|
let n = 0;
|
|
2923
2992
|
for (let r of [...t].sort((e, t) => e.range.start - t.range.start)) {
|
|
2924
2993
|
if (e < r.range.start) break;
|
|
2925
|
-
if (e > r.range.end) n += r.text.length -
|
|
2994
|
+
if (e > r.range.end) n += r.text.length - _t(r.range);
|
|
2926
2995
|
else return r.range.start + n + Math.min(e - r.range.start, r.text.length);
|
|
2927
2996
|
}
|
|
2928
2997
|
return e + n;
|
|
2929
2998
|
}
|
|
2930
|
-
function
|
|
2999
|
+
function wt(e) {
|
|
2931
3000
|
e.preventDefault();
|
|
2932
3001
|
}
|
|
2933
|
-
function
|
|
3002
|
+
function Tt(e) {
|
|
2934
3003
|
return e.isComposing === !0 || e.keyCode === 229;
|
|
2935
3004
|
}
|
|
2936
|
-
function
|
|
2937
|
-
let n =
|
|
3005
|
+
function Et(e, t) {
|
|
3006
|
+
let n = ut(t, 0, e.length), r = e.lastIndexOf("\n", n - 1) + 1;
|
|
2938
3007
|
return {
|
|
2939
3008
|
line: e.slice(0, n).split("\n").length,
|
|
2940
3009
|
column: n - r + 1
|
|
2941
3010
|
};
|
|
2942
3011
|
}
|
|
2943
|
-
function
|
|
2944
|
-
let ee = oe(),
|
|
2945
|
-
N.current = O,
|
|
3012
|
+
function Dt({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit: s, onLocate: c, disabled: f = !1 }) {
|
|
3013
|
+
let ee = oe(), _ = ht[ee], ne = o(), re = o(), ie = u(null), ae = u(null), [v, y] = d(0), [b, x] = d(null), [S, C] = d(""), [w, T] = d(null), [E, D] = d(null), [O, k] = d(!1), [A, se] = d([]), [j, M] = d(0), N = u(O), ce = u(A), le = u(j);
|
|
3014
|
+
N.current = O, ce.current = A, le.current = j, a(() => {
|
|
2946
3015
|
let e = i.current;
|
|
2947
3016
|
if (!e) return;
|
|
2948
3017
|
let t = () => y(e.selectionStart);
|
|
@@ -2963,17 +3032,17 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
2963
3032
|
}, [e]), a(() => {
|
|
2964
3033
|
D(null), T(null);
|
|
2965
3034
|
}, [ee]);
|
|
2966
|
-
let
|
|
3035
|
+
let P = l(() => vt(t.bindings, v), [t.bindings, v]);
|
|
2967
3036
|
a(() => {
|
|
2968
|
-
|
|
2969
|
-
}, [
|
|
2970
|
-
let
|
|
3037
|
+
P && x(P.binding.name);
|
|
3038
|
+
}, [P]);
|
|
3039
|
+
let F = l(() => (b ? t.bindings.find((e) => e.name === b) : void 0) ?? t.bindings[0] ?? null, [t.bindings, b]);
|
|
2971
3040
|
a(() => {
|
|
2972
3041
|
C(""), T(null);
|
|
2973
|
-
}, [
|
|
2974
|
-
let
|
|
3042
|
+
}, [F?.name]);
|
|
3043
|
+
let I = F && n ? n.bindings[F.name]?.type ?? n.computations?.[F.name]?.type : void 0, L = P && n ? n.bindings[P.binding.name]?.type ?? n.computations?.[P.binding.name]?.type : void 0, R = L ? _.typeNames[L] ?? L : _.unknownType, z = I ? _.typeNames[I] ?? I : _.unknownType, B = r(() => {
|
|
2975
3044
|
if (f) return;
|
|
2976
|
-
let t = i.current, n =
|
|
3045
|
+
let t = i.current, n = ut(t?.selectionStart ?? 0, 0, e.length), r = [];
|
|
2977
3046
|
try {
|
|
2978
3047
|
r = te(e, n) ?? [];
|
|
2979
3048
|
} catch {
|
|
@@ -2984,9 +3053,9 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
2984
3053
|
f,
|
|
2985
3054
|
i,
|
|
2986
3055
|
e
|
|
2987
|
-
]),
|
|
3056
|
+
]), V = r((t) => {
|
|
2988
3057
|
if (f) return;
|
|
2989
|
-
let n =
|
|
3058
|
+
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;
|
|
2990
3059
|
k(!1), s({
|
|
2991
3060
|
value: i,
|
|
2992
3061
|
selection: {
|
|
@@ -3003,7 +3072,7 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3003
3072
|
let e = i.current;
|
|
3004
3073
|
if (!e) return;
|
|
3005
3074
|
let t = (e) => {
|
|
3006
|
-
if (
|
|
3075
|
+
if (Tt(e)) return;
|
|
3007
3076
|
if (f) {
|
|
3008
3077
|
N.current && k(!1);
|
|
3009
3078
|
return;
|
|
@@ -3013,27 +3082,27 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3013
3082
|
else if (N.current) {
|
|
3014
3083
|
if (t === "ArrowDown" || t === "ArrowUp") {
|
|
3015
3084
|
e.preventDefault(), e.stopPropagation();
|
|
3016
|
-
let n =
|
|
3085
|
+
let n = ce.current.length;
|
|
3017
3086
|
M((e) => n === 0 ? 0 : (e + (t === "ArrowDown" ? 1 : -1) + n) % n);
|
|
3018
3087
|
} else if (t === "Enter") {
|
|
3019
3088
|
e.preventDefault(), e.stopPropagation();
|
|
3020
|
-
let t =
|
|
3021
|
-
t ?
|
|
3089
|
+
let t = ce.current[le.current];
|
|
3090
|
+
t ? V(t) : k(!1);
|
|
3022
3091
|
} else t === "Escape" && (e.preventDefault(), e.stopPropagation(), k(!1));
|
|
3023
3092
|
}
|
|
3024
3093
|
};
|
|
3025
3094
|
return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
|
|
3026
3095
|
}, [
|
|
3027
|
-
|
|
3096
|
+
V,
|
|
3028
3097
|
f,
|
|
3029
3098
|
i,
|
|
3030
3099
|
B
|
|
3031
3100
|
]), a(() => {
|
|
3032
3101
|
if (!O) return;
|
|
3033
3102
|
let e = (e) => {
|
|
3034
|
-
|
|
3103
|
+
ie.current?.contains(e.target) || k(!1);
|
|
3035
3104
|
}, t = (e) => {
|
|
3036
|
-
e.key === "Escape" && !
|
|
3105
|
+
e.key === "Escape" && !Tt(e) && k(!1);
|
|
3037
3106
|
};
|
|
3038
3107
|
return document.addEventListener("pointerdown", e, !0), document.addEventListener("keydown", t, !0), () => {
|
|
3039
3108
|
document.removeEventListener("pointerdown", e, !0), document.removeEventListener("keydown", t, !0);
|
|
@@ -3041,121 +3110,121 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3041
3110
|
}, [O]), a(() => {
|
|
3042
3111
|
O && ae.current?.querySelector(`[data-completion-index="${j}"]`)?.scrollIntoView({ block: "nearest" });
|
|
3043
3112
|
}, [j, O]);
|
|
3044
|
-
let
|
|
3113
|
+
let H = () => {
|
|
3045
3114
|
if (f) return;
|
|
3046
3115
|
let t;
|
|
3047
3116
|
try {
|
|
3048
3117
|
t = h(e);
|
|
3049
3118
|
} catch (e) {
|
|
3050
|
-
D(
|
|
3119
|
+
D(_.formatFailed(e instanceof Error ? e.message : String(e)));
|
|
3051
3120
|
return;
|
|
3052
3121
|
}
|
|
3053
3122
|
if (t === e) {
|
|
3054
|
-
D(
|
|
3123
|
+
D(_.formatUnchanged);
|
|
3055
3124
|
return;
|
|
3056
3125
|
}
|
|
3057
|
-
let n =
|
|
3126
|
+
let n = yt(i);
|
|
3058
3127
|
s({
|
|
3059
3128
|
value: t,
|
|
3060
3129
|
selection: {
|
|
3061
|
-
start:
|
|
3062
|
-
end:
|
|
3130
|
+
start: St(e, t, n.start),
|
|
3131
|
+
end: St(e, t, n.end)
|
|
3063
3132
|
}
|
|
3064
|
-
}), D(
|
|
3065
|
-
},
|
|
3066
|
-
if (f || !
|
|
3133
|
+
}), D(_.formatApplied);
|
|
3134
|
+
}, U = () => {
|
|
3135
|
+
if (f || !F) return;
|
|
3067
3136
|
let t = S.trim();
|
|
3068
|
-
if (!t) T(
|
|
3069
|
-
else if (t ===
|
|
3137
|
+
if (!t) T(_.renameEmpty);
|
|
3138
|
+
else if (t === F.name) T(_.renameSame);
|
|
3070
3139
|
else try {
|
|
3071
|
-
let n =
|
|
3140
|
+
let n = g(e, F.name, t), r = yt(i);
|
|
3072
3141
|
s({
|
|
3073
3142
|
value: n.source,
|
|
3074
3143
|
selection: {
|
|
3075
|
-
start:
|
|
3076
|
-
end:
|
|
3144
|
+
start: Ct(r.start, n.edits),
|
|
3145
|
+
end: Ct(r.end, n.edits)
|
|
3077
3146
|
}
|
|
3078
|
-
}), x(t), C(""), T(null), D(
|
|
3147
|
+
}), x(t), C(""), T(null), D(_.renameDone(F.name, t));
|
|
3079
3148
|
} catch (e) {
|
|
3080
|
-
T(
|
|
3149
|
+
T(_.renameFailed(e instanceof Error ? e.message : String(e)));
|
|
3081
3150
|
}
|
|
3082
|
-
},
|
|
3151
|
+
}, W = A[j], ue = F ? [...F.declarations.map((e, t) => ({
|
|
3083
3152
|
range: e,
|
|
3084
3153
|
role: "declaration",
|
|
3085
3154
|
index: t
|
|
3086
|
-
})), ...
|
|
3155
|
+
})), ...F.references.map((e, t) => ({
|
|
3087
3156
|
range: e,
|
|
3088
3157
|
role: "reference",
|
|
3089
3158
|
index: t
|
|
3090
3159
|
}))] : [];
|
|
3091
3160
|
return /* @__PURE__ */ m("section", {
|
|
3092
3161
|
className: "source-authoring",
|
|
3093
|
-
"aria-label":
|
|
3094
|
-
ref:
|
|
3162
|
+
"aria-label": _.region,
|
|
3163
|
+
ref: ie,
|
|
3095
3164
|
children: [
|
|
3096
3165
|
/* @__PURE__ */ m("div", {
|
|
3097
3166
|
className: "authoring-bar",
|
|
3098
3167
|
children: [/* @__PURE__ */ p("span", {
|
|
3099
3168
|
className: "authoring-title",
|
|
3100
|
-
children:
|
|
3169
|
+
children: _.title
|
|
3101
3170
|
}), /* @__PURE__ */ m("div", {
|
|
3102
3171
|
className: "authoring-actions",
|
|
3103
3172
|
children: [/* @__PURE__ */ p("button", {
|
|
3104
3173
|
type: "button",
|
|
3105
3174
|
className: "authoring-button",
|
|
3106
3175
|
"data-authoring-action": "format",
|
|
3107
|
-
title:
|
|
3176
|
+
title: _.formatTitle,
|
|
3108
3177
|
disabled: f,
|
|
3109
|
-
onMouseDown:
|
|
3110
|
-
onClick:
|
|
3111
|
-
children:
|
|
3178
|
+
onMouseDown: wt,
|
|
3179
|
+
onClick: H,
|
|
3180
|
+
children: _.format
|
|
3112
3181
|
}), /* @__PURE__ */ p("button", {
|
|
3113
3182
|
type: "button",
|
|
3114
3183
|
className: "authoring-button",
|
|
3115
3184
|
"data-authoring-action": "suggest",
|
|
3116
|
-
title:
|
|
3185
|
+
title: _.suggestionsTitle,
|
|
3117
3186
|
"aria-expanded": O,
|
|
3118
|
-
"aria-controls":
|
|
3187
|
+
"aria-controls": re,
|
|
3119
3188
|
disabled: f,
|
|
3120
|
-
onMouseDown:
|
|
3189
|
+
onMouseDown: wt,
|
|
3121
3190
|
onClick: B,
|
|
3122
|
-
children:
|
|
3191
|
+
children: _.suggestions
|
|
3123
3192
|
})]
|
|
3124
3193
|
})]
|
|
3125
3194
|
}),
|
|
3126
3195
|
O ? /* @__PURE__ */ m("div", {
|
|
3127
3196
|
className: "authoring-completion",
|
|
3128
|
-
"aria-label":
|
|
3197
|
+
"aria-label": _.completionLabel,
|
|
3129
3198
|
children: [
|
|
3130
3199
|
/* @__PURE__ */ m("div", {
|
|
3131
3200
|
className: "authoring-completion-head",
|
|
3132
|
-
children: [/* @__PURE__ */ p("span", { children:
|
|
3201
|
+
children: [/* @__PURE__ */ p("span", { children: _.completionLabel }), /* @__PURE__ */ p("span", {
|
|
3133
3202
|
className: "authoring-completion-count",
|
|
3134
|
-
children:
|
|
3203
|
+
children: _.completionCount(A.length)
|
|
3135
3204
|
})]
|
|
3136
3205
|
}),
|
|
3137
3206
|
/* @__PURE__ */ p("div", {
|
|
3138
|
-
id:
|
|
3207
|
+
id: re,
|
|
3139
3208
|
className: "authoring-completion-list",
|
|
3140
3209
|
role: "listbox",
|
|
3141
|
-
"aria-label":
|
|
3210
|
+
"aria-label": _.completionLabel,
|
|
3142
3211
|
ref: ae,
|
|
3143
3212
|
children: A.length === 0 ? /* @__PURE__ */ p("p", {
|
|
3144
3213
|
className: "authoring-empty",
|
|
3145
|
-
children:
|
|
3214
|
+
children: _.completionEmpty
|
|
3146
3215
|
}) : A.map((e, t) => /* @__PURE__ */ m("button", {
|
|
3147
3216
|
type: "button",
|
|
3148
3217
|
role: "option",
|
|
3149
3218
|
"data-completion-index": t,
|
|
3150
3219
|
"aria-selected": t === j,
|
|
3151
3220
|
className: `authoring-completion-item${t === j ? " is-active" : ""}`,
|
|
3152
|
-
onMouseDown:
|
|
3221
|
+
onMouseDown: wt,
|
|
3153
3222
|
onMouseEnter: () => M(t),
|
|
3154
|
-
onClick: () =>
|
|
3223
|
+
onClick: () => V(e),
|
|
3155
3224
|
children: [
|
|
3156
3225
|
/* @__PURE__ */ p("span", {
|
|
3157
3226
|
className: `authoring-kind is-${e.kind}`,
|
|
3158
|
-
children:
|
|
3227
|
+
children: _.kinds[e.kind] ?? e.kind
|
|
3159
3228
|
}),
|
|
3160
3229
|
/* @__PURE__ */ p("span", {
|
|
3161
3230
|
className: "authoring-completion-label",
|
|
@@ -3171,7 +3240,7 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3171
3240
|
/* @__PURE__ */ p("p", {
|
|
3172
3241
|
className: "reactive-md-editor-sr-only",
|
|
3173
3242
|
"aria-live": "polite",
|
|
3174
|
-
children:
|
|
3243
|
+
children: W ? `${_.kinds[W.kind] ?? W.kind} ${W.label}` : ""
|
|
3175
3244
|
})
|
|
3176
3245
|
]
|
|
3177
3246
|
}) : null,
|
|
@@ -3180,46 +3249,46 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3180
3249
|
children: [
|
|
3181
3250
|
/* @__PURE__ */ m("p", {
|
|
3182
3251
|
className: "authoring-caret",
|
|
3183
|
-
"data-binding-caret":
|
|
3252
|
+
"data-binding-caret": P?.binding.name ?? "",
|
|
3184
3253
|
children: [/* @__PURE__ */ p("span", {
|
|
3185
3254
|
className: "authoring-label",
|
|
3186
|
-
children:
|
|
3187
|
-
}),
|
|
3255
|
+
children: _.caretLabel
|
|
3256
|
+
}), P ? /* @__PURE__ */ m("span", {
|
|
3188
3257
|
className: "authoring-caret-value",
|
|
3189
3258
|
children: [
|
|
3190
|
-
/* @__PURE__ */ p("strong", { children:
|
|
3259
|
+
/* @__PURE__ */ p("strong", { children: P.binding.name }),
|
|
3191
3260
|
/* @__PURE__ */ m("span", {
|
|
3192
3261
|
className: "authoring-type",
|
|
3193
3262
|
children: [
|
|
3194
|
-
|
|
3263
|
+
_.typeLabel,
|
|
3195
3264
|
": ",
|
|
3196
|
-
|
|
3265
|
+
R
|
|
3197
3266
|
]
|
|
3198
3267
|
}),
|
|
3199
|
-
/* @__PURE__ */ p("span", { children:
|
|
3200
|
-
/* @__PURE__ */ p("span", { children:
|
|
3268
|
+
/* @__PURE__ */ p("span", { children: _.declarationCount(P.binding.declarations.length) }),
|
|
3269
|
+
/* @__PURE__ */ p("span", { children: _.referenceCount(P.binding.references.length) })
|
|
3201
3270
|
]
|
|
3202
3271
|
}) : /* @__PURE__ */ p("span", {
|
|
3203
3272
|
className: "authoring-muted",
|
|
3204
|
-
children:
|
|
3273
|
+
children: _.noBindingAtCaret
|
|
3205
3274
|
})]
|
|
3206
3275
|
}),
|
|
3207
3276
|
/* @__PURE__ */ m("div", {
|
|
3208
3277
|
className: "authoring-row",
|
|
3209
3278
|
children: [/* @__PURE__ */ p("span", {
|
|
3210
3279
|
className: "authoring-label",
|
|
3211
|
-
children:
|
|
3280
|
+
children: _.bindingsLabel
|
|
3212
3281
|
}), /* @__PURE__ */ p("div", {
|
|
3213
3282
|
className: "authoring-binding-list",
|
|
3214
3283
|
children: t.bindings.length === 0 ? /* @__PURE__ */ p("span", {
|
|
3215
3284
|
className: "authoring-muted",
|
|
3216
|
-
children:
|
|
3285
|
+
children: _.noBindings
|
|
3217
3286
|
}) : t.bindings.map((e) => /* @__PURE__ */ m("button", {
|
|
3218
3287
|
type: "button",
|
|
3219
3288
|
"data-binding-name": e.name,
|
|
3220
3289
|
className: "authoring-binding-chip",
|
|
3221
|
-
"aria-pressed": e.name ===
|
|
3222
|
-
title: `${
|
|
3290
|
+
"aria-pressed": e.name === F?.name,
|
|
3291
|
+
title: `${_.declarationCount(e.declarations.length)} · ${_.referenceCount(e.references.length)}`,
|
|
3223
3292
|
onClick: () => {
|
|
3224
3293
|
x(e.name), D(null);
|
|
3225
3294
|
},
|
|
@@ -3234,38 +3303,38 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3234
3303
|
}, e.name))
|
|
3235
3304
|
})]
|
|
3236
3305
|
}),
|
|
3237
|
-
|
|
3306
|
+
F ? /* @__PURE__ */ m("div", {
|
|
3238
3307
|
className: "authoring-row",
|
|
3239
3308
|
children: [/* @__PURE__ */ m("span", {
|
|
3240
3309
|
className: "authoring-label",
|
|
3241
3310
|
children: [
|
|
3242
|
-
|
|
3311
|
+
F.name,
|
|
3243
3312
|
" · ",
|
|
3244
|
-
|
|
3313
|
+
_.typeLabel,
|
|
3245
3314
|
": ",
|
|
3246
3315
|
z
|
|
3247
3316
|
]
|
|
3248
3317
|
}), /* @__PURE__ */ p("div", {
|
|
3249
3318
|
className: "authoring-locations",
|
|
3250
|
-
children:
|
|
3251
|
-
let i =
|
|
3319
|
+
children: ue.map(({ range: t, role: n, index: r }) => {
|
|
3320
|
+
let i = Et(e, t.start);
|
|
3252
3321
|
return /* @__PURE__ */ m("button", {
|
|
3253
3322
|
type: "button",
|
|
3254
3323
|
className: `authoring-location is-${n}`,
|
|
3255
3324
|
"data-binding-location": n,
|
|
3256
3325
|
"data-start": t.start,
|
|
3257
3326
|
"data-end": t.end,
|
|
3258
|
-
title:
|
|
3327
|
+
title: _.locateTitle,
|
|
3259
3328
|
onClick: () => {
|
|
3260
|
-
x(
|
|
3329
|
+
x(F.name), c(t);
|
|
3261
3330
|
},
|
|
3262
3331
|
children: [/* @__PURE__ */ m("span", { children: [
|
|
3263
|
-
n === "declaration" ?
|
|
3332
|
+
n === "declaration" ? _.declaration : _.reference,
|
|
3264
3333
|
" ",
|
|
3265
3334
|
r + 1
|
|
3266
3335
|
] }), /* @__PURE__ */ p("span", {
|
|
3267
3336
|
className: "authoring-location-position",
|
|
3268
|
-
children:
|
|
3337
|
+
children: _.position(i.line, i.column)
|
|
3269
3338
|
})]
|
|
3270
3339
|
}, `${n}-${t.start}-${t.end}`);
|
|
3271
3340
|
})
|
|
@@ -3276,36 +3345,36 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3276
3345
|
children: [
|
|
3277
3346
|
/* @__PURE__ */ p("label", {
|
|
3278
3347
|
className: "authoring-label",
|
|
3279
|
-
htmlFor:
|
|
3280
|
-
children:
|
|
3348
|
+
htmlFor: ne,
|
|
3349
|
+
children: _.renameLabel
|
|
3281
3350
|
}),
|
|
3282
3351
|
/* @__PURE__ */ m("div", {
|
|
3283
3352
|
className: "authoring-rename-row",
|
|
3284
3353
|
children: [/* @__PURE__ */ p("input", {
|
|
3285
|
-
id:
|
|
3354
|
+
id: ne,
|
|
3286
3355
|
type: "text",
|
|
3287
3356
|
className: "authoring-rename-input",
|
|
3288
3357
|
"data-authoring-action": "rename-input",
|
|
3289
3358
|
value: S,
|
|
3290
|
-
placeholder:
|
|
3359
|
+
placeholder: _.renamePlaceholder,
|
|
3291
3360
|
autoComplete: "off",
|
|
3292
3361
|
spellCheck: !1,
|
|
3293
|
-
disabled: f || !
|
|
3362
|
+
disabled: f || !F,
|
|
3294
3363
|
onChange: (e) => {
|
|
3295
3364
|
C(e.target.value), T(null);
|
|
3296
3365
|
},
|
|
3297
3366
|
onKeyDown: (e) => {
|
|
3298
|
-
e.key === "Enter" &&
|
|
3367
|
+
e.key === "Enter" && Tt(e.nativeEvent) && e.preventDefault();
|
|
3299
3368
|
}
|
|
3300
3369
|
}), /* @__PURE__ */ p("button", {
|
|
3301
3370
|
type: "button",
|
|
3302
3371
|
className: "authoring-button authoring-primary",
|
|
3303
3372
|
"data-authoring-action": "rename",
|
|
3304
|
-
disabled: f || !
|
|
3305
|
-
onMouseDown:
|
|
3306
|
-
onClick:
|
|
3307
|
-
title:
|
|
3308
|
-
children:
|
|
3373
|
+
disabled: f || !F,
|
|
3374
|
+
onMouseDown: wt,
|
|
3375
|
+
onClick: U,
|
|
3376
|
+
title: _.renameTitle,
|
|
3377
|
+
children: _.renameAction
|
|
3309
3378
|
})]
|
|
3310
3379
|
}),
|
|
3311
3380
|
w ? /* @__PURE__ */ p("p", {
|
|
@@ -3315,7 +3384,7 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3315
3384
|
}) : null,
|
|
3316
3385
|
/* @__PURE__ */ p("p", {
|
|
3317
3386
|
className: "authoring-hint",
|
|
3318
|
-
children:
|
|
3387
|
+
children: _.renameHint
|
|
3319
3388
|
})
|
|
3320
3389
|
]
|
|
3321
3390
|
}),
|
|
@@ -3331,10 +3400,10 @@ function Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit:
|
|
|
3331
3400
|
});
|
|
3332
3401
|
}
|
|
3333
3402
|
// src/editor/use-gutter-metrics.ts
|
|
3334
|
-
function
|
|
3403
|
+
function Ot(e, t) {
|
|
3335
3404
|
return e.length === t.length && e.every((e, n) => Math.abs(e - t[n]) < .01);
|
|
3336
3405
|
}
|
|
3337
|
-
function
|
|
3406
|
+
function kt(e, t, n) {
|
|
3338
3407
|
let [r, i] = d(0), [o, s] = d([]), [l, u] = d(0);
|
|
3339
3408
|
return c(() => {
|
|
3340
3409
|
let e = n.current;
|
|
@@ -3356,7 +3425,7 @@ function Ot(e, t, n) {
|
|
|
3356
3425
|
let i = Array.from(n.children);
|
|
3357
3426
|
if (i.length !== e.length) return;
|
|
3358
3427
|
let a = Number.parseFloat(window.getComputedStyle(n).lineHeight) || 22, o = i.map((e) => e.getBoundingClientRect().height || a);
|
|
3359
|
-
s((e) =>
|
|
3428
|
+
s((e) => Ot(e, o) ? e : o);
|
|
3360
3429
|
}, [
|
|
3361
3430
|
e,
|
|
3362
3431
|
r,
|
|
@@ -3368,11 +3437,11 @@ function Ot(e, t, n) {
|
|
|
3368
3437
|
};
|
|
3369
3438
|
}
|
|
3370
3439
|
// src/editor/use-source-history.ts
|
|
3371
|
-
var
|
|
3440
|
+
var At = 700, jt = 120, Mt = {
|
|
3372
3441
|
start: 0,
|
|
3373
3442
|
end: 0
|
|
3374
3443
|
};
|
|
3375
|
-
function
|
|
3444
|
+
function Nt(e, t = Mt, n = Date.now) {
|
|
3376
3445
|
let r = [{
|
|
3377
3446
|
value: e,
|
|
3378
3447
|
selection: t
|
|
@@ -3388,17 +3457,17 @@ function Mt(e, t = jt, n = Date.now) {
|
|
|
3388
3457
|
let c = r[i];
|
|
3389
3458
|
if (e === c.value && t.start === c.selection.start && t.end === c.selection.end) return;
|
|
3390
3459
|
let l = n();
|
|
3391
|
-
s === "merge" && o && i > 0 && i === r.length - 1 && l - a <
|
|
3460
|
+
s === "merge" && o && i > 0 && i === r.length - 1 && l - a < At ? r[i] = {
|
|
3392
3461
|
value: e,
|
|
3393
3462
|
selection: t
|
|
3394
3463
|
} : (r = r.slice(0, i + 1), r.push({
|
|
3395
3464
|
value: e,
|
|
3396
3465
|
selection: t
|
|
3397
|
-
}), r.length >
|
|
3466
|
+
}), r.length > jt && r.shift(), i = r.length - 1), a = l, o = s === "merge";
|
|
3398
3467
|
},
|
|
3399
3468
|
undo: () => i <= 0 ? null : (--i, a = 0, o = !1, r[i]),
|
|
3400
3469
|
redo: () => i >= r.length - 1 ? null : (i += 1, a = 0, o = !1, r[i]),
|
|
3401
|
-
reset: (e, t =
|
|
3470
|
+
reset: (e, t = Mt) => {
|
|
3402
3471
|
r = [{
|
|
3403
3472
|
value: e,
|
|
3404
3473
|
selection: t
|
|
@@ -3406,9 +3475,9 @@ function Mt(e, t = jt, n = Date.now) {
|
|
|
3406
3475
|
}
|
|
3407
3476
|
};
|
|
3408
3477
|
}
|
|
3409
|
-
function
|
|
3478
|
+
function Pt(e, t = Mt) {
|
|
3410
3479
|
let n = u(null);
|
|
3411
|
-
n.current ||=
|
|
3480
|
+
n.current ||= Nt(e, t);
|
|
3412
3481
|
let [, i] = d(0), a = r(() => i((e) => e + 1), []), o = r((e, t, r) => {
|
|
3413
3482
|
n.current.record(e, t, r), a();
|
|
3414
3483
|
}, [a]), s = r(() => {
|
|
@@ -3433,10 +3502,10 @@ function Nt(e, t = jt) {
|
|
|
3433
3502
|
function $(e, t) {
|
|
3434
3503
|
return Number.isFinite(e) ? Math.min(Math.max(Math.trunc(e), 0), t) : 0;
|
|
3435
3504
|
}
|
|
3436
|
-
function
|
|
3505
|
+
function Ft(e) {
|
|
3437
3506
|
return typeof e == "number" ? `${e}px` : e;
|
|
3438
3507
|
}
|
|
3439
|
-
function
|
|
3508
|
+
function It(e, t) {
|
|
3440
3509
|
let n = $(t.start, e.length), r = $(t.end, e.length);
|
|
3441
3510
|
return n <= r ? {
|
|
3442
3511
|
start: n,
|
|
@@ -3446,88 +3515,99 @@ function Ft(e, t) {
|
|
|
3446
3515
|
end: n
|
|
3447
3516
|
};
|
|
3448
3517
|
}
|
|
3449
|
-
function
|
|
3518
|
+
function Lt(e, t) {
|
|
3450
3519
|
e && (e.current = t);
|
|
3451
3520
|
}
|
|
3452
|
-
var
|
|
3453
|
-
let
|
|
3521
|
+
var Rt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto", preview: a, viewMode: f, defaultViewMode: ee = "edit", onViewModeChange: te, id: h, className: g, style: _, height: ne = 560, minHeight: ie = 280, placeholder: ae, ariaLabel: v, readOnly: y = !1, disabled: oe = !1, documentKey: x, diagnostics: S, document: C = null, toolbar: w = !0, authoring: T = !0, onExport: E, textareaRef: D }, O) {
|
|
3522
|
+
let k = o(), A = h ?? `reactive-md-editor-${k.replace(/:/g, "")}`, se = re[n], j = u(null), [M, N] = d(!1);
|
|
3523
|
+
c(() => {
|
|
3524
|
+
let e = j.current;
|
|
3525
|
+
if (!e) return;
|
|
3526
|
+
let t = () => N(e.clientWidth <= 600);
|
|
3527
|
+
if (t(), typeof ResizeObserver > "u") return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
3528
|
+
let n = new ResizeObserver(t);
|
|
3529
|
+
return n.observe(e), () => n.disconnect();
|
|
3530
|
+
}, []);
|
|
3531
|
+
let [ce, le] = d(ee), P = a != null, F = P ? f ?? ce : "edit", I = M && F === "split" ? "edit" : F, L = (e) => {
|
|
3532
|
+
f === void 0 && le(e), te?.(e);
|
|
3533
|
+
}, R = u(null), z = u(null), B = u(null), V = u({
|
|
3454
3534
|
start: 0,
|
|
3455
3535
|
end: 0
|
|
3456
|
-
}),
|
|
3457
|
-
|
|
3458
|
-
let
|
|
3459
|
-
|
|
3460
|
-
let [
|
|
3461
|
-
|
|
3536
|
+
}), H = u(null), U = u(e), W = u(x), ue = u(!1), G = u(!1), fe = u(e);
|
|
3537
|
+
fe.current = e;
|
|
3538
|
+
let K = y || oe, pe = u(K);
|
|
3539
|
+
pe.current = K;
|
|
3540
|
+
let [me, he] = d(!1), [ge, _e] = d(1), { canUndo: ve, canRedo: ye, record: q, undo: be, redo: xe, reset: J } = Pt(e), Se = r(() => {
|
|
3541
|
+
V.current = {
|
|
3462
3542
|
start: 0,
|
|
3463
3543
|
end: 0
|
|
3464
3544
|
};
|
|
3465
|
-
let e =
|
|
3466
|
-
e && (e.setSelectionRange(0, 0), e.scrollTop = 0, e.scrollLeft = 0),
|
|
3545
|
+
let e = R.current;
|
|
3546
|
+
e && (e.setSelectionRange(0, 0), e.scrollTop = 0, e.scrollLeft = 0), z.current && (z.current.scrollTop = 0), _e(1);
|
|
3467
3547
|
}, []);
|
|
3468
3548
|
c(() => {
|
|
3469
|
-
e !==
|
|
3549
|
+
e !== U.current && (U.current = e, H.current = null, J(e), Se());
|
|
3470
3550
|
}, [
|
|
3471
3551
|
e,
|
|
3472
|
-
|
|
3473
|
-
|
|
3552
|
+
J,
|
|
3553
|
+
Se
|
|
3474
3554
|
]), c(() => {
|
|
3475
|
-
|
|
3555
|
+
W.current !== x && (W.current = x, U.current = e, H.current = null, J(e), Se());
|
|
3476
3556
|
}, [
|
|
3477
|
-
|
|
3557
|
+
x,
|
|
3478
3558
|
e,
|
|
3479
|
-
|
|
3480
|
-
|
|
3559
|
+
J,
|
|
3560
|
+
Se
|
|
3481
3561
|
]);
|
|
3482
|
-
let
|
|
3562
|
+
let Ce = ft(e, T), we = l(() => e.split("\n"), [e]), Te = kt(we, B, R), Ee = l(() => {
|
|
3483
3563
|
let e = /* @__PURE__ */ new Set();
|
|
3484
|
-
for (let t of
|
|
3564
|
+
for (let t of S ?? []) Number.isInteger(t.line) && t.line > 0 && e.add(t.line);
|
|
3485
3565
|
return e;
|
|
3486
|
-
}, [
|
|
3566
|
+
}, [S]), De = r((e) => {
|
|
3487
3567
|
let t = e.value.length, n = $(e.selectionStart, t), r = $(e.selectionEnd, t);
|
|
3488
|
-
|
|
3568
|
+
V.current = {
|
|
3489
3569
|
start: n,
|
|
3490
3570
|
end: r
|
|
3491
|
-
},
|
|
3492
|
-
}, []),
|
|
3493
|
-
let r = e !==
|
|
3494
|
-
|
|
3495
|
-
}, [t]),
|
|
3496
|
-
|
|
3497
|
-
}, [
|
|
3498
|
-
if (
|
|
3499
|
-
let e =
|
|
3500
|
-
e &&
|
|
3501
|
-
}, [
|
|
3502
|
-
if (
|
|
3503
|
-
let e =
|
|
3504
|
-
e &&
|
|
3505
|
-
}, [
|
|
3571
|
+
}, _e(e.value.slice(0, n).split("\n").length);
|
|
3572
|
+
}, []), Y = r((e, n) => {
|
|
3573
|
+
let r = e !== fe.current;
|
|
3574
|
+
fe.current = e, U.current = e, n && r && (H.current = n), t(e);
|
|
3575
|
+
}, [t]), Oe = r((e) => {
|
|
3576
|
+
pe.current || (q(e.value, e.selection, "separate"), Y(e.value, e.selection));
|
|
3577
|
+
}, [Y, q]), ke = r(() => {
|
|
3578
|
+
if (pe.current) return;
|
|
3579
|
+
let e = be();
|
|
3580
|
+
e && Y(e.value, e.selection);
|
|
3581
|
+
}, [Y, be]), Ae = r(() => {
|
|
3582
|
+
if (pe.current) return;
|
|
3583
|
+
let e = xe();
|
|
3584
|
+
e && Y(e.value, e.selection);
|
|
3585
|
+
}, [Y, xe]);
|
|
3506
3586
|
c(() => {
|
|
3507
|
-
let t =
|
|
3587
|
+
let t = H.current;
|
|
3508
3588
|
if (!t) return;
|
|
3509
|
-
if (e !==
|
|
3510
|
-
|
|
3589
|
+
if (e !== U.current) {
|
|
3590
|
+
H.current = null;
|
|
3511
3591
|
return;
|
|
3512
3592
|
}
|
|
3513
|
-
|
|
3514
|
-
let n =
|
|
3593
|
+
H.current = null;
|
|
3594
|
+
let n = R.current;
|
|
3515
3595
|
if (!n) return;
|
|
3516
|
-
let r =
|
|
3517
|
-
n.setSelectionRange(r.start, r.end), n.focus({ preventScroll: !0 }),
|
|
3596
|
+
let r = It(n.value, t);
|
|
3597
|
+
n.setSelectionRange(r.start, r.end), n.focus({ preventScroll: !0 }), V.current = r, _e(n.value.slice(0, r.start).split("\n").length);
|
|
3518
3598
|
}, [e]);
|
|
3519
|
-
let
|
|
3520
|
-
let t =
|
|
3599
|
+
let je = r((e) => {
|
|
3600
|
+
let t = R.current;
|
|
3521
3601
|
if (t && (t.focus({ preventScroll: !0 }), e)) {
|
|
3522
|
-
let n =
|
|
3523
|
-
t.setSelectionRange(n.start, n.end),
|
|
3602
|
+
let n = It(t.value, e);
|
|
3603
|
+
t.setSelectionRange(n.start, n.end), V.current = n, _e(t.value.slice(0, n.start).split("\n").length);
|
|
3524
3604
|
}
|
|
3525
|
-
}, []),
|
|
3526
|
-
let t =
|
|
3605
|
+
}, []), Me = r((e) => {
|
|
3606
|
+
let t = R.current;
|
|
3527
3607
|
if (!t) return;
|
|
3528
|
-
let n =
|
|
3529
|
-
|
|
3530
|
-
let r = t.value.slice(0, n.start).split("\n").length, i =
|
|
3608
|
+
let n = It(t.value, e);
|
|
3609
|
+
je(n);
|
|
3610
|
+
let r = t.value.slice(0, n.start).split("\n").length, i = z.current, a = i?.children[r - 1];
|
|
3531
3611
|
if (i && a) {
|
|
3532
3612
|
let e = a.getBoundingClientRect().top - i.getBoundingClientRect().top + i.scrollTop;
|
|
3533
3613
|
t.scrollTop = Math.max(0, e - t.clientHeight / 3);
|
|
@@ -3536,17 +3616,17 @@ var Lt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto"
|
|
|
3536
3616
|
t.scrollTop = Math.max(0, (r - 1) * n - t.clientHeight / 3);
|
|
3537
3617
|
}
|
|
3538
3618
|
i && (i.scrollTop = t.scrollTop);
|
|
3539
|
-
}, [
|
|
3540
|
-
s(
|
|
3619
|
+
}, [je]);
|
|
3620
|
+
s(O, () => ({
|
|
3541
3621
|
focus(e) {
|
|
3542
|
-
|
|
3622
|
+
je(e);
|
|
3543
3623
|
},
|
|
3544
3624
|
selectRange(e) {
|
|
3545
|
-
|
|
3625
|
+
je(e);
|
|
3546
3626
|
},
|
|
3547
3627
|
getSelection() {
|
|
3548
|
-
let e =
|
|
3549
|
-
if (!e) return
|
|
3628
|
+
let e = R.current;
|
|
3629
|
+
if (!e) return V.current;
|
|
3550
3630
|
let t = e.value.length;
|
|
3551
3631
|
return {
|
|
3552
3632
|
start: $(e.selectionStart, t),
|
|
@@ -3554,157 +3634,201 @@ var Lt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto"
|
|
|
3554
3634
|
};
|
|
3555
3635
|
},
|
|
3556
3636
|
getTextarea() {
|
|
3557
|
-
return
|
|
3637
|
+
return R.current;
|
|
3558
3638
|
},
|
|
3559
|
-
undo:
|
|
3560
|
-
redo:
|
|
3639
|
+
undo: ke,
|
|
3640
|
+
redo: Ae
|
|
3561
3641
|
}), [
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3642
|
+
je,
|
|
3643
|
+
ke,
|
|
3644
|
+
Ae
|
|
3565
3645
|
]);
|
|
3566
|
-
let
|
|
3567
|
-
|
|
3568
|
-
}, [
|
|
3569
|
-
if (
|
|
3646
|
+
let Ne = r((e) => {
|
|
3647
|
+
R.current = e, Lt(D, e);
|
|
3648
|
+
}, [D]), Pe = (e) => {
|
|
3649
|
+
if (pe.current) return;
|
|
3570
3650
|
let t = e.currentTarget, n = {
|
|
3571
3651
|
start: $(t.selectionStart, t.value.length),
|
|
3572
3652
|
end: $(t.selectionEnd, t.value.length)
|
|
3573
3653
|
};
|
|
3574
|
-
|
|
3575
|
-
},
|
|
3576
|
-
if (
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3654
|
+
q(t.value, n, "merge"), Y(t.value);
|
|
3655
|
+
}, Fe = (e) => {
|
|
3656
|
+
if (ue.current || e.nativeEvent.isComposing) return;
|
|
3657
|
+
if (e.key === "Escape") {
|
|
3658
|
+
G.current = w;
|
|
3659
|
+
return;
|
|
3660
|
+
}
|
|
3661
|
+
let t = G.current && e.key === "Tab" && !e.shiftKey;
|
|
3662
|
+
if (G.current = !1, t) {
|
|
3663
|
+
let t = R.current?.closest(".reactive-md-editor")?.querySelector(".editor-toolbar [tabindex=\"0\"]:not(:disabled)");
|
|
3664
|
+
if (t) {
|
|
3665
|
+
e.preventDefault(), t.focus({ preventScroll: !0 });
|
|
3666
|
+
return;
|
|
3667
|
+
}
|
|
3668
|
+
}
|
|
3669
|
+
if (pe.current) return;
|
|
3670
|
+
let n = e.metaKey || e.ctrlKey, r = e.key.toLowerCase();
|
|
3671
|
+
if (n && !e.altKey && r === "z") {
|
|
3672
|
+
e.preventDefault(), e.shiftKey ? Ae() : ke();
|
|
3580
3673
|
return;
|
|
3581
3674
|
}
|
|
3582
|
-
if (
|
|
3583
|
-
e.preventDefault(),
|
|
3675
|
+
if (n && !e.altKey && r === "y") {
|
|
3676
|
+
e.preventDefault(), Ae();
|
|
3584
3677
|
return;
|
|
3585
3678
|
}
|
|
3586
3679
|
if (e.key !== "Tab" || e.shiftKey) return;
|
|
3587
3680
|
e.preventDefault();
|
|
3588
|
-
let
|
|
3589
|
-
if (
|
|
3590
|
-
|
|
3591
|
-
start:
|
|
3592
|
-
end:
|
|
3681
|
+
let i = e.currentTarget, a = $(i.selectionStart, i.value.length), o = $(i.selectionEnd, i.value.length);
|
|
3682
|
+
if (a !== o) {
|
|
3683
|
+
Oe(de(i.value, {
|
|
3684
|
+
start: a,
|
|
3685
|
+
end: o
|
|
3593
3686
|
}));
|
|
3594
3687
|
return;
|
|
3595
3688
|
}
|
|
3596
|
-
let
|
|
3597
|
-
start:
|
|
3598
|
-
end:
|
|
3689
|
+
let s = `${i.value.slice(0, a)} ${i.value.slice(o)}`, c = {
|
|
3690
|
+
start: a + 2,
|
|
3691
|
+
end: a + 2
|
|
3599
3692
|
};
|
|
3600
|
-
|
|
3601
|
-
},
|
|
3602
|
-
|
|
3603
|
-
},
|
|
3604
|
-
|
|
3605
|
-
},
|
|
3606
|
-
|
|
3607
|
-
},
|
|
3693
|
+
q(s, c, "separate"), Y(s, c);
|
|
3694
|
+
}, Ie = () => {
|
|
3695
|
+
G.current = !1, ue.current = !0, he(!0);
|
|
3696
|
+
}, Le = (e) => {
|
|
3697
|
+
ue.current = !1, he(!1), De(e.currentTarget);
|
|
3698
|
+
}, Re = (e) => {
|
|
3699
|
+
z.current && (z.current.scrollTop = e.currentTarget.scrollTop);
|
|
3700
|
+
}, ze = w, Be = `reactive-md-editor${g ? ` ${g}` : ""}`;
|
|
3608
3701
|
return /* @__PURE__ */ p(b, {
|
|
3609
3702
|
locale: n,
|
|
3610
3703
|
children: /* @__PURE__ */ m("div", {
|
|
3611
|
-
className:
|
|
3704
|
+
className: Be,
|
|
3612
3705
|
"data-editor-theme": i,
|
|
3613
3706
|
lang: n === "zh" ? "zh-CN" : "en",
|
|
3614
|
-
style:
|
|
3707
|
+
style: _,
|
|
3615
3708
|
role: "group",
|
|
3616
|
-
"aria-label":
|
|
3617
|
-
"aria-disabled":
|
|
3618
|
-
inert:
|
|
3709
|
+
"aria-label": se.region,
|
|
3710
|
+
"aria-disabled": K || void 0,
|
|
3711
|
+
inert: oe || void 0,
|
|
3619
3712
|
children: [/* @__PURE__ */ m("div", {
|
|
3620
3713
|
className: "editor-frame",
|
|
3714
|
+
ref: j,
|
|
3715
|
+
"data-editor-view": I,
|
|
3621
3716
|
style: {
|
|
3622
|
-
height:
|
|
3623
|
-
minHeight:
|
|
3717
|
+
height: Ft(ne),
|
|
3718
|
+
minHeight: Ft(ie)
|
|
3624
3719
|
},
|
|
3625
3720
|
children: [
|
|
3626
|
-
|
|
3627
|
-
editorRef:
|
|
3628
|
-
onEdit:
|
|
3629
|
-
onUndo:
|
|
3630
|
-
onRedo:
|
|
3631
|
-
canUndo:
|
|
3632
|
-
canRedo:
|
|
3633
|
-
onExport:
|
|
3634
|
-
showExport: typeof
|
|
3635
|
-
disabled:
|
|
3721
|
+
ze ? /* @__PURE__ */ p(at, {
|
|
3722
|
+
editorRef: R,
|
|
3723
|
+
onEdit: Oe,
|
|
3724
|
+
onUndo: ke,
|
|
3725
|
+
onRedo: Ae,
|
|
3726
|
+
canUndo: ve,
|
|
3727
|
+
canRedo: ye,
|
|
3728
|
+
onExport: E,
|
|
3729
|
+
showExport: typeof E == "function",
|
|
3730
|
+
disabled: K
|
|
3636
3731
|
}) : null,
|
|
3637
3732
|
/* @__PURE__ */ p("label", {
|
|
3638
3733
|
className: "reactive-md-editor-sr-only",
|
|
3639
|
-
htmlFor:
|
|
3640
|
-
children:
|
|
3734
|
+
htmlFor: A,
|
|
3735
|
+
children: se.sourceLabel
|
|
3641
3736
|
}),
|
|
3642
3737
|
/* @__PURE__ */ m("div", {
|
|
3643
|
-
className:
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3738
|
+
className: "editor-workspace",
|
|
3739
|
+
"data-view": I,
|
|
3740
|
+
children: [/* @__PURE__ */ m("div", {
|
|
3741
|
+
id: `${A}-source`,
|
|
3742
|
+
hidden: I === "preview",
|
|
3743
|
+
className: `editor-shell${me ? " is-composing" : ""}`,
|
|
3744
|
+
children: [
|
|
3745
|
+
/* @__PURE__ */ p("div", {
|
|
3746
|
+
className: "editor-gutter",
|
|
3747
|
+
ref: z,
|
|
3748
|
+
"aria-hidden": "true",
|
|
3749
|
+
children: we.map((e, t) => {
|
|
3750
|
+
let n = t + 1;
|
|
3751
|
+
return /* @__PURE__ */ p("span", {
|
|
3752
|
+
className: `gutter-line ${ge === n ? "is-active" : ""} ${Ee.has(n) ? "is-diagnostic" : ""}`,
|
|
3753
|
+
style: Te.heights[t] ? { height: `${Te.heights[t]}px` } : void 0,
|
|
3754
|
+
children: n
|
|
3755
|
+
}, n);
|
|
3756
|
+
})
|
|
3757
|
+
}),
|
|
3758
|
+
/* @__PURE__ */ m("div", {
|
|
3759
|
+
className: "editor-input-wrap",
|
|
3760
|
+
children: [/* @__PURE__ */ p(mt, {
|
|
3761
|
+
source: e,
|
|
3762
|
+
tokens: Ce.tokens,
|
|
3763
|
+
width: Te.width,
|
|
3764
|
+
editorRef: R
|
|
3765
|
+
}), /* @__PURE__ */ p("textarea", {
|
|
3766
|
+
id: A,
|
|
3767
|
+
ref: Ne,
|
|
3768
|
+
className: "editor-input",
|
|
3769
|
+
value: e,
|
|
3770
|
+
wrap: "soft",
|
|
3771
|
+
spellCheck: !1,
|
|
3772
|
+
autoCapitalize: "off",
|
|
3773
|
+
autoCorrect: "off",
|
|
3774
|
+
placeholder: ae,
|
|
3775
|
+
"aria-label": v,
|
|
3776
|
+
readOnly: y,
|
|
3777
|
+
disabled: oe,
|
|
3778
|
+
onScroll: Re,
|
|
3779
|
+
onChange: Pe,
|
|
3780
|
+
onKeyDown: Fe,
|
|
3781
|
+
onBlur: () => {
|
|
3782
|
+
G.current = !1;
|
|
3783
|
+
},
|
|
3784
|
+
onCompositionStart: Ie,
|
|
3785
|
+
onCompositionEnd: Le,
|
|
3786
|
+
onSelect: (e) => De(e.currentTarget),
|
|
3787
|
+
onKeyUp: (e) => De(e.currentTarget),
|
|
3788
|
+
onClick: (e) => De(e.currentTarget)
|
|
3789
|
+
})]
|
|
3790
|
+
}),
|
|
3791
|
+
/* @__PURE__ */ p("div", {
|
|
3792
|
+
className: "editor-mirror",
|
|
3793
|
+
ref: B,
|
|
3794
|
+
"aria-hidden": "true",
|
|
3795
|
+
style: Te.width ? { width: Te.width } : void 0,
|
|
3796
|
+
children: we.map((e, t) => /* @__PURE__ */ p("div", { children: e.replace(/\r$/, "") || "" }, t))
|
|
3656
3797
|
})
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
readOnly: re,
|
|
3677
|
-
disabled: _,
|
|
3678
|
-
onScroll: Te,
|
|
3679
|
-
onChange: xe,
|
|
3680
|
-
onKeyDown: Se,
|
|
3681
|
-
onCompositionStart: Ce,
|
|
3682
|
-
onCompositionEnd: we,
|
|
3683
|
-
onSelect: (e) => ge(e.currentTarget),
|
|
3684
|
-
onKeyUp: (e) => ge(e.currentTarget),
|
|
3685
|
-
onClick: (e) => ge(e.currentTarget)
|
|
3686
|
-
})]
|
|
3687
|
-
}),
|
|
3688
|
-
/* @__PURE__ */ p("div", {
|
|
3689
|
-
className: "editor-mirror",
|
|
3690
|
-
ref: A,
|
|
3691
|
-
"aria-hidden": "true",
|
|
3692
|
-
style: me.width ? { width: me.width } : void 0,
|
|
3693
|
-
children: G.map((e, t) => /* @__PURE__ */ p("div", { children: e.replace(/\r$/, "") || "" }, t))
|
|
3694
|
-
})
|
|
3695
|
-
]
|
|
3798
|
+
]
|
|
3799
|
+
}), P ? /* @__PURE__ */ p("div", {
|
|
3800
|
+
id: `${A}-preview`,
|
|
3801
|
+
className: "editor-preview",
|
|
3802
|
+
role: "region",
|
|
3803
|
+
"aria-label": se.previewRegion,
|
|
3804
|
+
hidden: I === "edit",
|
|
3805
|
+
children: a
|
|
3806
|
+
}) : null]
|
|
3807
|
+
}),
|
|
3808
|
+
/* @__PURE__ */ p(ot, {
|
|
3809
|
+
source: e,
|
|
3810
|
+
mode: I,
|
|
3811
|
+
onModeChange: L,
|
|
3812
|
+
sourceId: `${A}-source`,
|
|
3813
|
+
previewId: `${A}-preview`,
|
|
3814
|
+
hasPreview: P,
|
|
3815
|
+
allowSplit: !M,
|
|
3816
|
+
toolbar: w && !K
|
|
3696
3817
|
})
|
|
3697
3818
|
]
|
|
3698
|
-
}),
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3819
|
+
}), T ? /* @__PURE__ */ p("div", {
|
|
3820
|
+
hidden: I === "preview",
|
|
3821
|
+
children: /* @__PURE__ */ p(Dt, {
|
|
3822
|
+
source: e,
|
|
3823
|
+
analysis: Ce,
|
|
3824
|
+
bindingDocument: C,
|
|
3825
|
+
editorRef: R,
|
|
3826
|
+
onEdit: Oe,
|
|
3827
|
+
onLocate: Me,
|
|
3828
|
+
disabled: K
|
|
3829
|
+
})
|
|
3706
3830
|
}) : null]
|
|
3707
3831
|
})
|
|
3708
3832
|
});
|
|
3709
3833
|
});
|
|
3710
|
-
export {
|
|
3834
|
+
export { Rt as ReactiveMarkdownEditor };
|