feat(paste): support filter functions in tag-based paste config#2999
Draft
costajohnt wants to merge 1 commit intocodex-team:nextfrom
Draft
feat(paste): support filter functions in tag-based paste config#2999costajohnt wants to merge 1 commit intocodex-team:nextfrom
costajohnt wants to merge 1 commit intocodex-team:nextfrom
Conversation
Extend the paste processing logic to check filter functions when matching pasted elements to tools. Previously, filter functions in pasteConfig.tags were only used during sanitization (via HTMLJanitor) but ignored during paste processing, causing all elements with a matching tag name to be treated as substitutable regardless of the filter. Add a filter field to TagSubstitute, store it in getTagsConfig when the sanitization config is a function, and introduce isTagSubstitutable that checks both tag name and filter. Update processHTML, processElementNode, and containsAnotherToolTags to use the helper. Closes codex-team#2959
This file contains hidden or 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
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.
Extend the paste processing logic to check filter functions when matching pasted elements to tools.
Previously, filter functions in
pasteConfig.tagswere only used during sanitization (via HTMLJanitor) but ignored during paste processing, causing all elements with a matching tag name to be treated as substitutable regardless of the filter.Changes
filterfield toTagSubstituteinterfacegetTagsConfigwhen the sanitization config is a functionisTagSubstitutablehelper that checks both tag name and filterprocessHTML,processElementNode, andcontainsAnotherToolTagsto use the helperExample
A tool can now use a filter function in
pasteConfig.tagsto match only specific elements:Previously, this filter was only checked during sanitization. Now it's also checked during paste processing, so only
<span>elements that pass the filter will be assigned to the tool.Closes #2959