markdown-flow-ui 0.1.111 → 0.1.112

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 (39) hide show
  1. package/dist/_virtual/index.cjs10.js +1 -1
  2. package/dist/_virtual/index.cjs9.js +1 -1
  3. package/dist/_virtual/index.es10.js +2 -2
  4. package/dist/_virtual/index.es9.js +2 -2
  5. package/dist/assets/markdown-flow-ui.css +1 -1
  6. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.js +1 -1
  7. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.js.map +1 -1
  8. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +321 -317
  9. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
  10. package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.cjs.js +1 -1
  11. package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.cjs.js.map +1 -1
  12. package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.es.js +48 -44
  13. package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.es.js.map +1 -1
  14. package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.cjs.js +1 -1
  15. package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.cjs.js.map +1 -1
  16. package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.d.ts +1 -0
  17. package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.es.js +38 -28
  18. package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.es.js.map +1 -1
  19. package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.cjs.js +1 -1
  20. package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.cjs.js.map +1 -1
  21. package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.es.js +28 -26
  22. package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.es.js.map +1 -1
  23. package/dist/components/MarkdownFlowEditor/utils.cjs.js +1 -1
  24. package/dist/components/MarkdownFlowEditor/utils.cjs.js.map +1 -1
  25. package/dist/components/MarkdownFlowEditor/utils.d.ts +8 -1
  26. package/dist/components/MarkdownFlowEditor/utils.es.js +59 -39
  27. package/dist/components/MarkdownFlowEditor/utils.es.js.map +1 -1
  28. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  29. package/dist/components/Slide/Slide.es.js.map +1 -1
  30. package/dist/components/Slide/useSlide.cjs.js.map +1 -1
  31. package/dist/components/Slide/useSlide.es.js.map +1 -1
  32. package/dist/components/Slide/utils/streamingNavigation.cjs.js.map +1 -1
  33. package/dist/components/Slide/utils/streamingNavigation.es.js.map +1 -1
  34. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  35. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js.map +1 -1
  36. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  37. package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
  38. package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
  39. package/package.json +1 -1
@@ -1,79 +1,79 @@
1
- import { j as c } from "../../_virtual/jsx-runtime.es.js";
2
- import { useEffect as b, useMemo as y, useState as x, useRef as Z, useCallback as a } from "react";
3
- import He from "../../markdown-flow-ui/node_modules/.pnpm/@uiw_react-codemirror@4.25.2_@babel_runtime@7.28.4_@codemirror_autocomplete@6.19.1_@cod_3434c6a3f0eb7fac49dbaa3a471d1162/node_modules/@uiw/react-codemirror/esm/index.es.js";
4
- import { autocompletion as Ue } from "../../markdown-flow-ui/node_modules/.pnpm/@codemirror_autocomplete@6.19.1/node_modules/@codemirror/autocomplete/dist/index.es.js";
5
- import { EditorView as ge } from "../../markdown-flow-ui/node_modules/.pnpm/@codemirror_view@6.38.6/node_modules/@codemirror/view/dist/index.es.js";
6
- import { markdown as Fe } from "../../markdown-flow-ui/node_modules/.pnpm/@codemirror_lang-markdown@6.5.0/node_modules/@codemirror/lang-markdown/dist/index.es.js";
7
- import { syntaxHighlighting as De, defaultHighlightStyle as Ge } from "../../markdown-flow-ui/node_modules/.pnpm/@codemirror_language@6.11.3/node_modules/@codemirror/language/dist/index.es.js";
8
- import { Tooltip as We, TooltipTrigger as Qe, TooltipContent as Ye } from "../ui/tooltip.es.js";
9
- import _e from "./components/CustomDialog.es.js";
10
- import Je from "./components/CustomPopover.es.js";
11
- import Ke from "./components/EditorToolbar.es.js";
12
- import Xe from "./components/VariableSearchDropdown.es.js";
13
- import Ze from "./editor-context.es.js";
14
- import et from "./components/ImageInject.es.js";
15
- import tt from "./components/VideoInject.es.js";
16
- import nt from "./components/VariableSelect.es.js";
17
- import { SelectedOption as f } from "./types.es.js";
1
+ import { j as l } from "../../_virtual/jsx-runtime.es.js";
2
+ import { useEffect as S, useMemo as k, useState as I, useRef as Z, useCallback as a } from "react";
3
+ import $e from "../../markdown-flow-ui/node_modules/.pnpm/@uiw_react-codemirror@4.25.2_@babel_runtime@7.28.4_@codemirror_autocomplete@6.19.1_@cod_3434c6a3f0eb7fac49dbaa3a471d1162/node_modules/@uiw/react-codemirror/esm/index.es.js";
4
+ import { autocompletion as He } from "../../markdown-flow-ui/node_modules/.pnpm/@codemirror_autocomplete@6.19.1/node_modules/@codemirror/autocomplete/dist/index.es.js";
5
+ import { EditorView as pe } from "../../markdown-flow-ui/node_modules/.pnpm/@codemirror_view@6.38.6/node_modules/@codemirror/view/dist/index.es.js";
6
+ import { markdown as Ue } from "../../markdown-flow-ui/node_modules/.pnpm/@codemirror_lang-markdown@6.5.0/node_modules/@codemirror/lang-markdown/dist/index.es.js";
7
+ import { syntaxHighlighting as qe, defaultHighlightStyle as Fe } from "../../markdown-flow-ui/node_modules/.pnpm/@codemirror_language@6.11.3/node_modules/@codemirror/language/dist/index.es.js";
8
+ import { Tooltip as De, TooltipTrigger as Ge, TooltipContent as Me } from "../ui/tooltip.es.js";
9
+ import We from "./components/CustomDialog.es.js";
10
+ import Qe from "./components/CustomPopover.es.js";
11
+ import Ye from "./components/EditorToolbar.es.js";
12
+ import _e from "./components/VariableSearchDropdown.es.js";
13
+ import Je from "./editor-context.es.js";
14
+ import Ke from "./components/ImageInject.es.js";
15
+ import Xe from "./components/VideoInject.es.js";
16
+ import Ze from "./components/VariableSelect.es.js";
17
+ import { SelectedOption as m } from "./types.es.js";
18
18
  /* empty css */
