Add support for configuring link target behavior in Rich Text Editor#10430
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a per-link ChangesRich Text Link Target Control
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
features/admin.flow-builder-core.v1/components/resource-property-panel/rich-text/helper-plugins/link-plugin.tsx (1)
538-545:⚠️ Potential issue | 🟠 MajorRestore editor selection before dispatching the link command.
The code at lines 538–540 calls
lastSelection?.clone?.()but discards the result without applying it. Since$setSelectionis not imported, the cloned selection is never restored to the editor beforeTOGGLE_SAFE_LINK_COMMANDexecutes, causing the command to run with an incorrect or missing selection context.Proposed fix
+import { $setSelection } from "lexical"; @@ - editor.update(()=>{ - lastSelection?.clone?.(); - }); + editor.update(() => { + if (lastSelection !== null) { + $setSelection(lastSelection.clone()); + } + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@features/admin.flow-builder-core.v1/components/resource-property-panel/rich-text/helper-plugins/link-plugin.tsx` around lines 538 - 545, The cloned selection from lastSelection is not being applied back to the editor before the TOGGLE_SAFE_LINK_COMMAND is dispatched. Import the $setSelection function from the lexical library and use it to restore the cloned selection to the editor by calling $setSelection(lastSelection?.clone?.()) within the editor.update() block, ensuring the selection context is correct when TOGGLE_SAFE_LINK_COMMAND executes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@features/admin.flow-builder-core.v1/components/resource-property-panel/rich-text/helper-plugins/link-plugin.tsx`:
- Around line 495-505: Replace the `any` type annotations on both currentUrl and
linkNode variables to use proper TypeScript types instead. For the currentUrl
variable assigned from getCurrentUrl(), determine the actual return type of that
function and use it. For the linkNode variable in the ternary expression with
$isLinkNode(node), use the proper LinkNode type or the correct return type from
that function. Remove all `any` type annotations and replace them with explicit
proper types to maintain type-safety throughout the checkbox update logic path.
---
Outside diff comments:
In
`@features/admin.flow-builder-core.v1/components/resource-property-panel/rich-text/helper-plugins/link-plugin.tsx`:
- Around line 538-545: The cloned selection from lastSelection is not being
applied back to the editor before the TOGGLE_SAFE_LINK_COMMAND is dispatched.
Import the $setSelection function from the lexical library and use it to restore
the cloned selection to the editor by calling
$setSelection(lastSelection?.clone?.()) within the editor.update() block,
ensuring the selection context is correct when TOGGLE_SAFE_LINK_COMMAND
executes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: c6fb15f0-4256-42ef-a20b-d60c58148f64
📒 Files selected for processing (6)
apps/console/.env.localfeatures/admin.flow-builder-core.v1/components/resource-property-panel/rich-text/helper-plugins/link-plugin.tsxfeatures/admin.registration-flow-builder.v1/data/templates.jsonidentity-apps-core/react-ui-core/src/components/adapters/rich-text-field-adapter.jsmodules/i18n/src/models/namespaces/flows-ns.tsmodules/i18n/src/translations/en-US/portals/flows.ts
| } | ||
| } | ||
| } | ||
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10430 +/- ##
==========================================
+ Coverage 72.62% 72.71% +0.08%
==========================================
Files 469 469
Lines 70633 70866 +233
Branches 240 240
==========================================
+ Hits 51300 51533 +233
Misses 19222 19222
Partials 111 111
🚀 New features to boost your workflow:
|
d0280c3 to
cb4abb1
Compare
Purpose
Fixes wso2/product-is#25367
Problem
In the new self-signup flow, links created through the Rich Text Editor are always configured to open in a new browser tab (
target="_blank").As a result, the Sign In link displayed in the Sign Up page is treated as an external link and opens in a new tab, which differs from the behavior in the old portal where navigation happens in the same tab.
Solution
This PR enhances the Rich Text Editor link editor by introducing support for configuring the link target.
Changes include:
_blankand_selftargets.relattribute based on the selected target.Result
Administrators can now decide whether a configured link should:
_self)_blank)This enables self-signup Sign In links to behave consistently with the legacy portal experience.
Testing
rel="noopener noreferrer"is applied only for_blank.