dishui 0.0.105 → 0.0.108

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 (64) hide show
  1. package/dist/.release-verified.json +2 -2
  2. package/dist/components/ChoicePicker/index.js +8 -6
  3. package/dist/components/ChoicePicker/index.js.map +1 -1
  4. package/dist/components/Column/index.d.ts +3 -2
  5. package/dist/components/Column/index.js +5 -17
  6. package/dist/components/Column/index.js.map +1 -1
  7. package/dist/components/ConfirmDialog/index.d.ts +20 -0
  8. package/dist/components/ConfirmDialog/index.js +84 -0
  9. package/dist/components/ConfirmDialog/index.js.map +1 -0
  10. package/dist/components/DateTimeInput/index.js +28 -26
  11. package/dist/components/DateTimeInput/index.js.map +1 -1
  12. package/dist/components/Input/index.js +1 -1
  13. package/dist/components/Input/index.js.map +1 -1
  14. package/dist/components/MultipleChoice/index.js +2 -1
  15. package/dist/components/MultipleChoice/index.js.map +1 -1
  16. package/dist/components/Row/index.d.ts +3 -2
  17. package/dist/components/Row/index.js +5 -17
  18. package/dist/components/Row/index.js.map +1 -1
  19. package/dist/components/Tab/index.js +80 -0
  20. package/dist/components/Tab/index.js.map +1 -0
  21. package/dist/components/Tabs/index.js +28 -33
  22. package/dist/components/Tabs/index.js.map +1 -1
  23. package/dist/components/Tabs/tabNavigation.d.ts +2 -0
  24. package/dist/components/Tabs/tabNavigation.js +14 -0
  25. package/dist/components/Tabs/tabNavigation.js.map +1 -0
  26. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.d.ts +1 -1
  27. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js +25 -26
  28. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js.map +1 -1
  29. package/dist/components/pro/FileExplorer/Breadcrumb.js +8 -11
  30. package/dist/components/pro/FileExplorer/Breadcrumb.js.map +1 -1
  31. package/dist/components/pro/Flow/Flow.js +184 -182
  32. package/dist/components/pro/Flow/Flow.js.map +1 -1
  33. package/dist/components/pro/Flow/archify/convert.js +26 -26
  34. package/dist/components/pro/Flow/archify/convert.js.map +1 -1
  35. package/dist/components/pro/Flow/hooks/useLayoutActions.js +13 -11
  36. package/dist/components/pro/Flow/hooks/useLayoutActions.js.map +1 -1
  37. package/dist/components/pro/RichTextEditor/AIRewrite.d.ts +1 -0
  38. package/dist/components/pro/RichTextEditor/AIRewrite.js +109 -88
  39. package/dist/components/pro/RichTextEditor/AIRewrite.js.map +1 -1
  40. package/dist/components/pro/RichTextEditor/BubbleToolbar.js +73 -83
  41. package/dist/components/pro/RichTextEditor/BubbleToolbar.js.map +1 -1
  42. package/dist/components/pro/RichTextEditor/RichTextEditor.js +133 -132
  43. package/dist/components/pro/RichTextEditor/RichTextEditor.js.map +1 -1
  44. package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.d.ts +2 -0
  45. package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js +73 -49
  46. package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js.map +1 -1
  47. package/dist/components/pro/RichTextEditor/Toolbar/SelectDropdown.d.ts +1 -0
  48. package/dist/components/pro/RichTextEditor/Toolbar/SelectDropdown.js +12 -14
  49. package/dist/components/pro/RichTextEditor/Toolbar/SelectDropdown.js.map +1 -1
  50. package/dist/components/pro/RichTextEditor/extensions/CodeBlockView.js +113 -113
  51. package/dist/components/pro/RichTextEditor/extensions/CodeBlockView.js.map +1 -1
  52. package/dist/components/pro/RichTextEditor/types.d.ts +2 -0
  53. package/dist/components/pro/RichTextEditor/types.js.map +1 -1
  54. package/dist/css.d.ts +1 -0
  55. package/dist/dishui.css +1 -1
  56. package/dist/index-nostyled.d.ts +2 -0
  57. package/dist/index.d.ts +4 -0
  58. package/dist/index.js +113 -111
  59. package/dist/layouts/Sidebar.js +201 -107
  60. package/dist/layouts/Sidebar.js.map +1 -1
  61. package/dist/utils/flexLayout.d.ts +5 -0
  62. package/dist/utils/flexLayout.js +19 -0
  63. package/dist/utils/flexLayout.js.map +1 -0
  64. package/package.json +63 -57
@@ -19,19 +19,19 @@ import { MediaOverlay as T } from "./nodes/MediaOverlay.js";
19
19
  import E from "./panels/FlowPanelGroup.js";
20
20
  import D from "./panels/Breadcrumb.js";
21
21
  import O from "./panels/ContextMenu.js";
