-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Headings support for Word Online while pasting. #70771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Headings support for Word Online while pasting. #70771
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| | MS Word Online | ✓ | ✓ | ✓ | ✓ | n/a | ✓ | ✘ [1] | | ||
| | LibreOffice | ✓ | ✓ | ✓ | ✘ [3] | ✓ | ✓ | ✓ | | ||
| | Evernote | ✓ | ✘ [5] | ✓ | ✓ | ✓ | ✓ | n/a | | ||
| | Evernote | ✓ | ✘ [4] | ✓ | ✓ | ✓ | ✓ | n/a | |
There was a problem hiding this comment.
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
| | Evernote | ✓ | ✘ [4] | ✓ | ✓ | ✓ | ✓ | n/a | | |
| | Evernote | ✓ | n/a [4] | ✓ | ✓ | ✓ | ✓ | n/a | |
There was a problem hiding this comment.
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.
|
@mecskyverse, the failing unit test seems to be related to the changes here. |
|
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. |
|
@mecskyverse, sorry for the late reply. Do you mind rebasing the branch onto the latest trunk and resolving any merge conflicts? |
7ce858d to
1df28e8
Compare
|
No worries @Mamaduka — I’ve rebased the branch onto the latest trunk, resolved the conflicts, and force-pushed the updates. |
ellatrix
left a comment
There was a problem hiding this 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
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
Use keyboard shortcuts to copy those headings and paste in Block Editor (Ctrl+V or Cmd+V).
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