-
Notifications
You must be signed in to change notification settings - Fork 32
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
PCH Smart Linking: Prevent Smart Linking from running on Freeform (Classic) blocks #2570
Conversation
Warning Rate limit exceeded@vaurdan has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 42 minutes and 37 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis update introduces handling for cases where Smart Links are applied to Freeform blocks or the entire content in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as User Interface
participant Component as SmartLinkComponent
participant Logic as SmartLinkLogic
User ->> UI: Attempts to apply Smart Links
UI ->> Component: Trigger applySmartLinks()
Component ->> Logic: Check if content is Freeform
Logic -->> Component: Return Freeform check result
alt Content is Freeform
Component ->> UI: Display error message
Component ->> Component: Set loading to false
Component ->> Component: Return early
else Content is not Freeform
Component ->> Logic: Apply Smart Links
Logic -->> Component: Smart Links applied
Component -->> UI: Reflect updated content
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files ignored due to path filters (2)
build/content-helper/editor-sidebar.asset.php
is excluded by!build/**
build/content-helper/editor-sidebar.js
is excluded by!build/**
Files selected for processing (1)
- src/content-helper/editor-sidebar/smart-linking/component.tsx (1 hunks)
Additional context used
Path-based instructions (1)
src/content-helper/editor-sidebar/smart-linking/component.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
# Conflicts: # build/content-helper/editor-sidebar.asset.php # build/content-helper/editor-sidebar.js
So, the existence of a single Freeform block can break things for other blocks as well, even if the selected block is not Freeform. Am I understanding this correctly? |
@acicovic exactly. If you are generating smart links for all blocks, and you get a smart link that is to be inserted into a freeform block, there's a high likelihood that either the block editor crashes, or the block content becomes empty. If there is at least one freeform block, only the "Selected Block" option will actually work, and only if you don't select the freeform block |
Description
Due to the way the Freeform blocks (aka Classic Editor blocks) works, the parsing and injection of Smart Links do not work properly on this type of block.
This PR checks if the current block (if "Selected Block" is selected) or if the content contains any freeform block (if "All Blocks" is selected), and throws a Snack Bar error if so.
Motivation and context
Prevent issues when running the Smart Linking on posts with Freeform blocks.
How has this been tested?
Tested locally
Summary by CodeRabbit