Add support for configuring link target behavior in Rich Text Editor#10430
Add support for configuring link target behavior in Rich Text Editor#10430Mahima-Sanketh-Git wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a per-link ChangesRich Text Link Target Control
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (5 passed)
✨ 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
|
Mahima Arachchi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
| const [ lastSelection, setLastSelection ] = useState<BaseSelection | null>(null); | ||
| const [ selectedUrlType, setSelectedUrlType ] = useState<string>("CUSTOM"); | ||
|
|
||
| const [ linkTarget, setLinkTarget ] = useState<"_blank" | "_self">("_blank"); |
There was a problem hiding this comment.
it seems "_blank" | "_self" is repeated throughout the file. Shall we extract it to a reusable type definition?
| } else { | ||
| linkNode.setRel(""); | ||
| } |
There was a problem hiding this comment.
Is this else block necessary?
| <Box sx={ { alignItems:"center", display: "flex", flexDirection: "row", gap: 0 | ||
| } }> |
There was a problem hiding this comment.
| <Box sx={ { alignItems:"center", display: "flex", flexDirection: "row", gap: 0 | |
| } }> | |
| <Box sx={ { alignItems:"center", display: "flex", flexDirection: "row", gap: 0 } }> |
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.