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

How to avoid pasting selected text from clipborad without images? #2719

Closed
leochiu-a opened this issue Sep 6, 2022 · 5 comments
Closed

How to avoid pasting selected text from clipborad without images? #2719

leochiu-a opened this issue Sep 6, 2022 · 5 comments

Comments

@leochiu-a
Copy link

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 leochiu-a changed the title How to prevent paste text exclude image? How to avoid pasting selected text from clipborad without images Sep 6, 2022
@leochiu-a leochiu-a changed the title How to avoid pasting selected text from clipborad without images How to avoid pasting selected text from clipborad without images? Sep 6, 2022
@jwlee1108
Copy link
Contributor

jwlee1108 commented Sep 7, 2022

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)

@williamsun1993
Copy link

williamsun1993 commented Sep 9, 2022

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')
            })
          },
        },
      },
    }
  },
}

@leochiu-a
Copy link
Author

@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.

@stale
Copy link

stale bot commented Nov 2, 2022

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 stale bot added the inactive label Nov 2, 2022
@stale
Copy link

stale bot commented Nov 12, 2022

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

@stale stale bot closed this as completed Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants