@slate-yjs/core 1.0.3 → 1.0.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/applyToYjs/node/mergeNode.d.ts.map +1 -1
  3. package/dist/applyToYjs/node/moveNode.d.ts.map +1 -1
  4. package/dist/applyToYjs/node/splitNode.d.ts.map +1 -1
  5. package/dist/index.cjs +60 -36
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.global.js +3851 -5380
  8. package/dist/index.global.js.map +1 -1
  9. package/dist/index.js +60 -36
  10. package/dist/index.js.map +1 -1
  11. package/dist/plugins/withCursors.d.ts.map +1 -1
  12. package/dist/plugins/withYjs.d.ts.map +1 -1
  13. package/dist/utils/clone.d.ts.map +1 -1
  14. package/dist/utils/convert.d.ts.map +1 -1
  15. package/dist/utils/yjs.d.ts +3 -0
  16. package/dist/utils/yjs.d.ts.map +1 -1
  17. package/package.json +10 -5
  18. package/src/applyToYjs/node/mergeNode.ts +2 -3
  19. package/src/applyToYjs/node/moveNode.ts +41 -14
  20. package/src/applyToYjs/node/splitNode.ts +2 -3
  21. package/src/plugins/withCursors.ts +38 -11
  22. package/src/plugins/withYjs.ts +17 -0
  23. package/src/utils/clone.ts +5 -3
  24. package/src/utils/convert.ts +2 -1
  25. package/src/utils/yjs.ts +6 -0
  26. package/test/collaboration/addMark/acrossMarks.tsx +0 -40
  27. package/test/collaboration/addMark/acrossMarksSame.tsx +0 -36
  28. package/test/collaboration/addMark/atBeginningOfDocument.tsx +0 -27
  29. package/test/collaboration/addMark/atEndOfDocument.tsx +0 -30
  30. package/test/collaboration/addMark/withOtherMarks.tsx +0 -31
  31. package/test/collaboration/insertNode/atBeginningOfDocument.tsx +0 -28
  32. package/test/collaboration/insertNode/atEndOfDocument.tsx +0 -28
  33. package/test/collaboration/insertNode/inTheMiddle.tsx +0 -30
  34. package/test/collaboration/insertText/atBeginningOfBlock.tsx +0 -26
  35. package/test/collaboration/insertText/atBeginningOfDocument.tsx +0 -26
  36. package/test/collaboration/insertText/atEndOfBlock.tsx +0 -26
  37. package/test/collaboration/insertText/atEndOfDocument.tsx +0 -26
  38. package/test/collaboration/insertText/inTheMiddle.tsx +0 -32
  39. package/test/collaboration/insertText/inTheMiddleOfNestedBlock.tsx +0 -30
  40. package/test/collaboration/insertText/insideMarks.tsx +0 -28
  41. package/test/collaboration/insertText/withEmptyString.tsx +0 -25
  42. package/test/collaboration/insertText/withEntities.tsx +0 -28
  43. package/test/collaboration/insertText/withMarks.tsx +0 -25
  44. package/test/collaboration/insertText/withUnicode.tsx +0 -28
  45. package/test/collaboration/mergeNode/afterADeleteBackward.tsx +0 -27
  46. package/test/collaboration/mergeNode/inSameParent.tsx +0 -34
  47. package/test/collaboration/mergeNode/onMixedNestedNodes.tsx +0 -29
  48. package/test/collaboration/mergeNode/onMixedTypeNodes.tsx +0 -27
  49. package/test/collaboration/mergeNode/withUnicode.tsx +0 -25
  50. package/test/collaboration/moveNode/downward/whenBlockBecomesNested.tsx +0 -43
  51. package/test/collaboration/moveNode/downward/whenBlockBecomesNonNested.tsx +0 -41
  52. package/test/collaboration/moveNode/downward/whenBlockStaysNested.tsx +0 -38
  53. package/test/collaboration/moveNode/downward/whenBlockStaysNonNested.tsx +0 -30
  54. package/test/collaboration/moveNode/upward/whenBlockBecomesNested.tsx +0 -43
  55. package/test/collaboration/moveNode/upward/whenBlockBecomesNonNested.tsx +0 -41
  56. package/test/collaboration/moveNode/upward/whenBlockStaysNested.tsx +0 -38
  57. package/test/collaboration/moveNode/upward/whenBlockStaysNonNested.tsx +0 -30
  58. package/test/collaboration/removeMark/inTheMiddleOfText.tsx +0 -43
  59. package/test/collaboration/removeMark/withAddMark.tsx +0 -31
  60. package/test/collaboration/removeMark/withOtherMarks.tsx +0 -47
  61. package/test/collaboration/removeNode/atBeginningOfDocument.tsx +0 -26
  62. package/test/collaboration/removeNode/atEndOfDocument.tsx +0 -26
  63. package/test/collaboration/removeNode/nestedBlock.tsx +0 -28
  64. package/test/collaboration/removeNode/wrapperBlock.tsx +0 -28
  65. package/test/collaboration/removeText/atBeginningOfDocument.tsx +0 -34
  66. package/test/collaboration/removeText/atEndOfDocument.tsx +0 -37
  67. package/test/collaboration/removeText/withUnicode.tsx +0 -29
  68. package/test/collaboration/setNode/atBeginningOfDocument.tsx +0 -27
  69. package/test/collaboration/setNode/atEndOfDocument.tsx +0 -27
  70. package/test/collaboration/setNode/onDataChange.tsx +0 -35
  71. package/test/collaboration/setNode/onDataChangeOnInline.tsx +0 -35
  72. package/test/collaboration/setNode/onResetBlock.tsx +0 -27
  73. package/test/collaboration/setNode/withAChangeOfType.tsx +0 -26
  74. package/test/collaboration/splitNode/atBeginningOfDocument.tsx +0 -28
  75. package/test/collaboration/splitNode/atEndOfBlock.tsx +0 -27
  76. package/test/collaboration/splitNode/atEndOfDocument.tsx +0 -27
  77. package/test/collaboration/splitNode/onNonDefaultBlock.tsx +0 -27
  78. package/test/collaboration/splitNode/withMultipleSubNodes.tsx +0 -32
  79. package/test/collaboration/splitNode/withUnicode.tsx +0 -29
  80. package/test/index.test.ts +0 -65
  81. package/test/slate.d.ts +0 -8
  82. package/test/withTestingElements.ts +0 -46
  83. package/tsconfig.json +0 -11
  84. package/tsup.config.ts +0 -32
