@ones-editor/editor 5.0.4-beta.h1449.3 → 5.0.4
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.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OnesEditorDoc } from './doc';
|
|
2
|
+
export interface RepairDuplicatedBlockIdsResult {
|
|
3
|
+
/** 被改掉 id 的 block 数量 */
|
|
4
|
+
repaired: number;
|
|
5
|
+
/** 出现重复的原始 id,用于上报定位产生脏数据的路径 */
|
|
6
|
+
duplicatedIds: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 修复同一份文档里出现多个相同 block id 的脏数据。
|
|
10
|
+
*
|
|
11
|
+
* block 的 id 会直接写成 DOM 元素的 id(`createBlockElement` 里的 `elem.id = id`),
|
|
12
|
+
* 而 `findBlockById` 是 `querySelector('#id')` —— 重复时永远只命中第一个。
|
|
13
|
+
* 于是后面那些副本会被渲染出来、光标也能落进去,但所有编辑都被重定向到第一个块,
|
|
14
|
+
* 用户看到的就是「内容重复而且改不了」。选区本身也是按 blockId 记录的,同样会被带偏。
|
|
15
|
+
*
|
|
16
|
+
* 按渲染顺序遍历,先出现的保留原 id,后面的重新发号。必须在 `createRootContainer`
|
|
17
|
+
* 之前调用:此时还没有任何 DOM,直接走底层 doc 的 local* 接口提交 op,修复会落库,
|
|
18
|
+
* 存量脏文档打开即自愈。
|
|
19
|
+
*
|
|
20
|
+
* 只读态不改数据,只告警。
|
|
21
|
+
*/
|
|
22
|
+
export declare function repairDuplicatedBlockIds(doc: OnesEditorDoc, readonly: boolean): RepairDuplicatedBlockIdsResult;
|