Skip to content

Visual revisions: Add a code diff view inside the editor - #80314

Merged
priethor merged 11 commits into
trunkfrom
priethor/check-visual-revisions
Aug 3, 2026
Merged

Visual revisions: Add a code diff view inside the editor#80314
priethor merged 11 commits into
trunkfrom
priethor/check-visual-revisions

Conversation

@priethor

@priethor priethor commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What

Closes #77841, part of #79120.

Adds a Code editor option to the block editor revisions screen, showing the selected revision's raw markup and highlighting the lines that were added or removed. The Show changes toggle on the top left switches between the diff and the plain markup.

Why

A visual diff can miss changes to block attributes when the rendered post still looks the same. The code view makes those changes visible in the new revisions screen instead of sending users back to the classic one.

Testing Instructions

  1. Create a post and save two revisions with different paragraph content.
  2. Open Revisions from the Post sidebar.
  3. Open Options and choose Code editor.
  4. Check that the old and new markup are highlighted, then move the slider and confirm the diff updates.
  5. Turn off Show changes and confirm that only the selected revision's markup is shown.
  6. Exit revisions while the Code editor is selected and confirm that the post editor remains in code mode.
  7. Switch back to the Visual editor and confirm that revisions return to the visual view.
  8. With network throttling enabled, reopen Revisions and open Options before the slider finishes loading. Confirm that the focus does not jump to the slider.

Screen recording

Grabacion.de.pantalla.2026-07-15.a.las.15.44.12.mov

I used Codex to implement these changes. I guided the work, tested it, and reviewed the results.

@priethor priethor self-assigned this Jul 15, 2026
@priethor priethor added [Type] Enhancement A suggestion for improvement. [Feature] History History, undo, redo, revisions, autosave. labels Jul 15, 2026
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Size Change: +2.5 kB (+0.03%)

Total Size: 7.77 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 502 kB +1.14 kB (+0.23%)
build/styles/editor/style-rtl.css 31.4 kB +352 B (+1.13%)
build/styles/editor/style-rtl.min.css 26.7 kB +329 B (+1.25%)
build/styles/editor/style.css 31.4 kB +349 B (+1.12%)
build/styles/editor/style.min.css 26.7 kB +330 B (+1.25%)

compressed-size-action

@priethor
priethor force-pushed the priethor/check-visual-revisions branch from 6273318 to 416f1ac Compare July 15, 2026 13:42
@priethor
priethor marked this pull request as ready for review July 15, 2026 13:45
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: priethor <priethor@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: himanshupathak95 <abcd95@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@priethor
priethor requested a review from ellatrix July 16, 2026 15:15
@priethor
priethor force-pushed the priethor/check-visual-revisions branch from 416f1ac to aa7aefd Compare July 16, 2026 15:19
@github-actions

Copy link
Copy Markdown

Flaky tests detected in aa7aefd.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29510630171
📝 Reported issues:

@priethor
priethor force-pushed the priethor/check-visual-revisions branch from aa7aefd to 119821e Compare July 20, 2026 09:27
@priethor
priethor force-pushed the priethor/check-visual-revisions branch from 454e67c to cd34da9 Compare July 27, 2026 15:08
Comment thread packages/editor/src/components/post-revisions-preview/revisions-code-diff.js Outdated
Comment thread packages/editor/src/components/post-revisions-preview/revisions-slider.js Outdated
Comment thread packages/editor/CHANGELOG.md Outdated

@jorgefilipecosta jorgefilipecosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments but things look good and I think it could be merged after the comments are addressed/answred.

/**
* Internal dependencies
*/
import { RevisionsCodeDiff, getCodeDiffRows } from '../revisions-code-diff';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we use for the classic revisions screen? Are we using the same thing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow; do you mean the diffing itself?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just curious if we can keep the content and diffing mostly the same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding content, both compare post_content but the classic screen also diffs the title and excerpt, which this view doesn’t.

The diffing is similar, but classic revisions normalize whitespace first, collapsing blank lines and repeated spaces, and it also highlights changed words within a line, while this view highlights the whole line.

I’ll explore bringing them closer in a follow-up PR to avoid scope creep. 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up to make the content diffing closer to the classic screen, with per-word highlights:
#81273

@priethor
priethor merged commit bb5f06c into trunk Aug 3, 2026
49 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] History History, undo, redo, revisions, autosave. [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual revisions: offer seamless code-diff mode

3 participants