cladogram 0.6.0-beta.4 → 0.6.0-beta.5
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/README.md +42 -44
- package/docs/release.md +11 -0
- package/package.json +1 -1
- package/plugins/agent/index.js +118 -116
- package/plugins/agent/style.css +0 -31
- package/plugins/view-controls/index.js +0 -11
- package/plugins/view-controls/style.css +0 -7
- package/skills/clado/SKILL.md +1 -1
- package/src/agent/pi-bridge.js +17 -3
- package/src/html/app-css.js +4 -0
- package/src/html/canvas-chain.js +6 -4
- package/src/html/canvas-ui.css +3 -2
- package/src/html/runtime.js +179 -73
- package/src/server/assets/library.css +139 -0
- package/src/server/assets/library.js +48 -17
package/skills/clado/SKILL.md
CHANGED
|
@@ -207,6 +207,6 @@ YAML中的版本写成带引号的文字,例如 `version: "1.0"`;组织方
|
|
|
207
207
|
|
|
208
208
|
删除有孩子的节点需要 `recursive:true`。被引用目标默认拒绝删除;确实要断开入链才给 `unlink:true`,工具保留链接显示文字。改名、移动用专用操作,让工具维护可解析引用;未解析目标由全量诊断持续报告。
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
交付前重新读取关键节点、检查引用并实际看网页;多卡画布应保持从左到右的单向无环流(DAG),严禁尾连头反向回环或双向互连,克制单卡跨卡连线数量(建议 1–3 条)且不留孤立卡片(单卡豁免)。按语义展开层级,不跳级、不凑L6;代码、表格、Mermaid、` ```svg ` 矢量图/轻动效、` ```ui ` 隔离沙盒 UI 原型及本地音视频(``)解释所属逻辑,不用巨型Mermaid代替节点。方法卡按当前模板说明职责、输入输出、内部步骤和失败出口。
|
|
211
211
|
|
|
212
212
|
事实需核对材料,新设计标提案,未知项保留待确认。工具不执行业务代码、SQL、迁移或发布任务,未执行的验证不能写成通过。最后说明修改文档、未决项、实际检查和打开方式;离线交付使用 `clado build`,默认输出可携带目录导航的只读 `clado.html`。
|
package/src/agent/pi-bridge.js
CHANGED
|
@@ -442,6 +442,7 @@ export function createPiBridge({
|
|
|
442
442
|
|
|
443
443
|
const turnAbort = new AbortController();
|
|
444
444
|
let draftActive = false;
|
|
445
|
+
let customSteerHandler = null;
|
|
445
446
|
|
|
446
447
|
const runState = {
|
|
447
448
|
sessionId: cleanId,
|
|
@@ -452,11 +453,23 @@ export function createPiBridge({
|
|
|
452
453
|
return true;
|
|
453
454
|
},
|
|
454
455
|
async steer(steerText) {
|
|
455
|
-
|
|
456
|
-
|
|
456
|
+
const clean = String(steerText || '').trim();
|
|
457
|
+
if (!clean) return false;
|
|
458
|
+
const handler = session?.steer
|
|
459
|
+
? (t) => session.steer(t)
|
|
460
|
+
: (typeof customSteerHandler === 'function' ? customSteerHandler : null);
|
|
461
|
+
if (!handler) return false;
|
|
462
|
+
const steerBlock = { type: 'steer', text: clean };
|
|
463
|
+
blocks.push(steerBlock);
|
|
464
|
+
emitWrapped({ type: 'steer', text: clean });
|
|
465
|
+
try {
|
|
466
|
+
await handler(clean);
|
|
457
467
|
return true;
|
|
468
|
+
} catch (err) {
|
|
469
|
+
const idx = blocks.lastIndexOf(steerBlock);
|
|
470
|
+
if (idx >= 0) blocks.splice(idx, 1);
|
|
471
|
+
throw err;
|
|
458
472
|
}
|
|
459
|
-
return false;
|
|
460
473
|
},
|
|
461
474
|
async abort() {
|
|
462
475
|
abortedByUser = true;
|
|
@@ -582,6 +595,7 @@ export function createPiBridge({
|
|
|
582
595
|
events,
|
|
583
596
|
emit: factoryEmit,
|
|
584
597
|
waitForUserAnswer,
|
|
598
|
+
onSteer: fn => { customSteerHandler = fn; },
|
|
585
599
|
signal: turnAbort.signal,
|
|
586
600
|
});
|
|
587
601
|
if (!assistantText && result?.text) appendTextDelta(String(result.text));
|
package/src/html/app-css.js
CHANGED
|
@@ -351,6 +351,10 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
351
351
|
}
|
|
352
352
|
[data-theme="dark"] #lensInner .zui-lens-frame{background:#0f172a}
|
|
353
353
|
|
|
354
|
+
.zoomable.zimg{padding:0; background:var(--panel); cursor:zoom-in}
|
|
355
|
+
.zoomable.zimg img{display:block; width:100%; height:auto; max-width:100%; margin:0 auto}
|
|
356
|
+
.zoomable.zimg:hover{border-color:var(--accent)}
|
|
357
|
+
|
|
354
358
|
.zvideo,.zaudio{
|
|
355
359
|
margin-top:8px; border:1px solid var(--line-2); border-radius:8px;
|
|
356
360
|
overflow:hidden; background:var(--bg);
|
package/src/html/canvas-chain.js
CHANGED
|
@@ -63,7 +63,8 @@ function canvasChainDocument(subset, selected) {
|
|
|
63
63
|
var data = child.createElement('script');
|
|
64
64
|
var values = { __CLADO__: subset, __CLADO_CHAIN__: { id: selected, mode: mode }, __CLADO_LIVE__: true,
|
|
65
65
|
__CLADO_DIAGNOSTICS__: [], __CLADO_FILE__: window.__CLADO_FILE__ || '',
|
|
66
|
-
__CLADO_FILE_PATH__: window.__CLADO_FILE_PATH__ || '',
|
|
66
|
+
__CLADO_FILE_PATH__: window.__CLADO_FILE_PATH__ || '', __CLADO_WORKSPACE_ID__: window.__CLADO_WORKSPACE_ID__ || '',
|
|
67
|
+
__CLADO_RESOURCES__: window.__CLADO_RESOURCES__ || {}, __CLADO_OFFLINE__: !!window.__CLADO_OFFLINE__ };
|
|
67
68
|
data.textContent = Object.keys(values).map(function (key) { return 'window.' + key + '=' + JSON.stringify(values[key]).replace(/</g, '\\u003c').replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029') + ';'; }).join('\n');
|
|
68
69
|
child.body.appendChild(data);
|
|
69
70
|
[runtime, ui].forEach(function (source) { var script = child.createElement('script'); script.id = source.id; script.textContent = source.textContent; child.body.appendChild(script); });
|
|
@@ -201,6 +202,7 @@ if (window.__CLADO_CHAIN__) {
|
|
|
201
202
|
if (canvasRecords[id]) { flash(canvasRecords[id].card); canvasChainCenter(id); if (link.dataset.mediaPoint) canvasRevealMediaTarget(link, id); }
|
|
202
203
|
return;
|
|
203
204
|
}
|
|
205
|
+
if (event.target.closest('.zblock-btn:not([data-svg-zoom]):not([data-ui-zoom]),.zcode-preview-btn')) return;
|
|
204
206
|
if (event.target.closest('.zoomable,a')) { event.preventDefault(); event.stopImmediatePropagation(); }
|
|
205
207
|
}, true);
|
|
206
208
|
function chainCenter() { canvasSetFocus(canvasChainInitialId); canvasChainCenter(canvasChainInitialId); }
|
|
@@ -220,14 +222,14 @@ if (window.__CLADO_CHAIN__) {
|
|
|
220
222
|
tx = mx - (mx - tx) * next / scale; ty = my - (my - ty) * next / scale; scale = next; apply(); if (document.body.dataset.mode === 'mindmap') drawMindWires(); else drawWires();
|
|
221
223
|
}
|
|
222
224
|
function chainResources() {
|
|
223
|
-
$$('img[src]:not([data-chain-resource])').forEach(function (
|
|
224
|
-
var href =
|
|
225
|
+
$$('img[src]:not([data-chain-resource]),video[src]:not([data-chain-resource]),audio[src]:not([data-chain-resource])').forEach(function (el) {
|
|
226
|
+
var href = el.getAttribute('src'); if (!href || /^(?:[a-z][a-z0-9+.-]*:|\/\/|\/)/i.test(href) || !window.__CLADO_FILE_PATH__) return;
|
|
225
227
|
try {
|
|
226
228
|
var url = new URL(href, 'https://clado.local/documents/' + window.__CLADO_FILE_PATH__);
|
|
227
229
|
if (!url.pathname.startsWith('/documents/')) return;
|
|
228
230
|
var path = decodeURIComponent(url.pathname.slice('/documents/'.length)), resource = (window.__CLADO_RESOURCES__ || {})[path];
|
|
229
231
|
var workspace = window.__CLADO_WORKSPACE_ID__ ? '&workspace=' + encodeURIComponent(window.__CLADO_WORKSPACE_ID__) : '';
|
|
230
|
-
if (resource || !window.__CLADO_OFFLINE__) {
|
|
232
|
+
if (resource || !window.__CLADO_OFFLINE__) { el.src = resource || '/library/resource?file=' + encodeURIComponent(path) + workspace; el.dataset.chainResource = '1'; }
|
|
231
233
|
} catch (_) {}
|
|
232
234
|
});
|
|
233
235
|
}
|
package/src/html/canvas-ui.css
CHANGED
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
/* 长按标题提取关联链路,主画布和子画布分别保存各自的取景。 */
|
|
28
28
|
.card-title h1,.slice-head,#toc a{touch-action:none;cursor:text;user-select:text;-webkit-user-select:text}
|
|
29
29
|
.card-title h1:focus-visible,.slice-head:focus-visible,#toc a:focus-visible{outline:2px solid var(--accent);outline-offset:3px;border-radius:3px}
|
|
30
|
-
.canvas-chain-dialog{position:fixed;inset:0;width:min(1440px,calc(100vw - 48px));height:calc(100dvh - 64px);max-width:none;max-height:none;margin:auto;padding:0;overflow:hidden}
|
|
31
|
-
.canvas-chain-bar{height:61px;display:flex;align-items:center;gap:14px;padding:0 17px;background
|
|
30
|
+
.canvas-chain-dialog{position:fixed;inset:0;width:min(1440px,calc(100vw - 48px));height:calc(100dvh - 64px);max-width:none;max-height:none;margin:auto;padding:0;overflow:hidden;background:var(--bg);color:var(--fg)}
|
|
31
|
+
.canvas-chain-bar{height:61px;display:flex;align-items:center;gap:14px;padding:0 17px;background:var(--panel);color:var(--fg);border-bottom:1px solid var(--line);--clado-ui-muted:var(--fg-2);--clado-ui-accent:var(--accent);--clado-ui-edge:var(--line);--clado-ui-active:var(--bg)}
|
|
32
|
+
[data-theme="dark"] .canvas-chain-bar{background:#161b22;color:#e6edf3;border-bottom-color:rgba(148,163,184,.2);--clado-ui-muted:#94a3b8;--clado-ui-accent:#60a5fa;--clado-ui-edge:rgba(148,163,184,.24);--clado-ui-active:rgba(255,255,255,.08)}
|
|
32
33
|
.canvas-chain-heading{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.canvas-chain-heading strong{font-size:14px;font-weight:600;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.canvas-chain-meta{font-size:11px;color:var(--clado-ui-muted)}
|
|
33
34
|
.canvas-chain-controls{display:flex;align-items:center;gap:6px}.canvas-chain-controls button{width:30px;min-height:30px;padding:0;display:grid;place-items:center;border-radius:7px;font-size:17px}.canvas-chain-dialog iframe{display:block;width:100%;height:calc(100% - 62px);border:0;background:var(--bg)}
|
|
34
35
|
@media(max-width:650px){.canvas-chain-dialog{width:calc(100vw - 16px);height:calc(100dvh - 24px);border-radius:10px}.canvas-chain-bar{padding-inline:10px;gap:8px}.canvas-chain-meta{font-size:10px}}
|
package/src/html/runtime.js
CHANGED
|
@@ -155,11 +155,23 @@
|
|
|
155
155
|
|
|
156
156
|
function sanitizeSvgMarkup(raw) {
|
|
157
157
|
var src = String(raw || '').trim();
|
|
158
|
-
if (!src ||
|
|
158
|
+
if (!src || !/<svg\b/i.test(src)) return null;
|
|
159
|
+
if (!/\bxmlns\s*=/i.test(src)) {
|
|
160
|
+
src = src.replace(/<svg\b/i, '<svg xmlns="http://www.w3.org/2000/svg"');
|
|
161
|
+
}
|
|
162
|
+
if (/\bxlink:/i.test(src) && !/\bxmlns:xlink\s*=/i.test(src)) {
|
|
163
|
+
src = src.replace(/<svg\b/i, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
|
|
164
|
+
}
|
|
159
165
|
var svg = null;
|
|
160
166
|
try {
|
|
161
167
|
var parsed = new DOMParser().parseFromString(src, 'image/svg+xml');
|
|
162
|
-
if (
|
|
168
|
+
if (
|
|
169
|
+
parsed
|
|
170
|
+
&& !parsed.querySelector('parsererror')
|
|
171
|
+
&& parsed.documentElement
|
|
172
|
+
&& parsed.documentElement.localName === 'svg'
|
|
173
|
+
&& parsed.documentElement.namespaceURI === 'http://www.w3.org/2000/svg'
|
|
174
|
+
) {
|
|
163
175
|
svg = document.importNode(parsed.documentElement, true);
|
|
164
176
|
}
|
|
165
177
|
} catch (e) {}
|
|
@@ -258,6 +270,7 @@
|
|
|
258
270
|
var wrap = document.createElement('div');
|
|
259
271
|
wrap.className = 'zoomable zui';
|
|
260
272
|
wrap.dataset.label = 'UI 原型预览';
|
|
273
|
+
wrap.dataset.rawSource = rawCode;
|
|
261
274
|
|
|
262
275
|
var bar = document.createElement('div');
|
|
263
276
|
bar.className = 'zblock-bar';
|
|
@@ -288,47 +301,14 @@
|
|
|
288
301
|
wrap.appendChild(bar);
|
|
289
302
|
wrap.appendChild(stage);
|
|
290
303
|
wrap.appendChild(preEl);
|
|
291
|
-
|
|
292
|
-
var deskBtn = bar.querySelector('[data-ui-vp="desktop"]');
|
|
293
|
-
var mobBtn = bar.querySelector('[data-ui-vp="mobile"]');
|
|
294
|
-
var zoomBtn = bar.querySelector('[data-ui-zoom]');
|
|
295
|
-
var modeBtn = bar.querySelector('[data-ui-mode]');
|
|
296
|
-
|
|
297
|
-
deskBtn.addEventListener('click', function (ev) {
|
|
298
|
-
ev.stopPropagation();
|
|
299
|
-
wrap.classList.remove('is-mobile');
|
|
300
|
-
deskBtn.classList.add('active');
|
|
301
|
-
mobBtn.classList.remove('active');
|
|
302
|
-
});
|
|
303
|
-
mobBtn.addEventListener('click', function (ev) {
|
|
304
|
-
ev.stopPropagation();
|
|
305
|
-
wrap.classList.add('is-mobile');
|
|
306
|
-
mobBtn.classList.add('active');
|
|
307
|
-
deskBtn.classList.remove('active');
|
|
308
|
-
});
|
|
309
|
-
modeBtn.addEventListener('click', function (ev) {
|
|
310
|
-
ev.stopPropagation();
|
|
311
|
-
var showCode = wrap.classList.toggle('is-code');
|
|
312
|
-
modeBtn.textContent = showCode ? '预览' : '代码';
|
|
313
|
-
modeBtn.classList.toggle('active', showCode);
|
|
314
|
-
if (document.body.dataset.mode === 'cards') { try { repinPorts(); drawWires(); } catch (e) {} }
|
|
315
|
-
});
|
|
316
|
-
zoomBtn.addEventListener('click', function (ev) {
|
|
317
|
-
ev.stopPropagation();
|
|
318
|
-
var lensHtml = '<iframe class="zui-lens-frame" sandbox="allow-scripts" title="UI 原型全屏预览"></iframe>';
|
|
319
|
-
openLens(lensHtml, 'UI 原型预览', 'ui');
|
|
320
|
-
var lensFr = $('#lensInner .zui-lens-frame');
|
|
321
|
-
if (lensFr) lensFr.srcdoc = buildUiSandboxDoc(rawCode, '');
|
|
322
|
-
});
|
|
323
304
|
return wrap;
|
|
324
305
|
}
|
|
325
306
|
|
|
326
|
-
|
|
327
|
-
var cleanSvg = sanitizeSvgMarkup(rawCode);
|
|
328
|
-
if (!cleanSvg) return null;
|
|
307
|
+
function createSvgBlock(rawCode, cleanSvg, preEl) {
|
|
329
308
|
var wrap = document.createElement('div');
|
|
330
309
|
wrap.className = 'zoomable zsvg';
|
|
331
310
|
wrap.dataset.label = 'SVG 矢量图';
|
|
311
|
+
wrap.dataset.rawSource = rawCode;
|
|
332
312
|
|
|
333
313
|
var bar = document.createElement('div');
|
|
334
314
|
bar.className = 'zblock-bar';
|
|
@@ -344,29 +324,18 @@
|
|
|
344
324
|
stage.title = '点一下放大';
|
|
345
325
|
stage.appendChild(cleanSvg);
|
|
346
326
|
|
|
347
|
-
var preEl = ctx.pre;
|
|
348
|
-
if (window.hljs && ctx.code) { try { hljs.highlightElement(ctx.code); } catch (e) {} }
|
|
349
327
|
preEl.classList.add('zsvg-code');
|
|
350
|
-
|
|
351
328
|
wrap.appendChild(bar);
|
|
352
329
|
wrap.appendChild(stage);
|
|
353
330
|
wrap.appendChild(preEl);
|
|
354
|
-
|
|
355
|
-
var modeBtn = bar.querySelector('[data-svg-mode]');
|
|
356
|
-
var zoomBtn = bar.querySelector('[data-svg-zoom]');
|
|
357
|
-
modeBtn.addEventListener('click', function (ev) {
|
|
358
|
-
ev.stopPropagation();
|
|
359
|
-
var showCode = wrap.classList.toggle('is-code');
|
|
360
|
-
modeBtn.textContent = showCode ? '视图' : '源码';
|
|
361
|
-
modeBtn.classList.toggle('active', showCode);
|
|
362
|
-
if (document.body.dataset.mode === 'cards') { try { repinPorts(); drawWires(); } catch (e) {} }
|
|
363
|
-
});
|
|
364
|
-
zoomBtn.addEventListener('click', function (ev) {
|
|
365
|
-
ev.stopPropagation();
|
|
366
|
-
var svgEl = $('.zsvg-stage svg', wrap);
|
|
367
|
-
if (svgEl) openLens(svgEl.outerHTML, 'SVG 矢量图', 'media');
|
|
368
|
-
});
|
|
369
331
|
return wrap;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
CladoBlockRegistry.register('svg', function (rawCode, lang, ctx) {
|
|
335
|
+
var cleanSvg = sanitizeSvgMarkup(rawCode);
|
|
336
|
+
if (!cleanSvg) return null;
|
|
337
|
+
if (window.hljs && ctx.code) { try { hljs.highlightElement(ctx.code); } catch (e) {} }
|
|
338
|
+
return createSvgBlock(rawCode, cleanSvg, ctx.pre);
|
|
370
339
|
});
|
|
371
340
|
|
|
372
341
|
CladoBlockRegistry.register(['ui', 'html-preview'], function (rawCode, lang, ctx) {
|
|
@@ -385,12 +354,24 @@
|
|
|
385
354
|
box.className = 'markdown-body';
|
|
386
355
|
if (!md) return box;
|
|
387
356
|
var template = document.createElement('template'); template.innerHTML = marked.parse(md);
|
|
357
|
+
// 兼容 AI 直接在正文中裸写 <svg>...</svg>(不带 ```svg 围栏)时同样安全清洗并支持放大
|
|
358
|
+
var inlineSvgs = [];
|
|
359
|
+
Array.from(template.content.querySelectorAll('svg')).forEach(function (svgNode) {
|
|
360
|
+
if (svgNode.parentNode && svgNode.parentNode.closest && svgNode.parentNode.closest('svg')) return;
|
|
361
|
+
var rawSvg = svgNode.outerHTML || '';
|
|
362
|
+
var cleaned = sanitizeSvgMarkup(rawSvg);
|
|
363
|
+
if (!cleaned) { svgNode.remove(); return; }
|
|
364
|
+
var ph = document.createElement('div');
|
|
365
|
+
ph.dataset.cladoInlineSvg = String(inlineSvgs.length);
|
|
366
|
+
inlineSvgs.push({ raw: rawSvg, node: cleaned });
|
|
367
|
+
svgNode.parentNode.replaceChild(ph, svgNode);
|
|
368
|
+
});
|
|
388
369
|
var tags = new Set('a p br hr em strong del code pre blockquote ul ol li table thead tbody tr th td img h1 h2 h3 h4 h5 h6 details summary sub sup kbd span div'.split(' '));
|
|
389
370
|
Array.from(template.content.querySelectorAll('*')).forEach(function (element) {
|
|
390
371
|
var tag = element.localName;
|
|
391
372
|
if (!tags.has(tag)) { element.remove(); return; }
|
|
392
373
|
Array.from(element.attributes).forEach(function (attribute) {
|
|
393
|
-
var name=attribute.name, value=attribute.value, allow=['title','alt','width','height','start','align'].includes(name);
|
|
374
|
+
var name=attribute.name, value=attribute.value, allow=['title','alt','width','height','start','align','data-clado-inline-svg'].includes(name);
|
|
394
375
|
if (name === 'class' && tag === 'code') allow = /^language-[\w+#.-]+$/.test(value);
|
|
395
376
|
if (name === 'href' && tag === 'a') allow = !/^[a-z][a-z0-9+.-]*:/i.test(value.replace(/[\x00-\x20]/g,'')) || /^(https?:|mailto:|tel:)/i.test(value);
|
|
396
377
|
if (name === 'src' && tag === 'img') allow = !/^[a-z][a-z0-9+.-]*:/i.test(value.replace(/[\x00-\x20]/g,'')) || /^(https?:|data:image\/(png|jpeg|gif|webp);base64,)/i.test(value);
|
|
@@ -399,7 +380,21 @@
|
|
|
399
380
|
});
|
|
400
381
|
box.appendChild(template.content);
|
|
401
382
|
|
|
402
|
-
//
|
|
383
|
+
// 还原裸写 <svg> 为带「放大 / 源码」的 .zoomable.zsvg
|
|
384
|
+
$$('[data-clado-inline-svg]', box).forEach(function (ph) {
|
|
385
|
+
var entry = inlineSvgs[Number(ph.dataset.cladoInlineSvg)];
|
|
386
|
+
if (!entry) { ph.remove(); return; }
|
|
387
|
+
var pre = document.createElement('pre');
|
|
388
|
+
var code = document.createElement('code');
|
|
389
|
+
code.className = 'language-svg';
|
|
390
|
+
code.textContent = entry.raw;
|
|
391
|
+
pre.appendChild(code);
|
|
392
|
+
if (window.hljs) { try { hljs.highlightElement(code); } catch (e) {} }
|
|
393
|
+
var svgBlock = createSvgBlock(entry.raw, entry.node, pre);
|
|
394
|
+
ph.parentNode.replaceChild(svgBlock, ph);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// 媒体交付件升级:视频 / 音频 / 可放大普通图片(含 .png/.jpg/.webp/.gif/.svg)
|
|
403
398
|
$$('img[src]', box).forEach(function (img) {
|
|
404
399
|
var src = img.getAttribute('src') || '';
|
|
405
400
|
var alt = (img.getAttribute('alt') || '').trim();
|
|
@@ -436,6 +431,22 @@
|
|
|
436
431
|
audio.setAttribute('src', src);
|
|
437
432
|
aw.appendChild(audio);
|
|
438
433
|
img.parentNode.replaceChild(aw, img);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
// 普通图片同样包进 .zoomable.zimg,点击即弹出放大镜全屏缩放查看
|
|
437
|
+
if (!img.closest('.zoomable')) {
|
|
438
|
+
var iw = document.createElement('div');
|
|
439
|
+
iw.className = 'zoomable zimg';
|
|
440
|
+
iw.dataset.label = alt || '图片';
|
|
441
|
+
iw.title = '点一下放大';
|
|
442
|
+
img.parentNode.insertBefore(iw, img);
|
|
443
|
+
iw.appendChild(img);
|
|
444
|
+
if (alt) {
|
|
445
|
+
var icap = document.createElement('div');
|
|
446
|
+
icap.className = 'zmedia-cap';
|
|
447
|
+
icap.textContent = alt;
|
|
448
|
+
iw.appendChild(icap);
|
|
449
|
+
}
|
|
439
450
|
}
|
|
440
451
|
});
|
|
441
452
|
|
|
@@ -486,6 +497,10 @@
|
|
|
486
497
|
z.className = 'zoomable zcode';
|
|
487
498
|
z.dataset.label = (lang || '代码') + ' 代码';
|
|
488
499
|
z.title = '点一下放大';
|
|
500
|
+
if (lang === 'html') {
|
|
501
|
+
z.dataset.lang = 'html';
|
|
502
|
+
z.dataset.rawSource = rawCode;
|
|
503
|
+
}
|
|
489
504
|
pre.parentNode.insertBefore(z, pre);
|
|
490
505
|
z.appendChild(pre);
|
|
491
506
|
if (lang === 'html') {
|
|
@@ -494,12 +509,6 @@
|
|
|
494
509
|
prevBtn.className = 'zcode-preview-btn';
|
|
495
510
|
prevBtn.textContent = '预览';
|
|
496
511
|
prevBtn.title = '在隔离沙盒中实时预览此 HTML';
|
|
497
|
-
prevBtn.addEventListener('click', function (ev) {
|
|
498
|
-
ev.stopPropagation();
|
|
499
|
-
var uiBlock = createUiPreviewBlock(rawCode, pre);
|
|
500
|
-
if (z.parentNode) z.parentNode.replaceChild(uiBlock, z);
|
|
501
|
-
if (document.body.dataset.mode === 'cards') { try { repinPorts(); drawWires(); } catch (e) {} }
|
|
502
|
-
});
|
|
503
512
|
z.appendChild(prevBtn);
|
|
504
513
|
}
|
|
505
514
|
});
|
|
@@ -1631,9 +1640,11 @@
|
|
|
1631
1640
|
function lensFit() {
|
|
1632
1641
|
var st = $('#lensStage').getBoundingClientRect(), inn = $('#lensInner');
|
|
1633
1642
|
var w = inn.offsetWidth, h = inn.offsetHeight;
|
|
1643
|
+
if (!w || !h || !st.width || !st.height) return;
|
|
1634
1644
|
// 一行代码也撑到 400% 就太夸张了,留个上限
|
|
1635
1645
|
var cap = Number(inn.dataset.cap || 4);
|
|
1636
|
-
|
|
1646
|
+
var fitScale = Math.min((st.width - 90) / w, (st.height - 140) / h);
|
|
1647
|
+
ls = Math.max(0.2, Math.min(cap, isFinite(fitScale) && fitScale > 0 ? fitScale : 1));
|
|
1637
1648
|
lx = (st.width - w * ls) / 2; ly = (st.height - h * ls) / 2;
|
|
1638
1649
|
lensApply();
|
|
1639
1650
|
}
|
|
@@ -1642,15 +1653,33 @@
|
|
|
1642
1653
|
lensSeq++;
|
|
1643
1654
|
var inn = $('#lensInner');
|
|
1644
1655
|
inn.innerHTML = kind ? '<div class="markdown-body">' + html + '</div>' : html;
|
|
1645
|
-
if (kind) {
|
|
1646
|
-
|
|
1656
|
+
if (kind) {
|
|
1657
|
+
inn.dataset.cap = kind === 'code' ? '2.2' : kind === 'ui' ? '1.5' : '3';
|
|
1658
|
+
inn.dataset.kind = kind;
|
|
1659
|
+
} else {
|
|
1660
|
+
delete inn.dataset.cap; delete inn.dataset.kind;
|
|
1661
|
+
}
|
|
1647
1662
|
$$('svg', inn).forEach(function (s) {
|
|
1648
1663
|
var vb = s.viewBox && s.viewBox.baseVal;
|
|
1664
|
+
var vbW = (vb && vb.width > 0) ? vb.width : 0;
|
|
1665
|
+
var vbH = (vb && vb.height > 0) ? vb.height : 0;
|
|
1666
|
+
if (!vbW || !vbH) {
|
|
1667
|
+
var vbAttr = String(s.getAttribute('viewBox') || '').trim().split(/[\s,]+/);
|
|
1668
|
+
if (vbAttr.length === 4) {
|
|
1669
|
+
vbW = parseFloat(vbAttr[2]) || vbW;
|
|
1670
|
+
vbH = parseFloat(vbAttr[3]) || vbH;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
var targetW = vbW || 640;
|
|
1674
|
+
var targetH = vbH || Math.round(targetW * 0.625);
|
|
1649
1675
|
s.removeAttribute('width'); s.removeAttribute('height');
|
|
1650
|
-
s.style.width =
|
|
1651
|
-
s.style.height = '
|
|
1676
|
+
s.style.width = targetW + 'px';
|
|
1677
|
+
s.style.height = targetH + 'px';
|
|
1678
|
+
});
|
|
1679
|
+
$$('img', inn).forEach(function (i) {
|
|
1680
|
+
i.style.maxWidth = 'none';
|
|
1681
|
+
if (!i.complete) i.addEventListener('load', function () { requestAnimationFrame(lensFit); }, { once: true });
|
|
1652
1682
|
});
|
|
1653
|
-
$$('img', inn).forEach(function (i) { i.style.maxWidth = 'none'; });
|
|
1654
1683
|
$('#lensLabel').textContent = label || '图';
|
|
1655
1684
|
if (!$('#lens').classList.contains('open')) {
|
|
1656
1685
|
$('#lens').classList.add('open');
|
|
@@ -1679,16 +1708,93 @@
|
|
|
1679
1708
|
var st = $('#lensStage');
|
|
1680
1709
|
var pointer = null, dragged = false, sx = 0, sy = 0, ox = 0, oy = 0;
|
|
1681
1710
|
document.addEventListener('click', function (e) {
|
|
1711
|
+
// 1. 富媒体块工具栏按钮统一委托(兼容卡片/脑图/文档与克隆链路弹窗)
|
|
1712
|
+
var svgZoomBtn = e.target.closest('[data-svg-zoom]');
|
|
1713
|
+
if (svgZoomBtn) {
|
|
1714
|
+
e.stopPropagation();
|
|
1715
|
+
var svgWrap = svgZoomBtn.closest('.zsvg');
|
|
1716
|
+
var svgNode = svgWrap && $('.zsvg-stage svg', svgWrap);
|
|
1717
|
+
if (svgNode) openLens(svgNode.outerHTML, svgWrap.dataset.label || 'SVG 矢量图', 'media');
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
var svgModeBtn = e.target.closest('[data-svg-mode]');
|
|
1721
|
+
if (svgModeBtn) {
|
|
1722
|
+
e.stopPropagation();
|
|
1723
|
+
var svgW = svgModeBtn.closest('.zsvg');
|
|
1724
|
+
if (!svgW) return;
|
|
1725
|
+
var showSvgCode = svgW.classList.toggle('is-code');
|
|
1726
|
+
svgModeBtn.textContent = showSvgCode ? '视图' : '源码';
|
|
1727
|
+
svgModeBtn.classList.toggle('active', showSvgCode);
|
|
1728
|
+
if (document.body.dataset.mode === 'cards') { try { repinPorts(); drawWires(); } catch (err) {} }
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
var uiVpBtn = e.target.closest('[data-ui-vp]');
|
|
1732
|
+
if (uiVpBtn) {
|
|
1733
|
+
e.stopPropagation();
|
|
1734
|
+
var uiW = uiVpBtn.closest('.zui');
|
|
1735
|
+
if (!uiW) return;
|
|
1736
|
+
var isMob = uiVpBtn.dataset.uiVp === 'mobile';
|
|
1737
|
+
uiW.classList.toggle('is-mobile', isMob);
|
|
1738
|
+
$$('[data-ui-vp]', uiW).forEach(function (b) { b.classList.toggle('active', b === uiVpBtn); });
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1741
|
+
var uiModeBtn = e.target.closest('[data-ui-mode]');
|
|
1742
|
+
if (uiModeBtn) {
|
|
1743
|
+
e.stopPropagation();
|
|
1744
|
+
var uiM = uiModeBtn.closest('.zui');
|
|
1745
|
+
if (!uiM) return;
|
|
1746
|
+
var showUiCode = uiM.classList.toggle('is-code');
|
|
1747
|
+
uiModeBtn.textContent = showUiCode ? '预览' : '代码';
|
|
1748
|
+
uiModeBtn.classList.toggle('active', showUiCode);
|
|
1749
|
+
if (document.body.dataset.mode === 'cards') { try { repinPorts(); drawWires(); } catch (err) {} }
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
var uiZoomBtn = e.target.closest('[data-ui-zoom]');
|
|
1753
|
+
if (uiZoomBtn) {
|
|
1754
|
+
e.stopPropagation();
|
|
1755
|
+
var uiZ = uiZoomBtn.closest('.zui');
|
|
1756
|
+
var uiRaw = uiZ ? (uiZ.dataset.rawSource || ($('pre code', uiZ)?.textContent || '')) : '';
|
|
1757
|
+
var lensHtml = '<iframe class="zui-lens-frame" sandbox="allow-scripts" title="UI 原型全屏预览"></iframe>';
|
|
1758
|
+
openLens(lensHtml, 'UI 原型预览', 'ui');
|
|
1759
|
+
var lensFr = $('#lensInner .zui-lens-frame');
|
|
1760
|
+
if (lensFr) lensFr.srcdoc = buildUiSandboxDoc(uiRaw, '');
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
var htmlPrevBtn = e.target.closest('.zcode-preview-btn');
|
|
1764
|
+
if (htmlPrevBtn) {
|
|
1765
|
+
e.stopPropagation();
|
|
1766
|
+
var zc = htmlPrevBtn.closest('.zcode');
|
|
1767
|
+
var preEl = zc && $('pre', zc);
|
|
1768
|
+
if (!zc || !preEl) return;
|
|
1769
|
+
var rawHtml = zc.dataset.rawSource || ($('code', preEl)?.textContent || '');
|
|
1770
|
+
var uiBlock = createUiPreviewBlock(rawHtml, preEl);
|
|
1771
|
+
if (zc.parentNode) zc.parentNode.replaceChild(uiBlock, zc);
|
|
1772
|
+
if (document.body.dataset.mode === 'cards') { try { repinPorts(); drawWires(); } catch (err) {} }
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
// 2. 点击任意 .zoomable 内容区(图片 / SVG / Mermaid / 代码 / 表格)直接弹出放大镜
|
|
1682
1777
|
var z = e.target.closest('.zoomable');
|
|
1683
1778
|
if (z && !e.target.closest('a.edge,.zblock-bar,.zblock-btn,.zcode-preview-btn,iframe,video,audio')) {
|
|
1684
|
-
if (z.classList.contains('zui')
|
|
1779
|
+
if (z.classList.contains('zui')) {
|
|
1780
|
+
if (z.classList.contains('is-code')) {
|
|
1781
|
+
var uiCode = $('pre', z);
|
|
1782
|
+
if (uiCode) openLens(uiCode.outerHTML, 'UI 源码', 'code');
|
|
1783
|
+
} else {
|
|
1784
|
+
var uiSrc = z.dataset.rawSource || ($('pre code', z)?.textContent || '');
|
|
1785
|
+
openLens('<iframe class="zui-lens-frame" sandbox="allow-scripts" title="UI 原型全屏预览"></iframe>', 'UI 原型预览', 'ui');
|
|
1786
|
+
var lFr = $('#lensInner .zui-lens-frame');
|
|
1787
|
+
if (lFr) lFr.srcdoc = buildUiSandboxDoc(uiSrc, '');
|
|
1788
|
+
}
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1685
1791
|
if (z.classList.contains('zsvg')) {
|
|
1686
1792
|
if (z.classList.contains('is-code')) {
|
|
1687
1793
|
var svgCode = $('pre', z);
|
|
1688
1794
|
if (svgCode) openLens(svgCode.outerHTML, 'SVG 源码', 'code');
|
|
1689
1795
|
} else {
|
|
1690
|
-
var
|
|
1691
|
-
if (
|
|
1796
|
+
var svgEl = $('.zsvg-stage svg', z);
|
|
1797
|
+
if (svgEl) openLens(svgEl.outerHTML, z.dataset.label || 'SVG 矢量图', 'media');
|
|
1692
1798
|
}
|
|
1693
1799
|
return;
|
|
1694
1800
|
}
|
|
@@ -1721,7 +1827,7 @@
|
|
|
1721
1827
|
st.addEventListener('pointerdown', function (e) {
|
|
1722
1828
|
if (pointer !== null) return;
|
|
1723
1829
|
dragged = false;
|
|
1724
|
-
if (e.button !== 0 || e.target.closest('pre,table,svg text,svg foreignObject,a')) return;
|
|
1830
|
+
if (e.button !== 0 || e.target.closest('pre,table,svg text,svg foreignObject,a,iframe')) return;
|
|
1725
1831
|
pointer = e.pointerId;
|
|
1726
1832
|
sx = e.clientX; sy = e.clientY; ox = lx; oy = ly;
|
|
1727
1833
|
});
|
|
@@ -268,12 +268,21 @@ iframe { height: 100%; width: 100%; display: block; border: 0; background: trans
|
|
|
268
268
|
position: absolute;
|
|
269
269
|
inset: 0;
|
|
270
270
|
display: flex;
|
|
271
|
+
flex-direction: column;
|
|
271
272
|
align-items: center;
|
|
272
273
|
justify-content: center;
|
|
274
|
+
gap: 16px;
|
|
273
275
|
padding: 64px 28px 28px;
|
|
274
276
|
background: transparent;
|
|
277
|
+
overflow-y: auto;
|
|
275
278
|
z-index: 12;
|
|
276
279
|
}
|
|
280
|
+
.empty-state > p {
|
|
281
|
+
margin: 0;
|
|
282
|
+
font-size: 13.5px;
|
|
283
|
+
color: var(--clado-ui-muted, var(--muted));
|
|
284
|
+
text-align: center;
|
|
285
|
+
}
|
|
277
286
|
.clado-empty-card {
|
|
278
287
|
width: min(720px, calc(100% - 32px));
|
|
279
288
|
border-radius: 26px;
|
|
@@ -285,6 +294,7 @@ iframe { height: 100%; width: 100%; display: block; border: 0; background: trans
|
|
|
285
294
|
border: 1px solid var(--clado-ui-glass-outline);
|
|
286
295
|
box-shadow: var(--clado-ui-glass-shadow);
|
|
287
296
|
text-align: left;
|
|
297
|
+
flex: none;
|
|
288
298
|
}
|
|
289
299
|
.clado-prism-aura-under {
|
|
290
300
|
position: absolute;
|
|
@@ -331,6 +341,135 @@ iframe { height: 100%; width: 100%; display: block; border: 0; background: trans
|
|
|
331
341
|
box-shadow: var(--clado-ui-prism-shadow);
|
|
332
342
|
}
|
|
333
343
|
|
|
344
|
+
/* Discovered Sub-Workspaces Grid inside Empty State */
|
|
345
|
+
.empty-workspaces {
|
|
346
|
+
margin-top: 20px;
|
|
347
|
+
padding-top: 18px;
|
|
348
|
+
border-top: 1px solid var(--clado-ui-edge, var(--line));
|
|
349
|
+
display: flex;
|
|
350
|
+
flex-direction: column;
|
|
351
|
+
gap: 12px;
|
|
352
|
+
text-align: left;
|
|
353
|
+
}
|
|
354
|
+
.empty-state > .empty-workspaces {
|
|
355
|
+
margin-top: 0;
|
|
356
|
+
width: min(720px, calc(100% - 32px));
|
|
357
|
+
padding: 24px 26px;
|
|
358
|
+
border-radius: 24px;
|
|
359
|
+
background: var(--clado-ui-surface);
|
|
360
|
+
backdrop-filter: blur(24px) saturate(190%) brightness(1.03);
|
|
361
|
+
-webkit-backdrop-filter: blur(24px) saturate(190%) brightness(1.03);
|
|
362
|
+
border: 1px solid var(--clado-ui-glass-outline, var(--line));
|
|
363
|
+
box-shadow: var(--clado-ui-glass-shadow);
|
|
364
|
+
}
|
|
365
|
+
.empty-workspaces-head {
|
|
366
|
+
display: flex;
|
|
367
|
+
align-items: center;
|
|
368
|
+
justify-content: space-between;
|
|
369
|
+
gap: 10px;
|
|
370
|
+
}
|
|
371
|
+
.empty-workspaces-title {
|
|
372
|
+
font-size: 12.5px;
|
|
373
|
+
font-weight: 620;
|
|
374
|
+
color: var(--clado-ui-text-soft, var(--ink));
|
|
375
|
+
letter-spacing: -0.01em;
|
|
376
|
+
}
|
|
377
|
+
.empty-workspaces-count {
|
|
378
|
+
font-size: 11px;
|
|
379
|
+
font-weight: 560;
|
|
380
|
+
color: var(--clado-ui-muted, var(--muted));
|
|
381
|
+
padding: 2px 8px;
|
|
382
|
+
border-radius: 999px;
|
|
383
|
+
background: var(--clado-ui-well);
|
|
384
|
+
border: 1px solid var(--clado-ui-well-border, var(--line));
|
|
385
|
+
}
|
|
386
|
+
.empty-workspaces-grid {
|
|
387
|
+
display: grid;
|
|
388
|
+
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
|
389
|
+
gap: 10px;
|
|
390
|
+
max-height: 230px;
|
|
391
|
+
overflow-y: auto;
|
|
392
|
+
padding: 2px 2px 4px;
|
|
393
|
+
}
|
|
394
|
+
.empty-workspace-card {
|
|
395
|
+
display: flex;
|
|
396
|
+
align-items: center;
|
|
397
|
+
gap: 10px;
|
|
398
|
+
padding: 11px 13px;
|
|
399
|
+
border-radius: 14px;
|
|
400
|
+
background: var(--clado-ui-well);
|
|
401
|
+
border: 1px solid var(--clado-ui-well-border, var(--line));
|
|
402
|
+
box-shadow: inset 0 1px 0 var(--clado-ui-highlight, rgba(255, 255, 255, 0.5));
|
|
403
|
+
color: var(--clado-ui-text, var(--ink));
|
|
404
|
+
text-decoration: none;
|
|
405
|
+
min-width: 0;
|
|
406
|
+
transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), background-color 150ms ease, border-color 150ms ease, box-shadow 160ms ease;
|
|
407
|
+
}
|
|
408
|
+
.empty-workspace-card:hover {
|
|
409
|
+
transform: translateY(-1.5px);
|
|
410
|
+
background: var(--clado-ui-hover);
|
|
411
|
+
border-color: var(--clado-ui-prism-border, var(--clado-ui-hover-border));
|
|
412
|
+
box-shadow: 0 10px 24px -12px rgba(56, 189, 248, 0.22), inset 0 1px 0 var(--clado-ui-highlight, rgba(255, 255, 255, 0.6));
|
|
413
|
+
}
|
|
414
|
+
.empty-workspace-card:focus-visible {
|
|
415
|
+
outline: 2px solid var(--accent);
|
|
416
|
+
outline-offset: 2px;
|
|
417
|
+
}
|
|
418
|
+
.empty-workspace-ico {
|
|
419
|
+
width: 30px;
|
|
420
|
+
height: 30px;
|
|
421
|
+
border-radius: 9px;
|
|
422
|
+
flex: none;
|
|
423
|
+
display: inline-flex;
|
|
424
|
+
align-items: center;
|
|
425
|
+
justify-content: center;
|
|
426
|
+
background: var(--clado-ui-prism-bg, rgba(56, 189, 248, 0.12));
|
|
427
|
+
border: 1px solid var(--clado-ui-prism-border, rgba(56, 189, 248, 0.24));
|
|
428
|
+
color: var(--accent);
|
|
429
|
+
}
|
|
430
|
+
.empty-workspace-ico svg {
|
|
431
|
+
width: 15px;
|
|
432
|
+
height: 15px;
|
|
433
|
+
stroke: currentColor;
|
|
434
|
+
fill: none;
|
|
435
|
+
stroke-width: 1.85;
|
|
436
|
+
stroke-linecap: round;
|
|
437
|
+
stroke-linejoin: round;
|
|
438
|
+
}
|
|
439
|
+
.empty-workspace-meta {
|
|
440
|
+
min-width: 0;
|
|
441
|
+
flex: 1;
|
|
442
|
+
display: flex;
|
|
443
|
+
flex-direction: column;
|
|
444
|
+
gap: 2px;
|
|
445
|
+
}
|
|
446
|
+
.empty-workspace-name {
|
|
447
|
+
font-size: 12.5px;
|
|
448
|
+
font-weight: 600;
|
|
449
|
+
color: var(--clado-ui-text, var(--ink));
|
|
450
|
+
overflow: hidden;
|
|
451
|
+
text-overflow: ellipsis;
|
|
452
|
+
white-space: nowrap;
|
|
453
|
+
}
|
|
454
|
+
.empty-workspace-card small {
|
|
455
|
+
font-size: 11px;
|
|
456
|
+
color: var(--clado-ui-muted, var(--muted));
|
|
457
|
+
line-height: 1.3;
|
|
458
|
+
}
|
|
459
|
+
.empty-workspace-arrow {
|
|
460
|
+
flex: none;
|
|
461
|
+
width: 14px;
|
|
462
|
+
height: 14px;
|
|
463
|
+
color: var(--clado-ui-subtle, var(--muted));
|
|
464
|
+
opacity: 0.65;
|
|
465
|
+
transition: transform 160ms ease, opacity 160ms ease, color 160ms ease;
|
|
466
|
+
}
|
|
467
|
+
.empty-workspace-card:hover .empty-workspace-arrow {
|
|
468
|
+
opacity: 1;
|
|
469
|
+
color: var(--accent);
|
|
470
|
+
transform: translateX(2px);
|
|
471
|
+
}
|
|
472
|
+
|
|
334
473
|
/* Toast */
|
|
335
474
|
.clado-toast {
|
|
336
475
|
position: absolute;
|