Managing nodes with multiple views

Hi, devs!

In my project I have nodes with multiple views. For example, almost everyone has something similar, I has the image uploader and it has three views:

  1. The dropzone with a placeholder text
  2. The progress bar of loading
  3. The result image + caption

If I understand correctly how the ProseMirror works, I must have three schema types and I must switch them between each other. Am I right? What is the best way to do it? Replace the schema type by using the current selection (like replaceSelectionWith)? The uploading of image is an async action, I think that at the uploading time the selection could change and then we can’t rely on the current selection

You could also use an attribute on a single node type to distinguish between the different states.

To track uploading images and their location, you’ll want a state field, so that you can map their positions through changes.

Do you mean that it’s possible to use one type with three views by using attributes?

“To track uploading images and their location, you’ll want a state field, so that you can map their positions through changes.” - Thank you, I understood it

I did it by adding an unique data-attribute at the creation stage of the first view. And at the time of changing I just find this node by this attribute and get its position at the document and then replace it