@wordpress/block-library
Version:
Block library for the WordPress editor.
8 lines (7 loc) • 2.31 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/html/preview.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport {\n\ttransformStyles,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { SandBox } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n// Default styles used to unset some of the styles\n// that might be inherited from the editor style.\nconst DEFAULT_STYLES = `\n\thtml,body,:root {\n\t\tmargin: 0 !important;\n\t\tpadding: 0 !important;\n\t\toverflow: visible !important;\n\t\tmin-height: auto !important;\n\t}\n`;\n\nexport default function HTMLEditPreview( { content, isSelected } ) {\n\tconst settingStyles = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().styles,\n\t\t[]\n\t);\n\n\tconst styles = useMemo(\n\t\t() => [\n\t\t\tDEFAULT_STYLES,\n\t\t\t...transformStyles(\n\t\t\t\t( settingStyles ?? [] ).filter( ( style ) => style.css )\n\t\t\t),\n\t\t],\n\t\t[ settingStyles ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<SandBox\n\t\t\t\thtml={ content }\n\t\t\t\tstyles={ styles }\n\t\t\t\ttitle={ __( 'Custom HTML Preview' ) }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t/>\n\t\t\t{ /*\n\t\t\t\tAn overlay is added when the block is not selected in order to register click events.\n\t\t\t\tSome browsers do not bubble up the clicks from the sandboxed iframe, which makes it\n\t\t\t\tdifficult to reselect the block.\n\t\t\t*/ }\n\t\t\t{ ! isSelected && (\n\t\t\t\t<div className=\"block-library-html__preview-overlay\"></div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
"mappings": ";AAGA,SAAS,eAAe;AACxB;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AA8BjB,mBACC,KADD;AA1BF,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASR,SAAR,gBAAkC,EAAE,SAAS,WAAW,GAAI;AAClE,QAAM,gBAAgB;AAAA,IACrB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,YAAY,EAAE;AAAA,IACvD,CAAC;AAAA,EACF;AAEA,QAAM,SAAS;AAAA,IACd,MAAM;AAAA,MACL;AAAA,MACA,GAAG;AAAA,SACA,iBAAiB,CAAC,GAAI,OAAQ,CAAE,UAAW,MAAM,GAAI;AAAA,MACxD;AAAA,IACD;AAAA,IACA,CAAE,aAAc;AAAA,EACjB;AAEA,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP;AAAA,QACA,OAAQ,GAAI,qBAAsB;AAAA,QAClC,UAAW;AAAA;AAAA,IACZ;AAAA,IAME,CAAE,cACH,oBAAC,SAAI,WAAU,uCAAsC;AAAA,KAEvD;AAEF;",
"names": []
}