cladogram 0.3.1 → 0.5.2
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 +57 -365
- package/bin/clado.js +126 -72
- package/package.json +11 -8
- package/skills/clado/SKILL.md +123 -747
- package/src/core/links.js +37 -0
- package/src/core/media-links.js +99 -0
- package/src/core/parse.js +81 -82
- package/src/html/app-css.js +51 -75
- package/src/html/canvas-card.js +65 -0
- package/src/html/canvas-chain.js +231 -0
- package/src/html/canvas-focus.js +175 -0
- package/src/html/canvas-ui.css +38 -0
- package/src/html/canvas-ui.js +40 -0
- package/src/html/canvas-wires.js +73 -0
- package/src/html/media-anchors.js +212 -0
- package/src/html/mindmap-connectors.js +78 -0
- package/src/html/mindmap-media.js +39 -0
- package/src/html/page.js +23 -4
- package/src/html/runtime-api.js +51 -0
- package/src/html/runtime-fixes.js +32 -0
- package/src/html/runtime.js +322 -272
- package/src/server/assets/library-canvas.js +96 -0
- package/src/server/assets/library.css +9 -0
- package/src/server/assets/library.html +20 -0
- package/src/server/assets/library.js +127 -0
- package/src/server/assets/tree.js +26 -0
- package/src/server/export.js +53 -0
- package/src/server/mcp.js +108 -0
- package/src/server/workspace.js +84 -0
- package/src/skill/install.js +16 -18
- package/src/skill/targets.js +28 -12
- package/src/skill/templates.js +60 -0
- package/src/util/version.js +3 -0
- package/src/workspace/content.js +72 -0
- package/src/workspace/documents.js +65 -0
- package/src/workspace/references.js +101 -0
- package/src/workspace/service.js +457 -0
- package/src/workspace/storage.js +169 -0
- package/src/workspace/tree.js +66 -0
- package/templates/business-flow.mdc +29 -0
- package/templates/call-chain.mdc +62 -0
- package/templates/data-design.mdc +35 -0
- package/templates/mind-expansion.mdc +52 -0
- package/templates/requirement-overview.mdc +29 -0
- package/templates/system-state.mdc +29 -0
- package/examples/showcase/README.md +0 -115
- package/examples/showcase/baseline.md +0 -365
- package/examples/showcase/build.sh +0 -48
- package/examples/showcase/calls.md +0 -136
- package/examples/showcase/fulfill-cn.md +0 -351
- package/examples/showcase/fulfill.md +0 -271
- package/examples/showcase/index.md +0 -187
- package/examples/showcase/order.md +0 -195
- package/examples/showcase/promo.md +0 -580
- package/examples/showcase/refund.md +0 -966
- package/examples/showcase/seckill.md +0 -787
- package/skills/clado/examples/01-/351/234/200/346/261/202/346/240/221.md +0 -32
- package/skills/clado/examples/02-/346/225/260/346/215/256/350/241/250.md +0 -44
- package/skills/clado/examples/03-/346/216/245/345/217/243/346/270/205/345/215/225.md +0 -51
- package/skills/clado/examples/04-/346/226/271/346/263/225/351/223/276.md +0 -70
- package/skills/clado/examples/05-/346/216/245/345/217/243/350/260/203/347/224/250.md +0 -58
- package/skills/clado/examples/06-/350/260/203/347/224/250/351/223/276.md +0 -49
- package/skills/clado/examples/07-/346/213/206/346/226/207/346/241/243/index.md +0 -38
- package/skills/clado/examples/07-/346/213/206/346/226/207/346/241/243/refund.md +0 -33
- package/skills/clado/examples/07-/346/213/206/346/226/207/346/241/243/seckill.md +0 -56
- package/skills/clado/examples/08-/347/234/237/345/256/236/350/247/204/346/250/241//346/216/245/345/217/243/345/245/221/347/272/246.md +0 -122
- package/skills/clado/examples/08-/347/234/237/345/256/236/350/247/204/346/250/241//346/225/205/351/232/234/345/244/215/347/233/230.md +0 -99
- package/skills/clado/examples/08-/347/234/237/345/256/236/350/247/204/346/250/241//350/260/203/347/224/250/351/223/276.md +0 -219
- package/skills/clado/examples/build.sh +0 -44
- package/skills/clado/references/diagnostics.md +0 -129
package/src/html/app-css.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
export const APP_CSS = String.raw`
|
|
19
19
|
|
|
20
|
+
:root{--canvas-card-width:750px}
|
|
21
|
+
|
|
20
22
|
/* ══ 我们自己的壳 ══════════════════════════════════════════════
|
|
21
23
|
正文的样子交给 vendor 里那套(github-markdown-css + highlight.js),
|
|
22
24
|
这里只管:顶栏、画布、卡片外壳、缩进、线、放大镜。 */
|
|
@@ -112,13 +114,18 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
112
114
|
#wires path.w-soft{stroke-dasharray:5 4; stroke-width:1.6; stroke-opacity:.45}
|
|
113
115
|
|
|
114
116
|
/* ── 卡片 ───────────────────────────────────────────────── */
|
|
115
|
-
.card{
|
|
116
|
-
position:absolute;
|
|
117
|
+
.canvas-card{
|
|
118
|
+
position:absolute; background:var(--panel);
|
|
117
119
|
border:1px solid var(--line); border-radius:11px; box-shadow:var(--shadow);
|
|
118
120
|
z-index:1; display:flex; flex-direction:column;
|
|
121
|
+
}
|
|
122
|
+
.card{
|
|
123
|
+
width:var(--canvas-card-width);
|
|
119
124
|
transition:opacity .18s, box-shadow .18s, border-color .18s,
|
|
120
125
|
left .26s cubic-bezier(.2,.7,.3,1), top .26s cubic-bezier(.2,.7,.3,1);
|
|
121
126
|
}
|
|
127
|
+
.canvas-card.card-gesturing{transition:none!important;z-index:3}
|
|
128
|
+
.canvas-card.card-gesturing > .bar,.canvas-card.card-gesturing .grip{cursor:grabbing}
|
|
122
129
|
/* 第一次摆位置的时候别从 0,0 滑过来 —— 那是开场动画,不是交互 */
|
|
123
130
|
#world:not(.ready) .card{transition:none}
|
|
124
131
|
/* 收放之后镜头平滑移过去 —— 只在 glideCam() 临时挂上这个 class 的这几百毫秒里生效,
|
|
@@ -126,7 +133,7 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
126
133
|
|
|
127
134
|
/* 右下角:拖着改卡片大小 */
|
|
128
135
|
.rz{position:absolute; right:0; bottom:0; width:18px; height:18px; cursor:nwse-resize; opacity:0; transition:opacity .12s}
|
|
129
|
-
.card:hover .rz{opacity:.55}
|
|
136
|
+
.canvas-card:hover .rz{opacity:.55}
|
|
130
137
|
.rz:hover{opacity:1 !important}
|
|
131
138
|
.rz::after{
|
|
132
139
|
content:''; position:absolute; right:3px; bottom:3px; width:7px; height:7px;
|
|
@@ -134,11 +141,11 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
134
141
|
}
|
|
135
142
|
.card.dim{opacity:.22}
|
|
136
143
|
.card.lit{border-color:var(--accent)}
|
|
137
|
-
.bar{
|
|
138
|
-
height:26px; display:flex; align-items:center; gap:4px; padding:0 6px 0 8px;
|
|
144
|
+
.canvas-card > .bar{
|
|
145
|
+
flex:0 0 26px; height:26px; display:flex; align-items:center; gap:4px; padding:0 6px 0 8px;
|
|
139
146
|
border-bottom:1px solid var(--line-2); cursor:grab;
|
|
140
147
|
}
|
|
141
|
-
.bar .grip{color:var(--
|
|
148
|
+
.canvas-card .bar .grip{color:var(--fg-2);opacity:.55; font-size:13px; letter-spacing:1px; cursor:grab}
|
|
142
149
|
.bar .sp{flex:1}
|
|
143
150
|
.bar .b{
|
|
144
151
|
width:22px; height:20px; display:grid; place-items:center; border:0; border-radius:5px;
|
|
@@ -154,13 +161,10 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
154
161
|
/* overflow 用 auto:卡片默认是「刚好包住内容」的,不会出滚动条;
|
|
155
162
|
只有用户自己把右下角往上拖矮了,内容装不下,才出现滚动条让他看全。 */
|
|
156
163
|
.body{position:relative; padding:10px 14px 14px; flex:1 1 auto; min-height:0; overflow:auto}
|
|
157
|
-
|
|
158
|
-
一千多像素的长条 —— 一行太长根本没法读。阅读宽度锁在 560px,
|
|
159
|
-
图和表格该多宽还多宽(它们自己有自己的宽度)。 */
|
|
160
|
-
.card .body p,.card .body li,.card .body h1,.card .body h2,.card .body h3,
|
|
161
|
-
.card .body h4,.card .body h5,.card .body h6,.card .body .slice-head{max-width:560px}
|
|
164
|
+
.canvas-card .markdown-body{overflow-wrap:anywhere}
|
|
162
165
|
/* 缩进:每一片自己带 --d(2..6),内容整体往右让 */
|
|
163
|
-
.slice{position:relative
|
|
166
|
+
.slice{position:relative}
|
|
167
|
+
.canvas-card .slice{padding-left:calc(max(0, var(--d) - 2) * 20px)}
|
|
164
168
|
|
|
165
169
|
/* ── 无序列表:不缩进,每层都用点 ─────────────────────────
|
|
166
170
|
层级不靠缩进表示,靠点的深浅(越深越淡、越小一点点),
|
|
@@ -188,13 +192,6 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
188
192
|
/* 缩进的层级用一根竖线标出来 —— 留白本身看不出「我是在谁下面」 */
|
|
189
193
|
/* 缩进标记:只贴在这一行标题旁边的一小段,但加粗上色 —— 灰的、1px 的根本看不出来 */
|
|
190
194
|
/* 二级怼到最左,三级开始缩进;三级以下的标题左边挂一根竖杠 */
|
|
191
|
-
.slice[style*="--d:3"]::before,
|
|
192
|
-
.slice[style*="--d:4"]::before,
|
|
193
|
-
.slice[style*="--d:5"]::before,
|
|
194
|
-
.slice[style*="--d:6"]::before{
|
|
195
|
-
content:''; position:absolute; top:2px; height:18px; width:3px; border-radius:2px;
|
|
196
|
-
left:calc((var(--d) - 2) * 22px - 14px); background:var(--accent);
|
|
197
|
-
}
|
|
198
195
|
.slice-head{display:flex; align-items:baseline; gap:6px; cursor:pointer; padding:2px 0; border-radius:5px}
|
|
199
196
|
/*
|
|
200
197
|
* 二到六级标题左边也来一根蓝竖杠,跟一级大标题那根呼应。
|
|
@@ -222,15 +219,15 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
222
219
|
background:var(--accent); opacity:.7; box-shadow:0 0 0 2px var(--panel);
|
|
223
220
|
cursor:pointer; transition:background .12s, opacity .12s, height .12s;
|
|
224
221
|
}
|
|
225
|
-
.card:hover .port{opacity:1}
|
|
222
|
+
.canvas-card:hover .port{opacity:1}
|
|
226
223
|
/* 关系端口:空心 + 浅,跟实心的调用端口区分开 */
|
|
227
224
|
.port.soft{background:transparent; border:1.5px solid var(--accent); opacity:.5; width:6px}
|
|
228
|
-
.card:hover .port.soft{opacity:.85}
|
|
225
|
+
.canvas-card:hover .port.soft{opacity:.85}
|
|
229
226
|
.port.soft.folded{background:transparent; border-color:var(--fg-2); opacity:.4}
|
|
230
227
|
/* 加宽点击热区:5px 宽实在不好点。伪元素不占布局,也不吃 pointer-events 以外的东西 */
|
|
231
228
|
.port::after{content:''; position:absolute; left:-7px; right:-7px; top:-4px; bottom:-4px}
|
|
232
229
|
.port.folded{background:var(--fg-2); opacity:.45}
|
|
233
|
-
.card:hover .port.folded{opacity:.8}
|
|
230
|
+
.canvas-card:hover .port.folded{opacity:.8}
|
|
234
231
|
.port.folded:hover{opacity:1}
|
|
235
232
|
/* 被收起来的下游:整张卡直接消失,位置也让出来 —— 展开时 layout() 会把位置重摆一遍。
|
|
236
233
|
原来只淡到 14% 还占着位,画布上留一堆虚影,看着像没加载出来。 */
|
|
@@ -252,31 +249,31 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
252
249
|
.card-title h1:hover{color:var(--accent)}
|
|
253
250
|
/* 入端口:卡片左上那根竖条 */
|
|
254
251
|
.hbar{position:absolute; left:-2px; top:34px; width:3px; height:26px; border-radius:2px; background:var(--accent); opacity:.8}
|
|
255
|
-
.card .markdown-body{background:transparent; font-size:12.5px; line-height:1.55}
|
|
252
|
+
.canvas-card .markdown-body{background:transparent; font-size:12.5px; line-height:1.55}
|
|
256
253
|
/* 外链:正常链接的样子 */
|
|
257
|
-
.card .markdown-body a{color:var(--accent); text-decoration:none; border-bottom:1px solid color-mix(in srgb, var(--accent) 35%, transparent)}
|
|
258
|
-
.card .markdown-body a:hover{background:var(--accent-soft)}
|
|
254
|
+
.canvas-card .markdown-body a{color:var(--accent); text-decoration:none; border-bottom:1px solid color-mix(in srgb, var(--accent) 35%, transparent)}
|
|
255
|
+
.canvas-card .markdown-body a:hover{background:var(--accent-soft)}
|
|
259
256
|
/* 内联链接是「图上的一条边」,不是外链 —— 不给蓝,免得整张卡蓝字 */
|
|
260
|
-
.card .markdown-body a.edge, #article .markdown-body a.edge, #lensInner .markdown-body a.edge{
|
|
257
|
+
.canvas-card .markdown-body a.edge, #article .markdown-body a.edge, #lensInner .markdown-body a.edge{
|
|
261
258
|
color:inherit; border-bottom:0; text-decoration:underline;
|
|
262
259
|
text-decoration-style:dotted; text-decoration-thickness:1px;
|
|
263
260
|
text-decoration-color:var(--line-2); text-underline-offset:2.5px;
|
|
264
261
|
}
|
|
265
|
-
.card .markdown-body a.edge:hover, #article .markdown-body a.edge:hover, #lensInner .markdown-body a.edge:hover{
|
|
262
|
+
.canvas-card .markdown-body a.edge:hover, #article .markdown-body a.edge:hover, #lensInner .markdown-body a.edge:hover{
|
|
266
263
|
color:var(--accent); background:transparent; text-decoration-color:var(--accent);
|
|
267
264
|
}
|
|
268
|
-
.card .markdown-body p{margin:0 0 6px}
|
|
269
|
-
.card .markdown-body p:last-child{margin-bottom:0}
|
|
270
|
-
.card .markdown-body pre{
|
|
265
|
+
.canvas-card .markdown-body p{margin:0 0 6px}
|
|
266
|
+
.canvas-card .markdown-body p:last-child{margin-bottom:0}
|
|
267
|
+
.canvas-card .markdown-body pre{
|
|
271
268
|
margin:6px 0 0; padding:7px 9px; border-radius:7px; border:1px solid var(--line-2);
|
|
272
269
|
white-space:pre-wrap; overflow-wrap:anywhere; font-size:11.5px; line-height:1.55;
|
|
273
270
|
}
|
|
274
|
-
.card .markdown-body pre code{background:transparent; padding:0; font-size:inherit; white-space:inherit}
|
|
275
|
-
.card .markdown-body code{
|
|
271
|
+
.canvas-card .markdown-body pre code{background:transparent; padding:0; font-size:inherit; white-space:inherit}
|
|
272
|
+
.canvas-card .markdown-body code{
|
|
276
273
|
font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,monospace;
|
|
277
274
|
font-size:11.5px; background:var(--bg); padding:.12em .35em; border-radius:4px;
|
|
278
275
|
}
|
|
279
|
-
.card .markdown-body table{font-size:11.5px}
|
|
276
|
+
.canvas-card .markdown-body table{font-size:11.5px}
|
|
280
277
|
/* 表格:上面留缝、左右到顶、列多了自己左右滑,点一下跟代码块一样弹出来 */
|
|
281
278
|
/* github-markdown 的 table 是 display:block + width:max-content,
|
|
282
279
|
而它被 scoped 成 [data-theme=...] .markdown-body table(0,2,1),比我们高 —— 只能加 !important 顶回来 */
|
|
@@ -292,8 +289,8 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
292
289
|
/* ★ 单元格必须能换行 —— 这条曾经是 white-space:nowrap(全局),后果是:
|
|
293
290
|
单元格不肯折行 → 一格的长内容把整张表撑得比卡片还宽 → .tscroll 上冒出一条横向滚动条。
|
|
294
291
|
所以用户看到「有些节点底部有横向滚动条、偏偏只有那些」—— 那些就是含表格的卡片。
|
|
295
|
-
|
|
296
|
-
.card .markdown-body .ztable table th,.card .markdown-body .ztable table td{
|
|
292
|
+
卡片内表格跟随可用宽度;文档和放大镜内保留单元格原有排版。 */
|
|
293
|
+
.canvas-card .markdown-body .ztable table th,.canvas-card .markdown-body .ztable table td{
|
|
297
294
|
white-space:normal !important; word-break:break-word;
|
|
298
295
|
}
|
|
299
296
|
#article .markdown-body .ztable table th,#article .markdown-body .ztable table td,
|
|
@@ -301,7 +298,7 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
301
298
|
.markdown-body .ztable table th{background:var(--bg)}
|
|
302
299
|
.markdown-body .ztable:hover .tscroll{border-color:var(--accent)}
|
|
303
300
|
#article .markdown-body .ztable table{font-size:12.5px}
|
|
304
|
-
.card .markdown-body ul,.card .markdown-body ol{padding-left:18px; margin:0 0 6px}
|
|
301
|
+
.canvas-card .markdown-body ul,.canvas-card .markdown-body ol{padding-left:18px; margin:0 0 6px}
|
|
305
302
|
|
|
306
303
|
/* 卡片里的图 / Mermaid:点一下悬浮出来放大 */
|
|
307
304
|
.zoomable{cursor:zoom-in; border:1px solid var(--line-2); border-radius:8px; overflow:hidden; margin-top:6px; background:var(--bg); padding:4px}
|
|
@@ -343,51 +340,28 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
343
340
|
#article .markdown-body{background:transparent; font-size:14px}
|
|
344
341
|
#article .markdown-body a{color:var(--accent)}
|
|
345
342
|
#article .markdown-body pre{font-size:12px; width:100%; box-sizing:border-box}
|
|
346
|
-
.card .markdown-body pre{width:100%}
|
|
347
|
-
#article
|
|
348
|
-
#article .slice{
|
|
349
|
-
#article .slice
|
|
350
|
-
#article .slice
|
|
351
|
-
#article .slice[
|
|
352
|
-
#article .slice
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
#article .slice-head{
|
|
357
|
-
#article .slice[
|
|
358
|
-
#article .slice[style*="--d:2"] > .slice-head .h{font-size:1.18em}
|
|
359
|
-
#article .slice[style*="--d:3"] > .slice-head .h{font-size:1.04em}
|
|
360
|
-
#article .slice[style*="--d:4"] > .slice-head .h,
|
|
361
|
-
#article .slice[style*="--d:5"] > .slice-head .h,
|
|
362
|
-
#article .slice[style*="--d:6"] > .slice-head .h{font-size:1em}
|
|
363
|
-
|
|
343
|
+
.canvas-card .markdown-body pre{width:100%}
|
|
344
|
+
#article .slice{padding-left:calc(max(0, var(--d) - 2) * 20px)}
|
|
345
|
+
#article .slice::before{display:none}
|
|
346
|
+
#article .slice-head{cursor:pointer;margin-bottom:5px}
|
|
347
|
+
#article .slice + .slice{margin-top:16px}
|
|
348
|
+
#article .slice[data-level="1"]{margin-top:32px}
|
|
349
|
+
#article .slice:first-child{margin-top:0}
|
|
350
|
+
#article .slice[data-level="1"]>.slice-head .h{font-size:22px}
|
|
351
|
+
#article .slice[data-level="2"]>.slice-head .h{font-size:17px}
|
|
352
|
+
#article .slice[data-level="3"]>.slice-head .h{font-size:15.5px}
|
|
353
|
+
#article .slice[data-level="4"]>.slice-head .h{font-size:14.5px}
|
|
354
|
+
#article .slice[data-level="5"]>.slice-head .h,#article .slice[data-level="6"]>.slice-head .h{font-size:14px}
|
|
364
355
|
/* ── 脑图模式 ───────────────────────────────────────────── */
|
|
365
356
|
/* 脑图在 #world 里面 —— 跟卡片同一块画布,拖 / 滚轮 / fit 全都共用 */
|
|
366
357
|
#mind{position:absolute; left:0; top:0; display:none}
|
|
367
358
|
[data-mode="mindmap"] #mind{display:block}
|
|
368
359
|
[data-mode="mindmap"] .card{display:none}
|
|
369
360
|
[data-mode="mindmap"] #wires{display:none}
|
|
370
|
-
/*
|
|
371
|
-
.mnode{
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
transition:opacity .18s, border-color .18s;
|
|
375
|
-
}
|
|
376
|
-
/*
|
|
377
|
-
* 脑图节点左边那根蓝竖条,和卡片视图的 .hbar 是同一个东西、同一套画法
|
|
378
|
-
* (同色 var(--accent)、同宽 3px、同透明度 .8)—— 用户要的是「跟卡片视图长得一模一样」。
|
|
379
|
-
*/
|
|
380
|
-
.mnode::before{
|
|
381
|
-
content:''; position:absolute; left:-2px; top:9px; width:3px; height:16px;
|
|
382
|
-
border-radius:2px; background:var(--accent); opacity:.8;
|
|
383
|
-
}
|
|
384
|
-
.mnode.root::before{top:10px; height:22px}
|
|
385
|
-
.mnode .mt{font-weight:600; font-size:12.5px; line-height:1.4; color:var(--fg); margin-bottom:3px}
|
|
386
|
-
.mnode .markdown-body{font-size:11.5px; line-height:1.5}
|
|
387
|
-
.mnode .markdown-body pre{margin:5px 0 0; padding:6px 8px; font-size:11px}
|
|
388
|
-
.mnode .markdown-body p{margin:0}
|
|
389
|
-
.mnode.root{border-color:var(--fg-2); border-width:2px}
|
|
390
|
-
.mnode.root .mt{font-size:15px}
|
|
361
|
+
/* 有正文的脑图节点与卡片视图共用阅读宽度,纯标题节点保留紧凑布局。 */
|
|
362
|
+
.mnode{width:max-content; min-width:240px; max-width:var(--canvas-card-width); transition:opacity .18s, border-color .18s}
|
|
363
|
+
.mnode.has-body{width:var(--canvas-card-width)}
|
|
364
|
+
.mnode.root{border-color:var(--accent)}
|
|
391
365
|
.mnode.dim{opacity:.2}
|
|
392
366
|
#article .slice.dim{opacity:.22}
|
|
393
367
|
#article .slice.lit > .slice-head .h{color:var(--fg)}
|
|
@@ -421,6 +395,8 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
421
395
|
#lensInner{position:absolute; left:0; top:0; transform-origin:0 0; background:var(--panel);
|
|
422
396
|
border:1px solid var(--line); border-radius:10px; padding:18px}
|
|
423
397
|
#lensInner svg,#lensInner img{display:block}
|
|
398
|
+
#lensInner :is(pre,table,svg text,svg foreignObject){cursor:text}
|
|
399
|
+
body:not(.dragging) #lensInner :is(pre,table,svg text,svg foreignObject){user-select:text;-webkit-user-select:text}
|
|
424
400
|
|
|
425
401
|
/* ── 底部提示 ───────────────────────────────────────────── */
|
|
426
402
|
.hint{
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* 注入 runtime 闭包:脑图和卡片视图只在布局/关系上不同,卡片组件共用。 */
|
|
2
|
+
function createCanvasCard(title, variant) {
|
|
3
|
+
var el = document.createElement('div');
|
|
4
|
+
el.className = 'canvas-card ' + variant;
|
|
5
|
+
el.innerHTML = '<div class="bar" title="拖动卡片"><span class="grip" aria-hidden="true">⠿</span></div>' +
|
|
6
|
+
'<span class="hbar"></span><div class="body"><div class="markdown-body card-title"><h1>' +
|
|
7
|
+
esc(title) + '</h1></div></div><span class="rz" title="拖我改卡片大小"></span>';
|
|
8
|
+
return el;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var canvasCardClickGuard = false;
|
|
12
|
+
function bindCanvasCard(el, adapter) {
|
|
13
|
+
if (el.dataset.cardBound) return;
|
|
14
|
+
el.dataset.cardBound = '1';
|
|
15
|
+
if (!canvasCardClickGuard) {
|
|
16
|
+
canvasCardClickGuard = true;
|
|
17
|
+
document.addEventListener('click', function (event) {
|
|
18
|
+
var card = event.target.closest('.canvas-card');
|
|
19
|
+
if (card && Number(card.dataset.suppressClickUntil) > Date.now()) {
|
|
20
|
+
event.preventDefault(); event.stopImmediatePropagation();
|
|
21
|
+
}
|
|
22
|
+
}, true);
|
|
23
|
+
}
|
|
24
|
+
function bind(handle, resizing) {
|
|
25
|
+
var gesture = null;
|
|
26
|
+
handle.addEventListener('pointerdown', function (event) {
|
|
27
|
+
if (event.button !== 0 || event.target.closest('button,a,.b')) return;
|
|
28
|
+
event.stopPropagation(); event.preventDefault();
|
|
29
|
+
var height = el.style.height; el.style.height = '';
|
|
30
|
+
var naturalHeight = el.offsetHeight; el.style.height = height;
|
|
31
|
+
gesture = { x: event.clientX, y: event.clientY, left: el.offsetLeft, top: el.offsetTop,
|
|
32
|
+
width: el.offsetWidth, height: el.offsetHeight, naturalHeight: naturalHeight,
|
|
33
|
+
scale: el.getBoundingClientRect().width / el.offsetWidth || 1, moved: false };
|
|
34
|
+
beginPan(); el.classList.add('card-gesturing');
|
|
35
|
+
handle.setPointerCapture(event.pointerId);
|
|
36
|
+
});
|
|
37
|
+
handle.addEventListener('pointermove', function (event) {
|
|
38
|
+
if (!gesture) return;
|
|
39
|
+
var dx = (event.clientX - gesture.x) / gesture.scale, dy = (event.clientY - gesture.y) / gesture.scale;
|
|
40
|
+
if (!gesture.moved && Math.hypot(event.clientX - gesture.x, event.clientY - gesture.y) < 3) return;
|
|
41
|
+
gesture.moved = true;
|
|
42
|
+
if (resizing) {
|
|
43
|
+
el.style.width = Math.max(240, gesture.width + dx) + 'px';
|
|
44
|
+
el.style.height = Math.min(gesture.naturalHeight, Math.max(110, gesture.height + dy)) + 'px';
|
|
45
|
+
adapter.resize?.(el.offsetWidth, el.offsetHeight);
|
|
46
|
+
} else {
|
|
47
|
+
el.style.left = gesture.left + dx + 'px'; el.style.top = gesture.top + dy + 'px';
|
|
48
|
+
adapter.move?.(gesture.left + dx, gesture.top + dy);
|
|
49
|
+
}
|
|
50
|
+
adapter.redraw();
|
|
51
|
+
});
|
|
52
|
+
function up(event) {
|
|
53
|
+
if (!gesture) return;
|
|
54
|
+
if (gesture.moved) el.dataset.suppressClickUntil = String(Date.now() + 400);
|
|
55
|
+
gesture = null; el.classList.remove('card-gesturing'); endPan();
|
|
56
|
+
if (handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId);
|
|
57
|
+
adapter.redraw();
|
|
58
|
+
}
|
|
59
|
+
handle.addEventListener('pointerup', up);
|
|
60
|
+
handle.addEventListener('pointercancel', up);
|
|
61
|
+
handle.addEventListener('lostpointercapture', up);
|
|
62
|
+
}
|
|
63
|
+
bind($('.bar', el), false); bind($('.rz', el), true);
|
|
64
|
+
$('.body', el).addEventListener('scroll', adapter.redraw, true);
|
|
65
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// 独立链路画布复用当前页面的运行时与卡片组件;不继承主画布的坐标或折叠态。
|
|
2
|
+
var canvasChainRuntimeScript = document.currentScript;
|
|
3
|
+
var canvasChainDialog = null, canvasChainGesture = null, canvasChainSuppressUntil = 0;
|
|
4
|
+
function canvasChainIsOpen() { return !!(canvasChainDialog && canvasChainDialog.open); }
|
|
5
|
+
function canvasChainCenter(id) {
|
|
6
|
+
var record = canvasRecords[id], node;
|
|
7
|
+
if (document.body.dataset.mode === 'doc') {
|
|
8
|
+
canvasRevealDocumentTitle(record);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (document.body.dataset.mode === 'mindmap') node = $('#mind .mnode[data-path="' + (id === '__document' ? '0' : record && record.mindPath) + '"]');
|
|
12
|
+
else if (record) node = record.parent ? $('#world .slice[data-id="' + id + '"]') : render.card[id];
|
|
13
|
+
if (!node) return;
|
|
14
|
+
var rect = node.getBoundingClientRect(), stage = $('#stage').getBoundingClientRect();
|
|
15
|
+
var heading = $('.card-title h1', node) || $('.slice-head', node) || node;
|
|
16
|
+
var headingRect = heading.getBoundingClientRect();
|
|
17
|
+
var nodeLeft = rect.left, headingTop = headingRect.top;
|
|
18
|
+
if (document.body.dataset.mode === 'cards' && record) {
|
|
19
|
+
var card = render.card[record.card], destination = pos[record.card];
|
|
20
|
+
if (card && destination) {
|
|
21
|
+
// CSS left/top 过渡期间 rect 仍在旧位置;保留标题在卡片内部的偏移,
|
|
22
|
+
// 用 layout 最终坐标计算它落定后的位置,避免首次取景在动画后失效。
|
|
23
|
+
var cardRect = card.getBoundingClientRect();
|
|
24
|
+
nodeLeft = stage.left + tx + destination.x * scale + rect.left - cardRect.left;
|
|
25
|
+
headingTop = stage.top + ty + destination.y * scale + headingRect.top - cardRect.top;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
tx += stage.left + stage.width / 2 - (nodeLeft + rect.width / 2);
|
|
29
|
+
// 以被按的标题定位,巨大正文向下延伸;整张卡居中会把标题移到视口外。
|
|
30
|
+
ty += stage.top + Math.min(72, Math.max(24, stage.height / 5)) - headingTop;
|
|
31
|
+
apply();
|
|
32
|
+
}
|
|
33
|
+
function canvasChainSubset(ids, selected) {
|
|
34
|
+
var keptCards = canvasFocusCards(ids);
|
|
35
|
+
var subset = Object.assign({}, DOC, { preamble: selected === '__document' ? DOC.preamble : '', cards: [], targets: {}, anchors: {}, targetNodes: {} });
|
|
36
|
+
subset.cards = DOC.cards.filter(function (card) { return keptCards.has(card.id); });
|
|
37
|
+
Object.keys(DOC.targets || {}).forEach(function (key) {
|
|
38
|
+
if (!keptCards.has(DOC.targets[key])) return;
|
|
39
|
+
subset.targets[key] = DOC.targets[key];
|
|
40
|
+
if ((DOC.anchors || {})[key]) subset.anchors[key] = DOC.anchors[key];
|
|
41
|
+
if ((DOC.targetNodes || {})[key]) subset.targetNodes[key] = DOC.targetNodes[key];
|
|
42
|
+
});
|
|
43
|
+
subset.edges = (DOC.edges || []).filter(function (edge) { return keptCards.has(edge[0]) && keptCards.has(edge[1]); });
|
|
44
|
+
return subset;
|
|
45
|
+
}
|
|
46
|
+
function canvasChainDocument(subset, selected) {
|
|
47
|
+
var runtime = canvasChainRuntimeScript, ui = $('#clado-canvas-ui');
|
|
48
|
+
if (!runtime || !ui || ui.tagName !== 'SCRIPT') return null;
|
|
49
|
+
var child = document.implementation.createHTMLDocument('链路画布');
|
|
50
|
+
child.documentElement.lang = 'zh-CN';
|
|
51
|
+
child.documentElement.dataset.theme = document.documentElement.dataset.theme || 'light';
|
|
52
|
+
child.documentElement.style.cssText = document.documentElement.style.cssText;
|
|
53
|
+
var viewport = child.createElement('meta'); viewport.name = 'viewport'; viewport.content = 'width=device-width,initial-scale=1'; child.head.appendChild(viewport);
|
|
54
|
+
var base = child.createElement('base'); base.href = document.baseURI; child.head.appendChild(base);
|
|
55
|
+
$$('style').forEach(function (style) { child.head.appendChild(style.cloneNode(true)); });
|
|
56
|
+
var style = child.createElement('style'); style.textContent = '.top{display:none!important}#stage,#doc{top:0!important}.zoomable{cursor:default!important}'; child.head.appendChild(style);
|
|
57
|
+
var mode = document.body.dataset.mode;
|
|
58
|
+
if (['cards','mindmap','doc'].indexOf(mode) < 0) mode = 'cards';
|
|
59
|
+
child.body.dataset.mode = mode;
|
|
60
|
+
child.body.innerHTML = '<header class="top"><div class="brand">clado</div><div class="seg" id="modes"><button data-mode="doc">doc</button><button data-mode="cards">cards</button><button data-mode="mindmap">mindmap</button></div><div class="diag"></div><button id="theme"></button></header>' +
|
|
61
|
+
'<div id="stage"><div id="world"><svg id="wires"></svg><div id="mind"><svg id="mwires"></svg></div></div></div>' +
|
|
62
|
+
'<div id="doc"><div class="docwrap"><nav class="toc" id="toc"></nav><article id="article"></article></div></div>' +
|
|
63
|
+
'<div id="lens"><div class="lensbar"><span id="lensLabel"></span><button id="lensOut"></button><span id="lensPct"></span><button id="lensIn"></button><button id="lensFit"></button><button id="lensClose"></button></div><div id="lensStage"><div id="lensInner"></div></div></div><div id="hint"></div>';
|
|
64
|
+
var data = child.createElement('script');
|
|
65
|
+
var values = { __CLADO__: subset, __CLADO_CHAIN__: { id: selected, mode: mode }, __CLADO_LIVE__: true,
|
|
66
|
+
__CLADO_DIAGNOSTICS__: [], __CLADO_FILE__: window.__CLADO_FILE__ || '',
|
|
67
|
+
__CLADO_FILE_PATH__: window.__CLADO_FILE_PATH__ || '', __CLADO_RESOURCES__: window.__CLADO_RESOURCES__ || {}, __CLADO_OFFLINE__: !!window.__CLADO_OFFLINE__ };
|
|
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');
|
|
69
|
+
child.body.appendChild(data);
|
|
70
|
+
[runtime, ui].forEach(function (source) { var script = child.createElement('script'); script.id = source.id; script.textContent = source.textContent; child.body.appendChild(script); });
|
|
71
|
+
return '<!doctype html>\n' + child.documentElement.outerHTML;
|
|
72
|
+
}
|
|
73
|
+
function canvasOpenChain(record, trigger) {
|
|
74
|
+
if (window.__CLADO_CHAIN__ || canvasChainIsOpen() || !record) return;
|
|
75
|
+
var ids = canvasFocusSet(record.id), source = canvasChainDocument(canvasChainSubset(ids, record.id), record.id);
|
|
76
|
+
if (!source) return;
|
|
77
|
+
var dialog = document.createElement('dialog'); dialog.className = 'canvas-chain-dialog';
|
|
78
|
+
dialog.setAttribute('aria-labelledby', 'canvas-chain-label');
|
|
79
|
+
dialog.innerHTML = '<div class="canvas-chain-bar"><div class="canvas-chain-heading"><strong id="canvas-chain-label"></strong><span class="canvas-chain-meta"></span></div><div class="canvas-chain-controls"><button type="button" data-chain-action="out" aria-label="缩小链路画布">−</button><button type="button" data-chain-action="in" aria-label="放大链路画布">+</button><button type="button" data-chain-action="center" aria-label="回到选中节点">◎</button><button type="button" data-chain-action="close" aria-label="关闭链路画布">✕</button></div></div><iframe title="独立链路画布"></iframe>';
|
|
80
|
+
$('.canvas-chain-heading strong', dialog).textContent = record.id === '__document' ? DOC.title : record.title;
|
|
81
|
+
$('.canvas-chain-meta', dialog).textContent = canvasFocusCards(ids).size + (document.body.dataset.mode === 'doc' ? ' 张关联卡片 · 滚动阅读' : ' 张关联卡片 · 拖动空白平移,滚轮缩放');
|
|
82
|
+
var frame = $('iframe', dialog), previousFocus = document.activeElement;
|
|
83
|
+
frame.srcdoc = source;
|
|
84
|
+
dialog.addEventListener('cancel', function (event) { event.preventDefault(); });
|
|
85
|
+
dialog.addEventListener('click', function (event) {
|
|
86
|
+
var button = event.target.closest('[data-chain-action]'); if (!button) return;
|
|
87
|
+
if (button.dataset.chainAction === 'close') {
|
|
88
|
+
dialog.close(); dialog.remove(); canvasChainDialog = null;
|
|
89
|
+
document.dispatchEvent(new CustomEvent('clado:chain-close'));
|
|
90
|
+
var restore = trigger && trigger.isConnected ? trigger : previousFocus;
|
|
91
|
+
if (restore && restore.isConnected && restore.focus) restore.focus({ preventScroll: true });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
var api = frame.contentWindow && frame.contentWindow.CladoChain;
|
|
95
|
+
if (api) api[button.dataset.chainAction]();
|
|
96
|
+
});
|
|
97
|
+
document.body.appendChild(dialog); canvasChainDialog = dialog; dialog.showModal();
|
|
98
|
+
document.dispatchEvent(new CustomEvent('clado:chain-open', { detail: { mode: document.body.dataset.mode } }));
|
|
99
|
+
$('[data-chain-action="close"]', dialog).focus();
|
|
100
|
+
}
|
|
101
|
+
function canvasChainCancelGesture(suppress) {
|
|
102
|
+
if (!canvasChainGesture) return;
|
|
103
|
+
clearTimeout(canvasChainGesture.timer);
|
|
104
|
+
if (suppress) canvasChainSuppressUntil = Date.now() + 700;
|
|
105
|
+
canvasChainGesture = null;
|
|
106
|
+
}
|
|
107
|
+
function canvasChainTitle(target) { return target.closest('.card-title h1,.slice-head,#toc a'); }
|
|
108
|
+
// 提供标题的键盘等价操作:Enter 聚焦,Shift+Enter 提取链路。
|
|
109
|
+
function canvasChainPrepareTitles() {
|
|
110
|
+
$$('#world .card-title h1,#world .slice-head,#article .slice-head,#toc a').forEach(function (title) {
|
|
111
|
+
if (title.dataset.chainTitle) return;
|
|
112
|
+
title.dataset.chainTitle = '1';
|
|
113
|
+
if (title.tagName !== 'A') { title.tabIndex = 0; title.setAttribute('role', 'button'); }
|
|
114
|
+
else title.draggable = false;
|
|
115
|
+
title.title = window.__CLADO_CHAIN__ ? '双击或 Enter 聚焦' : '双击或 Enter 聚焦,长按或 Shift+Enter 查看独立链路';
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
canvasChainPrepareTitles();
|
|
119
|
+
new MutationObserver(canvasChainPrepareTitles).observe($('#world'), { childList: true, subtree: true });
|
|
120
|
+
document.addEventListener('pointerdown', function (event) {
|
|
121
|
+
if (!event.isPrimary) { canvasChainCancelGesture(true); return; }
|
|
122
|
+
if (window.__CLADO_CHAIN__ || canvasChainIsOpen() || event.button !== 0) return;
|
|
123
|
+
var title = canvasChainTitle(event.target);
|
|
124
|
+
if (!title || event.target.closest('button,.port,.rz,a:not(#toc a),.zoomable')) return;
|
|
125
|
+
var record = canvasRecordForTarget(title); if (!record) return;
|
|
126
|
+
canvasChainCancelGesture(false);
|
|
127
|
+
var gesture = { pointer: event.pointerId, x: event.clientX, y: event.clientY, title: title, fired: false };
|
|
128
|
+
gesture.timer = setTimeout(function () {
|
|
129
|
+
if (canvasChainGesture !== gesture || !title.isConnected) return;
|
|
130
|
+
gesture.fired = true; canvasChainSuppressUntil = Date.now() + 1000;
|
|
131
|
+
canvasOpenChain(record, title);
|
|
132
|
+
}, 600);
|
|
133
|
+
canvasChainGesture = gesture;
|
|
134
|
+
}, true);
|
|
135
|
+
document.addEventListener('pointermove', function (event) {
|
|
136
|
+
var gesture = canvasChainGesture;
|
|
137
|
+
if (gesture && event.pointerId === gesture.pointer && Math.hypot(event.clientX - gesture.x, event.clientY - gesture.y) > 7) canvasChainCancelGesture(true);
|
|
138
|
+
}, true);
|
|
139
|
+
['pointerup','pointercancel','lostpointercapture'].forEach(function (name) {
|
|
140
|
+
document.addEventListener(name, function (event) {
|
|
141
|
+
if (canvasChainGesture && event.pointerId === canvasChainGesture.pointer) canvasChainCancelGesture(name !== 'pointerup' || canvasChainGesture.fired);
|
|
142
|
+
}, true);
|
|
143
|
+
});
|
|
144
|
+
window.addEventListener('blur', function () { canvasChainCancelGesture(true); });
|
|
145
|
+
document.addEventListener('visibilitychange', function () { if (document.hidden) canvasChainCancelGesture(true); });
|
|
146
|
+
document.addEventListener('wheel', function () { canvasChainCancelGesture(true); }, { capture: true, passive: true });
|
|
147
|
+
// 长按释放时拦下随后产生的标题点击。
|
|
148
|
+
['click','dblclick'].forEach(function (name) {
|
|
149
|
+
document.addEventListener(name, function (event) {
|
|
150
|
+
if (canvasChainTitle(event.target) && (canvasChainIsOpen() || Date.now() < canvasChainSuppressUntil)) { event.preventDefault(); event.stopImmediatePropagation(); }
|
|
151
|
+
}, true);
|
|
152
|
+
});
|
|
153
|
+
document.addEventListener('contextmenu', function (event) {
|
|
154
|
+
if (canvasChainTitle(event.target) && (event.pointerType === 'touch' || canvasChainIsOpen())) event.preventDefault();
|
|
155
|
+
}, true);
|
|
156
|
+
document.addEventListener('keydown', function (event) {
|
|
157
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
158
|
+
var title = canvasChainTitle(event.target); if (!title || event.target !== title) return;
|
|
159
|
+
var record = canvasRecordForTarget(title); if (!record) return;
|
|
160
|
+
event.preventDefault(); event.stopImmediatePropagation();
|
|
161
|
+
if (event.repeat) return;
|
|
162
|
+
if (event.shiftKey && !window.__CLADO_CHAIN__) canvasOpenChain(record, title);
|
|
163
|
+
else if (!event.shiftKey) canvasFocusContent(record.id);
|
|
164
|
+
}, true);
|
|
165
|
+
if (window.__CLADO_CHAIN__) {
|
|
166
|
+
var canvasChainInitialId = window.__CLADO_CHAIN__.id;
|
|
167
|
+
var canvasChainPositioned = false, canvasChainUserMoved = false;
|
|
168
|
+
fit = function () {
|
|
169
|
+
if (!canvasChainPositioned) { scale = 1; canvasChainPositioned = true; }
|
|
170
|
+
apply();
|
|
171
|
+
if (!canvasChainUserMoved) canvasChainCenter(canvasChainInitialId);
|
|
172
|
+
};
|
|
173
|
+
document.addEventListener('pointerdown', function (event) { if (event.target.closest('#stage,#doc')) canvasChainUserMoved = true; }, true);
|
|
174
|
+
document.addEventListener('wheel', function (event) { if (event.target.closest('#stage,#doc')) canvasChainUserMoved = true; }, { capture: true, passive: true });
|
|
175
|
+
document.addEventListener('keydown', function (event) { if (['ArrowUp','ArrowDown','ArrowLeft','ArrowRight','PageUp','PageDown','Home','End',' '].indexOf(event.key) >= 0) canvasChainUserMoved = true; }, true);
|
|
176
|
+
// 子画布只有这一层;代码/表格随画布缩放,不再打开媒体弹窗。
|
|
177
|
+
document.addEventListener('click', function (event) {
|
|
178
|
+
var link = event.target.closest('a.edge');
|
|
179
|
+
if (link) {
|
|
180
|
+
event.preventDefault(); event.stopImmediatePropagation();
|
|
181
|
+
var id = link.dataset.anchorId || link.dataset.edge;
|
|
182
|
+
if (!link.dataset.anchorId && link.dataset.anchor) {
|
|
183
|
+
var anchored = Object.values(canvasRecords).find(function (r) { return r.card === id && r.title === link.dataset.anchor; });
|
|
184
|
+
if (anchored) id = anchored.id;
|
|
185
|
+
}
|
|
186
|
+
if (canvasRecords[id]) { flash(canvasRecords[id].card); canvasChainCenter(id); if (link.dataset.mediaPoint) canvasRevealMediaTarget(link, id); }
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (event.target.closest('.zoomable,a')) { event.preventDefault(); event.stopImmediatePropagation(); }
|
|
190
|
+
}, true);
|
|
191
|
+
function chainCenter() { canvasSetFocus(canvasChainInitialId); canvasChainCenter(canvasChainInitialId); }
|
|
192
|
+
window.CladoChain = {
|
|
193
|
+
center: function () { canvasChainUserMoved = true; chainCenter(); },
|
|
194
|
+
in: function () { chainZoom(1.15); }, out: function () { chainZoom(1 / 1.15); }
|
|
195
|
+
};
|
|
196
|
+
function chainZoom(multiplier) {
|
|
197
|
+
canvasChainUserMoved = true;
|
|
198
|
+
if (document.body.dataset.mode === 'doc') {
|
|
199
|
+
scale = Math.min(2, Math.max(.6, scale * multiplier));
|
|
200
|
+
$('.docwrap').style.zoom = scale;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
var stage = $('#stage').getBoundingClientRect(), mx = stage.width / 2, my = stage.height / 2;
|
|
204
|
+
var next = Math.min(2.5, Math.max(.2, scale * multiplier));
|
|
205
|
+
tx = mx - (mx - tx) * next / scale; ty = my - (my - ty) * next / scale; scale = next; apply(); if (document.body.dataset.mode === 'mindmap') drawMindWires(); else drawWires();
|
|
206
|
+
}
|
|
207
|
+
function chainResources() {
|
|
208
|
+
$$('img[src]:not([data-chain-resource])').forEach(function (img) {
|
|
209
|
+
var href = img.getAttribute('src'); if (!href || /^(?:[a-z][a-z0-9+.-]*:|\/\/|\/)/i.test(href) || !window.__CLADO_FILE_PATH__) return;
|
|
210
|
+
try {
|
|
211
|
+
var url = new URL(href, 'https://clado.local/documents/' + window.__CLADO_FILE_PATH__);
|
|
212
|
+
if (!url.pathname.startsWith('/documents/')) return;
|
|
213
|
+
var path = decodeURIComponent(url.pathname.slice('/documents/'.length)), resource = (window.__CLADO_RESOURCES__ || {})[path];
|
|
214
|
+
if (resource || !window.__CLADO_OFFLINE__) { img.src = resource || '/library/resource?file=' + encodeURIComponent(path); img.dataset.chainResource = '1'; }
|
|
215
|
+
} catch (_) {}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
chainResources(); new MutationObserver(chainResources).observe($('#world'), { childList: true, subtree: true });
|
|
219
|
+
// 弹窗对提取出的卡片重新排布。
|
|
220
|
+
if (document.body.dataset.mode === 'cards') {
|
|
221
|
+
openEdge = {}; DOC.edges.forEach(function (edge) { openEdge[edgeKey(edge[0], edge[1])] = 1; });
|
|
222
|
+
applyVisibility(); layout(); repinPorts();
|
|
223
|
+
}
|
|
224
|
+
requestAnimationFrame(function () { requestAnimationFrame(function () { renderMermaid().then(function () {
|
|
225
|
+
var mode = document.body.dataset.mode;
|
|
226
|
+
if (mode === 'mindmap') renderMind();
|
|
227
|
+
else if (mode === 'cards') { layout(); repinPorts(); }
|
|
228
|
+
fit(); if (!canvasChainUserMoved) chainCenter();
|
|
229
|
+
}); }); });
|
|
230
|
+
if (document.fonts && document.fonts.ready) document.fonts.ready.then(function () { requestAnimationFrame(function () { if (!canvasChainUserMoved) chainCenter(); }); });
|
|
231
|
+
}
|