fixing cors issue
This commit is contained in:
parent
bca113b989
commit
7092fb601e
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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}`;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue