@wordpress/block-editor
Version:
61 lines (57 loc) • 2.27 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _compose = require("@wordpress/compose");
var _block = _interopRequireDefault(require("./block.scss"));
var _jsxRuntime = require("react/jsx-runtime");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const TEXT_BLOCKS_WITH_OUTLINE = ['core/missing', 'core/freeform'];
const DESIGN_BLOCKS_WITHOUT_OUTLINE = ['core/button', 'core/spacer'];
const MEDIA_BLOCKS_WITH_OUTLINE = ['core/audio', 'core/file'];
function BlockOutline({
blockCategory,
hasInnerBlocks,
isSelected,
name
}) {
const textBlockWithOutline = TEXT_BLOCKS_WITH_OUTLINE.includes(name);
const hasBlockTextCategory = blockCategory === 'text' && !textBlockWithOutline;
const hasBlockMediaCategory = blockCategory === 'media' || blockCategory === 'embed' || !blockCategory;
const shouldShowCompactOutline = hasBlockMediaCategory && !hasInnerBlocks || textBlockWithOutline;
const styleSolidBorder = [_block.default.solidBorder, (0, _compose.usePreferredColorSchemeStyle)(_block.default.solidBorderColor, _block.default.solidBorderColorDark), shouldShowCompactOutline && _block.default.solidBorderCompact, hasBlockTextCategory && _block.default.solidBorderTextContent];
if (!isSelected) {
return null;
}
let shouldShowOutline = true;
if (hasBlockTextCategory && !hasInnerBlocks) {
shouldShowOutline = false;
} else if (blockCategory === 'media' && !hasInnerBlocks && !MEDIA_BLOCKS_WITH_OUTLINE.includes(name)) {
shouldShowOutline = false;
} else if (blockCategory === 'media' && name === 'core/cover') {
shouldShowOutline = false;
} else if (blockCategory === 'design' && DESIGN_BLOCKS_WITHOUT_OUTLINE.includes(name)) {
shouldShowOutline = false;
}
if (shouldShowOutline) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
pointerEvents: "box-none",
style: styleSolidBorder,
testID: "block-outline"
});
}
return null;
}
var _default = exports.default = BlockOutline;
//# sourceMappingURL=block-outline.native.js.map
;