chmln / vue-wysiwyg

A lightweight WYSIWYG HTML editor for Vue.js
https://chmln.github.io/vue-wysiwyg/
MIT License
555 stars 134 forks source link

forcePlainTextOnPaste doesn't work #84

Open JanMP opened 5 years ago

JanMP commented 5 years ago

Text copied while this option is set to true is still copied with styling.

tychovbh commented 5 years ago

+1

MrSunshyne commented 5 years ago

+1

alexvargash commented 5 years ago

+1

alexvargash commented 5 years ago

Just found out that the functionality was added to the repository on commit: 3ac688fba67c06d5bbc722d4e452b842f93dee75

@chmln But the npm package was never updated.

clamarque commented 5 years ago

+1

weblabio commented 5 years ago

+1

Latentimagedesign commented 5 years ago

When will this be added to the NPM package? otherwise - is there a way to work around this?

k3ssen commented 5 years ago

When will this be added to the NPM package? otherwise - is there a way to work around this?

I guess you could have NPM refer to the specific commit. A workaround would be that you implement the required code yourself. When you look into 3ac688f, you'll see that basically the paste-method must be somehow overwritten. Without diving into the code too much I wouldn't know how to add the eventListener to the component, but instead you could add an eventListener to the document, since you're only required to call execCommand on document.

So instead of using

import wysiwyg from "vue-wysiwyg";
Vue.use(wysiwyg, {
    forcePlainTextOnPaste: true
});

You could end up with something like:

import wysiwyg from "vue-wysiwyg";
Vue.use(wysiwyg);
document.addEventListener('paste', function (e) {
    e.preventDefault();
    document.execCommand("insertHTML", false, e.clipboardData.getData("text/plain"));
});
fayt81 commented 4 years ago

Hi @chmln could you kindly add the commit 3ac688f (#72) to the npm package or should we find a workaround?

All the best

jezzdk commented 4 years ago

Use this if you want: https://www.npmjs.com/package/vue-wysiwyg-fixed

chmln commented 4 years ago

@fayt81 @Latentimagedesign my bad for taking a while, I will push a release out very soon.

limeandcoconut commented 3 years ago

@chmln, any time now would be sweet!

nathanchase commented 3 years ago

Yes, please update https://www.npmjs.com/package/vue-wysiwyg if you are able to @chmln! I also need forcePlainTextOnPaste working for my project. Thank you!