|
@@ -1,6 +1,6 @@
|
|
|
function parseMd(content) {
|
|
|
var frontMatters = [];
|
|
|
- var blockArray = [{title: ''}];
|
|
|
+ var blockArray = [{title: '', data: []}];
|
|
|
var blockCount;
|
|
|
var preDataIndex;
|
|
|
var parseBlockDiv;
|
|
@@ -56,7 +56,7 @@ function parseMd(content) {
|
|
|
}
|
|
|
imgButton.onclick = function() {
|
|
|
const imgDataIndex = blockArray[preBlockindex].data.length;
|
|
|
- const {img, imgInput, widthInput, heightInput, imgInputButton} = getImgElements(blockDiv);
|
|
|
+ const {img, imgInput, widthInput, heightInput, imgInputButton, imgRemoveButton} = getImgElements(blockDiv);
|
|
|
imgInputButton.onclick = function() {
|
|
|
const imgObject = {image: {src: 'img/' + imgInput.files[0].name,
|
|
|
height: heightInput.value,
|
|
@@ -65,6 +65,10 @@ function parseMd(content) {
|
|
|
layout: 'responsive'}};
|
|
|
blockArray = handleImgInputClick(img, imgObject, blockArray, preBlockindex, imgDataIndex, url);
|
|
|
}
|
|
|
+ imgRemoveButton.onclick = function() {
|
|
|
+ removeImgElement(img, imgInput, widthInput, heightInput, imgInputButton, imgRemoveButton);
|
|
|
+ blockArray = removeImgData(blockArray, preBlockindex, imgDataIndex);
|
|
|
+ }
|
|
|
}
|
|
|
} else if (line.includes('amp-img')) {
|
|
|
const preBlockindex = blockCount;
|
|
@@ -77,7 +81,7 @@ function parseMd(content) {
|
|
|
const imgDataIndex = preDataIndex;
|
|
|
preDataIndex += 1;
|
|
|
isAmpImgRange = true;
|
|
|
- const {img, imgInput, widthInput, heightInput, imgInputButton} = getImgElements(parseBlockDiv);
|
|
|
+ const {img, imgInput, widthInput, heightInput, imgInputButton, imgRemoveButton} = getImgElements(parseBlockDiv);
|
|
|
preImg = img;
|
|
|
imgInputButton.onclick = function() {
|
|
|
const imgObject = {image: {src: 'img/' + imgInput.files[0].name,
|
|
@@ -87,6 +91,10 @@ function parseMd(content) {
|
|
|
layout: 'responsive'}};
|
|
|
blockArray = handleImgInputClick(img, imgObject, blockArray, preBlockindex, imgDataIndex, url);
|
|
|
}
|
|
|
+ imgRemoveButton.onclick = function() {
|
|
|
+ removeImgElement(img, imgInput, widthInput, heightInput, imgInputButton, imgRemoveButton);
|
|
|
+ blockArray = removeImgData(blockArray, preBlockindex, imgDataIndex);
|
|
|
+ }
|
|
|
} else {
|
|
|
if (parseBlockDiv === undefined){
|
|
|
// for skipping space before first title
|