zcode-pro 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +12 -5
- package/README.md +12 -5
- package/dist/inject.js +4515 -415
- package/package.json +3 -3
- package/src/host/helper.mjs +3099 -48
- package/src/host/hot-swap.mjs +76 -0
- package/src/host/main.mjs +36 -14
- package/src/host/prompt-inject.mjs +174 -0
- package/src/host/provider-proxy.mjs +562 -0
- package/src/host/proxy-chain.mjs +137 -0
- package/src/host/setup.mjs +42 -17
- package/src/host/taskIndex.mjs +38 -13
- package/src/host/tool-name-check.mjs +164 -0
- package/src/host/translate-lib.mjs +781 -0
- package/src/inject/core.js +453 -17
- package/src/inject/features/auto-continue.js +46 -15
- package/src/inject/features/hr-notice.js +138 -0
- package/src/inject/features/newtab-panels.js +60 -20
- package/src/inject/features/proxy-chain-notice.js +215 -0
- package/src/inject/features/selection-toolbar-translate.js +174 -0
- package/src/inject/features/settings-dialog.js +1072 -86
- package/src/inject/features/status-bar.js +41 -10
- package/src/inject/features/translate-panel.js +883 -0
- package/src/inject/features/turn-usage.js +22 -3
- package/src/inject/index.js +10 -0
- package/src/inject/locales/ja.js +235 -7
- package/src/inject/locales/ko.js +235 -7
- package/src/inject/locales/ru.js +235 -7
- package/src/inject/provider-model-thinking.js +142 -0
- package/src/inject/thinking-levels.js +117 -0
- package/src/inject/ui.js +472 -2
package/src/inject/ui.js
CHANGED
|
@@ -41,6 +41,146 @@ export function showToast(text, kind = 'info') {
|
|
|
41
41
|
toastTimer = setTimeout(() => wrap.remove(), v.ms);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// 右下角提示卡片:固定贴在窗体右下角,用于「需要用户留意但不打断操作」的提示
|
|
45
|
+
// (居中 toast 会盖住正文,且 2.6 秒自动消失,操作类提示来不及处理)。
|
|
46
|
+
// 视觉与自动继续卡一致:12px 圆角、主题变量边框与底色、24px 阴影;主题变量缺失时
|
|
47
|
+
// 回退字面量,跟亮/暗主题都能对上。actions 为 [{ label, primary, onClick }],
|
|
48
|
+
// 点击后不自动关闭(由调用方或用户关)。同一 position 只保留一张卡,避免叠罗马柱。
|
|
49
|
+
//
|
|
50
|
+
// 底色不能用 --color-surface:该 token 在应用里是 ~3% 不透明度的着色层
|
|
51
|
+
// (#0d0d0d08),拿来做卡片底会整卡透明(见下方 AlertDialog 注释)。这里用
|
|
52
|
+
// --color-popover(实体底色),缺失时回退深色字面量。
|
|
53
|
+
const cornerCards = new Map();
|
|
54
|
+
|
|
55
|
+
// 位置表:bf=左下、br=右下、tl=左上、tr=右上
|
|
56
|
+
// 同一位置只保留一张卡片(新的替换旧的)。自动继续、headroom 提示、代理链迁移说明
|
|
57
|
+
// 都用 br;调用方在弹之前先用 .zcodepro-corner-card[data-zcodepro-corner="br"] 判断
|
|
58
|
+
// 有没有别的卡片占着,有就等它关掉,别叠在一起互相覆盖。
|
|
59
|
+
const CORNER_POS = {
|
|
60
|
+
bl: 'left:16px;bottom:16px;',
|
|
61
|
+
br: 'right:16px;bottom:16px;',
|
|
62
|
+
tl: 'left:16px;top:16px;',
|
|
63
|
+
tr: 'right:16px;top:16px;',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export function showCornerCard({ position = 'br', title, desc, actions = [], kind = 'info' } = {}) {
|
|
67
|
+
cornerCards.get(position)?.remove();
|
|
68
|
+
const glyph = { success: '✓', warning: '!', error: '✕', info: 'ⓘ' }[kind] || '';
|
|
69
|
+
const pos = CORNER_POS[position] || CORNER_POS.br;
|
|
70
|
+
const card = h('div', {
|
|
71
|
+
class: 'zcodepro-corner-card',
|
|
72
|
+
'data-zcodepro-corner': position,
|
|
73
|
+
style: `position:fixed;${pos}z-index:2147483000;max-width:360px;padding:12px;`
|
|
74
|
+
+ `border-radius:12px;border:1px solid var(--color-border, #3f3f46);`
|
|
75
|
+
+ `background:var(--color-popover, #1f1f23);color:var(--color-foreground, #eee);`
|
|
76
|
+
+ `font-size:13px;line-height:1.5;box-shadow:0 4px 24px rgba(0,0,0,.4);animation:zcodepro-fade-in .18s ease;`,
|
|
77
|
+
});
|
|
78
|
+
const head = h('div', { style: 'display:flex;align-items:flex-start;gap:6px;font-weight:600;margin-bottom:4px;' });
|
|
79
|
+
if (glyph) head.append(h('span', { style: 'flex:none;' }, glyph));
|
|
80
|
+
head.append(h('span', { style: 'flex:1;min-width:0;' }, String(title ?? '')));
|
|
81
|
+
const close = h('button', {
|
|
82
|
+
type: 'button',
|
|
83
|
+
'aria-label': '关闭',
|
|
84
|
+
style: 'flex:none;cursor:pointer;border:none;background:transparent;color:inherit;opacity:.6;font-size:14px;line-height:1;padding:0 2px;',
|
|
85
|
+
onclick: () => closeCornerCard(position),
|
|
86
|
+
}, '×');
|
|
87
|
+
head.append(close);
|
|
88
|
+
card.append(head);
|
|
89
|
+
if (desc) card.append(h('div', { style: 'opacity:.85;white-space:pre-wrap;' }, String(desc)));
|
|
90
|
+
const usable = actions.filter((a) => a && typeof a.onClick === 'function');
|
|
91
|
+
if (usable.length) {
|
|
92
|
+
const row = h('div', { style: 'display:flex;gap:8px;margin-top:10px;flex-wrap:wrap;' });
|
|
93
|
+
for (const a of usable) {
|
|
94
|
+
row.append(h('button', {
|
|
95
|
+
type: 'button',
|
|
96
|
+
style: a.primary
|
|
97
|
+
? 'cursor:pointer;border:none;border-radius:8px;padding:5px 12px;background:var(--color-brand, #4a7cf7);color:#fff;font-size:12px;'
|
|
98
|
+
: 'cursor:pointer;border-radius:8px;padding:5px 12px;background:transparent;border:1px solid var(--color-border, #666);color:inherit;font-size:12px;',
|
|
99
|
+
onclick: () => a.onClick(),
|
|
100
|
+
}, String(a.label ?? '')));
|
|
101
|
+
}
|
|
102
|
+
card.append(row);
|
|
103
|
+
}
|
|
104
|
+
document.body.append(card);
|
|
105
|
+
cornerCards.set(position, card);
|
|
106
|
+
return { close: () => closeCornerCard(position) };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 确认小弹窗:贴在触发按钮下方、带尖角指向按钮(视觉与划词翻译面板同款)。
|
|
110
|
+
// confirmTip(anchorEl, { title, desc, confirmLabel, onConfirm })
|
|
111
|
+
// 返回 close 函数;确认/取消/点击外部/按 Esc 都会关掉。
|
|
112
|
+
// 一次只开一个:再调时先关上一个(连点不同按钮不会叠一堆卡片)
|
|
113
|
+
let tipEl = null;
|
|
114
|
+
export function confirmTip(anchorEl, { title, desc = '', confirmLabel, onConfirm, buttons } = {}) {
|
|
115
|
+
closeConfirmTip();
|
|
116
|
+
if (!anchorEl || !anchorEl.isConnected) return () => {};
|
|
117
|
+
ensureStyle();
|
|
118
|
+
const el = h('div', { class: 'zcodepro-confirm-tip', role: 'dialog' },
|
|
119
|
+
h('div', { class: 'zcodepro-tip-arrow', 'aria-hidden': 'true' }));
|
|
120
|
+
const body = h('div', { style: 'padding:10px 12px;min-width:200px;max-width:300px;' });
|
|
121
|
+
if (title) body.append(h('div', { style: 'font-weight:600;margin-bottom:2px;' }, String(title)));
|
|
122
|
+
if (desc) body.append(h('div', { style: 'opacity:.85;white-space:pre-wrap;margin-bottom:8px;' }, String(desc)));
|
|
123
|
+
const row = h('div', { style: 'display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;' });
|
|
124
|
+
const mkBtn = (label, primary, onClick) => h('button', {
|
|
125
|
+
type: 'button',
|
|
126
|
+
style: primary
|
|
127
|
+
? 'cursor:pointer;border:none;border-radius:8px;padding:4px 10px;background:var(--color-brand, #4a7cf7);color:#fff;font-size:12px;'
|
|
128
|
+
: 'cursor:pointer;border-radius:8px;padding:4px 10px;background:transparent;border:1px solid var(--color-border, #666);color:inherit;font-size:12px;',
|
|
129
|
+
onclick: () => { closeConfirmTip(); onClick && onClick(); },
|
|
130
|
+
}, String(label));
|
|
131
|
+
// buttons 传入时完全替代默认的「取消/确认」:双选择场景(比如还原到链地址还是直连)
|
|
132
|
+
// 每个按钮点击后同样关掉弹窗,取消路径由调用方自己给一个按钮
|
|
133
|
+
if (Array.isArray(buttons) && buttons.length) {
|
|
134
|
+
for (const b of buttons) {
|
|
135
|
+
if (b && typeof b.label === 'string') row.append(mkBtn(b.label, !!b.primary, b.onClick));
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
row.append(mkBtn('取消', false, null), mkBtn(confirmLabel || '确认', true, onConfirm));
|
|
139
|
+
}
|
|
140
|
+
body.append(row);
|
|
141
|
+
el.append(body);
|
|
142
|
+
document.body.append(el);
|
|
143
|
+
tipEl = el;
|
|
144
|
+
// 落位:按钮下方,水平对准按钮中心并夹取到视口;尖角按实际左边距反算
|
|
145
|
+
const r = anchorEl.getBoundingClientRect();
|
|
146
|
+
const w = el.offsetWidth;
|
|
147
|
+
let left = r.left + r.width / 2 - w / 2;
|
|
148
|
+
left = Math.max(8, Math.min(left, window.innerWidth - w - 8));
|
|
149
|
+
el.style.left = `${Math.round(left)}px`;
|
|
150
|
+
el.style.top = `${Math.round(r.bottom + 8)}px`;
|
|
151
|
+
el.style.setProperty('--tip-arrow-x', `${Math.round(Math.min(Math.max(r.left + r.width / 2 - left, 10), w - 10))}px`);
|
|
152
|
+
// 点外部 / Esc 关闭(mousedown 而非 click:点确认/取消时这里先跑,别把刚开的弹窗当场关了)
|
|
153
|
+
const onDown = (e) => { if (tipEl && !tipEl.contains(e.target)) closeConfirmTip(); };
|
|
154
|
+
const onKey = (e) => { if (e.key === 'Escape') closeConfirmTip(); };
|
|
155
|
+
// 设置弹窗自己也有 Esc 栈:按 Esc 时它的 handler 先跑(关掉整个设置弹窗),
|
|
156
|
+
// 这里的 keydown 收不到——靠 settings-closed 事件兜住,弹窗关时 tip 不留孤儿
|
|
157
|
+
// (translate-panel 用的是同一个事件)
|
|
158
|
+
const onSettingsClosed = () => closeConfirmTip();
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
document.addEventListener('mousedown', onDown);
|
|
161
|
+
document.addEventListener('keydown', onKey);
|
|
162
|
+
window.addEventListener('zcodepro:settings-closed', onSettingsClosed);
|
|
163
|
+
}, 0);
|
|
164
|
+
tipEl.__cleanup = () => {
|
|
165
|
+
document.removeEventListener('mousedown', onDown);
|
|
166
|
+
document.removeEventListener('keydown', onKey);
|
|
167
|
+
window.removeEventListener('zcodepro:settings-closed', onSettingsClosed);
|
|
168
|
+
};
|
|
169
|
+
return closeConfirmTip;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function closeConfirmTip() {
|
|
173
|
+
if (!tipEl) return;
|
|
174
|
+
try { tipEl.__cleanup && tipEl.__cleanup(); } catch { /* ignore */ }
|
|
175
|
+
tipEl.remove();
|
|
176
|
+
tipEl = null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function closeCornerCard(position = 'br') {
|
|
180
|
+
cornerCards.get(position)?.remove();
|
|
181
|
+
cornerCards.delete(position);
|
|
182
|
+
}
|
|
183
|
+
|
|
44
184
|
// 复用应用自身 AlertDialog 的真实类名组合(逆向自 app.asar 渲染层源码):
|
|
45
185
|
// 遮罩 fixed inset-0 z-50 bg-black/60 + 毛玻璃 + Linux 下 top-12(让出自绘标题栏),
|
|
46
186
|
// 内容卡 rounded-2xl bg-popover/98 ring-border shadow-2xl。
|
|
@@ -57,11 +197,13 @@ const contentClass = 'w-full sm:max-w-md rounded-2xl border-none bg-popover/98 p
|
|
|
57
197
|
// dismissOnOutside: 点弹窗外部是否关闭(默认 true)。为 false 时遮罩不再拦截鼠标,
|
|
58
198
|
// 可以直接操作弹窗后面的会话(滚动/选中),弹窗只通过关闭按钮或 Esc 关闭。
|
|
59
199
|
// draggable: 允许按住标题栏拖动弹窗。posKey: 记住拖动位置(localStorage)。
|
|
200
|
+
// resizable: 允许拖左右两边改变宽度(高度始终随内容自适应,避免各标签页
|
|
201
|
+
// 内容多少不同时留大片空白)。sizeKey: 记住宽度(localStorage,与位置分开存)。
|
|
60
202
|
// 弹窗栈:同时打开多层弹窗(如“切换文件夹”上叠二次确认)时,
|
|
61
203
|
// Esc 只关最上层,避免一次 Esc 把两层一起关掉
|
|
62
204
|
let dialogStack = [];
|
|
63
205
|
|
|
64
|
-
export function openDialog({ title, description, onMount, onClose, width = 'sm:max-w-md', overlay = 'dim', draggable = false, posKey = '', dismissOnOutside = true, bodyClass = '', closable = false }) {
|
|
206
|
+
export function openDialog({ title, description, onMount, onClose, width = 'sm:max-w-md', overlay = 'dim', draggable = false, posKey = '', resizable = false, sizeKey = '', dismissOnOutside = true, bodyClass = '', closable = false }) {
|
|
65
207
|
const L = t();
|
|
66
208
|
const prevActive = document.activeElement;
|
|
67
209
|
let cleanupDrag = null;
|
|
@@ -74,6 +216,7 @@ export function openDialog({ title, description, onMount, onClose, width = 'sm:m
|
|
|
74
216
|
dialogStack = dialogStack.filter((e) => e !== overlayEl);
|
|
75
217
|
document.removeEventListener('keydown', onKey);
|
|
76
218
|
if (cleanupDrag) cleanupDrag();
|
|
219
|
+
if (cleanupResize) cleanupResize();
|
|
77
220
|
if (prevActive && prevActive.focus) { try { prevActive.focus(); } catch { /* ignore */ } }
|
|
78
221
|
onClose && onClose();
|
|
79
222
|
};
|
|
@@ -123,6 +266,7 @@ export function openDialog({ title, description, onMount, onClose, width = 'sm:m
|
|
|
123
266
|
const body = h('div', { class: 'zcodepro-dialog-body ' + (bodyClass || 'mt-4') });
|
|
124
267
|
content.append(body);
|
|
125
268
|
let restorePos = null;
|
|
269
|
+
let cleanupResize = null;
|
|
126
270
|
if (draggable) {
|
|
127
271
|
titleEl.style.cursor = 'move';
|
|
128
272
|
titleEl.style.userSelect = 'none';
|
|
@@ -214,6 +358,76 @@ export function openDialog({ title, description, onMount, onClose, width = 'sm:m
|
|
|
214
358
|
};
|
|
215
359
|
restorePos = restore;
|
|
216
360
|
}
|
|
361
|
+
// 缩放:四边与四角各一条透明热区,拖动改尺寸,松开写 localStorage。
|
|
362
|
+
// 与起始尺寸一起记下,下次打开在恢复位置之前先应用尺寸
|
|
363
|
+
// 只支持改宽度:高度保持内容自适应(各标签页内容多少差别大,固定高度会
|
|
364
|
+
// 留下大片空白)。左右两条透明热区,拖动改宽度,松开写 localStorage 记住
|
|
365
|
+
if (resizable) {
|
|
366
|
+
const MIN_W = 320;
|
|
367
|
+
const edges = [
|
|
368
|
+
['w', 'left:0;top:10px;bottom:10px;width:6px;cursor:ew-resize'],
|
|
369
|
+
['e', 'right:0;top:10px;bottom:10px;width:6px;cursor:ew-resize'],
|
|
370
|
+
];
|
|
371
|
+
// 宽度以整卡当前宽度为起点;拖左边时同步平移 margin-left,右边界不动
|
|
372
|
+
const baseMarginLeft = () => parseFloat(getComputedStyle(content).marginLeft) || 0;
|
|
373
|
+
const edgeEls = edges.map(([dir, css]) => {
|
|
374
|
+
const el = h('div', { class: 'zcodepro-dialog-edge', 'data-dir': dir, 'aria-hidden': 'true', style: css });
|
|
375
|
+
el.addEventListener('mousedown', (e) => {
|
|
376
|
+
if (e.button !== 0) return;
|
|
377
|
+
e.preventDefault();
|
|
378
|
+
e.stopPropagation();
|
|
379
|
+
const r = content.getBoundingClientRect();
|
|
380
|
+
const sx = e.clientX;
|
|
381
|
+
const sw = r.width;
|
|
382
|
+
const sl = r.left;
|
|
383
|
+
const hasW = dir.includes('w');
|
|
384
|
+
const ml0 = baseMarginLeft();
|
|
385
|
+
let w = sw;
|
|
386
|
+
const onMove = (ev) => {
|
|
387
|
+
const dx = ev.clientX - sx;
|
|
388
|
+
if (hasW) {
|
|
389
|
+
// 拖左边:宽度反向变化,左边界跟鼠标走,右边界不动
|
|
390
|
+
const clamped = Math.max(dx, MIN_W - sw); // 不让宽度小于下限
|
|
391
|
+
const newLeft = Math.max(8, sl + clamped);
|
|
392
|
+
w = sw + (sl - newLeft); // 左边界左移则变宽
|
|
393
|
+
w = Math.max(MIN_W, Math.min(w, window.innerWidth - newLeft - 8));
|
|
394
|
+
const shift = newLeft - sl;
|
|
395
|
+
content.style.marginLeft = (ml0 + shift) + 'px';
|
|
396
|
+
} else {
|
|
397
|
+
// 拖右边:左边界不动,宽度跟鼠标走
|
|
398
|
+
w = Math.max(MIN_W, Math.min(sw + dx, window.innerWidth - sl - 8));
|
|
399
|
+
}
|
|
400
|
+
content.style.width = w + 'px';
|
|
401
|
+
content.style.maxWidth = 'none';
|
|
402
|
+
};
|
|
403
|
+
const onUp = () => {
|
|
404
|
+
document.removeEventListener('mousemove', onMove);
|
|
405
|
+
document.removeEventListener('mouseup', onUp);
|
|
406
|
+
if (sizeKey) {
|
|
407
|
+
try { localStorage.setItem('zcodepro-dialog-size:' + sizeKey, JSON.stringify({ w: Math.round(w) })); } catch { /* ignore */ }
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
document.addEventListener('mousemove', onMove);
|
|
411
|
+
document.addEventListener('mouseup', onUp);
|
|
412
|
+
});
|
|
413
|
+
return el;
|
|
414
|
+
});
|
|
415
|
+
content.style.position = 'relative';
|
|
416
|
+
content.append(...edgeEls);
|
|
417
|
+
// 恢复上次宽度(只存宽度;高度始终由内容决定)
|
|
418
|
+
if (sizeKey) {
|
|
419
|
+
try {
|
|
420
|
+
const saved = JSON.parse(localStorage.getItem('zcodepro-dialog-size:' + sizeKey) || 'null');
|
|
421
|
+
if (saved && Number.isFinite(saved.w)) {
|
|
422
|
+
content.style.width = Math.max(MIN_W, Math.min(saved.w, window.innerWidth - 16)) + 'px';
|
|
423
|
+
content.style.maxWidth = 'none';
|
|
424
|
+
}
|
|
425
|
+
} catch { /* ignore */ }
|
|
426
|
+
}
|
|
427
|
+
cleanupResize = () => {
|
|
428
|
+
// 热区跟着 content 一起被移除,无需单独摘监听
|
|
429
|
+
};
|
|
430
|
+
}
|
|
217
431
|
document.addEventListener('keydown', onKey, true);
|
|
218
432
|
document.body.append(overlayEl);
|
|
219
433
|
// 恢复位置要在挂载后测尺寸(未挂载时 offsetWidth 为 0,边界算不出来)
|
|
@@ -455,6 +669,8 @@ export function ensureStyle() {
|
|
|
455
669
|
.zcodepro-toast-info .zcodepro-toast-glyph { color: var(--color-foreground-subtle, #999); }
|
|
456
670
|
/* 弹窗遮罩/面板兜底:不依赖应用 Tailwind 类是否仍存在;主题色走 --color-* 变量,缺失时回退字面量 */
|
|
457
671
|
.zcodepro-overlay { background-color: rgba(0, 0, 0, 0.6); }
|
|
672
|
+
/* 弹窗缩放热区:四边四角透明细条,没有可见图标 */
|
|
673
|
+
.zcodepro-dialog-edge { position: absolute; touch-action: none; z-index: 5; }
|
|
458
674
|
.zcodepro-overlay[data-overlay="none"] { background-color: transparent; }
|
|
459
675
|
.zcodepro-card {
|
|
460
676
|
background-color: var(--color-popover, #fff);
|
|
@@ -517,6 +733,36 @@ export function ensureStyle() {
|
|
|
517
733
|
border-radius: 9999px;
|
|
518
734
|
background-color: color-mix(in oklab, var(--color-foreground, #888) 8%, transparent);
|
|
519
735
|
}
|
|
736
|
+
/* 一级 tab 栏可横向滚动:tab 多、弹窗窄时不被裁掉。
|
|
737
|
+
滚动条默认隐藏(保持胶囊外观),但内容溢出时鼠标滚轮可横向滚、
|
|
738
|
+
按住 tab 可拖动滚动(见 settings-dialog.js 的 bindTabDragScroll)。
|
|
739
|
+
边缘渐隐只在“确实还有内容被挡住”时由 JS 加 data-overflow 才出现,
|
|
740
|
+
全部能显示时不加任何遮罩 */
|
|
741
|
+
.zcodepro-tablist.zcodepro-tablist-scroll {
|
|
742
|
+
max-width: 100%;
|
|
743
|
+
overflow-x: auto;
|
|
744
|
+
overflow-y: hidden;
|
|
745
|
+
scrollbar-width: none; /* Firefox */
|
|
746
|
+
-ms-overflow-style: none; /* 旧 Edge */
|
|
747
|
+
cursor: grab;
|
|
748
|
+
user-select: none; /* 拖动时不要选中 tab 文字 */
|
|
749
|
+
}
|
|
750
|
+
.zcodepro-tablist.zcodepro-tablist-scroll[data-dragging="1"] { cursor: grabbing; }
|
|
751
|
+
.zcodepro-tablist.zcodepro-tablist-scroll::-webkit-scrollbar { display: none; }
|
|
752
|
+
.zcodepro-tablist.zcodepro-tablist-scroll > * { flex-shrink: 0; }
|
|
753
|
+
/* 内容溢出时两端渐隐;滚到某一端时该端不再渐隐(该侧已无内容) */
|
|
754
|
+
.zcodepro-tablist.zcodepro-tablist-scroll[data-overflow="1"] {
|
|
755
|
+
-webkit-mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
|
|
756
|
+
mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
|
|
757
|
+
}
|
|
758
|
+
.zcodepro-tablist.zcodepro-tablist-scroll[data-overflow="start"] {
|
|
759
|
+
-webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
|
|
760
|
+
mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
|
|
761
|
+
}
|
|
762
|
+
.zcodepro-tablist.zcodepro-tablist-scroll[data-overflow="end"] {
|
|
763
|
+
-webkit-mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 100%);
|
|
764
|
+
mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 100%);
|
|
765
|
+
}
|
|
520
766
|
.zcodepro-tab {
|
|
521
767
|
display: inline-flex;
|
|
522
768
|
align-items: center;
|
|
@@ -781,12 +1027,15 @@ export function ensureStyle() {
|
|
|
781
1027
|
opacity: 0.3;
|
|
782
1028
|
margin: 0 2px;
|
|
783
1029
|
}
|
|
784
|
-
/* 每项内部用 flex
|
|
1030
|
+
/* 每项内部用 flex 对齐:图标、标签、数值垂直居中,间距统一。
|
|
1031
|
+
pointer-events 必须显式恢复:容器设 none 是为了不挡住输入框区域的点击,
|
|
1032
|
+
但 none 会被子项继承,原生 title 提示就永远弹不出来(所有项的悬停说明都失效) */
|
|
785
1033
|
.zcodepro-statusbar span[title] {
|
|
786
1034
|
display: inline-flex;
|
|
787
1035
|
align-items: center;
|
|
788
1036
|
gap: 3px;
|
|
789
1037
|
white-space: nowrap;
|
|
1038
|
+
pointer-events: auto;
|
|
790
1039
|
}
|
|
791
1040
|
.zcodepro-sb-icon {
|
|
792
1041
|
width: 12px;
|
|
@@ -955,5 +1204,226 @@ export function ensureStyle() {
|
|
|
955
1204
|
.zcodepro-pin-collapsed > :is(ul, div):has(li[data-task-item-key]) { display: none !important; }
|
|
956
1205
|
/* 折叠后去掉标题自带的底部留白,与下一分区的间隔和其他分区节奏一致 */
|
|
957
1206
|
.zcodepro-pin-collapsed .zcodepro-pin-head { padding-bottom: 0; }
|
|
1207
|
+
/* 确认小弹窗(实例行「还原」等危险操作用):与划词翻译面板同一套视觉
|
|
1208
|
+
(popover 配色/圆角/阴影/尖角),贴在触发按钮下方 */
|
|
1209
|
+
.zcodepro-confirm-tip {
|
|
1210
|
+
position: fixed;
|
|
1211
|
+
z-index: 2147483000;
|
|
1212
|
+
background: var(--color-popover, #fff);
|
|
1213
|
+
color: var(--color-foreground, #222);
|
|
1214
|
+
border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
|
|
1215
|
+
border-radius: 12px;
|
|
1216
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
|
|
1217
|
+
font-size: 13px;
|
|
1218
|
+
line-height: 1.6;
|
|
1219
|
+
animation: zcodepro-fade-in .12s ease;
|
|
1220
|
+
}
|
|
1221
|
+
/* 尖角贴顶边朝上,指向触发按钮:--tip-arrow-x 由定位函数按按钮中心反算 */
|
|
1222
|
+
.zcodepro-confirm-tip .zcodepro-tip-arrow {
|
|
1223
|
+
position: absolute;
|
|
1224
|
+
top: -8px;
|
|
1225
|
+
width: 0;
|
|
1226
|
+
height: 0;
|
|
1227
|
+
left: var(--tip-arrow-x, 50%);
|
|
1228
|
+
transform: translateX(-50%);
|
|
1229
|
+
pointer-events: none;
|
|
1230
|
+
border-left: 8px solid transparent;
|
|
1231
|
+
border-right: 8px solid transparent;
|
|
1232
|
+
border-bottom: 8px solid var(--color-border, rgba(0, 0, 0, 0.12));
|
|
1233
|
+
}
|
|
1234
|
+
.zcodepro-confirm-tip .zcodepro-tip-arrow::after {
|
|
1235
|
+
content: '';
|
|
1236
|
+
position: absolute;
|
|
1237
|
+
left: -7px;
|
|
1238
|
+
top: 1px;
|
|
1239
|
+
border-left: 7px solid transparent;
|
|
1240
|
+
border-right: 7px solid transparent;
|
|
1241
|
+
border-bottom: 7px solid var(--color-popover, #fff);
|
|
1242
|
+
}
|
|
1243
|
+
/* 划词翻译面板:fixed 浮层(右键菜单同级的最高层),配色全走主题变量 */
|
|
1244
|
+
.zcodepro-translate-panel {
|
|
1245
|
+
position: fixed;
|
|
1246
|
+
z-index: 2147483000;
|
|
1247
|
+
display: flex;
|
|
1248
|
+
flex-direction: column;
|
|
1249
|
+
background: var(--color-popover, #fff);
|
|
1250
|
+
color: var(--color-foreground, #222);
|
|
1251
|
+
border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
|
|
1252
|
+
border-radius: 12px;
|
|
1253
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
|
|
1254
|
+
overflow: visible; /* 尖角探出面板边界 */
|
|
1255
|
+
font-size: 13px;
|
|
1256
|
+
line-height: 1.6;
|
|
1257
|
+
}
|
|
1258
|
+
/* 面板内滚动区自己裁切(面板不能 overflow:hidden,否则尖角被切掉) */
|
|
1259
|
+
/* 面板内的块元素用相对定位(给尖角与缩放手柄做定位参照)。
|
|
1260
|
+
必须排除同样是绝对定位的子元素:尖角与缩放热区若被这条覆盖成
|
|
1261
|
+
relative 会掉进普通流、跑到面板左下角 */
|
|
1262
|
+
.zcodepro-translate-panel > :not(.zcodepro-tr-arrow):not(.zcodepro-tr-edge) { position: relative; }
|
|
1263
|
+
/* 指向选中文字的尖角:--tr-arrow-x 由 positionPanel 按选区中心反算。
|
|
1264
|
+
外层画描边色三角、after 画面板底色三角,叠出带边框的尖角 */
|
|
1265
|
+
.zcodepro-tr-arrow {
|
|
1266
|
+
position: absolute;
|
|
1267
|
+
width: 0;
|
|
1268
|
+
height: 0;
|
|
1269
|
+
left: var(--tr-arrow-x, 50%);
|
|
1270
|
+
transform: translateX(-50%);
|
|
1271
|
+
pointer-events: none;
|
|
1272
|
+
border-left: 8px solid transparent;
|
|
1273
|
+
border-right: 8px solid transparent;
|
|
1274
|
+
}
|
|
1275
|
+
.zcodepro-tr-arrow::after {
|
|
1276
|
+
content: '';
|
|
1277
|
+
position: absolute;
|
|
1278
|
+
left: -7px;
|
|
1279
|
+
border-left: 7px solid transparent;
|
|
1280
|
+
border-right: 7px solid transparent;
|
|
1281
|
+
}
|
|
1282
|
+
/* 面板在选区上方:尖角贴面板底边、朝下 */
|
|
1283
|
+
.zcodepro-translate-panel[data-placement="top"] .zcodepro-tr-arrow {
|
|
1284
|
+
bottom: -8px;
|
|
1285
|
+
border-top: 8px solid var(--color-border, rgba(0, 0, 0, 0.12));
|
|
1286
|
+
}
|
|
1287
|
+
.zcodepro-translate-panel[data-placement="top"] .zcodepro-tr-arrow::after {
|
|
1288
|
+
top: -9px;
|
|
1289
|
+
border-top: 7px solid var(--color-popover, #fff);
|
|
1290
|
+
}
|
|
1291
|
+
/* 面板在选区下方:尖角贴面板顶边、朝上 */
|
|
1292
|
+
.zcodepro-translate-panel[data-placement="bottom"] .zcodepro-tr-arrow {
|
|
1293
|
+
top: -8px;
|
|
1294
|
+
border-bottom: 8px solid var(--color-border, rgba(0, 0, 0, 0.12));
|
|
1295
|
+
}
|
|
1296
|
+
.zcodepro-translate-panel[data-placement="bottom"] .zcodepro-tr-arrow::after {
|
|
1297
|
+
top: 1px;
|
|
1298
|
+
border-bottom: 7px solid var(--color-popover, #fff);
|
|
1299
|
+
}
|
|
1300
|
+
/* 手动拖动过:尖角不再指向选区,隐藏 */
|
|
1301
|
+
.zcodepro-translate-panel[data-dragged] .zcodepro-tr-arrow { display: none; }
|
|
1302
|
+
/* 缩放热区:四边四角各一条透明的绝对定位细条,没有可见图标。
|
|
1303
|
+
具体位置与光标由内联样式按方向给出(见 translate-panel.js 的 edges 表)。
|
|
1304
|
+
放在最上层(z-index:3)以保证边缘优先于内容接收鼠标 */
|
|
1305
|
+
.zcodepro-tr-edge {
|
|
1306
|
+
position: absolute;
|
|
1307
|
+
touch-action: none;
|
|
1308
|
+
z-index: 3;
|
|
1309
|
+
}
|
|
1310
|
+
/* 设了像素高度后,正文区自己滚动 */
|
|
1311
|
+
.zcodepro-translate-panel[style*="height:"] .zcodepro-tr-body { overflow: auto; }
|
|
1312
|
+
/* overflow:visible 后圆角不再被父级裁切:首尾子元素各自补圆角(11px = 12px 减去 1px 边框) */
|
|
1313
|
+
.zcodepro-translate-panel > .zcodepro-tr-head { border-top-left-radius: 11px; border-top-right-radius: 11px; }
|
|
1314
|
+
.zcodepro-translate-panel > .zcodepro-tr-body { border-bottom-left-radius: 11px; border-bottom-right-radius: 11px; }
|
|
1315
|
+
/* flex 子项要能收缩,否则 body 的 overflow:auto 不起作用、高内容撑破 max-height */
|
|
1316
|
+
.zcodepro-tr-body { min-height: 0; }
|
|
1317
|
+
/* 面板主题:data-theme=light/dark 在面板根上覆盖主题变量(follow 不设,跟随宿主) */
|
|
1318
|
+
.zcodepro-translate-panel[data-theme="light"] {
|
|
1319
|
+
--color-popover: #fff; --color-foreground: #222; --color-border: rgba(0, 0, 0, 0.12);
|
|
1320
|
+
--color-muted: rgba(0, 0, 0, 0.04); --color-muted-foreground: #777; --color-accent: rgba(0, 0, 0, 0.08);
|
|
1321
|
+
--color-input: #fff; --color-primary: #2563eb; --color-primary-foreground: #fff; --color-destructive: #dc2626;
|
|
1322
|
+
}
|
|
1323
|
+
.zcodepro-translate-panel[data-theme="dark"] {
|
|
1324
|
+
--color-popover: #202124; --color-foreground: #e8eaed; --color-border: rgba(255, 255, 255, 0.14);
|
|
1325
|
+
--color-muted: rgba(255, 255, 255, 0.06); --color-muted-foreground: #9aa0a6; --color-accent: rgba(255, 255, 255, 0.1);
|
|
1326
|
+
--color-input: #2a2b2e; --color-primary: #4c8dff; --color-primary-foreground: #fff; --color-destructive: #f2635f;
|
|
1327
|
+
}
|
|
1328
|
+
.zcodepro-tr-head {
|
|
1329
|
+
display: flex;
|
|
1330
|
+
align-items: center;
|
|
1331
|
+
justify-content: space-between;
|
|
1332
|
+
gap: 8px;
|
|
1333
|
+
padding: 5px 8px 5px 12px;
|
|
1334
|
+
cursor: move;
|
|
1335
|
+
user-select: none;
|
|
1336
|
+
border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
|
|
1337
|
+
background: var(--color-muted, rgba(0, 0, 0, 0.04));
|
|
1338
|
+
}
|
|
1339
|
+
.zcodepro-tr-title { font-weight: 600; font-size: 12px; }
|
|
1340
|
+
.zcodepro-tr-headbtns { display: flex; gap: 2px; }
|
|
1341
|
+
.zcodepro-tr-ibtn {
|
|
1342
|
+
border: none;
|
|
1343
|
+
background: transparent;
|
|
1344
|
+
color: inherit;
|
|
1345
|
+
cursor: pointer;
|
|
1346
|
+
padding: 2px 7px;
|
|
1347
|
+
border-radius: 6px;
|
|
1348
|
+
font-size: 12px;
|
|
1349
|
+
line-height: 1.5;
|
|
1350
|
+
}
|
|
1351
|
+
.zcodepro-tr-ibtn:hover { background: var(--color-accent, rgba(0, 0, 0, 0.08)); }
|
|
1352
|
+
/* 按钮内图标与文字居中对齐(lucide 描边图标统一纯色) */
|
|
1353
|
+
.zcodepro-tr-ibtn {
|
|
1354
|
+
display: inline-flex;
|
|
1355
|
+
align-items: center;
|
|
1356
|
+
gap: 4px;
|
|
1357
|
+
}
|
|
1358
|
+
.zcodepro-tr-ibtn svg { display: block; }
|
|
1359
|
+
/* 历史条目的类型图标跟文字基线对齐 */
|
|
1360
|
+
.zcodepro-tr-histtext { display: inline-flex; align-items: center; gap: 4px; }
|
|
1361
|
+
.zcodepro-tr-ibtn-primary { background: var(--color-primary, #2563eb); color: var(--color-primary-foreground, #fff); }
|
|
1362
|
+
.zcodepro-tr-toolbar {
|
|
1363
|
+
display: flex;
|
|
1364
|
+
flex-wrap: wrap;
|
|
1365
|
+
align-items: center;
|
|
1366
|
+
gap: 6px;
|
|
1367
|
+
padding: 7px 10px;
|
|
1368
|
+
border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
|
|
1369
|
+
}
|
|
1370
|
+
.zcodepro-tr-select, .zcodepro-tr-input {
|
|
1371
|
+
height: 26px;
|
|
1372
|
+
border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
|
|
1373
|
+
background: var(--color-input, #fff);
|
|
1374
|
+
color: inherit;
|
|
1375
|
+
border-radius: 7px;
|
|
1376
|
+
padding: 0 6px;
|
|
1377
|
+
font-size: 12px;
|
|
1378
|
+
min-width: 0;
|
|
1379
|
+
}
|
|
1380
|
+
.zcodepro-tr-select { max-width: 220px; }
|
|
1381
|
+
.zcodepro-tr-textarea {
|
|
1382
|
+
width: 100%;
|
|
1383
|
+
border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
|
|
1384
|
+
background: var(--color-input, #fff);
|
|
1385
|
+
color: inherit;
|
|
1386
|
+
border-radius: 8px;
|
|
1387
|
+
padding: 6px 8px;
|
|
1388
|
+
font-size: 12px;
|
|
1389
|
+
resize: vertical;
|
|
1390
|
+
}
|
|
1391
|
+
.zcodepro-tr-inputrow { display: flex; gap: 6px; padding: 8px 10px 0; }
|
|
1392
|
+
.zcodepro-tr-inputrow .zcodepro-tr-input { flex: 1; height: 28px; }
|
|
1393
|
+
.zcodepro-tr-body { padding: 10px; overflow: auto; flex: 1; min-height: 48px; }
|
|
1394
|
+
.zcodepro-tr-loading { color: var(--color-muted-foreground, #888); }
|
|
1395
|
+
.zcodepro-tr-err { color: var(--color-destructive, #dc2626); }
|
|
1396
|
+
.zcodepro-tr-wordrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
|
|
1397
|
+
.zcodepro-tr-word { font-size: 15px; font-weight: 600; }
|
|
1398
|
+
.zcodepro-tr-phon { color: var(--color-muted-foreground, #777); font-size: 12px; }
|
|
1399
|
+
.zcodepro-tr-defs { margin-top: 4px; }
|
|
1400
|
+
.zcodepro-tr-pos { display: inline-block; margin-right: 6px; color: var(--color-muted-foreground, #777); font-style: italic; font-size: 12px; }
|
|
1401
|
+
.zcodepro-tr-example {
|
|
1402
|
+
border-left: 2px solid var(--color-border, rgba(0, 0, 0, 0.15));
|
|
1403
|
+
padding-left: 8px;
|
|
1404
|
+
margin: 6px 0 0;
|
|
1405
|
+
color: var(--color-muted-foreground, #666);
|
|
1406
|
+
font-size: 12px;
|
|
1407
|
+
}
|
|
1408
|
+
.zcodepro-tr-example-dst { margin-top: 2px; }
|
|
1409
|
+
.zcodepro-tr-forms { margin-top: 6px; color: var(--color-muted-foreground, #777); font-size: 12px; }
|
|
1410
|
+
.zcodepro-tr-out { white-space: pre-wrap; word-break: break-word; }
|
|
1411
|
+
.zcodepro-tr-details summary { cursor: pointer; color: var(--color-muted-foreground, #888); font-size: 12px; }
|
|
1412
|
+
.zcodepro-tr-src-text { color: var(--color-muted-foreground, #888); font-size: 12px; margin-top: 4px; white-space: pre-wrap; }
|
|
1413
|
+
.zcodepro-tr-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
|
|
1414
|
+
.zcodepro-tr-meta { color: var(--color-muted-foreground, #888); font-size: 12px; margin-right: auto; }
|
|
1415
|
+
.zcodepro-tr-hint { margin-top: 6px; color: var(--color-muted-foreground, #888); font-size: 12px; }
|
|
1416
|
+
.zcodepro-tr-empty { color: var(--color-muted-foreground, #888); }
|
|
1417
|
+
.zcodepro-tr-histitem {
|
|
1418
|
+
display: flex;
|
|
1419
|
+
gap: 8px;
|
|
1420
|
+
padding: 4px 6px;
|
|
1421
|
+
border-radius: 6px;
|
|
1422
|
+
cursor: pointer;
|
|
1423
|
+
align-items: baseline;
|
|
1424
|
+
}
|
|
1425
|
+
.zcodepro-tr-histitem:hover { background: var(--color-accent, rgba(0, 0, 0, 0.06)); }
|
|
1426
|
+
.zcodepro-tr-histtime { color: var(--color-muted-foreground, #999); font-size: 11px; flex-shrink: 0; }
|
|
1427
|
+
.zcodepro-tr-histtext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
958
1428
|
`));
|
|
959
1429
|
}
|