slate-yjs icon indicating copy to clipboard operation
slate-yjs copied to clipboard

Empty text node added when replacing the doc content with the new content

Open Maryam-Yumna opened this issue 2 years ago • 2 comments

Discussed in https://github.com/BitPhinix/slate-yjs/discussions/387

Originally posted by Maryam-Yumna April 11, 2023 There's an extra empty text node added everytime i try to delete all the content in a shared type and insert new content

const versionContent = [
    {
        "type": "p",
        "id": 1681200966756,
        "children": [
            {
                "text": "hi"
            }
        ]
    }
]
sharedType.delete(0, sharedType.length);
const delta = slateNodesToInsertDelta(versionContent);
sharedType.applyDelta(delta);

//expected

 [
    {
        "type": "p",
        "id": 1681200966756,
        "children": [
            {
                "text": "hi"
            }
        ]
]

//result I get

[
    {
        "type": "p",
        "id": 1681200966756,
        "children": [
            {
                "text": "hi"
            }
        ]
    },
    {
        "type": "p",
        "children": [
            {
                "text": ""
            }
        ]
    }
]
```</div>

Maryam-Yumna avatar Apr 11 '23 10:04 Maryam-Yumna

Duplicate of https://github.com/BitPhinix/slate-yjs/issues/385

BitPhinix avatar May 06 '23 17:05 BitPhinix

Nvm, could you provide a repo with a reproduction case?

BitPhinix avatar May 06 '23 17:05 BitPhinix