@wordpress/block-library
Version:
Block library for the WordPress editor.
8 lines (7 loc) • 1.52 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/utils/migrate-font-family.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\n/**\n * Migrates the current style.typography.fontFamily attribute,\n * whose value was \"var:preset|font-family|helvetica-arial\",\n * to the style.fontFamily attribute, whose value will be \"helvetica-arial\".\n *\n * @param {Object} attributes The current attributes\n * @return {Object} The updated attributes.\n */\nexport default function ( attributes ) {\n\tif ( ! attributes?.style?.typography?.fontFamily ) {\n\t\treturn attributes;\n\t}\n\n\tconst { fontFamily, ...typography } = attributes.style.typography;\n\n\treturn {\n\t\t...attributes,\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...attributes.style,\n\t\t\ttypography,\n\t\t} ),\n\t\tfontFamily: fontFamily.split( '|' ).pop(),\n\t};\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAsD;AAKtD,yBAAuB;AAEvB,IAAM,EAAE,iBAAiB,QAAI,2BAAQ,oBAAAA,WAAuB;AAU7C,SAAR,4BAAmB,YAAa;AACtC,MAAK,CAAE,YAAY,OAAO,YAAY,YAAa;AAClD,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,YAAY,GAAG,WAAW,IAAI,WAAW,MAAM;AAEvD,SAAO;AAAA,IACN,GAAG;AAAA,IACH,OAAO,iBAAkB;AAAA,MACxB,GAAG,WAAW;AAAA,MACd;AAAA,IACD,CAAE;AAAA,IACF,YAAY,WAAW,MAAO,GAAI,EAAE,IAAI;AAAA,EACzC;AACD;",
"names": ["blockEditorPrivateApis"]
}