1 year ago

#95761

test-img

user3760959

Confused with Tiptap editor behaviour?

I'm trying Tiptap editor and playing with some dummy code. But I'm confused with the behaviour. Could somebody please help me understand the behaviour ?

Below is the dummy code I'm trying (Below 4 cases were tried individually, just here for mentioning I'm placing them in one code block under same braces) :

const customCommand = () => ({commands, state, editor}) => {

// Doesn't work. Parent node doesn't change
console.log('current node ', state.selection.from)
commands.selectParentNode()
console.log('parent node ', state.selection.from)

// Doesn't work. Parent node doesn't change
console.log('current node ', state.selection.from)
this.editor.commands.selectParentNode()
console.log('parent node ', state.selection.from)

// Doesn't work. Parent node doesn't change
console.log('current node ', this.editor.view.state.selection.from)
commands.selectParentNode()
console.log('parent node ', this.editor.view.state.selection.from)

// Works. Parent Node changes.
console.log('current node ', this.editor.view.state.selection.from)
editor.commands.selectParentNode()
console.log('parent node ', this.editor.view.state.selection.from)

}

javascript

reactjs

typescript

tiptap

prose-mirror

0 Answers

Your Answer

Accepted video resources