Skip to content

Commit

Permalink
fix: handle autofocus
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicou committed Apr 12, 2023
1 parent 0c2bcb1 commit 35ac9f8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/tiptap-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,16 @@ const props = withDefaults(
defineProps<{
value: ValueType | null;
type: TypeType;
disabled: boolean;
placeholder: string | null;
disabled: boolean;
autofocus: boolean;
}>(),
{ value: null, disabled: false, placeholder: null }
{
value: null,
placeholder: null,
disabled: false,
autofocus: false,
}
);
const emit = defineEmits<{
Expand All @@ -492,7 +498,12 @@ const editor = new Editor({
editable: !props.disabled,
content: props.value,
extensions: [...extensions, placeholder],
onUpdate: () => {
onCreate: ({ editor }) => {
if (props.autofocus) {
editor.chain().focus().run();
}
},
onUpdate: ({ editor }) => {
switch (props.type) {
case "json":
emit("input", editor.getJSON());
Expand Down

0 comments on commit 35ac9f8

Please sign in to comment.