Skip to content

Changing custom attribute of <img> via extend on Image-extension will trigger reload of image and loss of selection ` #5985

Closed Answered by nperez0111
martinmolema asked this question in Questions & Help
Discussion options

You must be logged in to vote

It is a little difficult to understand if this is your issue exactly, but my best interpretation is that because updateAttributes changes the selection, you are seeing unwanted selection events?

It would probably be ideal to change updateAttributes to not mess with selections, but technically this can change behavior of existing commands, so I think we can only change this for the next major version.

In your case, though, I think that you can probably use something like this instead:

    const originalSelection = this.editor.state.selection

    this.editor.chain().updateAttributes('image', { float: float }).command(({ tr }) => {
      tr.setSelection(originalSelection)
      return true

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@martinmolema
Comment options

@nperez0111
Comment options

@martinmolema
Comment options

@nperez0111
Comment options

@martinmolema
Comment options

Answer selected by nperez0111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants