Created
July 10, 2018 00:03
-
-
Save prodrammer/d4d205594b2993224b8ad111cebe1a13 to your computer and use it in GitHub Desktop.
Example enforcing plain text paste in Quill.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Quill from 'quill' | |
import PlainClipboard from './PlainClipboard' | |
Quill.register('modules/clipboard', PlainClipboard, true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Quill from 'quill' | |
const Clipboard = Quill.import('modules/clipboard') | |
const Delta = Quill.import('delta') | |
class PlainClipboard extends Clipboard { | |
onPaste (e) { | |
e.preventDefault() | |
const range = this.quill.getSelection() | |
const text = e.clipboardData.getData('text/plain') | |
const delta = new Delta() | |
.retain(range.index) | |
.delete(range.length) | |
.insert(text) | |
const index = text.length + range.index | |
const length = 0 | |
this.quill.updateContents(delta, 'silent') | |
this.quill.setSelection(index, length, 'silent') | |
this.quill.scrollIntoView() | |
} | |
} | |
export default PlainClipboard |
@clonn How are you able to get this working on vue-quill-editor? All I get is an empty box with error:
[Vue warn]: Error in mounted hook: "TypeError: moduleClass is not a constructor"
I have followed all the instructions here. cc: @ryanhaney
Hie everyone !
do you know how is this solution with angular 8 ?
i don't want change de source code of quill js. Because i work with my team.
How can i use this solutions only with ngx-quill please ?
i only want the text in the clipboard (no style, pictures or html code).
@marcerkol78, perhaps the author of ngx-quill
can help with your questions. You'll need to find out how to register a custom clipboard module with Quill.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_vue_quill_editor___default.a.register is not a function
I have no idea what happen
// -----
Updated,
that is my fault, have to use origin quill module to register plugin