@yfwu2020/dsh-selection-explain 0.4.0 → 0.7.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 +15 -2
- package/lib/client.js +842 -26
- package/lib/index.js +88 -0
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/gen-star-path.mjs +71 -0
- package/scripts/smoke-panel.mjs +757 -1
- package/scripts/test-client.mjs +28 -2
- package/src/client/index.js +842 -26
- package/src/index.ts +92 -0
package/scripts/test-client.mjs
CHANGED
|
@@ -1044,11 +1044,16 @@ const textEl = new FakeEl('span')
|
|
|
1044
1044
|
textEl._text = 'Dev: the migration ran long, so we ship Wednesday. PM: fine, freeze features.'
|
|
1045
1045
|
container.appendChild(textEl)
|
|
1046
1046
|
body.appendChild(container)
|
|
1047
|
+
/** 选区桩:记下 removeAllRanges 有没有被调用(点「解读」后要把本文档选区收掉)。 */
|
|
1048
|
+
const clearedSelections = { count: 0 }
|
|
1047
1049
|
const selection = {
|
|
1048
1050
|
isCollapsed: false,
|
|
1049
1051
|
rangeCount: 1,
|
|
1050
1052
|
toString: () => 'the migration ran long',
|
|
1051
1053
|
getRangeAt: () => documentStub.createRange(),
|
|
1054
|
+
removeAllRanges() {
|
|
1055
|
+
clearedSelections.count += 1
|
|
1056
|
+
},
|
|
1052
1057
|
}
|
|
1053
1058
|
windowStub.getSelection = () => selection
|
|
1054
1059
|
documentStub.dispatch('mouseup', { target: body })
|
|
@@ -1092,6 +1097,17 @@ const chatLog = Array.from(walk(panel)).find((node) => node.className === 'dsh-s
|
|
|
1092
1097
|
const askRow = Array.from(walk(panel)).find((node) => node.className === 'dsh-sel-ask')
|
|
1093
1098
|
assert('弹窗打开', !!panel && panel.style.display === 'flex')
|
|
1094
1099
|
assert('弹窗显示选中文字', !!panel && textOf(panel).indexOf('the migration ran long') >= 0)
|
|
1100
|
+
// 点完「解读」立刻把本文档选区收掉:留着它,小窗开着时按个方向键又会冒出一个「❝ 引用」,
|
|
1101
|
+
// 指的是刚才解读的那段文字(解读要的文字与上下文在 mouseup 那刻就抓好了,见 openForSelection)
|
|
1102
|
+
assert('点「解读」后本文档选区被收掉', clearedSelections.count >= 1, `removeAllRanges 调用 ${clearedSelections.count} 次`)
|
|
1103
|
+
{
|
|
1104
|
+
const quoteBtnNode = Array.from(walk(mount)).find((n) => String(n.className).indexOf('dsh-sel-quotebtn') >= 0)
|
|
1105
|
+
assert(
|
|
1106
|
+
'点「解读」后引用浮标不出现(旧选区不该复活它)',
|
|
1107
|
+
!quoteBtnNode || quoteBtnNode.style.display === 'none',
|
|
1108
|
+
quoteBtnNode ? String(quoteBtnNode.style.display) : '浮标节点还没建出来(= 没显示)',
|
|
1109
|
+
)
|
|
1110
|
+
}
|
|
1095
1111
|
|
|
1096
1112
|
const hook = windowStub.__dshSelectionExplain
|
|
1097
1113
|
assert('自检钩子可用', !!hook && typeof hook.state === 'function')
|
|
@@ -2237,13 +2253,23 @@ assert('尾部上下文变化后仍命中历史(不再重新生成一个)',
|
|
|
2237
2253
|
const pill = Array.from(walk(panel.parentNode)).find((n) => n.className === 'dsh-sel-pill')
|
|
2238
2254
|
assert('右下角有状态胶囊', !!pill, pill ? pill.className : '未找到')
|
|
2239
2255
|
assert(
|
|
2240
|
-
'
|
|
2256
|
+
'胶囊结构和费用胶囊同构:星芒 + 主体 + 次要 + 箭头',
|
|
2241
2257
|
!!pill &&
|
|
2242
|
-
['dsh-sel-
|
|
2258
|
+
['dsh-sel-pillname', 'dsh-sel-pillmeta', 'dsh-sel-pillcaret'].every((c) =>
|
|
2243
2259
|
Array.from(walk(pill)).some((n) => n.className === c),
|
|
2260
|
+
) &&
|
|
2261
|
+
// SVG 元素的 class 是 SVGAnimatedString,客户端用 setAttribute('class', …) 写 —— 桩里也照这个读
|
|
2262
|
+
['dsh-sel-pillicon', 'dsh-sel-pillstar'].every((c) =>
|
|
2263
|
+
Array.from(walk(pill)).some((n) => n.getAttribute && n.getAttribute('class') === c),
|
|
2244
2264
|
),
|
|
2245
2265
|
pill ? walk(pill).next().value.className : '',
|
|
2246
2266
|
)
|
|
2267
|
+
const pillStarEl = pill && Array.from(walk(pill)).find((n) => n.getAttribute && n.getAttribute('class') === 'dsh-sel-pillstar')
|
|
2268
|
+
assert(
|
|
2269
|
+
'球心里的图形初始是"圆点态"那条 path(展开时不许直接画成星)',
|
|
2270
|
+
!!pillStarEl && /^M4 0/.test(String(pillStarEl.getAttribute('d'))),
|
|
2271
|
+
pillStarEl ? String(pillStarEl.getAttribute('d')).slice(0, 24) : '未找到',
|
|
2272
|
+
)
|
|
2247
2273
|
assert('箭头用和费用胶囊同一个字符 ▴ / ▾(不是大三角 ▲ ▼)', textOf(pill).indexOf('▲') < 0 && textOf(pill).indexOf('▼') < 0, textOf(pill))
|
|
2248
2274
|
|
|
2249
2275
|
// 进行中:圆点在呼吸(tone=busy),文本报阶段 + 秒数
|