Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vue-quill): add focus method #361

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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