@240xu/dsh-message-ops 0.17.0 → 0.18.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.md +81 -0
- package/package.json +1 -1
- package/src/client.js +192 -27
package/README.md
CHANGED
|
@@ -891,6 +891,87 @@ min fence=10 → seq>=10 全藏 → 4792/4793 全被隐藏 → 正文几乎空
|
|
|
891
891
|
| `src/index.js:336-340` `revertFences` 塌缩复盘 | 「0.9.4 · 修「正文几乎空白」」 |
|
|
892
892
|
| `src/ops-core.js:551-557` 0.5.7 磁盘路径复盘 | 「0.5.7 · 第四层根因:store-miss 会话的磁盘追加路径」 |
|
|
893
893
|
|
|
894
|
+
### 0.18.0 · 行内操作三项修复 + 面板唤起 UI
|
|
895
|
+
|
|
896
|
+
用户反馈(原话):
|
|
897
|
+
|
|
898
|
+
> 「编辑重发的按钮可以和回撤放在同一个地方,就是用一个笔的那个图标」
|
|
899
|
+
> 「引用AI的话…我怎么还得点一下这个类似于复制的按钮,然后这个会话直接跳进输入框,
|
|
900
|
+
> 这UI做的怎么这么诡异?而且这样真的行吗?查点权威资料和官方代码」
|
|
901
|
+
> 「还有就是那个时间的图标,怎么点那个也是回撤啊?」
|
|
902
|
+
> 「消息操作的那个面板的,唤起它的UI显示明显有问题」
|
|
903
|
+
|
|
904
|
+
#### 1 · 行内编辑按钮(铅笔图标)
|
|
905
|
+
|
|
906
|
+
新增 `ensureEditBtn`,与回滚**同一动作行**,顺序 `回滚 → 编辑 → 分叉`
|
|
907
|
+
(破坏性从左到右递减)。图标用官方 `edit-outline` 几何。
|
|
908
|
+
|
|
909
|
+
回填**复用 `refillComposer`** —— 0.17.0 刚清理掉「同语义两套实现」,
|
|
910
|
+
这里绝不能另起一条。
|
|
911
|
+
|
|
912
|
+
#### 2 · 引用改用官方 `insertQuote`
|
|
913
|
+
|
|
914
|
+
**旧实现是错的**(用户直觉对:「这样真的行吗」)。查宿主源码:
|
|
915
|
+
|
|
916
|
+
```js
|
|
917
|
+
// dsh-client-ui-conversation:15369
|
|
918
|
+
insertQuote: (text) => this.insertQuote(text)
|
|
919
|
+
// → draftEditor.insertQuote(text, labels)
|
|
920
|
+
// → $replaceDetectSpanWithNodes({start, end}, [$createQuoteNode(text, labels), Go(" ")])
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
官方插入的是**结构化 QuoteNode**(带删除标签、独立 undo 编辑、自动补空格分隔)。
|
|
924
|
+
|
|
925
|
+
而 0.5.0 的旧实现是:
|
|
926
|
+
|
|
927
|
+
```js
|
|
928
|
+
text.split('\n').map(l => '> ' + l).join('\n') + '\n\n' // ← 手工拼 markdown
|
|
929
|
+
inputActions.insertText(quoted, span) // ← 裸插文本
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
三个问题:
|
|
933
|
+
1. **不是引用** —— 宿主不会渲染成引用块,也没有删除按钮
|
|
934
|
+
2. `captureInsertion()` 返回的是**插入位置快照**,用户在菜单里点完到文本到达之间
|
|
935
|
+
若改过草稿,位置就失效 → 文本插到奇怪的地方
|
|
936
|
+
3. 手工拼的 `> ` 会和已有内容粘连
|
|
937
|
+
|
|
938
|
+
已改为直接调 `inputActions.insertQuote(text)`。
|
|
939
|
+
|
|
940
|
+
#### 3 · 时间文本与回滚按钮的误触
|
|
941
|
+
|
|
942
|
+
用户说「点那个时间图标也是回撤」。核实后**不是绑定错误**
|
|
943
|
+
(插件代码里没有任何 `data-clock` / `timeStart` 的事件绑定),
|
|
944
|
+
而是**视觉与命中区相邻**:
|
|
945
|
+
|
|
946
|
+
```
|
|
947
|
+
宿主 DOM: div.actions[data-clock="start"] > span.timeStart + button(copy) + extraActions
|
|
948
|
+
↑ 时间文本 padding-right:12px ↑ 8px gap
|
|
949
|
+
我们: appendChild → [回滚][编辑][分叉] 紧跟在复制按钮后面
|
|
950
|
+
```
|
|
951
|
+
|
|
952
|
+
触屏上 28px 按钮的命中区紧贴时间文本,点时间很容易滑到回滚上。
|
|
953
|
+
|
|
954
|
+
修法:给插件按钮组加**视觉分隔**(首按钮左侧 10px 间距 + 1px 竖线),
|
|
955
|
+
把「消息元信息(时间/复制)」与「破坏性操作」在视觉和命中上分成两组。
|
|
956
|
+
|
|
957
|
+
#### 4 · 面板唤起 UI
|
|
958
|
+
|
|
959
|
+
**唤起按钮用的是分叉图标** —— 一个「消息操作」面板长着「分叉」的脸,
|
|
960
|
+
用户会以为点它是 fork。这就是「唤起它的 UI 显示明显有问题」。
|
|
961
|
+
|
|
962
|
+
改为官方 `list-pen-outline`(列表 + 笔)—— 同时表达「浏览消息列表」与「编辑」,
|
|
963
|
+
正是这个面板的用途(用户确认它可以当作「编辑 + AI 对话上下文面板」)。
|
|
964
|
+
|
|
965
|
+
圆角从写死的 `6` 改为 `4`,与行内按钮统一。
|
|
966
|
+
|
|
967
|
+
#### 主题自适应审计
|
|
968
|
+
|
|
969
|
+
逐行检查面板 CSS:**没有裸 hex**,所有颜色都是
|
|
970
|
+
`var(--dsw-alias-*, <浅色 fallback>)` 形式 → 深色模式自动跟随宿主 token。
|
|
971
|
+
新增测试锁定这条(防止以后有人图省事写死颜色)。
|
|
972
|
+
|
|
973
|
+
新增 `test/row-actions-v2.test.js`(11 条)。测试 309(305 pass / 4 skip)。
|
|
974
|
+
|
|
894
975
|
### 0.17.0 · 动作入口冲突清理
|
|
895
976
|
|
|
896
977
|
用户问:「那个编辑并重发是你的吗?你看看有多少是功能冲突的」
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -133,6 +133,10 @@ window.__ModuleLoader__.load({
|
|
|
133
133
|
'op.branchDesc': '把此条之前的对话复制到新会话,并把此条原文放回新会话输入框(原会话不变,非破坏操作)。',
|
|
134
134
|
'slot.revert': '回滚到此条',
|
|
135
135
|
'slot.revertUnmatched': '在日志里定位不到这条消息的 seq(通常是模型写的摘要与渲染文本偏差过大)——请改用「消息操作」对话框。',
|
|
136
|
+
'slot.edit': '编辑(复制原文到输入框)',
|
|
137
|
+
'slot.editHint': '复制此条原文到输入框;发出后新增一条消息,不修改原消息',
|
|
138
|
+
'slot.editDone': '原文已复制到输入框',
|
|
139
|
+
'slot.editNoText': '这条消息没有可复制的文本',
|
|
136
140
|
'slot.fork': '从此条分叉',
|
|
137
141
|
'slot.forkHint': '复制此条之前的对话到新会话,并把此条原文放回新会话输入框',
|
|
138
142
|
'slot.forkDone': '已分叉:新会话 {id}',
|
|
@@ -264,6 +268,10 @@ window.__ModuleLoader__.load({
|
|
|
264
268
|
'slot.revert': 'Revert to here',
|
|
265
269
|
'slot.revertUnmatched':
|
|
266
270
|
'Cannot locate this message seq in the log (usually the model-written summary drifted too far from the rendered text) — use the Message ops dialog instead.',
|
|
271
|
+
'slot.edit': 'Edit (copy text to composer)',
|
|
272
|
+
'slot.editHint': 'Copies this text into the composer; sending adds a new message without modifying the original',
|
|
273
|
+
'slot.editDone': 'Original text copied to the composer',
|
|
274
|
+
'slot.editNoText': 'This message has no text to copy',
|
|
267
275
|
'slot.fork': 'Branch from here',
|
|
268
276
|
'slot.forkHint': 'Copies the conversation above this message into a new session and puts this message back in the new composer',
|
|
269
277
|
'slot.forkDone': 'Branched: new session {id}',
|
|
@@ -428,7 +436,7 @@ window.__ModuleLoader__.load({
|
|
|
428
436
|
height: 28,
|
|
429
437
|
padding: 0,
|
|
430
438
|
border: 'none',
|
|
431
|
-
borderRadius:
|
|
439
|
+
borderRadius: 4,
|
|
432
440
|
background: 'transparent',
|
|
433
441
|
color: 'var(--dsw-alias-label-tertiary, #8a8a8e)',
|
|
434
442
|
cursor: 'pointer',
|
|
@@ -552,6 +560,25 @@ window.__ModuleLoader__.load({
|
|
|
552
560
|
)
|
|
553
561
|
}
|
|
554
562
|
|
|
563
|
+
/**
|
|
564
|
+
* 面板唤起按钮的图标:官方 `list-pen-outline`(列表 + 笔)。
|
|
565
|
+
*
|
|
566
|
+
* 0.18.0 前的 bug:这里用的是**分叉图标**(IconBranch)—— 一个"消息操作"
|
|
567
|
+
* 面板却长着"分叉"的脸,用户会以为点它是 fork。语义错位就是用户说的
|
|
568
|
+
* 「唤起它的 UI 显示明显有问题」。
|
|
569
|
+
*
|
|
570
|
+
* 「列表 + 笔」同时表达了两件事:浏览消息列表、编辑内容 —— 正是这个面板
|
|
571
|
+
* 的用途(用户也确认它可以当作"编辑 + AI 对话上下文面板")。
|
|
572
|
+
*
|
|
573
|
+
* 几何取自宿主 icon sprite 的 `dsw-icon-list-pen-outline-regular`
|
|
574
|
+
* (16 viewBox,描边 1.2,与宿主动作行图标同一套视觉)。
|
|
575
|
+
*/
|
|
576
|
+
/**
|
|
577
|
+
* 分叉图标组件。0.18.0 起**不再用于面板唤起按钮**(那曾造成语义错位:
|
|
578
|
+
* "消息操作"面板长着"分叉"的脸),但保留它是因为 `branchIconMarkup`
|
|
579
|
+
* 与它共用 `BRANCH_PATH` 常量 —— `test/icon-render.test.js` 锁定了这条同源约束,
|
|
580
|
+
* 防止两处各画一套分叉几何而慢慢漂移。
|
|
581
|
+
*/
|
|
555
582
|
function BranchIcon() {
|
|
556
583
|
return React.createElement(
|
|
557
584
|
'svg',
|
|
@@ -575,6 +602,31 @@ window.__ModuleLoader__.load({
|
|
|
575
602
|
)
|
|
576
603
|
}
|
|
577
604
|
|
|
605
|
+
function OpsPanelIcon() {
|
|
606
|
+
return React.createElement(
|
|
607
|
+
'svg',
|
|
608
|
+
{
|
|
609
|
+
width: 16,
|
|
610
|
+
height: 16,
|
|
611
|
+
viewBox: '0 0 16 16',
|
|
612
|
+
fill: 'none',
|
|
613
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
614
|
+
'aria-hidden': 'true',
|
|
615
|
+
focusable: 'false',
|
|
616
|
+
},
|
|
617
|
+
React.createElement('path', { d: 'M4.9375 5.90295H11.0625', stroke: 'currentColor', strokeWidth: 1.2, strokeLinecap: 'round' }),
|
|
618
|
+
React.createElement('path', { d: 'M4.9375 9.02991H8.27841', stroke: 'currentColor', strokeWidth: 1.2, strokeLinecap: 'round' }),
|
|
619
|
+
React.createElement('path', {
|
|
620
|
+
d: 'M12.5 1.32617C13.3039 1.32617 14 1.95171 14 2.77637V7.61328L13 8.68164V2.77637C13 2.55186 12.8007 2.32617 12.5 2.32617H3.5C3.1993 2.32617 3 2.55186 3 2.77637V13.2246C3.00044 13.4489 3.19963 13.6738 3.5 13.6738H8.32812L7.39258 14.6738H3.5C2.69637 14.6738 2.00042 14.0489 2 13.2246V2.77637C2 1.95171 2.69613 1.32617 3.5 1.32617H12.5Z',
|
|
621
|
+
fill: 'currentColor',
|
|
622
|
+
}),
|
|
623
|
+
React.createElement('path', {
|
|
624
|
+
d: 'M8.97212 14.3693C9.17511 14.5723 9.37811 14.7753 9.5811 14.9783C9.67012 14.8953 9.75914 14.8123 9.84815 14.7293C11.4505 13.2352 13.0528 11.7411 14.6551 10.247C14.7441 10.164 14.8331 10.081 14.9221 9.99803C14.5989 9.6748 14.2756 9.35157 13.9524 9.02834C13.8694 9.11736 13.7864 9.20637 13.7034 9.29539C12.2093 10.8977 10.7152 12.5 9.22113 14.1023C9.13813 14.1913 9.05513 14.2803 8.97212 14.3693Z',
|
|
625
|
+
fill: 'currentColor',
|
|
626
|
+
}),
|
|
627
|
+
)
|
|
628
|
+
}
|
|
629
|
+
|
|
578
630
|
// --- 共享对话框 -------------------------------------------------------------
|
|
579
631
|
// 模块级缓存最近一次 target,事件驱动打开。
|
|
580
632
|
const MAX_RENDER = 200
|
|
@@ -2663,7 +2715,7 @@ window.__ModuleLoader__.load({
|
|
|
2663
2715
|
style: btnStyle,
|
|
2664
2716
|
onClick: openDialog,
|
|
2665
2717
|
},
|
|
2666
|
-
React.createElement(
|
|
2718
|
+
React.createElement(OpsPanelIcon),
|
|
2667
2719
|
)
|
|
2668
2720
|
}
|
|
2669
2721
|
|
|
@@ -2857,36 +2909,56 @@ window.__ModuleLoader__.load({
|
|
|
2857
2909
|
.finally(() => setBusy(null))
|
|
2858
2910
|
}
|
|
2859
2911
|
|
|
2860
|
-
// 0.
|
|
2912
|
+
// ── 0.18.0:引用改用官方 insertQuote(结构化 QuoteNode)──────────────────
|
|
2913
|
+
//
|
|
2914
|
+
// 旧实现(0.5.0)用 `captureInsertion` + `insertText` 手工拼 `> ` markdown:
|
|
2915
|
+
//
|
|
2916
|
+
// text.split('\n').map(l => '> ' + l).join('\n') + '\n\n'
|
|
2917
|
+
//
|
|
2918
|
+
// 问题(用户实测反馈「这 UI 做的怎么这么诡异」):
|
|
2919
|
+
// 1. **不是引用**,是一段普通 markdown 文本 —— 宿主不会渲染成引用块,
|
|
2920
|
+
// 也不会给删除按钮、不进结构化编辑语义;
|
|
2921
|
+
// 2. `captureInsertion` 返回的是**插入位置快照**,用户在菜单里点完到
|
|
2922
|
+
// 文本到达之间若改过草稿,位置就失效,文本会插到奇怪的地方;
|
|
2923
|
+
// 3. 手工拼的 `> ` 会和用户已有内容粘连(无空行分隔时)。
|
|
2924
|
+
//
|
|
2925
|
+
// 宿主其实提供了官方能力(dsh-client-ui-conversation:15369):
|
|
2926
|
+
// insertQuote: (text) => this.insertQuote(text)
|
|
2927
|
+
// 它内部走 `draftEditor.insertQuote(text, labels)` →
|
|
2928
|
+
// `$replaceDetectSpanWithNodes([$createQuoteNode(text, labels), Go(" ")])`
|
|
2929
|
+
// 即:在当前光标处插入一个**真正的 QuoteNode**(带 remove 标签、独立 undo),
|
|
2930
|
+
// 并自动补一个空格分隔。这才是"规范"的引用。
|
|
2861
2931
|
const runQuote = () => {
|
|
2932
|
+
const finish = ok => notifyDone(ok ? t('quote.done') : t('quote.unavailable'), ok ? 'ok' : 'warn')
|
|
2862
2933
|
try {
|
|
2863
|
-
if (!inputActions || typeof inputActions.
|
|
2864
|
-
|
|
2934
|
+
if (!inputActions || typeof inputActions.insertQuote !== 'function') {
|
|
2935
|
+
finish(false)
|
|
2865
2936
|
return
|
|
2866
2937
|
}
|
|
2867
|
-
const
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
notifyDone(t('quote.unavailable'), 'warn')
|
|
2938
|
+
const put = text => {
|
|
2939
|
+
if (typeof text !== 'string' || text.trim() === '') {
|
|
2940
|
+
finish(false)
|
|
2871
2941
|
return
|
|
2872
2942
|
}
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2943
|
+
// insertQuote 的返回值是 boolean(是否真的插入了)
|
|
2944
|
+
let ok = false
|
|
2945
|
+
try {
|
|
2946
|
+
ok = inputActions.insertQuote(text.replace(/\r\n?/g, '\n')) !== false
|
|
2947
|
+
} catch (e) {
|
|
2948
|
+
console.warn('[message-ops] insertQuote failed:', e)
|
|
2949
|
+
ok = false
|
|
2950
|
+
}
|
|
2951
|
+
finish(ok)
|
|
2880
2952
|
}
|
|
2881
|
-
// assistant 消息 fullText 恒 null(列表不携带)→ 按 seq
|
|
2953
|
+
// assistant 消息 fullText 恒 null(列表不携带)→ 按 seq 取单条全文
|
|
2882
2954
|
if (fullText != null && fullText !== '') {
|
|
2883
|
-
|
|
2955
|
+
put(fullText)
|
|
2884
2956
|
return
|
|
2885
2957
|
}
|
|
2886
2958
|
fetch('/api/message-ops/text?sessionId=' + encodeURIComponent(sessionId) + '&seq=' + encodeURIComponent(seq))
|
|
2887
2959
|
.then(r => (r.ok ? r.json() : null))
|
|
2888
|
-
.then(d =>
|
|
2889
|
-
.catch(() =>
|
|
2960
|
+
.then(d => put(d && d.ok && typeof d.text === 'string' ? d.text : null))
|
|
2961
|
+
.catch(() => put(null))
|
|
2890
2962
|
} catch (e) {
|
|
2891
2963
|
notifyDone(t('errorPrefix') + (e && e.message ? e.message : String(e)), 'error')
|
|
2892
2964
|
}
|
|
@@ -3617,10 +3689,16 @@ window.__ModuleLoader__.load({
|
|
|
3617
3689
|
// 配不上(data-mops-unmatched)→ 禁用 + 说明原因,绝不留装饰按钮。
|
|
3618
3690
|
var syncEnabled = (block, btn) => {
|
|
3619
3691
|
if (!btn) return
|
|
3692
|
+
// 0.18.0:三种按钮各有自己的提示文案(新增编辑按钮后不能都写 revert)
|
|
3693
|
+
const hintKey = btn.classList.contains('mopsUserFork')
|
|
3694
|
+
? 'slot.forkHint'
|
|
3695
|
+
: btn.classList.contains('mopsUserEdit')
|
|
3696
|
+
? 'slot.editHint'
|
|
3697
|
+
: 'slot.revert'
|
|
3620
3698
|
const ok = block.getAttribute('data-mops-seq')
|
|
3621
3699
|
if (ok) {
|
|
3622
3700
|
btn.disabled = false
|
|
3623
|
-
btn.title = __t(
|
|
3701
|
+
btn.title = __t(hintKey)
|
|
3624
3702
|
btn.removeAttribute('data-mops-unmatched')
|
|
3625
3703
|
} else {
|
|
3626
3704
|
btn.disabled = true
|
|
@@ -3631,7 +3709,7 @@ window.__ModuleLoader__.load({
|
|
|
3631
3709
|
/** 块内全部插件按钮一起同步(回滚 / 分叉同一动作行)。 */
|
|
3632
3710
|
var syncBlockButtons = block => {
|
|
3633
3711
|
if (!block || !block.querySelectorAll) return
|
|
3634
|
-
for (const b of block.querySelectorAll('.mopsUserRevert, .mopsUserFork')) syncEnabled(block, b)
|
|
3712
|
+
for (const b of block.querySelectorAll('.mopsUserRevert, .mopsUserEdit, .mopsUserFork')) syncEnabled(block, b)
|
|
3635
3713
|
}
|
|
3636
3714
|
var assignSeqs = (sid, cache, anchors) => {
|
|
3637
3715
|
const idx = cache && cache.idx
|
|
@@ -3842,6 +3920,81 @@ window.__ModuleLoader__.load({
|
|
|
3842
3920
|
return btn
|
|
3843
3921
|
}
|
|
3844
3922
|
|
|
3923
|
+
/**
|
|
3924
|
+
* 0.18.0 编辑按钮:与回滚**同一动作行**,铅笔图标。
|
|
3925
|
+
*
|
|
3926
|
+
* 语义 = 把该条原文放回输入框(不遮蔽后续、不修改原消息)。发出后会新增
|
|
3927
|
+
* 一条消息 —— 与面板里的「复制到输入框」是同一件事,两条入口共用
|
|
3928
|
+
* `refillToComposer` 实现,避免又出现"同语义两套实现"。
|
|
3929
|
+
*
|
|
3930
|
+
* 图标取官方 `edit-outline`(宿主 icon sprite 里的 dsw-icon-edit-outline-regular)。
|
|
3931
|
+
*/
|
|
3932
|
+
var ensureEditBtn = block => {
|
|
3933
|
+
let host = block.querySelector('[class*="xzv4MW_actions"]')
|
|
3934
|
+
if (!host) {
|
|
3935
|
+
host = document.createElement('div')
|
|
3936
|
+
host.className = 'mopsUserActionsRow'
|
|
3937
|
+
block.appendChild(host)
|
|
3938
|
+
}
|
|
3939
|
+
const existing = host.querySelector('.mopsUserEdit')
|
|
3940
|
+
if (existing) return existing
|
|
3941
|
+
const btn = document.createElement('button')
|
|
3942
|
+
btn.type = 'button'
|
|
3943
|
+
btn.className = 'mopsUserEdit'
|
|
3944
|
+
btn.title = __t('slot.edit')
|
|
3945
|
+
btn.setAttribute('aria-label', __t('slot.edit'))
|
|
3946
|
+
// 铅笔:官方 edit-outline 的几何(16 viewBox)
|
|
3947
|
+
btn.innerHTML =
|
|
3948
|
+
'<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="none">' +
|
|
3949
|
+
'<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M11.9 1.4a1.6 1.6 0 0 1 2.3 0l.4.4a1.6 1.6 0 0 1 0 2.3l-1 1-2.7-2.7 1-1ZM9.8 3.5l2.7 2.7-6.9 6.9a1 1 0 0 1-.4.2l-2.6.7a.5.5 0 0 1-.6-.6l.7-2.6a1 1 0 0 1 .2-.4l6.9-6.9Z"/>' +
|
|
3950
|
+
'</svg>'
|
|
3951
|
+
btn.addEventListener('click', e => {
|
|
3952
|
+
e.preventDefault()
|
|
3953
|
+
e.stopPropagation()
|
|
3954
|
+
if (btn.disabled) return
|
|
3955
|
+
runUserEdit(btn, block)
|
|
3956
|
+
})
|
|
3957
|
+
host.appendChild(btn)
|
|
3958
|
+
syncEnabled(block, btn)
|
|
3959
|
+
return btn
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3962
|
+
/**
|
|
3963
|
+
* 0.18.0 行内编辑:把该条原文放回输入框。
|
|
3964
|
+
*
|
|
3965
|
+
* 直接复用 `refillComposer`(回滚路径用的同一实现)——
|
|
3966
|
+
* 0.17.0 刚把"同语义两套实现"问题清理掉,绝不能在这里再引入一条。
|
|
3967
|
+
*/
|
|
3968
|
+
var runUserEdit = (btn, block) => {
|
|
3969
|
+
const sid = __currentSessionId
|
|
3970
|
+
if (!sid) return
|
|
3971
|
+
const seq = Number(block.getAttribute('data-mops-seq'))
|
|
3972
|
+
if (!Number.isFinite(seq)) {
|
|
3973
|
+
notifyDone(__t('errorPrefix') + __t('slot.revertUnmatched'), 'error')
|
|
3974
|
+
return
|
|
3975
|
+
}
|
|
3976
|
+
btn.disabled = true
|
|
3977
|
+
Promise.resolve()
|
|
3978
|
+
.then(() => ensureAssign(sid))
|
|
3979
|
+
.then(() => fetchRows(sid))
|
|
3980
|
+
.then(cache => {
|
|
3981
|
+
const rows = cache && cache.rows
|
|
3982
|
+
const row = rows && rows.find(r => r.seq === seq)
|
|
3983
|
+
if (!row) {
|
|
3984
|
+
notifyDone(__t('errorPrefix') + __t('slot.revertUnmatched'), 'error')
|
|
3985
|
+
return
|
|
3986
|
+
}
|
|
3987
|
+
const ok = refillComposer(sid, seq)
|
|
3988
|
+
notifyDone(ok ? __t('slot.editDone') : __t('slot.editNoText'), ok ? 'ok' : 'warn')
|
|
3989
|
+
})
|
|
3990
|
+
.catch(reason => {
|
|
3991
|
+
notifyDone(__t('errorPrefix') + (reason && reason.message ? reason.message : String(reason)), 'error')
|
|
3992
|
+
})
|
|
3993
|
+
.finally(() => {
|
|
3994
|
+
btn.disabled = false
|
|
3995
|
+
})
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3845
3998
|
/** 0.12.0 分叉按钮:与回滚按钮**同一动作行**(opencode 把 fork 放在 copy/undo 同组)。 */
|
|
3846
3999
|
var ensureForkBtn = block => {
|
|
3847
4000
|
let host = block.querySelector('[class*="xzv4MW_actions"]')
|
|
@@ -3873,6 +4026,9 @@ window.__ModuleLoader__.load({
|
|
|
3873
4026
|
// 两个按钮的顺序由 DOM 顺序决定:回滚在前(破坏性更高),分叉在后(非破坏)。
|
|
3874
4027
|
var ensureUserActions = block => {
|
|
3875
4028
|
ensureBtn(block)
|
|
4029
|
+
// 0.18.0:编辑按钮与回滚**同一动作行**(用户要求:和回撤放同一个地方)。
|
|
4030
|
+
// 顺序 = 回滚 → 编辑 → 分叉,破坏性从左到右递减。
|
|
4031
|
+
ensureEditBtn(block)
|
|
3876
4032
|
ensureForkBtn(block)
|
|
3877
4033
|
}
|
|
3878
4034
|
// 0.9.7(P0-2 读合并):把 150/700/1600ms 三档并成**一次**真网络请求,
|
|
@@ -4062,11 +4218,20 @@ window.__ModuleLoader__.load({
|
|
|
4062
4218
|
// (宿主 .xzv4MW_actions 已定 height:28px,改小会撑裂行高)。
|
|
4063
4219
|
// · 无淡入动画(opencode 源码注释明写 "Hover actions show and hide
|
|
4064
4220
|
// at once, without a fade")—— 显隐完全交给宿主 [data-actions-reveal]。
|
|
4065
|
-
'.mopsUserRevert,.mopsUserFork{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-tertiary,#808080);cursor:pointer;padding:0;flex:none}',
|
|
4066
|
-
'.mopsUserRevert svg,.mopsUserFork svg{width:14px;height:14px;display:block}',
|
|
4067
|
-
'.mopsUserRevert:hover,.mopsUserFork:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.12));color:var(--dsw-alias-label-secondary,#6b6b70)}',
|
|
4068
|
-
'.mopsUserRevert:disabled,.mopsUserFork:disabled{opacity:.4;cursor:default;background:transparent}',
|
|
4069
|
-
'.mopsUserRevert:focus-visible,.mopsUserFork:focus-visible{outline:2px solid var(--dsw-alias-border-l2,#b8b8b8);outline-offset:1px}',
|
|
4221
|
+
'.mopsUserRevert,.mopsUserEdit,.mopsUserFork{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-tertiary,#808080);cursor:pointer;padding:0;flex:none}',
|
|
4222
|
+
'.mopsUserRevert svg,.mopsUserEdit svg,.mopsUserFork svg{width:14px;height:14px;display:block}',
|
|
4223
|
+
'.mopsUserRevert:hover,.mopsUserEdit:hover,.mopsUserFork:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.12));color:var(--dsw-alias-label-secondary,#6b6b70)}',
|
|
4224
|
+
'.mopsUserRevert:disabled,.mopsUserEdit:disabled,.mopsUserFork:disabled{opacity:.4;cursor:default;background:transparent}',
|
|
4225
|
+
'.mopsUserRevert:focus-visible,.mopsUserEdit:focus-visible,.mopsUserFork:focus-visible{outline:2px solid var(--dsw-alias-border-l2,#b8b8b8);outline-offset:1px}',
|
|
4226
|
+
// 0.18.0:用户反馈「点时间图标也会回撤」——根因不是绑定错误,而是
|
|
4227
|
+
// 我们的按钮被 appendChild 到宿主 .actions 行末尾,而该行在
|
|
4228
|
+
// data-clock="start"(用户消息)时第一个子元素就是**时间文本**:
|
|
4229
|
+
// [时间文本 padding-right:12px] 8px [复制] 8px [回滚][编辑][分叉]
|
|
4230
|
+
// 触屏上 28px 按钮的命中区紧贴时间文本,点时间很容易滑到回滚上。
|
|
4231
|
+
// 修:给插件按钮组加一道**视觉与命中分隔**(左侧细线 + 额外间距),
|
|
4232
|
+
// 让"消息元信息(时间/复制)"和"破坏性操作"在视觉上分成两组。
|
|
4233
|
+
'.mopsUserRevert:first-of-type{margin-left:10px;position:relative}',
|
|
4234
|
+
'.mopsUserRevert:first-of-type::before{content:"";position:absolute;left:-9px;top:50%;transform:translateY(-50%);width:1px;height:14px;background:var(--dsw-alias-border-l1,rgba(128,128,128,.28));pointer-events:none}',
|
|
4070
4235
|
'.mopsUserActionsRow{height:28px;display:flex;align-items:center;gap:8px;margin-left:-6px}',
|
|
4071
4236
|
'@media (hover:none){.mopsUserActionsRow{opacity:1}}',
|
|
4072
4237
|
].join('')
|