slate icon indicating copy to clipboard operation
slate copied to clipboard

Cannot get the end point in the node at path [] because it has no end text node.

Open JoseVov opened this issue 9 months ago • 0 comments

Description I'm trying to insert a text in a specific path by using Transform.insertText and I'm receiving the Cannot get the end point in the node at path [] because it has no end text node.

This is the editor's children's structure

[
  {
    "type": "page",
    "id": "WlaRyAtiz",
    "children": [
      {
        "type": "paragraph",
        "id": "HZTuvdih9-",
        "children": [
          {
            "text": "My example text"
          }
        ]
      }
    ]
  },
  {
    "type": "page",
    "id": "bkp8qniab",
    "children": []
  }
]

I'm inserting a custom text in the paragraph

Transforms.insertText(editor, 'Insert custom text', { at: [0, 0] })

Based on this path I'm extracting the endpoint manually to confirm the path using -> Editor.end(editor, path) and the result is `[ 0, 0, 0], which I think is expected since that points directly to the text inside the paragraph.

After spending days on this I realized that if I remove the new/second page from the nodes the error disappears. I think that Slate is ignoring the path that I'm passing [0,0] and Transforms.insertText its always getting the latest node from the editor.children.

Any idea why is this happening?

Environment

  • Slate Version: 0.81.1
  • Slate-react: 0.81.0
  • Operating System: OS
  • Browser: Chrome

JoseVov avatar May 07 '24 16:05 JoseVov