@@ -1,4 +1,4 @@
1
- import { MoveNodeOperation, Node, Path, Text } from 'slate';
1
+ import { Descendant, MoveNodeOperation, Node, Path, Text } from 'slate';
2
2
  import * as Y from 'yjs';
3
3
  import { Delta } from '../../model/types';
4
4
  import { cloneInsertDeltaDeep } from '../../utils/clone';
@@ -8,25 +8,32 @@ import {
8
8
  getStoredPositionsInDeltaAbsolute,
9
9
  restoreStoredPositionsWithDeltaAbsolute,
10
10
  } from '../../utils/position';
11
+ import { PRESERVE_CONTENT } from '../../utils/yjs';
12
+
13
+ // Returns a copy of root without the node at path. Only the ancestors of the
14
+ // removed node are copied.
15
+ function withoutNode(root: Node, path: Path): Node {
16
+ if (Text.isText(root)) {
17
+ throw new Error('Cannot descend into slate text');
18
+ }
19
+
20
+ const [index, ...rest] = path;
21
+ const children = [...root.children];
22
+ if (rest.length === 0) {
23
+ children.splice(index, 1);
24
+ } else {
25
+ children[index] = withoutNode(children[index], rest) as Descendant;
26
+ }
27
+
28
+ return { ...root, children } as Node;
29
+ }
11
30
 
