UNPKG

@wordpress/block-library

Version:
1 lines • 1.27 kB
{"version":3,"file":"transforms.cjs","names":["create","parse","createBlock"],"sources":["../../src/html/transforms.js"],"sourcesContent":["import { createBlock, parse } from '@wordpress/blocks';\nimport { create } from '@wordpress/rich-text';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/code' ],\n\t\t\ttransform: ( { content: html } ) => {\n\t\t\t\t// The code block may output HTML formatting, so convert it\n\t\t\t\t// to plain text, then parse it so any block delimiters become\n\t\t\t\t// editable inner blocks at their positions within the static\n\t\t\t\t// HTML, rather than inert comment text.\n\t\t\t\tconst text = create( { html } ).text;\n\t\t\t\tconst [ block ] = parse(\n\t\t\t\t\t`<!-- wp:html -->\\n${ text }\\n<!-- /wp:html -->`\n\t\t\t\t);\n\n\t\t\t\treturn block ?? createBlock( 'core/html', {}, [], [ text ] );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":";;;;;;;;AAGA,MAAM,aAAa,EAClB,MAAM,CACL;CACC,MAAM;CACN,QAAQ,CAAE,WAAY;CACtB,YAAa,EAAE,SAAS,WAAY;EAKnC,MAAM,QAAA,GAAOA,qBAAAA,OAAAA,CAAQ,EAAE,KAAK,CAAE,CAAC,CAAC;EAChC,MAAM,CAAE,UAAA,GAAUC,kBAAAA,MAAAA,CACjB,qBAAsB,KAAM,oBAC7B;EAEA,OAAO,UAAA,GAASC,kBAAAA,YAAAA,CAAa,aAAa,CAAC,GAAG,CAAC,GAAG,CAAE,IAAK,CAAE;CAC5D;AACD,CACD,EACD"}