UNPKG

@wordpress/block-library

Version:
8 lines (7 loc) 1.94 kB
{ "version": 3, "sources": ["../../src/paragraph/transforms.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock, getBlockAttributes } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\n\nconst { name } = metadata;\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\t// Paragraph is a fallback and should be matched last.\n\t\t\tpriority: 20,\n\t\t\tselector: 'p',\n\t\t\tschema: ( { phrasingContentSchema, isPaste } ) => ( {\n\t\t\t\tp: {\n\t\t\t\t\tchildren: phrasingContentSchema,\n\t\t\t\t\tattributes: isPaste ? [] : [ 'style', 'id' ],\n\t\t\t\t},\n\t\t\t} ),\n\t\t\ttransform( node ) {\n\t\t\t\tconst attributes = getBlockAttributes( name, node.outerHTML );\n\t\t\t\tconst { textAlign } = node.style || {};\n\n\t\t\t\tif (\n\t\t\t\t\ttextAlign === 'left' ||\n\t\t\t\t\ttextAlign === 'center' ||\n\t\t\t\t\ttextAlign === 'right'\n\t\t\t\t) {\n\t\t\t\t\tattributes.style = {\n\t\t\t\t\t\t...attributes.style,\n\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t...attributes.style?.typography,\n\t\t\t\t\t\t\ttextAlign,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn createBlock( name, attributes );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"], "mappings": ";AAGA,SAAS,aAAa,0BAA0B;AAKhD,OAAO,cAAc;AAErB,IAAM,EAAE,KAAK,IAAI;AAEjB,IAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA;AAAA,MAEN,UAAU;AAAA,MACV,UAAU;AAAA,MACV,QAAQ,CAAE,EAAE,uBAAuB,QAAQ,OAAS;AAAA,QACnD,GAAG;AAAA,UACF,UAAU;AAAA,UACV,YAAY,UAAU,CAAC,IAAI,CAAE,SAAS,IAAK;AAAA,QAC5C;AAAA,MACD;AAAA,MACA,UAAW,MAAO;AACjB,cAAM,aAAa,mBAAoB,MAAM,KAAK,SAAU;AAC5D,cAAM,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC;AAErC,YACC,cAAc,UACd,cAAc,YACd,cAAc,SACb;AACD,qBAAW,QAAQ;AAAA,YAClB,GAAG,WAAW;AAAA,YACd,YAAY;AAAA,cACX,GAAG,WAAW,OAAO;AAAA,cACrB;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAEA,eAAO,YAAa,MAAM,UAAW;AAAA,MACtC;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;", "names": [] }