{"version":3,"file":"transforms.mjs","names":[],"sources":["../../src/pullquote/transforms.js"],"sourcesContent":["import { createBlock } from '@wordpress/blocks';\nimport { create, join, toHTMLString } from '@wordpress/rich-text';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue: toHTMLString( {\n\t\t\t\t\t\tvalue: join(\n\t\t\t\t\t\t\tattributes.map( ( { content } ) =>\n\t\t\t\t\t\t\t\tcreate( { html: content } )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t'\\n'\n\t\t\t\t\t\t),\n\t\t\t\t\t} ),\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/heading' ],\n\t\t\ttransform: ( { content, anchor } ) => {\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue: content,\n\t\t\t\t\tanchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { value, citation } ) => {\n\t\t\t\tconst paragraphs = [];\n\t\t\t\tif ( value ) {\n\t\t\t\t\tparagraphs.push(\n\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( citation ) {\n\t\t\t\t\tparagraphs.push(\n\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( paragraphs.length === 0 ) {\n\t\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn paragraphs;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/heading' ],\n\t\t\ttransform: ( { value, citation } ) => {\n\t\t\t\t// If there is no pullquote content, use the citation as the\n\t\t\t\t// content of the resulting heading. A nonexistent citation\n\t\t\t\t// will result in an empty heading.\n\t\t\t\tif ( ! value ) {\n\t\t\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tconst headingBlock = createBlock( 'core/heading', {\n\t\t\t\t\tcontent: value,\n\t\t\t\t} );\n\t\t\t\tif ( ! citation ) {\n\t\t\t\t\treturn headingBlock;\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\theadingBlock,\n\t\t\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t} ),\n\t\t\t\t];\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":";;;AAGA,MAAM,aAAa;CAClB,MAAM,CACL;EACC,MAAM;EACN,cAAc;EACd,QAAQ,CAAE,gBAAiB;EAC3B,YAAa,eAAgB;GAC5B,OAAO,YAAa,kBAAkB;IACrC,OAAO,aAAc,EACpB,OAAO,KACN,WAAW,KAAO,EAAE,cACnB,OAAQ,EAAE,MAAM,QAAQ,CAAE,CAC3B,GACA,IACD,EACD,CAAE;IACF,QAAQ,WAAW;GACpB,CAAE;EACH;CACD,GACA;EACC,MAAM;EACN,QAAQ,CAAE,cAAe;EACzB,YAAa,EAAE,SAAS,aAAc;GACrC,OAAO,YAAa,kBAAkB;IACrC,OAAO;IACP;GACD,CAAE;EACH;CACD,CACD;CACA,IAAI,CACH;EACC,MAAM;EACN,QAAQ,CAAE,gBAAiB;EAC3B,YAAa,EAAE,OAAO,eAAgB;GACrC,MAAM,aAAa,CAAC;GACpB,IAAK,OACJ,WAAW,KACV,YAAa,kBAAkB,EAC9B,SAAS,MACV,CAAE,CACH;GAED,IAAK,UACJ,WAAW,KACV,YAAa,kBAAkB,EAC9B,SAAS,SACV,CAAE,CACH;GAED,IAAK,WAAW,WAAW,GAC1B,OAAO,YAAa,kBAAkB,EACrC,SAAS,GACV,CAAE;GAEH,OAAO;EACR;CACD,GACA;EACC,MAAM;EACN,QAAQ,CAAE,cAAe;EACzB,YAAa,EAAE,OAAO,eAAgB;GAIrC,IAAK,CAAE,OACN,OAAO,YAAa,gBAAgB,EACnC,SAAS,SACV,CAAE;GAEH,MAAM,eAAe,YAAa,gBAAgB,EACjD,SAAS,MACV,CAAE;GACF,IAAK,CAAE,UACN,OAAO;GAER,OAAO,CACN,cACA,YAAa,gBAAgB,EAC5B,SAAS,SACV,CAAE,CACH;EACD;CACD,CACD;AACD"}