@wordpress/block-library
Version:
Block library for the WordPress editor.
51 lines (50 loc) • 1.05 kB
JavaScript
// packages/block-library/src/separator/transforms.js
import {
createBlock,
getBlockVariations,
getDefaultBlockName
} from "@wordpress/blocks";
var transforms = {
from: [
{
type: "input",
regExp: /^-{3,}$/,
transform: () => {
const defaultVariation = getBlockVariations(
"core/separator"
)?.find((variation) => variation.isDefault);
return [
createBlock(
"core/separator",
defaultVariation?.attributes ?? {}
),
createBlock(getDefaultBlockName())
];
}
},
{
type: "raw",
selector: "hr",
schema: {
hr: {}
}
}
],
to: [
{
type: "block",
blocks: ["core/spacer"],
// Transform to Spacer.
transform: ({ anchor }) => {
return createBlock("core/spacer", {
anchor: anchor || void 0
});
}
}
]
};
var transforms_default = transforms;
export {
transforms_default as default
};
//# sourceMappingURL=transforms.mjs.map