How can I get the siblings of a newly inserted inline?

434 Views Asked by At

The following code doesn't work and I see the first inserted entity only when the code is running the second time:

editor.insertInline({
  key: 'XX',
  data: {},
  nodes: List([
    Text.create({
      'Hello World!',
    })
  ]),
  type: 'deletion',
})

const insertedDeletion = value.document.getInlinesByType('deletion').first()

Immediately after inserting the inline, insertedDeletion is null. Where exactly should I check for the existence of the inline? Is there a callback?

1

There are 1 best solutions below

0
On BEST ANSWER

After further investigating, I found that I need to get the value directly from the editor instance:

const insertedDeletion = editor.value.document.getInlinesByType('deletion').first()