fixing cors issue

This commit is contained in:
hkgnp 2022-02-15 16:38:24 +08:00
parent bca113b989
commit 7092fb601e
2 changed files with 28 additions and 28 deletions

View File

@ -5,7 +5,7 @@
"icon": "./icon.svg"
},
"name": "logseq-mermaid-plugin",
"version": "1.0.7",
"version": "1.0.8",
"description": "",
"main": "dist/index.html",
"targets": {

View File

@ -19,8 +19,7 @@ export const renderMermaid = async (type, payload, colour, mermaidUUID) => {
);
};
// const handleEvent = async (e) => {
// if (e.currentTarget.response !== 'invalid encoded code') {
const handleEvent = async () => {
if (colour === undefined) {
renderBlock(`<img src="https://mermaid.ink/img/${jsonString}" />`);
} else if (colour.startsWith('#')) {
@ -36,15 +35,16 @@ export const renderMermaid = async (type, payload, colour, mermaidUUID) => {
} else {
renderBlock(`<img src="https://mermaid.ink/img/${jsonString}" />`);
}
// } else {
// renderBlock(
// '<p>There is an error with your mermaid syntax. Please rectify and render again.</p>'
// );
// }
// };
};
// let req = new XMLHttpRequest();
// req.open('GET', `https://mermaid.ink/img/${jsonString}`, true);
// req.send();
// req.onload = handleEvent;
const handleError = () => {
renderBlock(
'<p>There is an error with your mermaid syntax. Please rectify and render again.</p>'
);
};
const image = new Image();
image.onload = handleEvent;
image.onerror = handleError;
image.src = `https://mermaid.ink/img/${jsonString}`;
};