зеркало из https://github.com/nextcloud/text.git
fix: Only insert smart picker result as preview if it is a valid URL
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
2996339698
Коммит
edd9665837
|
@ -44,6 +44,14 @@ const isValidMarkdown = (content) => {
|
|||
}
|
||||
}
|
||||
|
||||
const isValidUrl = (url) => {
|
||||
try {
|
||||
return Boolean(new URL(url))
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const sortImportantFirst = (list) => {
|
||||
return [
|
||||
...list.filter(e => important.indexOf(e.key) > -1),
|
||||
|
@ -77,9 +85,11 @@ export default () => createSuggestions({
|
|||
}
|
||||
getLinkWithPicker(props.providerId, true)
|
||||
.then(link => {
|
||||
if (hasMarkdownSyntax(link) && isValidMarkdown(link)) {
|
||||
const isUrl = isValidUrl(link)
|
||||
if (!isUrl) {
|
||||
const isMarkdown = hasMarkdownSyntax(link) && isValidMarkdown(link)
|
||||
// Insert markdown content (e.g. from `text_templates` app)
|
||||
const content = markdownit.render(link)
|
||||
const content = isMarkdown ? markdownit.render(link) : link
|
||||
editor
|
||||
.chain()
|
||||
.focus()
|
||||
|
|
Загрузка…
Ссылка в новой задаче