Updating attributes on the image caused the node to be deselected in tiptap

51 Views Asked by At

I'm developing an image extension but I've run into an issue that causes nodes to be deselected when I update the image properties

import Image from '@tiptap/extension-image';
...
extensions: [
      ...
      Image.configure({
        inline: true,
      }),
    ]

I inserted a picture

editor.chain().focus().setImage({
   src: 'https://xxxx'
 }).run();

and then, after selecting the image,

editor.chain().focus().updateAttributes('image', {
   title: 'Hello'
 }).run();

the bubble menu for my images disappear after each attribute updates,the css class 'ProseMirror-selectednode' is being removed from the node

The node is deselected but shouldn't


my current plan is as follows. I don’t know if it’s right, but it works for me.

editor.chain().focus().updateAttributes('image', {
   title: 'Hello'
 }).setNodeSelection(editor.view.state.selection.anchor).run();
0

There are 0 best solutions below