Skip to content
Discussion options

You must be logged in to vote

There is a forEach command and a findChildren helper which could make this more readable. This code should create one single transaction:

import { findChildren } from '@tiptap/core'

editor.commands.forEach(ids, (id, { tr, commands }) => {
  const item = findChildren(tr.doc, node => {
    return node.type.name === 'custom_item' && id === node.attrs.uuid
  })?.[0]

  if (!item) {
    return true
  }

  return commands.deleteRange({
    from: item.pos,
    to: item.pos + item.node.nodeSize,
  })
})

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by hanspagel
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants