reactive-md 0.5.0 → 0.5.1

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.
Files changed (48) hide show
  1. package/CHANGELOG-ch.md +16 -0
  2. package/CHANGELOG.md +16 -0
  3. package/README-ch.md +9 -7
  4. package/README-en.md +10 -7
  5. package/README.md +10 -7
  6. package/SECURITY-ch.md +4 -3
  7. package/SECURITY.md +4 -3
  8. package/THIRD_PARTY_NOTICES.md +45 -1
  9. package/dist-library/reactive-md-editor.css +1 -1
  10. package/dist-library/reactive-md-editor.js +739 -615
  11. package/dist-library/reactive-md-react.js +2081 -1904
  12. package/dist-library/reactive-md.js +440 -320
  13. package/dist-library/{runtime-DPuMxM_y.js → runtime-CXBdLQ3A.js} +8405 -2745
  14. package/dist-library/types/editor/editor-i18n.d.ts +7 -0
  15. package/dist-library/types/editor/editor-view-bar.d.ts +11 -0
  16. package/dist-library/types/editor/index.d.ts +1 -1
  17. package/dist-library/types/editor/types.d.ts +8 -1
  18. package/dist-library/types/local/LocalDocumentView.d.ts +10 -3
  19. package/dist-library/types/local/code-block.d.ts +3 -1
  20. package/dist-library/types/local/diagnostics.d.ts +25 -0
  21. package/dist-library/types/local/heading-anchors.d.ts +2 -0
  22. package/dist-library/types/local/html.d.ts +16 -0
  23. package/dist-library/types/local/image-view.d.ts +3 -1
  24. package/dist-library/types/local/index.d.ts +1 -1
  25. package/dist-library/types/local/options.d.ts +29 -0
  26. package/dist-library/types/local/types.d.ts +35 -1
  27. package/dist-library/types/local/worker.d.ts +18 -6
  28. package/dist-library/types/shareable.d.ts +9 -1
  29. package/dist-standalone/reactive-md-standalone.js +48 -48
  30. package/docs/compatibility-ch.md +4 -4
  31. package/docs/compatibility-en.md +4 -4
  32. package/docs/editor-ch.md +235 -216
  33. package/docs/editor-en.md +235 -216
  34. package/docs/html-compatibility-ch.md +98 -0
  35. package/docs/html-compatibility-en.md +98 -0
  36. package/docs/local-integration-ch.md +4 -1
  37. package/docs/local-integration-en.md +4 -1
  38. package/docs/local-interaction-syntax-ch.md +3 -1
  39. package/docs/local-interaction-syntax-en.md +1 -1
  40. package/docs/release-0.5.1-ch.md +39 -0
  41. package/docs/release-0.5.1-en.md +39 -0
  42. package/docs/releasing-ch.md +7 -7
  43. package/docs/releasing-en.md +8 -8
  44. package/docs/shareable-export-ch.md +2 -0
  45. package/docs/shareable-export-en.md +2 -0
  46. package/examples/local/README.md +2 -0
  47. package/examples/local/html-compat.reactive.md +24 -0
  48. 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 ne } from "reactive-md";
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 g = [
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
- ], re = {
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
- }, ie = {
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
- ...re,
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 _[e] ?? _.en;
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 P(e, t) {
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 ce(e, t, n = "en") {
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 = P(e, r);
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 F = /^(#{1,6})[ \t]+/;
903
- function I(e, t, n) {
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 = F.exec(t.text), r = e ? e[0].length : 0;
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 L = /^([ \t]*)([-*+] )/, R = /^([ \t]*)(\d+[.)] )/, le = /^([ \t]*)([-*+] \[[ xX]\] )/, z = /^([ \t]*)(> ?)/;
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 ue(e) {
938
+ function V(e) {
925
939
  let t = /^[ \t]*/.exec(e);
926
940
  return t ? t[0] : "";
927
941
  }
928
- function V(e, t, n, r) {
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 : ue(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);
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 V(e, t, (e) => B(e, le), () => "- [ ] ");
963
+ return H(e, t, (e) => B(e, I), () => "- ");
956
964
  }
957
965
  function W(e, t) {
958
- return V(e, t, (e) => B(e, z), () => "> ");
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 fe(e, t) {
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 pe(e) {
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 G(e, t) {
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 = pe(t.text);
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 me(e, t, n = "en") {
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 he(e, t, n = "en") {
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 = `![${a}](${o})`, n = r + 2 + a.length + 2;
@@ -1031,14 +1045,14 @@ function he(e, t, n = "en") {
1031
1045
  }
1032
1046
  };
1033
1047
  }
1034
- function ge(e, t, n = "en") {
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 q(e, r, `${s}${a}\n${o}`, {
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 K(e) {
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 q(e, t, n, r) {
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 ve(e, t, n = "en") {
1071
- let r = S(e, t), i = C(n), a = K(i), o = i.tableRows[0][0], s = a.indexOf(o);
1072
- return q(e, r, a, {
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 J(e, t) {
1078
- return q(e, S(e, t), "---", {
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 ye(e, t, n) {
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 be = /\{\{(selection(?::[^{}]*)?|caret|select:[^{}]*)\}\}/g;
1094
- function xe(e, t) {
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
- be.lastIndex = 0;
1097
- for (let s = be.exec(e); s; s = be.exec(e)) {
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 = xe(n, e.slice(i.start, i.end)), o = r.block === !0 && a.text.length > 0 ? _e(e, i) : {
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 Oe(e, t, n, r) {
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 >= ke(n.text)));
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 ke(e) {
1213
+ function Oe(e) {
1200
1214
  let t = 0;
1201
1215
  for (;;) {
1202
- let n = e.slice(t), r = B(n, le) ?? B(n, L) ?? B(n, R) ?? B(n, z);
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 Ae(e) {
1208
- return B(e, le) ? "task" : B(e, L) ? "bullet" : B(e, R) ? "ordered" : null;
1221
+ function ke(e) {
1222
+ return B(e, R) ? "task" : B(e, I) ? "bullet" : B(e, L) ? "ordered" : null;
1209
1223
  }
1210
- function je(e, t) {
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 = F.exec(i);
1228
+ })[0], i = r.text, a = P.exec(i);
1215
1229
  return {
1216
1230
  headingLevel: a ? a[1].length : 0,
1217
- bold: Oe(e, n, r, "bold"),
1218
- italic: Oe(e, n, r, "italic"),
1219
- strike: Oe(e, n, r, "strike"),
1220
- inlineCode: Oe(e, n, r, "inlineCode"),
1221
- list: Ae(i),
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 Me = [
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
- ], Ne = [
1248
- ...g,
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
- ], Pe = /\{\{bind:([^{}]+)\}\}/g, Fe = /[A-Za-z_][A-Za-z0-9_]*/g;
1599
- function Ie(e, t) {
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 Le = Me.map((e) => ({
1621
+ var Ie = je.map((e) => ({
1608
1622
  ...e,
1609
1623
  label: v.zh.groups[e.id]
1610
- })), Re = Ne.map((e) => ({
1624
+ })), Le = Me.map((e) => ({
1611
1625
  ...e,
1612
- keywords: Ie(e.keywords, v.zh.components[e.id]?.keywords ?? [])
1613
- })), ze = Ne.map((e) => {
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: Ie(e.keywords, t.keywords),
1633
+ keywords: Fe(e.keywords, t.keywords),
1620
1634
  template: t.template
1621
1635
  } : e;
1622
1636
  });
1623
- function Be(e = "en") {
1637
+ function ze(e = "en") {
1624
1638
  return e === "zh" ? {
1625
- groups: Le,
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 Ve(e) {
1633
- return new Set(e.match(Fe) ?? []);
1646
+ function Be(e) {
1647
+ return new Set(e.match(Pe) ?? []);
1634
1648
  }
1635
- function He(e) {
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 Ue(e, t) {
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 We(e, t, n) {
1646
- let r = Ve(t), i = /* @__PURE__ */ new Map();
1647
- return e.template.replace(Pe, (e, t) => {
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 = Ue(He(n), r);
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 Ge = /* @__PURE__ */ "😀.😄.😁.😊.🙂.😉.😍.🤔.😎.😅.😂.🥳.👍.👎.👏.🙏.💡.✅.❌.⚠️.🔥.⭐.🎉.❤️.💬.📌.🚀.📈.📉.🧩.⚙️.🔍.📎.🗂️.🕒.✨".split("."), Ke = [
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
- ], qe = [
1698
+ ], Ke = [
1685
1699
  {
1686
1700
  type: "bullet",
1687
1701
  icon: "bulletList",
1688
- command: de
1702
+ command: U
1689
1703
  },
1690
1704
  {
1691
1705
  type: "ordered",
1692
1706
  icon: "orderedList",
1693
- command: H
1707
+ command: W
1694
1708
  },
1695
1709
  {
1696
1710
  type: "task",
1697
1711
  icon: "taskList",
1698
- command: U
1712
+ command: ue
1699
1713
  }
1700
- ], Je = [{
1714
+ ], qe = [{
1701
1715
  labelKey: "decreaseIndent",
1702
1716
  icon: "outdent",
1703
- command: G
1717
+ command: K
1704
1718
  }, {
1705
1719
  labelKey: "increaseIndent",
1706
1720
  icon: "indent",
1707
- command: fe
1708
- }], Ye = [
1721
+ command: de
1722
+ }], Je = [
1709
1723
  {
1710
1724
  labelKey: "image",
1711
1725
  icon: "image",
1712
- command: he
1726
+ command: me
1713
1727
  },
1714
1728
  {
1715
1729
  labelKey: "table",
1716
1730
  icon: "table",
1717
- command: ve
1731
+ command: ye
1718
1732
  },
1719
1733
  {
1720
1734
  labelKey: "divider",
1721
1735
  icon: "divider",
1722
- command: J
1736
+ command: q
1723
1737
  },
1724
1738
  {
1725
1739
  labelKey: "codeBlock",
1726
1740
  icon: "codeBlock",
1727
- command: ge
1741
+ command: he
1728
1742
  },
1729
1743
  {
1730
1744
  labelKey: "inlineCode",
1731
1745
  icon: "inlineCode",
1732
- command: ce
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: W
1756
+ command: G
1743
1757
  }
1744
- ], Xe = {
1758
+ ], Ye = {
1745
1759
  heading: 200,
1746
1760
  list: 208,
1747
1761
  insert: 216,
1748
1762
  more: 188
1749
- }, Ze = {
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
- }, Qe = {
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 Y({ name: e, className: t }) {
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: Qe[e]
1925
+ children: Ze[e]
1912
1926
  });
1913
1927
  }
1914
- function X(e) {
1928
+ function Z(e) {
1915
1929
  e.preventDefault();
1916
1930
  }
1917
- function Z({ 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 }) {
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 : X,
1946
+ onMouseDown: l ? void 0 : Z,
1933
1947
  onClick: i,
1934
1948
  onKeyDown: m,
1935
1949
  children: a
1936
1950
  });
1937
1951
  }
1938
- function $e(e) {
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 et(e, t) {
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 tt(e, t) {
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 nt(e) {
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 rt(e) {
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 it(e, t) {
1962
- let n = rt(t);
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 at(e, t) {
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 ot({ editorRef: e, onEdit: t, onUndo: n, onRedo: i, canUndo: s, canRedo: f, onExport: ee, showExport: te = !1, disabled: h = !1 }) {
2013
- let ne = u(null), g = u(null), re = u(null), ie = u(null), _ = u(null), v = u(null), [y, b] = d(null), [x, S] = d("heading"), [C, w] = d(""), [T, E] = d(Ze), [D, O] = d(null), k = o(), j = `${k}-emoji-menu`, M = `${k}-heading-menu`, N = `${k}-list-menu`, P = `${k}-insert-menu`, ce = `${k}-more-menu`, F = `${k}-native-menu`, L = oe(), R = ae[L], le = l(() => Be(L), [L]), z = Ke.map((e) => ({
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: R.headingLabels[e.level]
2016
- })), B = qe.map((e) => ({
2029
+ label: L.headingLabels[e.level]
2030
+ })), B = Ke.map((e) => ({
2017
2031
  ...e,
2018
- label: R.listLabels[e.type]
2019
- })), ue = Je.map((e) => ({
2032
+ label: L.listLabels[e.type]
2033
+ })), V = qe.map((e) => ({
2020
2034
  ...e,
2021
- label: R[e.labelKey]
2022
- })), V = Ye.map((e) => ({
2035
+ label: L[e.labelKey]
2036
+ })), H = Je.map((e) => ({
2023
2037
  ...e,
2024
- label: R.insertItems[e.labelKey]
2025
- })), de = l(() => {
2038
+ label: L.insertItems[e.labelKey]
2039
+ })), U = l(() => {
2026
2040
  let e = C.trim().toLowerCase();
2027
- return le.groups.map((t) => ({
2041
+ return R.groups.map((t) => ({
2028
2042
  group: t,
2029
- components: le.components.filter((n) => n.group === t.id && et(n, e))
2043
+ components: R.components.filter((n) => n.group === t.id && $e(n, e))
2030
2044
  })).filter((e) => e.components.length > 0);
2031
- }, [le, C]), H = r(() => {
2045
+ }, [R, C]), W = r(() => {
2032
2046
  let t = e.current;
2033
2047
  if (!t) {
2034
- E(Ze);
2048
+ E(Xe);
2035
2049
  return;
2036
2050
  }
2037
- let n = je(t.value, {
2051
+ let n = Ae(t.value, {
2038
2052
  start: t.selectionStart,
2039
2053
  end: t.selectionEnd
2040
2054
  });
2041
- E((e) => tt(e, n) ? e : n);
2042
- }, [e]), U = r(() => {
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, H();
2058
+ v.current = null, W();
2045
2059
  });
2046
- }, [H]);
2060
+ }, [W]);
2047
2061
  a(() => {
2048
2062
  let t = e.current;
2049
2063
  if (!t) return;
2050
- let n = () => H(), r = [
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 && H();
2073
+ document.activeElement === t && W();
2060
2074
  };
2061
- return document.addEventListener("selectionchange", i), H(), () => {
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, H]), a(() => () => {
2079
+ }, [e, W]), a(() => () => {
2066
2080
  v.current !== null && window.cancelAnimationFrame(v.current);
2067
2081
  }, []);
2068
- let W = r((e) => {
2082
+ let G = r((e) => {
2069
2083
  let t = e === "emoji" ? "insert" : e === "native" ? "components" : e;
2070
- return ne.current?.querySelector(`[data-toolbar-id="${t}"]`) ?? null;
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 = W(y);
2096
+ let t = G(y);
2083
2097
  if (!t) return;
2084
- let n = t.getBoundingClientRect(), r = Xe[y] ?? 216, i = n.top - 6 - 8, a = window.innerHeight - n.bottom - 6 - 8, o = {};
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, W]), a(() => {
2104
+ }, [y, G]), a(() => {
2091
2105
  if (!y) return;
2092
2106
  let e = (e) => {
2093
- ne.current && !ne.current.contains(e.target) && b(null);
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), W(t)?.focus();
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, W]), a(() => {
2117
+ }, [y, G]), a(() => {
2104
2118
  if (!y) return;
2105
- let e = _.current;
2106
- _.current = null;
2119
+ let e = ie.current;
2120
+ ie.current = null;
2107
2121
  let t = window.requestAnimationFrame(() => {
2108
- let t = g.current;
2122
+ let t = _.current;
2109
2123
  if (e) {
2110
- let n = rt(t);
2124
+ let n = nt(t);
2111
2125
  (e === "first" ? n[0] : n[n.length - 1])?.focus();
2112
- } else y === "native" ? re.current?.focus() : y === "emoji" && rt(t)[0]?.focus();
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 fe = r(() => {
2117
- let e = nt(ne.current);
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(() => (fe(), window.addEventListener("resize", fe), () => window.removeEventListener("resize", fe)), [fe]), a(() => {
2121
- fe();
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
- fe
2140
+ de
2127
2141
  ]);
2128
- let pe = r((e) => {
2129
- h || (b(null), t(e), U());
2142
+ let fe = r((e) => {
2143
+ h || (b(null), t(e), ue());
2130
2144
  }, [
2131
2145
  h,
2132
2146
  t,
2133
- U
2134
- ]), G = (t) => {
2147
+ ue
2148
+ ]), K = (t) => {
2135
2149
  if (h) return;
2136
- let { value: n, selection: r } = $e(e);
2137
- pe(t(n, r, L));
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 } = $e(e);
2141
- pe(I(n, r, t));
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 } = $e(e);
2145
- pe(ye(n, r, t));
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(), U());
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
- }, J = (e) => {
2170
+ }, q = (e) => {
2157
2171
  b((t) => t === e ? null : e), e === "native" && w("");
2158
- }, be = (e, t, n) => {
2172
+ }, xe = (e, t, n) => {
2159
2173
  if (t.preventDefault(), e === "native" && w(""), y === e) {
2160
- let e = rt(g.current);
2174
+ let e = nt(_.current);
2161
2175
  (n === "first" ? e[0] : e[e.length - 1])?.focus();
2162
- } else _.current = n, b(e);
2163
- }, xe = (e, t) => {
2164
- (t.key === "ArrowDown" || t.key === "ArrowUp") && be(e, t, t.key === "ArrowDown" ? "first" : "last");
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 = nt(ne.current), i = r.indexOf(n);
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), W("native")?.focus();
2197
- }, Te = z.find((e) => e.level === T.headingLevel)?.label ?? R.headingLabels[0], Ee = T.headingLevel === 0 ? "¶" : `H${T.headingLevel}`, De = R.headingLevelLabel(Te), Oe = T.list ? R.listLabels[T.list] : null, ke = Oe ? R.listLabelWithType(Oe) : R.listLabel, Ae = T.list === "ordered" ? "orderedList" : T.list === "task" ? "taskList" : "bulletList";
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": R.toolbarLabel,
2215
+ "aria-label": L.toolbarLabel,
2202
2216
  "aria-orientation": "horizontal",
2203
2217
  "aria-disabled": h || void 0,
2204
- ref: ne,
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(Z, {
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: () => J("heading"),
2221
- onKeyDown: (e) => xe("heading", 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(Y, {
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: g,
2253
+ ref: _,
2240
2254
  className: "editor-toolbar-popover editor-toolbar-heading-menu",
2241
2255
  role: "menu",
2242
- "aria-label": R.headingMenuLabel,
2256
+ "aria-label": L.headingMenuLabel,
2243
2257
  style: D ?? void 0,
2244
- onKeyDown: (e) => it(e, g.current),
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: X,
2252
- onClick: () => he(e.level),
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(Z, {
2275
+ /* @__PURE__ */ p(Q, {
2262
2276
  toolbarId: "bold",
2263
- label: R.bold,
2277
+ label: L.bold,
2264
2278
  tabStop: x === "bold",
2265
2279
  onFocus: () => S("bold"),
2266
2280
  disabled: h,
2267
- onClick: () => G(A),
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(Z, {
2290
+ /* @__PURE__ */ p(Q, {
2277
2291
  toolbarId: "italic",
2278
- label: R.italic,
2292
+ label: L.italic,
2279
2293
  tabStop: x === "italic",
2280
2294
  onFocus: () => S("italic"),
2281
2295
  disabled: h,
2282
- onClick: () => G(se),
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(Z, {
2307
+ children: [/* @__PURE__ */ m(Q, {
2294
2308
  toolbarId: "list",
2295
- label: ke,
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: () => J("list"),
2305
- onKeyDown: (e) => xe("list", e),
2306
- children: [/* @__PURE__ */ p(Y, { name: Ae }), /* @__PURE__ */ p(Y, {
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: g,
2326
+ ref: _,
2313
2327
  className: "editor-toolbar-popover editor-toolbar-list-menu",
2314
2328
  role: "menu",
2315
- "aria-label": R.listMenuLabel,
2329
+ "aria-label": L.listMenuLabel,
2316
2330
  style: D ?? void 0,
2317
- onKeyDown: (e) => it(e, g.current),
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: X,
2326
- onClick: () => G(e.command),
2327
- children: [/* @__PURE__ */ p(Y, {
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
- ue.map((e) => /* @__PURE__ */ m("button", {
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: X,
2342
- onClick: () => G(e.command),
2343
- children: [/* @__PURE__ */ p(Y, {
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(Z, {
2365
+ /* @__PURE__ */ p(Q, {
2352
2366
  toolbarId: "link",
2353
- label: R.insertLink,
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: () => G(me),
2359
- children: /* @__PURE__ */ p(Y, { name: "link" })
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(Z, {
2378
+ /* @__PURE__ */ m(Q, {
2365
2379
  toolbarId: "insert",
2366
- label: R.insert,
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 : P,
2374
- onClick: () => J("insert"),
2375
- onKeyDown: (e) => xe("insert", e),
2387
+ controls: y === "emoji" ? j : ce,
2388
+ onClick: () => q("insert"),
2389
+ onKeyDown: (e) => J("insert", e),
2376
2390
  children: [
2377
- /* @__PURE__ */ p(Y, { name: "plus" }),
2391
+ /* @__PURE__ */ p(X, { name: "plus" }),
2378
2392
  /* @__PURE__ */ p("span", {
2379
2393
  className: "editor-toolbar-insert-label",
2380
- children: R.insert
2394
+ children: L.insert
2381
2395
  }),
2382
- /* @__PURE__ */ p(Y, {
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: P,
2390
- ref: g,
2403
+ id: ce,
2404
+ ref: _,
2391
2405
  className: "editor-toolbar-popover editor-toolbar-insert-menu",
2392
2406
  role: "menu",
2393
- "aria-label": R.insertMenuLabel,
2407
+ "aria-label": L.insertMenuLabel,
2394
2408
  style: D ?? void 0,
2395
- onKeyDown: (e) => it(e, g.current),
2396
- children: [V.map((e) => /* @__PURE__ */ m("button", {
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: X,
2402
- onClick: () => G(e.command),
2403
- children: [/* @__PURE__ */ p(Y, {
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: X,
2426
+ onMouseDown: Z,
2413
2427
  onClick: () => b("emoji"),
2414
- children: [/* @__PURE__ */ p(Y, {
2428
+ children: [/* @__PURE__ */ p(X, {
2415
2429
  name: "smile",
2416
2430
  className: "editor-toolbar-menu-icon"
2417
- }), /* @__PURE__ */ p("span", { children: R.emoji })]
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: g,
2436
+ ref: _,
2423
2437
  className: "editor-toolbar-popover editor-toolbar-emoji-menu",
2424
2438
  role: "menu",
2425
- "aria-label": R.insertEmojiMenuLabel,
2426
- onKeyDown: (e) => at(e, ie.current),
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: ie,
2430
- children: Ge.map((e) => /* @__PURE__ */ p("button", {
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": R.insertEmojiLabel(e),
2436
- onMouseDown: X,
2437
- onClick: () => ge(e),
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(Z, {
2460
+ children: [/* @__PURE__ */ m(Q, {
2447
2461
  toolbarId: "components",
2448
- label: R.componentsTriggerLabel,
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: F,
2456
- onClick: () => J("native"),
2457
- onKeyDown: (e) => xe("native", e),
2469
+ controls: P,
2470
+ onClick: () => q("native"),
2471
+ onKeyDown: (e) => J("native", e),
2458
2472
  children: [
2459
- /* @__PURE__ */ p(Y, { name: "sparkle" }),
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: R.componentsLabel
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: R.componentsCompactLabel
2480
+ children: L.componentsCompactLabel
2467
2481
  })
2468
2482
  ]
2469
2483
  }), y === "native" ? /* @__PURE__ */ m("div", {
2470
- id: F,
2471
- ref: g,
2484
+ id: P,
2485
+ ref: _,
2472
2486
  className: "editor-toolbar-popover editor-toolbar-native-menu",
2473
2487
  role: "dialog",
2474
- "aria-label": R.nativeMenuLabel,
2475
- onKeyDown: (e) => it(e, g.current),
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: R.nativeTitle
2495
+ children: L.nativeTitle
2482
2496
  }), /* @__PURE__ */ p("button", {
2483
2497
  type: "button",
2484
2498
  className: "editor-toolbar-close",
2485
- "aria-label": R.closeNativeLabel,
2486
- onMouseDown: X,
2499
+ "aria-label": L.closeNativeLabel,
2500
+ onMouseDown: Z,
2487
2501
  onClick: we,
2488
- children: /* @__PURE__ */ p(Y, { name: "close" })
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(Y, {
2507
+ children: [/* @__PURE__ */ p(X, {
2494
2508
  name: "search",
2495
2509
  className: "editor-toolbar-search-icon"
2496
2510
  }), /* @__PURE__ */ p("input", {
2497
- ref: re,
2511
+ ref: ne,
2498
2512
  type: "search",
2499
2513
  className: "editor-toolbar-search-input",
2500
2514
  value: C,
2501
- placeholder: R.searchPlaceholder,
2502
- "aria-label": R.searchLabel,
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": R.nativeListLabel,
2512
- children: de.length === 0 ? /* @__PURE__ */ p("p", {
2525
+ "aria-label": L.nativeListLabel,
2526
+ children: U.length === 0 ? /* @__PURE__ */ p("p", {
2513
2527
  className: "editor-toolbar-menu-empty",
2514
- children: R.noMatchingComponents
2515
- }) : de.map(({ group: e, components: t }) => /* @__PURE__ */ m("div", {
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: X,
2529
- onClick: () => K(e),
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: R.inlineBadge
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(Y, {
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": R.historyLabel,
2569
+ "aria-label": L.historyLabel,
2556
2570
  children: [
2557
- /* @__PURE__ */ p(Z, {
2571
+ /* @__PURE__ */ p(Q, {
2558
2572
  toolbarId: "undo",
2559
- label: R.undo,
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(Y, { name: "undo" })
2579
+ children: /* @__PURE__ */ p(X, { name: "undo" })
2566
2580
  }),
2567
- /* @__PURE__ */ p(Z, {
2581
+ /* @__PURE__ */ p(Q, {
2568
2582
  toolbarId: "redo",
2569
- label: R.redo,
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: q,
2575
- children: /* @__PURE__ */ p(Y, { name: "redo" })
2588
+ onClick: ve,
2589
+ children: /* @__PURE__ */ p(X, { name: "redo" })
2576
2590
  }),
2577
- te ? /* @__PURE__ */ p(Z, {
2591
+ te ? /* @__PURE__ */ p(Q, {
2578
2592
  toolbarId: "download",
2579
- label: R.download,
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: ve,
2585
- children: /* @__PURE__ */ p(Y, { name: "download" })
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(Z, {
2603
+ children: [/* @__PURE__ */ p(Q, {
2590
2604
  toolbarId: "more",
2591
- label: R.more,
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: ce,
2599
- onClick: () => J("more"),
2600
- onKeyDown: (e) => xe("more", e),
2601
- children: /* @__PURE__ */ p(Y, { name: "more" })
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: ce,
2604
- ref: g,
2617
+ id: le,
2618
+ ref: _,
2605
2619
  className: "editor-toolbar-popover editor-toolbar-more-menu",
2606
2620
  role: "menu",
2607
- "aria-label": R.moreMenuLabel,
2621
+ "aria-label": L.moreMenuLabel,
2608
2622
  style: D ?? void 0,
2609
- onKeyDown: (e) => it(e, g.current),
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: X,
2617
- onClick: () => G(me),
2618
- children: [/* @__PURE__ */ p(Y, {
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: R.linkMenuItem })]
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: X,
2643
+ onMouseDown: Z,
2630
2644
  onClick: _e,
2631
- children: [/* @__PURE__ */ p(Y, {
2645
+ children: [/* @__PURE__ */ p(X, {
2632
2646
  name: "undo",
2633
2647
  className: "editor-toolbar-menu-icon"
2634
- }), /* @__PURE__ */ p("span", { children: R.undo })]
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: X,
2643
- onClick: q,
2644
- children: [/* @__PURE__ */ p(Y, {
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: R.redo })]
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: X,
2655
- onClick: ve,
2656
- children: [/* @__PURE__ */ p(Y, {
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: R.download })]
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 Q(e, t, n) {
2758
+ function ut(e, t, n) {
2690
2759
  return Math.min(Math.max(e, t), n);
2691
2760
  }
2692
- function ut(e, t) {
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 = Q(Math.max(t.range.start, r), 0, e.length), a = Q(t.range.end, i, e.length);
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 dt(e, t = !0) {
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: ut(e, t.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 ft(e, t) {
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 pt = n(function({ source: e, tokens: t, width: n, editorRef: r }) {
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: ft(e, t)
2834
+ children: pt(e, t)
2766
2835
  })
2767
2836
  });
2768
- }), mt = {
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 ht(e, t) {
2937
+ function gt(e, t) {
2869
2938
  return t >= e.start && t <= e.end;
2870
2939
  }
2871
- function gt(e) {
2940
+ function _t(e) {
2872
2941
  return e.end - e.start;
2873
2942
  }
2874
- function _t(e, t) {
2943
+ function vt(e, t) {
2875
2944
  let n = null, r = Infinity, i = (e, i, a) => {
2876
- if (!ht(i, t)) return;
2877
- let o = gt(i);
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 vt(e) {
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 = Q(t.selectionStart, 0, n);
2964
+ let n = t.value.length, r = ut(t.selectionStart, 0, n);
2896
2965
  return {
2897
2966
  start: r,
2898
- end: Q(t.selectionEnd, r, n)
2967
+ end: ut(t.selectionEnd, r, n)
2899
2968
  };
2900
2969
  }
2901
- function yt(e, t) {
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 bt(e, t, n) {
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 xt(e, t, n) {
2912
- let r = Q(n, 0, e.length), i = yt(e, t);
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 = bt(e, t, i), o = e.length - 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 St(e, t) {
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 - gt(r.range);
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 Ct(e) {
2999
+ function wt(e) {
2931
3000
  e.preventDefault();
2932
3001
  }
2933
- function wt(e) {
3002
+ function Tt(e) {
2934
3003
  return e.isComposing === !0 || e.keyCode === 229;
2935
3004
  }
2936
- function Tt(e, t) {
2937
- let n = Q(t, 0, e.length), r = e.lastIndexOf("\n", n - 1) + 1;
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 Et({ source: e, analysis: t, bindingDocument: n, editorRef: i, onEdit: s, onLocate: c, disabled: f = !1 }) {
2944
- let ee = oe(), g = mt[ee], re = o(), ie = o(), _ = 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), P = u(A), ce = u(j);
2945
- N.current = O, P.current = A, ce.current = j, a(() => {
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 F = l(() => _t(t.bindings, v), [t.bindings, v]);
3035
+ let P = l(() => vt(t.bindings, v), [t.bindings, v]);
2967
3036
  a(() => {
2968
- F && x(F.binding.name);
2969
- }, [F]);
2970
- let I = l(() => (b ? t.bindings.find((e) => e.name === b) : void 0) ?? t.bindings[0] ?? null, [t.bindings, b]);
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
- }, [I?.name]);
2974
- let L = I && n ? n.bindings[I.name]?.type ?? n.computations?.[I.name]?.type : void 0, R = F && n ? n.bindings[F.binding.name]?.type ?? n.computations?.[F.binding.name]?.type : void 0, le = R ? g.typeNames[R] ?? R : g.unknownType, z = L ? g.typeNames[L] ?? L : g.unknownType, B = r(() => {
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 = Q(t?.selectionStart ?? 0, 0, e.length), r = [];
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
- ]), ue = r((t) => {
3056
+ ]), V = r((t) => {
2988
3057
  if (f) return;
2989
- let n = Q(t.range.start, 0, e.length), r = Q(t.range.end, n, e.length), i = e.slice(0, n) + t.insertText + e.slice(r), a = n + t.insertText.length;
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 (wt(e)) return;
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 = P.current.length;
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 = P.current[ce.current];
3021
- t ? ue(t) : k(!1);
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
- ue,
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
- _.current?.contains(e.target) || k(!1);
3103
+ ie.current?.contains(e.target) || k(!1);
3035
3104
  }, t = (e) => {
3036
- e.key === "Escape" && !wt(e) && k(!1);
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 V = () => {
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(g.formatFailed(e instanceof Error ? e.message : String(e)));
3119
+ D(_.formatFailed(e instanceof Error ? e.message : String(e)));
3051
3120
  return;
3052
3121
  }
3053
3122
  if (t === e) {
3054
- D(g.formatUnchanged);
3123
+ D(_.formatUnchanged);
3055
3124
  return;
3056
3125
  }
3057
- let n = vt(i);
3126
+ let n = yt(i);
3058
3127
  s({
3059
3128
  value: t,
3060
3129
  selection: {
3061
- start: xt(e, t, n.start),
3062
- end: xt(e, t, n.end)
3130
+ start: St(e, t, n.start),
3131
+ end: St(e, t, n.end)
3063
3132
  }
3064
- }), D(g.formatApplied);
3065
- }, de = () => {
3066
- if (f || !I) return;
3133
+ }), D(_.formatApplied);
3134
+ }, U = () => {
3135
+ if (f || !F) return;
3067
3136
  let t = S.trim();
3068
- if (!t) T(g.renameEmpty);
3069
- else if (t === I.name) T(g.renameSame);
3137
+ if (!t) T(_.renameEmpty);
3138
+ else if (t === F.name) T(_.renameSame);
3070
3139
  else try {
3071
- let n = ne(e, I.name, t), r = vt(i);
3140
+ let n = g(e, F.name, t), r = yt(i);
3072
3141
  s({
3073
3142
  value: n.source,
3074
3143
  selection: {
3075
- start: St(r.start, n.edits),
3076
- end: St(r.end, n.edits)
3144
+ start: Ct(r.start, n.edits),
3145
+ end: Ct(r.end, n.edits)
3077
3146
  }
3078
- }), x(t), C(""), T(null), D(g.renameDone(I.name, t));
3147
+ }), x(t), C(""), T(null), D(_.renameDone(F.name, t));
3079
3148
  } catch (e) {
3080
- T(g.renameFailed(e instanceof Error ? e.message : String(e)));
3149
+ T(_.renameFailed(e instanceof Error ? e.message : String(e)));
3081
3150
  }
3082
- }, H = A[j], U = I ? [...I.declarations.map((e, t) => ({
3151
+ }, W = A[j], ue = F ? [...F.declarations.map((e, t) => ({
3083
3152
  range: e,
3084
3153
  role: "declaration",
3085
3154
  index: t
3086
- })), ...I.references.map((e, t) => ({
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": g.region,
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: g.title
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: g.formatTitle,
3176
+ title: _.formatTitle,
3108
3177
  disabled: f,
3109
- onMouseDown: Ct,
3110
- onClick: V,
3111
- children: g.format
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: g.suggestionsTitle,
3185
+ title: _.suggestionsTitle,
3117
3186
  "aria-expanded": O,
3118
- "aria-controls": ie,
3187
+ "aria-controls": re,
3119
3188
  disabled: f,
3120
- onMouseDown: Ct,
3189
+ onMouseDown: wt,
3121
3190
  onClick: B,
3122
- children: g.suggestions
3191
+ children: _.suggestions
3123
3192
  })]
3124
3193
  })]
3125
3194
  }),
3126
3195
  O ? /* @__PURE__ */ m("div", {
3127
3196
  className: "authoring-completion",
3128
- "aria-label": g.completionLabel,
3197
+ "aria-label": _.completionLabel,
3129
3198
  children: [
3130
3199
  /* @__PURE__ */ m("div", {
3131
3200
  className: "authoring-completion-head",
3132
- children: [/* @__PURE__ */ p("span", { children: g.completionLabel }), /* @__PURE__ */ p("span", {
3201
+ children: [/* @__PURE__ */ p("span", { children: _.completionLabel }), /* @__PURE__ */ p("span", {
3133
3202
  className: "authoring-completion-count",
3134
- children: g.completionCount(A.length)
3203
+ children: _.completionCount(A.length)
3135
3204
  })]
3136
3205
  }),
3137
3206
  /* @__PURE__ */ p("div", {
3138
- id: ie,
3207
+ id: re,
3139
3208
  className: "authoring-completion-list",
3140
3209
  role: "listbox",
3141
- "aria-label": g.completionLabel,
3210
+ "aria-label": _.completionLabel,
3142
3211
  ref: ae,
3143
3212
  children: A.length === 0 ? /* @__PURE__ */ p("p", {
3144
3213
  className: "authoring-empty",
3145
- children: g.completionEmpty
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: Ct,
3221
+ onMouseDown: wt,
3153
3222
  onMouseEnter: () => M(t),
3154
- onClick: () => ue(e),
3223
+ onClick: () => V(e),
3155
3224
  children: [
3156
3225
  /* @__PURE__ */ p("span", {
3157
3226
  className: `authoring-kind is-${e.kind}`,
3158
- children: g.kinds[e.kind] ?? e.kind
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: H ? `${g.kinds[H.kind] ?? H.kind} ${H.label}` : ""
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": F?.binding.name ?? "",
3252
+ "data-binding-caret": P?.binding.name ?? "",
3184
3253
  children: [/* @__PURE__ */ p("span", {
3185
3254
  className: "authoring-label",
3186
- children: g.caretLabel
3187
- }), F ? /* @__PURE__ */ m("span", {
3255
+ children: _.caretLabel
3256
+ }), P ? /* @__PURE__ */ m("span", {
3188
3257
  className: "authoring-caret-value",
3189
3258
  children: [
3190
- /* @__PURE__ */ p("strong", { children: F.binding.name }),
3259
+ /* @__PURE__ */ p("strong", { children: P.binding.name }),
3191
3260
  /* @__PURE__ */ m("span", {
3192
3261
  className: "authoring-type",
3193
3262
  children: [
3194
- g.typeLabel,
3263
+ _.typeLabel,
3195
3264
  ": ",
3196
- le
3265
+ R
3197
3266
  ]
3198
3267
  }),
3199
- /* @__PURE__ */ p("span", { children: g.declarationCount(F.binding.declarations.length) }),
3200
- /* @__PURE__ */ p("span", { children: g.referenceCount(F.binding.references.length) })
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: g.noBindingAtCaret
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: g.bindingsLabel
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: g.noBindings
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 === I?.name,
3222
- title: `${g.declarationCount(e.declarations.length)} · ${g.referenceCount(e.references.length)}`,
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
- I ? /* @__PURE__ */ m("div", {
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
- I.name,
3311
+ F.name,
3243
3312
  " · ",
3244
- g.typeLabel,
3313
+ _.typeLabel,
3245
3314
  ": ",
3246
3315
  z
3247
3316
  ]
3248
3317
  }), /* @__PURE__ */ p("div", {
3249
3318
  className: "authoring-locations",
3250
- children: U.map(({ range: t, role: n, index: r }) => {
3251
- let i = Tt(e, t.start);
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: g.locateTitle,
3327
+ title: _.locateTitle,
3259
3328
  onClick: () => {
3260
- x(I.name), c(t);
3329
+ x(F.name), c(t);
3261
3330
  },
3262
3331
  children: [/* @__PURE__ */ m("span", { children: [
3263
- n === "declaration" ? g.declaration : g.reference,
3332
+ n === "declaration" ? _.declaration : _.reference,
3264
3333
  " ",
3265
3334
  r + 1
3266
3335
  ] }), /* @__PURE__ */ p("span", {
3267
3336
  className: "authoring-location-position",
3268
- children: g.position(i.line, i.column)
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: re,
3280
- children: g.renameLabel
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: re,
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: g.renamePlaceholder,
3359
+ placeholder: _.renamePlaceholder,
3291
3360
  autoComplete: "off",
3292
3361
  spellCheck: !1,
3293
- disabled: f || !I,
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" && wt(e.nativeEvent) && e.preventDefault();
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 || !I,
3305
- onMouseDown: Ct,
3306
- onClick: de,
3307
- title: g.renameTitle,
3308
- children: g.renameAction
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: g.renameHint
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 Dt(e, t) {
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 Ot(e, t, n) {
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) => Dt(e, o) ? e : o);
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 kt = 700, At = 120, jt = {
3440
+ var At = 700, jt = 120, Mt = {
3372
3441
  start: 0,
3373
3442
  end: 0
3374
3443
  };
3375
- function Mt(e, t = jt, n = Date.now) {
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 < kt ? r[i] = {
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 > At && r.shift(), i = r.length - 1), a = l, o = s === "merge";
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 = jt) => {
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 Nt(e, t = jt) {
3478
+ function Pt(e, t = Mt) {
3410
3479
  let n = u(null);
3411
- n.current ||= Mt(e, t);
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 Pt(e) {
3505
+ function Ft(e) {
3437
3506
  return typeof e == "number" ? `${e}px` : e;
3438
3507
  }
3439
- function Ft(e, t) {
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 It(e, t) {
3518
+ function Lt(e, t) {
3450
3519
  e && (e.current = t);
3451
3520
  }
3452
- var Lt = t(function({ value: e, onChange: t, locale: n = "en", theme: i = "auto", id: a, className: f, style: ee, height: te = 560, minHeight: h = 280, placeholder: ne, ariaLabel: g, readOnly: re = !1, disabled: _ = !1, documentKey: ae, diagnostics: v, document: y = null, toolbar: oe = !0, authoring: x = !0, onExport: S, textareaRef: C }, w) {
3453
- let T = o(), E = a ?? `reactive-md-editor-${T.replace(/:/g, "")}`, D = ie[n], O = u(null), k = u(null), A = u(null), se = u({
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
- }), j = u(null), M = u(e), N = u(ae), P = u(!1), ce = u(e);
3457
- ce.current = e;
3458
- let F = re || _, I = u(F);
3459
- I.current = F;
3460
- let [L, R] = d(!1), [le, z] = d(1), { canUndo: B, canRedo: ue, record: V, undo: de, redo: H, reset: U } = Nt(e), W = r(() => {
3461
- se.current = {
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 = O.current;
3466
- e && (e.setSelectionRange(0, 0), e.scrollTop = 0, e.scrollLeft = 0), k.current && (k.current.scrollTop = 0), z(1);
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 !== M.current && (M.current = e, j.current = null, U(e), W());
3549
+ e !== U.current && (U.current = e, H.current = null, J(e), Se());
3470
3550
  }, [
3471
3551
  e,
3472
- U,
3473
- W
3552
+ J,
3553
+ Se
3474
3554
  ]), c(() => {
3475
- N.current !== ae && (N.current = ae, M.current = e, j.current = null, U(e), W());
3555
+ W.current !== x && (W.current = x, U.current = e, H.current = null, J(e), Se());
3476
3556
  }, [
3477
- ae,
3557
+ x,
3478
3558
  e,
3479
- U,
3480
- W
3559
+ J,
3560
+ Se
3481
3561
  ]);
3482
- let pe = dt(e, x), G = l(() => e.split("\n"), [e]), me = Ot(G, A, O), he = l(() => {
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 v ?? []) Number.isInteger(t.line) && t.line > 0 && e.add(t.line);
3564
+ for (let t of S ?? []) Number.isInteger(t.line) && t.line > 0 && e.add(t.line);
3485
3565
  return e;
3486
- }, [v]), ge = r((e) => {
3566
+ }, [S]), De = r((e) => {
3487
3567
  let t = e.value.length, n = $(e.selectionStart, t), r = $(e.selectionEnd, t);
3488
- se.current = {
3568
+ V.current = {
3489
3569
  start: n,
3490
3570
  end: r
3491
- }, z(e.value.slice(0, n).split("\n").length);
3492
- }, []), K = r((e, n) => {
3493
- let r = e !== ce.current;
3494
- ce.current = e, M.current = e, n && r && (j.current = n), t(e);
3495
- }, [t]), _e = r((e) => {
3496
- I.current || (V(e.value, e.selection, "separate"), K(e.value, e.selection));
3497
- }, [K, V]), q = r(() => {
3498
- if (I.current) return;
3499
- let e = de();
3500
- e && K(e.value, e.selection);
3501
- }, [K, de]), ve = r(() => {
3502
- if (I.current) return;
3503
- let e = H();
3504
- e && K(e.value, e.selection);
3505
- }, [K, H]);
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 = j.current;
3587
+ let t = H.current;
3508
3588
  if (!t) return;
3509
- if (e !== M.current) {
3510
- j.current = null;
3589
+ if (e !== U.current) {
3590
+ H.current = null;
3511
3591
  return;
3512
3592
  }
3513
- j.current = null;
3514
- let n = O.current;
3593
+ H.current = null;
3594
+ let n = R.current;
3515
3595
  if (!n) return;
3516
- let r = Ft(n.value, t);
3517
- n.setSelectionRange(r.start, r.end), n.focus({ preventScroll: !0 }), se.current = r, z(n.value.slice(0, r.start).split("\n").length);
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 J = r((e) => {
3520
- let t = O.current;
3599
+ let je = r((e) => {
3600
+ let t = R.current;
3521
3601
  if (t && (t.focus({ preventScroll: !0 }), e)) {
3522
- let n = Ft(t.value, e);
3523
- t.setSelectionRange(n.start, n.end), se.current = n, z(t.value.slice(0, n.start).split("\n").length);
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
- }, []), ye = r((e) => {
3526
- let t = O.current;
3605
+ }, []), Me = r((e) => {
3606
+ let t = R.current;
3527
3607
  if (!t) return;
3528
- let n = Ft(t.value, e);
3529
- J(n);
3530
- let r = t.value.slice(0, n.start).split("\n").length, i = k.current, a = i?.children[r - 1];
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
- }, [J]);
3540
- s(w, () => ({
3619
+ }, [je]);
3620
+ s(O, () => ({
3541
3621
  focus(e) {
3542
- J(e);
3622
+ je(e);
3543
3623
  },
3544
3624
  selectRange(e) {
3545
- J(e);
3625
+ je(e);
3546
3626
  },
3547
3627
  getSelection() {
3548
- let e = O.current;
3549
- if (!e) return se.current;
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 O.current;
3637
+ return R.current;
3558
3638
  },
3559
- undo: q,
3560
- redo: ve
3639
+ undo: ke,
3640
+ redo: Ae
3561
3641
  }), [
3562
- J,
3563
- q,
3564
- ve
3642
+ je,
3643
+ ke,
3644
+ Ae
3565
3645
  ]);
3566
- let be = r((e) => {
3567
- O.current = e, It(C, e);
3568
- }, [C]), xe = (e) => {
3569
- if (I.current) return;
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
- V(t.value, n, "merge"), K(t.value);
3575
- }, Se = (e) => {
3576
- if (P.current || e.nativeEvent.isComposing || I.current) return;
3577
- let t = e.metaKey || e.ctrlKey, n = e.key.toLowerCase();
3578
- if (t && !e.altKey && n === "z") {
3579
- e.preventDefault(), e.shiftKey ? ve() : q();
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 (t && !e.altKey && n === "y") {
3583
- e.preventDefault(), ve();
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 r = e.currentTarget, i = $(r.selectionStart, r.value.length), a = $(r.selectionEnd, r.value.length);
3589
- if (i !== a) {
3590
- _e(fe(r.value, {
3591
- start: i,
3592
- end: a
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 o = `${r.value.slice(0, i)} ${r.value.slice(a)}`, s = {
3597
- start: i + 2,
3598
- end: i + 2
3689
+ let s = `${i.value.slice(0, a)} ${i.value.slice(o)}`, c = {
3690
+ start: a + 2,
3691
+ end: a + 2
3599
3692
  };
3600
- V(o, s, "separate"), K(o, s);
3601
- }, Ce = () => {
3602
- P.current = !0, R(!0);
3603
- }, we = (e) => {
3604
- P.current = !1, R(!1), ge(e.currentTarget);
3605
- }, Te = (e) => {
3606
- k.current && (k.current.scrollTop = e.currentTarget.scrollTop);
3607
- }, Ee = oe, De = `reactive-md-editor${f ? ` ${f}` : ""}`;
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: De,
3704
+ className: Be,
3612
3705
  "data-editor-theme": i,
3613
3706
  lang: n === "zh" ? "zh-CN" : "en",
3614
- style: ee,
3707
+ style: _,
3615
3708
  role: "group",
3616
- "aria-label": D.region,
3617
- "aria-disabled": F || void 0,
3618
- inert: _ || void 0,
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: Pt(te),
3623
- minHeight: Pt(h)
3717
+ height: Ft(ne),
3718
+ minHeight: Ft(ie)
3624
3719
  },
3625
3720
  children: [
3626
- Ee ? /* @__PURE__ */ p(ot, {
3627
- editorRef: O,
3628
- onEdit: _e,
3629
- onUndo: q,
3630
- onRedo: ve,
3631
- canUndo: B,
3632
- canRedo: ue,
3633
- onExport: S,
3634
- showExport: typeof S == "function",
3635
- disabled: F
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: E,
3640
- children: D.sourceLabel
3734
+ htmlFor: A,
3735
+ children: se.sourceLabel
3641
3736
  }),
3642
3737
  /* @__PURE__ */ m("div", {
3643
- className: `editor-shell${L ? " is-composing" : ""}`,
3644
- children: [
3645
- /* @__PURE__ */ p("div", {
3646
- className: "editor-gutter",
3647
- ref: k,
3648
- "aria-hidden": "true",
3649
- children: G.map((e, t) => {
3650
- let n = t + 1;
3651
- return /* @__PURE__ */ p("span", {
3652
- className: `gutter-line ${le === n ? "is-active" : ""} ${he.has(n) ? "is-diagnostic" : ""}`,
3653
- style: me.heights[t] ? { height: `${me.heights[t]}px` } : void 0,
3654
- children: n
3655
- }, n);
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
- /* @__PURE__ */ m("div", {
3659
- className: "editor-input-wrap",
3660
- children: [/* @__PURE__ */ p(pt, {
3661
- source: e,
3662
- tokens: pe.tokens,
3663
- width: me.width,
3664
- editorRef: O
3665
- }), /* @__PURE__ */ p("textarea", {
3666
- id: E,
3667
- ref: be,
3668
- className: "editor-input",
3669
- value: e,
3670
- wrap: "soft",
3671
- spellCheck: !1,
3672
- autoCapitalize: "off",
3673
- autoCorrect: "off",
3674
- placeholder: ne,
3675
- "aria-label": g,
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
- }), x ? /* @__PURE__ */ p(Et, {
3699
- source: e,
3700
- analysis: pe,
3701
- bindingDocument: y,
3702
- editorRef: O,
3703
- onEdit: _e,
3704
- onLocate: ye,
3705
- disabled: F
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 { Lt as ReactiveMarkdownEditor };
3834
+ export { Rt as ReactiveMarkdownEditor };