@slate-yjs/core 0.2.0 → 0.2.1
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.md +3 -0
- package/dist/applyToSlate/index.d.ts +2 -2
- package/dist/applyToSlate/index.d.ts.map +1 -1
- package/dist/applyToSlate/index.js +3 -1
- package/dist/applyToSlate/index.js.map +1 -1
- package/dist/applyToSlate/textEvent.d.ts.map +1 -1
- package/dist/applyToSlate/textEvent.js +17 -15
- package/dist/applyToSlate/textEvent.js.map +1 -1
- package/dist/applyToYjs/node/splitNode.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/plugins/withCursors.js +30 -29
- package/dist/plugins/withCursors.js.map +1 -1
- package/dist/plugins/withYHistory.js +20 -10
- package/dist/plugins/withYHistory.js.map +1 -1
- package/dist/plugins/withYjs.d.ts +2 -2
- package/dist/plugins/withYjs.d.ts.map +1 -1
- package/dist/plugins/withYjs.js +60 -38
- package/dist/plugins/withYjs.js.map +1 -1
- package/dist/utils/delta.d.ts +1 -0
- package/dist/utils/delta.d.ts.map +1 -1
- package/dist/utils/delta.js +26 -1
- package/dist/utils/delta.js.map +1 -1
- package/dist/utils/object.d.ts +7 -4
- package/dist/utils/object.d.ts.map +1 -1
- package/dist/utils/object.js +54 -15
- package/dist/utils/object.js.map +1 -1
- package/dist/utils/slate.js.map +1 -1
- package/package.json +5 -5
- package/src/applyToSlate/index.ts +2 -2
- package/src/applyToSlate/textEvent.ts +21 -20
- package/src/plugins/withYjs.ts +13 -4
- package/src/utils/delta.ts +36 -1
- package/src/utils/object.ts +65 -20
- package/test/collaboration/addMark/acrossMarks.tsx +40 -0
- package/test/collaboration/addMark/acrossMarksSame.tsx +36 -0
- package/test/collaboration/addMark/atBeginningOfDocument.tsx +27 -0
- package/test/collaboration/addMark/atEndOfDocument.tsx +30 -0
- package/test/collaboration/addMark/withOtherMarks.tsx +31 -0
- package/test/collaboration/insertNode/atBeginningOfDocument.tsx +28 -0
- package/test/collaboration/insertNode/atEndOfDocument.tsx +28 -0
- package/test/collaboration/insertNode/inTheMiddle.tsx +30 -0
- package/test/collaboration/insertText/atBeginningOfBlock.tsx +26 -0
- package/test/collaboration/insertText/atBeginningOfDocument.tsx +26 -0
- package/test/collaboration/insertText/atEndOfBlock.tsx +26 -0
- package/test/collaboration/insertText/atEndOfDocument.tsx +26 -0
- package/test/collaboration/insertText/inTheMiddle.tsx +32 -0
- package/test/collaboration/insertText/inTheMiddleOfNestedBlock.tsx +30 -0
- package/test/collaboration/insertText/insideMarks.tsx +28 -0
- package/test/collaboration/insertText/withEmptyString.tsx +25 -0
- package/test/collaboration/insertText/withEntities.tsx +28 -0
- package/test/collaboration/insertText/withMarks.tsx +25 -0
- package/test/collaboration/insertText/withUnicode.tsx +28 -0
- package/test/collaboration/mergeNode/afterADeleteBackward.tsx +27 -0
- package/test/collaboration/mergeNode/onMixedNestedNodes.tsx +29 -0
- package/test/collaboration/mergeNode/onMixedTypeNodes.tsx +27 -0
- package/test/collaboration/mergeNode/withUnicode.tsx +25 -0
- package/test/collaboration/moveNode/downward/whenBlockBecomesNested.tsx +43 -0
- package/test/collaboration/moveNode/downward/whenBlockBecomesNonNested.tsx +41 -0
- package/test/collaboration/moveNode/downward/whenBlockStaysNested.tsx +38 -0
- package/test/collaboration/moveNode/downward/whenBlockStaysNonNested.tsx +30 -0
- package/test/collaboration/moveNode/upward/whenBlockBecomesNested.tsx +43 -0
- package/test/collaboration/moveNode/upward/whenBlockBecomesNonNested.tsx +41 -0
- package/test/collaboration/moveNode/upward/whenBlockStaysNested.tsx +38 -0
- package/test/collaboration/moveNode/upward/whenBlockStaysNonNested.tsx +30 -0
- package/test/collaboration/removeMark/inTheMiddleOfText.tsx +43 -0
- package/test/collaboration/removeMark/withAddMark.tsx +31 -0
- package/test/collaboration/removeMark/withOtherMarks.tsx +47 -0
- package/test/collaboration/removeNode/atBeginningOfDocument.tsx +26 -0
- package/test/collaboration/removeNode/atEndOfDocument.tsx +26 -0
- package/test/collaboration/removeNode/nestedBlock.tsx +28 -0
- package/test/collaboration/removeNode/wrapperBlock.tsx +28 -0
- package/test/collaboration/removeText/atBeginningOfDocument.tsx +34 -0
- package/test/collaboration/removeText/atEndOfDocument.tsx +37 -0
- package/test/collaboration/removeText/withUnicode.tsx +29 -0
- package/test/collaboration/setNode/atBeginningOfDocument.tsx +27 -0
- package/test/collaboration/setNode/atEndOfDocument.tsx +27 -0
- package/test/collaboration/setNode/onDataChange.tsx +35 -0
- package/test/collaboration/setNode/onDataChangeOnInline.tsx +35 -0
- package/test/collaboration/setNode/onResetBlock.tsx +27 -0
- package/test/collaboration/setNode/withAChangeOfType.tsx +26 -0
- package/test/collaboration/splitNode/atBeginningOfDocument.tsx +28 -0
- package/test/collaboration/splitNode/atEndOfBlock.tsx +27 -0
- package/test/collaboration/splitNode/atEndOfDocument.tsx +27 -0
- package/test/collaboration/splitNode/onNonDefaultBlock.tsx +27 -0
- package/test/collaboration/splitNode/withMultipleSubNodes.tsx +32 -0
- package/test/collaboration/splitNode/withUnicode.tsx +29 -0
- package/test/index.test.ts +66 -0
- package/test/{types.d.ts → slate.d.ts} +0 -0
- package/test/withTestingElements.ts +46 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/test/collaboration.test.ts +0 -395
- package/test/concurrent.test.ts +0 -233
- package/test/testEditor.ts +0 -134
- package/test/utils.ts +0 -64
package/src/plugins/withYjs.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type YjsEditor = BaseEditor & {
|
|
|
32
32
|
localOrigin: unknown;
|
|
33
33
|
positionStorageOrigin: unknown;
|
|
34
34
|
|
|
35
|
-
applyRemoteEvents: (events: Y.YEvent[], origin: unknown) => void;
|
|
35
|
+
applyRemoteEvents: (events: Y.YEvent<Y.XmlText>[], origin: unknown) => void;
|
|
36
36
|
|
|
37
37
|
storeLocalChange: (op: Operation) => void;
|
|
38
38
|
flushLocalChanges: () => void;
|
|
@@ -65,7 +65,7 @@ export const YjsEditor = {
|
|
|
65
65
|
|
|
66
66
|
applyRemoteEvents(
|
|
67
67
|
editor: YjsEditor,
|
|
68
|
-
events: Y.YEvent[],
|
|
68
|
+
events: Y.YEvent<Y.XmlText>[],
|
|
69
69
|
origin: unknown
|
|
70
70
|
): void {
|
|
71
71
|
editor.applyRemoteEvents(events, origin);
|
|
@@ -84,6 +84,10 @@ export const YjsEditor = {
|
|
|
84
84
|
},
|
|
85
85
|
|
|
86
86
|
connect(editor: YjsEditor): void {
|
|
87
|
+
if (YjsEditor.connected(editor)) {
|
|
88
|
+
throw new Error('already connected');
|
|
89
|
+
}
|
|
90
|
+
|
|
87
91
|
editor.connect();
|
|
88
92
|
},
|
|
89
93
|
|
|
@@ -96,7 +100,8 @@ export const YjsEditor = {
|
|
|
96
100
|
},
|
|
97
101
|
|
|
98
102
|
origin(editor: YjsEditor): unknown {
|
|
99
|
-
|
|
103
|
+
const origin = ORIGIN.get(editor);
|
|
104
|
+
return origin !== undefined ? origin : editor.localOrigin;
|
|
100
105
|
},
|
|
101
106
|
|
|
102
107
|
withOrigin(editor: YjsEditor, origin: unknown, fn: () => void): void {
|
|
@@ -181,7 +186,10 @@ export function withYjs<T extends Editor>(
|
|
|
181
186
|
|
|
182
187
|
e.isLocalOrigin = (origin) => origin === e.localOrigin;
|
|
183
188
|
|
|
184
|
-
const handleYEvents = (
|
|
189
|
+
const handleYEvents = (
|
|
190
|
+
events: Y.YEvent<Y.XmlText>[],
|
|
191
|
+
transaction: Y.Transaction
|
|
192
|
+
) => {
|
|
185
193
|
if (e.isLocalOrigin(transaction.origin)) {
|
|
186
194
|
return;
|
|
187
195
|
}
|
|
@@ -241,6 +249,7 @@ export function withYjs<T extends Editor>(
|
|
|
241
249
|
|
|
242
250
|
txGroups.forEach((txGroup) => {
|
|
243
251
|
assertDocumentAttachment(e.sharedRoot);
|
|
252
|
+
|
|
244
253
|
e.sharedRoot.doc.transact(() => {
|
|
245
254
|
txGroup.forEach((change) => {
|
|
246
255
|
assertDocumentAttachment(e.sharedRoot);
|
package/src/utils/delta.ts
CHANGED
|
@@ -1,8 +1,43 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
2
|
import { DeltaInsert, InsertDelta } from '../model/types';
|
|
3
|
+
import { deepEquals } from './object';
|
|
4
|
+
|
|
5
|
+
export function normalizeInsertDelta(delta: InsertDelta): InsertDelta {
|
|
6
|
+
const normalized: InsertDelta = [];
|
|
7
|
+
|
|
8
|
+
for (const element of delta) {
|
|
9
|
+
if (typeof element.insert === 'string' && element.insert.length === 0) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const prev = normalized[normalized.length - 1];
|
|
14
|
+
if (
|
|
15
|
+
!prev ||
|
|
16
|
+
typeof prev.insert !== 'string' ||
|
|
17
|
+
typeof element.insert !== 'string'
|
|
18
|
+
) {
|
|
19
|
+
normalized.push(element);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const merge =
|
|
24
|
+
prev.attributes === element.attributes ||
|
|
25
|
+
(!prev.attributes === !element.attributes &&
|
|
26
|
+
deepEquals(prev.attributes ?? {}, element.attributes ?? {}));
|
|
27
|
+
|
|
28
|
+
if (merge) {
|
|
29
|
+
prev.insert += element.insert;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
normalized.push(element);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return normalized;
|
|
37
|
+
}
|
|
3
38
|
|
|
4
39
|
export function yTextToInsertDelta(yText: Y.XmlText): InsertDelta {
|
|
5
|
-
return yText.toDelta() as InsertDelta;
|
|
40
|
+
return normalizeInsertDelta(yText.toDelta()) as InsertDelta;
|
|
6
41
|
}
|
|
7
42
|
|
|
8
43
|
export function getInsertLength({ insert }: DeltaInsert): number {
|
package/src/utils/object.ts
CHANGED
|
@@ -1,34 +1,72 @@
|
|
|
1
1
|
type InspectableObject = Record<string | number | symbol, unknown>;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
return
|
|
3
|
+
function isObject(o: unknown): o is InspectableObject {
|
|
4
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export function isPlainObject(o: unknown): o is InspectableObject {
|
|
8
|
+
if (!isObject(o)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// If has modified constructor
|
|
13
|
+
const ctor = o.constructor;
|
|
14
|
+
if (ctor === undefined) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
// If has modified prototype
|
|
19
|
+
const prot = ctor.prototype;
|
|
20
|
+
if (isObject(prot) === false) {
|
|
15
21
|
return false;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
// If constructor does not have an Object-specific method
|
|
25
|
+
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Most likely a plain Object
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Slates deep equality function: https://github.com/ianstormtaylor/slate/blob/68aff89e892fe15a16314398ff052ade6068900b/packages/slate/src/utils/deep-equal.ts#L13
|
|
34
|
+
// We have to match slates deepEquals behavior to merge insert deltas in the same way slate does.
|
|
35
|
+
export function deepEquals(
|
|
36
|
+
node: InspectableObject,
|
|
37
|
+
another: InspectableObject
|
|
38
|
+
): boolean {
|
|
39
|
+
// eslint-disable-next-line guard-for-in
|
|
40
|
+
for (const key in node) {
|
|
41
|
+
const a = node[key];
|
|
42
|
+
const b = another[key];
|
|
43
|
+
|
|
44
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
45
|
+
if (!deepEquals(a, b)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
} else if (Array.isArray(a) && Array.isArray(b)) {
|
|
49
|
+
if (a.length !== b.length) return false;
|
|
50
|
+
for (let i = 0; i < a.length; i++) {
|
|
51
|
+
if (a[i] !== b[i]) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} else if (a !== b) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
21
59
|
|
|
22
|
-
|
|
23
|
-
|
|
60
|
+
for (const key in another) {
|
|
61
|
+
if (node[key] === undefined && another[key] !== undefined) {
|
|
62
|
+
return false;
|
|
24
63
|
}
|
|
64
|
+
}
|
|
25
65
|
|
|
26
|
-
|
|
27
|
-
});
|
|
66
|
+
return true;
|
|
28
67
|
}
|
|
29
68
|
|
|
30
|
-
|
|
31
|
-
export function pick<TObj extends {}, TKeys extends keyof TObj>(
|
|
69
|
+
export function pick<TObj, TKeys extends keyof TObj>(
|
|
32
70
|
obj: TObj,
|
|
33
71
|
...keys: TKeys[]
|
|
34
72
|
): Pick<TObj, TKeys> {
|
|
@@ -37,8 +75,7 @@ export function pick<TObj extends {}, TKeys extends keyof TObj>(
|
|
|
37
75
|
) as Pick<TObj, TKeys>;
|
|
38
76
|
}
|
|
39
77
|
|
|
40
|
-
|
|
41
|
-
export function omit<TObj extends {}, TKeys extends keyof TObj>(
|
|
78
|
+
export function omit<TObj, TKeys extends keyof TObj>(
|
|
42
79
|
obj: TObj,
|
|
43
80
|
...keys: TKeys[]
|
|
44
81
|
): Omit<TObj, TKeys> {
|
|
@@ -46,3 +83,11 @@ export function omit<TObj extends {}, TKeys extends keyof TObj>(
|
|
|
46
83
|
Object.entries(obj).filter(([key]) => !keys.includes(key as TKeys))
|
|
47
84
|
) as Omit<TObj, TKeys>;
|
|
48
85
|
}
|
|
86
|
+
|
|
87
|
+
export function omitNullEntries<TObj>(obj: TObj): {
|
|
88
|
+
[K in keyof TObj]: TObj[K] extends null ? never : K;
|
|
89
|
+
} {
|
|
90
|
+
return Object.fromEntries(
|
|
91
|
+
Object.entries(obj).filter(([, value]) => value !== null)
|
|
92
|
+
) as { [K in keyof TObj]: TObj[K] extends null ? never : K };
|
|
93
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
<text>
|
|
9
|
+
Hel
|
|
10
|
+
<anchor />l
|
|
11
|
+
</text>
|
|
12
|
+
<text bold>o</text>
|
|
13
|
+
<text>
|
|
14
|
+
{' '}
|
|
15
|
+
w<focus />
|
|
16
|
+
orld!
|
|
17
|
+
</text>
|
|
18
|
+
</unstyled>
|
|
19
|
+
</editor>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const expected = (
|
|
23
|
+
<editor>
|
|
24
|
+
<unstyled>
|
|
25
|
+
<text>Hel</text>
|
|
26
|
+
<anchor />
|
|
27
|
+
<text italic>l</text>
|
|
28
|
+
<text italic bold>
|
|
29
|
+
o
|
|
30
|
+
</text>
|
|
31
|
+
<text italic> w</text>
|
|
32
|
+
<focus />
|
|
33
|
+
<text>orld!</text>
|
|
34
|
+
</unstyled>
|
|
35
|
+
</editor>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export function run(editor: Editor) {
|
|
39
|
+
editor.addMark('italic', true);
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
<text>
|
|
9
|
+
Hel
|
|
10
|
+
<anchor />l
|
|
11
|
+
</text>
|
|
12
|
+
<text bold>o</text>
|
|
13
|
+
<text>
|
|
14
|
+
{' '}
|
|
15
|
+
w<focus />
|
|
16
|
+
orld!
|
|
17
|
+
</text>
|
|
18
|
+
</unstyled>
|
|
19
|
+
</editor>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const expected = (
|
|
23
|
+
<editor>
|
|
24
|
+
<unstyled>
|
|
25
|
+
<text>Hel</text>
|
|
26
|
+
<anchor />
|
|
27
|
+
<text bold>lo w</text>
|
|
28
|
+
<focus />
|
|
29
|
+
<text>orld!</text>
|
|
30
|
+
</unstyled>
|
|
31
|
+
</editor>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export function run(editor: Editor) {
|
|
35
|
+
editor.addMark('bold', true);
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
<anchor />
|
|
9
|
+
Hello
|
|
10
|
+
<focus /> world!
|
|
11
|
+
</unstyled>
|
|
12
|
+
</editor>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const expected = (
|
|
16
|
+
<editor>
|
|
17
|
+
<unstyled>
|
|
18
|
+
<anchor />
|
|
19
|
+
<text bold>Hello</text>
|
|
20
|
+
<focus /> world!
|
|
21
|
+
</unstyled>
|
|
22
|
+
</editor>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export function run(editor: Editor) {
|
|
26
|
+
editor.addMark('bold', true);
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
Hello <anchor />
|
|
9
|
+
world!
|
|
10
|
+
<focus />
|
|
11
|
+
</unstyled>
|
|
12
|
+
</editor>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const expected = (
|
|
16
|
+
<editor>
|
|
17
|
+
<unstyled>
|
|
18
|
+
Hello{' '}
|
|
19
|
+
<text bold>
|
|
20
|
+
<anchor />
|
|
21
|
+
world!
|
|
22
|
+
</text>
|
|
23
|
+
<focus />
|
|
24
|
+
</unstyled>
|
|
25
|
+
</editor>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export function run(editor: Editor) {
|
|
29
|
+
editor.addMark('bold', true);
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
<anchor />
|
|
9
|
+
<text italic>Hello world</text>
|
|
10
|
+
<focus />
|
|
11
|
+
<text bold>!</text>
|
|
12
|
+
</unstyled>
|
|
13
|
+
</editor>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const expected = (
|
|
17
|
+
<editor>
|
|
18
|
+
<unstyled>
|
|
19
|
+
<anchor />
|
|
20
|
+
<text italic bold>
|
|
21
|
+
Hello world
|
|
22
|
+
</text>
|
|
23
|
+
<focus />
|
|
24
|
+
<text bold>!</text>
|
|
25
|
+
</unstyled>
|
|
26
|
+
</editor>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export function run(editor: Editor) {
|
|
30
|
+
editor.addMark('bold', true);
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
<cursor />
|
|
9
|
+
Hello world!
|
|
10
|
+
</unstyled>
|
|
11
|
+
<unstyled>Welcome to slate-yjs!</unstyled>
|
|
12
|
+
</editor>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const expected = (
|
|
16
|
+
<editor>
|
|
17
|
+
<h1>
|
|
18
|
+
Foo bar!
|
|
19
|
+
<cursor />
|
|
20
|
+
</h1>
|
|
21
|
+
<unstyled>Hello world!</unstyled>
|
|
22
|
+
<unstyled>Welcome to slate-yjs!</unstyled>
|
|
23
|
+
</editor>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export function run(editor: Editor) {
|
|
27
|
+
editor.insertNode(<h1>Foo bar!</h1>);
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>Hello world!</unstyled>
|
|
8
|
+
<unstyled>
|
|
9
|
+
Welcome to slate-yjs!
|
|
10
|
+
<cursor />
|
|
11
|
+
</unstyled>
|
|
12
|
+
</editor>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const expected = (
|
|
16
|
+
<editor>
|
|
17
|
+
<unstyled>Hello world!</unstyled>
|
|
18
|
+
<unstyled>Welcome to slate-yjs!</unstyled>
|
|
19
|
+
<h1>
|
|
20
|
+
Foo bar!
|
|
21
|
+
<cursor />
|
|
22
|
+
</h1>
|
|
23
|
+
</editor>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export function run(editor: Editor) {
|
|
27
|
+
editor.insertNode(<h1>Foo bar!</h1>);
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>Hello world!</unstyled>
|
|
8
|
+
<unstyled>
|
|
9
|
+
Welcome
|
|
10
|
+
<cursor />
|
|
11
|
+
to slate-yjs!
|
|
12
|
+
</unstyled>
|
|
13
|
+
</editor>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const expected = (
|
|
17
|
+
<editor>
|
|
18
|
+
<unstyled>Hello world!</unstyled>
|
|
19
|
+
<unstyled>Welcome</unstyled>
|
|
20
|
+
<h1>
|
|
21
|
+
Foo bar!
|
|
22
|
+
<cursor />
|
|
23
|
+
</h1>
|
|
24
|
+
<unstyled>to slate-yjs!</unstyled>
|
|
25
|
+
</editor>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export function run(editor: Editor) {
|
|
29
|
+
editor.insertNode(<h1>Foo bar!</h1>);
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>Hello world!</unstyled>
|
|
8
|
+
<unstyled>
|
|
9
|
+
<cursor />
|
|
10
|
+
</unstyled>
|
|
11
|
+
</editor>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const expected = (
|
|
15
|
+
<editor>
|
|
16
|
+
<unstyled>Hello world!</unstyled>
|
|
17
|
+
<unstyled>
|
|
18
|
+
Welcome to slate-yjs!
|
|
19
|
+
<cursor />
|
|
20
|
+
</unstyled>
|
|
21
|
+
</editor>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export function run(editor: Editor) {
|
|
25
|
+
editor.insertText('Welcome to slate-yjs!');
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
<cursor />
|
|
9
|
+
</unstyled>
|
|
10
|
+
<unstyled>Welcome to slate-yjs!</unstyled>
|
|
11
|
+
</editor>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const expected = (
|
|
15
|
+
<editor>
|
|
16
|
+
<unstyled>
|
|
17
|
+
Hello world!
|
|
18
|
+
<cursor />
|
|
19
|
+
</unstyled>
|
|
20
|
+
<unstyled>Welcome to slate-yjs!</unstyled>
|
|
21
|
+
</editor>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export function run(editor: Editor) {
|
|
25
|
+
editor.insertText('Hello world!');
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
Hello <cursor />
|
|
9
|
+
</unstyled>
|
|
10
|
+
<unstyled>Welcome to slate-yjs!</unstyled>
|
|
11
|
+
</editor>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const expected = (
|
|
15
|
+
<editor>
|
|
16
|
+
<unstyled>
|
|
17
|
+
Hello world!
|
|
18
|
+
<cursor />
|
|
19
|
+
</unstyled>
|
|
20
|
+
<unstyled>Welcome to slate-yjs!</unstyled>
|
|
21
|
+
</editor>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export function run(editor: Editor) {
|
|
25
|
+
editor.insertText('world!');
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>Hello world!</unstyled>
|
|
8
|
+
<unstyled>
|
|
9
|
+
Welcome to <cursor />
|
|
10
|
+
</unstyled>
|
|
11
|
+
</editor>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const expected = (
|
|
15
|
+
<editor>
|
|
16
|
+
<unstyled>Hello world!</unstyled>
|
|
17
|
+
<unstyled>
|
|
18
|
+
Welcome to slate-yjs!
|
|
19
|
+
<cursor />
|
|
20
|
+
</unstyled>
|
|
21
|
+
</editor>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export function run(editor: Editor) {
|
|
25
|
+
editor.insertText('slate-yjs!');
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
Hello <cursor />!
|
|
9
|
+
</unstyled>
|
|
10
|
+
</editor>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const expected = (
|
|
14
|
+
<editor>
|
|
15
|
+
<unstyled>
|
|
16
|
+
Hello world
|
|
17
|
+
<cursor />!
|
|
18
|
+
</unstyled>
|
|
19
|
+
</editor>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const inputRemoteEditor = (
|
|
23
|
+
<editor>
|
|
24
|
+
<unstyled>
|
|
25
|
+
Hello !<cursor />
|
|
26
|
+
</unstyled>
|
|
27
|
+
</editor>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export function run(editor: Editor) {
|
|
31
|
+
editor.insertText('world');
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<ul>
|
|
8
|
+
<ul-li>Hello world!</ul-li>
|
|
9
|
+
<ul-li>
|
|
10
|
+
Welcome to <cursor />
|
|
11
|
+
</ul-li>
|
|
12
|
+
</ul>
|
|
13
|
+
</editor>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const expected = (
|
|
17
|
+
<editor>
|
|
18
|
+
<ul>
|
|
19
|
+
<ul-li>Hello world!</ul-li>
|
|
20
|
+
<ul-li>
|
|
21
|
+
Welcome to slate-yjs!
|
|
22
|
+
<cursor />
|
|
23
|
+
</ul-li>
|
|
24
|
+
</ul>
|
|
25
|
+
</editor>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export function run(editor: Editor) {
|
|
29
|
+
editor.insertText('slate-yjs!');
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { jsx } from '../../../../../support/jsx';
|
|
4
|
+
|
|
5
|
+
export const input = (
|
|
6
|
+
<editor>
|
|
7
|
+
<unstyled>
|
|
8
|
+
<text bold>
|
|
9
|
+
Hello <cursor />!
|
|
10
|
+
</text>
|
|
11
|
+
</unstyled>
|
|
12
|
+
</editor>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const expected = (
|
|
16
|
+
<editor>
|
|
17
|
+
<unstyled>
|
|
18
|
+
<text bold>
|
|
19
|
+
Hello world
|
|
20
|
+
<cursor />!
|
|
21
|
+
</text>
|
|
22
|
+
</unstyled>
|
|
23
|
+
</editor>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export function run(editor: Editor) {
|
|
27
|
+
editor.insertText('world');
|
|
28
|
+
}
|