Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a08e54c2fc | ||
|
|
2b377cd46d | ||
|
|
df9bfbe778 | ||
|
|
f1ab417570 | ||
|
|
371f2b6d55 | ||
|
|
85a7ad148f | ||
|
|
7ec1b3a19e | ||
|
|
15ea4ee805 |
@@ -100,6 +100,7 @@ are implemented in separate modules.
|
|||||||
| [CodeMirror](https://codemirror.net/) | ✔ | [y-codemirror](https://github.com/yjs/y-codemirror) | [demo](https://demos.yjs.dev/codemirror/codemirror.html) |
|
| [CodeMirror](https://codemirror.net/) | ✔ | [y-codemirror](https://github.com/yjs/y-codemirror) | [demo](https://demos.yjs.dev/codemirror/codemirror.html) |
|
||||||
| [Monaco](https://microsoft.github.io/monaco-editor/) | ✔ | [y-monaco](https://github.com/yjs/y-monaco) | [demo](https://demos.yjs.dev/monaco/monaco.html) |
|
| [Monaco](https://microsoft.github.io/monaco-editor/) | ✔ | [y-monaco](https://github.com/yjs/y-monaco) | [demo](https://demos.yjs.dev/monaco/monaco.html) |
|
||||||
| [Slate](https://github.com/ianstormtaylor/slate) | ✔ | [slate-yjs](https://github.com/bitphinix/slate-yjs) | [demo](https://bitphinix.github.io/slate-yjs-example) |
|
| [Slate](https://github.com/ianstormtaylor/slate) | ✔ | [slate-yjs](https://github.com/bitphinix/slate-yjs) | [demo](https://bitphinix.github.io/slate-yjs-example) |
|
||||||
|
| [valtio](https://github.com/pmndrs/valtio) | | [valtio-yjs](https://github.com/dai-shi/valtio-yjs) | [demo](https://codesandbox.io/s/valtio-yjs-demo-ox3iy) |
|
||||||
|
|
||||||
### Providers
|
### Providers
|
||||||
|
|
||||||
@@ -988,7 +989,7 @@ order of the structs anymore (e.g. if the parent was deleted).
|
|||||||
**Examples:**
|
**Examples:**
|
||||||
|
|
||||||
1. If a user inserts elements in sequence, the struct will be merged into a
|
1. If a user inserts elements in sequence, the struct will be merged into a
|
||||||
single struct. E.g. `array.insert(0, ['a']), array.insert(0, ['b']);` is
|
single struct. E.g. `text.insert(0, 'a'), text.insert(1, 'b');` is
|
||||||
first represented as two structs (`[{id: {client, clock: 0}, content: 'a'},
|
first represented as two structs (`[{id: {client, clock: 0}, content: 'a'},
|
||||||
{id: {client, clock: 1}, content: 'b'}`) and then merged into a single
|
{id: {client, clock: 1}, content: 'b'}`) and then merged into a single
|
||||||
struct: `[{id: {client, clock: 0}, content: 'ab'}]`.
|
struct: `[{id: {client, clock: 0}, content: 'ab'}]`.
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.12",
|
"version": "13.5.13",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.12",
|
"version": "13.5.13",
|
||||||
"description": "Shared Editing Library",
|
"description": "Shared Editing Library",
|
||||||
"main": "./dist/yjs.cjs",
|
"main": "./dist/yjs.cjs",
|
||||||
"module": "./dist/yjs.mjs",
|
"module": "./dist/yjs.mjs",
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export {
|
|||||||
snapshot,
|
snapshot,
|
||||||
emptySnapshot,
|
emptySnapshot,
|
||||||
findRootTypeKey,
|
findRootTypeKey,
|
||||||
|
findIndexSS,
|
||||||
getItem,
|
getItem,
|
||||||
typeListToArraySnapshot,
|
typeListToArraySnapshot,
|
||||||
typeMapGetSnapshot,
|
typeMapGetSnapshot,
|
||||||
|
|||||||
@@ -287,6 +287,9 @@ const sliceStruct = (left, diff) => {
|
|||||||
* @return {Uint8Array}
|
* @return {Uint8Array}
|
||||||
*/
|
*/
|
||||||
export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2) => {
|
export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2) => {
|
||||||
|
if (updates.length === 1) {
|
||||||
|
return updates[0]
|
||||||
|
}
|
||||||
const updateDecoders = updates.map(update => new YDecoder(decoding.createDecoder(update)))
|
const updateDecoders = updates.map(update => new YDecoder(decoding.createDecoder(update)))
|
||||||
let lazyStructDecoders = updateDecoders.map(decoder => new LazyStructReader(decoder, true))
|
let lazyStructDecoders = updateDecoders.map(decoder => new LazyStructReader(decoder, true))
|
||||||
|
|
||||||
@@ -312,8 +315,9 @@ export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = U
|
|||||||
if (dec1.curr.id.client === dec2.curr.id.client) {
|
if (dec1.curr.id.client === dec2.curr.id.client) {
|
||||||
const clockDiff = dec1.curr.id.clock - dec2.curr.id.clock
|
const clockDiff = dec1.curr.id.clock - dec2.curr.id.clock
|
||||||
if (clockDiff === 0) {
|
if (clockDiff === 0) {
|
||||||
|
// @todo remove references to skip since the structDecoders must filter Skips.
|
||||||
return dec1.curr.constructor === dec2.curr.constructor ? 0 : (
|
return dec1.curr.constructor === dec2.curr.constructor ? 0 : (
|
||||||
dec1.curr.constructor === Skip ? 1 : -1
|
dec1.curr.constructor === Skip ? 1 : -1 // we are filtering skips anyway.
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return clockDiff
|
return clockDiff
|
||||||
|
|||||||
Reference in New Issue
Block a user