text icon indicating copy to clipboard operation
text copied to clipboard

Attachments are formatted together with the next paragraph

Open max-nextcloud opened this issue 3 years ago • 3 comments

Describe the bug When changing the format below an attachment it also affects the attachment itself.

To Reproduce Steps to reproduce the behavior:

  1. Open a text file
  2. Upload an attachment
  3. type somethign below
  4. change format below - heading, list, todo list

Expected behavior The attachment stays the way it is. Formatting only affects the section below

Screencast Bildschirmaufzeichnung vom 08.09.2022, 11:23:23.webm

max-nextcloud avatar Sep 08 '22 09:09 max-nextcloud

I suspect attachments are inline elements and therefor form part of the next paragraph. I think they should be block elements in their own right.

max-nextcloud avatar Sep 08 '22 09:09 max-nextcloud

@eneiluj Do you have an idea about this?

max-nextcloud avatar Sep 08 '22 09:09 max-nextcloud

Seems it is related to #2868

vinicius73 avatar Sep 08 '22 19:09 vinicius73

The reason is that we intentionally set inline: true for image nodes. Not sure whether that's a good thing though, given that images (and attachments) are complex structures with nested div elements anyway in our ImageView.vue.

inline: true in the Image node configuration got introduced by the upgrade to TipTap2, specificially in this commit: edfbb70f1578dad76ff869b9f2ca0f3c027232d2. The commit message says:

Tiptap v1 had inline images. v2 keeps them outside of paragraphs by default. Configure Image node to use inline images as markdownit creates inline images right now.

I'm not sure about the implications of switching to inline: false for image nodes (default in TipTap v2). A quick test at least fixed this bug :wink:

@max-nextcloud, @juliushaertl and @vinicius73 curious about your thoughts :blush:

mejo- avatar Oct 17 '22 10:10 mejo-

As we are using complex render strategies to render attachments, it can't be handled inline mode.

vinicius73 avatar Oct 17 '22 13:10 vinicius73

As we are using complex render strategies to render attachments, it can't be handled inline mode.

I agree. I wonder though, what implications switching from inline to block mode has. Given that markdown-it creates inline images, would that result in modified markdown source code after opening and closing documents with images?

mejo- avatar Oct 17 '22 14:10 mejo-