该组件通过 iframe 为任意 HTML 提供隔离环境。

用法

import { SandBox } from '@wordpress/components';

const MySandBox = () => (
    <SandBox html="<p>Content</p>" title="SandBox" type="embed" />
);

属性

html: string

要在 iframe 文档 body 中渲染的 HTML。

  • 是否必需:否
  • 默认值:“”

onFocus: React.DOMAttributes< HTMLIFrameElement >[ ‘onFocus’ ]

iframe 的 onFocus 回调函数。

  • 是否必需:否

scripts: string[]

要注入到 iframe 文档 <body> 底部的 <script> 标签的脚本 URL 数组。

  • 是否必需:否
  • 默认值:[]

styles: string[]

要注入到 iframe 文档 <head> 的 CSS 字符串数组。

  • 是否必需:否
  • 默认值:[]

title: string

iframe 文档的 <title>。

  • 是否必需:否
  • 默认值:“”

type: string

应用于 iframe 的 <html> 和 <body> 元素的 CSS 类名。

  • 是否必需:否
  • 默认值:“”

tabIndex: HTMLElement[ ‘tabIndex’ ]

iframe 应接收的 tabindex。

  • 是否必需:否