ECharts 图表块支持 loose-json (#6917)

* 🎨 ECharts 图表块支持 loose-json

* 📝 更新用户手册 ECharts 相关内容

* 📝 更新用户手册 ECharts 相关内容
This commit is contained in:
颖逸 2022-12-25 10:27:02 +08:00 committed by GitHub
parent a96d6a019f
commit 27c9ac2b25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 799 additions and 28 deletions

View file

@ -8,7 +8,7 @@
"title": "Formatting elements",
"title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;",
"type": "doc",
"updated": "20221105164926"
"updated": "20221225013408"
},
"Children": [
{
@ -3119,25 +3119,281 @@
]
},
{
"ID": "20221105164926-hhpq6np",
"ID": "20221225013111-k0tinm3",
"Type": "NodeParagraph",
"Properties": {
"id": "20221105164926-hhpq6np",
"updated": "20221105164926"
"id": "20221225013111-k0tinm3",
"updated": "20221225013144"
},
"Children": [
{
"Type": "NodeText",
"Data": "The JSON format in the form of "
"Data": "It can be defined in the following three formats:"
}
]
},
{
"ID": "20221225013111-f97ur4a",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225013111-f97ur4a",
"updated": "20221225013408"
},
"Children": [
{
"ID": "20221225013111-jhcu06t",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225013111-jhcu06t",
"updated": "20221225013111"
},
"Children": [
{
"ID": "20221225013111-6lkoa8j",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225013111-6lkoa8j",
"updated": "20221225013111"
},
"Children": [
{
"Type": "NodeText",
"Data": "JSON"
}
]
},
{
"ID": "20221225013111-t6sb6j6",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225013111-t6sb6j6",
"updated": "20221225013111"
},
"Children": [
{
"ID": "20221225013111-7mps9wm",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225013111-7mps9wm",
"updated": "20221225013111"
},
"Children": [
{
"ID": "20221225013111-r6474wt",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225013111-r6474wt",
"updated": "20221225013111"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "anNvbg=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "{\n \"propName\": \"propValue\"\n}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "{\u0026quot;key\u0026quot;: \u0026quot;value\u0026quot;}"
"ID": "20221225013111-whe7nls",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225013111-whe7nls",
"updated": "20221225013111"
},
"Children": [
{
"ID": "20221225013111-nspyxcz",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225013111-nspyxcz",
"updated": "20221225013111"
},
"Children": [
{
"Type": "NodeText",
"Data": "JavaScript Object"
}
]
},
{
"ID": "20221225013111-unluh7r",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225013111-unluh7r",
"updated": "20221225013111"
},
"Children": [
{
"ID": "20221225013111-oy9fq7l",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225013111-oy9fq7l",
"updated": "20221225013111"
},
"Children": [
{
"ID": "20221225013111-hdaldw8",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225013111-hdaldw8",
"updated": "20221225013111"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "amF2YXNjcmlwdA=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "{\n propName: 'propValue',\n}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
},
{
"ID": "20221225013111-jpxi1rx",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225013111-jpxi1rx",
"updated": "20221225013408"
},
"Children": [
{
"ID": "20221225013111-n32s76k",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225013111-n32s76k",
"updated": "20221225013408"
},
"Children": [
{
"Type": "NodeText",
"Data": "An Immediately-Invoked Function Expression (IIFE) that returns a JavaScript Object"
}
]
},
{
"ID": "20221225013111-ech372z",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225013111-ech372z",
"updated": "20221225013111"
},
"Children": [
{
"ID": "20221225013111-hhjn30z",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225013111-hhjn30z",
"updated": "20221225013111"
},
"Children": [
{
"ID": "20221225013111-vq3lqmp",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225013111-vq3lqmp",
"updated": "20221225013111"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "amF2YXNjcmlwdA=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "(() =\u003e {\n const option = {};\n option.propName = `propValue`;\n return option;\n})()\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
}
]
},
{
"ID": "20221105164926-hhpq6np",
"Type": "NodeParagraph",
"Properties": {
"id": "20221105164926-hhpq6np",
"updated": "20221225013054"
},
"Children": [
{
"Type": "NodeText",
"Data": " is required. For the syntax, please refer to "
"Data": "For the specific syntax, please refer to "
},
{
"Type": "NodeTextMark",

View file

@ -8,7 +8,7 @@
"title": "排版元素",
"title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);",
"type": "doc",
"updated": "20221105164605"
"updated": "20221225012910"
},
"Children": [
{
@ -3116,25 +3116,278 @@
]
},
{
"ID": "20221105164044-b22rtsr",
"ID": "20221225011731-fkkxxrw",
"Type": "NodeParagraph",
"Properties": {
"id": "20221105164044-b22rtsr",
"updated": "20221105164605"
"id": "20221225011731-fkkxxrw",
"updated": "20221225012400"
},
"Children": [
{
"Type": "NodeText",
"Data": "需使用 "
"Data": "可使用如下三种格式定义:"
}
]
},
{
"ID": "20221225011757-zcfae5d",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225011757-zcfae5d",
"updated": "20221225012910"
},
"Children": [
{
"ID": "20221225011757-ojf9val",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225011757-ojf9val",
"updated": "20221225012827"
},
"Children": [
{
"ID": "20221225011757-48mzmh0",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225011757-48mzmh0",
"updated": "20221225011759"
},
"Children": [
{
"Type": "NodeText",
"Data": "JSON"
}
]
},
{
"ID": "20221225012020-fclr7wc",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225012020-fclr7wc",
"updated": "20221225012827"
},
"Children": [
{
"ID": "20221225012020-ccv0cpm",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012020-ccv0cpm",
"updated": "20221225012827"
},
"Children": [
{
"ID": "20221225012020-a7nibhu",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225012020-a7nibhu",
"updated": "20221225012827"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "anNvbg=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "{\n \"propName\": \"propValue\"\n}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "{\u0026quot;key\u0026quot;: \u0026quot;value\u0026quot;}"
"ID": "20221225011800-6pbspkn",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225011800-6pbspkn"
},
"Children": [
{
"ID": "20221225011800-2y5560p",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225011800-2y5560p",
"updated": "20221225011804"
},
"Children": [
{
"Type": "NodeText",
"Data": "JavaScript Object"
}
]
},
{
"ID": "20221225012504-vri2cye",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225012504-vri2cye"
},
"Children": [
{
"ID": "20221225012503-52bpd8m",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012503-52bpd8m"
},
"Children": [
{
"ID": "20221225012503-osjhbni",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225012503-osjhbni",
"updated": "20221225012615"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "amF2YXNjcmlwdA=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "{\n propName: 'propValue',\n}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
},
{
"ID": "20221225011805-qla9i5b",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225011805-qla9i5b",
"updated": "20221225012910"
},
"Children": [
{
"ID": "20221225011805-gv1d4ep",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225011805-gv1d4ep",
"updated": "20221225012006"
},
"Children": [
{
"Type": "NodeText",
"Data": "返回一个 JavaScript Object 的立即执行函数"
}
]
},
{
"ID": "20221225012629-qdzqfiq",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225012629-qdzqfiq",
"updated": "20221225012910"
},
"Children": [
{
"ID": "20221225012629-wkougnr",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012629-wkougnr",
"updated": "20221225012910"
},
"Children": [
{
"ID": "20221225012629-1ha6h2j",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225012629-1ha6h2j",
"updated": "20221225012910"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "amF2YXNjcmlwdA=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "(() =\u003e {\n const option = {};\n option.propName = `propValue`;\n return option;\n})()\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
}
]
},
{
"ID": "20221105164044-b22rtsr",
"Type": "NodeParagraph",
"Properties": {
"id": "20221105164044-b22rtsr",
"updated": "20221225012142"
},
"Children": [
{
"Type": "NodeText",
"Data": " 形式的 JSON 格式,语法请参考 "
"Data": "具体语法请参考 "
},
{
"Type": "NodeTextMark",

View file

@ -7,7 +7,7 @@
"id": "20211226121319-emrk2yy",
"title": "排版元素",
"title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);",
"updated": "20221105165105"
"updated": "20221225013013"
},
"Children": [
{
@ -3093,25 +3093,281 @@
]
},
{
"ID": "20221105165104-31b4raz",
"ID": "20221225012231-gx68k6u",
"Type": "NodeParagraph",
"Properties": {
"id": "20221105165104-31b4raz",
"updated": "20221105165105"
"id": "20221225012231-gx68k6u",
"updated": "20221225012248"
},
"Children": [
{
"Type": "NodeText",
"Data": "需使用 "
"Data": "可使用如下三種格式定義:"
}
]
},
{
"ID": "20221225012948-i6bceww",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225012948-i6bceww",
"updated": "20221225013013"
},
"Children": [
{
"ID": "20221225012948-g2nbl2p",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012948-g2nbl2p",
"updated": "20221225012948"
},
"Children": [
{
"ID": "20221225012948-bebbc68",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225012948-bebbc68",
"updated": "20221225012948"
},
"Children": [
{
"Type": "NodeText",
"Data": "JSON"
}
]
},
{
"ID": "20221225012948-si3kytj",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225012948-si3kytj",
"updated": "20221225012948"
},
"Children": [
{
"ID": "20221225012948-4hjr5xi",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012948-4hjr5xi",
"updated": "20221225012948"
},
"Children": [
{
"ID": "20221225012948-jhn1wm0",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225012948-jhn1wm0",
"updated": "20221225012948"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "anNvbg=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "{\n \"propName\": \"propValue\"\n}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "{\u0026quot;key\u0026quot;: \u0026quot;value\u0026quot;}"
"ID": "20221225012948-5583jn8",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012948-5583jn8",
"updated": "20221225012948"
},
"Children": [
{
"ID": "20221225012948-axegxwv",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225012948-axegxwv",
"updated": "20221225012948"
},
"Children": [
{
"Type": "NodeText",
"Data": "JavaScript Object"
}
]
},
{
"ID": "20221225012948-w1w6605",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225012948-w1w6605",
"updated": "20221225012948"
},
"Children": [
{
"ID": "20221225012948-dcmh3u7",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012948-dcmh3u7",
"updated": "20221225012948"
},
"Children": [
{
"ID": "20221225012948-6envn24",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225012948-6envn24",
"updated": "20221225012948"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "amF2YXNjcmlwdA=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "{\n propName: 'propValue',\n}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
},
{
"ID": "20221225012948-u5z9jmr",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012948-u5z9jmr",
"updated": "20221225013013"
},
"Children": [
{
"ID": "20221225012948-7htzbq0",
"Type": "NodeParagraph",
"Properties": {
"id": "20221225012948-7htzbq0",
"updated": "20221225013013"
},
"Children": [
{
"Type": "NodeText",
"Data": "返回一個 JavaScript Object 的立即執行函數"
}
]
},
{
"ID": "20221225012948-2d26uk8",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221225012948-2d26uk8",
"updated": "20221225012948"
},
"Children": [
{
"ID": "20221225012948-0pxhnd0",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221225012948-0pxhnd0",
"updated": "20221225012948"
},
"Children": [
{
"ID": "20221225012948-27doejs",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20221225012948-27doejs",
"updated": "20221225012948"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker",
"CodeBlockInfo": "amF2YXNjcmlwdA=="
},
{
"Type": "NodeCodeBlockCode",
"Data": "(() =\u003e {\n const option = {};\n option.propName = `propValue`;\n return option;\n})()\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
}
]
}
]
}
]
},
{
"ID": "20221105165104-31b4raz",
"Type": "NodeParagraph",
"Properties": {
"id": "20221105165104-31b4raz",
"updated": "20221225012323"
},
"Children": [
{
"Type": "NodeText",
"Data": " 形式的 JSON 格式,語法請參考 "
"Data": "具體語法請參考 "
},
{
"Type": "NodeTextMark",

View file

@ -1,6 +1,7 @@
import {addScript} from "../util/addScript";
import {Constants} from "../../constants";
import {hasClosestByClassName} from "../util/hasClosest";
import {looseJsonParse} from "../../util/functions";
export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
let echartsElements: Element[] = [];
@ -38,7 +39,7 @@ export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
const renderElement = e.firstElementChild.nextElementSibling as HTMLElement;
try {
renderElement.style.height = e.style.height;
const option = JSON.parse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content")));
const option = looseJsonParse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content")));
echarts.init(renderElement, window.siyuan.config.appearance.mode === 1 ? "dark" : undefined, {width}).setOption(option);
e.setAttribute("data-render", "true");
renderElement.classList.remove("ft__error");

View file

@ -45,3 +45,8 @@ export const isDynamicRef = (text: string) => {
export const isFileAnnotation = (text: string) => {
return /^<<assets\/.+\/\d{14}-\w{7} ".+">>$/.test(text);
};
// REF https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/eval
export const looseJsonParse = (text: string) => {
return Function(`"use strict";return (${text})`)();
}