@xiangfa/mindmap 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +534 -0
  2. package/README.zh-CN.md +534 -0
  3. package/dist/MindMap.d.ts +3 -0
  4. package/dist/components/MindMapContextMenu.d.ts +20 -0
  5. package/dist/components/MindMapControls.d.ts +16 -0
  6. package/dist/components/MindMapNode.d.ts +32 -0
  7. package/dist/components/icons.d.ts +8 -0
  8. package/dist/esm/MindMap2.js +713 -0
  9. package/dist/esm/components/MindMapContextMenu.js +123 -0
  10. package/dist/esm/components/MindMapControls.js +114 -0
  11. package/dist/esm/components/MindMapNode.js +588 -0
  12. package/dist/esm/components/icons.js +45 -0
  13. package/dist/esm/hooks/useDrag.js +346 -0
  14. package/dist/esm/hooks/useNewNodeAnimation.js +20 -0
  15. package/dist/esm/hooks/useNodeEdit.js +57 -0
  16. package/dist/esm/hooks/usePanZoom.js +85 -0
  17. package/dist/esm/hooks/useTheme.js +16 -0
  18. package/dist/esm/index.js +14 -0
  19. package/dist/esm/logo.svg +9 -0
  20. package/dist/esm/plugins/cross-link.js +65 -0
  21. package/dist/esm/plugins/dotted-line.js +23 -0
  22. package/dist/esm/plugins/folding.js +20 -0
  23. package/dist/esm/plugins/front-matter.js +19 -0
  24. package/dist/esm/plugins/index.js +19 -0
  25. package/dist/esm/plugins/latex.js +132 -0
  26. package/dist/esm/plugins/multi-line.js +39 -0
  27. package/dist/esm/plugins/runner.js +128 -0
  28. package/dist/esm/plugins/tags.js +55 -0
  29. package/dist/esm/style.css +2 -0
  30. package/dist/esm/utils/export.js +50 -0
  31. package/dist/esm/utils/i18n.js +61 -0
  32. package/dist/esm/utils/inline-markdown.js +189 -0
  33. package/dist/esm/utils/layout.js +208 -0
  34. package/dist/esm/utils/markdown.js +288 -0
  35. package/dist/esm/utils/theme.js +119 -0
  36. package/dist/esm/utils/tree-ops.js +136 -0
  37. package/dist/hooks/useDrag.d.ts +40 -0
  38. package/dist/hooks/useNewNodeAnimation.d.ts +2 -0
  39. package/dist/hooks/useNodeEdit.d.ts +17 -0
  40. package/dist/hooks/usePanZoom.d.ts +26 -0
  41. package/dist/hooks/useTheme.d.ts +3 -0
  42. package/dist/index.d.ts +16 -0
  43. package/dist/logo.svg +9 -0
  44. package/dist/mindmap.umd.cjs +24 -0
  45. package/dist/plugins/cross-link.d.ts +2 -0
  46. package/dist/plugins/dotted-line.d.ts +2 -0
  47. package/dist/plugins/folding.d.ts +2 -0
  48. package/dist/plugins/front-matter.d.ts +2 -0
  49. package/dist/plugins/index.d.ts +11 -0
  50. package/dist/plugins/latex.d.ts +20 -0
  51. package/dist/plugins/multi-line.d.ts +2 -0
  52. package/dist/plugins/runner.d.ts +30 -0
  53. package/dist/plugins/tags.d.ts +2 -0
  54. package/dist/plugins/types.d.ts +78 -0
  55. package/dist/style.css +2 -0
  56. package/dist/types.d.ts +105 -0
  57. package/dist/utils/export.d.ts +18 -0
  58. package/dist/utils/i18n.d.ts +22 -0
  59. package/dist/utils/inline-markdown.d.ts +66 -0
  60. package/dist/utils/layout.d.ts +14 -0
  61. package/dist/utils/markdown.d.ts +20 -0
  62. package/dist/utils/theme.d.ts +62 -0
  63. package/dist/utils/tree-ops.d.ts +36 -0
  64. package/package.json +65 -0
