Hi,I’m developing a Vue application using Tiptap, a rich-text editor framework based on ProseMirror. I’m facing an issue related to programmatically unwrapping (lifting) a node that is wrapped in a blockquote and that uses an extended NodeView.
Here’s my approach:
- Wrapping a node: I can successfully wrap a node with blockquote using the following sequence of commands:
commands.setTextSelection(pos + 1); // in parent component
commands.toggleWrap('blockquote'); // in child component
The setTextSelection()
command is executed in a parent component, and the toggleWrap()
command is in a child component. The blockquote wraps the node as expected.
2.Unwrapping a node: Unwrapping the blockquote node is where the issue lies. I’ve tried using the lift()
method, but it doesn’t seem to be effective:
const { state, editor } = props;
const { doc, tr } = state;
const $pos = doc.resolve(getPos());
if ($pos.parent.hasMarkup(state.schema.nodes.blockquote)) {
const start = $pos.before($pos.depth);
const end = $pos.after($pos.depth);
const range = new NodeRange(doc.resolve(start), doc.resolve(end), 1);
if (tr.lift(range, $pos.depth)) {
editor.updateState(state.apply(tr));
} else {
console.log('Lift operation failed');
}
}
Despite this, the tr.lift()
operation fails and I’m unable to determine why. Notably, if I execute setTextSelection()
and toggleWrap()
within the same component, neither command works as expected. If I manually move the cursor to the line first, toggleWrap()
works to get unWrap well.
I’m seeking guidance on why these issues might be happening. Is there a better way to unwrap nodes or something I’m missing in my current approach? Note that I have extended the blockquote node with a custom NodeView. Any help would be appreciated.