@wordpress/block-library
Version:
Block library for the WordPress editor.
44 lines • 1.01 kB
JavaScript
/**
* WordPress dependencies
*/
import { createBlock } from '@wordpress/blocks';
const transforms = {
from: [{
type: 'block',
blocks: ['core/code', 'core/paragraph'],
transform: _ref => {
let {
content,
anchor
} = _ref;
return createBlock('core/preformatted', {
content,
anchor
});
}
}, {
type: 'raw',
isMatch: node => node.nodeName === 'PRE' && !(node.children.length === 1 && node.firstChild.nodeName === 'CODE'),
schema: _ref2 => {
let {
phrasingContentSchema
} = _ref2;
return {
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)
}]
};
export default transforms;
//# sourceMappingURL=transforms.js.map