fix: img compress (#546)

This commit is contained in:
Archer
2023-12-03 23:56:45 +08:00
committed by GitHub
parent 7fc05af09e
commit 9c77dfbddd
6 changed files with 14 additions and 7 deletions

View File

@@ -92,6 +92,7 @@ export const compressBase64ImgAndUpload = ({
reject(error);
}
};
img.onerror = reject;
});
};
export const compressImgFileAndUpload = async ({

View File

@@ -187,6 +187,7 @@ export const formatMarkdown = async (rawText: string = '') => {
maxH: 4329,
maxSize: 1024 * 1024 * 5
});
rawText = rawText.replace(base64, str);
} catch (error) {
rawText = rawText.replace(base64, '');
@@ -194,6 +195,7 @@ export const formatMarkdown = async (rawText: string = '') => {
}
})
);
// Remove white space on both sides of the picture
const trimReg = /\s*(!\[.*\]\(.*\))\s*/g;
if (trimReg.test(rawText)) {