嵌入
嵌入是一种简单的方式,可以在您的网站中包含应用程序。 添加以下代码到您的网站:
<iframe src="https://web.butterfly.linwood.dev/embed" width="100%" height="500px" allowtransparency="true"></iframe>| 选项 | 类型 | 默认设置 | 描述 |
|---|---|---|---|
| 保存 | 布尔值(true,false) | true | 启用保存。 如果禁用,只显示退出按钮 |
| 可编辑 | 布尔值(true,false) | true | 启用编辑。 如果禁用,文档将只读 |
| 语言 | 字符串 (…, 系统, 用户) | 系统 | 文件所用语文。 如果系统从浏览器中检测到该语言。 如果用户,语言将设置为用户首选项 |
如何使用的示例:
const embedElement = document.querySelector('#butterfly');embedElement.addEventListener('message', (data) => { if(data.detail.type === 'save') { console.log('Saving...', data.detail.message); }});The
saveevent is emitted when the user clicks the save button.
参数:
data(TypeList<int>): The data of the document.
The
exitevent is emitted when the user clicks the exit button.
参数:
data(TypeList<int>): The data of the document.
change
Section titled “change”The
changeevent is emitted when the user changes the document.
参数:
data(TypeList<int>): The data of the document.
如何使用它的示例:
const embedElement = document.querySelector('#butterfly');embedElement.pushMessage('getData', {});embedElement.addEventListener('message', (data) => { if(data.detail.type === 'getData') { console.log(data.detail.message); }});getData
Section titled “getData”The
getDatamethod returns the data of the document.
没有参数。
Returns: List<int>
setData
Section titled “setData”The
setDatamethod sets the data of the document.
参数:
data(TypeList<int>): The data of the document.
render
Section titled “render”The
rendermethod renders the document to a png image.
参数:
width(TypeNumber): The width of the image.height(TypeNumber): The height of the image.scale(TypeNumber): The scale of the image.renderBackground(TypeBoolean): If true, the background will be rendered.
Returns: String (Base64 encoded image)
renderSVG
Section titled “renderSVG”The
renderSVGmethod renders the document to a svg image.
参数:
width(TypeNumber): The width of the image.height(TypeNumber): The height of the image.renderBackground(TypeBoolean): If true, the background will be rendered.
Returns: String (SVG)