@linker-design-plus/tiny-peony 1.2.34 → 1.2.35
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/dist/index.js +18 -18
- package/dist/index.mjs +883 -862
- package/dist/utils/dom.d.ts +17 -0
- package/package.json +1 -1
package/dist/utils/dom.d.ts
CHANGED
|
@@ -16,3 +16,20 @@ export declare const spellingTextNode: (node: Node, spellingText?: string, first
|
|
|
16
16
|
* 空间复杂度:O(n) - text2字符串长度
|
|
17
17
|
*/
|
|
18
18
|
export declare const longestConsecutiveSubsequence: (text1: string, text2: string) => string;
|
|
19
|
+
/**
|
|
20
|
+
* 判断光标是否在 <p> 段落的末尾
|
|
21
|
+
*
|
|
22
|
+
* 使用场景:
|
|
23
|
+
* - 监听 Backspace/Delete 时,避免浏览器默认合并段落的行为
|
|
24
|
+
* - 用于富文本编辑器中,检测用户是否在段落结尾输入
|
|
25
|
+
*
|
|
26
|
+
* 实现思路:
|
|
27
|
+
* 1. 获取当前 selection 对象(window.getSelection)
|
|
28
|
+
* 2. 如果没有光标或当前是选区(Range),直接返回 false
|
|
29
|
+
* 3. 找到光标所在的最近 <p> 段落
|
|
30
|
+
* 4. 克隆一个 range,从光标位置扩展到段落结尾
|
|
31
|
+
* 5. 如果扩展后的 range 没有内容,说明光标就在段落末尾
|
|
32
|
+
*
|
|
33
|
+
* @returns {boolean} true 表示光标在当前 <p> 段落的末尾
|
|
34
|
+
*/
|
|
35
|
+
export declare const isCursorAtParagraphEnd: () => boolean;
|