-
Notifications
You must be signed in to change notification settings - Fork 53
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
[WIP] feat/489: Add Rewrite Tone feature #803
base: develop
Are you sure you want to change the base?
Conversation
* @return {Array} Array of objects with content without delimiters. | ||
*/ | ||
export const removeBlockDelimiters = ( content ) => { | ||
return content.replace( /<!--[\s\S]*?-->/g, '' ); |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High
<!--
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to ensure that the regular expression replacement is applied repeatedly until no more replacements can be performed. This will ensure that all instances of the targeted pattern are removed from the content, effectively sanitizing it.
The best way to fix this issue without changing existing functionality is to modify the removeBlockDelimiters
function to apply the regular expression replacement in a loop until the content no longer changes. This approach ensures that all HTML comments are removed, even if they are nested or malformed.
-
Copy modified lines R25-R30
@@ -24,3 +24,8 @@ | ||
export const removeBlockDelimiters = ( content ) => { | ||
return content.replace( /<!--[\s\S]*?-->/g, '' ); | ||
let previous; | ||
do { | ||
previous = content; | ||
content = content.replace( /<!--[\s\S]*?-->/g, '' ); | ||
} while (content !== previous); | ||
return content; | ||
}; |
@jeffpaul I've updated the PR with a screencast showing how the UI will be for the admin. Can you please share your thoughts on it? |
I know I wasn't pinged but going to provide some thoughts anyway :) Overall I think this looks good so no real complaints with this approach. What I do think is worth discussing is how best to ensure we have consistency across all of our different features. As an example, right now someone could have a I don't think we need a single experience for everything as some things do make sense where they're at (for instance, I think the Also worth considering in progress features like #859 that adds a new button that opens a new modal. This feels like something that would be worth consolidating into what's done here, if we decide this approach is the right one |
Thanks for reviewing @dkotter The main reason why this popup was introduced was to support multiple block selection of different types. Once we move the Content Resizing options, we'll only have 2 different Plugin Panel areas – The sidebar and this new Popup in the editor header (unless we plan to re-introduce a custom Block Toolbar in the future).
I've added a collapsible panel within the Popup for this reason, however that adds an extra step. If we move all settings here, then it'll require thorough testing, as Gutenberg doesn't really allow to extend this area. I've added the button in the header through some heavy workarounds and a custom Slot-Fill. @10up/open-source-practice pinging ya'll to weigh in your opinions. |
So I know Gutenberg has the |
Yes. The |
To be more clear, my confusion was around this piece:
I guess I would assume if we're using the |
This is possible. If we do this, would we also move controls for Excerpt and Title Generation too? |
That's really the main question here that I'm bringing up for conversation as I'm not sure what's best. My concern is if someone has this Rewrite Tone Feature on plus Title Generation plus Excerpt Generation plus Classification each of those adds their own way to trigger functionality and wondering if we should be concerned with that fractured approach. My own opinion (not saying we should make changes yet, just to be clear) would be to get rid of the custom panel we currently have and all the settings in there and add those to this new custom plugin section. I'd probably leave the Excerpt Generation button alone and maybe Title Generation as well but could also see benefit to putting those in the same place. Ultimately I don't think any of that needs to happen on this PR, just want to ensure we're thinking through the best UI/UX for new Features like this and ensuring we're not backing ourselves into a corner with any decisions we make. |
I talked through this a bit with @Sidsector9 earlier today and my knee-jerk reaction is:
@fabiankaegy I'm curious if you might recommend something different/similar here? |
Description of the Change
Closes #489
Screencast
The Tone Rewriting options are preserved in local storage so that the admin does not have to perform the same selection every time.
Screen.Recording.2025-03-03.at.4.57.22.PM.mov
How to test the Change
Changelog Entry
Credits
Props @jeffpaul @Sidsector9
Checklist: