fixing cors issue
This commit is contained in:
parent
bca113b989
commit
7092fb601e
|
|
@ -5,7 +5,7 @@
|
||||||
"icon": "./icon.svg"
|
"icon": "./icon.svg"
|
||||||
},
|
},
|
||||||
"name": "logseq-mermaid-plugin",
|
"name": "logseq-mermaid-plugin",
|
||||||
"version": "1.0.7",
|
"version": "1.0.8",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.html",
|
"main": "dist/index.html",
|
||||||
"targets": {
|
"targets": {
|
||||||
|
|
|
||||||
|
|
@ -19,32 +19,32 @@ export const renderMermaid = async (type, payload, colour, mermaidUUID) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// const handleEvent = async (e) => {
|
const handleEvent = async () => {
|
||||||
// if (e.currentTarget.response !== 'invalid encoded code') {
|
if (colour === undefined) {
|
||||||
if (colour === undefined) {
|
renderBlock(`<img src="https://mermaid.ink/img/${jsonString}" />`);
|
||||||
renderBlock(`<img src="https://mermaid.ink/img/${jsonString}" />`);
|
} else if (colour.startsWith('#')) {
|
||||||
} else if (colour.startsWith('#')) {
|
renderBlock(
|
||||||
renderBlock(
|
`<img src="https://mermaid.ink/img/${jsonString}?bgColor=${colour.substring(
|
||||||
`<img src="https://mermaid.ink/img/${jsonString}?bgColor=${colour.substring(
|
1
|
||||||
1
|
)}" />`
|
||||||
)}" />`
|
);
|
||||||
);
|
} else if (!colour.startsWith('#')) {
|
||||||
} else if (!colour.startsWith('#')) {
|
renderBlock(
|
||||||
renderBlock(
|
`<img src="https://mermaid.ink/img/${jsonString}?bgColor=!${colour}" />`
|
||||||
`<img src="https://mermaid.ink/img/${jsonString}?bgColor=!${colour}" />`
|
);
|
||||||
);
|
} else {
|
||||||
} else {
|
renderBlock(`<img src="https://mermaid.ink/img/${jsonString}" />`);
|
||||||
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();
|
const handleError = () => {
|
||||||
// req.open('GET', `https://mermaid.ink/img/${jsonString}`, true);
|
renderBlock(
|
||||||
// req.send();
|
'<p>There is an error with your mermaid syntax. Please rectify and render again.</p>'
|
||||||
// req.onload = handleEvent;
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const image = new Image();
|
||||||
|
image.onload = handleEvent;
|
||||||
|
image.onerror = handleError;
|
||||||
|
image.src = `https://mermaid.ink/img/${jsonString}`;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue