UNPKG

@wordpress/block-library

Version:
39 lines (38 loc) 1.11 kB
// packages/block-library/src/paragraph/transforms.js import { createBlock, getBlockAttributes } from "@wordpress/blocks"; import { name } from "./block.json"; var transforms = { from: [ { type: "raw", // Paragraph is a fallback and should be matched last. 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); } } ] }; var transforms_default = transforms; export { transforms_default as default }; //# sourceMappingURL=transforms.js.map