@textbus/collaborate 5.2.6 → 5.3.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.en.md +12 -0
- package/README.md +3 -1
- package/dist/base/collab-history.d.ts +1 -0
- package/dist/base/collaborate.d.ts +11 -0
- package/dist/connectors/_api.d.ts +1 -0
- package/dist/connectors/local-connector.d.ts +32 -0
- package/dist/index.esm.js +418 -180
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +416 -177
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.en.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
**[中文](README.md)**
|
|
2
|
+
|
|
3
|
+
@textbus/collaborate
|
|
4
|
+
=====================
|
|
5
|
+
|
|
6
|
+
Textbus is a framework for highly interactive rich text editing. Unlike many editors, it centers on **components**, uses formats as helpers, simplifies common editor APIs, and raises the abstraction level so Textbus stays approachable while scaling to complex apps.
|
|
7
|
+
|
|
8
|
+
This package adds **multi-user collaborative editing** for Textbus (including Yjs-oriented integrations).
|
|
9
|
+
|
|
10
|
+
### Documentation
|
|
11
|
+
|
|
12
|
+
More docs: [textbus.io](https://textbus.io) · [English](https://textbus.io/en/index.html)
|
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@ import { Observable } from '@tanbo/stream';
|
|
|
3
3
|
import { Item, Transaction } from 'yjs';
|
|
4
4
|
import { Collaborate } from './collaborate';
|
|
5
5
|
export declare abstract class CustomUndoManagerConfig {
|
|
6
|
+
abstract captureTimeout?: number;
|
|
6
7
|
abstract captureTransaction?(arg0: Transaction): boolean;
|
|
7
8
|
abstract deleteFilter?(arg0: Item): boolean;
|
|
8
9
|
}
|
|
@@ -64,6 +64,17 @@ export declare class Collaborate {
|
|
|
64
64
|
private createLocalModelBySharedByModel;
|
|
65
65
|
private createSharedComponentByLocalComponent;
|
|
66
66
|
private createLocalComponentBySharedComponent;
|
|
67
|
+
private createArrayHoleXmlElement;
|
|
68
|
+
private isArrayHoleElement;
|
|
69
|
+
/**
|
|
70
|
+
* 仅用于 YArray ↔ 可观察数组:本地 `undefined` 槽位用 XmlElement 占位同步到 Yjs(不与对象字面量同步混用)。
|
|
71
|
+
*/
|
|
72
|
+
private sharedModelForArraySlot;
|
|
73
|
+
/**
|
|
74
|
+
* 在可观察数组中插入稀疏空洞(与 YArray 中 XmlElement 占位对齐)。
|
|
75
|
+
* 仅在远端同步路径调用;直接操作 raw,避免走插入 undefined 的可观察路径。
|
|
76
|
+
*/
|
|
77
|
+
private insertSparseHole;
|
|
67
78
|
/**
|
|
68
79
|
* 双向同步数组
|
|
69
80
|
* @param sharedArray
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Doc as YDoc } from 'yjs';
|
|
2
|
+
import { SyncConnector } from '../base/sync-connector';
|
|
3
|
+
export interface LocalConnectorOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 与其它连接器一致,会出现在 `onStateChange` 的 `clientId` 中。
|
|
6
|
+
* 多实例场景可传入不同值以模拟多客户端。
|
|
7
|
+
*/
|
|
8
|
+
clientId?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 不经网络的协作连接器,实现与 {@link SyncConnector} 相同的对外行为,
|
|
12
|
+
* 便于在单元测试中配合 {@link CollaborateModule} 使用,无需 WebSocket / Provider。
|
|
13
|
+
*
|
|
14
|
+
* - `onLoad`:在微任务中触发一次,对应远端「已同步可编辑」的时机。
|
|
15
|
+
* - `onStateChange`:在每次 {@link LocalConnector.setLocalStateField} 后发出当前客户端状态,
|
|
16
|
+
* 载荷形状与 `YWebsocketConnector` 一致(`{ clientId, message }`,其中 `message` 为 awareness 上的 `message` 字段)。
|
|
17
|
+
*
|
|
18
|
+
* 第一个参数与 `createConnector(yDoc)` 对齐,便于直接传入 `Collaborate` 的文档;当前实现不读写该 `YDoc`。
|
|
19
|
+
*/
|
|
20
|
+
export declare class LocalConnector extends SyncConnector {
|
|
21
|
+
readonly clientId: number;
|
|
22
|
+
private destroyed;
|
|
23
|
+
private fields;
|
|
24
|
+
constructor(_yDoc?: YDoc, options?: LocalConnectorOptions);
|
|
25
|
+
setLocalStateField(key: string, data: Record<string, any>): void;
|
|
26
|
+
onDestroy(): void;
|
|
27
|
+
/**
|
|
28
|
+
* 读取当前本地 awareness 字段快照,仅用于测试断言。
|
|
29
|
+
*/
|
|
30
|
+
getLocalAwarenessSnapshot(): Readonly<Record<string, any>>;
|
|
31
|
+
private emitAwarenessStates;
|
|
32
|
+
}
|