UNPKG

@wordpress/block-editor

Version:
93 lines (78 loc) 2.22 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _element = require("@wordpress/element"); var _reactNative = require("react-native"); var _blockEditor = require("@wordpress/block-editor"); var _compose = require("@wordpress/compose"); var _data = require("@wordpress/data"); var _styles = _interopRequireDefault(require("./styles.scss")); var _store = require("../../store"); /** * External dependencies */ /** * WordPress dependencies */ /** * Internal dependencies */ const BlockCaption = ({ accessible, accessibilityLabelCreator, onBlur, onChange, onFocus, isSelected, shouldDisplay, text, insertBlocksAfter }) => (0, _element.createElement)(_reactNative.View, { style: [_styles.default.container, shouldDisplay && _styles.default.padding] }, (0, _element.createElement)(_blockEditor.Caption, { accessibilityLabelCreator: accessibilityLabelCreator, accessible: accessible, isSelected: isSelected, onBlur: onBlur, onChange: onChange, onFocus: onFocus, shouldDisplay: shouldDisplay, value: text, insertBlocksAfter: insertBlocksAfter })); var _default = (0, _compose.compose)([(0, _data.withSelect)((select, { clientId }) => { const { getBlockAttributes, getSelectedBlockClientId } = select(_store.store); const { caption } = getBlockAttributes(clientId) || {}; const isBlockSelected = getSelectedBlockClientId() === clientId; // We'll render the caption so that the soft keyboard is not forced to close on Android // but still hide it by setting its display style to none. See wordpress-mobile/gutenberg-mobile#1221 const shouldDisplay = !_blockEditor.RichText.isEmpty(caption) > 0 || isBlockSelected; return { shouldDisplay, text: caption }; }), (0, _data.withDispatch)((dispatch, { clientId }) => { const { updateBlockAttributes } = dispatch(_store.store); return { onChange: caption => { updateBlockAttributes(clientId, { caption }); } }; })])(BlockCaption); exports.default = _default; //# sourceMappingURL=index.native.js.map