@slate-yjs/core
Advanced tools
Comparing version 1.0.1 to 1.0.2
# @slate-yjs/core | ||
## 1.0.2 | ||
### Patch Changes | ||
- [#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. | ||
## 1.0.1 | ||
@@ -4,0 +10,0 @@ |
@@ -683,8 +683,17 @@ var __defProp = Object.defineProperty; | ||
if (!prev.yTarget || !target.yTarget) { | ||
const { yParent: parent, textRange } = target; | ||
const previousSibling = Node6.get(slateRoot, Path3.previous(op.path)); | ||
if (!Text7.isText(previousSibling)) { | ||
throw new Error("Path points to a y text but not a slate node"); | ||
const { yParent: parent, textRange, slateTarget } = target; | ||
if (!slateTarget) { | ||
throw new Error("Expected Slate target node for merge op."); | ||
} | ||
return parent.format(textRange.start, textRange.start - textRange.end, getProperties(previousSibling)); | ||
const prevSibling = Node6.get(slateRoot, Path3.previous(op.path)); | ||
if (!Text7.isText(prevSibling)) { | ||
throw new Error("Path points to Y.Text but not a Slate text node."); | ||
} | ||
const targetProps = getProperties(slateTarget); | ||
const prevSiblingProps = getProperties(prevSibling); | ||
const unsetProps = Object.keys(targetProps).reduce((acc, key) => { | ||
const prevSiblingHasProp = key in prevSiblingProps; | ||
return prevSiblingHasProp ? acc : __spreadProps(__spreadValues({}, acc), { [key]: null }); | ||
}, {}); | ||
return parent.format(textRange.start, textRange.end - textRange.start, __spreadValues(__spreadValues({}, unsetProps), prevSiblingProps)); | ||
} | ||
@@ -691,0 +700,0 @@ const deltaApplyYOffset = prev.yTarget.length; |
{ | ||
"name": "@slate-yjs/core", | ||
"sideEffects": false, | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Yjs binding for Slate.", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -30,14 +30,23 @@ import { MergeNodeOperation, Node, Path, Text } from 'slate'; | ||
if (!prev.yTarget || !target.yTarget) { | ||
const { yParent: parent, textRange } = target; | ||
const { yParent: parent, textRange, slateTarget } = target; | ||
if (!slateTarget) { | ||
throw new Error('Expected Slate target node for merge op.'); | ||
} | ||
const previousSibling = Node.get(slateRoot, Path.previous(op.path)); | ||
if (!Text.isText(previousSibling)) { | ||
throw new Error('Path points to a y text but not a slate node'); | ||
const prevSibling = Node.get(slateRoot, Path.previous(op.path)); | ||
if (!Text.isText(prevSibling)) { | ||
throw new Error('Path points to Y.Text but not a Slate text node.'); | ||
} | ||
return parent.format( | ||
textRange.start, | ||
textRange.start - textRange.end, | ||
getProperties(previousSibling) | ||
); | ||
const targetProps = getProperties(slateTarget); | ||
const prevSiblingProps = getProperties(prevSibling); | ||
const unsetProps = Object.keys(targetProps).reduce((acc, key) => { | ||
const prevSiblingHasProp = key in prevSiblingProps; | ||
return prevSiblingHasProp ? acc : { ...acc, [key]: null }; | ||
}, {}); | ||
return parent.format(textRange.start, textRange.end - textRange.start, { | ||
...unsetProps, | ||
...prevSiblingProps, | ||
}); | ||
} | ||
@@ -44,0 +53,0 @@ |
@@ -40,3 +40,3 @@ import * as Y from 'yjs'; | ||
export function yTextToInsertDelta(yText: Y.XmlText): InsertDelta { | ||
return normalizeInsertDelta(yText.toDelta()) as InsertDelta; | ||
return normalizeInsertDelta(yText.toDelta()); | ||
} | ||
@@ -43,0 +43,0 @@ |
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
1756880
153
16715