0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/spec/support/shared_contexts
Renato Atilio ce43d1b189
UX: better rich editor placeholder for non-image and image uploads (#39102)
Previously, all uploads in the rich editor used image placeholder nodes
— even for non-image files like PDFs. This looked broken since a blob
URL for a PDF rendered as a broken image.

This PR introduces a dedicated `upload_placeholder` inline node for
non-image uploads, rendered as a pill with the filename, upload
progress, and a cancel button. Image placeholders now also get a
progress/cancel overlay.

The entire upload lifecycle (insert → progress → resolve/cancel) is
excluded from undo history, so Ctrl+Z never leaves orphaned
placeholders. Deleting a placeholder automatically cancels the in-flight
upload, and duplicates from Option+drag or copy+paste are cleaned up via
`appendTransaction`.

It also fixes a flash of `transparent.png` on image upload completion by
resolving the cached upload URL in the same transaction as the
placeholder replacement.

<img width="275" height="109" alt="image"
src="https://github.com/user-attachments/assets/6b808094-46f9-44db-ad77-6a7714d51587"
/>

<img width="529" height="217" alt="image"
src="https://github.com/user-attachments/assets/3606f992-f6cd-4e88-863e-191c3cc72a9c"
/>

---------

Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
2026-05-20 16:48:51 -03:00
..
prosemirror_editor_context.rb