@wordpress/block-library
Version:
Block library for the WordPress editor.
27 lines (26 loc) • 945 B
JavaScript
import { privateApis } from "@wordpress/block-editor";
import { unlock } from "../lock-unlock.mjs";
// packages/block-library/src/utils/migrate-font-family.js
const { cleanEmptyObject } = unlock(privateApis);
/**
* Migrates the current style.typography.fontFamily attribute,
* whose value was "var:preset|font-family|helvetica-arial",
* to the style.fontFamily attribute, whose value will be "helvetica-arial".
*
* @param {Object} attributes The current attributes
* @return {Object} The updated attributes.
*/
function migrate_font_family_default(attributes) {
if (!attributes?.style?.typography?.fontFamily) return attributes;
const { fontFamily, ...typography } = attributes.style.typography;
return {
...attributes,
style: cleanEmptyObject({
...attributes.style,
typography
}),
fontFamily: fontFamily.split("|").pop()
};
}
export { migrate_font_family_default as default };
//# sourceMappingURL=migrate-font-family.mjs.map