Skip to content

Conversation

@mecskyverse
Copy link
Contributor

@mecskyverse mecskyverse commented Jul 18, 2025

What?

Closes #63824
This PR adds a paste transformer that correctly maps heading tags from Microsoft Word Online to Gutenberg Heading blocks, instead of defaulting to Paragraph blocks.

Why?

Currently, when users copy-paste content from Word Online, all headings are flattened into Paragraph (<p>) blocks, resulting in loss of semantic structure. This makes it tedious for users to manually reapply correct heading levels and poses accessibility and SEO issues. This PR improves that flow by preserving the correct heading levels during paste.

How?

The transformer scans pasted content for <p> tags with role="heading" and aria-level (used by Word Online to represent headings). It replaces them with semantic heading tags based on the aria-level, preserving content and relevant attributes. This ensures correct Heading blocks are generated instead of Paragraph blocks.

Testing Instructions

  1. Create Headings in Word Online using Heading tag at the top.
image
  1. Use keyboard shortcuts to copy those headings and paste in Block Editor (Ctrl+V or Cmd+V).

  2. Use arrow keys to navigate the pasted blocks and ensure that heading blocks are correctly rendered and accessible via keyboard navigation.

Screenshots or screencast

Before

Screen.Recording.2025-07-18.at.1.09.40.PM.mov

After

Screen.Recording.2025-07-18.at.1.29.14.PM.mov

@github-actions
Copy link

github-actions bot commented Jul 18, 2025

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: mecskyverse <aakashverma1@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: mrwweb <mrwweb@git.wordpress.org>

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

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Feature] Paste labels Jul 18, 2025
@Mamaduka Mamaduka requested a review from ellatrix July 18, 2025 08:05
| MS Word Online || ||| n/a ||[1] |
| LibreOffice ||||[3] ||||
| Evernote ||[5] ||||| n/a |
| Evernote ||[4] ||||| n/a |
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to the PR, but might be a nice change to make

Suggested change
| Evernote || [4] ||||| n/a |
| Evernote || n/a [4] ||||| n/a |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree let me know if I should commit this suggestion.

@Mamaduka
Copy link
Member

Mamaduka commented Aug 7, 2025

@mecskyverse, the failing unit test seems to be related to the changes here.

@mecskyverse
Copy link
Contributor Author

Hey @Mamaduka, I've fixed the integration test related to this PR. The currently failing or cancelled unit tests seem to be CI-related, not caused by these changes.

@Mamaduka
Copy link
Member

@mecskyverse, sorry for the late reply.

Do you mind rebasing the branch onto the latest trunk and resolving any merge conflicts?

@mecskyverse mecskyverse force-pushed the feat/headings-support-word-online branch from 7ce858d to 1df28e8 Compare October 27, 2025 11:56
@mecskyverse
Copy link
Contributor Author

No worries @Mamaduka — I’ve rebased the branch onto the latest trunk, resolved the conflicts, and force-pushed the updates.

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good to me

@ellatrix ellatrix merged commit 44eca37 into WordPress:trunk Dec 11, 2025
43 of 44 checks passed
@github-actions github-actions bot added this to the Gutenberg 22.4 milestone Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Paste [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Headings not pasted from Word in the browser

4 participants