22
- import { MiniMapRenderer as k } from "./canvas/MiniMapRenderer.js";
23
- import { useUndoRedo as ee } from "./hooks/useUndoRedo.js";
24
- import { useClipboard as A } from "./hooks/useClipboard.js";
25
- import { useCompactMode as te } from "./hooks/useCompactMode.js";
26
- import { usePdfExport as j } from "./hooks/usePdfExport.js";
27
- import { useKeyboardShortcuts as M } from "./hooks/useKeyboardShortcuts.js";
28
- import { useMindMap as N } from "./hooks/useMindMap.js";
22
+ import { MiniMapRenderer as ee } from "./canvas/MiniMapRenderer.js";
23
+ import { useUndoRedo as te } from "./hooks/useUndoRedo.js";
24
+ import { useClipboard as k } from "./hooks/useClipboard.js";
25
+ import { useCompactMode as ne } from "./hooks/useCompactMode.js";
26
+ import { usePdfExport as A } from "./hooks/usePdfExport.js";
27
+ import { useKeyboardShortcuts as j } from "./hooks/useKeyboardShortcuts.js";
28
+ import { useMindMap as M } from "./hooks/useMindMap.js";
29
29
  /* empty css */
30
- import { forwardRef as P, useCallback as F, useEffect as I, useImperativeHandle as ne, useMemo as L, useRef as R, useState as z } from "react";
31
- import { jsx as B, jsxs as V } from "react/jsx-runtime";
32
- import { EditorView as H } from "@codemirror/view";
30
+ import { forwardRef as N, useCallback as P, useEffect as F, useImperativeHandle as re, useMemo as I, useRef as L, useState as R } from "react";
31
+ import { jsx as z, jsxs as B } from "react/jsx-runtime";
32
+ import { EditorView as V } from "@codemirror/view";
33
33
  //#region src/components/pro/Flow/Flow.tsx
