Skip to content
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
3 changes: 3 additions & 0 deletions src/components/Editor/MediaHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ export default {
// Scroll image into view
this.$editor.commands.scrollIntoView()

// Store last inserted attachment src to focus it in ImageView.vue
this.$editor.commands.setMeta('insertedAttachmentSrc', { src })

emit('text:image-node:add', null)
},
},
Expand Down
11 changes: 10 additions & 1 deletion src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
showImageModal: false,
imageIndex: null,
isEditable: false,
isLastInserted: false,

Check warning on line 167 in src/nodes/ImageView.vue

View check run for this annotation

Codecov / codecov/patch

src/nodes/ImageView.vue#L167

Added line #L167 was not covered by tests
embeddedImageList: [],
}
},
Expand Down Expand Up @@ -220,6 +221,12 @@
this.editor.on('update', ({ editor }) => {
this.isEditable = editor.isEditable
})
this.editor.on('transaction', ({ transaction }) => {
const trMeta = transaction.getMeta('insertedAttachmentSrc')
if (trMeta?.src === this.src) {
this.isLastInserted = true
}
})

Check warning on line 229 in src/nodes/ImageView.vue

View check run for this annotation

Codecov / codecov/patch

src/nodes/ImageView.vue#L224-L229

Added lines #L224 - L229 were not covered by tests
this.loadPreview()
.catch(this.onImageLoadFailure)
},
Expand Down Expand Up @@ -263,7 +270,9 @@
onLoaded() {
this.loaded = true
this.$nextTick(() => {
this.$refs.altInput?.focus()
if (this.isLastInserted) {
this.$refs.altInput?.focus()
}

Check warning on line 275 in src/nodes/ImageView.vue

View check run for this annotation

Codecov / codecov/patch

src/nodes/ImageView.vue#L273-L275

Added lines #L273 - L275 were not covered by tests
})
},
async updateEmbeddedImageList() {
Expand Down
Loading