@getguru/slate-yjs-core 1.0.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/CHANGELOG.md +67 -0
- package/README.md +3 -0
- package/dist/applyToSlate/index.d.ts +23 -0
- package/dist/applyToSlate/textEvent.d.ts +4 -0
- package/dist/applyToYjs/index.d.ts +4 -0
- package/dist/applyToYjs/node/index.d.ts +4 -0
- package/dist/applyToYjs/node/insertNode.d.ts +4 -0
- package/dist/applyToYjs/node/mergeNode.d.ts +4 -0
- package/dist/applyToYjs/node/moveNode.d.ts +4 -0
- package/dist/applyToYjs/node/removeNode.d.ts +4 -0
- package/dist/applyToYjs/node/setNode.d.ts +4 -0
- package/dist/applyToYjs/node/splitNode.d.ts +4 -0
- package/dist/applyToYjs/text/index.d.ts +4 -0
- package/dist/applyToYjs/text/insertText.d.ts +4 -0
- package/dist/applyToYjs/text/removeText.d.ts +4 -0
- package/dist/applyToYjs/types.d.ts +9 -0
- package/dist/index.cjs +1360 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.global.js +10365 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +1338 -0
- package/dist/index.js.map +1 -0
- package/dist/model/types.d.ts +38 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/withCursors.d.ts +39 -0
- package/dist/plugins/withYHistory.d.ts +20 -0
- package/dist/plugins/withYjs.d.ts +43 -0
- package/dist/utils/clone.d.ts +5 -0
- package/dist/utils/convert.d.ts +8 -0
- package/dist/utils/delta.d.ts +8 -0
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/location.d.ts +12 -0
- package/dist/utils/object.d.ts +10 -0
- package/dist/utils/position.d.ts +20 -0
- package/dist/utils/slate.d.ts +3 -0
- package/dist/utils/yjs.d.ts +5 -0
- package/package.json +47 -0
- package/src/applyToSlate/index.ts +118 -0
- package/src/applyToSlate/textEvent.ts +280 -0
- package/src/applyToYjs/index.ts +28 -0
- package/src/applyToYjs/node/index.ts +17 -0
- package/src/applyToYjs/node/insertNode.ts +23 -0
- package/src/applyToYjs/node/mergeNode.ts +82 -0
- package/src/applyToYjs/node/moveNode.ts +57 -0
- package/src/applyToYjs/node/removeNode.ts +16 -0
- package/src/applyToYjs/node/setNode.ts +42 -0
- package/src/applyToYjs/node/splitNode.ts +98 -0
- package/src/applyToYjs/text/index.ts +9 -0
- package/src/applyToYjs/text/insertText.ts +27 -0
- package/src/applyToYjs/text/removeText.ts +16 -0
- package/src/applyToYjs/types.ts +12 -0
- package/src/index.ts +47 -0
- package/src/model/types.ts +50 -0
- package/src/plugins/index.ts +3 -0
- package/src/plugins/withCursors.ts +269 -0
- package/src/plugins/withYHistory.ts +183 -0
- package/src/plugins/withYjs.ts +284 -0
- package/src/utils/clone.ts +29 -0
- package/src/utils/convert.ts +48 -0
- package/src/utils/delta.ts +97 -0
- package/src/utils/errors.ts +20 -0
- package/src/utils/location.ts +157 -0
- package/src/utils/object.ts +93 -0
- package/src/utils/position.ts +300 -0
- package/src/utils/slate.ts +11 -0
- package/src/utils/yjs.ts +10 -0
- 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/inSameParent.tsx +34 -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 +65 -0
- package/test/slate.d.ts +8 -0
- package/test/withTestingElements.ts +46 -0
- package/tsconfig.json +11 -0
- package/tsup.config.ts +32 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @slate-yjs/core
|
|
2
|
+
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#411](https://github.com/BitPhinix/slate-yjs/pull/411) [`117c9e5`](https://github.com/BitPhinix/slate-yjs/commit/117c9e504d826ea3ea4e69437f671ada8a44855f) Thanks [@BrentFarese](https://github.com/BrentFarese)! - Patch bug in mergeNode that causes getYTarget to error.
|
|
8
|
+
|
|
9
|
+
## 1.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#402](https://github.com/BitPhinix/slate-yjs/pull/402) [`c453baf`](https://github.com/BitPhinix/slate-yjs/commit/c453baf5c7a720436ee434eda3e93fe16e1482fc) Thanks [@juliankrispel](https://github.com/juliankrispel)! - Fix applyDelta to produce correct slate operations for adjacent text operations
|
|
14
|
+
|
|
15
|
+
## 1.0.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#395](https://github.com/BitPhinix/slate-yjs/pull/395) [`a6a27c8`](https://github.com/BitPhinix/slate-yjs/commit/a6a27c86678656e55ecbf0ba76852545605a0955) Thanks [@BitPhinix](https://github.com/BitPhinix)! - ignore formatting attributes for non-text
|
|
20
|
+
|
|
21
|
+
- [#398](https://github.com/BitPhinix/slate-yjs/pull/398) [`72bbbf3`](https://github.com/BitPhinix/slate-yjs/commit/72bbbf3bb8a3f57762153cbd9a7f689d2b282f0c) Thanks [@gblaketx](https://github.com/gblaketx)! - Fix assoc calculation when creating relative position from a Slate point
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#395](https://github.com/BitPhinix/slate-yjs/pull/395) [`a6a27c8`](https://github.com/BitPhinix/slate-yjs/commit/a6a27c86678656e55ecbf0ba76852545605a0955) Thanks [@BitPhinix](https://github.com/BitPhinix)! - chore: remove unnecessary assertion
|
|
26
|
+
|
|
27
|
+
## 0.3.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#369](https://github.com/BitPhinix/slate-yjs/pull/369) [`aa10864`](https://github.com/BitPhinix/slate-yjs/commit/aa108641f44ca00559124cca8277a7c1e4354c00) Thanks [@BitPhinix](https://github.com/BitPhinix)! - Normalize editor on connect to avoid rendering denormalized state
|
|
32
|
+
|
|
33
|
+
## 0.3.0
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- [#363](https://github.com/BitPhinix/slate-yjs/pull/363) [`3710c48`](https://github.com/BitPhinix/slate-yjs/commit/3710c4887ee89946ace787ba24436d82d95bc856) Thanks [@BitPhinix](https://github.com/BitPhinix)! - Loosen `CursorEditor.isCursorEditor` to not check awareness instance.
|
|
38
|
+
|
|
39
|
+
## 0.2.8
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- [#360](https://github.com/BitPhinix/slate-yjs/pull/360) [`c3c7a44`](https://github.com/BitPhinix/slate-yjs/commit/c3c7a4428fd500a94796747537b87512d9ed3ca6) Thanks [@zarv1k](https://github.com/zarv1k)! - fix: use editor properties in plugin methods
|
|
44
|
+
|
|
45
|
+
## 0.2.7
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- [#358](https://github.com/BitPhinix/slate-yjs/pull/358) [`27d39dd`](https://github.com/BitPhinix/slate-yjs/commit/27d39ddc3cf79797a878d0540f8b2605fcf38988) Thanks [@zarv1k](https://github.com/zarv1k)! - use editor.sharedRoot in connect/disconnect
|
|
50
|
+
|
|
51
|
+
## 0.2.6
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- [#352](https://github.com/BitPhinix/slate-yjs/pull/352) [`3e172a6`](https://github.com/BitPhinix/slate-yjs/commit/3e172a63f6d0a298da26975cb2b6831a02f81f2b) Thanks [@BitPhinix](https://github.com/BitPhinix)! - Throw error in non-static connect call if editor is already connected
|
|
56
|
+
|
|
57
|
+
## 0.2.5
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- [#350](https://github.com/BitPhinix/slate-yjs/pull/350) [`bc90d51`](https://github.com/BitPhinix/slate-yjs/commit/bc90d51b191ae2e13aac40ff986d2fe3c626eac3) Thanks [@AntonNiklasson](https://github.com/AntonNiklasson)! - Decode positions as binary in getStoredPositionsInDeltaAbsolute
|
|
62
|
+
|
|
63
|
+
## 0.2.3
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- [#334](https://github.com/BitPhinix/slate-yjs/pull/334) [`5172e4a`](https://github.com/BitPhinix/slate-yjs/commit/5172e4a0033db41bc3530f227c5371e9ddb22269) Thanks [@BitPhinix](https://github.com/BitPhinix)! - don't autoConnect by default
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Editor, Operation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
/**
|
|
4
|
+
* Translate a yjs event into slate operations. The editor state has to match the
|
|
5
|
+
* yText state before the event occurred.
|
|
6
|
+
*
|
|
7
|
+
* @param sharedType
|
|
8
|
+
* @param op
|
|
9
|
+
*/
|
|
10
|
+
export declare function translateYjsEvent(sharedRoot: Y.XmlText, editor: Editor, event: Y.YEvent<Y.XmlText>): Operation[];
|
|
11
|
+
/**
|
|
12
|
+
* Translates yjs events into slate operations and applies them to the editor. The
|
|
13
|
+
* editor state has to match the yText state before the events occurred.
|
|
14
|
+
*
|
|
15
|
+
* If a sync-skew error occurs (e.g. invalid path due to Yjs/Slate mismatch),
|
|
16
|
+
* the editor is re-synced from the Yjs shared root to recover gracefully.
|
|
17
|
+
*
|
|
18
|
+
* @param sharedRoot
|
|
19
|
+
* @param editor
|
|
20
|
+
* @param events
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyYjsEvents(sharedRoot: Y.XmlText, editor: Editor, events: Y.YEvent<Y.XmlText>[]): void;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node, Operation } from 'slate';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare type ApplyFunc<O extends Operation = Operation> = (sharedRoot: Y.XmlText, slateRoot: Node, op: O) => void;
|
|
4
|
+
export declare type OpMapper<O extends Operation = Operation> = {
|
|
5
|
+
[K in O['type']]: O extends {
|
|
6
|
+
type: K;
|
|
7
|
+
} ? ApplyFunc<O> : never;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|