@wangeditor-next/yjs 0.1.3 → 0.1.5
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 +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/{applyToSlate → yjs/src/applyToSlate}/index.d.ts +19 -19
- package/dist/{applyToSlate → yjs/src/applyToSlate}/textEvent.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/index.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/node/index.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/node/insertNode.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/node/mergeNode.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/node/moveNode.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/node/removeNode.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/node/setNode.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/node/splitNode.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/text/index.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/text/insertText.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/text/removeText.d.ts +3 -3
- package/dist/{applyToYjs → yjs/src/applyToYjs}/types.d.ts +8 -8
- package/dist/{index.d.ts → yjs/src/index.d.ts} +5 -5
- package/dist/{module → yjs/src/module}/custom-types.d.ts +41 -41
- package/dist/{plugins → yjs/src/plugins}/index.d.ts +3 -3
- package/dist/yjs/src/plugins/withCursors.d.ts +38 -0
- package/dist/{plugins → yjs/src/plugins}/withYHistory.d.ts +19 -34
- package/dist/{plugins → yjs/src/plugins}/withYjs.d.ts +42 -52
- package/dist/{utils → yjs/src/utils}/clone.d.ts +4 -4
- package/dist/{utils → yjs/src/utils}/convert.d.ts +7 -7
- package/dist/{utils → yjs/src/utils}/delta.d.ts +7 -7
- package/dist/{utils → yjs/src/utils}/location.d.ts +11 -11
- package/dist/{utils → yjs/src/utils}/object.d.ts +9 -9
- package/dist/{utils → yjs/src/utils}/position.d.ts +19 -19
- package/dist/{utils → yjs/src/utils}/slate.d.ts +2 -2
- package/dist/{utils → yjs/src/utils}/yjs.d.ts +4 -4
- package/package.json +11 -12
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/plugins/withCursors.d.ts +0 -55
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Editor, Operation } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
/**
|
|
4
|
-
* Translate a yjs event into slate operations. The editor state has to match the
|
|
5
|
-
* yText state before the event occurred.
|
|
6
|
-
*
|
|
7
|
-
* @param sharedType
|
|
8
|
-
* @param op
|
|
9
|
-
*/
|
|
10
|
-
export declare function translateYjsEvent(sharedRoot: Y.XmlText, editor: Editor, event: Y.YEvent<Y.XmlText>): Operation[];
|
|
11
|
-
/**
|
|
12
|
-
* Translates yjs events into slate operations and applies them to the editor. The
|
|
13
|
-
* editor state has to match the yText state before the events occurred.
|
|
14
|
-
*
|
|
15
|
-
* @param sharedRoot
|
|
16
|
-
* @param editor
|
|
17
|
-
* @param events
|
|
18
|
-
*/
|
|
19
|
-
export declare function applyYjsEvents(sharedRoot: Y.XmlText, editor: Editor, events: Y.YEvent<Y.XmlText>[]): void;
|
|
1
|
+
import { Editor, Operation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
/**
|
|
4
|
+
* Translate a yjs event into slate operations. The editor state has to match the
|
|
5
|
+
* yText state before the event occurred.
|
|
6
|
+
*
|
|
7
|
+
* @param sharedType
|
|
8
|
+
* @param op
|
|
9
|
+
*/
|
|
10
|
+
export declare function translateYjsEvent(sharedRoot: Y.XmlText, editor: Editor, event: Y.YEvent<Y.XmlText>): Operation[];
|
|
11
|
+
/**
|
|
12
|
+
* Translates yjs events into slate operations and applies them to the editor. The
|
|
13
|
+
* editor state has to match the yText state before the events occurred.
|
|
14
|
+
*
|
|
15
|
+
* @param sharedRoot
|
|
16
|
+
* @param editor
|
|
17
|
+
* @param events
|
|
18
|
+
*/
|
|
19
|
+
export declare function applyYjsEvents(sharedRoot: Y.XmlText, editor: Editor, events: Y.YEvent<Y.XmlText>[]): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Editor, Operation } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export declare function translateYTextEvent(sharedRoot: Y.XmlText, editor: Editor, event: Y.YTextEvent): Operation[];
|
|
1
|
+
import { Editor, Operation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function translateYTextEvent(sharedRoot: Y.XmlText, editor: Editor, event: Y.YTextEvent): Operation[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Node, Operation } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export declare function applySlateOp(sharedRoot: Y.XmlText, slateRoot: Node, op: Operation): void;
|
|
1
|
+
import { Node, Operation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function applySlateOp(sharedRoot: Y.XmlText, slateRoot: Node, op: Operation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NodeOperation } from 'slate';
|
|
2
|
-
import { OpMapper } from '../types';
|
|
3
|
-
export declare const NODE_MAPPER: OpMapper<NodeOperation>;
|
|
1
|
+
import { NodeOperation } from 'slate';
|
|
2
|
+
import { OpMapper } from '../types';
|
|
3
|
+
export declare const NODE_MAPPER: OpMapper<NodeOperation>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { InsertNodeOperation, Node } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export declare function insertNode(sharedRoot: Y.XmlText, slateRoot: Node, op: InsertNodeOperation): void;
|
|
1
|
+
import { InsertNodeOperation, Node } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function insertNode(sharedRoot: Y.XmlText, slateRoot: Node, op: InsertNodeOperation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MergeNodeOperation, Node } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export declare function mergeNode(sharedRoot: Y.XmlText, slateRoot: Node, op: MergeNodeOperation): void;
|
|
1
|
+
import { MergeNodeOperation, Node } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function mergeNode(sharedRoot: Y.XmlText, slateRoot: Node, op: MergeNodeOperation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MoveNodeOperation, Node } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export declare function moveNode(sharedRoot: Y.XmlText, slateRoot: Node, op: MoveNodeOperation): void;
|
|
1
|
+
import { MoveNodeOperation, Node } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function moveNode(sharedRoot: Y.XmlText, slateRoot: Node, op: MoveNodeOperation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Node, RemoveNodeOperation } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export declare function removeNode(sharedRoot: Y.XmlText, slateRoot: Node, op: RemoveNodeOperation): void;
|
|
1
|
+
import { Node, RemoveNodeOperation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function removeNode(sharedRoot: Y.XmlText, slateRoot: Node, op: RemoveNodeOperation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Node, SetNodeOperation } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export declare function setNode(sharedRoot: Y.XmlText, slateRoot: Node, op: SetNodeOperation): void;
|
|
1
|
+
import { Node, SetNodeOperation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function setNode(sharedRoot: Y.XmlText, slateRoot: Node, op: SetNodeOperation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Node, SplitNodeOperation } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export declare function splitNode(sharedRoot: Y.XmlText, slateRoot: Node, op: SplitNodeOperation): void;
|
|
1
|
+
import { Node, SplitNodeOperation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function splitNode(sharedRoot: Y.XmlText, slateRoot: Node, op: SplitNodeOperation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TextOperation } from 'slate';
|
|
2
|
-
import { OpMapper } from '../types';
|
|
3
|
-
export declare const TEXT_MAPPER: OpMapper<TextOperation>;
|
|
1
|
+
import { TextOperation } from 'slate';
|
|
2
|
+
import { OpMapper } from '../types';
|
|
3
|
+
export declare const TEXT_MAPPER: OpMapper<TextOperation>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { InsertTextOperation, Node } from 'slate';
|
|
2
|
-
import
|
|
3
|
-
export declare function insertText(sharedRoot: Y.XmlText, slateRoot: Node, op: InsertTextOperation): void;
|
|
1
|
+
import { InsertTextOperation, Node } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function insertText(sharedRoot: Y.XmlText, slateRoot: Node, op: InsertTextOperation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Node, RemoveTextOperation } from 'slate';
|
|
2
|
-
import
|
|
3
|
-
export declare function removeText(sharedRoot: Y.XmlText, slateRoot: Node, op: RemoveTextOperation): void;
|
|
1
|
+
import { Node, RemoveTextOperation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare function removeText(sharedRoot: Y.XmlText, slateRoot: Node, op: RemoveTextOperation): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Node, Operation } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
export type ApplyFunc<O extends Operation = Operation> = (sharedRoot: Y.XmlText, slateRoot: Node, op: O) => void;
|
|
4
|
-
export type OpMapper<O extends Operation = Operation> = {
|
|
5
|
-
[K in O['type']]: O extends {
|
|
6
|
-
type: K;
|
|
7
|
-
} ? ApplyFunc<O> : never;
|
|
8
|
-
};
|
|
1
|
+
import { Node, Operation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export type ApplyFunc<O extends Operation = Operation> = (sharedRoot: Y.XmlText, slateRoot: Node, op: O) => void;
|
|
4
|
+
export type OpMapper<O extends Operation = Operation> = {
|
|
5
|
+
[K in O['type']]: O extends {
|
|
6
|
+
type: K;
|
|
7
|
+
} ? ApplyFunc<O> : never;
|
|
8
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RelativeRange } from './module/custom-types';
|
|
2
|
-
import { CursorEditor, CursorState, CursorStateChangeEvent, RemoteCursorChangeEventListener, withCursors, WithCursorsOptions, withYHistory, WithYHistoryOptions, withYjs, WithYjsOptions, YHistoryEditor, YjsEditor } from './plugins';
|
|
3
|
-
import { slateNodesToInsertDelta, yTextToSlateElement } from './utils/convert';
|
|
4
|
-
import { relativePositionToSlatePoint, relativeRangeToSlateRange, slatePointToRelativePosition, slateRangeToRelativeRange } from './utils/position';
|
|
5
|
-
export {
|
|
1
|
+
import { RelativeRange } from './module/custom-types';
|
|
2
|
+
import { CursorEditor, CursorState, CursorStateChangeEvent, RemoteCursorChangeEventListener, withCursors, WithCursorsOptions, withYHistory, WithYHistoryOptions, withYjs, WithYjsOptions, YHistoryEditor, YjsEditor } from './plugins';
|
|
3
|
+
import { slateNodesToInsertDelta, yTextToSlateElement } from './utils/convert';
|
|
4
|
+
import { relativePositionToSlatePoint, relativeRangeToSlateRange, slatePointToRelativePosition, slateRangeToRelativeRange } from './utils/position';
|
|
5
|
+
export { CursorEditor, CursorState, CursorStateChangeEvent, relativePositionToSlatePoint, RelativeRange, relativeRangeToSlateRange, RemoteCursorChangeEventListener, slateNodesToInsertDelta, slatePointToRelativePosition, slateRangeToRelativeRange, withCursors, WithCursorsOptions, withYHistory, WithYHistoryOptions, withYjs, WithYjsOptions, YHistoryEditor, YjsEditor, yTextToSlateElement, };
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import type { Descendant, Editor, Element, Node } from 'slate';
|
|
2
|
-
import
|
|
3
|
-
export type DeltaAttributes = {
|
|
4
|
-
retain: number;
|
|
5
|
-
attributes: Record<string, unknown>;
|
|
6
|
-
};
|
|
7
|
-
export type DeltaRetain = {
|
|
8
|
-
retain: number;
|
|
9
|
-
};
|
|
10
|
-
export type DeltaDelete = {
|
|
11
|
-
delete: number;
|
|
12
|
-
};
|
|
13
|
-
export type DeltaInsert = {
|
|
14
|
-
insert: string | Y.XmlText;
|
|
15
|
-
attributes?: Record<string, unknown>;
|
|
16
|
-
};
|
|
17
|
-
export type InsertDelta = Array<DeltaInsert>;
|
|
18
|
-
export type Delta = Array<DeltaRetain | DeltaDelete | DeltaInsert | DeltaAttributes>;
|
|
19
|
-
export type TextRange = {
|
|
20
|
-
start: number;
|
|
21
|
-
end: number;
|
|
22
|
-
};
|
|
23
|
-
export type HistoryStackItem = {
|
|
24
|
-
meta: Map<string, unknown>;
|
|
25
|
-
};
|
|
26
|
-
export type YTarget = {
|
|
27
|
-
textRange: TextRange;
|
|
28
|
-
yParent: Y.XmlText;
|
|
29
|
-
slateParent: Element | Editor;
|
|
30
|
-
yTarget?: Y.XmlText;
|
|
31
|
-
slateTarget?: Node;
|
|
32
|
-
targetDelta: InsertDelta;
|
|
33
|
-
};
|
|
34
|
-
export type RelativeRange = {
|
|
35
|
-
anchor: Y.RelativePosition;
|
|
36
|
-
focus: Y.RelativePosition;
|
|
37
|
-
};
|
|
38
|
-
export type NodeElement = {
|
|
39
|
-
type: string;
|
|
40
|
-
children: Descendant[];
|
|
41
|
-
};
|
|
1
|
+
import type { Descendant, Editor, Element, Node } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export type DeltaAttributes = {
|
|
4
|
+
retain: number;
|
|
5
|
+
attributes: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export type DeltaRetain = {
|
|
8
|
+
retain: number;
|
|
9
|
+
};
|
|
10
|
+
export type DeltaDelete = {
|
|
11
|
+
delete: number;
|
|
12
|
+
};
|
|
13
|
+
export type DeltaInsert = {
|
|
14
|
+
insert: string | Y.XmlText;
|
|
15
|
+
attributes?: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
export type InsertDelta = Array<DeltaInsert>;
|
|
18
|
+
export type Delta = Array<DeltaRetain | DeltaDelete | DeltaInsert | DeltaAttributes>;
|
|
19
|
+
export type TextRange = {
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
};
|
|
23
|
+
export type HistoryStackItem = {
|
|
24
|
+
meta: Map<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
export type YTarget = {
|
|
27
|
+
textRange: TextRange;
|
|
28
|
+
yParent: Y.XmlText;
|
|
29
|
+
slateParent: Element | Editor;
|
|
30
|
+
yTarget?: Y.XmlText;
|
|
31
|
+
slateTarget?: Node;
|
|
32
|
+
targetDelta: InsertDelta;
|
|
33
|
+
};
|
|
34
|
+
export type RelativeRange = {
|
|
35
|
+
anchor: Y.RelativePosition;
|
|
36
|
+
focus: Y.RelativePosition;
|
|
37
|
+
};
|
|
38
|
+
export type NodeElement = {
|
|
39
|
+
type: string;
|
|
40
|
+
children: Descendant[];
|
|
41
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './withYHistory';
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './withCursors';
|
|
2
|
+
export * from './withYHistory';
|
|
3
|
+
export * from './withYjs';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Range } from 'slate';
|
|
2
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
3
|
+
import { RelativeRange } from '../module/custom-types';
|
|
4
|
+
import { YjsEditor } from './withYjs';
|
|
5
|
+
export type CursorStateChangeEvent = {
|
|
6
|
+
added: number[];
|
|
7
|
+
updated: number[];
|
|
8
|
+
removed: number[];
|
|
9
|
+
};
|
|
10
|
+
export type RemoteCursorChangeEventListener = (event: CursorStateChangeEvent) => void;
|
|
11
|
+
export type CursorState<TCursorData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
12
|
+
relativeSelection: RelativeRange | null;
|
|
13
|
+
data?: TCursorData;
|
|
14
|
+
clientId: number;
|
|
15
|
+
};
|
|
16
|
+
export type CursorEditor<TCursorData extends Record<string, unknown> = Record<string, unknown>> = YjsEditor & {
|
|
17
|
+
awareness: Awareness;
|
|
18
|
+
cursorDataField: string;
|
|
19
|
+
selectionStateField: string;
|
|
20
|
+
sendCursorPosition: (range: Range | null) => void;
|
|
21
|
+
sendCursorData: (data: TCursorData) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare const CursorEditor: {
|
|
24
|
+
isCursorEditor(value: unknown): value is CursorEditor;
|
|
25
|
+
sendCursorPosition<TCursorData extends Record<string, unknown>>(editor: CursorEditor<TCursorData>, range?: Range | null): void;
|
|
26
|
+
sendCursorData<TCursorData extends Record<string, unknown>>(editor: CursorEditor<TCursorData>, data: TCursorData): void;
|
|
27
|
+
on<TCursorData extends Record<string, unknown>>(editor: CursorEditor<TCursorData>, event: "change", handler: RemoteCursorChangeEventListener): void;
|
|
28
|
+
off<TCursorData extends Record<string, unknown>>(editor: CursorEditor<TCursorData>, event: "change", listener: RemoteCursorChangeEventListener): void;
|
|
29
|
+
cursorState<TCursorData extends Record<string, unknown>>(editor: CursorEditor<TCursorData>, clientId: number): CursorState<TCursorData> | null;
|
|
30
|
+
cursorStates<TCursorData extends Record<string, unknown>>(editor: CursorEditor<TCursorData>): Record<string, CursorState<TCursorData>>;
|
|
31
|
+
};
|
|
32
|
+
export type WithCursorsOptions<TCursorData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
33
|
+
cursorStateField?: string;
|
|
34
|
+
cursorDataField?: string;
|
|
35
|
+
data?: TCursorData;
|
|
36
|
+
autoSend?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare function withCursors<TCursorData extends Record<string, unknown>>(awareness: Awareness, options?: WithCursorsOptions<TCursorData>): <T extends YjsEditor>(editor: T) => T & CursorEditor<TCursorData>;
|
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
import * as Y from 'yjs';
|
|
2
|
-
import { YjsEditor } from './withYjs';
|
|
3
|
-
export type YHistoryEditor = YjsEditor & {
|
|
4
|
-
undoManager: Y.UndoManager;
|
|
5
|
-
withoutSavingOrigin: unknown;
|
|
6
|
-
undo: () => void;
|
|
7
|
-
redo: () => void;
|
|
8
|
-
};
|
|
9
|
-
export declare const YHistoryEditor: {
|
|
10
|
-
isYHistoryEditor(value: unknown): value is YHistoryEditor;
|
|
11
|
-
canUndo(editor: YHistoryEditor): boolean;
|
|
12
|
-
canRedo(editor: YHistoryEditor): boolean;
|
|
13
|
-
isSaving(editor: YHistoryEditor): boolean;
|
|
14
|
-
withoutSaving(editor: YHistoryEditor, fn: () => void): void;
|
|
15
|
-
};
|
|
16
|
-
export type WithYHistoryOptions = NonNullable<ConstructorParameters<typeof Y.UndoManager>[1]> & {
|
|
17
|
-
withoutSavingOrigin?: unknown;
|
|
18
|
-
};
|
|
19
|
-
export declare function withYHistory(options?: WithYHistoryOptions): <T extends YjsEditor>(editor: T) => T &
|
|
20
|
-
sharedRoot: Y.XmlText;
|
|
21
|
-
localOrigin: unknown;
|
|
22
|
-
positionStorageOrigin: unknown;
|
|
23
|
-
applyRemoteEvents: (events: Y.YEvent<Y.XmlText>[], origin: unknown) => void;
|
|
24
|
-
storeLocalChange: (op: import("slate").BaseOperation) => void;
|
|
25
|
-
flushLocalChanges: () => void;
|
|
26
|
-
isLocalOrigin: (origin: unknown) => boolean;
|
|
27
|
-
connect: () => void;
|
|
28
|
-
disconnect: () => void;
|
|
29
|
-
} & {
|
|
30
|
-
undoManager: Y.UndoManager;
|
|
31
|
-
withoutSavingOrigin: unknown;
|
|
32
|
-
undo: () => void;
|
|
33
|
-
redo: () => void;
|
|
34
|
-
};
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { YjsEditor } from './withYjs';
|
|
3
|
+
export type YHistoryEditor = YjsEditor & {
|
|
4
|
+
undoManager: Y.UndoManager;
|
|
5
|
+
withoutSavingOrigin: unknown;
|
|
6
|
+
undo: () => void;
|
|
7
|
+
redo: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const YHistoryEditor: {
|
|
10
|
+
isYHistoryEditor(value: unknown): value is YHistoryEditor;
|
|
11
|
+
canUndo(editor: YHistoryEditor): boolean;
|
|
12
|
+
canRedo(editor: YHistoryEditor): boolean;
|
|
13
|
+
isSaving(editor: YHistoryEditor): boolean;
|
|
14
|
+
withoutSaving(editor: YHistoryEditor, fn: () => void): void;
|
|
15
|
+
};
|
|
16
|
+
export type WithYHistoryOptions = NonNullable<ConstructorParameters<typeof Y.UndoManager>[1]> & {
|
|
17
|
+
withoutSavingOrigin?: unknown;
|
|
18
|
+
};
|
|
19
|
+
export declare function withYHistory(options?: WithYHistoryOptions): <T extends YjsEditor>(editor: T) => T & YHistoryEditor;
|
|
@@ -1,52 +1,42 @@
|
|
|
1
|
-
import { BaseEditor, Descendant, Operation, Point } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
type LocalChange = {
|
|
4
|
-
op: Operation;
|
|
5
|
-
doc: Descendant[];
|
|
6
|
-
origin: unknown;
|
|
7
|
-
};
|
|
8
|
-
export type YjsEditor = BaseEditor & {
|
|
9
|
-
sharedRoot: Y.XmlText;
|
|
10
|
-
localOrigin: unknown;
|
|
11
|
-
positionStorageOrigin: unknown;
|
|
12
|
-
applyRemoteEvents: (events: Y.YEvent<Y.XmlText>[], origin: unknown) => void;
|
|
13
|
-
storeLocalChange: (op: Operation) => void;
|
|
14
|
-
flushLocalChanges: () => void;
|
|
15
|
-
isLocalOrigin: (origin: unknown) => boolean;
|
|
16
|
-
connect: () => void;
|
|
17
|
-
disconnect: () => void;
|
|
18
|
-
};
|
|
19
|
-
export declare const YjsEditor: {
|
|
20
|
-
isYjsEditor(value: unknown): value is YjsEditor;
|
|
21
|
-
localChanges(editor: YjsEditor): LocalChange[];
|
|
22
|
-
applyRemoteEvents(editor: YjsEditor, events: Y.YEvent<Y.XmlText>[], origin: unknown): void;
|
|
23
|
-
storeLocalChange(editor: YjsEditor, op: Operation): void;
|
|
24
|
-
flushLocalChanges(editor: YjsEditor): void;
|
|
25
|
-
connected(editor: YjsEditor): boolean;
|
|
26
|
-
connect(editor: YjsEditor): void;
|
|
27
|
-
disconnect(editor: YjsEditor): void;
|
|
28
|
-
isLocal(editor: YjsEditor): boolean;
|
|
29
|
-
origin(editor: YjsEditor): unknown;
|
|
30
|
-
withOrigin(editor: YjsEditor, origin: unknown, fn: () => void): void;
|
|
31
|
-
storePosition(editor: YjsEditor, key: string, point: Point): void;
|
|
32
|
-
removeStoredPosition(editor: YjsEditor, key: string): void;
|
|
33
|
-
position(editor: YjsEditor, key: string): Point | null | undefined;
|
|
34
|
-
storedPositionsRelative(editor: YjsEditor): Record<string, Y.RelativePosition>;
|
|
35
|
-
};
|
|
36
|
-
export type WithYjsOptions = {
|
|
37
|
-
autoConnect?: boolean;
|
|
38
|
-
localOrigin?: unknown;
|
|
39
|
-
positionStorageOrigin?: unknown;
|
|
40
|
-
};
|
|
41
|
-
export declare function withYjs(sharedRoot: Y.XmlText, options?: WithYjsOptions): <T extends
|
|
42
|
-
|
|
43
|
-
localOrigin: unknown;
|
|
44
|
-
positionStorageOrigin: unknown;
|
|
45
|
-
applyRemoteEvents: (events: Y.YEvent<Y.XmlText>[], origin: unknown) => void;
|
|
46
|
-
storeLocalChange: (op: import("slate").BaseOperation) => void;
|
|
47
|
-
flushLocalChanges: () => void;
|
|
48
|
-
isLocalOrigin: (origin: unknown) => boolean;
|
|
49
|
-
connect: () => void;
|
|
50
|
-
disconnect: () => void;
|
|
51
|
-
};
|
|
52
|
-
export {};
|
|
1
|
+
import { BaseEditor, Descendant, Editor, Operation, Point } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
type LocalChange = {
|
|
4
|
+
op: Operation;
|
|
5
|
+
doc: Descendant[];
|
|
6
|
+
origin: unknown;
|
|
7
|
+
};
|
|
8
|
+
export type YjsEditor = BaseEditor & {
|
|
9
|
+
sharedRoot: Y.XmlText;
|
|
10
|
+
localOrigin: unknown;
|
|
11
|
+
positionStorageOrigin: unknown;
|
|
12
|
+
applyRemoteEvents: (events: Y.YEvent<Y.XmlText>[], origin: unknown) => void;
|
|
13
|
+
storeLocalChange: (op: Operation) => void;
|
|
14
|
+
flushLocalChanges: () => void;
|
|
15
|
+
isLocalOrigin: (origin: unknown) => boolean;
|
|
16
|
+
connect: () => void;
|
|
17
|
+
disconnect: () => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const YjsEditor: {
|
|
20
|
+
isYjsEditor(value: unknown): value is YjsEditor;
|
|
21
|
+
localChanges(editor: YjsEditor): LocalChange[];
|
|
22
|
+
applyRemoteEvents(editor: YjsEditor, events: Y.YEvent<Y.XmlText>[], origin: unknown): void;
|
|
23
|
+
storeLocalChange(editor: YjsEditor, op: Operation): void;
|
|
24
|
+
flushLocalChanges(editor: YjsEditor): void;
|
|
25
|
+
connected(editor: YjsEditor): boolean;
|
|
26
|
+
connect(editor: YjsEditor): void;
|
|
27
|
+
disconnect(editor: YjsEditor): void;
|
|
28
|
+
isLocal(editor: YjsEditor): boolean;
|
|
29
|
+
origin(editor: YjsEditor): unknown;
|
|
30
|
+
withOrigin(editor: YjsEditor, origin: unknown, fn: () => void): void;
|
|
31
|
+
storePosition(editor: YjsEditor, key: string, point: Point): void;
|
|
32
|
+
removeStoredPosition(editor: YjsEditor, key: string): void;
|
|
33
|
+
position(editor: YjsEditor, key: string): Point | null | undefined;
|
|
34
|
+
storedPositionsRelative(editor: YjsEditor): Record<string, Y.RelativePosition>;
|
|
35
|
+
};
|
|
36
|
+
export type WithYjsOptions = {
|
|
37
|
+
autoConnect?: boolean;
|
|
38
|
+
localOrigin?: unknown;
|
|
39
|
+
positionStorageOrigin?: unknown;
|
|
40
|
+
};
|
|
41
|
+
export declare function withYjs(sharedRoot: Y.XmlText, options?: WithYjsOptions): <T extends Editor>(editor: T) => T & YjsEditor;
|
|
42
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as Y from 'yjs';
|
|
2
|
-
import { InsertDelta } from '../module/custom-types';
|
|
3
|
-
export declare function cloneInsertDeltaDeep(delta: InsertDelta): InsertDelta;
|
|
4
|
-
export declare function cloneDeep(yText: Y.XmlText): Y.XmlText;
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { InsertDelta } from '../module/custom-types';
|
|
3
|
+
export declare function cloneInsertDeltaDeep(delta: InsertDelta): InsertDelta;
|
|
4
|
+
export declare function cloneDeep(yText: Y.XmlText): Y.XmlText;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Element, Node } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
import { DeltaInsert, InsertDelta } from '../module/custom-types';
|
|
4
|
-
export declare function yTextToSlateElement(yText: Y.XmlText): Element;
|
|
5
|
-
export declare function deltaInsertToSlateNode(insert: DeltaInsert): Node;
|
|
6
|
-
export declare function slateNodesToInsertDelta(nodes: Node[]): InsertDelta;
|
|
7
|
-
export declare function slateElementToYText({ children, ...attributes }: Element): Y.XmlText;
|
|
1
|
+
import { Element, Node } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
import { DeltaInsert, InsertDelta } from '../module/custom-types';
|
|
4
|
+
export declare function yTextToSlateElement(yText: Y.XmlText): Element;
|
|
5
|
+
export declare function deltaInsertToSlateNode(insert: DeltaInsert): Node;
|
|
6
|
+
export declare function slateNodesToInsertDelta(nodes: Node[]): InsertDelta;
|
|
7
|
+
export declare function slateElementToYText({ children, ...attributes }: Element): Y.XmlText;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as Y from 'yjs';
|
|
2
|
-
import { DeltaInsert, InsertDelta } from '../module/custom-types';
|
|
3
|
-
export declare function normalizeInsertDelta(delta: InsertDelta): InsertDelta;
|
|
4
|
-
export declare function yTextToInsertDelta(yText: Y.XmlText): InsertDelta;
|
|
5
|
-
export declare function getInsertLength({ insert }: DeltaInsert): number;
|
|
6
|
-
export declare function getInsertDeltaLength(delta: InsertDelta): number;
|
|
7
|
-
export declare function sliceInsertDelta(delta: InsertDelta, start: number, length: number): InsertDelta;
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { DeltaInsert, InsertDelta } from '../module/custom-types';
|
|
3
|
+
export declare function normalizeInsertDelta(delta: InsertDelta): InsertDelta;
|
|
4
|
+
export declare function yTextToInsertDelta(yText: Y.XmlText): InsertDelta;
|
|
5
|
+
export declare function getInsertLength({ insert }: DeltaInsert): number;
|
|
6
|
+
export declare function getInsertDeltaLength(delta: InsertDelta): number;
|
|
7
|
+
export declare function sliceInsertDelta(delta: InsertDelta, start: number, length: number): InsertDelta;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Element, Node, Path } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
import { YTarget } from '../module/custom-types';
|
|
4
|
-
export declare function getSlateNodeYLength(node: Node | undefined): number;
|
|
5
|
-
export declare function slatePathOffsetToYOffset(element: Element, pathOffset: number): number;
|
|
6
|
-
export declare function getYTarget(yRoot: Y.XmlText, slateRoot: Node, path: Path): YTarget;
|
|
7
|
-
export declare function yOffsetToSlateOffsets(parent: Element, yOffset: number, opts?: {
|
|
8
|
-
assoc?: number;
|
|
9
|
-
insert?: boolean;
|
|
10
|
-
}): [number, number];
|
|
11
|
-
export declare function getSlatePath(sharedRoot: Y.XmlText, slateRoot: Node, yText: Y.XmlText): Path;
|
|
1
|
+
import { Element, Node, Path } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
import { YTarget } from '../module/custom-types';
|
|
4
|
+
export declare function getSlateNodeYLength(node: Node | undefined): number;
|
|
5
|
+
export declare function slatePathOffsetToYOffset(element: Element, pathOffset: number): number;
|
|
6
|
+
export declare function getYTarget(yRoot: Y.XmlText, slateRoot: Node, path: Path): YTarget;
|
|
7
|
+
export declare function yOffsetToSlateOffsets(parent: Element, yOffset: number, opts?: {
|
|
8
|
+
assoc?: number;
|
|
9
|
+
insert?: boolean;
|
|
10
|
+
}): [number, number];
|
|
11
|
+
export declare function getSlatePath(sharedRoot: Y.XmlText, slateRoot: Node, yText: Y.XmlText): Path;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
type InspectableObject = Record<string | number | symbol, unknown>;
|
|
2
|
-
export declare function isPlainObject(o: unknown): o is InspectableObject;
|
|
3
|
-
export declare function deepEquals(node: InspectableObject, another: InspectableObject): boolean;
|
|
4
|
-
export declare function pick<TObj extends Object, TKeys extends keyof TObj>(obj: TObj, ...keys: TKeys[]): Pick<TObj, TKeys>;
|
|
5
|
-
export declare function omit<TObj extends Object, TKeys extends keyof TObj>(obj: TObj, ...keys: TKeys[]): Omit<TObj, TKeys>;
|
|
6
|
-
export declare function omitNullEntries<TObj extends Object>(obj: TObj): {
|
|
7
|
-
[K in keyof TObj]: TObj[K] extends null ? never : K;
|
|
8
|
-
};
|
|
9
|
-
export {};
|
|
1
|
+
type InspectableObject = Record<string | number | symbol, unknown>;
|
|
2
|
+
export declare function isPlainObject(o: unknown): o is InspectableObject;
|
|
3
|
+
export declare function deepEquals(node: InspectableObject, another: InspectableObject): boolean;
|
|
4
|
+
export declare function pick<TObj extends Object, TKeys extends keyof TObj>(obj: TObj, ...keys: TKeys[]): Pick<TObj, TKeys>;
|
|
5
|
+
export declare function omit<TObj extends Object, TKeys extends keyof TObj>(obj: TObj, ...keys: TKeys[]): Omit<TObj, TKeys>;
|
|
6
|
+
export declare function omitNullEntries<TObj extends Object>(obj: TObj): {
|
|
7
|
+
[K in keyof TObj]: TObj[K] extends null ? never : K;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { BasePoint, BaseRange, Node } from 'slate';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
import { InsertDelta, RelativeRange } from '../module/custom-types';
|
|
4
|
-
export declare const STORED_POSITION_PREFIX = "__slateYjsStoredPosition_";
|
|
5
|
-
export declare function slatePointToRelativePosition(sharedRoot: Y.XmlText, slateRoot: Node, point: BasePoint): Y.RelativePosition;
|
|
6
|
-
export declare function absolutePositionToSlatePoint(sharedRoot: Y.XmlText, slateRoot: Node, { type, index, assoc }: Y.AbsolutePosition): BasePoint | null;
|
|
7
|
-
export declare function relativePositionToSlatePoint(sharedRoot: Y.XmlText, slateRoot: Node, pos: Y.RelativePosition): BasePoint | null;
|
|
8
|
-
export declare function getStoredPosition(sharedRoot: Y.XmlText, key: string): Y.RelativePosition | null;
|
|
9
|
-
export declare function getStoredPositions(sharedRoot: Y.XmlText): Record<string, Y.RelativePosition>;
|
|
10
|
-
export declare function removeStoredPosition(sharedRoot: Y.XmlText, key: string): void;
|
|
11
|
-
export declare function setStoredPosition(sharedRoot: Y.XmlText, key: string, position: Y.RelativePosition): void;
|
|
12
|
-
export declare function getStoredPositionsInDeltaAbsolute(sharedRoot: Y.XmlText, yText: Y.XmlText, delta: InsertDelta, deltaOffset?: number): {
|
|
13
|
-
'': {
|
|
14
|
-
[k: string]: Y.AbsolutePosition;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export declare function restoreStoredPositionsWithDeltaAbsolute(sharedRoot: Y.XmlText, yText: Y.XmlText, absolutePositions: Record<string, Record<string, Y.AbsolutePosition>>, delta: InsertDelta, newDeltaOffset?: number, previousDeltaOffset?: number, path?: string): void;
|
|
18
|
-
export declare function slateRangeToRelativeRange(sharedRoot: Y.XmlText, slateRoot: Node, range: BaseRange): RelativeRange;
|
|
19
|
-
export declare function relativeRangeToSlateRange(sharedRoot: Y.XmlText, slateRoot: Node, range: RelativeRange): BaseRange | null;
|
|
1
|
+
import { BasePoint, BaseRange, Node } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
import { InsertDelta, RelativeRange } from '../module/custom-types';
|
|
4
|
+
export declare const STORED_POSITION_PREFIX = "__slateYjsStoredPosition_";
|
|
5
|
+
export declare function slatePointToRelativePosition(sharedRoot: Y.XmlText, slateRoot: Node, point: BasePoint): Y.RelativePosition;
|
|
6
|
+
export declare function absolutePositionToSlatePoint(sharedRoot: Y.XmlText, slateRoot: Node, { type, index, assoc }: Y.AbsolutePosition): BasePoint | null;
|
|
7
|
+
export declare function relativePositionToSlatePoint(sharedRoot: Y.XmlText, slateRoot: Node, pos: Y.RelativePosition): BasePoint | null;
|
|
8
|
+
export declare function getStoredPosition(sharedRoot: Y.XmlText, key: string): Y.RelativePosition | null;
|
|
9
|
+
export declare function getStoredPositions(sharedRoot: Y.XmlText): Record<string, Y.RelativePosition>;
|
|
10
|
+
export declare function removeStoredPosition(sharedRoot: Y.XmlText, key: string): void;
|
|
11
|
+
export declare function setStoredPosition(sharedRoot: Y.XmlText, key: string, position: Y.RelativePosition): void;
|
|
12
|
+
export declare function getStoredPositionsInDeltaAbsolute(sharedRoot: Y.XmlText, yText: Y.XmlText, delta: InsertDelta, deltaOffset?: number): {
|
|
13
|
+
'': {
|
|
14
|
+
[k: string]: Y.AbsolutePosition;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function restoreStoredPositionsWithDeltaAbsolute(sharedRoot: Y.XmlText, yText: Y.XmlText, absolutePositions: Record<string, Record<string, Y.AbsolutePosition>>, delta: InsertDelta, newDeltaOffset?: number, previousDeltaOffset?: number, path?: string): void;
|
|
18
|
+
export declare function slateRangeToRelativeRange(sharedRoot: Y.XmlText, slateRoot: Node, range: BaseRange): RelativeRange;
|
|
19
|
+
export declare function relativeRangeToSlateRange(sharedRoot: Y.XmlText, slateRoot: Node, range: RelativeRange): BaseRange | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BaseText, Descendant } from 'slate';
|
|
2
|
-
export declare function getProperties<TNode extends Descendant>(node: TNode): Omit<TNode, TNode extends BaseText ? 'text' : 'children'>;
|
|
1
|
+
import { BaseText, Descendant } from 'slate';
|
|
2
|
+
export declare function getProperties<TNode extends Descendant>(node: TNode): Omit<TNode, TNode extends BaseText ? 'text' : 'children'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as Y from 'yjs';
|
|
2
|
-
export declare function assertDocumentAttachment<T extends Y.AbstractType<any>>(sharedType: T): asserts sharedType is T & {
|
|
3
|
-
doc: NonNullable<T['doc']>;
|
|
4
|
-
};
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
export declare function assertDocumentAttachment<T extends Y.AbstractType<any>>(sharedType: T): asserts sharedType is T & {
|
|
3
|
+
doc: NonNullable<T['doc']>;
|
|
4
|
+
};
|