@xiangfa/mindmap 0.3.0 → 0.5.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.
- package/LICENSE +13 -0
- package/README.md +106 -6
- package/README.zh-CN.md +106 -6
- package/dist/components/MindMapAIInput.d.ts +13 -0
- package/dist/components/MindMapContextMenu.d.ts +1 -1
- package/dist/components/MindMapControls.d.ts +1 -1
- package/dist/components/icons.d.ts +4 -0
- package/dist/esm/MindMap2.js +322 -320
- package/dist/esm/components/MindMapAIInput.js +199 -0
- package/dist/esm/components/MindMapContextMenu.js +28 -57
- package/dist/esm/components/MindMapControls.js +14 -27
- package/dist/esm/components/MindMapNode.js +8 -27
- package/dist/esm/components/icons.js +78 -1
- package/dist/esm/hooks/useNodeEdit.js +1 -1
- package/dist/esm/hooks/usePanZoom.js +3 -1
- package/dist/esm/plugins/tags.js +8 -8
- package/dist/esm/style.css +1 -1
- package/dist/esm/utils/export.js +25 -25
- package/dist/esm/utils/i18n.js +6 -0
- package/dist/esm/utils/layout.js +26 -18
- package/dist/esm/utils/markdown.js +1 -1
- package/dist/esm/utils/theme.js +44 -1
- package/dist/index.d.ts +1 -1
- package/dist/mindmap.umd.cjs +75 -16
- package/dist/plugins/tags.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/utils/export.d.ts +2 -1
- package/dist/utils/i18n.d.ts +3 -0
- package/dist/utils/theme.d.ts +10 -0
- package/package.json +2 -1
- package/dist/esm/logo.svg +0 -9
- package/dist/logo.svg +0 -9
package/dist/esm/style.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.mindmap-container{width:100%;height:100%;position:relative;overflow:hidden}.mindmap-svg{cursor:grab;-webkit-user-select:none;user-select:none;touch-action:none;width:100%;height:100%;display:block}.mindmap-svg:focus{outline:none}.mindmap-svg.dragging-canvas,.mindmap-svg.dragging-node{cursor:grabbing}.mindmap-node-animated{transition:transform .3s ease-out}.mindmap-edge-animated{transition:d .3s ease-out}@keyframes mindmap-node-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}.mindmap-node-new{animation:.3s ease-out mindmap-node-appear}@keyframes mindmap-expand-appear{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.mindmap-node-expanding{animation:.3s ease-out both mindmap-expand-appear}@keyframes mindmap-edge-draw{0%{stroke-dashoffset:300px}to{stroke-dashoffset:0}}.mindmap-edge-expanding{stroke-dasharray:300;animation:.3s ease-out both mindmap-edge-draw}.mindmap-edit-input{text-align:center;box-sizing:border-box;background:0 0;border:none;outline:none;width:100%;height:100%;margin:0;padding:0}.mindmap-edit-root{color:#fff;background:0 0}.mindmap-edit-child{color:inherit;background:0 0;border-radius:4px}.mindmap-zoom-controls{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:8px;align-items:center;gap:2px;padding:4px;display:flex;position:absolute;bottom:16px;left:16px;box-shadow:0 2px 8px #0000001a}.mindmap-ctrl-btn{cursor:pointer;width:32px;height:32px;color:inherit;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:background .15s,color .15s;display:flex}.mindmap-ctrl-btn:hover{background:#80808033}.mindmap-ctrl-pct{cursor:pointer;min-width:48px;height:32px;color:inherit;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:system-ui,sans-serif;font-size:13px;font-weight:500;transition:background .15s;display:flex}.mindmap-ctrl-pct:hover{background:#80808033}.mindmap-extra-controls{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:20;border-radius:8px;align-items:center;gap:2px;padding:4px;display:flex;position:absolute;bottom:16px;right:16px;box-shadow:0 2px 8px #0000001a}.mindmap-text-editor{resize:none;box-sizing:border-box;z-index:10;border:none;outline:none;width:100%;height:100%;padding:24px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:15px;line-height:1.7;position:absolute;inset:0}.mindmap-add-btn{opacity:0;cursor:pointer;transition:opacity .2s}.mindmap-node-g:hover .mindmap-add-btn{opacity:1}.mindmap-context-menu{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:1000;border:1px solid;border-radius:8px;min-width:150px;padding:4px 0;font-family:system-ui,-apple-system,sans-serif;position:absolute}.mindmap-ctx-item{cursor:pointer;white-space:nowrap;justify-content:space-between;align-items:center;padding:8px 16px;font-size:14px;display:flex;position:relative}.mindmap-ctx-item:hover{filter:brightness(.92);background:#8080801a}.mindmap-ctx-arrow{opacity:.5;margin-left:12px;font-size:8px}.mindmap-ctx-divider{opacity:.3;border-top:1px solid;height:0;margin:4px 8px}.mindmap-ctx-submenu{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid;border-radius:8px;min-width:140px;padding:4px 0;position:absolute;top:-4px;left:100%}.mindmap-ctx-has-sub{position:relative}.mindmap-dialog-backdrop{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:2000;background:#0003;justify-content:center;align-items:center;font-family:system-ui,-apple-system,sans-serif;animation:.15s ease-out mindmap-fade-in;display:flex;position:absolute;inset:0}@keyframes mindmap-fade-in{0%{opacity:0}to{opacity:1}}.mindmap-dialog-modal{border:1px solid;border-radius:12px;width:calc(100% - 32px);max-width:480px;max-height:80%;padding:24px;animation:.2s ease-out mindmap-dialog-enter;position:relative;overflow-y:auto;box-shadow:0 8px 32px #0003}@keyframes mindmap-dialog-enter{0%{opacity:0;transform:scale(.95)translateY(8px)}to{opacity:1;transform:scale(1)translateY(0)}}.mindmap-dialog-header{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.mindmap-dialog-title{margin:0;font-size:16px;font-weight:600}.mindmap-dialog-close{cursor:pointer;width:28px;height:28px;color:inherit;opacity:.5;background:0 0;border:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;transition:opacity .15s,background .15s;display:flex}.mindmap-dialog-close:hover{opacity:1;background:#80808033}@media (width<=500px){.mindmap-dialog-modal{max-height:90%;padding:16px}}@media (width<=768px){.mindmap-ctrl-btn{width:28px;height:28px}.mindmap-ctrl-btn svg{width:14px;height:14px}.mindmap-ctrl-pct{min-width:40px;height:28px;font-size:12px}.mindmap-zoom-controls,.mindmap-extra-controls{gap:1px;padding:3px;bottom:12px}.mindmap-zoom-controls{left:12px}.mindmap-extra-controls{right:12px}}.mindmap-node-content{white-space:nowrap;box-sizing:border-box;justify-content:center;align-items:center;gap:4px;line-height:1;display:flex;overflow:hidden}.mindmap-node-root-content{line-height:1}.mindmap-node-content strong{font-weight:700}.mindmap-node-content em{font-style:italic}.mindmap-node-content del{opacity:.6;text-decoration:line-through}.mindmap-node-content .mindmap-inline-code{background:#8080801f;border-radius:3px;padding:1px 4px;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:.88em}.mindmap-node-content .mindmap-highlight{color:#fac800;background:#fcd34d33;border-radius:2px;padding:1px 2px}.mindmap-node-content .mindmap-link{color:#2563eb;cursor:pointer;text-decoration:none}.mindmap-node-content .mindmap-link:hover{text-decoration:underline}.mindmap-node-content .mindmap-inline-image{vertical-align:middle;border-radius:2px;max-width:80px;max-height:1.2em}.mindmap-node-root-content .mindmap-inline-code{background:#ffffff26}.mindmap-node-root-content .mindmap-highlight{color:#fcd34d;background:#fbbf2433}.mindmap-node-root-content .mindmap-link{color:#93c5fd}.mindmap-task-icon{vertical-align:middle;flex-shrink:0}.mindmap-remark-indicator{opacity:.5;cursor:help;flex-shrink:0;font-size:.7em;line-height:1;transition:opacity .15s}.mindmap-remark-indicator:hover{opacity:1}.mindmap-remark-tooltip{white-space:pre-wrap;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:1000;pointer-events:none;border-radius:8px;max-width:280px;padding:8px 12px;font-family:system-ui,-apple-system,sans-serif;font-size:13px;line-height:1.5;animation:.15s ease-out mindmap-fade-in;position:absolute;box-shadow:0 4px 16px #00000026}
|
|
1
|
+
.mindmap-container{width:100%;height:100%;position:relative;overflow:hidden}.mindmap-svg{cursor:grab;-webkit-user-select:none;user-select:none;touch-action:none;background:var(--mindmap-canvas-bg);width:100%;height:100%;display:block}.mindmap-svg:focus{outline:none}.mindmap-svg.dragging-canvas,.mindmap-svg.dragging-node{cursor:grabbing}.mindmap-node-g{cursor:pointer}.mindmap-node-ghost{opacity:.3}.mindmap-canvas-ready{transition:opacity .4s ease-out}.mindmap-floating,.mindmap-floating-edge,.mindmap-edge-label{pointer-events:none}.mindmap-fold-btn{cursor:pointer}.mindmap-latex{pointer-events:none;overflow:visible}.mindmap-latex-content{white-space:nowrap;text-align:center}.mindmap-node-animated{transition:transform .3s ease-out}.mindmap-edge-animated{transition:d .3s ease-out}@keyframes mindmap-node-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}.mindmap-node-new{animation:.3s ease-out mindmap-node-appear}@keyframes mindmap-expand-appear{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.mindmap-node-expanding{animation:.3s ease-out both mindmap-expand-appear}@keyframes mindmap-edge-draw{0%{stroke-dashoffset:300px}to{stroke-dashoffset:0}}.mindmap-edge-expanding{stroke-dasharray:300;animation:.3s ease-out both mindmap-edge-draw}.mindmap-edit-input{text-align:center;box-sizing:border-box;background:0 0;border:none;outline:none;width:100%;height:100%;margin:0;padding:0}.mindmap-edit-root{color:#fff;background:0 0}.mindmap-edit-child{color:inherit;background:0 0;border-radius:4px}.mindmap-zoom-controls{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:var(--mindmap-controls-bg);color:var(--mindmap-controls-text);border-radius:8px;align-items:center;gap:2px;padding:4px;display:flex;position:absolute;bottom:16px;left:16px;box-shadow:0 2px 8px #0000001a}.mindmap-ctrl-btn{cursor:pointer;width:32px;height:32px;color:inherit;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:background .15s,color .15s;display:flex}.mindmap-ctrl-btn:hover{background:#80808033}.mindmap-ctrl-pct{cursor:pointer;min-width:48px;height:32px;color:inherit;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:system-ui,sans-serif;font-size:13px;font-weight:500;transition:background .15s;display:flex}.mindmap-ctrl-pct:hover{background:#80808033}.mindmap-extra-controls{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:20;background:var(--mindmap-controls-bg);color:var(--mindmap-controls-text);border-radius:8px;align-items:center;gap:2px;padding:4px;display:flex;position:absolute;bottom:16px;right:16px;box-shadow:0 2px 8px #0000001a}.mindmap-text-editor{resize:none;box-sizing:border-box;z-index:10;background:var(--mindmap-canvas-bg);width:100%;height:100%;color:var(--mindmap-node-text);border:none;outline:none;padding:24px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:15px;line-height:1.7;position:absolute;inset:0}.mindmap-add-btn{opacity:0;cursor:pointer;transition:opacity .2s}.mindmap-node-g:hover .mindmap-add-btn{opacity:1}.mindmap-context-menu{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:1000;background:var(--mindmap-ctx-bg);min-width:150px;color:var(--mindmap-ctx-text);border:1px solid;border-color:var(--mindmap-ctx-border);box-shadow:0 4px 16px var(--mindmap-ctx-shadow);border-radius:8px;padding:4px 0;font-family:system-ui,-apple-system,sans-serif;position:absolute}.mindmap-ctx-item{cursor:pointer;white-space:nowrap;justify-content:space-between;align-items:center;padding:8px 16px;font-size:14px;display:flex;position:relative}.mindmap-ctx-item:hover{filter:brightness(.92);background:#8080801a}.mindmap-ctx-arrow{opacity:.5;margin-left:12px;font-size:8px}.mindmap-ctx-divider{opacity:.3;border-top:1px solid;height:0;margin:4px 8px}.mindmap-ctx-submenu{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);background:var(--mindmap-ctx-bg);border:1px solid;border-color:var(--mindmap-ctx-border);min-width:140px;box-shadow:0 4px 16px var(--mindmap-ctx-shadow);border-radius:8px;padding:4px 0;position:absolute;top:-4px;left:100%}.mindmap-ctx-has-sub{position:relative}.mindmap-dialog-backdrop{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:2000;background:#0003;justify-content:center;align-items:center;font-family:system-ui,-apple-system,sans-serif;animation:.15s ease-out mindmap-fade-in;display:flex;position:absolute;inset:0}@keyframes mindmap-fade-in{0%{opacity:0}to{opacity:1}}.mindmap-dialog-modal{border:1px solid;border-radius:12px;width:calc(100% - 32px);max-width:480px;max-height:80%;padding:24px;animation:.2s ease-out mindmap-dialog-enter;position:relative;overflow-y:auto;box-shadow:0 8px 32px #0003}@keyframes mindmap-dialog-enter{0%{opacity:0;transform:scale(.95)translateY(8px)}to{opacity:1;transform:scale(1)translateY(0)}}.mindmap-dialog-header{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.mindmap-dialog-title{margin:0;font-size:16px;font-weight:600}.mindmap-dialog-close{cursor:pointer;width:28px;height:28px;color:inherit;opacity:.5;background:0 0;border:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;transition:opacity .15s,background .15s;display:flex}.mindmap-dialog-close:hover{opacity:1;background:#80808033}@media (width<=500px){.mindmap-dialog-modal{max-height:90%;padding:16px}}@media (width<=768px){.mindmap-ctrl-btn{width:28px;height:28px}.mindmap-ctrl-btn svg{width:14px;height:14px}.mindmap-ctrl-pct{min-width:40px;height:28px;font-size:12px}.mindmap-zoom-controls,.mindmap-extra-controls{gap:1px;padding:3px;bottom:12px}.mindmap-zoom-controls{left:12px}.mindmap-extra-controls{right:12px}}.mindmap-node-content{white-space:nowrap;box-sizing:border-box;justify-content:center;align-items:center;gap:4px;line-height:1;display:flex;overflow:hidden}.mindmap-node-root-content{line-height:1}.mindmap-node-content strong{font-weight:700}.mindmap-node-content em{font-style:italic}.mindmap-node-content del{opacity:.6;text-decoration:line-through}.mindmap-node-content .mindmap-inline-code{background:#8080801f;border-radius:3px;padding:1px 4px;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:.88em}.mindmap-node-content .mindmap-highlight{color:#fac800;background:#fcd34d33;border-radius:2px;padding:1px 2px}.mindmap-node-content .mindmap-link{color:#2563eb;cursor:pointer;text-decoration:none}.mindmap-node-content .mindmap-link:hover{text-decoration:underline}.mindmap-node-content .mindmap-inline-image{vertical-align:middle;border-radius:2px;max-width:80px;max-height:1.2em}.mindmap-node-root-content .mindmap-inline-code{background:#ffffff26}.mindmap-node-root-content .mindmap-highlight{color:#fcd34d;background:#fbbf2433}.mindmap-node-root-content .mindmap-link{color:#93c5fd}.mindmap-task-icon{vertical-align:middle;flex-shrink:0}.mindmap-remark-indicator{opacity:.5;cursor:help;flex-shrink:0;font-size:.7em;line-height:1;transition:opacity .15s}.mindmap-remark-indicator:hover{opacity:1}.mindmap-remark-tooltip{white-space:pre-wrap;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:1000;pointer-events:none;background:var(--mindmap-ctx-bg);max-width:280px;color:var(--mindmap-ctx-text);border:1px solid var(--mindmap-ctx-border);border-radius:8px;padding:8px 12px;font-family:system-ui,-apple-system,sans-serif;font-size:13px;line-height:1.5;animation:.15s ease-out mindmap-fade-in;position:absolute;box-shadow:0 4px 16px #00000026}.mindmap-ai-input{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:30;background:var(--mindmap-controls-bg);width:calc(100% - 32px);max-width:600px;color:var(--mindmap-controls-text);border:1px solid;border-color:var(--mindmap-ctx-border);border-radius:26px;outline:none;font-family:system-ui,-apple-system,sans-serif;animation:.15s ease-out mindmap-fade-in;position:absolute;bottom:56px;left:50%;transform:translate(-50%)}.mindmap-ai-input-row{align-items:center;gap:4px;padding:6px 6px 6px 16px;display:flex}.mindmap-ai-input-field{color:inherit;background:0 0;border:none;outline:none;flex:1;min-width:0;font-family:inherit;font-size:14px;line-height:1.5}.mindmap-ai-input-field:focus{box-shadow:none}.mindmap-ai-input-field::placeholder{opacity:.5}.mindmap-ai-input-field:disabled{opacity:.5;cursor:not-allowed}.mindmap-ai-send-btn{cursor:pointer;border:none;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:36px;height:36px;transition:background .15s,opacity .15s,transform .1s;display:flex;position:relative}.mindmap-ai-send-btn:hover:not(:disabled){opacity:.85;transform:scale(1.05)}.mindmap-ai-send-btn:disabled{cursor:not-allowed;opacity:.4}.mindmap-ai-send-btn--loading{cursor:pointer}@keyframes mindmap-ai-spin{to{transform:rotate(360deg)}}.mindmap-ai-spinner{justify-content:center;align-items:center;transition:opacity .2s;animation:.8s linear infinite mindmap-ai-spin;display:flex}.mindmap-ai-stop-icon{opacity:0;color:#ef4444;justify-content:center;align-items:center;transition:opacity .2s,transform .2s;display:flex;position:absolute;transform:scale(.5)}.mindmap-ai-send-btn--loading:hover .mindmap-ai-spinner{opacity:0}.mindmap-ai-send-btn--loading:hover .mindmap-ai-stop-icon{opacity:1;transform:scale(1)}.mindmap-ai-send-btn--loading:hover{background:#ef44441a!important}.mindmap-ai-attach-btn{cursor:pointer;opacity:.5;background:0 0;border:none;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;transition:opacity .15s,background .15s;display:flex}.mindmap-ai-attach-btn:hover:not(:disabled){opacity:1;background:#80808026}.mindmap-ai-attach-btn:disabled{cursor:not-allowed;opacity:.3}.mindmap-ai-file-previews{flex-wrap:wrap;gap:6px;padding:8px 12px 0;display:flex}.mindmap-ai-file-chip{background:var(--mindmap-controls-hover);border-radius:12px;align-items:center;gap:4px;max-width:160px;padding:3px 8px;font-size:12px;display:inline-flex}.mindmap-ai-file-name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mindmap-ai-file-remove{cursor:pointer;opacity:.5;background:0 0;border:none;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:16px;height:16px;padding:0;transition:opacity .15s;display:flex}.mindmap-ai-file-remove:hover{opacity:1}.mindmap-ai-error{color:#ef4444;padding:0 16px 8px;font-size:12px;animation:.15s ease-out mindmap-fade-in}@media (width<=768px){.mindmap-ai-input{border-radius:20px;max-width:calc(100% - 24px);bottom:48px}.mindmap-ai-input-row{padding:4px 4px 4px 12px}.mindmap-ai-send-btn{width:32px;height:32px}}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/esm/utils/export.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { THEME as e } from "./theme.js";
|
|
2
|
-
import { buildSvgNodeTextString as
|
|
3
|
-
import { runExportNodeDecoration as
|
|
1
|
+
import { THEME as e, generateExportStyles as t } from "./theme.js";
|
|
2
|
+
import { buildSvgNodeTextString as n } from "./inline-markdown.js";
|
|
3
|
+
import { runExportNodeDecoration as r, runExportOverlay as i } from "../plugins/runner.js";
|
|
4
4
|
//#region src/components/MindMap/utils/export.ts
|
|
5
|
-
function
|
|
6
|
-
let { padding:
|
|
7
|
-
for (let e of
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
for (let e of
|
|
11
|
-
let t = `
|
|
12
|
-
if (e.strokeDasharray && (
|
|
13
|
-
let
|
|
14
|
-
if (
|
|
15
|
-
let r = (
|
|
16
|
-
|
|
5
|
+
function a(a, o, s = {}, c = e, l) {
|
|
6
|
+
let { padding: u = 40, background: d = c.canvas.bgColor, pngSafe: f = !1 } = s, p = Infinity, m = -Infinity, h = Infinity, g = -Infinity;
|
|
7
|
+
for (let e of a) p = Math.min(p, e.x - e.width / 2), m = Math.max(m, e.x + e.width / 2), h = Math.min(h, e.y - e.height / 2), g = Math.max(g, e.y + e.height / 2);
|
|
8
|
+
let _ = m - p + u * 2, v = g - h + u * 2, y = -p + u, b = -h + u, x = [];
|
|
9
|
+
x.push(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${_}" height="${v}" viewBox="0 0 ${_} ${v}">`), x.push("<defs>"), x.push(" <style>"), x.push(` ${t(c)}`), x.push(" </style>"), o.some((e) => e.isCrossLink) && (x.push("<marker id=\"arrowhead\" markerWidth=\"8\" markerHeight=\"6\" refX=\"8\" refY=\"3\" orient=\"auto\">"), x.push("<path d=\"M0,0 L8,3 L0,6\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"/>"), x.push("</marker>")), x.push("</defs>"), x.push(`<rect width="100%" height="100%" fill="${d}"/>`), x.push(`<g transform="translate(${y}, ${b})">`);
|
|
10
|
+
for (let e of o) {
|
|
11
|
+
let t = a.find((t) => t.id === e.toId), n = t?.branchIndex === void 0 ? "" : ` data-branch-index="${t.branchIndex}"`, r = `class="mindmap-edge" d="${e.path}" stroke="${e.color}"${n}`;
|
|
12
|
+
if (e.strokeDasharray && (r += ` stroke-dasharray="${e.strokeDasharray}"`), e.isCrossLink && (r += " marker-end=\"url(#arrowhead)\" opacity=\"0.7\""), x.push(`<path ${r}/>`), e.label) {
|
|
13
|
+
let n = a.find((t) => t.id === e.fromId);
|
|
14
|
+
if (n && t) {
|
|
15
|
+
let r = (n.x + t.x) / 2, i = (n.y + t.y) / 2;
|
|
16
|
+
x.push(`<text class="mindmap-edge-label" x="${r}" y="${i - 6}" text-anchor="middle" font-size="11" fill="${e.color}" opacity="0.8">${e.label}</text>`);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
for (let e of
|
|
21
|
-
let
|
|
20
|
+
for (let e of a) {
|
|
21
|
+
let t = e.x, i = e.y, a = e.branchIndex === void 0 ? "" : ` data-branch-index="${e.branchIndex}"`;
|
|
22
22
|
if (e.depth === 0) {
|
|
23
|
-
let { fontSize:
|
|
24
|
-
|
|
23
|
+
let { fontSize: o, fontWeight: s, fontFamily: u, textColor: d } = c.root, p = c.root.bgColor;
|
|
24
|
+
x.push(`<g class="mindmap-node-g mindmap-node-root" transform="translate(${t}, ${i})"${a}>`), x.push(`<rect class="mindmap-node-bg" x="${-e.width / 2}" y="${-e.height / 2}" width="${e.width}" height="${e.height}" rx="${e.height / 2}" ry="${e.height / 2}" fill="${p}"/>`), x.push(n(e.text, o, s, u, d, e.taskStatus, e.remark, l, c.highlight.textColor, c.highlight.bgColor, f)), l && l.length > 0 && x.push(r(l, e, c, l, f)), x.push("</g>");
|
|
25
25
|
} else {
|
|
26
|
-
let
|
|
27
|
-
|
|
26
|
+
let o = e.depth === 1 ? c.level1.fontSize : c.node.fontSize, s = e.depth === 1 ? c.level1.fontWeight : c.node.fontWeight, u = e.width - c.node.paddingH * 2, d = o / 2 + 4;
|
|
27
|
+
x.push(`<g class="mindmap-node-g mindmap-node-child" transform="translate(${t}, ${i})"${a}>`), x.push(n(e.text, o, s, c.node.fontFamily, c.node.textColor, e.taskStatus, e.remark, l, c.highlight.textColor, c.highlight.bgColor, f)), x.push(`<line class="mindmap-node-underline" x1="${-u / 2}" y1="${d}" x2="${u / 2}" y2="${d}" stroke="${e.color}"/>`), l && l.length > 0 && x.push(r(l, e, c, l, f)), x.push("</g>");
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return l && l.length > 0 && x.push(i(l, a, o, c)), x.push("</g>"), x.push("</svg>"), x.join("\n");
|
|
31
31
|
}
|
|
32
|
-
var
|
|
33
|
-
function
|
|
32
|
+
var o = a;
|
|
33
|
+
function s(e, t = {}) {
|
|
34
34
|
let n = typeof window < "u" ? Math.max(window.devicePixelRatio ?? 1, 2) : 2, { scale: r = n } = t;
|
|
35
35
|
return new Promise((t, n) => {
|
|
36
36
|
let i = new DOMParser().parseFromString(e, "image/svg+xml").documentElement, a = parseFloat(i.getAttribute("width") || "800"), o = parseFloat(i.getAttribute("height") || "600"), s = new Blob([e], { type: "image/svg+xml;charset=utf-8" }), c = URL.createObjectURL(s), l = new Image();
|
|
@@ -47,4 +47,4 @@ function o(e, t = {}) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
|
-
export {
|
|
50
|
+
export { a as buildExportSVG, o as buildExportSVGForPNG, s as exportToPNG };
|
package/dist/esm/utils/i18n.js
CHANGED
|
@@ -17,6 +17,9 @@ var e = {
|
|
|
17
17
|
exportPNG: "导出为 PNG",
|
|
18
18
|
exportMarkdown: "导出为 Markdown",
|
|
19
19
|
layout: "布局",
|
|
20
|
+
aiPlaceholder: "让 AI 生成思维导图...",
|
|
21
|
+
aiGenerating: "生成中...",
|
|
22
|
+
aiError: "生成失败",
|
|
20
23
|
close: "关闭"
|
|
21
24
|
}, t = {
|
|
22
25
|
newNode: "New Node",
|
|
@@ -36,6 +39,9 @@ var e = {
|
|
|
36
39
|
exportPNG: "Export as PNG",
|
|
37
40
|
exportMarkdown: "Export as Markdown",
|
|
38
41
|
layout: "Layout",
|
|
42
|
+
aiPlaceholder: "Ask AI to generate a mind map...",
|
|
43
|
+
aiGenerating: "Generating...",
|
|
44
|
+
aiError: "Generation failed",
|
|
39
45
|
close: "Close"
|
|
40
46
|
}, n = {
|
|
41
47
|
"zh-CN": e,
|
package/dist/esm/utils/layout.js
CHANGED
|
@@ -15,49 +15,50 @@ function p(e, t, r, i, a) {
|
|
|
15
15
|
let o = u(n(e), t, r);
|
|
16
16
|
return i && (o += t * .9 + d), a && (o += f), o;
|
|
17
17
|
}
|
|
18
|
-
function m(n, a, o, c, l, u, d) {
|
|
19
|
-
let
|
|
18
|
+
function m(n, a, o, c, l, u, d, f) {
|
|
19
|
+
let h = a === 0, g = a === 1, _ = h ? t.root.fontSize : g ? t.level1.fontSize : t.node.fontSize, v = h ? t.root.fontWeight : g ? t.level1.fontWeight : t.node.fontWeight, y = h ? t.root.paddingH : t.node.paddingH, b = h ? t.root.paddingV : t.node.paddingV, x = p(n.text, _, v, n.taskStatus, !!n.remark) + y * 2, S = _ + b * 2;
|
|
20
20
|
if (u && u.length > 0) {
|
|
21
|
-
let e = r(u, n,
|
|
22
|
-
|
|
21
|
+
let e = r(u, n, x, S, _);
|
|
22
|
+
x = e.width, S = e.height;
|
|
23
23
|
}
|
|
24
|
-
let
|
|
25
|
-
u && u.length > 0 && d && (
|
|
26
|
-
let
|
|
24
|
+
let C = n.children || [];
|
|
25
|
+
u && u.length > 0 && d && (C = i(u, n, C, d));
|
|
26
|
+
let w = c;
|
|
27
27
|
if (u && u.length > 0) {
|
|
28
28
|
let e = s(u, {
|
|
29
29
|
id: n.id,
|
|
30
30
|
text: n.text,
|
|
31
31
|
x: 0,
|
|
32
32
|
y: 0,
|
|
33
|
-
width:
|
|
34
|
-
height:
|
|
33
|
+
width: x,
|
|
34
|
+
height: S,
|
|
35
35
|
color: c,
|
|
36
36
|
depth: a,
|
|
37
37
|
side: o,
|
|
38
38
|
parentId: l
|
|
39
39
|
}, n, c);
|
|
40
|
-
e.color && (
|
|
40
|
+
e.color && (w = e.color);
|
|
41
41
|
}
|
|
42
|
-
let
|
|
43
|
-
let i =
|
|
44
|
-
return m(t, a + 1, o, i, n.id, u, d);
|
|
42
|
+
let T = C.map((t, r) => {
|
|
43
|
+
let i = h ? e[r % e.length] : w, s = h ? r % e.length : f;
|
|
44
|
+
return m(t, a + 1, o, i, n.id, u, d, s);
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
47
47
|
id: n.id,
|
|
48
48
|
text: n.text,
|
|
49
|
-
children:
|
|
50
|
-
width:
|
|
51
|
-
height:
|
|
49
|
+
children: T,
|
|
50
|
+
width: x,
|
|
51
|
+
height: S,
|
|
52
52
|
depth: a,
|
|
53
53
|
side: o,
|
|
54
|
-
color:
|
|
54
|
+
color: w,
|
|
55
55
|
x: 0,
|
|
56
56
|
y: 0,
|
|
57
57
|
subtreeHeight: 0,
|
|
58
58
|
parentId: l,
|
|
59
59
|
remark: n.remark,
|
|
60
60
|
taskStatus: n.taskStatus,
|
|
61
|
+
branchIndex: f,
|
|
61
62
|
dottedLine: n.dottedLine,
|
|
62
63
|
multiLineContent: n.multiLineContent,
|
|
63
64
|
tags: n.tags,
|
|
@@ -93,6 +94,7 @@ function _(e, t) {
|
|
|
93
94
|
parentId: e.parentId,
|
|
94
95
|
remark: e.remark,
|
|
95
96
|
taskStatus: e.taskStatus,
|
|
97
|
+
branchIndex: e.branchIndex,
|
|
96
98
|
dottedLine: e.dottedLine,
|
|
97
99
|
multiLineContent: e.multiLineContent,
|
|
98
100
|
tags: e.tags,
|
|
@@ -133,7 +135,13 @@ function b(n, r = "both", i, o, s, c, l) {
|
|
|
133
135
|
let b = m({
|
|
134
136
|
...n,
|
|
135
137
|
children: []
|
|
136
|
-
}, 0, "root", t.root.bgColor, void 0, s, u), x = f.map((t, r) =>
|
|
138
|
+
}, 0, "root", t.root.bgColor, void 0, s, u), x = f.map((t, r) => {
|
|
139
|
+
let a = r % e.length;
|
|
140
|
+
return m(t, 1, "right", i?.[t.id] ?? e[a], n.id, s, u, a);
|
|
141
|
+
}), S = p.map((t, a) => {
|
|
142
|
+
let o = ((r === "left" ? 0 : v) + a) % e.length;
|
|
143
|
+
return m(t, 1, "left", i?.[t.id] ?? e[o], n.id, s, u, o);
|
|
144
|
+
});
|
|
137
145
|
b.children = [...x, ...S];
|
|
138
146
|
for (let e of b.children) h(e);
|
|
139
147
|
b.x = 0, b.y = 0;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { runCollectFollowLines as e, runParseLine as t, runPostParseTree as n, runPreParseMarkdown as r, runSerializeFollowLines as i, runSerializeListMarker as a, runSerializeNodeText as o, runSerializePreamble as s, runTransformNodeData as c } from "../plugins/runner.js";
|
|
2
2
|
//#region src/components/MindMap/utils/markdown.ts
|
|
3
3
|
function l(e) {
|
|
4
|
-
let t = e.match(/^\[([ x
|
|
4
|
+
let t = e.match(/^\[([ x-])\]\s+(.*)/);
|
|
5
5
|
if (!t) return { text: e };
|
|
6
6
|
let n = t[1], r = t[2];
|
|
7
7
|
return n === " " ? {
|
package/dist/esm/utils/theme.js
CHANGED
|
@@ -115,5 +115,48 @@ function i(e) {
|
|
|
115
115
|
return e === "dark" ? r : n;
|
|
116
116
|
}
|
|
117
117
|
var a = n;
|
|
118
|
+
function o(t, n = e) {
|
|
119
|
+
let r = {
|
|
120
|
+
"--mindmap-canvas-bg": t.canvas.bgColor,
|
|
121
|
+
"--mindmap-root-bg": t.root.bgColor,
|
|
122
|
+
"--mindmap-root-text": t.root.textColor,
|
|
123
|
+
"--mindmap-root-font-size": `${t.root.fontSize}px`,
|
|
124
|
+
"--mindmap-root-font-weight": String(t.root.fontWeight),
|
|
125
|
+
"--mindmap-root-font-family": t.root.fontFamily,
|
|
126
|
+
"--mindmap-node-text": t.node.textColor,
|
|
127
|
+
"--mindmap-node-font-size": `${t.node.fontSize}px`,
|
|
128
|
+
"--mindmap-node-font-weight": String(t.node.fontWeight),
|
|
129
|
+
"--mindmap-node-font-family": t.node.fontFamily,
|
|
130
|
+
"--mindmap-level1-font-size": `${t.level1.fontSize}px`,
|
|
131
|
+
"--mindmap-level1-font-weight": String(t.level1.fontWeight),
|
|
132
|
+
"--mindmap-edge-width": String(t.connection.strokeWidth),
|
|
133
|
+
"--mindmap-selection-stroke": t.selection.strokeColor,
|
|
134
|
+
"--mindmap-selection-fill": t.selection.fillColor,
|
|
135
|
+
"--mindmap-highlight-text": t.highlight.textColor,
|
|
136
|
+
"--mindmap-highlight-bg": t.highlight.bgColor,
|
|
137
|
+
"--mindmap-addbtn-fill": t.addBtn.fill,
|
|
138
|
+
"--mindmap-addbtn-hover": t.addBtn.hoverFill,
|
|
139
|
+
"--mindmap-addbtn-icon": t.addBtn.iconColor,
|
|
140
|
+
"--mindmap-controls-bg": t.controls.bgColor,
|
|
141
|
+
"--mindmap-controls-text": t.controls.textColor,
|
|
142
|
+
"--mindmap-controls-hover": t.controls.hoverBg,
|
|
143
|
+
"--mindmap-ctx-bg": t.contextMenu.bgColor,
|
|
144
|
+
"--mindmap-ctx-text": t.contextMenu.textColor,
|
|
145
|
+
"--mindmap-ctx-hover": t.contextMenu.hoverBg,
|
|
146
|
+
"--mindmap-ctx-border": t.contextMenu.borderColor,
|
|
147
|
+
"--mindmap-ctx-shadow": t.contextMenu.shadowColor
|
|
148
|
+
};
|
|
149
|
+
for (let e = 0; e < n.length; e++) r[`--mindmap-branch-${e}`] = n[e];
|
|
150
|
+
return r;
|
|
151
|
+
}
|
|
152
|
+
function s(e) {
|
|
153
|
+
return [
|
|
154
|
+
`.mindmap-edge { stroke-width: ${e.connection.strokeWidth}; stroke-linecap: round; fill: none; }`,
|
|
155
|
+
".mindmap-node-underline { stroke-width: 2.5; stroke-linecap: round; }",
|
|
156
|
+
".mindmap-code-bg { fill: rgba(128,128,128,0.12); }",
|
|
157
|
+
`.mindmap-highlight-bg { fill: ${e.highlight.bgColor}; }`,
|
|
158
|
+
`.mindmap-edge-label { pointer-events: none; font-family: ${e.node.fontFamily}; }`
|
|
159
|
+
].join("\n ");
|
|
160
|
+
}
|
|
118
161
|
//#endregion
|
|
119
|
-
export { e as BRANCH_COLORS, a as THEME, i as getTheme };
|
|
162
|
+
export { e as BRANCH_COLORS, a as THEME, o as generateCSSVariables, s as generateExportStyles, i as getTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MindMap } from './MindMap';
|
|
2
|
-
export type { MindMapData, MindMapProps, MindMapRef, MindMapEvent, LayoutDirection, ThemeMode, ToolbarConfig, TaskStatus, CrossLink } from './types';
|
|
2
|
+
export type { MindMapData, MindMapProps, MindMapRef, MindMapEvent, LayoutDirection, ThemeMode, ToolbarConfig, TaskStatus, CrossLink, MindMapAIConfig, AIAttachmentType } from './types';
|
|
3
3
|
export type { MindMapMessages } from './utils/i18n';
|
|
4
4
|
export { resolveMessages, detectLocale } from './utils/i18n';
|
|
5
5
|
export { buildExportSVG, buildExportSVGForPNG, exportToPNG } from './utils/export';
|