dsh-edit-turn 0.5.23 → 0.6.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/lib/client.js +56 -11
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -371,11 +371,39 @@ window.__ModuleLoader__.load({
|
|
|
371
371
|
clearVar('--dshet-panel')
|
|
372
372
|
clearVar('--dshet-chip')
|
|
373
373
|
clearVar('--dshet-field')
|
|
374
|
+
clearVar('--dshet-ink')
|
|
375
|
+
clearVar('--dshet-ink-dim')
|
|
376
|
+
clearVar('--dshet-ink-soft')
|
|
374
377
|
} else {
|
|
375
378
|
const fieldSolid = solid(layer2) ?? panelSolid
|
|
376
379
|
setVar('--dshet-panel', css(panelSolid))
|
|
377
380
|
setVar('--dshet-chip', css(panelSolid))
|
|
378
381
|
setVar('--dshet-field', css(fieldSolid))
|
|
382
|
+
// 文字颜色必须和「我们自己画的那块底」配,而不是和主题的底色配:
|
|
383
|
+
// 皮肤可能只覆盖了表面色、没覆盖 label-primary(或把它定义在别的
|
|
384
|
+
// 作用域),这时 `var(--dsw-alias-label-primary, #0f1524)` 会落到近黑,
|
|
385
|
+
// 深色面板上就是「黑底黑字」——看起来像整块黑板。
|
|
386
|
+
// 用面板亮度直接决定前景色。
|
|
387
|
+
const channel = (value) => {
|
|
388
|
+
const v = value / 255
|
|
389
|
+
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4
|
|
390
|
+
}
|
|
391
|
+
const panelLuminance = 0.2126 * channel(panelSolid.r) + 0.7152 * channel(panelSolid.g) + 0.0722 * channel(panelSolid.b)
|
|
392
|
+
const declaredInk = read('--dsw-alias-label-primary')
|
|
393
|
+
const readableOnDark = panelLuminance < 0.4
|
|
394
|
+
const declaredContrast = declaredInk === null
|
|
395
|
+
? 0
|
|
396
|
+
: Math.abs(0.2126 * channel(declaredInk.r) + 0.7152 * channel(declaredInk.g) + 0.0722 * channel(declaredInk.b) - panelLuminance)
|
|
397
|
+
if (declaredContrast < 0.24) {
|
|
398
|
+
// 主题给的前景在这个面板上没有对比度(或根本没给)——自己配一套。
|
|
399
|
+
setVar('--dshet-ink', readableOnDark ? '#f2f4f8' : '#0f1524')
|
|
400
|
+
setVar('--dshet-ink-dim', readableOnDark ? 'rgba(242,244,248,.76)' : 'rgba(15,21,36,.72)')
|
|
401
|
+
setVar('--dshet-ink-soft', readableOnDark ? 'rgba(242,244,248,.58)' : 'rgba(15,21,36,.55)')
|
|
402
|
+
} else {
|
|
403
|
+
clearVar('--dshet-ink')
|
|
404
|
+
clearVar('--dshet-ink-dim')
|
|
405
|
+
clearVar('--dshet-ink-soft')
|
|
406
|
+
}
|
|
379
407
|
}
|
|
380
408
|
if (accent === null) {
|
|
381
409
|
clearVar('--dshet-on-accent')
|
|
@@ -429,7 +457,7 @@ window.__ModuleLoader__.load({
|
|
|
429
457
|
// read as a different, "active" icon next to the neutral grey ones. The
|
|
430
458
|
// variable resolves on the action bar (and everywhere above it); the
|
|
431
459
|
// fallback is the value it resolves to in the default theme.
|
|
432
|
-
'.dshet-action{width:28px;height:28px;padding:6px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:28px;background:transparent;color:var(--dsw-alias-label-tertiary,#81858c);cursor:pointer;transition:background-color .12s,color .12s}',
|
|
460
|
+
'.dshet-action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));padding:6px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:28px;background:transparent;color:var(--dsw-alias-label-tertiary,#81858c);cursor:pointer;transition:background-color .12s,color .12s}',
|
|
433
461
|
// The fallback strip for a turn with no closing body.
|
|
434
462
|
//
|
|
435
463
|
// The gate is the host's OWN marker: TurnTailNodeView renders
|
|
@@ -445,7 +473,7 @@ window.__ModuleLoader__.load({
|
|
|
445
473
|
'.dshet-action:hover:not(:disabled){background:var(--dshet-chip);box-shadow:inset 0 0 0 1px var(--dshet-line);color:var(--dsw-alias-label-primary,var(--dshet-ink))}',
|
|
446
474
|
'.dshet-action:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,var(--dshet-accent));outline-offset:2px}',
|
|
447
475
|
'.dshet-action:disabled{cursor:default;opacity:.4}',
|
|
448
|
-
'.dshet-action svg{width:
|
|
476
|
+
'.dshet-action svg{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}',
|
|
449
477
|
// The reply pencil leads its strip. The host draws the copy button ahead of
|
|
450
478
|
// the slot this entry is rendered into, and the strip lays its children out
|
|
451
479
|
// in DOM order, so in DOM position the pencil can only ever come second -
|
|
@@ -519,7 +547,7 @@ window.__ModuleLoader__.load({
|
|
|
519
547
|
'.dshet-editor:focus-within{border-color:var(--dsw-alias-button-primary-fill,var(--dshet-accent))}',
|
|
520
548
|
'.dshet-editor[data-dshet-inplace="1"]{overflow:hidden;border:1.5px solid var(--dsw-alias-button-primary-fill,#4a7dff);border-radius:var(--dshet-radius-md);background:var(--dshet-panel);backdrop-filter:none;box-shadow:none}',
|
|
521
549
|
'.dshet-editor[data-dshet-inplace="1"] textarea{position:absolute;min-height:0;max-height:none;padding:6px 10px;border:0;border-radius:8px;background:transparent;overflow-y:auto}',
|
|
522
|
-
'.dshet-editor[data-dshet-inplace="1"] .dshet-footer{position:absolute;top:auto;left:0;right:0;bottom:0;height:46px;align-items:center;padding:6px 10px;box-sizing:border-box;background:
|
|
550
|
+
'.dshet-editor[data-dshet-inplace="1"] .dshet-footer{position:absolute;top:auto;left:0;right:0;bottom:0;height:calc(46px + var(--dsh-content-font-delta,0px));align-items:center;padding:6px 10px;box-sizing:border-box;background:transparent;border-radius:0 0 var(--dshet-radius-md) var(--dshet-radius-md);gap:6px}',
|
|
523
551
|
'.dshet-editor[data-dshet-inplace="1"] .dshet-btn{padding:2px 8px;font-size:12px;line-height:18px;border-radius:8px}',
|
|
524
552
|
'.dshet-editor[data-dshet-inplace="1"] .dshet-pick{position:static;top:auto;left:auto;padding:0;background:transparent;border-radius:0}',
|
|
525
553
|
'.dshet-editor[data-dshet-inplace="1"] .dshet-note,.dshet-editor[data-dshet-inplace="1"] .dshet-warn{position:absolute;left:8px;bottom:6px;max-width:60%;margin:0;background:var(--dshet-panel);border-radius:8px;padding:2px 6px}',
|
|
@@ -570,19 +598,19 @@ window.__ModuleLoader__.load({
|
|
|
570
598
|
'.dshet-btn:hover:not(:disabled){background:var(--dshet-hover)}',
|
|
571
599
|
'.dshet-btn:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,var(--dshet-accent));outline-offset:2px}',
|
|
572
600
|
'.dshet-btn:disabled{cursor:default;opacity:.5}',
|
|
573
|
-
'.dshet-btn-save{width:28px;height:28px;padding:0;border:0;border-radius:50%;background:transparent;color:#81858c}',
|
|
601
|
+
'.dshet-btn-save{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));padding:0;border:0;border-radius:50%;background:transparent;color:#81858c}',
|
|
574
602
|
'.dshet-btn-save:hover:not(:disabled){background:var(--dshet-hover)}',
|
|
575
|
-
'.dshet-btn-save svg{width:
|
|
603
|
+
'.dshet-btn-save svg{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));display:block;stroke:currentColor;fill:none;stroke-width:1.2;stroke-linecap:round;stroke-linejoin:round}',
|
|
576
604
|
'.dshet-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}',
|
|
577
605
|
'.dshet-btn-primary{border-color:var(--dsw-alias-button-primary-fill,var(--dshet-accent));background:var(--dsw-alias-button-primary-fill,var(--dshet-accent));color:var(--dsw-alias-label-primary-foreground,var(--dshet-on-accent))}',
|
|
578
606
|
'.dshet-btn-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-fill,var(--dshet-accent));filter:brightness(1.08)}',
|
|
579
|
-
'.dshet-btn.dshet-btn-save{width:28px;height:28px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--dshet-ink-soft);filter:none}',
|
|
607
|
+
'.dshet-btn.dshet-btn-save{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));padding:0;border:0;border-radius:50%;background:transparent;color:var(--dshet-ink-soft);filter:none}',
|
|
580
608
|
'.dshet-btn.dshet-btn-save:hover:not(:disabled){background:var(--dshet-hover);filter:none}',
|
|
581
609
|
'.dshet-btn.dshet-btn-save.dshet-btn-confirm{background:var(--dshet-hover);box-shadow:inset 0 0 0 1.5px var(--dshet-accent)}',
|
|
582
|
-
'.dshet-editor .dshet-footer .dshet-btn.dshet-btn-icon{width:28px;height:28px;padding:0;border:0;border-radius:50%;background:transparent;color:#81858c;filter:none}',
|
|
610
|
+
'.dshet-editor .dshet-footer .dshet-btn.dshet-btn-icon{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));padding:0;border:0;border-radius:50%;background:transparent;color:#81858c;filter:none}',
|
|
583
611
|
'.dshet-editor .dshet-footer .dshet-btn.dshet-btn-icon:hover:not(:disabled){background:var(--dshet-hover);color:var(--dshet-ink-soft);filter:none}',
|
|
584
|
-
'.dshet-btn-icon svg{width:
|
|
585
|
-
'.dshet-editor[data-dshet-inplace="1"] .dshet-btn.dshet-btn-save{width:28px;height:28px;padding:0;border:0;border-radius:50%;background:transparent;color:#81858c;filter:none}',
|
|
612
|
+
'.dshet-btn-icon svg{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));display:block;fill:none;stroke:currentColor;stroke-width:1.2;stroke-linecap:round;stroke-linejoin:round}',
|
|
613
|
+
'.dshet-editor[data-dshet-inplace="1"] .dshet-btn.dshet-btn-save{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));padding:0;border:0;border-radius:50%;background:transparent;color:#81858c;filter:none}',
|
|
586
614
|
'.dshet-editor[data-dshet-inplace="1"] .dshet-btn.dshet-btn-save:hover:not(:disabled){background:var(--dshet-hover);filter:none}',
|
|
587
615
|
'.dshet-pick{display:flex;align-items:center;gap:4px;padding:0;font-size:12px;color:var(--dshet-ink-dim)}',
|
|
588
616
|
'.dshet-config{display:flex;flex-direction:column;gap:10px}',
|
|
@@ -3817,6 +3845,8 @@ window.__ModuleLoader__.load({
|
|
|
3817
3845
|
})
|
|
3818
3846
|
box.addEventListener('dragover', (event) => {
|
|
3819
3847
|
event.preventDefault()
|
|
3848
|
+
// 不让事件传到输入框:否则宿主也会把这次拖拽当成它的附件。
|
|
3849
|
+
event.stopPropagation()
|
|
3820
3850
|
box.dataset.dshetDrop = '1'
|
|
3821
3851
|
})
|
|
3822
3852
|
box.addEventListener('dragleave', () => {
|
|
@@ -3824,9 +3854,17 @@ window.__ModuleLoader__.load({
|
|
|
3824
3854
|
})
|
|
3825
3855
|
box.addEventListener('drop', (event) => {
|
|
3826
3856
|
event.preventDefault()
|
|
3857
|
+
event.stopPropagation()
|
|
3827
3858
|
delete box.dataset.dshetDrop
|
|
3828
3859
|
const files = filesFromData(event.dataTransfer)
|
|
3829
3860
|
if (files.length > 0) controller.attachFiles(files)
|
|
3861
|
+
// 宿主的「文件或图片拖动到此处即可添加」遮罩是靠它自己的 document drop
|
|
3862
|
+
// 关闭的;我们把事件拦下来了,就得替它收尾,否则遮罩会一直挂着。
|
|
3863
|
+
try {
|
|
3864
|
+
window.dispatchEvent(new DragEvent('dragend', { bubbles: true }))
|
|
3865
|
+
} catch {
|
|
3866
|
+
/* 老环境没有 DragEvent 就算了 */
|
|
3867
|
+
}
|
|
3830
3868
|
})
|
|
3831
3869
|
}
|
|
3832
3870
|
|
|
@@ -4681,12 +4719,18 @@ window.__ModuleLoader__.load({
|
|
|
4681
4719
|
if (typeof unsubscribe === 'function') unsubscribe()
|
|
4682
4720
|
}
|
|
4683
4721
|
}, [controller])
|
|
4684
|
-
|
|
4685
|
-
|
|
4722
|
+
// 先渲染、后确认:/state 还没回来时也把铅笔画出来(置灰),
|
|
4723
|
+
// 否则宿主和别的插件都在了,只有我们要等一次请求才出现。
|
|
4724
|
+
// 没有 messageId 就无从谈起:这种行不进入口。
|
|
4725
|
+
if (messageId === undefined || messageId === null || messageId === '') return null
|
|
4726
|
+
const loaded = view !== null
|
|
4727
|
+
const entry = loaded ? view.repliesByMessage.get(messageId) : undefined
|
|
4728
|
+
if (loaded && (entry === undefined || entry === null || view.hidden.has(entry.seq))) return null
|
|
4686
4729
|
const label = t === null ? '' : t('action.edit-reply')
|
|
4687
4730
|
const open = (event) => {
|
|
4688
4731
|
event.preventDefault()
|
|
4689
4732
|
event.stopPropagation()
|
|
4733
|
+
if (entry === undefined) return
|
|
4690
4734
|
controller.open({
|
|
4691
4735
|
anchor: event.currentTarget,
|
|
4692
4736
|
seq: entry.seq,
|
|
@@ -4710,6 +4754,7 @@ window.__ModuleLoader__.load({
|
|
|
4710
4754
|
className: 'dshet-action dshet-row-action dshet-reply-action',
|
|
4711
4755
|
'aria-label': label,
|
|
4712
4756
|
title: label,
|
|
4757
|
+
disabled: entry === undefined,
|
|
4713
4758
|
onClick: open,
|
|
4714
4759
|
children: jsx(PencilIcon, {}),
|
|
4715
4760
|
})
|
package/lib/index.js
CHANGED
|
@@ -78,7 +78,7 @@ export const PLUGIN_ID = 'dsh-edit-turn'
|
|
|
78
78
|
export const name = PLUGIN_ID
|
|
79
79
|
|
|
80
80
|
/** Keep in sync with package.json and lib/client.js. */
|
|
81
|
-
export const PLUGIN_VERSION = '0.
|
|
81
|
+
export const PLUGIN_VERSION = '0.6.0'
|
|
82
82
|
|
|
83
83
|
// A ring of the last few requests, answering "did the browser half even ask, and
|
|
84
84
|
// what did it get?" without needing its console. Read-only diagnostics: the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-edit-turn",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Edit any message in DeepSeek Harness in place: a prompt is replaced where it stands; a model reply block (answer text or reasoning) is patched through a plugin record and a message projection, so the turn stays where it is, later turns are untouched and the log grows by one small record. Falls back to the replay splice on hosts without the projection API. The append-only session log is never rewritten.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|