File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,9 @@ export default {
194194 // Scroll image into view
195195 this .$editor .commands .scrollIntoView ()
196196
197+ // Store last inserted attachment src to focus it in ImageView.vue
198+ this .$editor .commands .setMeta (' insertedAttachmentSrc' , { src })
199+
197200 emit (' text:image-node:add' , null )
198201 },
199202 },
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ export default {
164164 showImageModal: false ,
165165 imageIndex: null ,
166166 isEditable: false ,
167+ isLastInserted: false ,
167168 embeddedImageList: [],
168169 }
169170 },
@@ -220,6 +221,12 @@ export default {
220221 this .editor .on (' update' , ({ editor }) => {
221222 this .isEditable = editor .isEditable
222223 })
224+ this .editor .on (' transaction' , ({ transaction }) => {
225+ const trMeta = transaction .getMeta (' insertedAttachmentSrc' )
226+ if (trMeta? .src === this .src ) {
227+ this .isLastInserted = true
228+ }
229+ })
223230 this .loadPreview ()
224231 .catch (this .onImageLoadFailure )
225232 },
@@ -263,7 +270,9 @@ export default {
263270 onLoaded () {
264271 this .loaded = true
265272 this .$nextTick (() => {
266- this .$refs .altInput ? .focus ()
273+ if (this .isLastInserted ) {
274+ this .$refs .altInput ? .focus ()
275+ }
267276 })
268277 },
269278 async updateEmbeddedImageList () {
You can’t perform that action at this time.
0 commit comments