mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 09:30:48 +08:00
This commit is contained in:
parent
8b69979fba
commit
a742bd49a6
@ -32,16 +32,20 @@ export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
|
||||
}
|
||||
const renderElement = e.firstElementChild.nextElementSibling as HTMLElement;
|
||||
try {
|
||||
window.echarts.dispose(renderElement);
|
||||
const chartInstance = window.echarts.getInstanceById(renderElement.getAttribute("_echarts_instance_"))
|
||||
const option = await looseJsonParse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content")));
|
||||
if (chartInstance && chartInstance.getOption().series[0]?.type !== option.series[0]?.type) {
|
||||
chartInstance.clear();
|
||||
}
|
||||
renderElement.classList.remove("ft__error");
|
||||
renderElement.style.height = e.style.height;
|
||||
const option = await looseJsonParse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content")));
|
||||
window.echarts.init(renderElement, window.siyuan.config.appearance.mode === 1 ? "dark" : undefined, {width}).setOption(option);
|
||||
e.setAttribute("data-render", "true");
|
||||
if (!renderElement.textContent.endsWith(Constants.ZWSP)) {
|
||||
renderElement.firstElementChild.insertAdjacentText("beforeend", Constants.ZWSP);
|
||||
}
|
||||
} catch (error) {
|
||||
window.echarts.dispose(renderElement);
|
||||
renderElement.classList.add("ft__error");
|
||||
renderElement.innerHTML = `echarts render error: <br>${error}`;
|
||||
}
|
||||
|
10
app/src/types/index.d.ts
vendored
10
app/src/types/index.d.ts
vendored
@ -138,6 +138,8 @@ interface Window {
|
||||
dispose(element: Element): void;
|
||||
getInstanceById(id: string): {
|
||||
resize: () => void
|
||||
clear: () => void
|
||||
getOption: () => { series: { type: string }[] }
|
||||
};
|
||||
}
|
||||
ABCJS: {
|
||||
@ -180,10 +182,10 @@ interface Window {
|
||||
siyuan: ISiyuan
|
||||
webkit: {
|
||||
messageHandlers: {
|
||||
openLink:{postMessage: (url: string) => void}
|
||||
startKernelFast:{postMessage: (url: string) => void}
|
||||
changeStatusBar:{postMessage: (url: string) => void}
|
||||
setClipboard:{postMessage: (url: string) => void}
|
||||
openLink: { postMessage: (url: string) => void }
|
||||
startKernelFast: { postMessage: (url: string) => void }
|
||||
changeStatusBar: { postMessage: (url: string) => void }
|
||||
setClipboard: { postMessage: (url: string) => void }
|
||||
}
|
||||
}
|
||||
html2canvas: (element: Element, opitons: {
|
||||
|
Loading…
Reference in New Issue
Block a user