fix: wrap generated body from link in markdown quotes, close #694
This commit is contained in:
1 file changed
+25
-10
@@ -72,17 +72,33 @@
|
|||||||
let uploadImage = $state(false)
|
let uploadImage = $state(false)
|
||||||
|
|
||||||
async function autofill(
|
async function autofill(
|
||||||
url: URL,
|
data: URL | { title?: string; body?: string },
|
||||||
): Promise<{ title?: string; body?: string }> {
|
): Promise<{ title?: string; body?: string }> {
|
||||||
const res = await autofillPost(url)
|
if (data instanceof URL) {
|
||||||
|
const res = await autofillPost(data)
|
||||||
|
|
||||||
if (settings.forms.autosubmitAutofill) {
|
if (settings.forms.autosubmitAutofill) {
|
||||||
form.title = res.title || form.title
|
autofill({
|
||||||
form.body = res.body || form.body
|
title: res.title,
|
||||||
history?.back?.()
|
body: res.body,
|
||||||
|
})
|
||||||
|
history?.back?.()
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
} else {
|
||||||
|
form.title = data.title || form.title
|
||||||
|
form.body =
|
||||||
|
data.body
|
||||||
|
?.split('\n')
|
||||||
|
.map((i) => `> ${i}`)
|
||||||
|
.join('\n') || form.body
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: form.title,
|
||||||
|
body: form.body,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -172,8 +188,7 @@
|
|||||||
size="lg"
|
size="lg"
|
||||||
color="primary"
|
color="primary"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
form.title = url.title ?? form.title
|
autofill({ title: url.title, body: url.body })
|
||||||
form.body = url.body ?? form.body
|
|
||||||
history.back()
|
history.back()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user