@240xu/dsh-message-ops 0.11.6 → 0.11.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.js +63 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@240xu/dsh-message-ops",
3
- "version": "0.11.6",
3
+ "version": "0.11.8",
4
4
  "description": "DSH web 插件:消息级回滚 / 删除 / 恢复(补 dsh 官方没有的部分)。分支与导出用官方内置能力。",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/client.js CHANGED
@@ -429,9 +429,20 @@ window.__ModuleLoader__.load({
429
429
  // `v3.44` / `V6.28` / `v.85` 这类**零宽度线段**。若用 fill 渲染,线段没有
430
430
  // 面积 → 整条分支线消失,只剩几个孤立色块(0.11.x 实测症状:
431
431
  // 「那个 svg 渲染有问题」)。必须 stroke + round cap/join。
432
- const BRANCH_PATHS = [
433
- 'M5 2.5a2 2 0 1 1-.9 3.78v3.44a2 2 0 1 1-1.2 0V6.28A2 2 0 1 1 5 2.5Zm0 1.2a.8.8 0 1 0 0 1.6.8.8 0 0 0 0-1.6ZM3.5 11.5a.8.8 0 1 0 1.6 0 .8.8 0 0 0-1.6 0ZM12.5 2.5a2 2 0 0 1 .6 3.9v.85c0 1.9-1.54 3.44-3.44 3.44H8.03a2 2 0 1 1 0-1.2h1.63a2.24 2.24 0 0 0 2.24-2.24V6.4a2 2 0 0 1 .6-3.9Zm0 1.2a.8.8 0 1 0 0 1.6.8.8 0 0 0 0-1.6Z',
434
- ]
432
+ // 唯一数据源:所有图标入口(React 组件 / innerHTML 字符串)都从这里取,
433
+ // 以免再次出现「一处改名、另一处仍用旧名 → d="undefined"」的回归。
434
+ const BRANCH_PATH = 'M5 2.5a2 2 0 1 1-.9 3.78v3.44a2 2 0 1 1-1.2 0V6.28A2 2 0 1 1 5 2.5Zm0 1.2a.8.8 0 1 0 0 1.6.8.8 0 0 0 0-1.6ZM3.5 11.5a.8.8 0 1 0 1.6 0 .8.8 0 0 0-1.6 0ZM12.5 2.5a2 2 0 0 1 .6 3.9v.85c0 1.9-1.54 3.44-3.44 3.44H8.03a2 2 0 1 1 0-1.2h1.63a2.24 2.24 0 0 0 2.24-2.24V6.4a2 2 0 0 1 .6-3.9Zm0 1.2a.8.8 0 1 0 0 1.6.8.8 0 0 0 0-1.6Z'
435
+ const BRANCH_STROKE = 1.4
436
+
437
+ /** 生成分支图标的 SVG 标记(供 innerHTML 场景复用)。 */
438
+ function branchIconMarkup(size) {
439
+ const px = size || 16
440
+ return '<svg width="' + px + '" height="' + px + '" viewBox="0 0 16 16" fill="none"'
441
+ + ' xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"'
442
+ + ' style="flex:none"><path d="' + BRANCH_PATH + '" fill="none"'
443
+ + ' stroke="currentColor" stroke-width="' + BRANCH_STROKE + '"'
444
+ + ' stroke-linecap="round" stroke-linejoin="round"/></svg>'
445
+ }
435
446
 
436
447
  function BranchIcon() {
437
448
  return React.createElement('svg', {
@@ -439,8 +450,8 @@ window.__ModuleLoader__.load({
439
450
  xmlns: 'http://www.w3.org/2000/svg',
440
451
  'aria-hidden': 'true', focusable: 'false',
441
452
  }, React.createElement('path', {
442
- d: BRANCH_PATHS[0],
443
- stroke: 'currentColor', strokeWidth: 1.4,
453
+ d: BRANCH_PATH,
454
+ stroke: 'currentColor', strokeWidth: BRANCH_STROKE,
444
455
  strokeLinecap: 'round', strokeLinejoin: 'round',
445
456
  fill: 'none',
446
457
  }))
@@ -1086,15 +1097,53 @@ window.__ModuleLoader__.load({
1086
1097
  else if (panelRef.current) panelRef.current.focus()
1087
1098
  }, 0)
1088
1099
  const scrim = scrimRef.current
1089
- const parent = scrim && scrim.parentElement
1090
1100
  const hidden = []
1091
- if (parent) {
1092
- for (const child of Array.from(parent.children)) {
1093
- if (child === scrim || child.tagName === 'SCRIPT' || child.tagName === 'STYLE') continue
1101
+ // 0.11.8:槽位会把 scrim 挂进一个**只有 scrim 自己**的独立容器,
1102
+ // 于是「遍历 parent.children」永远遍历不到真实背景 —— inert 形同虚设
1103
+ // (实测:inert=false,Tab 能跑到背后的会话列表,读屏也读得到)。
1104
+ // 正确做法是从宿主挂载点(body 直接子节点)出发,把**包含 scrim 的那条
1105
+ // 祖先链之外**的兄弟节点全部隔离;祖先链本身不能 inert(会连面板一起废掉)。
1106
+ if (scrim && document.body) {
1107
+ const chain = new Set()
1108
+ for (let el = scrim; el && el !== document.body; el = el.parentElement) chain.add(el)
1109
+ for (const child of Array.from(document.body.children)) {
1110
+ if (chain.has(child)) continue
1111
+ if (child.tagName === 'SCRIPT' || child.tagName === 'STYLE' || child.tagName === 'LINK') continue
1094
1112
  hidden.push({ child, inert: child.hasAttribute('inert'), aria: child.getAttribute('aria-hidden') })
1095
1113
  child.setAttribute('inert', '')
1096
1114
  child.setAttribute('aria-hidden', 'true')
1097
1115
  }
1116
+ // 祖先链上的每一层:把**除当前链节点以外**的兄弟也隔离掉。
1117
+ // 典型结构 body > #root > ... > 槽位容器 > scrim,中途每层都可能带界面。
1118
+ for (const el of chain) {
1119
+ const parent = el.parentElement
1120
+ if (!parent || parent === document.body) continue
1121
+ for (const sib of Array.from(parent.children)) {
1122
+ if (sib === el || chain.has(sib)) continue
1123
+ if (sib.tagName === 'SCRIPT' || sib.tagName === 'STYLE' || sib.tagName === 'LINK') continue
1124
+ hidden.push({ child: sib, inert: sib.hasAttribute('inert'), aria: sib.getAttribute('aria-hidden') })
1125
+ sib.setAttribute('inert', '')
1126
+ sib.setAttribute('aria-hidden', 'true')
1127
+ }
1128
+ }
1129
+ }
1130
+ // 居中模态必须锁背景滚动:否则滚轮/触屏拖拽会把背后的会话列表滚走,
1131
+ // 关闭后视口停在别处。用 overflow:hidden 而非 position:fixed,
1132
+ // 后者会丢失滚动位置。保留原有内联值以便精确还原。
1133
+ const body = document.body
1134
+ const prevOverflow = body && body.style ? body.style.overflow : ''
1135
+ const prevPaddingRight = body && body.style ? body.style.paddingRight : ''
1136
+ let scrollbarW = 0
1137
+ try {
1138
+ scrollbarW = window.innerWidth - document.documentElement.clientWidth
1139
+ } catch { /* non-browser */ }
1140
+ if (body && body.style) {
1141
+ body.style.overflow = 'hidden'
1142
+ // 为被隐藏的经典滚动条补回等宽内边距,避免整页横向跳动。
1143
+ if (scrollbarW > 0) {
1144
+ const base = Number.parseFloat(getComputedStyle(body).paddingRight) || 0
1145
+ body.style.paddingRight = (base + scrollbarW) + 'px'
1146
+ }
1098
1147
  }
1099
1148
  return () => {
1100
1149
  clearTimeout(timer)
@@ -1103,6 +1152,10 @@ window.__ModuleLoader__.load({
1103
1152
  if (item.aria === null) item.child.removeAttribute('aria-hidden')
1104
1153
  else item.child.setAttribute('aria-hidden', item.aria)
1105
1154
  }
1155
+ if (body && body.style) {
1156
+ body.style.overflow = prevOverflow
1157
+ body.style.paddingRight = prevPaddingRight
1158
+ }
1106
1159
  if (openRef.current) return
1107
1160
  const trigger = triggerRef.current
1108
1161
  triggerRef.current = null
@@ -2732,7 +2785,7 @@ window.__ModuleLoader__.load({
2732
2785
  'font:inherit', 'font-size:13px', 'line-height:20px',
2733
2786
  'text-align:left', 'border-radius:6px', 'cursor:pointer',
2734
2787
  ].join(';')
2735
- item.innerHTML = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" style="flex:none"><path d="' + BRANCH_PATH + '" fill="currentColor"/></svg><span></span>'
2788
+ item.innerHTML = branchIconMarkup(16) + '<span></span>'
2736
2789
  item.querySelector('span').textContent = __t('menu.ops')
2737
2790
  item.addEventListener('mouseenter', function () {
2738
2791
  item.style.background = 'var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.14))'