UNPKG

@wordpress/block-library

Version:
28 lines (27 loc) • 855 B
import { createBlock, getBlockAttributes } from "@wordpress/blocks"; import metadata from "./block.json"; // packages/block-library/src/paragraph/transforms.js const { name } = metadata; const transforms = { from: [{ type: "raw", priority: 20, selector: "p", schema: ({ phrasingContentSchema, isPaste }) => ({ p: { children: phrasingContentSchema, attributes: isPaste ? [] : ["style", "id"] } }), transform(node) { const attributes = getBlockAttributes(name, node.outerHTML); const { textAlign } = node.style || {}; if (textAlign === "left" || textAlign === "center" || textAlign === "right") attributes.style = { ...attributes.style, typography: { ...attributes.style?.typography, textAlign } }; return createBlock(name, attributes); } }] }; export { transforms as default }; //# sourceMappingURL=transforms.mjs.map