feat: add support for the Web Share Target API (#1100)
Co-authored-by: userquin <userquin@gmail.com>
This commit is contained in:
parent
a6a825e553
commit
bede92404b
11 changed files with 221 additions and 7 deletions
|
@ -1,7 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { EditorContent } from '@tiptap/vue-3'
|
||||
import type { mastodon } from 'masto'
|
||||
import type { Ref } from 'vue'
|
||||
import type { Draft } from '~/types'
|
||||
|
||||
const {
|
||||
|
@ -90,6 +89,19 @@ async function publish() {
|
|||
emit('published', status)
|
||||
}
|
||||
|
||||
useWebShareTarget(async ({ data: { data, action } }: any) => {
|
||||
if (action !== 'compose-with-shared-data')
|
||||
return
|
||||
|
||||
editor.value?.commands.focus('end')
|
||||
|
||||
if (data.text !== undefined)
|
||||
editor.value?.commands.insertContent(data.text)
|
||||
|
||||
if (data.files !== undefined)
|
||||
await uploadAttachments(data.files)
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
focusEditor: () => {
|
||||
editor.value?.commands?.focus?.()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue