Skip to content

Commit

Permalink
Merge pull request #5836 from nextcloud/backport/5832/stable29
Browse files Browse the repository at this point in the history
[stable29] fix: smartpicker set links for selected text
  • Loading branch information
mejo- authored May 27, 2024
2 parents e959c77 + 0600e50 commit c771a10
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/Menu/ActionInsertLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,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 @@ -231,11 +231,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

0 comments on commit c771a10

Please sign in to comment.