@slate-yjs/core
Advanced tools
Comparing version 1.0.0 to 1.0.1
# @slate-yjs/core | ||
## 1.0.1 | ||
### Patch Changes | ||
- [#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 | ||
## 1.0.0 | ||
@@ -4,0 +10,0 @@ |
@@ -410,3 +410,9 @@ var __defProp = Object.defineProperty; | ||
if (Text4.isText(child)) { | ||
if (typeof change.insert === "string" && deepEquals((_a = change.attributes) != null ? _a : {}, getProperties(child))) { | ||
const lastOp = ops[ops.length - 1]; | ||
const currentProps = lastOp != null && lastOp.type === "insert_node" ? lastOp.node : getProperties(child); | ||
let lastPath = []; | ||
if (lastOp != null && (lastOp.type === "insert_node" || lastOp.type === "insert_text" || lastOp.type === "split_node" || lastOp.type === "set_node")) { | ||
lastPath = lastOp.path; | ||
} | ||
if (typeof change.insert === "string" && deepEquals((_a = change.attributes) != null ? _a : {}, currentProps) && Path2.equals(childPath, lastPath)) { | ||
return ops.push({ | ||
@@ -413,0 +419,0 @@ type: "insert_text", |
{ | ||
"name": "@slate-yjs/core", | ||
"sideEffects": false, | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Yjs binding for Slate.", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -162,5 +162,34 @@ import { Editor, Element, Node, Operation, Path, Text } from 'slate'; | ||
if (Text.isText(child)) { | ||
const lastOp = ops[ops.length - 1]; | ||
/** | ||
* The props that exist at the current path | ||
* Since we're not actually using slate to update the node | ||
* this is a simulation | ||
*/ | ||
const currentProps = | ||
lastOp != null && lastOp.type === 'insert_node' | ||
? lastOp.node | ||
: getProperties(child); | ||
let lastPath: Path = []; | ||
if ( | ||
lastOp != null && | ||
(lastOp.type === 'insert_node' || | ||
lastOp.type === 'insert_text' || | ||
lastOp.type === 'split_node' || | ||
lastOp.type === 'set_node') | ||
) { | ||
lastPath = lastOp.path; | ||
} | ||
/** | ||
* If the insert is a string and the attributes are the same as the | ||
* props at the current path, we can just insert a text node | ||
*/ | ||
if ( | ||
typeof change.insert === 'string' && | ||
deepEquals(change.attributes ?? {}, getProperties(child)) | ||
deepEquals(change.attributes ?? {}, currentProps) && | ||
Path.equals(childPath, lastPath) | ||
) { | ||
@@ -167,0 +196,0 @@ return ops.push({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1752010
16649