19
- import { extractVariableNames as ot, getVideoContentToInsert as rt, createSlashCommands as st, parseContentInfo as it, createVariableExpressionRegexp as at } from "./utils.es.js";
20
- import lt from "./plugins/ImgPlaceholder.es.js";
21
- import ct from "./plugins/VideoPlaceholder.es.js";
22
- import ut from "./plugins/VariablePlaceholder.es.js";
23
- import mt from "./plugins/SyntaxHighlighter.es.js";
24
- import Se from "./locales/en-US.json.es.js";
25
- import ft from "./locales/zh-CN.json.es.js";
19
+ import { extractVariableNames as et, getImageContentToInsert as tt, getVideoContentToInsert as nt, createSlashCommands as ot, parseContentInfo as rt, createVariableExpressionRegexp as st } from "./utils.es.js";
20
+ import it from "./plugins/ImgPlaceholder.es.js";
21
+ import at from "./plugins/VideoPlaceholder.es.js";
22
+ import lt from "./plugins/VariablePlaceholder.es.js";
23
+ import ct from "./plugins/SyntaxHighlighter.es.js";
24
+ import Ce from "./locales/en-US.json.es.js";
25
+ import ut from "./locales/zh-CN.json.es.js";
26
26
  import ee from "../../markdown-flow-ui/node_modules/.pnpm/i18next@23.16.8/node_modules/i18next/dist/esm/i18next.es.js";
27
- import { initReactI18next as ht } from "../../markdown-flow-ui/node_modules/.pnpm/react-i18next@15.7.4_i18next@23.16.8_react-dom@19.0.1_react@19.0.1__react@19.0.1_typescript@5.9.3/node_modules/react-i18next/dist/es/initReactI18next.es.js";
28
- import { useTranslation as pt } from "../../markdown-flow-ui/node_modules/.pnpm/react-i18next@15.7.4_i18next@23.16.8_react-dom@19.0.1_react@19.0.1__react@19.0.1_typescript@5.9.3/node_modules/react-i18next/dist/es/useTranslation.es.js";
27
+ import { initReactI18next as mt } from "../../markdown-flow-ui/node_modules/.pnpm/react-i18next@15.7.4_i18next@23.16.8_react-dom@19.0.1_react@19.0.1__react@19.0.1_typescript@5.9.3/node_modules/react-i18next/dist/es/initReactI18next.es.js";
28
+ import { useTranslation as ft } from "../../markdown-flow-ui/node_modules/.pnpm/react-i18next@15.7.4_i18next@23.16.8_react-dom@19.0.1_react@19.0.1__react@19.0.1_typescript@5.9.3/node_modules/react-i18next/dist/es/useTranslation.es.js";
29
29
  const te = {
30
- "en-US": { translation: Se },
31
- "zh-CN": { translation: ft }
30
+ "en-US": { translation: Ce },
31
+ "zh-CN": { translation: ut }
32
32
  };
