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 @@ -226,6 +226,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 @@ -170,6 +170,7 @@
showImageModal: false,
imageIndex: null,
isEditable: false,
isLastInserted: false,

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

View check run for this annotation

Codecov / codecov/patch

src/nodes/ImageView.vue#L173

Added line #L173 was not covered by tests
embeddedImageList: [],
}
},
Expand Down Expand Up @@ -223,6 +224,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 232 in src/nodes/ImageView.vue

View check run for this annotation

Codecov / codecov/patch

src/nodes/ImageView.vue#L227-L232

Added lines #L227 - L232 were not covered by tests
this.loadPreview().catch(this.onImageLoadFailure)
},
methods: {
Expand Down Expand Up @@ -265,7 +272,9 @@
onLoaded() {
this.loaded = true
this.$nextTick(() => {
this.$refs.altInput?.focus()
if (this.isLastInserted) {
this.$refs.altInput?.focus()
}

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

View check run for this annotation

Codecov / codecov/patch

src/nodes/ImageView.vue#L275-L277

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