34
- function re(e) {
34
+ function ie(e) {
35
35
  let t = !1, n = { ...e.canvases };
36
36
  for (let [e, r] of Object.entries(n)) {
37
37
  let i = r.nodes.map((e) => {
@@ -79,19 +79,19 @@ function re(e) {
79
79
  canvases: n
80
80
  } : e;
81
81
  }
82
- var ie = {
82
+ var ae = {
83
83
  nodeIds: /* @__PURE__ */ new Set(),
84
84
  edgeIds: /* @__PURE__ */ new Set(),
85
85
  lineIds: /* @__PURE__ */ new Set()
86
86
  };
87
- function ae({ onUndo: e, onRedo: t, groupRef: r, geoGroupRef: i, ungroupRef: a }) {
88
- let { selection: s, setSelection: l, currentCanvas: d, setDoc: p, currentCanvasId: m } = o(), { viewport: h } = c(), { copy: g, cut: _, paste: v, duplicate: y } = A(), b = f(), x = F(() => {
87
+ function oe({ onUndo: e, onRedo: t, groupRef: r, geoGroupRef: i, ungroupRef: a }) {
88
+ let { selection: s, setSelection: l, currentCanvas: d, setDoc: p, currentCanvasId: m } = o(), { viewport: h } = c(), { copy: g, cut: _, paste: v, duplicate: y } = k(), b = f(), x = P(() => {
89
89
  l({
90
90
  nodeIds: new Set(d.nodes.map((e) => e.id)),
91
91
  edgeIds: new Set(d.edges.map((e) => e.id)),
92
92
  lineIds: new Set(d.lines.map((e) => e.id))
93
93
  });
94
- }, [d, l]), S = F((e) => {
94
+ }, [d, l]), S = P((e) => {
95
95
  let t = s.nodeIds, r = s.lineIds;
96
96
  if (t.size + r.size < 2) return;
97
97
  let i = d.nodes.filter((e) => t.has(e.id)), a = d.lines.filter((e) => r.has(e.id)), o = Infinity, c = Infinity, f = -Infinity, h = -Infinity;
@@ -146,7 +146,7 @@ function ae({ onUndo: e, onRedo: t, groupRef: r, geoGroupRef: i, ungroupRef: a }
146
146
  p,
147
147
  m,
148
148
  l
149
- ]), C = F(() => S("flowGroup"), [S]), w = F(() => S("geometryGroup"), [S]), T = F(() => {
149
+ ]), C = P(() => S("flowGroup"), [S]), w = P(() => S("geometryGroup"), [S]), T = P(() => {
150
150
  let e = s.nodeIds;
151
151
  if (e.size === 0) return;
152
152
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
@@ -187,25 +187,27 @@ function ae({ onUndo: e, onRedo: t, groupRef: r, geoGroupRef: i, ungroupRef: a }
187
187
  l
188
188
  ]);
189
189
  r.current = C, i.current = w, a.current = T;
190
- let E = F((e) => {
190
+ let E = P((e) => {
191
191
  let t = s.nodeIds, n = s.lineIds;
192
- (t.size !== 0 || n.size !== 0) && p((r) => {
193
- let i = r.canvases[m];
194
- if (!i) return r;
195
- let a = i.nodes.map((e) => e.zIndex ?? 0), o = a.length > 0 ? Math.max(...a) : 0, s = a.length > 0 ? Math.min(...a) : 0, c = i.lines.map((e) => e.zIndex ?? 0), l = c.length > 0 ? Math.max(...c) : 0, u = c.length > 0 ? Math.min(...c) : 0, d = (t, n, r) => e === "front" ? n + 1 : e === "back" ? r - 1 : e === "up" ? t + 1 : t - 1;
192
+ if (t.size === 0 && n.size === 0) return;
193
+ let r = (t, n, r) => e === "front" ? n + 1 : e === "back" ? r - 1 : e === "up" ? t + 1 : t - 1;
194
+ p((e) => {
195
+ let i = e.canvases[m];
196
+ if (!i) return e;
197
+ let a = i.nodes.map((e) => e.zIndex ?? 0), o = a.length > 0 ? Math.max(...a) : 0, s = a.length > 0 ? Math.min(...a) : 0, c = i.lines.map((e) => e.zIndex ?? 0), l = c.length > 0 ? Math.max(...c) : 0, u = c.length > 0 ? Math.min(...c) : 0;
196
198
  return {
197
- ...r,
199
+ ...e,
198
200
  canvases: {
199
- ...r.canvases,
201
+ ...e.canvases,
200
202
  [m]: {
201
203
  ...i,
202
204
  nodes: i.nodes.map((e) => t.has(e.id) ? {
203
205
  ...e,
204
- zIndex: d(e.zIndex ?? 0, o, s)
206
+ zIndex: r(e.zIndex ?? 0, o, s)
205
207
  } : e),
206
208
  lines: i.lines.map((e) => n.has(e.id) ? {
207
209
  ...e,
208
- zIndex: d(e.zIndex ?? 0, l, u)
210
+ zIndex: r(e.zIndex ?? 0, l, u)
209
211
  } : e)
210
212
  }
211
213
  }
@@ -216,7 +218,7 @@ function ae({ onUndo: e, onRedo: t, groupRef: r, geoGroupRef: i, ungroupRef: a }
216
218
  p,
217
219
  m
218
220
  ]);
219
- I(() => {
221
+ F(() => {
220
222
  let e = (e) => {
221
223
  let t = e.target;
222
224
  if (t?.tagName === "INPUT" || t?.tagName === "TEXTAREA" || t?.isContentEditable) return;
@@ -306,7 +308,7 @@ function ae({ onUndo: e, onRedo: t, groupRef: r, geoGroupRef: i, ungroupRef: a }
306
308
  l,
307
309
  h
308
310
  ]);
309
- let D = L(() => ({
311
+ let D = I(() => ({
310
312
  undo: e,
311
313
  redo: t,
312
314
  copy: g,
@@ -336,54 +338,54 @@ function ae({ onUndo: e, onRedo: t, groupRef: r, geoGroupRef: i, ungroupRef: a }
336
338
  T,
337
339
  E
338
340
  ]);
339
- return M(D), N(), null;
341
+ return j(D), M(), null;
340
342
  }
341
- function oe({ pixiRef: e, exportPdfRef: t }) {
342
- return t.current = j(e), null;
343
+ function se({ pixiRef: e, exportPdfRef: t }) {
344
+ return t.current = A(e), null;
343
345
  }
344
- var U = P(function({ initialDocument: e, onChange: t, width: n, height: r, readOnly: o = !1, onBack: c, onExportPNG: u, onPublish: d, showMiniMap: f = !0, showGrid: v = !0, gridSize: y = 20, className: b, showAI: x = !0, showAIConfig: S = !0, aiConfig: C }, E) {
345
- let [O, A] = z(() => re(e ?? i())), [j, M] = z(ie), N = R(null), P = R(null), L = R(null), H = R(null), U = te(H), { wrappedSetDoc: W, setDocTransient: G, undo: K, redo: q, canUndo: J, canRedo: Y } = ee(O, A), X = R(null), Z = R(null), Q = R(null), de = R(null), fe = R(t);
346
- fe.current = t;
347
- let pe = R(O);
348
- I(() => {
349
- pe.current !== O && (pe.current = O, o || fe.current?.(O));
346
+ var H = N(function({ initialDocument: e, onChange: t, width: n, height: r, readOnly: o = !1, onBack: c, onExportPNG: u, onPublish: d, showMiniMap: f = !0, showGrid: v = !0, gridSize: y = 20, className: b, showAI: x = !0, showAIConfig: S = !0, aiConfig: C }, E) {
347
+ let [O, k] = R(() => ie(e ?? i())), [A, j] = R(ae), M = L(null), N = L(null), I = L(null), V = L(null), H = ne(V), { wrappedSetDoc: U, setDocTransient: W, undo: G, redo: K, canUndo: q, canRedo: J } = te(O, k), Y = L(null), X = L(null), Z = L(null), fe = L(null), pe = L(t);
348
+ pe.current = t;
349
+ let me = L(O);
350
+ F(() => {
351
+ me.current !== O && (me.current = O, o || pe.current?.(O));
350
352
  }, [O, o]);
351
- let $ = R(O);
352
- $.current = O, ne(E, () => ({
353
+ let Q = L(O);
354
+ Q.current = O, re(E, () => ({
353
355
  exportPNG: async (e) => {
354
- let t = N.current;
356
+ let t = M.current;
355
357
  return !t || t.destroyed ? null : t.exportPNG(e);
356
358
  },
357
- getDocument: () => $.current
359
+ getDocument: () => Q.current
358
360
  }), []);
359
- let me = F((e) => {
360
- W((t) => {
361
+ let he = P((e) => {
362
+ U((t) => {
361
363
  let n = typeof e == "function" ? e(t) : e;
362
364
  return o ? n.canvases === t.canvases && n.title === t.title ? n : t : n;
363
365
  });
364
- }, [W, o]), he = F((e) => {
365
- G((t) => {
366
+ }, [U, o]), ge = P((e) => {
367
+ W((t) => {
366
368
  let n = typeof e == "function" ? e(t) : e;
367
369
  return o ? n.canvases === t.canvases && n.title === t.title ? n : t : n;
368
370
  });
369
- }, [G, o]), ge = F(() => {
371
+ }, [W, o]), _e = P(() => {
372
+ o || G();
373
+ }, [o, G]), $ = P(() => {
370
374
  o || K();
371
- }, [o, K]), _e = F(() => {
372
- o || q();
373
- }, [o, q]), ve = F((e) => {
374
- N.current = e, P.current && !L.current && (L.current = new k(P.current));
375
- }, []), ye = F(async () => {
375
+ }, [o, K]), ve = P((e) => {
376
+ M.current = e, N.current && !I.current && (I.current = new ee(N.current));
377
+ }, []), ye = P(async () => {
376
378
  if (u) return void u();
377
- let e = N.current;
379
+ let e = M.current;
378
380
  if (!e || e.destroyed) return;
379
381
  let t = await e.exportPNG(16777215);
380
- t && m(t, `${h($.current.title)}.png`);
381
- }, [u]), be = F(async () => {
382
- await de.current?.();
382
+ t && m(t, `${h(Q.current.title)}.png`);
383
+ }, [u]), be = P(async () => {
384
+ await fe.current?.();
383
385
  }, []);
384
- I(() => {
386
+ F(() => {
385
387
  let e = !1, t = null, n = () => {
386
- let e = N.current, t = L.current;
388
+ let e = M.current, t = I.current;
387
389
  if (!e || e.destroyed || !t) return;
388
390
  let n = {
389
391
  x: e.world.position.x,
@@ -393,8 +395,8 @@ var U = P(function({ initialDocument: e, onChange: t, width: n, height: r, readO
393
395
  i && t.update(i.nodes, n, e.app.screen.width, e.app.screen.height);
394
396
  }, r = () => {
395
397
  if (e) return;
396
- let i = N.current;
397
- i && !i.destroyed && L.current ? (i.app.ticker.add(n), t = i) : requestAnimationFrame(r);
398
+ let i = M.current;
399
+ i && !i.destroyed && I.current ? (i.app.ticker.add(n), t = i) : requestAnimationFrame(r);
398
400
  };
399
401
  return r(), () => {
400
402
  e = !0, t && !t.destroyed && t.app.ticker.remove(n);
@@ -404,64 +406,64 @@ var U = P(function({ initialDocument: e, onChange: t, width: n, height: r, readO
404
406
  width: n ?? "100%",
405
407
  height: r ?? "100%"
406
408
  };
407
- return /* @__PURE__ */ B("div", {
408
- ref: H,
409
+ return /* @__PURE__ */ z("div", {
410
+ ref: V,
409
411
  className: `flow-container ${b ?? ""}`,
410
412
  style: xe,
411
- children: /* @__PURE__ */ B(a, {
413
+ children: /* @__PURE__ */ z(a, {
412
414
  doc: O,
413
- setDoc: me,
414
- setDocTransient: he,
415
- selection: j,
416
- setSelection: M,
417
- children: /* @__PURE__ */ B(s, {
415
+ setDoc: he,
416
+ setDocTransient: ge,
417
+ selection: A,
418
+ setSelection: j,
419
+ children: /* @__PURE__ */ z(s, {
418
420
  showMiniMap: f,
419
421
  showGrid: v,
420
422
  gridSize: y,
421
423
  showAI: x,
422
424
  readOnly: o,
423
- children: /* @__PURE__ */ V(l, {
425
+ children: /* @__PURE__ */ B(l, {
424
426
  initialConfig: C,
425
427
  showAIConfig: S,
426
428
  children: [
427
- /* @__PURE__ */ B(ae, {
428
- onUndo: ge,
429
- onRedo: _e,
430
- groupRef: X,
431
- geoGroupRef: Z,
432
- ungroupRef: Q
429
+ /* @__PURE__ */ z(oe, {
430
+ onUndo: _e,
431
+ onRedo: $,
432
+ groupRef: Y,
433
+ geoGroupRef: X,
434
+ ungroupRef: Z
433
435
  }),
434
- /* @__PURE__ */ B(oe, {
435
- pixiRef: N,
436
- exportPdfRef: de
436
+ /* @__PURE__ */ z(se, {
437
+ pixiRef: M,
438
+ exportPdfRef: fe
437
439
  }),
438
- /* @__PURE__ */ V(ce, {
439
- compact: U,
440
- toolbar: o ? null : /* @__PURE__ */ B(g, {
441
- compact: U,
440
+ /* @__PURE__ */ B(le, {
441
+ compact: H,
442
+ toolbar: o ? null : /* @__PURE__ */ z(g, {
443
+ compact: H,
442
444
  onBack: c,
443
- onUndo: ge,
444
- onRedo: _e,
445
- canUndo: J,
446
- canRedo: Y,
447
- onGroup: () => X.current?.(),
448
- onGeoGroup: () => Z.current?.(),
449
- onUngroup: () => Q.current?.(),
445
+ onUndo: _e,
446
+ onRedo: $,
447
+ canUndo: q,
448
+ canRedo: J,
449
+ onGroup: () => Y.current?.(),
450
+ onGeoGroup: () => X.current?.(),
451
+ onUngroup: () => Z.current?.(),
450
452
  onExportPNG: ye,
451
453
  onExportPDF: be,
452
454
  onPublish: d
453
455
  }),
454
456
  children: [
455
- /* @__PURE__ */ B(p, { onPixiReady: ve }),
456
- /* @__PURE__ */ B(T, {}),
457
- /* @__PURE__ */ V(se, { children: [!o && /* @__PURE__ */ B(_, {}), /* @__PURE__ */ B(D, {})] }),
458
- !o && /* @__PURE__ */ B(ue, {}),
459
- /* @__PURE__ */ B(le, {
460
- canvasRef: P,
461
- pixiRef: N,
462
- miniMapRef: L
457
+ /* @__PURE__ */ z(p, { onPixiReady: ve }),
458
+ /* @__PURE__ */ z(T, {}),
459
+ /* @__PURE__ */ B(ce, { children: [!o && /* @__PURE__ */ z(_, {}), /* @__PURE__ */ z(D, {})] }),
460
+ !o && /* @__PURE__ */ z(de, {}),
461
+ /* @__PURE__ */ z(ue, {
462
+ canvasRef: N,
463
+ pixiRef: M,
464
+ miniMapRef: I
463
465
  }),
464
- /* @__PURE__ */ B(w, {})
466
+ /* @__PURE__ */ z(w, {})
465
467
  ]
466
468
  })
467
469
  ]
@@ -470,15 +472,15 @@ var U = P(function({ initialDocument: e, onChange: t, width: n, height: r, readO
470
472
  })
471
473
  });
472
474
  });
473
- function se({ children: e }) {
475
+ function ce({ children: e }) {
474
476
  let { presentation: t } = c();
475
- return /* @__PURE__ */ B("div", {
477
+ return /* @__PURE__ */ z("div", {
476
478
  className: "flow-overlay",
477
479
  style: { display: t ? "none" : void 0 },
478
480
  children: e
479
481
  });
480
482
  }
481
- var W = [
483
+ var U = [
482
484
  {
483
485
  id: "shapes",
484
486
  label: "Shapes",
@@ -522,43 +524,43 @@ var W = [
522
524
  showKey: "showAI"
523
525
  }
524
526
  ];
525
- function G(e) {
527
+ function W(e) {
526
528
  switch (e) {
527
- case "shapes": return /* @__PURE__ */ B(y, {});
528
- case "icons": return /* @__PURE__ */ B(b, {});
529
- case "media": return /* @__PURE__ */ B(v, {});
530
- case "inspector": return /* @__PURE__ */ B(x, {});
531
- case "outline": return /* @__PURE__ */ B(S, {});
532
- case "json": return /* @__PURE__ */ B(X, {});
533
- case "ai": return /* @__PURE__ */ B(C, {});
529
+ case "shapes": return /* @__PURE__ */ z(y, {});
530
+ case "icons": return /* @__PURE__ */ z(b, {});
531
+ case "media": return /* @__PURE__ */ z(v, {});
532
+ case "inspector": return /* @__PURE__ */ z(x, {});
533
+ case "outline": return /* @__PURE__ */ z(S, {});
534
+ case "json": return /* @__PURE__ */ z(X, {});
535
+ case "ai": return /* @__PURE__ */ z(C, {});
534
536
  default: return null;
535
537
  }
536
538
  }
537
- var K = /* @__PURE__ */ new Set([
539
+ var G = /* @__PURE__ */ new Set([
538
540
  "shapes",
539
541
  "icons",
540
542
  "media"
541
- ]);
542
- function ce({ children: t, toolbar: n, compact: r }) {
543
- let i = c(), { panelDocks: a, setPanelDock: o, presentation: s, readOnly: l, setPendingPlacement: u } = i, { setShowPalette: d, setShowInspector: f, setShowOutline: p, setShowJson: m, setShowAI: h } = i, g = l ? [] : W.filter((e) => !e.showKey || i[e.showKey]), _ = (e) => ({
544
- id: e.id,
545
- label: e.label,
546
- icon: e.icon,
547
- content: G(e.id)
548
- }), [v, y] = z(null), b = R(null);
549
- I(() => {
543
+ ]), K = (e) => ({
544
+ id: e.id,
545
+ label: e.label,
546
+ icon: e.icon,
547
+ content: W(e.id)
548
+ });
549
+ function le({ children: t, toolbar: n, compact: r }) {
550
+ let i = c(), { panelDocks: a, setPanelDock: o, presentation: s, readOnly: l, setPendingPlacement: u } = i, { setShowPalette: d, setShowInspector: f, setShowOutline: p, setShowJson: m, setShowAI: h } = i, g = l ? [] : U.filter((e) => !e.showKey || i[e.showKey]), [_, v] = R(null), y = L(null);
551
+ F(() => {
550
552
  if (!r) {
551
- b.current = null;
553
+ y.current = null;
552
554
  return;
553
555
  }
554
- let e = i.pendingPlacement, t = e ? `${e.type}:${e.data?.svgId ?? ""}:${e.data?.mediaKind ?? ""}` : null, n = b.current;
555
- b.current = t, t && t !== n && v && K.has(v) && y(null);
556
+ let e = i.pendingPlacement, t = e ? `${e.type}:${e.data?.svgId ?? ""}:${e.data?.mediaKind ?? ""}` : null, n = y.current;
557
+ y.current = t, t && t !== n && _ && G.has(_) && v(null);
556
558
  }, [
557
559
  i.pendingPlacement,
558
560
  r,
559
- v
561
+ _
560
562
  ]);
561
- let [x, S] = z(null), C = F((e, t) => o(e, t), [o]), w = F((e) => {
563
+ let [b, x] = R(null), S = P((e, t) => o(e, t), [o]), C = P((e) => {
562
564
  e === "inspector" ? f(!1) : e === "outline" ? p(!1) : e === "json" ? m(!1) : e === "ai" ? h(!1) : d(!1);
563
565
  }, [
564
566
  f,
@@ -568,86 +570,86 @@ function ce({ children: t, toolbar: n, compact: r }) {
568
570
  d
569
571
  ]);
570
572
  if (r && !s) {
571
- let r = g.find((e) => e.id === v) ?? null;
572
- return /* @__PURE__ */ V("div", {
573
+ let r = g.find((e) => e.id === _) ?? null;
574
+ return /* @__PURE__ */ B("div", {
573
575
  className: "flow-workspace",
574
576
  children: [
575
577
  n,
576
- g.length > 0 && /* @__PURE__ */ B("div", {
578
+ g.length > 0 && /* @__PURE__ */ z("div", {
577
579
  className: "flow-mobile-panel-bar",
578
- children: /* @__PURE__ */ B(e, {
580
+ children: /* @__PURE__ */ z(e, {
579
581
  placeholder: "选择面板…",
580
582
  options: g.map((e) => ({
581
583
  value: e.id,
582
584
  label: e.label
583
585
  })),
584
- value: v ?? void 0,
586
+ value: _ ?? void 0,
585
587
  onChange: (e) => {
586
- u(null), y(String(e));
588
+ u(null), v(String(e));
587
589
  }
588
590
  })
589
591
  }),
590
- /* @__PURE__ */ V("div", {
592
+ /* @__PURE__ */ B("div", {
591
593
  className: "flow-workspace-main",
592
- children: [/* @__PURE__ */ B("div", {
594
+ children: [/* @__PURE__ */ z("div", {
593
595
  className: "flow-stage",
594
596
  children: t
595
- }), r && /* @__PURE__ */ V("div", {
597
+ }), r && /* @__PURE__ */ B("div", {
596
598
  className: "flow-mobile-panel",
597
- children: [/* @__PURE__ */ V("div", {
599
+ children: [/* @__PURE__ */ B("div", {
598
600
  className: "flow-mobile-panel-header",
599
- children: [/* @__PURE__ */ V("span", {
601
+ children: [/* @__PURE__ */ B("span", {
600
602
  className: "flow-mobile-panel-title",
601
- children: [r.icon && /* @__PURE__ */ B("span", {
603
+ children: [r.icon && /* @__PURE__ */ z("span", {
602
604
  className: "flow-panel-tab-icon",
603
605
  children: r.icon
604
606
  }), r.label]
605
- }), /* @__PURE__ */ B("button", {
607
+ }), /* @__PURE__ */ z("button", {
606
608
  type: "button",
607
609
  className: "flow-mobile-panel-close",
608
610
  "aria-label": "关闭面板",
609
- onClick: () => y(null),
611
+ onClick: () => v(null),
610
612
  children: "✕"
611
613
  })]
612
- }), /* @__PURE__ */ B("div", {
614
+ }), /* @__PURE__ */ z("div", {
613
615
  className: "flow-mobile-panel-body",
614
- children: G(r.id)
616
+ children: W(r.id)
615
617
  })]
616
618
  })]
617
619
  })
618
620
  ]
619
621
  });
620
622
  }
621
- let T = (e) => a[e] ?? "left", D = g.filter((e) => T(e.id) === "left").map(_), O = g.filter((e) => T(e.id) === "right").map(_), k = g.filter((e) => T(e.id) === "float");
622
- return /* @__PURE__ */ V("div", {
623
+ let w = (e) => a[e] ?? "left", T = g.filter((e) => w(e.id) === "left").map(K), D = g.filter((e) => w(e.id) === "right").map(K), O = g.filter((e) => w(e.id) === "float");
624
+ return /* @__PURE__ */ B("div", {
623
625
  className: "flow-workspace",
624
- children: [!s && n, /* @__PURE__ */ V("div", {
626
+ children: [!s && n, /* @__PURE__ */ B("div", {
625
627
  className: "flow-workspace-main",
626
628
  children: [
627
- !s && D.length > 0 && /* @__PURE__ */ B(E, {
628
- tabs: D,
629
- defaultTab: D[0]?.id,
629
+ !s && T.length > 0 && /* @__PURE__ */ z(E, {
630
+ tabs: T,
631
+ defaultTab: T[0]?.id,
630
632
  resizeEdge: "right",
631
633
  defaultWidth: 220,
632
634
  dock: "left",
633
- onDock: C,
634
- onClose: w
635
+ onDock: S,
636
+ onClose: C
635
637
  }),
636
- /* @__PURE__ */ B("div", {
638
+ /* @__PURE__ */ z("div", {
637
639
  className: "flow-stage",
638
640
  children: t
639
641
  }),
640
- !s && O.length > 0 && /* @__PURE__ */ B(E, {
641
- tabs: O,
642
- defaultTab: O[0]?.id,
642
+ !s && D.length > 0 && /* @__PURE__ */ z(E, {
643
+ tabs: D,
644
+ defaultTab: D[0]?.id,
643
645
  resizeEdge: "left",
644
646
  defaultWidth: 220,
645
647
  dock: "right",
646
- onDock: C,
647
- onClose: w
648
+ onDock: S,
649
+ onClose: C
648
650
  }),
649
- !s && k.map((e, t) => /* @__PURE__ */ B(E, {
650
- tabs: [_(e)],
651
+ !s && O.map((e, t) => /* @__PURE__ */ z(E, {
652
+ tabs: [K(e)],
651
653
  resizeEdge: "right",
652
654
  defaultWidth: 220,
653
655
  dock: "float",
@@ -655,20 +657,20 @@ function ce({ children: t, toolbar: n, compact: r }) {
655
657
  top: 48 + t * 40,
656
658
  left: 24 + t * 30
657
659
  },
658
- onDock: C,
659
- onClose: w,
660
- onDragHintChange: S
660
+ onDock: S,
661
+ onClose: C,
662
+ onDragHintChange: x
661
663
  }, e.id)),
662
- !s && x && /* @__PURE__ */ B("div", {
663
- className: `flow-dock-dropzone flow-dock-dropzone--${x}`,
664
- children: /* @__PURE__ */ B("span", { children: x === "left" ? "⇤ 停靠左侧" : "停靠右侧 ⇥" })
664
+ !s && b && /* @__PURE__ */ z("div", {
665
+ className: `flow-dock-dropzone flow-dock-dropzone--${b}`,
666
+ children: /* @__PURE__ */ z("span", { children: b === "left" ? "⇤ 停靠左侧" : "停靠右侧 ⇥" })
665
667
  })
666
668
  ]
667
669
  })]
668
670
  });
669
671
  }
670
- function le({ canvasRef: e, pixiRef: t, miniMapRef: n }) {
671
- let { showMiniMap: r, setViewport: i, presentation: a } = c(), o = R(!1), s = F((r, a) => {
672
+ function ue({ canvasRef: e, pixiRef: t, miniMapRef: n }) {
673
+ let { showMiniMap: r, setViewport: i, presentation: a } = c(), o = L(!1), s = P((r, a) => {
672
674
  let o = e.current, s = t.current, c = n.current;
673
675
  if (!o || !s || s.destroyed || !c) return;
674
676
  let l = o.getBoundingClientRect();
@@ -686,17 +688,17 @@ function le({ canvasRef: e, pixiRef: t, miniMapRef: n }) {
686
688
  t,
687
689
  n,
688
690
  i
689
- ]), l = F((e) => {
691
+ ]), l = P((e) => {
690
692
  e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), o.current = !0, s(e.clientX, e.clientY);
691
- }, [s]), u = F((e) => {
693
+ }, [s]), u = P((e) => {
692
694
  o.current && s(e.clientX, e.clientY);
693
- }, [s]), d = F((e) => {
695
+ }, [s]), d = P((e) => {
694
696
  o.current = !1;
695
697
  try {
696
698
  e.currentTarget.releasePointerCapture(e.pointerId);
697
699
  } catch {}
698
700
  }, []);
699
- return /* @__PURE__ */ B("div", {
701
+ return /* @__PURE__ */ z("div", {
700
702
  className: "flow-minimap",
701
703
  style: {
702
704
  display: r && !a ? void 0 : "none",
@@ -706,7 +708,7 @@ function le({ canvasRef: e, pixiRef: t, miniMapRef: n }) {
706
708
  onPointerMove: u,
707
709
  onPointerUp: d,
708
710
  title: "点击或拖动以移动画布",
709
- children: /* @__PURE__ */ B("canvas", {
711
+ children: /* @__PURE__ */ z("canvas", {
710
712
  ref: e,
711
713
  width: 180,
712
714
  height: 120,
@@ -752,14 +754,14 @@ function Y(e, t, n) {
752
754
  } catch {}
753
755
  }
754
756
  function X() {
755
- let { setDoc: e, currentCanvasId: n, selection: r, currentCanvas: i } = o(), [a, s] = z(""), [c, l] = z(null), u = R(!1), d = R(null), f = R(null), p = L(() => r.nodeIds.size + r.edgeIds.size + r.lineIds.size === 1 ? r.nodeIds.size === 1 ? [...r.nodeIds][0] : r.edgeIds.size === 1 ? [...r.edgeIds][0] : r.lineIds.size === 1 ? [...r.lineIds][0] : null : null, [r]);
756
- I(() => {
757
+ let { setDoc: e, currentCanvasId: n, selection: r, currentCanvas: i } = o(), [a, s] = R(""), [c, l] = R(null), u = L(!1), d = L(null), f = L(null), p = I(() => r.nodeIds.size + r.edgeIds.size + r.lineIds.size === 1 ? r.nodeIds.size === 1 ? [...r.nodeIds][0] : r.edgeIds.size === 1 ? [...r.edgeIds][0] : r.lineIds.size === 1 ? [...r.lineIds][0] : null : null, [r]);
758
+ F(() => {
757
759
  if (u.current) {
758
760
  u.current = !1;
759
761
  return;
760
762
  }
761
763
  s(JSON.stringify(i, null, 2)), l(null);
762
- }, [i]), I(() => {
764
+ }, [i]), F(() => {
763
765
  let e = f.current;
764
766
  if (e && J(e), !p) return;
765
767
  let t = setTimeout(() => {
@@ -770,7 +772,7 @@ function X() {
770
772
  let n = f.current, r = t.scrollDOM;
771
773
  r.style.scrollBehavior = "smooth";
772
774
  let i = t.state.doc.line(e.startLine);
773
- t.dispatch({ effects: H.scrollIntoView(i.from, {
775
+ t.dispatch({ effects: V.scrollIntoView(i.from, {
774
776
  y: "start",
775
777
  yMargin: 0
776
778
  }) });
@@ -785,7 +787,7 @@ function X() {
785
787
  }, 120);
786
788
  return () => clearTimeout(t);
787
789
  }, [p, a]);
788
- let m = F((t) => {
790
+ let m = P((t) => {
789
791
  s(t);
790
792
  try {
791
793
  let r = JSON.parse(t);
@@ -800,7 +802,7 @@ function X() {
800
802
  l(e.message?.slice(0, 60) ?? "Invalid JSON");
801
803
  }
802
804
  }, [e, n]), h = p ? r.nodeIds.has(p) ? "Node" : r.edgeIds.has(p) ? "Edge" : "Line" : null;
803
- return /* @__PURE__ */ V("div", {
805
+ return /* @__PURE__ */ B("div", {
804
806
  style: {
805
807
  display: "flex",
806
808
  flexDirection: "column",
@@ -808,14 +810,14 @@ function X() {
808
810
  minHeight: 0
809
811
  },
810
812
  children: [
811
- /* @__PURE__ */ B("div", {
813
+ /* @__PURE__ */ z("div", {
812
814
  className: "flow-json-header",
813
- children: /* @__PURE__ */ B("span", {
815
+ children: /* @__PURE__ */ z("span", {
814
816
  className: "flow-json-scope",
815
817
  children: h ? `${h}: ${p.slice(0, 8)}` : "Canvas"
816
818
  })
817
819
  }),
818
- c && /* @__PURE__ */ B("div", {
820
+ c && /* @__PURE__ */ z("div", {
819
821
  style: {
820
822
  fontSize: 11,
821
823
  color: "oklch(var(--er))",
@@ -824,13 +826,13 @@ function X() {
824
826
  },
825
827
  children: c
826
828
  }),
827
- /* @__PURE__ */ B("div", {
829
+ /* @__PURE__ */ z("div", {
828
830
  ref: f,
829
831
  style: {
830
832
  flex: 1,
831
833
  minHeight: 0
832
834
  },
833
- children: /* @__PURE__ */ B(t, {
835
+ children: /* @__PURE__ */ z(t, {
834
836
  ref: d,
835
837
  value: a,
836
838
  onChange: m,
@@ -843,8 +845,8 @@ function X() {
843
845
  ]
844
846
  });
845
847
  }
846
- function ue() {
847
- let { contextMenu: e, setContextMenu: t } = c(), { doc: n, setDoc: i, currentCanvasId: a, pushCanvas: s, setSelection: l } = o(), { duplicate: d } = A();
848
+ function de() {
849
+ let { contextMenu: e, setContextMenu: t } = c(), { doc: n, setDoc: i, currentCanvasId: a, pushCanvas: s, setSelection: l } = o(), { duplicate: d } = k();
848
850
  if (!e) return null;
849
851
  let f = n.canvases[a];
850
852
  if (!f) return t(null), null;
@@ -930,7 +932,7 @@ function ue() {
930
932
  } : t;
931
933
  }), s(e);
932
934
  }
933
- })), m.length === 0 ? null : /* @__PURE__ */ B(O, {
935
+ })), m.length === 0 ? null : /* @__PURE__ */ z(O, {
934
936
  x: e.x,
935
937
  y: e.y,
936
938
  items: m,
@@ -945,6 +947,6 @@ function Z(e, t) {
945
947
  }
946
948
  }
947
949
  //#endregion
948
- export { U as default };
950
+ export { H as default };
949
951
 
950
952
  //# sourceMappingURL=Flow.js.map