Post editor: allow previewing diff
https://meta.codidact.com/posts/283027
Just gonna copy that 'cause it's well-asked there:
It's possible to view the differences between two adjacent, existing revisions of a post through the History feature.
Post owners can, of course, make arbitrary edits to posts, save those, and see the results both in terms of the final result as well as such a diff. (Others need the Edit Posts ability for that.)
However, there have been times, at least for me, when it would have been beneficial to be able to clearly see the changes made to a post before committing to those changes in public.
In the Edit interface, could there be some kind of Display Changes feature that would work similarly to the history revision diff, but without having to first save the post publicly? Kind of like doing a Compare before Commit in source code control?
@ArtOfCode- four years ago when the code was pretty different from today, you marked this as hard. Is that still your assessment today?
I would say so. It's not difficult, per se, but it's non-trivial - either involves some sort of client-side JS diffing (which we don't currently have) or a new server side arbitrary diff route - which has its own considerations.
If we had the concept of a rollback (possibly related: https://github.com/codidact/qpixel/pull/1144), then one way to approach it might be to apply the edit in some "pending" state, and then either apply or roll back depending on what the user does. To keep the history from getting noisy we'd want to exclude that pair of edit/rollback (which is where that draft PR comes in). Or maybe that's completely the wrong way to approach it; this needs someone with more experience than me.
I think it's worth discovering where the demand is before planning an approach.
Of the two suggested implementations (JS or server side) only JS supports seeing a live diff during editing. If all that's wanted is a way to see a diff once at the end of editing as a double check, then server side is sufficient if you don't mind having to click something to see the diff. If people want to be able to glance at the diff while deciding what to edit next or what to edit further, then there's no point considering server side approaches, even if they're simpler.
I regularly check the preview during editing, and scroll back and forth between preview and source. I want live previews, though I think slightly delayed ones are a slight improvement over none. Allowing me to switch between previews for old (currently latest post revision) and new (current edit), would also be an improvement over the status quo.