diff --git a/resources/assets/js/components/PreviewImage/state.vue b/resources/assets/js/components/PreviewImage/state.vue index 92d39644c..412b68a45 100644 --- a/resources/assets/js/components/PreviewImage/state.vue +++ b/resources/assets/js/components/PreviewImage/state.vue @@ -22,7 +22,10 @@ export default { }, watch: { show(v) { - if (!v) { + if (v) { + this.$store.state.previewImageIndex = Math.max(this.$store.state.previewImageIndex, 0) + this.$store.state.previewImageIndex = Math.min(this.$store.state.previewImageIndex, this.$store.state.previewImageList.length - 1) + } else { this.$store.state.previewImageIndex = 0; this.$store.state.previewImageList = []; } diff --git a/resources/assets/js/components/TEditor.vue b/resources/assets/js/components/TEditor.vue index b8f4c7907..61b2846f9 100755 --- a/resources/assets/js/components/TEditor.vue +++ b/resources/assets/js/components/TEditor.vue @@ -306,7 +306,7 @@ let index = 0; const imgElm = editor.selection.getNode(); if (imgElm && imgElm.nodeName === "IMG") { - index = array.findIndex(item => item === imgElm.getAttribute("src")); + index = array.findIndex(item => item.src === imgElm.getAttribute("src")); } this.$store.state.previewImageIndex = index; this.$store.state.previewImageList = array;