-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
V15: Rich Text Editor links do not work with query strings and anchors #17288
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Since the change from UDIs to localLinks in href, the pattern matched a little too much in the href section completely ignoring any "extras" such as querystrings and anchors after the locallink, which meant that the locallink did not get replaced at all if they were present. This is fixed by limiting the regexp a bit.
Because we are now no longer matching the whole `href` attribute but only some of its contents, we need to fix up the old pattern as well. It has been extended with matching groups that follow the same pattern as the new links.
Closed
example: ```html <a type="document" href="/{localLink:<GUID>}"> Test </a> ```
leekelleher
approved these changes
Oct 16, 2024
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'm happy to say that we've got there with this one! 😅
Tested out with various scenarios for both TinyMCE and Tiptap RTE editors, I'm happy with the results. Great work on the RegEx, (it made my head hurt). 🚀
iOvergaard
added a commit
that referenced
this pull request
Oct 17, 2024
#17288) * fix: anchors and query strings do not work Since the change from UDIs to localLinks in href, the pattern matched a little too much in the href section completely ignoring any "extras" such as querystrings and anchors after the locallink, which meant that the locallink did not get replaced at all if they were present. This is fixed by limiting the regexp a bit. * fix: legacy links do not follow the same regexp as new links Because we are no longer matching the whole `href` attribute but only some of its contents, we need to fix up the old pattern. It has been extended with matching groups that follow the same pattern as the new links. * feat: allow a-tags to be multiline example: ```html <a type="document" href="/{localLink:<GUID>}"> Test </a> ``` * fix: split regex into two parts: first a tokenizer for a-tags and then a type-finder * fix: ensure only "document" and "media" are matching to speed up the pattern * feat: allow a-tags to be multiline (cherry picked from commit 35e8f2e)
This was referenced Nov 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Fixes #17219
Fixes #17272
Partly fixes #17009 (which still needs a frontend fix)
Description
Since the change from UDIs to "localLinks" in the
href
attribute (>=14.1), the pattern matched a little too much in the href section completely ignoring any "extras" such as query strings and anchors after the locallink, which meant that the locallink did not get replaced at all if they were present. This is fixed by limiting the regexp a bit.Because we are no longer matching the whole
href
attribute but only some of its contents, we need to fix the old pattern. It has been simplified into a main RegExp that finds all a-tags with local links inside, then another regex is run on each component subset to find itstype
attribute value.I have added more test cases to cover what did not work before. In general, the two paradigms of rich text pattern matching should be:
{localLink:<GUID|INT>}
leaving all other parts to itselfThis means that links like the following now work: