Skip to content

Commit e5b26a8

Browse files
Merge remote-tracking branch 'origin/main' into faker-name-deprecated
2 parents 173c4ca + 8a8e3a8 commit e5b26a8

File tree

8 files changed

+54
-5
lines changed

8 files changed

+54
-5
lines changed

docs/walkthroughs/collaboration-hocuspocus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ server.listen();
4040

4141
```javascript
4242
import { HocuspocusProvider } from '@hocuspocus/provider';
43-
import { withYHistory, withYjs, YjsEditor, withYHistory } from '@slate-yjs/core';
43+
import { withYjs, YjsEditor, withYHistory } from '@slate-yjs/core';
4444
import React, { useCallback, useEffect, useMemo, useState } from 'react';
4545
import { createEditor, Descendant, Editor, Transforms } from 'slate';
4646
import { Editable, Slate, withReact } from 'slate-react';

examples/backend/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @slate-yjs/example-backend
22

3+
## 0.0.10
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`c453baf`](https://github.com/BitPhinix/slate-yjs/commit/c453baf5c7a720436ee434eda3e93fe16e1482fc)]:
8+
- @slate-yjs/core@1.0.1
9+
310
## 0.0.9
411

512
### Patch Changes

examples/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slate-yjs/example-backend",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"private": true,
55
"type": "module",
66
"scripts": {

examples/frontend/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @slate-yjs/example
22

3+
## 0.0.10
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`c453baf`](https://github.com/BitPhinix/slate-yjs/commit/c453baf5c7a720436ee434eda3e93fe16e1482fc)]:
8+
- @slate-yjs/core@1.0.1
9+
310
## 0.0.9
411

512
### Patch Changes

examples/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slate-yjs/example",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"private": true,
55
"scripts": {
66
"dev": "vite",

packages/core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @slate-yjs/core
22

3+
## 1.0.1
4+
5+
### Patch Changes
6+
7+
- [#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
8+
39
## 1.0.0
410

511
### Minor Changes

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@slate-yjs/core",
33
"sideEffects": false,
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"description": "Yjs binding for Slate.",
66
"keywords": [
77
"slate",

packages/core/src/applyToSlate/textEvent.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,38 @@ function applyDelta(node: Element, slatePath: Path, delta: Delta): Operation[] {
159159
const childPath = [...slatePath, pathOffset];
160160

161161
if (Text.isText(child)) {
162+
const lastOp = ops[ops.length - 1];
163+
164+
/**
165+
* The props that exist at the current path
166+
* Since we're not actually using slate to update the node
167+
* this is a simulation
168+
*/
169+
const currentProps =
170+
lastOp != null && lastOp.type === 'insert_node'
171+
? lastOp.node
172+
: getProperties(child);
173+
174+
let lastPath: Path = [];
175+
176+
if (
177+
lastOp != null &&
178+
(lastOp.type === 'insert_node' ||
179+
lastOp.type === 'insert_text' ||
180+
lastOp.type === 'split_node' ||
181+
lastOp.type === 'set_node')
182+
) {
183+
lastPath = lastOp.path;
184+
}
185+
186+
/**
187+
* If the insert is a string and the attributes are the same as the
188+
* props at the current path, we can just insert a text node
189+
*/
162190
if (
163191
typeof change.insert === 'string' &&
164-
deepEquals(change.attributes ?? {}, getProperties(child))
192+
deepEquals(change.attributes ?? {}, currentProps) &&
193+
Path.equals(childPath, lastPath)
165194
) {
166195
return ops.push({
167196
type: 'insert_text',

0 commit comments

Comments
 (0)