From ea4d09fb5ccba12ed774fcf7c913edfa1e6a851a Mon Sep 17 00:00:00 2001 From: Agando Date: Thu, 2 Jul 2026 06:00:40 +0200 Subject: auto: 2026-07-02_06:00 changes --- modules/ext/mindmap.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'modules/ext/mindmap.js') diff --git a/modules/ext/mindmap.js b/modules/ext/mindmap.js index a5e7286..acce9aa 100644 --- a/modules/ext/mindmap.js +++ b/modules/ext/mindmap.js @@ -1075,6 +1075,61 @@ class MindmapModule { } } } + _svgFullscreen(args) { + const cur = this._ensureMindmap(); + if (!cur) return this.terminal.print('No mindmap. Create one with mindmap new first.', 'warning'); + const name = args[0] || this.current || 'mindmap'; + const layout = this._layoutTree(cur.root); + const colorMap = { + red: '#fb7185', green: '#34d399', yellow: '#fbbf24', blue: '#818cf8', + cyan: '#22d3ee', magenta: '#e879f9', white: '#e0e0e0' + }; + const xShift = layout.minX === Infinity ? 0 : -layout.minX; + const svgWidth = layout.width; + const svgHeight = layout.height; + let svg = ''; + for (const e of layout.edges) { + const sx = e.x1 + xShift + 30, sy = e.y1; + const ex = e.x2 + xShift + 30, ey = e.y2; + const mx = (sx + ex) / 2; + svg += ''; + } + for (const n of layout.nodes) { + const nx = n.x + xShift + 30; + const color = colorMap[n.color] || '#818cf8'; + const fontSize = n.w < 120 ? '9' : '10'; + const text = n.text.length > 18 ? n.text.substring(0, 16) + '..' : n.text; + svg += ''; + svg += '' + this._escapeHtml(text) + ''; + } + svg += ''; + + // Create fullscreen overlay + const overlay = document.createElement('div'); + overlay.id = 'mindmap-svg-overlay'; + overlay.style.cssText = 'position:fixed;inset:0;z-index:9999;background:#0a0a14;display:flex;align-items:center;justify-content:center;overflow:auto'; + overlay.innerHTML = svg; + document.body.appendChild(overlay); + + // Close button + const closeBtn = document.createElement('button'); + closeBtn.textContent = '✕'; + closeBtn.style.cssText = 'position:fixed;top:12px;right:12px;z-index:10000;background:rgba(0,0,0,0.6);color:#e0e0e0;border:1px solid #444;border-radius:6px;padding:6px 14px;font-size:16px;cursor:pointer;font-family:monospace'; + closeBtn.addEventListener('click', () => { overlay.remove(); closeBtn.remove(); }); + document.body.appendChild(closeBtn); + + // Escape key + const escHandler = (e) => { + if (e.key === 'Escape') { + overlay.remove(); + closeBtn.remove(); + document.removeEventListener('keydown', escHandler); + } + }; + document.addEventListener('keydown', escHandler); + + this.terminal.print(`🖼️ SVG fullscreen: ${layout.nodes.length} nodes, ${svgWidth}x${svgHeight}`, 'success'); + } // ── Main dispatcher ── registerCommands() { this.commands['mindmap'] = (args) => { @@ -1116,7 +1171,15 @@ class MindmapModule { case 'clone': return this._clone(rest); case 'archive': return this._archive(rest); case 'refresh-html': return this._refreshHtml(rest); - case 'svg': return this._svg(rest); + case 'svg': { + const fsIdx = rest.indexOf('--fullscreen'); + if (fsIdx >= 0) { + const clean = rest.filter(a => a !== '--fullscreen'); + return this._svgFullscreen(clean); + } + return this._svg(rest); + } + case 'svg-fullscreen': return this._svgFullscreen(rest); default: this.terminal.print('Unknown subcommand: ' + sub + '. Try: mindmap help', 'warning'); } }; -- cgit v1.2.3