12
31
  export function moveNode(
13
32
  sharedRoot: Y.XmlText,
14
33
  slateRoot: Node,
15
34
  op: MoveNodeOperation
16
35
  ): void {
17
- const newParentPath = Path.parent(op.newPath);
18
- const newPathOffset = op.newPath[op.newPath.length - 1];
19
- const parent = Node.get(slateRoot, newParentPath);
20
- if (Text.isText(parent)) {
21
- throw new Error('Cannot move slate node into text element');
22
- }
23
- const normalizedNewPath = [
24
- ...newParentPath,
25
- Math.min(newPathOffset, parent.children.length),
26
- ];
27
-
28
36
  const origin = getYTarget(sharedRoot, slateRoot, op.path);
29
- const target = getYTarget(sharedRoot, slateRoot, normalizedNewPath);
30
37
  const insertDelta = cloneInsertDeltaDeep(origin.targetDelta);
31
38
 
32
39
  const storedPositions = getStoredPositionsInDeltaAbsolute(
@@ -40,11 +47,31 @@ export function moveNode(
40
47
  origin.textRange.end - origin.textRange.start
41
48
  );
42
49
 
50
+ // Slate removes the node first and inserts it at Path.transform(path, op)
51
+ // in the remaining tree. Resolve the target the same way, so it matches
52
+ // Yjs after the delete above.
53
+ const rootWithoutNode = withoutNode(slateRoot, op.path);
54
+ const newPath = Path.transform(op.path, op);
55
+ if (!newPath) {
56
+ throw new Error('Cannot resolve the target path of a move');
57
+ }
58
+
59
+ const newParentPath = Path.parent(newPath);
60
+ const parent = Node.get(rootWithoutNode, newParentPath);
61
+ if (Text.isText(parent)) {
62
+ throw new Error('Cannot move slate node into text element');
63
+ }
64
+
65
+ const target = getYTarget(sharedRoot, rootWithoutNode, [
66
+ ...newParentPath,
67
+ Math.min(newPath[newPath.length - 1], parent.children.length),
68
+ ]);
69
+
43
70
  const targetLength = getInsertDeltaLength(yTextToInsertDelta(target.yParent));
44
71
  const deltaApplyYOffset = Math.min(target.textRange.start, targetLength);
45
72
  const applyDelta: Delta = [{ retain: deltaApplyYOffset }, ...insertDelta];
46
73
 
47
- target.yParent.applyDelta(applyDelta, { sanitize: false });
74
+ target.yParent.applyDelta(applyDelta, PRESERVE_CONTENT);
48
75
 
49
76
  restoreStoredPositionsWithDeltaAbsolute(
50
77
  sharedRoot,
@@ -7,6 +7,7 @@ import {
7
7
  getStoredPositionsInDeltaAbsolute,
8
8
  restoreStoredPositionsWithDeltaAbsolute,
9
9
  } from '../../utils/position';
10
+ import { PRESERVE_CONTENT } from '../../utils/yjs';
10
11
 
11
12
  export function splitNode(
12
13
  sharedRoot: Y.XmlText,
@@ -72,9 +73,7 @@ export function splitNode(
72
73
  );
73
74
 
74
75
  const toInsert = new Y.XmlText();
75
- toInsert.applyDelta(clonedDelta, {
76
- sanitize: false,
77
- });
76
+ toInsert.applyDelta(clonedDelta, PRESERVE_CONTENT);
78
77
 
79
78
  Object.entries(op.properties).forEach(([key, value]) => {
80
79
  toInsert.setAttribute(key, value);
@@ -180,11 +180,33 @@ export function withCursors<
180
180
  e.awareness.setLocalStateField(e.cursorDataField, cursorData);
181
181
  };
182
182
 
183
+ // Where the selection was when the cursor was last hidden, or undefined
184
+ // while it's shown. autoSend leaves a hidden cursor hidden until the
185
+ // selection moves away from this point. Relative positions don't change
186
+ // when other clients edit the document.
187
+ let hiddenAt: RelativeRange | null | undefined;
188
+
189
+ const relativeSelection = () =>
190
+ e.selection
191
+ ? slateRangeToRelativeRange(e.sharedRoot, e, e.selection)
192
+ : null;
193
+
194
+ const isSameRange = (a: RelativeRange | null, b: RelativeRange | null) =>
195
+ a === b ||
196
+ (!!a &&
197
+ !!b &&
198
+ Y.compareRelativePositions(a.anchor, b.anchor) &&
199
+ Y.compareRelativePositions(a.focus, b.focus));
200
+
183
201
  e.sendCursorPosition = (range) => {
184
202
  const localState = e.awareness.getLocalState();
185
- const currentRange = localState?.[selectionStateField];
203
+ const currentRange = localState?.[selectionStateField] as
204
+ | RelativeRange
205
+ | null
206
+ | undefined;
186
207
 
187
208
  if (!range) {
209
+ hiddenAt = relativeSelection();
188
210
  if (currentRange) {
189
211
  e.awareness.setLocalStateField(e.selectionStateField, null);
190
212
  }
@@ -192,14 +214,10 @@ export function withCursors<
192
214
  return;
193
215
  }
194
216
 
195
- const { anchor, focus } = slateRangeToRelativeRange(e.sharedRoot, e, range);
196
-
197
- if (
198
- !currentRange ||
199
- !Y.compareRelativePositions(anchor, currentRange) ||
200
- !Y.compareRelativePositions(focus, currentRange)
201
- ) {
202
- e.awareness.setLocalStateField(e.selectionStateField, { anchor, focus });
217
+ hiddenAt = undefined;
218
+ const relativeRange = slateRangeToRelativeRange(e.sharedRoot, e, range);
219
+ if (!currentRange || !isSameRange(relativeRange, currentRange)) {
220
+ e.awareness.setLocalStateField(e.selectionStateField, relativeRange);
203
221
  }
204
222
  };
205
223
 
@@ -246,9 +264,18 @@ export function withCursors<
246
264
  e.onChange = () => {
247
265
  onChange();
248
266
 
249
- if (YjsEditor.connected(e)) {
250
- CursorEditor.sendCursorPosition(e);
267
+ if (!YjsEditor.connected(e)) {
268
+ return;
251
269
  }
270
+
271
+ if (
272
+ hiddenAt !== undefined &&
273
+ isSameRange(relativeSelection(), hiddenAt)
274
+ ) {
275
+ return;
276
+ }
277
+
278
+ CursorEditor.sendCursorPosition(e);
252
279
  };
253
280
  }
254
281
  };
@@ -170,7 +170,18 @@ export function withYjs<T extends Editor>(
170
170
  e.positionStorageOrigin =
171
171
  positionStorageOrigin ?? DEFAULT_POSITION_STORAGE_ORIGIN;
172
172
 
173
+ let warnedAboutQueuedChanges = false;
173
174
  e.applyRemoteEvents = (events, origin) => {
175
+ // Local changes still queued here were recorded against the tree before
176
+ // this remote update, so flushing them can target the wrong nodes. Flush
177
+ // local changes (or call onChange) before applying remote updates.
178
+ if (!warnedAboutQueuedChanges && YjsEditor.localChanges(e).length > 0) {
179
+ warnedAboutQueuedChanges = true;
180
+ // eslint-disable-next-line no-console
181
+ console.warn(
182
+ '[slate-yjs] A remote update was applied while local changes were still queued. Call YjsEditor.flushLocalChanges(editor) before applying remote updates in the same task as local edits, or the document can be corrupted.'
183
+ );
184
+ }
174
185
  YjsEditor.flushLocalChanges(e);
175
186
 
176
187
  Editor.withoutNormalizing(e, () => {
@@ -178,6 +189,12 @@ export function withYjs<T extends Editor>(
178
189
  applyYjsEvents(e.sharedRoot, e, events);
179
190
  });
180
191
  });
192
+
193
+ // Normalizing the remote change can queue local changes. Write them now,
194
+ // while Yjs still matches the tree they were recorded against. If another
195
+ // remote update were applied first, their paths could point at different
196
+ // nodes.
197
+ YjsEditor.flushLocalChanges(e);
181
198
  };
182
199
 
183
200
  e.isLocalOrigin = (origin) => origin === e.localOrigin;
@@ -1,6 +1,7 @@
1
1
  import * as Y from 'yjs';
2
2
  import { InsertDelta } from '../model/types';
3
3
  import { yTextToInsertDelta } from './delta';
4
+ import { PRESERVE_CONTENT } from './yjs';
4
5
 
5
6
  export function cloneInsertDeltaDeep(delta: InsertDelta): InsertDelta {
6
7
  return delta.map((element) => {
@@ -21,9 +22,10 @@ export function cloneDeep(yText: Y.XmlText): Y.XmlText {
21
22
  clone.setAttribute(key, value);
22
23
  });
23
24
 
24
- clone.applyDelta(cloneInsertDeltaDeep(yTextToInsertDelta(yText)), {
25
- sanitize: false,
26
- });
25
+ clone.applyDelta(
26
+ cloneInsertDeltaDeep(yTextToInsertDelta(yText)),
27
+ PRESERVE_CONTENT
28
+ );
27
29
 
28
30
  return clone;
29
31
  }
@@ -3,6 +3,7 @@ import * as Y from 'yjs';
3
3
  import { DeltaInsert, InsertDelta } from '../model/types';
4
4
  import { yTextToInsertDelta } from './delta';
5
5
  import { getProperties } from './slate';
6
+ import { PRESERVE_CONTENT } from './yjs';
6
7
 
7
8
  export function yTextToSlateElement(yText: Y.XmlText): Element {
8
9
  const delta = yTextToInsertDelta(yText);
@@ -43,6 +44,6 @@ export function slateElementToYText({
43
44
  yElement.setAttribute(key, value);
44
45
  });
45
46
 
46
- yElement.applyDelta(slateNodesToInsertDelta(children), { sanitize: false });
47
+ yElement.applyDelta(slateNodesToInsertDelta(children), PRESERVE_CONTENT);
47
48
  return yElement;
48
49
  }
package/src/utils/yjs.ts CHANGED
@@ -8,3 +8,9 @@ export function assertDocumentAttachment<T extends Y.AbstractType<any>>(
8
8
  throw new Error("shared type isn't attached to a document");
9
9
  }
10
10
  }
11
+
12
+ // Options for Y.Text#applyDelta that keep the content exactly as given. Yjs
13
+ // strips a trailing "\n" from the last insert at the end of the text when
14
+ // `sanitize` is false (the reverse of what the name suggests), which drops
15
+ // soft line breaks. See https://github.com/yjs/yjs/issues/848.
16
+ export const PRESERVE_CONTENT = { sanitize: true };
@@ -1,40 +0,0 @@
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
- }
@@ -1,36 +0,0 @@
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
- }
@@ -1,27 +0,0 @@
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
- }
@@ -1,30 +0,0 @@
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
- }
@@ -1,31 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
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
- }
@@ -1,30 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- }
@@ -1,32 +0,0 @@
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
- }