@wordpress/block-library
Version:
Block library for the WordPress editor.
28 lines (27 loc) • 1.13 kB
JavaScript
import { useMemo } from "@wordpress/element";
import { store, transformStyles } from "@wordpress/block-editor";
import { SandBox } from "@wordpress/components";
import { useSelect } from "@wordpress/data";
import { __ } from "@wordpress/i18n";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
// packages/block-library/src/html/preview.jsx
const DEFAULT_STYLES = `
html,body,:root {
margin: 0 !important;
padding: 0 !important;
overflow: visible !important;
min-height: auto !important;
}
`;
function HTMLEditPreview({ content, isSelected }) {
const settingStyles = useSelect((select) => select(store).getSettings().styles, []);
const styles = useMemo(() => [DEFAULT_STYLES, ...transformStyles((settingStyles ?? []).filter((style) => style.css))], [settingStyles]);
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SandBox, {
html: content,
styles,
title: __("Custom HTML Preview"),
tabIndex: -1
}), !isSelected && /* @__PURE__ */ jsx("div", { className: "block-library-html__preview-overlay" })] });
}
export { HTMLEditPreview as default };
//# sourceMappingURL=preview.mjs.map