-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5836 from nextcloud/backport/5832/stable29
[stable29] fix: smartpicker set links for selected text
- Loading branch information
Showing
1 changed file
with
7 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
|
@@ -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) | ||
|