UNPKG

@gechiui/block-editor

Version:
98 lines (83 loc) 2.33 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _element = require("@gechiui/element"); var _reactNative = require("react-native"); var _blockEditor = require("@gechiui/block-editor"); var _compose = require("@gechiui/compose"); var _data = require("@gechiui/data"); var _styles = _interopRequireDefault(require("./styles.scss")); var _store = require("../../store"); /** * External dependencies */ /** * GeChiUI dependencies */ /** * Internal dependencies */ const BlockCaption = _ref => { let { accessible, accessibilityLabelCreator, onBlur, onChange, onFocus, isSelected, shouldDisplay, text, insertBlocksAfter } = _ref; return (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, _ref2) => { let { clientId } = _ref2; 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 gechiui-mobile/gutenberg-mobile#1221 const shouldDisplay = !_blockEditor.RichText.isEmpty(caption) > 0 || isBlockSelected; return { shouldDisplay, text: caption }; }), (0, _data.withDispatch)((dispatch, _ref3) => { let { clientId } = _ref3; const { updateBlockAttributes } = dispatch(_store.store); return { onChange: caption => { updateBlockAttributes(clientId, { caption }); } }; })])(BlockCaption); exports.default = _default; //# sourceMappingURL=index.native.js.map