@@ -0,0 +1,123 @@
1
+ import { useState as e } from "react";
2
+ import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
3
+ //#region src/components/MindMap/components/MindMapContextMenu.tsx
4
+ function i({ position: i, theme: a, messages: o, readonly: s, onNewRootNode: c, onExportSVG: l, onExportPNG: u, onExportMarkdown: d, onDirectionChange: f, onClose: p }) {
5
+ let [m, h] = e(!1), [g, _] = e(!1);
6
+ return /* @__PURE__ */ r("div", {
7
+ className: "mindmap-context-menu",
8
+ style: {
9
+ left: i.x,
10
+ top: i.y,
11
+ background: a.contextMenu.bgColor,
12
+ color: a.contextMenu.textColor,
13
+ boxShadow: `0 4px 16px ${a.contextMenu.shadowColor}`,
14
+ borderColor: a.contextMenu.borderColor
15
+ },
16
+ onClick: (e) => e.stopPropagation(),
17
+ children: [
18
+ !s && /* @__PURE__ */ r(t, { children: [/* @__PURE__ */ n("div", {
19
+ className: "mindmap-ctx-item mindmap-ctx-new-root",
20
+ onClick: c,
21
+ style: { color: a.contextMenu.textColor },
22
+ children: o.newRootNode
23
+ }), /* @__PURE__ */ n("div", {
24
+ className: "mindmap-ctx-divider",
25
+ style: { borderColor: a.contextMenu.borderColor }
26
+ })] }),
27
+ /* @__PURE__ */ r("div", {
28
+ className: "mindmap-ctx-item mindmap-ctx-has-sub mindmap-ctx-layout",
29
+ onMouseEnter: () => _(!0),
30
+ onMouseLeave: () => _(!1),
31
+ style: { color: a.contextMenu.textColor },
32
+ children: [
33
+ o.layout,
34
+ /* @__PURE__ */ n("span", {
35
+ className: "mindmap-ctx-arrow",
36
+ children: "▶"
37
+ }),
38
+ g && /* @__PURE__ */ r("div", {
39
+ className: "mindmap-ctx-submenu",
40
+ style: {
41
+ background: a.contextMenu.bgColor,
42
+ boxShadow: `0 4px 16px ${a.contextMenu.shadowColor}`,
43
+ borderColor: a.contextMenu.borderColor
44
+ },
45
+ children: [
46
+ /* @__PURE__ */ n("div", {
47
+ className: "mindmap-ctx-item mindmap-ctx-layout-left",
48
+ onClick: () => {
49
+ f("left"), p();
50
+ },
51
+ style: { color: a.contextMenu.textColor },
52
+ children: o.layoutLeft
53
+ }),
54
+ /* @__PURE__ */ n("div", {
55
+ className: "mindmap-ctx-item mindmap-ctx-layout-both",
56
+ onClick: () => {
57
+ f("both"), p();
58
+ },
59
+ style: { color: a.contextMenu.textColor },
60
+ children: o.layoutBoth
61
+ }),
62
+ /* @__PURE__ */ n("div", {
63
+ className: "mindmap-ctx-item mindmap-ctx-layout-right",
64
+ onClick: () => {
65
+ f("right"), p();
66
+ },
67
+ style: { color: a.contextMenu.textColor },
68
+ children: o.layoutRight
69
+ })
70
+ ]
71
+ })
72
+ ]
73
+ }),
74
+ /* @__PURE__ */ n("div", {
75
+ className: "mindmap-ctx-divider",
76
+ style: { borderColor: a.contextMenu.borderColor }
77
+ }),
78
+ /* @__PURE__ */ r("div", {
79
+ className: "mindmap-ctx-item mindmap-ctx-has-sub mindmap-ctx-export",
80
+ onMouseEnter: () => h(!0),
81
+ onMouseLeave: () => h(!1),
82
+ style: { color: a.contextMenu.textColor },
83
+ children: [
84
+ o.export,
85
+ /* @__PURE__ */ n("span", {
86
+ className: "mindmap-ctx-arrow",
87
+ children: "▶"
88
+ }),
89
+ m && /* @__PURE__ */ r("div", {
90
+ className: "mindmap-ctx-submenu",
91
+ style: {
92
+ background: a.contextMenu.bgColor,
93
+ boxShadow: `0 4px 16px ${a.contextMenu.shadowColor}`,
94
+ borderColor: a.contextMenu.borderColor
95
+ },
96
+ children: [
97
+ /* @__PURE__ */ n("div", {
98
+ className: "mindmap-ctx-item mindmap-ctx-export-svg",
99
+ onClick: l,
100
+ style: { color: a.contextMenu.textColor },
101
+ children: o.exportSVG
102
+ }),
103
+ /* @__PURE__ */ n("div", {
104
+ className: "mindmap-ctx-item mindmap-ctx-export-png",
105
+ onClick: u,
106
+ style: { color: a.contextMenu.textColor },
107
+ children: o.exportPNG
108
+ }),
109
+ /* @__PURE__ */ n("div", {
110
+ className: "mindmap-ctx-item mindmap-ctx-export-md",
111
+ onClick: d,
112
+ style: { color: a.contextMenu.textColor },
113
+ children: o.exportMarkdown
114
+ })
115
+ ]
116
+ })
117
+ ]
118
+ })
119
+ ]
120
+ });
121
+ }
122
+ //#endregion
123
+ export { i as MindMapContextMenu };
@@ -0,0 +1,114 @@
1
+ import { IconMinus as e, IconPlus as t } from "./icons.js";
2
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ //#region src/components/MindMap/components/MindMapControls.tsx
4
+ function a({ zoom: a, theme: o, messages: s, showZoom: c = !0, mode: l, isFullscreen: u, onZoomIn: d, onZoomOut: f, onAutoFit: p, onModeToggle: m, onFullscreenToggle: h }) {
5
+ return /* @__PURE__ */ i(n, { children: [c && /* @__PURE__ */ i("div", {
6
+ className: "mindmap-zoom-controls",
7
+ style: {
8
+ background: o.controls.bgColor,
9
+ color: o.controls.textColor
10
+ },
11
+ children: [
12
+ /* @__PURE__ */ r("button", {
13
+ className: "mindmap-ctrl-btn mindmap-ctrl-zoom-out",
14
+ onClick: f,
15
+ title: s.zoomOut,
16
+ style: { color: o.controls.textColor },
17
+ children: /* @__PURE__ */ r(e, { size: 16 })
18
+ }),
19
+ /* @__PURE__ */ i("button", {
20
+ className: "mindmap-ctrl-pct",
21
+ onClick: p,
22
+ title: s.resetView,
23
+ style: { color: o.controls.textColor },
24
+ children: [Math.round(a * 100), "%"]
25
+ }),
26
+ /* @__PURE__ */ r("button", {
27
+ className: "mindmap-ctrl-btn mindmap-ctrl-zoom-in",
28
+ onClick: d,
29
+ title: s.zoomIn,
30
+ style: { color: o.controls.textColor },
31
+ children: /* @__PURE__ */ r(t, { size: 16 })
32
+ })
33
+ ]
34
+ }), /* @__PURE__ */ i("div", {
35
+ className: "mindmap-extra-controls",
36
+ style: {
37
+ background: o.controls.bgColor,
38
+ color: o.controls.textColor
39
+ },
40
+ children: [/* @__PURE__ */ r("button", {
41
+ className: "mindmap-ctrl-btn mindmap-ctrl-mode",
42
+ onClick: m,
43
+ title: l === "view" ? s.textMode : s.viewMode,
44
+ style: { color: o.controls.textColor },
45
+ children: l === "view" ? /* @__PURE__ */ i("svg", {
46
+ width: 16,
47
+ height: 16,
48
+ viewBox: "0 0 24 24",
49
+ fill: "none",
50
+ stroke: "currentColor",
51
+ strokeWidth: 2,
52
+ strokeLinecap: "round",
53
+ strokeLinejoin: "round",
54
+ children: [
55
+ /* @__PURE__ */ r("path", { d: "M6 5h12" }),
56
+ /* @__PURE__ */ r("path", { d: "M4 12h10" }),
57
+ /* @__PURE__ */ r("path", { d: "M12 19h8" })
58
+ ]
59
+ }) : /* @__PURE__ */ i("svg", {
60
+ width: 16,
61
+ height: 16,
62
+ viewBox: "0 0 24 24",
63
+ fill: "none",
64
+ stroke: "currentColor",
65
+ strokeWidth: 2,
66
+ strokeLinecap: "round",
67
+ strokeLinejoin: "round",
68
+ children: [/* @__PURE__ */ r("path", { d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }), /* @__PURE__ */ r("circle", {
69
+ cx: "12",
70
+ cy: "12",
71
+ r: "3"
72
+ })]
73
+ })
74
+ }), /* @__PURE__ */ r("button", {
75
+ className: "mindmap-ctrl-btn mindmap-ctrl-fullscreen",
76
+ onClick: h,
77
+ title: u ? s.exitFullscreen : s.fullscreen,
78
+ style: { color: o.controls.textColor },
79
+ children: u ? /* @__PURE__ */ i("svg", {
80
+ width: 16,
81
+ height: 16,
82
+ viewBox: "0 0 24 24",
83
+ fill: "none",
84
+ stroke: "currentColor",
85
+ strokeWidth: 2,
86
+ strokeLinecap: "round",
87
+ strokeLinejoin: "round",
88
+ children: [
89
+ /* @__PURE__ */ r("path", { d: "M8 3v3a2 2 0 0 1-2 2H3" }),
90
+ /* @__PURE__ */ r("path", { d: "M21 8h-3a2 2 0 0 1-2-2V3" }),
91
+ /* @__PURE__ */ r("path", { d: "M3 16h3a2 2 0 0 1 2 2v3" }),
92
+ /* @__PURE__ */ r("path", { d: "M16 21v-3a2 2 0 0 1 2-2h3" })
93
+ ]
94
+ }) : /* @__PURE__ */ i("svg", {
95
+ width: 16,
96
+ height: 16,
97
+ viewBox: "0 0 24 24",
98
+ fill: "none",
99
+ stroke: "currentColor",
100
+ strokeWidth: 2,
101
+ strokeLinecap: "round",
102
+ strokeLinejoin: "round",
103
+ children: [
104
+ /* @__PURE__ */ r("path", { d: "M8 3H5a2 2 0 0 0-2 2v3" }),
105
+ /* @__PURE__ */ r("path", { d: "M21 8V5a2 2 0 0 0-2-2h-3" }),
106
+ /* @__PURE__ */ r("path", { d: "M3 16v3a2 2 0 0 0 2 2h3" }),
107
+ /* @__PURE__ */ r("path", { d: "M16 21h3a2 2 0 0 0 2-2v-3" })
108
+ ]
109
+ })
110
+ })]
111
+ })] });
112
+ }
113
+ //#endregion
114
+ export { a as MindMapControls };