@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.
Files changed (103) hide show
  1. package/README.md +3 -0
  2. package/dist/applyToSlate/index.d.ts +2 -2
  3. package/dist/applyToSlate/index.d.ts.map +1 -1
  4. package/dist/applyToSlate/index.js +3 -1
  5. package/dist/applyToSlate/index.js.map +1 -1
  6. package/dist/applyToSlate/textEvent.d.ts.map +1 -1
  7. package/dist/applyToSlate/textEvent.js +17 -15
  8. package/dist/applyToSlate/textEvent.js.map +1 -1
  9. package/dist/applyToYjs/node/splitNode.js.map +1 -1
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +1 -3
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.modern.js +1 -1
  15. package/dist/index.modern.js.map +1 -1
  16. package/dist/index.module.js +1 -1
  17. package/dist/index.module.js.map +1 -1
  18. package/dist/index.umd.js +1 -1
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/plugins/withCursors.js +30 -29
  21. package/dist/plugins/withCursors.js.map +1 -1
  22. package/dist/plugins/withYHistory.js +20 -10
  23. package/dist/plugins/withYHistory.js.map +1 -1
  24. package/dist/plugins/withYjs.d.ts +2 -2
  25. package/dist/plugins/withYjs.d.ts.map +1 -1
  26. package/dist/plugins/withYjs.js +60 -38
  27. package/dist/plugins/withYjs.js.map +1 -1
  28. package/dist/utils/delta.d.ts +1 -0
  29. package/dist/utils/delta.d.ts.map +1 -1
  30. package/dist/utils/delta.js +26 -1
  31. package/dist/utils/delta.js.map +1 -1
  32. package/dist/utils/object.d.ts +7 -4
  33. package/dist/utils/object.d.ts.map +1 -1
  34. package/dist/utils/object.js +54 -15
  35. package/dist/utils/object.js.map +1 -1
  36. package/dist/utils/slate.js.map +1 -1
  37. package/package.json +5 -5
  38. package/src/applyToSlate/index.ts +2 -2
  39. package/src/applyToSlate/textEvent.ts +21 -20
  40. package/src/plugins/withYjs.ts +13 -4
  41. package/src/utils/delta.ts +36 -1
  42. package/src/utils/object.ts +65 -20
  43. package/test/collaboration/addMark/acrossMarks.tsx +40 -0
  44. package/test/collaboration/addMark/acrossMarksSame.tsx +36 -0
  45. package/test/collaboration/addMark/atBeginningOfDocument.tsx +27 -0
  46. package/test/collaboration/addMark/atEndOfDocument.tsx +30 -0
  47. package/test/collaboration/addMark/withOtherMarks.tsx +31 -0
  48. package/test/collaboration/insertNode/atBeginningOfDocument.tsx +28 -0
  49. package/test/collaboration/insertNode/atEndOfDocument.tsx +28 -0
  50. package/test/collaboration/insertNode/inTheMiddle.tsx +30 -0
  51. package/test/collaboration/insertText/atBeginningOfBlock.tsx +26 -0
  52. package/test/collaboration/insertText/atBeginningOfDocument.tsx +26 -0
  53. package/test/collaboration/insertText/atEndOfBlock.tsx +26 -0
  54. package/test/collaboration/insertText/atEndOfDocument.tsx +26 -0
  55. package/test/collaboration/insertText/inTheMiddle.tsx +32 -0
  56. package/test/collaboration/insertText/inTheMiddleOfNestedBlock.tsx +30 -0
  57. package/test/collaboration/insertText/insideMarks.tsx +28 -0
  58. package/test/collaboration/insertText/withEmptyString.tsx +25 -0
  59. package/test/collaboration/insertText/withEntities.tsx +28 -0
  60. package/test/collaboration/insertText/withMarks.tsx +25 -0
  61. package/test/collaboration/insertText/withUnicode.tsx +28 -0
  62. package/test/collaboration/mergeNode/afterADeleteBackward.tsx +27 -0
  63. package/test/collaboration/mergeNode/onMixedNestedNodes.tsx +29 -0
  64. package/test/collaboration/mergeNode/onMixedTypeNodes.tsx +27 -0
  65. package/test/collaboration/mergeNode/withUnicode.tsx +25 -0
  66. package/test/collaboration/moveNode/downward/whenBlockBecomesNested.tsx +43 -0
  67. package/test/collaboration/moveNode/downward/whenBlockBecomesNonNested.tsx +41 -0
  68. package/test/collaboration/moveNode/downward/whenBlockStaysNested.tsx +38 -0
  69. package/test/collaboration/moveNode/downward/whenBlockStaysNonNested.tsx +30 -0
  70. package/test/collaboration/moveNode/upward/whenBlockBecomesNested.tsx +43 -0
  71. package/test/collaboration/moveNode/upward/whenBlockBecomesNonNested.tsx +41 -0
  72. package/test/collaboration/moveNode/upward/whenBlockStaysNested.tsx +38 -0
  73. package/test/collaboration/moveNode/upward/whenBlockStaysNonNested.tsx +30 -0
  74. package/test/collaboration/removeMark/inTheMiddleOfText.tsx +43 -0
  75. package/test/collaboration/removeMark/withAddMark.tsx +31 -0
  76. package/test/collaboration/removeMark/withOtherMarks.tsx +47 -0
  77. package/test/collaboration/removeNode/atBeginningOfDocument.tsx +26 -0
  78. package/test/collaboration/removeNode/atEndOfDocument.tsx +26 -0
  79. package/test/collaboration/removeNode/nestedBlock.tsx +28 -0
  80. package/test/collaboration/removeNode/wrapperBlock.tsx +28 -0
  81. package/test/collaboration/removeText/atBeginningOfDocument.tsx +34 -0
  82. package/test/collaboration/removeText/atEndOfDocument.tsx +37 -0
  83. package/test/collaboration/removeText/withUnicode.tsx +29 -0
  84. package/test/collaboration/setNode/atBeginningOfDocument.tsx +27 -0
  85. package/test/collaboration/setNode/atEndOfDocument.tsx +27 -0
  86. package/test/collaboration/setNode/onDataChange.tsx +35 -0
  87. package/test/collaboration/setNode/onDataChangeOnInline.tsx +35 -0
  88. package/test/collaboration/setNode/onResetBlock.tsx +27 -0
  89. package/test/collaboration/setNode/withAChangeOfType.tsx +26 -0
  90. package/test/collaboration/splitNode/atBeginningOfDocument.tsx +28 -0
  91. package/test/collaboration/splitNode/atEndOfBlock.tsx +27 -0
  92. package/test/collaboration/splitNode/atEndOfDocument.tsx +27 -0
  93. package/test/collaboration/splitNode/onNonDefaultBlock.tsx +27 -0
  94. package/test/collaboration/splitNode/withMultipleSubNodes.tsx +32 -0
  95. package/test/collaboration/splitNode/withUnicode.tsx +29 -0
  96. package/test/index.test.ts +66 -0
  97. package/test/{types.d.ts → slate.d.ts} +0 -0
  98. package/test/withTestingElements.ts +46 -0
  99. package/tsconfig.tsbuildinfo +1 -1
  100. package/test/collaboration.test.ts +0 -395
  101. package/test/concurrent.test.ts +0 -233
  102. package/test/testEditor.ts +0 -134
  103. package/test/utils.ts +0 -64
