feat: HTML 小工具支持无边框

This commit is contained in:
purocean
2021-10-29 12:01:31 +08:00
parent 23e751fbfa
commit 07584ec022
2 changed files with 28 additions and 15 deletions
+7
View File
@@ -242,6 +242,13 @@ function run (type) {
</div>
```
如果没有标题,将没有外部边框装饰
```html
<!-- --applet-- -->
<button onclick="ctx.ui.useToast().show(`info`, `HELLOWORLD!`)">HELLO</button>
```
## ECharts 图形
Js 代码块第一行包含以 `--echarts--` 字符串会被解析成 ECharts 图形,示例如下
+21 -15
View File
@@ -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
}