Skip to content

Commit

Permalink
Merge pull request #361 from fylzero/add-focus-method
Browse files Browse the repository at this point in the history
feat(vue-quill): add focus method
  • Loading branch information
luthfimasruri authored May 12, 2023
2 parents 54eefc7 + f1a93b7 commit f544b92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/content/api/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ We highly recommend to call method when the quill editor ready, use @ready event

To import raw HTML from a non-Quill environment.

## focus()

Focuses the editor.

## getText(index, length)

- **Parameter:** `index?: number, length?: number`
Expand Down
7 changes: 6 additions & 1 deletion packages/vue-quill/src/components/QuillEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export const QuillEditor = defineComponent({
const getQuill = (): Quill => {
if (quill) return quill
else
throw `The quill editor hasn't been instantiated yet,
throw `The quill editor hasn't been instantiated yet,
make sure to call this method when the editor ready
or use v-on:ready="onReady(quill)" event instead.`
}
Expand Down Expand Up @@ -340,6 +340,10 @@ export const QuillEditor = defineComponent({
if (delta) quill?.setContents(delta, source)
}

const focus = () => {
quill?.focus()
}

const reinit = () => {
nextTick(() => {
if (!ctx.slots.toolbar && quill)
Expand Down Expand Up @@ -380,6 +384,7 @@ export const QuillEditor = defineComponent({
getHTML,
setHTML,
pasteHTML,
focus,
getText,
setText,
reinit,
Expand Down

0 comments on commit f544b92

Please sign in to comment.