@wordpress/block-library
Version:
Block library for the WordPress editor.
117 lines (106 loc) • 2.16 kB
JavaScript
import { createElement } from "@wordpress/element";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { RichText, useBlockProps } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import migrateFontFamily from '../utils/migrate-font-family';
const v1 = {
attributes: {
content: {
type: 'string',
source: 'html',
selector: 'pre',
default: ''
},
textAlign: {
type: 'string'
}
},
save(_ref) {
let {
attributes
} = _ref;
const {
textAlign,
content
} = attributes;
return createElement(RichText.Content, {
tagName: "pre",
style: {
textAlign
},
value: content
});
}
};
const v2 = {
attributes: {
content: {
type: 'string',
source: 'html',
selector: 'pre',
default: '',
__unstablePreserveWhiteSpace: true,
__experimentalRole: 'content'
},
textAlign: {
type: 'string'
}
},
supports: {
anchor: true,
color: {
gradients: true,
link: true
},
typography: {
fontSize: true,
__experimentalFontFamily: true
},
spacing: {
padding: true
}
},
save(_ref2) {
let {
attributes
} = _ref2;
const {
textAlign,
content
} = attributes;
const className = classnames({
[`has-text-align-${textAlign}`]: textAlign
});
return createElement("pre", useBlockProps.save({
className
}), createElement(RichText.Content, {
value: content
}));
},
migrate: migrateFontFamily,
isEligible(_ref3) {
var _style$typography;
let {
style
} = _ref3;
return style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontFamily;
}
};
/**
* New deprecations need to be placed first
* for them to have higher priority.
*
* Old deprecations may need to be updated as well.
*
* See block-deprecation.md
*/
export default [v2, v1];
//# sourceMappingURL=deprecated.js.map