tui.editor icon indicating copy to clipboard operation
tui.editor copied to clipboard

How to avoid pasting selected text from clipborad without images?

Open leochiu-a opened this issue 3 years ago • 3 comments

Summary

How to avoid pasting selected text from clipborad without images? Because images pasted from clipborad will become base64 encoding, but generally do not want the database to store base64 encoding images, so I hope to avoid pasting text exclude images.

Version

3.1.3

leochiu-a avatar Sep 06 '22 02:09 leochiu-a

It's not a easy thing. There won't be a simple way to deal with it. It would need to handle prosemirror. But I guess you can make an plugin for this issue. We did open plugin interface for keymap (#2647)

jwlee1108 avatar Sep 07 '22 14:09 jwlee1108

You can add a hook and it will be called the hook when uploading or pasting this image to OSS. This is my code. @leochiu-a

// ~ template
// ==================

<Editor
  ref="toastuiEditor"
  height="500px"
  :options="editorOptions"
  initial-edit-type="markdown"
></Editor>

// ~ script
// ==================

export default {
  data() {
    ...
    return {
      editorOptions: {
        hooks: {
          addImageBlobHook: (blob, callback) => {
            // upload image
            UploadApi.uploadImg(blob).then(res => {
              callback(res.data.data, 'img')
            })
          },
        },
      },
    }
  },
}

cryozerolabs avatar Sep 09 '22 07:09 cryozerolabs

@williamsun1993 Thank you for your reply. It is seams like the way to upload image, but what I want is prevent pasting text from clipboard which maybe includes images. These images will be transformed to base64 encoding even doesn't trigger addImageBlobHook.

leochiu-a avatar Sep 12 '22 00:09 leochiu-a

This issue has been automatically marked as inactive because there hasn’t been much going on it lately. It is going to be closed after 7 days. Thanks!

stale[bot] avatar Nov 02 '22 08:11 stale[bot]

This issue will be closed due to inactivity. Thanks for your contribution!

stale[bot] avatar Nov 12 '22 20:11 stale[bot]