@wangeditor-next/yjs 6.4.1 → 6.4.3
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.d.ts +124 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -11
- package/dist/yjs/src/applyToSlate/index.d.ts +0 -19
- package/dist/yjs/src/applyToSlate/textEvent.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/index.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/node/index.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/node/insertNode.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/node/mergeNode.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/node/moveNode.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/node/removeNode.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/node/setNode.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/node/splitNode.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/text/index.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/text/insertText.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/text/removeText.d.ts +0 -3
- package/dist/yjs/src/applyToYjs/types.d.ts +0 -8
- package/dist/yjs/src/index.d.ts +0 -6
- package/dist/yjs/src/module/custom-types.d.ts +0 -41
- package/dist/yjs/src/plugins/index.d.ts +0 -6
- package/dist/yjs/src/plugins/withCursors.d.ts +0 -38
- package/dist/yjs/src/plugins/withYHistory.d.ts +0 -19
- package/dist/yjs/src/plugins/withYjs.d.ts +0 -42
- package/dist/yjs/src/utils/clone.d.ts +0 -4
- package/dist/yjs/src/utils/convert.d.ts +0 -7
- package/dist/yjs/src/utils/delta.d.ts +0 -7
- package/dist/yjs/src/utils/location.d.ts +0 -11
- package/dist/yjs/src/utils/object.d.ts +0 -9
- package/dist/yjs/src/utils/position.d.ts +0 -19
- package/dist/yjs/src/utils/slate.d.ts +0 -2
- package/dist/yjs/src/utils/yjs.d.ts +0 -4
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/yjs/src/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CursorEditor, withCursors, withYHistory, withYjs, YHistoryEditor, YjsEditor } from './plugins';
|
|
2
|
-
import { slateNodesToInsertDelta, yTextToSlateElement } from './utils/convert';
|
|
3
|
-
import { relativePositionToSlatePoint, relativeRangeToSlateRange, slatePointToRelativePosition, slateRangeToRelativeRange } from './utils/position';
|
|
4
|
-
export { CursorEditor, relativePositionToSlatePoint, relativeRangeToSlateRange, slateNodesToInsertDelta, slatePointToRelativePosition, slateRangeToRelativeRange, withCursors, withYHistory, withYjs, YHistoryEditor, YjsEditor, yTextToSlateElement, };
|
|
5
|
-
export type { RelativeRange } from './module/custom-types';
|
|
6
|
-
export type { CursorState, CursorStateChangeEvent, RemoteCursorChangeEventListener, WithCursorsOptions, WithYHistoryOptions, WithYjsOptions, } from './plugins';
|
|
@@ -1,41 +0,0 @@
|
|
|
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,6 +0,0 @@
|
|
|
1
|
-
export type { CursorState, CursorStateChangeEvent, RemoteCursorChangeEventListener, WithCursorsOptions, } from './withCursors';
|
|
2
|
-
export { CursorEditor, withCursors, } from './withCursors';
|
|
3
|
-
export type { WithYHistoryOptions } from './withYHistory';
|
|
4
|
-
export { withYHistory, YHistoryEditor, } from './withYHistory';
|
|
5
|
-
export type { WithYjsOptions } from './withYjs';
|
|
6
|
-
export { withYjs, YjsEditor, } from './withYjs';
|
|
@@ -1,38 +0,0 @@
|
|
|
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,19 +0,0 @@
|
|
|
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,42 +0,0 @@
|
|
|
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,7 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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;
|