UNPKG

@wordpress/block-library

Version:
56 lines (51 loc) 1.56 kB
import { createElement } from "@wordpress/element"; /** * External dependencies */ import { View } from 'react-native'; /** * WordPress dependencies */ import { PlainText } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { usePreferredColorSchemeStyle } from '@wordpress/compose'; /** * Internal dependencies */ /** * Block code style */ import styles from './theme.scss'; // Note: styling is applied directly to the (nested) PlainText component. Web-side components // apply it to the container 'div' but we don't have a proper proposal for cascading styling yet. export function CodeEdit(props) { const { attributes, setAttributes, onFocus, onBlur, style } = props; const codeStyle = { ...usePreferredColorSchemeStyle(styles.blockCode, styles.blockCodeDark), ...((style === null || style === void 0 ? void 0 : style.fontSize) && { fontSize: style.fontSize }) }; const placeholderStyle = usePreferredColorSchemeStyle(styles.placeholder, styles.placeholderDark); return createElement(View, null, createElement(PlainText, { value: attributes.content, style: codeStyle, multiline: true, underlineColorAndroid: "transparent", onChange: content => setAttributes({ content }), placeholder: __('Write code…'), "aria-label": __('Code'), isSelected: props.isSelected, onFocus: onFocus, onBlur: onBlur, placeholderTextColor: placeholderStyle.color })); } export default CodeEdit; //# sourceMappingURL=edit.native.js.map