fix(rich-text-editor): DP-179947 use URL as display text when inserting link without text#1202
Conversation
…ng link without text When setLink is called with an empty display text, insert the href URL as the visible text instead of inserting an empty string, which left the editor with a zero-width selection and no visible link node.
|
Please add either the |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughUpdates Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.42.1)packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.jsComment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.js`:
- Around line 1647-1663: Refactor the two tests around setLink/getOutput into
parameterized single-assertion cases using it.each: call wrapper.vm.setLink(url,
displayText, linkOptions, supportedProtocols, defaultPrefix) and await
wrapper.vm.$nextTick() inside each row, then assert only one expected string per
case against wrapper.vm.getOutput(); consolidate the two scenarios (display text
provided vs empty) into a table of [url, displayText, expectedSubstring] and
replace the duplicate test flow with a single it.each block that checks the one
expectedSubstring per row (referencing setLink and getOutput to locate the
change).
🪄 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: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: b1b73448-281d-4838-a123-ca77032d319e
📒 Files selected for processing (2)
packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.jspackages/dialtone-vue/components/rich_text_editor/rich_text_editor.vue
|
✔️ Deploy previews ready! |
## [3.219.1](dialtone-vue/v3.219.0...dialtone-vue/v3.219.1) (2026-04-17) ### Bug Fixes * **Rich Text Editor:** DP-179947 use URL as display text when inserting link without text ([#1202](#1202)) ([30f2504](30f2504))
# [9.180.0](dialtone/v9.179.0...dialtone/v9.180.0) (2026-04-17) ### Bug Fixes * **Rich Text Editor:** DP-179947 use URL as display text when inserting link without text ([#1202](#1202)) ([30f2504](30f2504)) ### Documentation * **Modal:** NO-JIRA fix code examples ([#1207](#1207)) ([aedd4a1](aedd4a1)) ### Features * **Eslint Plugin Dialtone:** DLT-3314 add deprecated-dialtone-component rule ([#1200](#1200)) ([c73b7ee](c73b7ee))
Description
JIRA Link: https://dialpad.atlassian.net/browse/DP-179947
When a user inserts a link in the rich text editor without providing display text, the link is now visible in the editor using the URL itself as the display text.
Summary of changes requested
setLinkinDtRichTextEditorto fall back to the URL when display text is emptyTechnical Details
Root cause:
setLink(linkInput, linkText, ...)calledinsertContent(linkText)followed bysetTextSelection({ from, to: from + linkText.length }). WhenlinkTextwas"", this inserted nothing and created a zero-width selection, so the subsequentsetLink()mark command had no range to apply to — leaving the editor with no visible link node.Fix:
packages/dialtone-vue/components/rich_text_editor/rich_text_editor.vue— introduceconst displayText = linkText || linkInputand use it for bothinsertContentandsetTextSelection, so the URL is used as the visible text when no display text is provided.Tests: Added two cases to
rich_text_editor.test.jsunder a newsetLink methoddescribe block — one for when display text is provided, one for when it is empty.Use the URL as visible link text when no display text is provided to prevent zero-width selections. setLink now derives displayText = linkText || linkInput and uses it for insertContent and selection. Added tests covering both non-empty and empty display-text link insertion.