docs: 补充插入变量禁止 execCommand(WKWebView 光标漂移)
This commit is contained in:
1 parent
de1a38e211
commit
03f74629a4
1 file changed
+3
-2
@@ -24,8 +24,9 @@ git checkout 178b36c -- promptlib/styles.css promptlib/src/index.js
|
||||
|
||||
- 工具栏按钮 `pointerdown` 必须 `preventDefault()`,避免抢走 textarea 焦点/选区
|
||||
- 记录选区只在 `keyup / mouseup / input / select`,**绝对不要在 `blur` 记录**(WebKit 失焦会重置选区 → 插入到前一个字符)
|
||||
- 点击时先 `focus()` → `setSelectionRange(lastSel)` → `document.execCommand("insertText", false, "{变量}")`
|
||||
- 插入后选中变量名;`execCommand` 不可用时才回退 splice
|
||||
- 点击时先 `focus()` → 用 `lastSel` 计算插入点,直接 `value.slice` 拼接(确定性 splice)
|
||||
- 插入后 `setSelectionRange` 选中变量名,并同步 `lastSel`
|
||||
- **不要用 `document.execCommand("insertText")`**:WKWebView 内部光标与 `selectionStart` 会漂移,第一次正常、第二次起偏移一个字符(v1.8.16 实测)
|
||||
|
||||
## 四、发布前检查清单
|
||||
|
||||
|
||||
Reference in new issue
Block a user