|
@@ -1,6 +1,7 @@
|
|
import {Constants} from "../constants";
|
|
import {Constants} from "../constants";
|
|
import {addScript} from "../util/addScript";
|
|
import {addScript} from "../util/addScript";
|
|
import {chartRenderAdapter} from "./adapterRender";
|
|
import {chartRenderAdapter} from "./adapterRender";
|
|
|
|
+import {looseJsonParse} from "../util/function";
|
|
|
|
|
|
declare const echarts: {
|
|
declare const echarts: {
|
|
init(element: HTMLElement, theme?: string): IEChart;
|
|
init(element: HTMLElement, theme?: string): IEChart;
|
|
@@ -10,7 +11,7 @@ export const chartRender = (element: (HTMLElement | Document) = document, cdn =
|
|
const echartsElements = chartRenderAdapter.getElements(element);
|
|
const echartsElements = chartRenderAdapter.getElements(element);
|
|
if (echartsElements.length > 0) {
|
|
if (echartsElements.length > 0) {
|
|
addScript(`${cdn}/dist/js/echarts/echarts.min.js?v=5.5.1`, "vditorEchartsScript").then(() => {
|
|
addScript(`${cdn}/dist/js/echarts/echarts.min.js?v=5.5.1`, "vditorEchartsScript").then(() => {
|
|
- echartsElements.forEach((e: HTMLDivElement) => {
|
|
|
|
|
|
+ echartsElements.forEach(async (e: HTMLDivElement) => {
|
|
if (e.parentElement.classList.contains("vditor-wysiwyg__pre") ||
|
|
if (e.parentElement.classList.contains("vditor-wysiwyg__pre") ||
|
|
e.parentElement.classList.contains("vditor-ir__marker--pre")) {
|
|
e.parentElement.classList.contains("vditor-ir__marker--pre")) {
|
|
return;
|
|
return;
|
|
@@ -24,7 +25,7 @@ export const chartRender = (element: (HTMLElement | Document) = document, cdn =
|
|
if (e.getAttribute("data-processed") === "true") {
|
|
if (e.getAttribute("data-processed") === "true") {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- const option = JSON.parse(text);
|
|
|
|
|
|
+ const option = await looseJsonParse(text);
|
|
echarts.init(e, theme === "dark" ? "dark" : undefined).setOption(option);
|
|
echarts.init(e, theme === "dark" ? "dark" : undefined).setOption(option);
|
|
e.setAttribute("data-processed", "true");
|
|
e.setAttribute("data-processed", "true");
|
|
} catch (error) {
|
|
} catch (error) {
|