Hi, I just don't to use the Clipboard, i.e. I just want to copy plain text, I read the documentation but I couldn't find some config to do that. Please, I am aware that this issue doesn't comply with the guidelines, can't I just get the answer if it's simple before closing it? Thanks.
There is no quick configuration for plain text pasting. You can provide your own Clipboard module if Quill's does not suit you: http://quilljs.com/docs/modules/. The code example there happens to be exactly a plain text clipboard but it is just a code example for explanation and demonstration purposes.
I couldn't get the example to work, so I created this. Hopefully it helps someone else.
https://gist.github.com/ryanhaney/d4d205594b2993224b8ad111cebe1a13
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
Most helpful comment
I couldn't get the example to work, so I created this. Hopefully it helps someone else.
https://gist.github.com/ryanhaney/d4d205594b2993224b8ad111cebe1a13