tiny-vue/examples/sites/demos/mobile-first/app/fluent-editor/image-upload.vue

47 lines
1.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div>
<tiny-fluent-editor v-model="content" :image-upload="imageUpload"></tiny-fluent-editor>
内容<br />
{{ content }}
</div>
</template>
<script>
import { Modal } from '@opentiny/vue'
import TinyFluentEditor from '@opentiny/vue-fluent-editor'
export default {
components: {
TinyFluentEditor
},
data() {
return {
content: '{"ops":[{"insert":"Hello "},{"attributes":{"bold":true},"insert":"FluentEditor"},{"insert":"!"}]}',
imageUpload: {
url: 'https://run.mocky.io/v3/f34365b4-679d-4e8f-8313-ddb11d6750be',
method: 'POST',
name: 'image',
withCredentials: true,
headers: {},
success: (serverResponse, next) => {
let file = {}
for (const key in serverResponse) {
file = serverResponse[key]
break
}
next(file.downloadUrl)
},
fail: (serverError) => {
Modal.message({
message: `上传失败回调事件:${serverError}`,
status: 'info'
})
}
}
}
}
}
</script>