Replace the doc content with the new content #320
Answered
by
BitPhinix
karthikcodes6
asked this question in
Q&A
-
With slate-yjs I was doing somethig like below to replace the content with new content. Since the shared type changed to XmlText. The code is not working. Any idea how to do this with new version? provider.document.transact(() => {
sharedType.delete(0, sharedType.length - 1);
toSharedType(sharedType, doc);
sharedType.delete(sharedType.length - 1);
}) |
Beta Was this translation helpful? Give feedback.
Answered by
BitPhinix
Mar 30, 2022
Replies: 1 comment
-
You do it in a pretty similar way using the provider.document.transact(() => {
sharedType.delete(0, sharedType.length);
const delta = slateNodesToInsertDelta([
{ type: 'paragraph', children: [{ text: 'Something' }] },
]);
sharedType.applyDelta(delta);
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
BitPhinix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You do it in a pretty similar way using the
slateNodesToInsertDelta
helper: