Skip to content

Commit

Permalink
feat: ✨ add pasteHTML method
Browse files Browse the repository at this point in the history
  • Loading branch information
luthfimasruri committed May 20, 2021
1 parent c82bb48 commit 63f0b3f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/vue-quill/src/components/QuillEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export const QuillEditor = defineComponent({

const setContents = (content: string | Delta, source: Sources = 'api') => {
if (props.contentType === 'html') {
setHTML(content as string, source)
setHTML(content as string)
} else if (props.contentType === 'text') {
setText(content as string, source)
} else {
Expand All @@ -285,7 +285,11 @@ export const QuillEditor = defineComponent({
return quill?.root.innerHTML ?? ''
}

const setHTML = (html: string, source: Sources = 'api') => {
const setHTML = (html: string) => {
if (quill) quill.root.innerHTML = html
}

const pasteHTML = (html: string, source: Sources = 'api') => {
const delta = quill?.clipboard.convert(html as {})
if (delta) quill?.setContents(delta, source)
}
Expand Down Expand Up @@ -322,6 +326,7 @@ export const QuillEditor = defineComponent({
setContents,
getHTML,
setHTML,
pasteHTML,
getText,
setText,
reinit,
Expand Down

0 comments on commit 63f0b3f

Please sign in to comment.