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
fix(image): Only focus image description on newly inserted image
Fixes: #6843
Fixes: nextcloud/collectives#1740

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- authored and backportbot[bot] committed May 8, 2025
commit ab27d68781f227bb0684eefe859e36fe58451c8d
3 changes: 3 additions & 0 deletions src/components/Editor/MediaHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,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 @@ -181,6 +181,7 @@ export default {
showImageModal: false,
imageIndex: null,
isEditable: false,
isLastInserted: false,
embeddedImageList: [],
}
},
Expand Down Expand Up @@ -237,6 +238,12 @@ export default {
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
}
})
this.loadPreview()
.catch(this.onImageLoadFailure)
},
Expand Down Expand Up @@ -280,7 +287,9 @@ export default {
onLoaded() {
this.loaded = true
this.$nextTick(() => {
this.$refs.altInput?.focus()
if (this.isLastInserted) {
this.$refs.altInput?.focus()
}
})
},
async updateEmbeddedImageList() {
Expand Down
Loading