@@ -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
- return ORIGIN.get(editor) ?? editor.localOrigin;
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 = (events: Y.YEvent[], transaction: Y.Transaction) => {
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);
@@ -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 {
@@ -1,34 +1,72 @@
1
1
  type InspectableObject = Record<string | number | symbol, unknown>;
2
2
 
3
- export function isObject(v: unknown): v is InspectableObject {
4
- return v !== null && typeof v === 'object';
3
+ function isObject(o: unknown): o is InspectableObject {
4
+ return Object.prototype.toString.call(o) === '[object Object]';
5
5
  }
6
6
 
7
- export function deepEquals(
8
- obj: InspectableObject,
9
- other: InspectableObject
10
- ): boolean {
11
- const keys1 = Object.keys(obj);
12
- const keys2 = Object.keys(other);
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
- if (keys1.length !== keys2.length) {
18
+ // If has modified prototype
19
+ const prot = ctor.prototype;
20
+ if (isObject(prot) === false) {
15
21
  return false;
16
22
  }
17
23
 
18
- return keys1.every((key) => {
19
- const val1 = obj[key];
20
- const val2 = other[key];
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
- if (!isObject(val1)) {
23
- return val1 === val2;
60
+ for (const key in another) {
61
+ if (node[key] === undefined && another[key] !== undefined) {
62
+ return false;
24
63
  }
64
+ }
25
65
 
26
- return isObject(val2) && deepEquals(val1, val2);
27
- });
66
+ return true;
28
67
  }
29
68
 
30
- // eslint-disable-next-line @typescript-eslint/ban-types
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
- // eslint-disable-next-line @typescript-eslint/ban-types
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
+ }