fixing cors issue

This commit is contained in:
hkgnp 2022-02-15 16:30:01 +08:00
parent 48d80f1889
commit bca113b989
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.6",
"version": "1.0.7",
"description": "",
"main": "dist/index.html",
"targets": {

View File

@ -19,8 +19,8 @@ export const renderMermaid = async (type, payload, colour, mermaidUUID) => {
);
};
const handleEvent = async (e) => {
if (e.currentTarget.response !== 'invalid encoded code') {
// const handleEvent = async (e) => {
// if (e.currentTarget.response !== 'invalid encoded code') {
if (colour === undefined) {
renderBlock(`<img src="https://mermaid.ink/img/${jsonString}" />`);
} else if (colour.startsWith('#')) {
@ -36,15 +36,15 @@ 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>'
);
}
};
// } 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;
// let req = new XMLHttpRequest();
// req.open('GET', `https://mermaid.ink/img/${jsonString}`, true);
// req.send();
// req.onload = handleEvent;
};