-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Keep id on paste if internal link points to it #31107
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @juanruitina! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
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 think we can remove name
from the schema.
Otherwise this is great. Simple and generalised so that's really nice.
Looks like there's something going wrong with the tests so you might have to rebase to re-run them again at a later time. |
packages/blocks/src/api/raw-handling/phrasing-content-reducer.js
Outdated
Show resolved
Hide resolved
packages/blocks/src/api/raw-handling/phrasing-content-reducer.js
Outdated
Show resolved
Hide resolved
b8eb52c
to
d77e7e8
Compare
Thanks a lot @ellatrix for your indications and suggestions, I incorporated them and rebased as suggested. It seems I need approval for rerunning tests, can you do that? |
@juanruitina You need to rebase to re-run them :) |
Oh, one last thing, could you add an paste integration test? I think they're in |
9af1715
to
c9f2a49
Compare
afa6c6f
to
2b08c30
Compare
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p><a>This is a paragraph with an anchor with no link pointing to it.</a></p> |
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.
@ellatrix Could you provide some more guidance on how could we unwrap text within links with no attributes (therefore with no use)? You mentioned removeInvalidHTML should handle it but I couldn't figure out how we could make sure it achieves that (it doesn't at the moment). It would be nice to clean it up a bit.
I added a test in (I did something wrong with the rebase and Github automatically asked for reviews from many code owners. I could undo the error, but not those review requests. Sorry for that!!! Geez, I need to get more familiar with git) |
If link has obsolete name attribute, save as id and remove name Remove links with no id nor href attributes (+ test) Update raw handling readme: footnote support, LibreOffice
No need to remove name attribute, handled by removeInvalidHTML
2b08c30
to
8642ec3
Compare
Congratulations on your first merged pull request, @juanruitina! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
Thanks for working on this, @juanruitina, and congratulations on the first merged PR 🎉 |
Description
With these changes, the block editor will keep the IDs in links when there's another link pointing to that ID. This is useful when pasting documents with internal links, e.g. when pasting text with footnotes from Microsoft Word, which used to work with the TinyMCE editor. Fixes #12784.
Sometimes internal links leverage the "name" attribute as the anchor instead of "id". However, the use of the
name
attribute fora
elements is obsolete in HTML5; use ofid
is recommended instead; W3C Markup Validator also shows a warning. This code also saves thename
attribute in links as the link'sid
(unless there's anid
attribute already), and then removes it.(Following @ellatrix feedback in #27677, these changes affect all links, not only footnotes and endnotes)
How has this been tested?
Tested locally with wp-env.
Types of changes
Bug fix
Checklist: