@wordpress/block-library
Version:
Block library for the WordPress editor.
50 lines • 1 kB
JavaScript
/**
* WordPress dependencies
*/
import { createBlock } from '@wordpress/blocks';
const transforms = {
from: [{
type: 'enter',
regExp: /^```$/,
transform: () => createBlock('core/code')
}, {
type: 'block',
blocks: ['core/html', 'core/paragraph'],
transform: _ref => {
let {
content
} = _ref;
return createBlock('core/code', {
content
});
}
}, {
type: 'raw',
isMatch: node => node.nodeName === 'PRE' && node.children.length === 1 && node.firstChild.nodeName === 'CODE',
schema: {
pre: {
children: {
code: {
children: {
'#text': {}
}
}
}
}
}
}],
to: [{
type: 'block',
blocks: ['core/paragraph'],
transform: _ref2 => {
let {
content
} = _ref2;
return createBlock('core/paragraph', {
content
});
}
}]
};
export default transforms;
//# sourceMappingURL=transforms.js.map