Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it support custom uploads? #72

Open
fred-hu opened this issue Aug 16, 2021 · 1 comment
Open

Does it support custom uploads? #72

fred-hu opened this issue Aug 16, 2021 · 1 comment

Comments

@fred-hu
Copy link

fred-hu commented Aug 16, 2021

No description provided.

@shartoo
Copy link

shartoo commented Oct 8, 2021

You can add a upload slot inside quasar-tiptap label

<template>
  <q-page class="new_blog_template">
    <quasar-tiptap v-bind="options" @update="onUpdate" scrollable>
      <template slot="toolbar-left">
      <q-separator vertical inset />
      </template>
      <template slot="toolbar-left">
        <el-upload
            class="img-uploader"
            action=""
            :http-request="uploadImg"
            :before-upload="beforeImgUpload"
            :on-remove="removeImg"
            list-type="picture">
            <q-icon name="upload" class="text-black" style="font-size: 32px;" />
        </el-upload>
      </template>
    </quasar-tiptap>
  </q-page>
</template>
  • the script methods
// 上传图片
    uploadImg (item) {
      const savepath = 'datasets'
      const formData = new FormData()
      formData.append('file', item.file)
      formData.append('path', savepath)
      const uid = item.file.uid
      uploadFile(formData).then(res => {
        document.execCommand('insertHTML', true, '<div><img src="' + res + '" /></div>')
      }).catch((res) => {
        this.$message.error('upload failed!' + res)
      })
    },

the code document.execCommand('insertHTML', true, '<div><img src="' + res + '" /></div>') can auto insert the image just upload in position of mouse cursor.
微信截图_20211008214511

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants