From 07584ec022cd6ef141352b1daaf136673ddfadc1 Mon Sep 17 00:00:00 2001 From: purocean Date: Fri, 29 Oct 2021 11:59:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20HTML=20=E5=B0=8F=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=97=A0=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- help/FEATURES.md | 7 +++++ src/renderer/plugins/markdown-applet.ts | 36 ++++++++++++++----------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/help/FEATURES.md b/help/FEATURES.md index 6484d9ab..656484bc 100644 --- a/help/FEATURES.md +++ b/help/FEATURES.md @@ -242,6 +242,13 @@ function run (type) { ``` +如果没有标题,将没有外部边框装饰 + +```html + + +``` + ## ECharts 图形 Js 代码块第一行包含以 `--echarts--` 字符串会被解析成 ECharts 图形,示例如下 diff --git a/src/renderer/plugins/markdown-applet.ts b/src/renderer/plugins/markdown-applet.ts index 7881704a..8f86807b 100644 --- a/src/renderer/plugins/markdown-applet.ts +++ b/src/renderer/plugins/markdown-applet.ts @@ -28,25 +28,31 @@ const MarkdownItPlugin = (md: Markdown) => { ${code} ` + const iframe = h(IFrame, { + html, + debounce: 1000, + globalStyle: true, + onLoad (iframe: HTMLIFrameElement) { + const win = iframe.contentWindow as any + win.appletId = appletId + win.init?.() + win.resize() + }, + iframeProps: { + class: 'applet-iframe', + height: '20px', + } + }) + + if (!appletTitle) { + return iframe + } + return h('fieldset', {}, [ h('legend', {}, `Applet: ${appletTitle}`), h('div', { class: 'applet' }, - h(IFrame, { - html, - debounce: 1000, - globalStyle: true, - onLoad (iframe: HTMLIFrameElement) { - const win = iframe.contentWindow as any - win.appletId = appletId - win.init?.() - win.resize() - }, - iframeProps: { - class: 'applet-iframe', - height: '20px', - } - }), + iframe, ) ]) as any }