33
- ee.isInitialized ? Object.entries(te).forEach(([C, p]) => {
33
+ ee.isInitialized ? Object.entries(te).forEach(([V, f]) => {
34
34
  ee.addResourceBundle(
35
- C,
35
+ V,
36
36
  "translation",
37
- p.translation,
37
+ f.translation,
38
38
  !0,
39
39
  !0
40
40
  );
41
- }) : ee.use(ht).init({
41
+ }) : ee.use(mt).init({
42
42
  resources: te,
43
43
  lng: "en-US",
44
44
  fallbackLng: "en-US",
45
45
  interpolation: { escapeValue: !1 }
46
46
  });
47
- const Ve = [], Ce = (C, p) => {
48
- if (!C || p < 0)
47
+ const ge = [], de = (V, f) => {
48
+ if (!V || f < 0)
49
49
  return !1;
50
- const L = at();
51
- let w;
52
- for (; (w = L.exec(C)) !== null; ) {
53
- const v = w.index ?? 0, F = v + w[0].length, k = v + 2, D = F - 2;
54
- if (p >= k && p <= D)
50
+ const L = st();
51
+ let x;
52
+ for (; (x = L.exec(V)) !== null; ) {
53
+ const v = x.index ?? 0, G = v + x[0].length, w = v + 2, M = G - 2;
54
+ if (f >= w && f <= M)
55
55
  return !0;
56
- L.lastIndex === w.index && L.lastIndex++;
56
+ L.lastIndex === x.index && L.lastIndex++;
57
57
  }
58
58
  return !1;
59
- }, dt = (C = "") => `{{${C}}}`, Dt = ({
60
- content: C = "",
61
- editMode: p = "codeEdit",
59
+ }, ht = (V = "") => `{{${V}}}`, Ft = ({
60
+ content: V = "",
61
+ editMode: f = "codeEdit",
62
62
  variables: L,
63
- systemVariables: w,
63
+ systemVariables: x,
64
64
  onChange: v,
65
- onBlur: F,
66
- locale: k = "en-US",
67
- uploadProps: D,
65
+ onBlur: G,
66
+ locale: w = "en-US",
67
+ uploadProps: M,
68
68
  disabled: o = !1,
69
- toolbarActionsRight: G,
70
- onReady: be
69
+ toolbarActionsRight: W,
70
+ onReady: Ve
71
71
  }) => {
72
- const { t: i, i18n: B } = pt();
73
- b(() => {
74
- k && B.language !== k && B.changeLanguage(k);
75
- }, [B, k]);
76
- const Ie = k || B.language, O = te[Ie]?.translation ?? Se, V = y(
72
+ const { t: i, i18n: $ } = ft();
73
+ S(() => {
74
+ w && $.language !== w && $.changeLanguage(w);
75
+ }, [$, w]);
76
+ const Se = w || $.language, O = te[Se]?.translation ?? Ce, d = k(
77
77
  () => ({
78
78
  image: i("toolbarInsertImage", {
79
79
  defaultValue: "Insert image"
@@ -116,7 +116,7 @@ const Ve = [], Ce = (C, p) => {
116
116
  })
117
117
  }),
118
118
  [i]
119
- ), xe = y(
119
+ ), be = k(
120
120
  () => ({
121
121
  searchPlaceholder: i("variableSearchPlaceholder", {
122
122
  defaultValue: "Search variable"
@@ -126,107 +126,107 @@ const Ve = [], Ce = (C, p) => {
126
126
  emptyLabel: i("variableNotFound", "No variables found")
127
127
  }),
128
128
  [i]
129
- ), we = p === "quickEdit" ? i("placeholderQuickEdit", {
129
+ ), Ie = f === "quickEdit" ? i("placeholderQuickEdit", {
130
130
  defaultValue: i("placeholderCodeEdit", {
131
131
  defaultValue: i("placeholder")
132
132
  })
133
- }) : i("placeholderCodeEdit", { defaultValue: i("placeholder") }), A = y(() => {
133
+ }) : i("placeholderCodeEdit", { defaultValue: i("placeholder") }), R = k(() => {
134
134
  const e = /* @__PURE__ */ new Set();
135
- return (w ?? Ve).filter((t) => {
136
- const r = typeof t?.name == "string" ? t.name.toLowerCase() : "";
135
+ return (x ?? ge).filter((n) => {
136
+ const r = typeof n?.name == "string" ? n.name.toLowerCase() : "";
137
137
  return !r || e.has(r) ? !1 : (e.add(r), !0);
138
138
  });
139
- }, [w]), W = y(() => {
139
+ }, [x]), Q = k(() => {
140
140
  const e = new Set(
141
- A.map((r) => r.name.toLowerCase())
142
- ), t = /* @__PURE__ */ new Set();
143
- return (L ?? Ve).filter((r) => {
144
- const n = typeof r?.name == "string" ? r.name.toLowerCase() : "";
145
- return !n || e.has(n) || t.has(n) ? !1 : (t.add(n), !0);
141
+ R.map((r) => r.name.toLowerCase())
142
+ ), n = /* @__PURE__ */ new Set();
143
+ return (L ?? ge).filter((r) => {
144
+ const t = typeof r?.name == "string" ? r.name.toLowerCase() : "";
145
+ return !t || e.has(t) || n.has(t) ? !1 : (n.add(t), !0);
146
146
  });
147
- }, [L, A]), [Q, E] = x(!1), [Y, j] = x(!1), [ve, z] = x(null), [ne, _] = x(
148
- W
149
- ), [M, ke] = x(
150
- A
147
+ }, [L, R]), [Y, E] = I(!1), [_, y] = I(!1), [xe, z] = I(null), [ne, J] = I(
148
+ Q
149
+ ), [H, ve] = I(
150
+ R
151
151
  );
152
- b(() => {
153
- _(W);
154
- }, [W]), b(() => {
155
- ke(A);
156
- }, [A]);
157
- const [S, T] = x(
158
- f.Empty
159
- ), [m, R] = x(), s = Z(null), q = Z(null), H = Z(null), [J, oe] = x(!1), g = a(() => {
160
- oe(!1), H.current = null;
161
- }, []), Ee = a(
152
+ S(() => {
153
+ J(Q);
154
+ }, [Q]), S(() => {
155
+ ve(R);
156
+ }, [R]);
157
+ const [b, T] = I(
158
+ m.Empty
159
+ ), [c, B] = I(), s = Z(null), U = Z(null), q = Z(null), [K, oe] = I(!1), g = a(() => {
160
+ oe(!1), q.current = null;
161
+ }, []), we = a(
162
162
  (e) => {
163
163
  if (!o) {
164
- if (J && H.current === e) {
164
+ if (K && q.current === e) {
165
165
  g();
166
166
  return;
167
167
  }
168
- H.current = e, oe(!0);
168
+ q.current = e, oe(!0);
169
169
  }
170
170
  },
171
- [g, o, J]
172
- ), Te = {
173
- selectedOption: S,
171
+ [g, o, K]
172
+ ), Ee = {
173
+ selectedOption: b,
174
174
  setSelectedOption: T,
175
- dialogOpen: Q,
175
+ dialogOpen: Y,
176
176
  setDialogOpen: E,
177
- popoverOpen: Y,
178
- setPopoverOpen: j,
179
- popoverPosition: ve,
177
+ popoverOpen: _,
178
+ setPopoverOpen: y,
179
+ popoverPosition: xe,
180
180
  setPopoverPosition: z
181
181
  };
182
- b(() => {
183
- o && (E(!1), j(!1), T(f.Empty), R(null), z(null), g());
182
+ S(() => {
183
+ o && (E(!1), y(!1), T(m.Empty), B(null), z(null), g());
184
184
  }, [
185
185
  g,
186
186
  o,
187
187
  E,
188
- j,
188
+ y,
189
189
  z,
190
190
  T,
191
- R
191
+ B
192
192
  ]);
193
- const N = a(
193
+ const j = a(
194
194
  (e) => {
195
- if (p !== "quickEdit" || !e)
195
+ if (f !== "quickEdit" || !e)
196
196
  return;
197
- const t = ot(e);
198
- if (!t.length)
197
+ const n = et(e);
198
+ if (!n.length)
199
199
  return;
200
200
  const r = new Set(
201
- M.map((n) => n.name.toLowerCase())
201
+ H.map((t) => t.name.toLowerCase())
202
202
  );
203
- _((n) => {
204
- const l = new Set(
205
- n.map((d) => d.name.toLowerCase())
206
- ), u = /* @__PURE__ */ new Set(), h = [];
207
- return t.forEach((d) => {
208
- const I = d.toLowerCase();
209
- !d || r.has(I) || l.has(I) || u.has(I) || (h.push({ name: d }), u.add(I));
210
- }), h.length ? [...h, ...n] : n;
203
+ J((t) => {
204
+ const u = new Set(
205
+ t.map((C) => C.name.toLowerCase())
206
+ ), h = /* @__PURE__ */ new Set(), p = [];
207
+ return n.forEach((C) => {
208
+ const A = C.toLowerCase();
209
+ !C || r.has(A) || u.has(A) || h.has(A) || (p.push({ name: C }), h.add(A));
210
+ }), p.length ? [...p, ...t] : t;
211
211
  });
212
212
  },
213
- [p, M]
213
+ [f, H]
214
214
  );
215
- b(() => {
216
- N(C);
217
- }, [C, N]);
218
- const K = a(
215
+ S(() => {
216
+ j(V);
217
+ }, [V, j]);
218
+ const X = a(
219
219
  (e) => {
220
220
  if (!o)
221
- if (g(), T(e), e === f.Variable) {
221
+ if (g(), T(e), e === m.Variable) {
222
222
  if (s.current) {
223
- const { state: t } = s.current, r = t.selection.main.from, n = s.current.coordsAtPos(r);
224
- n && z({
225
- x: n.left,
226
- y: n.bottom
223
+ const { state: n } = s.current, r = n.selection.main.from, t = s.current.coordsAtPos(r);
224
+ t && z({
225
+ x: t.left,
226
+ y: t.bottom
227
227
  });
228
228
  }
229
- j(!0);
229
+ y(!0);
230
230
  } else
231
231
  E(!0);
232
232
  },
@@ -234,10 +234,10 @@ const Ve = [], Ce = (C, p) => {
234
234
  ), P = a(
235
235
  (e) => {
236
236
  if (o || !s.current) return;
237
- const { state: t, dispatch: r } = s.current, n = t.selection.main.from;
237
+ const { state: n, dispatch: r } = s.current, t = n.selection.main.from;
238
238
  r({
239
- changes: { from: n, insert: e },
240
- selection: { anchor: n + e.length }
239
+ changes: { from: t, insert: e },
240
+ selection: { anchor: t + e.length }
241
241
  });
242
242
  },
243
243
  [s, o]
@@ -245,10 +245,10 @@ const Ve = [], Ce = (C, p) => {
245
245
  (e) => {
246
246
  if (o || !s.current)
247
247
  return;
248
- const { state: t, dispatch: r } = s.current, n = t.selection.main;
248
+ const { state: n, dispatch: r } = s.current, t = n.selection.main;
249
249
  r({
250
- changes: { from: n.from, to: n.to, insert: e },
251
- selection: { anchor: n.from + e.length }
250
+ changes: { from: t.from, to: t.to, insert: e },
251
+ selection: { anchor: t.from + e.length }
252
252
  });
253
253
  },
254
254
  [o]
@@ -262,180 +262,184 @@ const Ve = [], Ce = (C, p) => {
262
262
  v?.(e);
263
263
  return;
264
264
  }
265
- const t = s.current, { state: r, dispatch: n } = t;
266
- n({
265
+ const n = s.current, { state: r, dispatch: t } = n;
266
+ t({
267
267
  changes: { from: 0, to: r.doc.length, insert: e },
268
268
  selection: { anchor: e.length }
269
269
  });
270
270
  },
271
271
  [o, v]
272
- ), le = a(() => {
273
- if (o || !m || !s.current || m.from === -1)
272
+ ), F = a(() => {
273
+ if (o || !c || !s.current || c.from === -1)
274
274
  return;
275
- const { from: e, to: t } = m, { dispatch: r } = s.current;
275
+ const { from: e, to: n } = c, { dispatch: r } = s.current;
276
276
  r({
277
- changes: { from: e, to: t, insert: "" }
277
+ changes: { from: e, to: n, insert: "" }
278
278
  });
279
- }, [m, s, o]), U = a(
280
- (e, t, r = !1) => {
279
+ }, [c, s, o]), D = a(
280
+ (e, n, r = !1) => {
281
281
  if (o || !s.current)
282
282
  return;
283
- const n = s.current, { state: l, dispatch: u } = n, h = t ?? l.selection.main, d = dt(e), I = r ? d.length : 2 + e.length;
284
- u({
283
+ const t = s.current, { state: u, dispatch: h } = t, p = n ?? u.selection.main, C = ht(e), A = r ? C.length : 2 + e.length;
284
+ h({
285
285
  changes: {
286
- from: h.from,
287
- to: h.to,
288
- insert: d
286
+ from: p.from,
287
+ to: p.to,
288
+ insert: C
289
289
  },
290
290
  selection: {
291
- anchor: h.from + I
291
+ anchor: p.from + A
292
292
  }
293
- }), n.focus();
293
+ }), t.focus();
294
294
  },
295
295
  [o]
296
- ), ye = a(() => {
297
- o || (g(), U(""));
298
- }, [g, o, U]), Le = a(() => {
296
+ ), Te = a(() => {
297
+ o || (g(), D(""));
298
+ }, [g, o, D]), ke = a(() => {
299
299
  if (o || !s.current)
300
300
  return;
301
- const e = s.current, { state: t, dispatch: r } = e, n = t.selection.main;
301
+ const e = s.current, { state: n, dispatch: r } = e, t = n.selection.main;
302
302
  r({
303
303
  changes: {
304
- from: n.from,
305
- to: n.to,
304
+ from: t.from,
305
+ to: t.to,
306
306
  insert: "======"
307
307
  },
308
308
  selection: {
309
- anchor: n.from + 3
309
+ anchor: t.from + 3
310
310
  }
311
311
  }), e.focus();
312
- }, [o]), Oe = a(() => {
312
+ }, [o]), Le = a(() => {
313
313
  if (o || !s.current)
314
314
  return;
315
- const e = s.current, { state: t, dispatch: r } = e, n = t.selection.main;
315
+ const e = s.current, { state: n, dispatch: r } = e, t = n.selection.main;
316
316
  r({
317
317
  changes: {
318
- from: n.from,
319
- to: n.to,
318
+ from: t.from,
319
+ to: t.to,
320
320
  insert: "[]()"
321
321
  },
322
322
  selection: {
323
- anchor: n.from + 1
323
+ anchor: t.from + 1
324
324
  }
325
325
  }), e.focus();
326
- }, [o]), je = a(() => {
326
+ }, [o]), Oe = a(() => {
327
327
  if (o || !s.current)
328
328
  return;
329
- const e = s.current, { state: t, dispatch: r } = e, n = t.selection.main;
329
+ const e = s.current, { state: n, dispatch: r } = e, t = n.selection.main;
330
330
  r({
331
331
  changes: {
332
- from: n.from,
333
- to: n.to,
332
+ from: t.from,
333
+ to: t.to,
334
334
  insert: "?[]"
335
335
  },
336
336
  selection: {
337
- anchor: n.from + 2
337
+ anchor: t.from + 2
338
338
  }
339
339
  }), e.focus();
340
- }, [o]), Ne = a(() => {
340
+ }, [o]), ye = a(() => {
341
341
  if (o || !s.current)
342
342
  return;
343
- const e = s.current, { state: t, dispatch: r } = e, n = t.selection.main, l = V.singleChoiceOption1, u = V.singleChoiceOption2, h = `?[%{{}} ${l} | ${u}]`;
343
+ const e = s.current, { state: n, dispatch: r } = e, t = n.selection.main, u = d.singleChoiceOption1, h = d.singleChoiceOption2, p = `?[%{{}} ${u} | ${h}]`;
344
344
  r({
345
345
  changes: {
346
- from: n.from,
347
- to: n.to,
348
- insert: h
346
+ from: t.from,
347
+ to: t.to,
348
+ insert: p
349
349
  },
350
350
  selection: {
351
- anchor: n.from + 5
351
+ anchor: t.from + 5
352
352
  }
353
353
  }), e.focus();
354
354
  }, [
355
355
  o,
356
- V.singleChoiceOption1,
357
- V.singleChoiceOption2
358
- ]), Pe = a(() => {
356
+ d.singleChoiceOption1,
357
+ d.singleChoiceOption2
358
+ ]), je = a(() => {
359
359
  if (o || !s.current)
360
360
  return;
361
- const e = s.current, { state: t, dispatch: r } = e, n = t.selection.main, l = V.singleChoiceOption1, u = V.singleChoiceOption2, h = `?[%{{}} ${l} || ${u}]`;
361
+ const e = s.current, { state: n, dispatch: r } = e, t = n.selection.main, u = d.singleChoiceOption1, h = d.singleChoiceOption2, p = `?[%{{}} ${u} || ${h}]`;
362
362
  r({
363
363
  changes: {
364
- from: n.from,
365
- to: n.to,
366
- insert: h
364
+ from: t.from,
365
+ to: t.to,
366
+ insert: p
367
367
  },
368
368
  selection: {
369
- anchor: n.from + 5
369
+ anchor: t.from + 5
370
370
  }
371
371
  }), e.focus();
372
372
  }, [
373
373
  o,
374
- V.singleChoiceOption1,
375
- V.singleChoiceOption2
376
- ]), $e = a(() => {
374
+ d.singleChoiceOption1,
375
+ d.singleChoiceOption2
376
+ ]), Pe = a(() => {
377
377
  if (o || !s.current)
378
378
  return;
379
- const e = s.current, { state: t, dispatch: r } = e, n = t.selection.main, u = `?[%{{}}...${V.inputPlaceholder ?? "请输入"}]`;
379
+ const e = s.current, { state: n, dispatch: r } = e, t = n.selection.main, h = `?[%{{}}...${d.inputPlaceholder ?? "请输入"}]`;
380
380
  r({
381
381
  changes: {
382
- from: n.from,
383
- to: n.to,
384
- insert: u
382
+ from: t.from,
383
+ to: t.to,
384
+ insert: h
385
385
  },
386
386
  selection: {
387
- anchor: n.from + 5
387
+ anchor: t.from + 5
388
388
  }
389
389
  }), e.focus();
390
- }, [o, V.inputPlaceholder]), Ae = a(
390
+ }, [o, d.inputPlaceholder]), Ne = a(
391
391
  ({
392
392
  resourceUrl: e,
393
- resourceTitle: t,
393
+ resourceTitle: n,
394
394
  scalePercent: r
395
395
  }) => {
396
396
  if (!e || o) return;
397
- const n = e.replace(/"/g, "&quot;"), l = typeof r == "number" ? Math.max(1, Math.min(1e3, Math.round(r))) : void 0, u = t?.replace(/"/g, "&quot;"), d = t ? ((X) => X.replace(/([\[\]\\])/g, "\\$1"))(t) : "", I = typeof l == "number" && l !== 100 ? ` width="${l}%"` : "", qe = u ? ` alt="${u}" title="${u}"` : "", de = !l || l === 100 ? `![${d}](${e})` : `<img src="${n}"${qe}${I} />`;
398
- if (m?.type === f.Image) {
399
- if (le(), !s.current) return;
400
- const { dispatch: X } = s.current;
401
- X({
402
- changes: { from: m.from, insert: de }
397
+ const t = tt({
398
+ resourceUrl: e,
399
+ resourceTitle: n,
400
+ scalePercent: r
401
+ });
402
+ if (c?.type === m.Image) {
403
+ if (F(), !s.current) return;
404
+ const { dispatch: u } = s.current;
405
+ u({
406
+ changes: { from: c.from, insert: t }
403
407
  });
404
408
  } else
405
- P(de);
409
+ P(t);
406
410
  E(!1);
407
411
  },
408
- [P, S, o]
409
- ), ze = a(
412
+ [F, o, P, c]
413
+ ), Ae = a(
410
414
  ({
411
415
  resourceUrl: e,
412
- resourceTitle: t
416
+ resourceTitle: n
413
417
  }) => {
414
418
  if (o)
415
419
  return;
416
- const r = rt(e, t);
417
- if (m?.type === f.Video) {
418
- if (le(), !s.current) return;
419
- const { dispatch: n } = s.current;
420
- n({
421
- changes: { from: m.from, insert: r }
420
+ const r = nt(e, n);
421
+ if (c?.type === m.Video) {
422
+ if (F(), !s.current) return;
423
+ const { dispatch: t } = s.current;
424
+ t({
425
+ changes: { from: c.from, insert: r }
422
426
  });
423
427
  } else
424
428
  P(r);
425
429
  E(!1);
426
430
  },
427
- [P, S, o]
428
- ), ce = a(
431
+ [F, o, P, c]
432
+ ), le = a(
429
433
  (e) => {
430
434
  if (o)
431
435
  return;
432
- const t = m?.type === f.Variable ? { from: m.from, to: m.to } : void 0;
433
- U(e.name, t, !0), j(!1), g();
436
+ const n = c?.type === m.Variable ? { from: c.from, to: c.to } : void 0;
437
+ D(e.name, n, !0), y(!1), g();
434
438
  },
435
- [o, U, m, g]
436
- ), ue = a(() => Ue({
439
+ [o, D, c, g]
440
+ ), ce = a(() => He({
437
441
  override: [
438
- st(K, {
442
+ ot(X, {
439
443
  // divider: currentStrings.slashDivider,
440
444
  // fixedText: currentStrings.slashFixedText,
441
445
  image: O.slashImage,
@@ -449,84 +453,84 @@ const Ve = [], Ce = (C, p) => {
449
453
  O.slashImage,
450
454
  O.slashVideo,
451
455
  O.slashVariable,
452
- K
453
- ]), me = a(
456
+ X
457
+ ]), ue = a(
454
458
  (e) => {
455
- if (s.current = e.view, p === "quickEdit" && q.current && e.selectionSet) {
456
- const t = e.state.selection.main.head, r = e.state.doc.toString();
457
- Ce(
459
+ if (s.current = e.view, f === "quickEdit" && U.current && e.selectionSet) {
460
+ const n = e.state.selection.main.head, r = e.state.doc.toString();
461
+ de(
458
462
  r,
459
- t
460
- ) || (N(r), q.current = null);
463
+ n
464
+ ) || (j(r), U.current = null);
461
465
  }
462
466
  },
463
- [N, p]
464
- ), fe = a(
467
+ [j, f]
468
+ ), me = a(
465
469
  (e) => {
466
470
  if (e.stopPropagation(), o)
467
471
  return;
468
- const { type: t, from: r, to: n, dataset: l, target: u } = e.detail, h = it(t, l);
469
- if (R({
470
- type: t,
471
- value: h,
472
+ const { type: n, from: r, to: t, dataset: u, target: h } = e.detail, p = rt(n, u);
473
+ if (B({
474
+ type: n,
475
+ value: p,
472
476
  from: r,
473
- to: n
474
- }), T(t), t === f.Variable) {
475
- if (u) {
476
- const d = u.getBoundingClientRect();
477
+ to: t
478
+ }), T(n), n === m.Variable) {
479
+ if (h) {
480
+ const C = h.getBoundingClientRect();
477
481
  z({
478
- x: d.left,
479
- y: d.bottom
482
+ x: C.left,
483
+ y: C.bottom
480
484
  });
481
485
  }
482
- j(!0);
486
+ y(!0);
483
487
  } else
484
488
  E(!0);
485
489
  },
486
490
  [o]
487
491
  );
488
- b(() => {
489
- Q || (T(f.Empty), R(null));
490
- }, [Q]), b(() => {
491
- !Y && S === f.Variable && (T(f.Empty), R(null));
492
- }, [Y, S]), b(() => {
493
- const e = (t) => {
494
- t.detail.view === s.current && fe(t);
492
+ S(() => {
493
+ Y || (T(m.Empty), B(null));
494
+ }, [Y]), S(() => {
495
+ !_ && b === m.Variable && (T(m.Empty), B(null));
496
+ }, [_, b]), S(() => {
497
+ const e = (n) => {
498
+ n.detail.view === s.current && me(n);
495
499
  };
496
500
  return window.addEventListener("globalTagClick", e), () => {
497
501
  window.removeEventListener("globalTagClick", e);
498
502
  };
499
- }, [fe]);
500
- const Re = y(() => {
503
+ }, [me]);
504
+ const Re = k(() => {
501
505
  const e = [
502
- ge.lineWrapping,
503
- Fe(),
504
- De(Ge),
505
- mt
506
+ pe.lineWrapping,
507
+ Ue(),
508
+ qe(Fe),
509
+ ct
506
510
  ];
507
- return o || e.push(ue()), p === "quickEdit" && e.push(
508
- lt,
509
- ct,
510
- ut
511
+ return o || e.push(ce()), f === "quickEdit" && e.push(
512
+ it,
513
+ at,
514
+ lt
511
515
  // fixedTextPlaceholderExtension,
512
516
  // DividerPlaceholder,
513
517
  ), e.push(
514
- ge.updateListener.of((t) => {
515
- me(t);
518
+ pe.updateListener.of((n) => {
519
+ ue(n);
516
520
  })
517
521
  ), e;
518
- }, [o, p, ue, me]), Be = a(
522
+ }, [o, f, ce, ue]), ze = a(
519
523
  (e) => {
520
524
  if (o)
521
525
  return;
522
- const t = s.current?.state.selection.main.head ?? -1;
523
- Ce(
526
+ const n = s.current?.state.selection.main.head ?? -1;
527
+ de(
524
528
  e,
525
- t
526
- ) ? q.current = e : (q.current = null, N(e)), v?.(e);
529
+ n
530
+ ) ? U.current = e : (U.current = null, j(e)), v?.(e);
527
531
  },
528
- [N, v, o]
529
- ), he = !o && J, $ = y(
532
+ [j, v, o]
533
+ ), fe = !o && K, N = k(
530
534
  () => ({
531
535
  insertTextAtCursor: P,
532
536
  replaceSelection: re,
@@ -535,92 +539,92 @@ const Ve = [], Ce = (C, p) => {
535
539
  setContent: ae
536
540
  }),
537
541
  [se, ie, P, re, ae]
538
- ), pe = a(
542
+ ), he = a(
539
543
  (e) => {
540
- o || "render" in e || e.onClick?.($);
544
+ o || "render" in e || e.onClick?.(N);
541
545
  },
542
- [o, $]
543
- ), Me = y(() => G?.length ? /* @__PURE__ */ c.jsx("div", { className: "markdown-flow-editor-toolbar-right", children: G.map((e) => {
546
+ [o, N]
547
+ ), Be = k(() => W?.length ? /* @__PURE__ */ l.jsx("div", { className: "markdown-flow-editor-toolbar-right", children: W.map((e) => {
544
548
  if ("render" in e)
545
- return /* @__PURE__ */ c.jsx(
549
+ return /* @__PURE__ */ l.jsx(
546
550
  "div",
547
551
  {
548
552
  className: "markdown-flow-editor-toolbar-right-item",
549
- children: e.render($)
553
+ children: e.render(N)
550
554
  },
551
555
  e.key
552
556
  );
553
- const t = e.label || e.tooltip || void 0, r = /* @__PURE__ */ c.jsxs(
557
+ const n = e.label || e.tooltip || void 0, r = /* @__PURE__ */ l.jsxs(
554
558
  "button",
555
559
  {
556
560
  type: "button",
557
561
  disabled: o || e.disabled,
558
- onClick: () => pe(e),
562
+ onClick: () => he(e),
559
563
  className: "markdown-flow-editor-toolbar-right-button",
560
- "aria-label": t,
564
+ "aria-label": n,
561
565
  title: e.label || e.tooltip,
562
566
  children: [
563
- e.icon ? /* @__PURE__ */ c.jsx("span", { className: "toolbar-right-icon", children: e.icon }) : null,
564
- e.label ? /* @__PURE__ */ c.jsx("span", { className: "toolbar-right-label", children: e.label }) : null
567
+ e.icon ? /* @__PURE__ */ l.jsx("span", { className: "toolbar-right-icon", children: e.icon }) : null,
568
+ e.label ? /* @__PURE__ */ l.jsx("span", { className: "toolbar-right-label", children: e.label }) : null
565
569
  ]
566
570
  },
567
571
  e.key
568
- ), n = e.tooltip ? /* @__PURE__ */ c.jsxs(We, { children: [
569
- /* @__PURE__ */ c.jsx(Qe, { asChild: !0, children: r }),
570
- /* @__PURE__ */ c.jsx(Ye, { side: "top", children: e.tooltip })
572
+ ), t = e.tooltip ? /* @__PURE__ */ l.jsxs(De, { children: [
573
+ /* @__PURE__ */ l.jsx(Ge, { asChild: !0, children: r }),
574
+ /* @__PURE__ */ l.jsx(Me, { side: "top", children: e.tooltip })
571
575
  ] }) : r;
572
- return /* @__PURE__ */ c.jsx(
576
+ return /* @__PURE__ */ l.jsx(
573
577
  "div",
574
578
  {
575
579
  className: "markdown-flow-editor-toolbar-right-item",
576
- children: n
580
+ children: t
577
581
  },
578
582
  e.key
579
583
  );
580
- }) }) : null, [o, $, pe, G]);
581
- return b(() => {
582
- be?.($);
583
- }, [$]), /* @__PURE__ */ c.jsxs(
584
+ }) }) : null, [o, N, he, W]);
585
+ return S(() => {
586
+ Ve?.(N);
587
+ }, [N]), /* @__PURE__ */ l.jsxs(
584
588
  "div",
585
589
  {
586
590
  className: "markdown-flow-editor",
587
591
  "data-disabled": o ? "true" : void 0,
588
592
  "aria-disabled": o,
589
593
  children: [
590
- /* @__PURE__ */ c.jsx(
591
- Ke,
594
+ /* @__PURE__ */ l.jsx(
595
+ Ye,
592
596
  {
593
597
  disabled: o,
594
- labels: V,
595
- onSelect: K,
596
- onInsertVariablePlaceholder: ye,
597
- onVariableSearchToggle: Ee,
598
+ labels: d,
599
+ onSelect: X,
600
+ onInsertVariablePlaceholder: Te,
601
+ onVariableSearchToggle: we,
598
602
  onVariableSearchClose: g,
599
- onInsertConfirmOutput: Le,
600
- onInsertLink: Oe,
601
- onInsertButton: je,
602
- onInsertSingleChoice: Ne,
603
- onInsertMultiChoice: Pe,
604
- onInsertInputField: $e,
605
- variableSearchActive: he,
606
- rightSlot: Me
603
+ onInsertConfirmOutput: ke,
604
+ onInsertLink: Le,
605
+ onInsertButton: Oe,
606
+ onInsertSingleChoice: ye,
607
+ onInsertMultiChoice: je,
608
+ onInsertInputField: Pe,
609
+ variableSearchActive: fe,
610
+ rightSlot: Be
607
611
  }
608
612
  ),
609
- /* @__PURE__ */ c.jsx(
610
- Xe,
613
+ /* @__PURE__ */ l.jsx(
614
+ _e,
611
615
  {
612
- open: he,
613
- anchorElement: H.current,
616
+ open: fe,
617
+ anchorElement: q.current,
614
618
  onClose: g,
615
- onSelect: ce,
619
+ onSelect: le,
616
620
  variables: ne,
617
- systemVariables: M,
618
- labels: xe
621
+ systemVariables: H,
622
+ labels: be
619
623
  }
620
624
  ),
621
- /* @__PURE__ */ c.jsx("div", { className: "markdown-flow-editor-body relative overflow-auto", children: /* @__PURE__ */ c.jsxs(Ze.Provider, { value: Te, children: [
622
- /* @__PURE__ */ c.jsx(
623
- He,
625
+ /* @__PURE__ */ l.jsx("div", { className: "markdown-flow-editor-body relative overflow-auto", children: /* @__PURE__ */ l.jsxs(Je.Provider, { value: Ee, children: [
626
+ /* @__PURE__ */ l.jsx(
627
+ $e,
624
628
  {
625
629
  extensions: Re,
626
630
  basicSetup: {
@@ -631,53 +635,53 @@ const Ve = [], Ce = (C, p) => {
631
635
  foldGutter: !1
632
636
  },
633
637
  className: "rounded-md",
634
- placeholder: we,
635
- value: C,
638
+ placeholder: Ie,
639
+ value: V,
636
640
  theme: "light",
637
641
  minHeight: "2rem",
638
642
  editable: !o,
639
- onChange: Be,
640
- onBlur: F
643
+ onChange: ze,
644
+ onBlur: G
641
645
  }
642
646
  ),
643
- !o && /* @__PURE__ */ c.jsxs(
644
- _e,
647
+ !o && /* @__PURE__ */ l.jsxs(
648
+ We,
645
649
  {
646
650
  labels: {
647
- title: S === f.Image ? i("dialogTitleImage") : S === f.Video ? i("dialogTitleVideo") : S === f.Variable ? i("dialogTitleVariable") : i("dialogTitle")
651
+ title: b === m.Image ? i("dialogTitleImage") : b === m.Video ? i("dialogTitleVideo") : b === m.Variable ? i("dialogTitleVariable") : i("dialogTitle")
648
652
  },
649
653
  children: [
650
- S === f.Image && /* @__PURE__ */ c.jsx(
651
- et,
654
+ b === m.Image && /* @__PURE__ */ l.jsx(
655
+ Ke,
652
656
  {
653
- value: m?.value,
654
- onSelect: Ae,
655
- uploadProps: D
657
+ value: c?.value,
658
+ onSelect: Ne,
659
+ uploadProps: M
656
660
  }
657
661
  ),
658
- S === f.Video && /* @__PURE__ */ c.jsx(
659
- tt,
662
+ b === m.Video && /* @__PURE__ */ l.jsx(
663
+ Xe,
660
664
  {
661
- value: m?.value,
662
- onSelect: ze
665
+ value: c?.value,
666
+ onSelect: Ae
663
667
  }
664
668
  )
665
669
  ]
666
670
  }
667
671
  ),
668
- !o && /* @__PURE__ */ c.jsx(Je, { children: /* @__PURE__ */ c.jsx(
669
- nt,
672
+ !o && /* @__PURE__ */ l.jsx(Qe, { children: /* @__PURE__ */ l.jsx(
673
+ Ze,
670
674
  {
671
675
  variables: ne,
672
- systemVariables: M,
673
- selectedName: m?.value?.variableName,
674
- onSelect: ce,
676
+ systemVariables: H,
677
+ selectedName: c?.value?.variableName,
678
+ onSelect: le,
675
679
  onAddVariable: (e) => {
676
- _((t) => {
680
+ J((n) => {
677
681
  const r = e.name.toLowerCase();
678
- return t.some(
679
- (l) => l.name.toLowerCase() === r
680
- ) ? t : [e, ...t];
682
+ return n.some(
683
+ (u) => u.name.toLowerCase() === r
684
+ ) ? n : [e, ...n];
681
685
  });
682
686
  }
683
687
  }
@@ -688,6 +692,6 @@ const Ve = [], Ce = (C, p) => {
688
692
  );
689
693
  };
690
694
  export {
691
- Dt as default
695
+ Ft as default
692
696
  };
693
697
  //# sourceMappingURL=MarkdownFlowEditor.es.js.map