@wordpress/block-editor
Version:
50 lines (42 loc) • 1.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _hooks = require("@wordpress/hooks");
var _blocks = require("@wordpress/blocks");
var _components = require("@wordpress/components");
var _align = require("./align.js");
Object.keys(_align).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _align[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _align[key];
}
});
});
/**
* WordPress dependencies
*/
const ALIGNMENTS = ['left', 'center', 'right'];
// Used to filter out blocks that don't support wide/full alignment on mobile
(0, _hooks.addFilter)('blocks.registerBlockType', 'core/react-native-editor/align', (settings, name) => {
if (_components.WIDE_ALIGNMENTS.excludeBlocks.includes(name) && (0, _blocks.hasBlockSupport)(settings, 'align')) {
const blockAlign = settings.supports.align;
settings.supports = { ...settings.supports,
align: Array.isArray(blockAlign) ? blockAlign.filter(alignment => !Object.values(_components.WIDE_ALIGNMENTS.alignments).includes(alignment)) : blockAlign,
alignWide: false
};
settings.attributes = { ...settings.attributes,
align: {
type: 'string',
// Allow for '' since it is used by updateAlignment function
// in withToolbarControls for special cases with defined default values.
enum: [...ALIGNMENTS, '']
}
};
}
return settings;
});
//# sourceMappingURL=align.native.js.map