@wordpress/block-library
Version:
Block library for the WordPress editor.
40 lines (39 loc) • 1.01 kB
JavaScript
import { createBlock } from "@wordpress/blocks";
// packages/block-library/src/preformatted/transforms.js
const transforms = {
from: [{
type: "block",
blocks: [
"core/code",
"core/paragraph",
"core/verse"
],
transform: ({ content, anchor }) => createBlock("core/preformatted", {
content,
anchor
})
}, {
type: "raw",
isMatch: (node) => node.nodeName === "PRE" && !(node.children.length === 1 && node.firstChild.nodeName === "CODE"),
schema: ({ phrasingContentSchema }) => ({ pre: { children: phrasingContentSchema } })
}],
to: [
{
type: "block",
blocks: ["core/paragraph"],
transform: (attributes) => createBlock("core/paragraph", attributes)
},
{
type: "block",
blocks: ["core/code"],
transform: (attributes) => createBlock("core/code", attributes)
},
{
type: "block",
blocks: ["core/verse"],
transform: (attributes) => createBlock("core/verse", attributes)
}
]
};
export { transforms as default };
//# sourceMappingURL=transforms.mjs.map