Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: smartpicker set links for selected text
Signed-off-by: Cleopatra Enjeck M <[email protected]>
  • Loading branch information
enjeck authored and backportbot[bot] committed May 27, 2024
commit e1359e30a09eda005f2a6b96f45a0b46c9b92eca
13 changes: 7 additions & 6 deletions src/components/Menu/ActionInsertLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default {
// Avoid issues when parsing urls later on in markdown that might be entered in an invalid format (e.g. "mailto: [email protected]")
const href = url.replaceAll(' ', '%20')
const chain = this.$editor.chain()
// Check if any text is selected, if not insert the lunk using the given text property
// Check if any text is selected, if not insert the link using the given text property
if (this.$editor.view.state?.selection.empty) {
chain.insertContent({
type: 'paragraph',
Expand Down Expand Up @@ -233,11 +233,12 @@ export default {
linkPicker() {
getLinkWithPicker(null, true)
.then(link => {
this.$editor
.chain()
.focus()
.insertContent(link + ' ')
.run()
const chain = this.$editor.chain()
if (this.$editor.view.state?.selection.empty) {
chain.focus().insertContent(link + ' ').run()
} else {
chain.setLink({ href: link }).focus().run()
}
})
.catch(error => {
console.error('Smart picker promise rejected', error)
Expand Down