edytor 0.0.5 → 0.0.6
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/edytor.cjs.development.js +256 -176
- package/dist/edytor.cjs.development.js.map +1 -1
- package/dist/edytor.cjs.production.min.js +1 -1
- package/dist/edytor.cjs.production.min.js.map +1 -1
- package/dist/edytor.esm.js +242 -163
- package/dist/edytor.esm.js.map +1 -1
- package/dist/events/onKeyDown.d.ts +67 -0
- package/dist/operations/deleteText.d.ts +1 -1
- package/dist/operations/splitLeaf.d.ts +2 -8
- package/dist/types.d.ts +14 -3
- package/dist/utils/common.d.ts +4 -4
- package/dist/utils/nodes.d.ts +2 -1
- package/dist/utils/selection.d.ts +9 -2
- package/dist/utils/yClasses/EdytorDoc.d.ts +1 -3
- package/dist/yjs/index.d.ts +0 -1
- package/package.json +2 -1
- package/dist/yjs/webrtcProvider.d.ts +0 -11
|
@@ -3,5 +3,5 @@ declare type deleteTextOpts = {
|
|
|
3
3
|
mode: "forward" | "backward" | "none";
|
|
4
4
|
selection?: EdytorSelection;
|
|
5
5
|
};
|
|
6
|
-
export declare const deleteText: (editor: Editor, { mode, selection }: deleteTextOpts) =>
|
|
6
|
+
export declare const deleteText: (editor: Editor, { mode, selection }: deleteTextOpts) => void;
|
|
7
7
|
export {};
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare type splitLeafOperation = {
|
|
4
|
-
yText: YText;
|
|
5
|
-
at: Position;
|
|
6
|
-
};
|
|
7
|
-
export declare const splitLeaf: (editor: Editor | Pick<Editor, "toYJS">, { yText, at }: splitLeafOperation) => void;
|
|
8
|
-
export {};
|
|
1
|
+
import { Editor } from "../types";
|
|
2
|
+
export declare const splitLeaf: (editor: Editor) => void;
|
package/dist/types.d.ts
CHANGED
|
@@ -40,6 +40,14 @@ interface HotKeys {
|
|
|
40
40
|
keys: string;
|
|
41
41
|
mark: Record<string, any>;
|
|
42
42
|
}
|
|
43
|
+
declare type DNDProps = {
|
|
44
|
+
canNest?: (block: YMap<any>, path: number[]) => boolean;
|
|
45
|
+
active: boolean;
|
|
46
|
+
renderIndicator: () => any;
|
|
47
|
+
onExternalDrop?: (files: any) => any;
|
|
48
|
+
accept?: string[];
|
|
49
|
+
afterDrop?: (editor: Editor, from: any, to: any) => void;
|
|
50
|
+
};
|
|
43
51
|
export interface EditorProps extends Record<any, any> {
|
|
44
52
|
allowNesting: boolean;
|
|
45
53
|
children: any;
|
|
@@ -47,10 +55,11 @@ export interface EditorProps extends Record<any, any> {
|
|
|
47
55
|
json?: jsonNode[];
|
|
48
56
|
yarray?: YArray<any>;
|
|
49
57
|
};
|
|
58
|
+
dnd?: DNDProps;
|
|
50
59
|
collaboration: {
|
|
51
60
|
awarenessId?: string;
|
|
52
61
|
awareness?: awarenessProtocol.Awareness;
|
|
53
|
-
url:
|
|
62
|
+
url: string;
|
|
54
63
|
room: string;
|
|
55
64
|
user?: {
|
|
56
65
|
color?: string;
|
|
@@ -71,14 +80,15 @@ export interface EditorProps extends Record<any, any> {
|
|
|
71
80
|
renderBefore?: () => any;
|
|
72
81
|
renderAfter?: () => any;
|
|
73
82
|
onChange?: (editor: Editor) => void;
|
|
74
|
-
renderBlock?: ({ attributes, children, block }: renderBlockProps) => any;
|
|
75
|
-
renderLeaf?: ({ attributes, string, leaf }: renderLeafProps) => any;
|
|
76
83
|
}
|
|
84
|
+
export declare type EditorWithChildren = Pick<Editor, "children">;
|
|
77
85
|
export interface Editor {
|
|
78
86
|
allowNesting: boolean;
|
|
79
87
|
readOnly: boolean;
|
|
80
88
|
editorId: string;
|
|
81
89
|
defaultBlock: string;
|
|
90
|
+
awareness?: awarenessProtocol.Awareness;
|
|
91
|
+
dnd?: DNDProps;
|
|
82
92
|
dropper: Dropper;
|
|
83
93
|
hotkeys?: HotKeys[];
|
|
84
94
|
selection: EdytorSelection;
|
|
@@ -88,6 +98,7 @@ export interface Editor {
|
|
|
88
98
|
undoManager: any;
|
|
89
99
|
editorRef: HTMLDivElement | undefined;
|
|
90
100
|
doc: EdytorDoc;
|
|
101
|
+
toRawText: () => string;
|
|
91
102
|
toJSON: () => jsonNode[];
|
|
92
103
|
ID_TO_NODE: Map<string, YMap<any>>;
|
|
93
104
|
children: YArray<any>;
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { YArray, YMap } from "yjs/dist/src/internals";
|
|
2
|
-
import { Editor } from "../types";
|
|
2
|
+
import { Editor, EditorWithChildren, YLeaf } from "../types";
|
|
3
3
|
export declare const nanoid: () => string;
|
|
4
4
|
declare type YNode = YMap<any>;
|
|
5
5
|
export declare const getNode: (node: any) => YNode;
|
|
6
6
|
export declare const getIndex: (node: YNode) => number;
|
|
7
7
|
export declare const getPath: (node: YNode) => number[];
|
|
8
8
|
export declare const getId: (node: any) => string;
|
|
9
|
-
export declare const getLeafAtPath: (editor: Editor, [start, ...path]: number[]) =>
|
|
9
|
+
export declare const getLeafAtPath: (editor: Editor | EditorWithChildren, [start, ...path]: number[]) => YLeaf;
|
|
10
10
|
export declare const getNodeAtPath: (editor: Editor, [start, ...path]: number[]) => YNode;
|
|
11
11
|
export declare const getContainerAtPath: (editor: Editor, path: number[]) => YArray<any>;
|
|
12
|
-
export declare const traverse: (editor: Editor, cb: (node: YMap<any>, isText: boolean, path: number[]) => void, opts?: {
|
|
12
|
+
export declare const traverse: (editor: Editor | EditorWithChildren, cb: (node: YMap<any>, isText: boolean, path: number[]) => void, opts?: {
|
|
13
13
|
start?: number;
|
|
14
14
|
end?: number;
|
|
15
15
|
}) => void;
|
|
16
|
-
export declare const toString: (editor: Editor) => string;
|
|
16
|
+
export declare const toString: (editor: Editor | EditorWithChildren) => string;
|
|
17
17
|
export {};
|
package/dist/utils/nodes.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { YArray, YMap } from "yjs/dist/src/internals";
|
|
2
2
|
import { Editor } from "../types";
|
|
3
3
|
import { YNode } from "./yClasses";
|
|
4
|
-
export declare const mergeContentWithPrevLeaf: (editor: Editor) =>
|
|
4
|
+
export declare const mergeContentWithPrevLeaf: (editor: Editor) => any[];
|
|
5
5
|
export declare const mergeContentWithNextLeaf: (editor: Editor) => any;
|
|
6
6
|
export declare const deleteNode: (node: any, defaultBlock: string) => void;
|
|
7
7
|
export declare const getNodeContainer: (node: any) => YArray<YNode>;
|
|
@@ -11,3 +11,4 @@ export declare const hasChildren: (node: any) => boolean;
|
|
|
11
11
|
export declare const isNodeEmpty: (node: any) => boolean;
|
|
12
12
|
export declare const isNodeContentEmpty: (node: any) => boolean;
|
|
13
13
|
export declare const copyNode: (node: YNode) => YMap<any>;
|
|
14
|
+
export declare const nodeString: (node: YNode) => string;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { Editor, Position } from "../types";
|
|
2
|
-
import {
|
|
1
|
+
import { Editor, Position, YLeaf } from "../types";
|
|
2
|
+
import { YNode } from ".";
|
|
3
3
|
export declare class EdytorSelection {
|
|
4
4
|
editor: Editor;
|
|
5
5
|
observers: ((selection: EdytorSelection) => void)[];
|
|
6
6
|
container: HTMLDivElement;
|
|
7
|
+
collaborationPosition: {
|
|
8
|
+
node: string;
|
|
9
|
+
leaf: string;
|
|
10
|
+
offset: number;
|
|
11
|
+
};
|
|
7
12
|
start: Position;
|
|
8
13
|
end: Position;
|
|
9
14
|
selectedText: string;
|
|
@@ -13,6 +18,8 @@ export declare class EdytorSelection {
|
|
|
13
18
|
range?: Range;
|
|
14
19
|
boundingRect?: DOMRect;
|
|
15
20
|
edges: {
|
|
21
|
+
startDocument: boolean;
|
|
22
|
+
endDocument: boolean;
|
|
16
23
|
startLeaf: boolean;
|
|
17
24
|
startNode: boolean;
|
|
18
25
|
endLeaf: boolean;
|
|
@@ -10,9 +10,7 @@ export declare type jsonNode = {
|
|
|
10
10
|
data?: object;
|
|
11
11
|
children?: jsonNode[];
|
|
12
12
|
};
|
|
13
|
-
export declare const getContent: (leaf: jsonLeaf) => any;
|
|
14
13
|
export declare const getChildren: ({ type, content, children, ...props }: jsonNode) => YNode;
|
|
15
14
|
export declare class EdytorDoc extends Doc {
|
|
16
|
-
constructor(value?: jsonNode[]);
|
|
17
15
|
}
|
|
18
|
-
export declare const DocFromJson: (value: jsonNode[]) => Doc;
|
|
16
|
+
export declare const DocFromJson: (value: jsonNode[], initialDoc?: Doc) => Doc;
|
package/dist/yjs/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edytor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "the core of edytor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"richtext"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"is-hotkey": "^0.2.0",
|
|
22
22
|
"nanoid": "^3.1.28",
|
|
23
|
+
"simple-peer-light": "^9.10.0",
|
|
23
24
|
"y-protocols": "^1.0.5",
|
|
24
25
|
"y-webrtc": "^10.2.0",
|
|
25
26
|
"y-websocket": "^1.3.16",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Doc } from "yjs";
|
|
2
|
-
declare type WebrtcProviderOptions = {
|
|
3
|
-
signaling: Array<string>;
|
|
4
|
-
password: string | null;
|
|
5
|
-
awareness: any;
|
|
6
|
-
maxConns: number;
|
|
7
|
-
filterBcConns: boolean;
|
|
8
|
-
peerOpts: any;
|
|
9
|
-
};
|
|
10
|
-
export declare const createWebRtcProvider: (doc: Doc, room: string, opts: WebrtcProviderOptions) => void;
|
|
11
|
-
export {};
|