cladogram 0.5.5-beta.3 → 0.5.5-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/src/core/parse.js CHANGED
@@ -7,6 +7,7 @@
7
7
  import { parse as parseYaml } from 'yaml';
8
8
  import { markdownLinks } from './links.js';
9
9
  import { hasTargetSpec, isTargetOnlyTitle, mediaLinkLocations, mediaTargetPoint, targetPointFits } from './media-links.js';
10
+ import { extractTagsFromBody } from './tags.js';
10
11
 
11
12
  /** 开头 `---` 包的 front matter */
12
13
  const FRONT_MATTER = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
@@ -65,6 +66,7 @@ export function contentLength(md) {
65
66
  if (fence) continue;
66
67
  const visible = line
67
68
  .replace(/!?\[([^\]]*)\]\([^()\s]*(?:\s+"[^"]*")?\)/g, '$1') // [文字](url) → 文字
69
+ .replace(/\[([^\]]*)\]\{[^{}\r\n]+\}/g, '$1') // [文字]{#id .green} → 文字
68
70
  .replace(/^\s{0,3}#{1,6}\s+/, '') // 行内小标题的 #
69
71
  .replace(/^\s{0,3}>\s?/, '') // 引用
70
72
  .replace(/[*_`~]/g, '');
@@ -320,13 +322,39 @@ export function parseDocument(text, opts = {}) {
320
322
  * 字段,把线连到对方的 `## id` 上才说得清是哪个字段对哪个字段。
321
323
  * 键和 targets 一样用链接的**原文**(客户端是拿渲染出来的 href 查表的)。
322
324
  */
323
- const anchors = Object.create(null), targetNodes = Object.create(null), titleOf = new Map(), bodyOf = new Map();
325
+ const anchors = Object.create(null), targetNodes = Object.create(null), tagTargets = Object.create(null), tags = Object.create(null);
326
+ const titleOf = new Map(), bodyOf = new Map();
327
+ const collectTags = (body, cardId, nodeId, baseLine) => {
328
+ for (const tag of extractTagsFromBody(body, { cardId, nodeId, baseLine })) {
329
+ if (!tag.id) continue;
330
+ if (tags[tag.id]) {
331
+ at('error', 'MD_TAG_DUPLICATE_ID',
332
+ `Tag ID「#${tag.id}」重复定义`,
333
+ '每个文档内的 Tag ID 必须唯一,修改其中一个 ID', tag.line);
334
+ continue;
335
+ }
336
+ tags[tag.id] = {
337
+ id: tag.id,
338
+ cardId: tag.cardId,
339
+ nodeId: tag.nodeId,
340
+ color: tag.color,
341
+ text: tag.text,
342
+ kind: tag.kind,
343
+ blockIndex: tag.blockIndex || 0,
344
+ codeLine: tag.codeLine || 0,
345
+ };
346
+ }
347
+ };
324
348
  for (const c of cards) {
349
+ const cBody = c._entry.body.join('\n');
325
350
  titleOf.set(c.id, c.title);
326
- bodyOf.set(c.id, c._entry.body.join('\n'));
351
+ bodyOf.set(c.id, cBody);
352
+ collectTags(cBody, c.id, c.id, c._entry.line + 1);
327
353
  const walk = ns => ns.forEach(n => {
354
+ const nBody = n._entry.body.join('\n');
328
355
  titleOf.set(n.id, n.title);
329
- bodyOf.set(n.id, n._entry.body.join('\n'));
356
+ bodyOf.set(n.id, nBody);
357
+ collectTags(nBody, c.id, n.id, n._entry.line + 1);
330
358
  walk(n.kids);
331
359
  });
332
360
  walk(c.nodes);
@@ -401,7 +429,21 @@ export function parseDocument(text, opts = {}) {
401
429
  try { got = resolve(decodeURIComponent(t)); } catch { got = null; }
402
430
  if (got) { head = t; anchor = ''; }
403
431
  }
404
- if (!got) continue;
432
+ // 二元目标模型:若未命中卡片/小节标题,再查文档内唯一 Tag ID(支持 [文字](#tagId))。
433
+ if (!got) {
434
+ let tagHit = tags[t];
435
+ if (!tagHit && t.includes('%')) {
436
+ try { tagHit = tags[decodeURIComponent(t)]; } catch { tagHit = null; }
437
+ }
438
+ if (!tagHit) continue;
439
+ const mine = e.level === 1 ? card.id : node.id;
440
+ const theirs = tagHit.cardId;
441
+ targets[raw] = theirs;
442
+ tagTargets[raw] = tagHit.id;
443
+ if (tagHit.nodeId && tagHit.nodeId !== theirs) targetNodes[raw] = tagHit.nodeId;
444
+ edgePairs.push([mine, theirs]);
445
+ continue;
446
+ }
405
447
  if (got.ambiguous) {
406
448
  at('error', 'MD_EDGE_AMBIGUOUS',
407
449
  `「${t}」能对上 ${got.ambiguous.length} 个地方:${got.ambiguous.join('、')}`,
@@ -421,8 +463,14 @@ export function parseDocument(text, opts = {}) {
421
463
  if (got.id === mine && !anchor) continue;
422
464
  // 键用 raw —— 客户端是拿**渲染出来的 href** 去查表的,剥过 `#` 就查不到了
423
465
  targets[raw] = theirs;
424
- if (!anchor && got.id !== theirs) { anchor = titleOf.get(got.id); targetNodes[raw] = got.id; }
425
- if (anchor) anchors[raw] = anchor;
466
+ // 若 `卡片#tagId` 的 `#` 后半段命中该卡内的 Tag ID,也视为 Tag 精准落点。
467
+ if (anchor && tags[anchor] && tags[anchor].cardId === theirs) {
468
+ tagTargets[raw] = tags[anchor].id;
469
+ if (tags[anchor].nodeId && tags[anchor].nodeId !== theirs) targetNodes[raw] = tags[anchor].nodeId;
470
+ } else {
471
+ if (!anchor && got.id !== theirs) { anchor = titleOf.get(got.id); targetNodes[raw] = got.id; }
472
+ if (anchor) anchors[raw] = anchor;
473
+ }
426
474
  edgePairs.push([mine, theirs]);
427
475
  }
428
476
 
@@ -492,6 +540,8 @@ export function parseDocument(text, opts = {}) {
492
540
  targets: { ...targets },
493
541
  anchors: { ...anchors },
494
542
  targetNodes: { ...targetNodes },
543
+ tags: { ...tags },
544
+ tagTargets: { ...tagTargets },
495
545
  edges: cardEdges,
496
546
  hasMermaid,
497
547
  };
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Clado 统一 Tag 锚点解析器(卡片 + Tag 二元连线模型)。
3
+ *
4
+ * 语法约定(100% 兼容标准 Markdown 与可编译代码注释):
5
+ * 1. 正文 / 列表 / 表格:
6
+ * - 有字胶囊 Tag:[新增]{#idempotency .green}(或省略 #id 只做视觉标记:[新增]{.green})
7
+ * - 无字小圆点 Tag:[]{#idempotency .green}(渲染为 5.5px 极小纯色圆点,视觉归左承接入线)
8
+ * 2. 代码块行尾注释(保持代码 100% 可复制直接运行,渲染时自动提取到代码行左侧边槽):
9
+ * - verifySign(req); // {#verify-sign .blue}
10
+ * - ledger.commit(req); // {#ledger-commit .green 落账}
11
+ * - 支持 //、#、--、/* ... *\/、<!-- ... --> 注释前缀
12
+ * 3. Mermaid 块内注释:
13
+ * - %% {#SETTLE .green}
14
+ * 4. 连线引用:
15
+ * - 同文档:[触发验签](#verify-sign)
16
+ * - 跨文档:[幂等落账](ledger.md#idempotency)
17
+ */
18
+
19
+ export const TAG_COLOR_ALIASES = Object.freeze({
20
+ green: 'green',
21
+ add: 'green',
22
+ amber: 'amber',
23
+ mod: 'amber',
24
+ yellow: 'amber',
25
+ warn: 'amber',
26
+ red: 'red',
27
+ del: 'red',
28
+ danger: 'red',
29
+ blue: 'blue',
30
+ spec: 'blue',
31
+ info: 'blue',
32
+ purple: 'purple',
33
+ note: 'purple',
34
+ gray: 'gray',
35
+ neutral: 'gray',
36
+ });
37
+
38
+ const ID_TOKEN = /^#([a-zA-Z0-9\u4e00-\u9fff_:-]{1,64})$/;
39
+ const COLOR_TOKEN = /^\.([a-zA-Z]+)$/;
40
+ const FENCE_RE = /^ {0,3}(`{3,}|~{3,})[ \t]*([^`]*)$/;
41
+ const CODE_COMMENT_TAG_RE = /(?:\/\/|#|--|\/\*|<!--)\s*\{([^{}\r\n]+)\}\s*(?:\*\/|-->)?\s*$/;
42
+ const MERMAID_COMMENT_TAG_RE = /^\s*%%\s*\{([^{}\r\n]+)\}\s*$/;
43
+
44
+ export function parseTagAttrs(raw) {
45
+ if (!raw || typeof raw !== 'string') return null;
46
+ const tokens = raw.trim().split(/\s+/).filter(Boolean);
47
+ if (!tokens.length) return null;
48
+ let id = null;
49
+ let color = null;
50
+ const extra = [];
51
+ for (const tok of tokens) {
52
+ const idMatch = ID_TOKEN.exec(tok);
53
+ if (idMatch && !id) {
54
+ id = idMatch[1];
55
+ continue;
56
+ }
57
+ const colorMatch = COLOR_TOKEN.exec(tok);
58
+ if (colorMatch && !color) {
59
+ const mapped = TAG_COLOR_ALIASES[colorMatch[1].toLowerCase()];
60
+ if (mapped) {
61
+ color = mapped;
62
+ continue;
63
+ }
64
+ return null;
65
+ }
66
+ if (tok.startsWith('#') || tok.startsWith('.')) return null;
67
+ extra.push(tok);
68
+ }
69
+ if (!id && !color) return null;
70
+ return {
71
+ id,
72
+ color: color || 'gray',
73
+ extraText: extra.join(' ').slice(0, 40),
74
+ };
75
+ }
76
+
77
+ /** 扫描单行 Markdown 正文中的行内 Tag(自动跳过行内反引号代码与普通 Markdown 链接)。 */
78
+ export function scanInlineTags(line) {
79
+ const hits = [];
80
+ for (let i = 0; i < line.length; i++) {
81
+ if (line[i] === '\\') { i++; continue; }
82
+ if (line[i] === '`') {
83
+ const run = /^`+/.exec(line.slice(i))[0];
84
+ const end = line.indexOf(run, i + run.length);
85
+ if (end >= 0) { i = end + run.length - 1; continue; }
86
+ }
87
+ if (line[i] !== '[' || line[i - 1] === '!') continue;
88
+ const closeBracket = line.indexOf(']', i + 1);
89
+ if (closeBracket < 0 || line[closeBracket + 1] !== '{') continue;
90
+ const closeBrace = line.indexOf('}', closeBracket + 2);
91
+ if (closeBrace < 0) continue;
92
+ const label = line.slice(i + 1, closeBracket);
93
+ if (label.length > 40 || /[\[\]\r\n]/.test(label)) continue;
94
+ const attrsRaw = line.slice(closeBracket + 2, closeBrace);
95
+ const parsed = parseTagAttrs(attrsRaw);
96
+ if (!parsed) continue;
97
+ hits.push({
98
+ start: i,
99
+ end: closeBrace + 1,
100
+ id: parsed.id,
101
+ color: parsed.color,
102
+ text: label.trim(),
103
+ });
104
+ i = closeBrace;
105
+ }
106
+ return hits;
107
+ }
108
+
109
+ export function extractTagsFromBody(body, { cardId = '', nodeId = '', baseLine = 1 } = {}) {
110
+ if (!body || typeof body !== 'string') return [];
111
+ const lines = body.split('\n');
112
+ const results = [];
113
+ let fence = null;
114
+ let fenceKind = null;
115
+ let codeBlockIndex = 0;
116
+ let mermaidBlockIndex = 0;
117
+ let codeLine = 0;
118
+
119
+ for (let i = 0; i < lines.length; i++) {
120
+ const line = lines[i];
121
+ const lineNo = baseLine + i;
122
+ const f = FENCE_RE.exec(line);
123
+ if (f) {
124
+ if (!fence) {
125
+ fence = f[1];
126
+ const lang = (f[2] || '').trim().toLowerCase();
127
+ if (/^mermaid(?:\s|$)/.test(lang)) {
128
+ fenceKind = 'mermaid';
129
+ mermaidBlockIndex += 1;
130
+ } else {
131
+ fenceKind = 'code';
132
+ codeBlockIndex += 1;
133
+ codeLine = 0;
134
+ }
135
+ } else if (f[1][0] === fence[0] && f[1].length >= fence.length) {
136
+ fence = null;
137
+ fenceKind = null;
138
+ }
139
+ continue;
140
+ }
141
+
142
+ if (fenceKind === 'code') {
143
+ codeLine += 1;
144
+ const m = CODE_COMMENT_TAG_RE.exec(line);
145
+ if (m) {
146
+ const parsed = parseTagAttrs(m[1]);
147
+ if (parsed) {
148
+ results.push({
149
+ id: parsed.id,
150
+ color: parsed.color,
151
+ text: parsed.extraText,
152
+ kind: 'code',
153
+ blockIndex: codeBlockIndex,
154
+ codeLine,
155
+ cardId,
156
+ nodeId,
157
+ line: lineNo,
158
+ });
159
+ }
160
+ }
161
+ continue;
162
+ }
163
+
164
+ if (fenceKind === 'mermaid') {
165
+ const m = MERMAID_COMMENT_TAG_RE.exec(line);
166
+ if (m) {
167
+ const parsed = parseTagAttrs(m[1]);
168
+ if (parsed && parsed.id) {
169
+ results.push({
170
+ id: parsed.id,
171
+ color: parsed.color,
172
+ text: parsed.extraText,
173
+ kind: 'mermaid',
174
+ blockIndex: mermaidBlockIndex,
175
+ cardId,
176
+ nodeId,
177
+ line: lineNo,
178
+ });
179
+ }
180
+ }
181
+ continue;
182
+ }
183
+
184
+ for (const hit of scanInlineTags(line)) {
185
+ results.push({
186
+ id: hit.id,
187
+ color: hit.color,
188
+ text: hit.text,
189
+ kind: 'inline',
190
+ cardId,
191
+ nodeId,
192
+ line: lineNo,
193
+ });
194
+ }
195
+ }
196
+ return results;
197
+ }
@@ -23,16 +23,28 @@ export const APP_CSS = String.raw`
23
23
  正文的样子交给 vendor 里那套(github-markdown-css + highlight.js),
24
24
  这里只管:顶栏、画布、卡片外壳、缩进、线、放大镜。 */
25
25
  [data-theme="light"]{
26
- --bg:#f9fafc; --panel:#ffffff; --line:#d1d9e0; --line-2:#e4e8ee;
27
- --fg:#1f2328; --fg-2:#59636e; --accent:#0969da; --accent-soft:#ddf4ff;
28
- --shadow:0 1px 2px rgba(31,35,40,.08), 0 8px 24px rgba(31,35,40,.08);
29
- --dot:#dfe3e8;
26
+ --bg:#fafafc; --panel:#ffffff; --line:rgba(15,23,42,.09); --line-2:rgba(15,23,42,.06);
27
+ --fg:#18181b; --fg-2:#52525b; --accent:#2563eb; --accent-soft:rgba(37,99,235,.09);
28
+ --shadow:0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.055);
29
+ --dot:#e2e6ec;
30
+ --tag-green-bg:rgba(16,185,129,.11); --tag-green-fg:#047857; --tag-green-dot:#10b981;
31
+ --tag-amber-bg:rgba(245,158,11,.13); --tag-amber-fg:#b45309; --tag-amber-dot:#f59e0b;
32
+ --tag-red-bg:rgba(244,63,94,.11); --tag-red-fg:#be123c; --tag-red-dot:#f43f5e;
33
+ --tag-blue-bg:rgba(59,130,246,.11); --tag-blue-fg:#1d4ed8; --tag-blue-dot:#3b82f6;
34
+ --tag-purple-bg:rgba(139,92,246,.11); --tag-purple-fg:#6d28d9; --tag-purple-dot:#8b5cf6;
35
+ --tag-gray-bg:rgba(100,116,139,.10); --tag-gray-fg:#475569; --tag-gray-dot:#94a3b8;
30
36
  }
31
37
  [data-theme="dark"]{
32
- --bg:#10151c; --panel:#161b22; --line:#30363d; --line-2:#21262d;
33
- --fg:#e6edf3; --fg-2:#9198a1; --accent:#58a6ff; --accent-soft:#12283f;
34
- --shadow:0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
35
- --dot:#1b2027;
38
+ --bg:#0f1217; --panel:#161b22; --line:rgba(255,255,255,.095); --line-2:rgba(255,255,255,.06);
39
+ --fg:#f1f5f9; --fg-2:#a1a1aa; --accent:#60a5fa; --accent-soft:rgba(96,165,250,.15);
40
+ --shadow:0 2px 6px rgba(0,0,0,.36), 0 12px 32px rgba(0,0,0,.35);
41
+ --dot:#1e242d;
42
+ --tag-green-bg:rgba(16,185,129,.18); --tag-green-fg:#6ee7b7; --tag-green-dot:#34d399;
43
+ --tag-amber-bg:rgba(245,158,11,.18); --tag-amber-fg:#fcd34d; --tag-amber-dot:#fbbf24;
44
+ --tag-red-bg:rgba(244,63,94,.18); --tag-red-fg:#fda4af; --tag-red-dot:#fb7185;
45
+ --tag-blue-bg:rgba(59,130,246,.18); --tag-blue-fg:#93c5fd; --tag-blue-dot:#60a5fa;
46
+ --tag-purple-bg:rgba(139,92,246,.18); --tag-purple-fg:#c4b5fd; --tag-purple-dot:#a78bfa;
47
+ --tag-gray-bg:rgba(148,163,184,.16); --tag-gray-fg:#cbd5e1; --tag-gray-dot:#94a3b8;
36
48
  }
37
49
  *{box-sizing:border-box}
38
50
  html,body{height:100%}
@@ -65,7 +77,7 @@ html,body,#doc,#article,.body,.tscroll,#lensInner{
65
77
  }
66
78
 
67
79
  /* ── 画布 ───────────────────────────────────────────────── */
68
- #stage{position:absolute; inset:0; overflow:hidden;
80
+ #stage{position:absolute; inset:0; overflow:hidden; touch-action:none;
69
81
  background-image:radial-gradient(circle, var(--dot) 1px, transparent 1px);
70
82
  background-size:22px 22px; cursor:grab}
71
83
  #stage.drag{cursor:grabbing}
@@ -88,7 +100,7 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
88
100
  /* ── 卡片 ───────────────────────────────────────────────── */
89
101
  .canvas-card{
90
102
  position:absolute; background:var(--panel);
91
- border:1px solid var(--line); border-radius:11px; box-shadow:var(--shadow);
103
+ border:1px solid var(--line); border-radius:13px; box-shadow:var(--shadow);
92
104
  z-index:1; display:flex; flex-direction:column;
93
105
  }
94
106
  .card{
@@ -133,6 +145,7 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
133
145
  /* overflow 用 auto:卡片默认是「刚好包住内容」的,不会出滚动条;
134
146
  只有用户自己把右下角往上拖矮了,内容装不下,才出现滚动条让他看全。 */
135
147
  .body{position:relative; padding:10px 14px 14px; flex:1 1 auto; min-height:0; overflow:auto}
148
+ .canvas-card > .body{touch-action:pan-y}
136
149
  .canvas-card .markdown-body{overflow-wrap:anywhere}
137
150
  /* 缩进:每一片自己带 --d(2..6),内容整体往右让 */
138
151
  .slice{position:relative}
@@ -347,6 +360,10 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
347
360
  #article .slice[data-level="3"]>.slice-head .h{font-size:15.5px}
348
361
  #article .slice[data-level="4"]>.slice-head .h{font-size:14.5px}
349
362
  #article .slice[data-level="5"]>.slice-head .h,#article .slice[data-level="6"]>.slice-head .h{font-size:14px}
363
+ @media (max-width: 680px){
364
+ .docwrap{grid-template-columns:minmax(0,1fr); gap:0; padding:70px 16px 88px}
365
+ .toc{display:none}
366
+ }
350
367
  /* ── 脑图模式 ───────────────────────────────────────────── */
351
368
  /* 脑图在 #world 里面 —— 跟卡片同一块画布,拖 / 滚轮 / fit 全都共用 */
352
369
  #mind{position:absolute; left:0; top:0; display:none}
@@ -169,6 +169,6 @@ document.addEventListener('click', function (event) {
169
169
  }
170
170
  if (document.body.dataset.mode === 'doc') canvasRevealDocumentTitle(canvasRecords[id]);
171
171
  else if (typeof canvasChainCenter === 'function') canvasChainCenter(id);
172
- if (link.dataset.mediaPoint) canvasRevealMediaTarget(link, id);
172
+ if (link.dataset.mediaPoint || link.dataset.tagTarget) canvasRevealMediaTarget(link, id);
173
173
  }
174
174
  });
@@ -64,66 +64,152 @@
64
64
  .clado-ai-selected::after{animation:selection-light-around 8s linear infinite}
65
65
  }
66
66
  .slice.clado-ai-selected::before,.slice.clado-ai-selected::after{inset:-2px -4px;border-radius:6px}
67
- @keyframes clado-ai-touch-pulse{
68
- 0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 55%,transparent),var(--shadow)}
69
- 30%{box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 32%,transparent),0 10px 30px color-mix(in srgb,var(--accent) 18%,transparent)}
70
- 100%{box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 16%,transparent),var(--shadow)}
67
+ @keyframes clado-aura-breathe{
68
+ 0%,100%{opacity:.64;transform:translateX(-50%) scaleX(.96) scaleY(.86)}
69
+ 50%{opacity:1;transform:translateX(-50%) scaleX(1.03) scaleY(1.18)}
71
70
  }
72
- @keyframes clado-ai-waiting-pulse{
73
- 0%,100%{box-shadow:0 0 0 2px rgb(217 119 6 / .22),0 8px 24px rgb(217 119 6 / .12)}
74
- 50%{box-shadow:0 0 0 4px rgb(217 119 6 / .36),0 10px 28px rgb(217 119 6 / .2)}
71
+ @keyframes clado-aura-drift{
72
+ 0%,100%{filter:blur(12px) hue-rotate(-8deg)}
73
+ 50%{filter:blur(14px) hue-rotate(12deg)}
75
74
  }
76
- .canvas-card.clado-ai-touched,.mnode.clado-ai-touched{
77
- border-color:color-mix(in srgb,var(--accent) 62%,var(--line));
78
- animation:clado-ai-touch-pulse 1.1s cubic-bezier(.22,.75,.24,1) 1 forwards;
79
- }
80
- .canvas-card.clado-ai-reading,.mnode.clado-ai-reading{
81
- border-color:color-mix(in srgb,var(--accent) 40%,var(--line));
82
- box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 16%,transparent),var(--shadow);
83
- }
84
- .canvas-card.clado-ai-waiting,.mnode.clado-ai-waiting{
85
- border-color:#d97706;
86
- animation:clado-ai-waiting-pulse 2.2s ease-in-out infinite;
87
- }
88
- [data-theme="dark"] .canvas-card.clado-ai-waiting,[data-theme="dark"] .mnode.clado-ai-waiting{
89
- border-color:#f59e0b;
75
+
76
+ /* AI 正在处理 / 生成时的底边柔光呼吸(仅在 AI 活跃状态显示,普通点击/静止卡片零彩边) */
77
+ .canvas-card:is(.clado-ai-touched,.clado-ai-reading,.clado-ai-waiting):not(.clado-ai-selected),
78
+ .mnode:is(.clado-ai-touched,.clado-ai-reading,.clado-ai-waiting):not(.clado-ai-selected){
79
+ border-color:var(--line);
80
+ box-shadow:var(--shadow);
81
+ }
82
+ .canvas-card:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::before,
83
+ .mnode:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::before{
84
+ content:"";position:absolute;left:50%;bottom:-.5px;width:86%;height:1px;
85
+ transform:translateX(-50%);pointer-events:none;z-index:3;
86
+ background:linear-gradient(90deg,transparent 0%,rgba(56,189,248,.20) 10%,rgba(56,189,248,.48) 28%,rgba(129,140,248,.62) 50%,rgba(232,121,249,.42) 72%,rgba(244,114,182,.16) 90%,transparent 100%);
87
+ }
88
+ .canvas-card:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::after,
89
+ .mnode:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::after{
90
+ content:"";position:absolute;left:50%;top:calc(100% - 2px);width:96%;height:48px;
91
+ transform-origin:50% 0%;transform:translateX(-50%);pointer-events:none;z-index:-1;
92
+ background:
93
+ radial-gradient(ellipse 36% 44% at 30% 6%,rgba(56,189,248,.34) 0%,rgba(56,189,248,.10) 48%,transparent 76%),
94
+ radial-gradient(ellipse 34% 52% at 50% 4%,rgba(139,92,246,.34) 0%,rgba(139,92,246,.10) 46%,transparent 74%),
95
+ radial-gradient(ellipse 34% 42% at 70% 7%,rgba(244,114,182,.26) 0%,rgba(244,114,182,.08) 44%,transparent 72%);
96
+ mask-image:linear-gradient(90deg,transparent 0%,rgba(0,0,0,.42) 12%,#000 32%,#000 68%,rgba(0,0,0,.42) 88%,transparent 100%);
97
+ -webkit-mask-image:linear-gradient(90deg,transparent 0%,rgba(0,0,0,.42) 12%,#000 32%,#000 68%,rgba(0,0,0,.42) 88%,transparent 100%);
98
+ animation:clado-aura-breathe 2.9s ease-in-out infinite,clado-aura-drift 5.5s ease-in-out infinite;
99
+ }
100
+ [data-theme="dark"] .canvas-card:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::after,
101
+ [data-theme="dark"] .mnode:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::after{
102
+ background:
103
+ radial-gradient(ellipse 36% 44% at 30% 6%,rgba(56,189,248,.40) 0%,rgba(56,189,248,.12) 48%,transparent 76%),
104
+ radial-gradient(ellipse 34% 52% at 50% 4%,rgba(167,139,250,.38) 0%,rgba(167,139,250,.10) 46%,transparent 74%),
105
+ radial-gradient(ellipse 34% 42% at 70% 7%,rgba(244,114,182,.28) 0%,rgba(244,114,182,.08) 44%,transparent 72%);
106
+ }
107
+ .canvas-card.clado-ai-waiting:not(.clado-ai-selected)::before,
108
+ .mnode.clado-ai-waiting:not(.clado-ai-selected)::before{
109
+ content:"";position:absolute;left:50%;bottom:-.5px;width:86%;height:1px;
110
+ transform:translateX(-50%);pointer-events:none;z-index:3;
111
+ background:linear-gradient(90deg,transparent 0%,rgba(251,191,36,.22) 12%,rgba(245,158,11,.56) 50%,rgba(251,146,60,.22) 88%,transparent 100%);
112
+ }
113
+ .canvas-card.clado-ai-waiting:not(.clado-ai-selected)::after,
114
+ .mnode.clado-ai-waiting:not(.clado-ai-selected)::after{
115
+ content:"";position:absolute;left:50%;top:calc(100% - 2px);width:96%;height:48px;
116
+ transform-origin:50% 0%;transform:translateX(-50%);pointer-events:none;z-index:-1;
117
+ background:
118
+ radial-gradient(ellipse 36% 44% at 32% 6%,rgba(251,191,36,.32) 0%,rgba(251,191,36,.10) 48%,transparent 76%),
119
+ radial-gradient(ellipse 34% 52% at 50% 4%,rgba(245,158,11,.34) 0%,rgba(245,158,11,.10) 46%,transparent 74%),
120
+ radial-gradient(ellipse 34% 42% at 68% 7%,rgba(251,146,60,.26) 0%,rgba(251,146,60,.08) 44%,transparent 72%);
121
+ mask-image:linear-gradient(90deg,transparent 0%,rgba(0,0,0,.42) 12%,#000 32%,#000 68%,rgba(0,0,0,.42) 88%,transparent 100%);
122
+ -webkit-mask-image:linear-gradient(90deg,transparent 0%,rgba(0,0,0,.42) 12%,#000 32%,#000 68%,rgba(0,0,0,.42) 88%,transparent 100%);
123
+ animation:clado-aura-breathe 2.6s ease-in-out infinite;
90
124
  }
91
125
  .slice.clado-ai-touched,.slice.clado-ai-reading{
92
- background:color-mix(in srgb,var(--accent) 7%,transparent);
126
+ background:color-mix(in srgb,var(--accent) 6%,transparent);
93
127
  border-radius:6px;
94
128
  }
95
129
  .slice.clado-ai-waiting{
96
- background:rgb(217 119 6 / .12);
130
+ background:rgba(245,158,11,.09);
97
131
  border-radius:6px;
98
132
  }
99
133
  @media(prefers-reduced-motion:reduce){
100
- .canvas-card.clado-ai-touched,.mnode.clado-ai-touched,.canvas-card.clado-ai-waiting,.mnode.clado-ai-waiting{animation:none}
134
+ .canvas-card:is(.clado-ai-touched,.clado-ai-reading,.clado-ai-waiting)::after,
135
+ .mnode:is(.clado-ai-touched,.clado-ai-reading,.clado-ai-waiting)::after{animation:none}
136
+ }
137
+
138
+ /* ── 统一语义 Tag 锚点(有字低饱和胶囊 + 无字 5.5px 纯色极小圆点,零外圈) ── */
139
+ .clado-tag{
140
+ display:inline-flex;align-items:center;
141
+ padding:1px 6.5px;border-radius:6px;
142
+ font-size:10.5px;font-weight:560;line-height:1.45;
143
+ vertical-align:middle;margin-inline-end:4px;
144
+ }
145
+ .clado-tag[data-color="green"]{background:var(--tag-green-bg);color:var(--tag-green-fg)}
146
+ .clado-tag[data-color="amber"]{background:var(--tag-amber-bg);color:var(--tag-amber-fg)}
147
+ .clado-tag[data-color="red"]{background:var(--tag-red-bg);color:var(--tag-red-fg)}
148
+ .clado-tag[data-color="blue"]{background:var(--tag-blue-bg);color:var(--tag-blue-fg)}
149
+ .clado-tag[data-color="purple"]{background:var(--tag-purple-bg);color:var(--tag-purple-fg)}
150
+ .clado-tag[data-color="gray"]{background:var(--tag-gray-bg);color:var(--tag-gray-fg)}
151
+
152
+ .clado-tag-dot{
153
+ display:inline-block;width:5.5px;height:5.5px;border-radius:50%;
154
+ flex:none;box-shadow:none!important;border:0;vertical-align:middle;
155
+ }
156
+ .clado-tag-dot[data-color="green"]{background:var(--tag-green-dot)}
157
+ .clado-tag-dot[data-color="amber"]{background:var(--tag-amber-dot)}
158
+ .clado-tag-dot[data-color="red"]{background:var(--tag-red-dot)}
159
+ .clado-tag-dot[data-color="blue"]{background:var(--tag-blue-dot)}
160
+ .clado-tag-dot[data-color="purple"]{background:var(--tag-purple-dot)}
161
+ .clado-tag-dot[data-color="gray"]{background:var(--tag-gray-dot)}
162
+
163
+ /* 无字小圆点一律视觉归左:列表项直接替代无序列表灰点;段落/单元格安静钉在最左侧 */
164
+ .markdown-body li.clado-li-dot-tag{list-style:none!important;position:relative}
165
+ .markdown-body li.clado-li-dot-tag>.clado-tag-dot:first-child{
166
+ position:absolute;left:-12px;top:.58em;margin:0;
167
+ }
168
+ .markdown-body .treelist li.clado-li-dot-tag::before{display:none!important}
169
+ .markdown-body .treelist li.clado-li-dot-tag>.clado-tag-dot:first-child{left:2px;top:8.5px}
170
+ .markdown-body :is(p,td,th,blockquote).clado-block-dot-tag{position:relative;padding-left:13px!important}
171
+ .markdown-body :is(p,td,th,blockquote).clado-block-dot-tag>.clado-tag-dot:first-child{
172
+ position:absolute;left:1px;top:.58em;margin:0;
101
173
  }
174
+
175
+ /* 代码块左侧边槽 Tag(源码行尾注释保持可复制运行,视觉自动提取到代码行最左侧) */
176
+ .markdown-body pre.has-code-tags{position:relative;padding-left:22px!important}
177
+ .markdown-body pre.has-code-pill-tags{padding-left:54px!important}
178
+ .clado-code-gutter-tag{
179
+ position:absolute;left:7px;transform:translateY(-50%);
180
+ display:inline-flex;align-items:center;line-height:1;z-index:2;pointer-events:auto;
181
+ }
182
+ .clado-code-gutter-tag.has-text{left:5px}
183
+ .clado-code-gutter-tag .clado-tag{margin:0;padding:0 5px;font-size:10px;line-height:1.45}
184
+
102
185
  #cladoAiToast{
103
- position:fixed;left:50%;bottom:18px;z-index:42;
186
+ position:fixed;left:50%;bottom:max(18px,env(safe-area-inset-bottom));z-index:42;
104
187
  display:inline-flex;align-items:center;gap:7px;
105
188
  max-width:min(460px,calc(100vw - 40px));padding:7px 14px;
106
- border:0;border-radius:999px;font-size:12px;font-weight:500;line-height:1.25;
189
+ border:1px solid var(--line);border-radius:999px;font-size:12px;font-weight:500;line-height:1.25;
107
190
  color:var(--fg);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
108
191
  background:color-mix(in srgb,var(--panel) 78%,transparent);
109
- backdrop-filter:blur(14px) saturate(145%);-webkit-backdrop-filter:blur(14px) saturate(145%);
110
- box-shadow:0 6px 24px rgb(0 0 0 / .12);
192
+ backdrop-filter:blur(16px) saturate(145%);-webkit-backdrop-filter:blur(16px) saturate(145%);
193
+ box-shadow:0 6px 24px rgba(15,23,42,.08);
111
194
  opacity:0;transform:translate(-50%,8px);pointer-events:none;
112
195
  transition:opacity 180ms cubic-bezier(.22,.75,.24,1),transform 180ms cubic-bezier(.22,.75,.24,1);
113
196
  }
114
197
  #cladoAiToast.open{opacity:1;transform:translate(-50%,0);pointer-events:auto}
115
198
  #cladoAiToast .dot{
116
- width:7px;height:7px;border-radius:50%;flex:none;
117
- background:var(--accent);box-shadow:0 0 8px color-mix(in srgb,var(--accent) 70%,transparent);
199
+ width:6px;height:6px;border-radius:50%;flex:none;
200
+ background:#6366f1;box-shadow:0 0 6px rgba(99,102,241,.6);
118
201
  }
119
202
  #cladoAiToast.waiting .dot{
120
- background:#d97706;box-shadow:0 0 8px rgb(217 119 6 / .72);
121
- }
122
- [data-theme="dark"] #cladoAiToast.waiting .dot{
123
- background:#f59e0b;box-shadow:0 0 8px rgb(245 158 11 / .75);
203
+ background:#f59e0b;box-shadow:0 0 6px rgba(245,158,11,.65);
124
204
  }
125
205
  [data-theme="dark"] #cladoAiToast{
126
- background:color-mix(in srgb,var(--panel) 72%,transparent);
127
- box-shadow:0 8px 28px rgb(0 0 0 / .36);
206
+ background:color-mix(in srgb,var(--panel) 74%,transparent);
207
+ box-shadow:0 8px 28px rgba(0,0,0,.38);
208
+ }
209
+ @media(max-width:680px){
210
+ #cladoAiToast{
211
+ bottom:calc(max(12px,env(safe-area-inset-bottom)) + 54px);
212
+ max-width:calc(100vw - 24px);
213
+ }
128
214
  }
129
215
 
@@ -39,12 +39,15 @@ drawWires = function () {
39
39
  var sourceId = port.dataset.sourceId || source.dataset.id;
40
40
  if (canvasFocusLinks && !(canvasFocusLinks.has(sourceId) && canvasFocusLinks.has(port.dataset.anchorId || target.dataset.id))) return;
41
41
  var input = $('.hbar', target), targetId = port.dataset.anchorId || target.dataset.id;
42
- var landing = canvasMediaTarget(target, targetId, port.dataset.mediaPoint);
42
+ var landing = port.dataset.tagTarget
43
+ ? canvasCardTagTarget(target, port.dataset.tagTarget)
44
+ : canvasMediaTarget(target, targetId, port.dataset.mediaPoint);
43
45
  if (landing) {
44
46
  input = document.createElement('span'); input.className = 'hbar incoming-anchor';
45
47
  var cardRect = target.getBoundingClientRect();
46
48
  input.style.top = ((landing.y - cardRect.top) / (cardRect.width / target.offsetWidth) - 10) + 'px';
47
- input.dataset.mediaPoint = port.dataset.mediaPoint;
49
+ if (port.dataset.mediaPoint) input.dataset.mediaPoint = port.dataset.mediaPoint;
50
+ if (port.dataset.tagTarget) input.dataset.tagTarget = port.dataset.tagTarget;
48
51
  input.dataset.sourceId = sourceId;
49
52
  input.dataset.edge = targetId;
50
53
  target.append(input);