Jelajahi Sumber

fix modify parsed content img failed with index not correct

weichen 4 tahun lalu
induk
melakukan
39612f699f
1 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 3 3
      backstage/static/js/parsers.js

+ 3 - 3
backstage/static/js/parsers.js

@@ -2,7 +2,7 @@ function parseMd(content) {
   var frontMatters = [];
   var blockArray = [{title: ''}];
   var blockCount;
-  var preDataIndex, imgDataIndex;
+  var preDataIndex;
   var parseBlockDiv;
   var url;
   var preImg, preImgObject;
@@ -69,12 +69,12 @@ function parseMd(content) {
     } else if (line.includes('amp-img')) {
       const preBlockindex = blockCount;
       if (line.includes('</amp-img>')) {
-        blockArray = addDataToBlockArray(preImgObject, blockArray, preBlockindex, imgDataIndex);
+        blockArray = addDataToBlockArray(preImgObject, blockArray, preBlockindex, preDataIndex - 1);
         isAmpImgRange = false;
         preImgObject = {'image': {}}
         continue;
       }
-      imgDataIndex = preDataIndex;
+      const imgDataIndex = preDataIndex;
       preDataIndex += 1;
       isAmpImgRange = true;
       const {img, imgInput, widthInput, heightInput, imgInputButton} = getImgElements(parseBlockDiv);