【发布时间】:2023-02-01 09:12:05
【问题描述】:
在 Gutenberg 中编辑帖子时,我已经开始在 Web 开发人员控制台中看到以下通知:
wp.blockEditor.RichText 多行 prop 自 6.1 版起已弃用,并将在 6.3 版中删除。请改用嵌套块(InnerBlocks)。
我不确定我将如何将当前使用
<RichText>和多行属性的自定义静态 Gutenberg 块转换为<div>和<InnerBlocks />仍然尊重我构建的原始功能。这是edit()函数当前在块中的样子的简化示例:edit: ( props ) => { const blockProps = useBlockProps( { className: 'custom-cta p-0 mb-0' } ); const { attributes: { blurb }, setAttributes, className, isSelected } = props; return ( <div { ...blockProps }> <RichText tagName="div" multiline="p" className="custom-cta__blurb w-100" translate-name="blurb" onChange={ value => setAttributes( { blurb: value } ) } placeholder={ __( 'Subtext goes here (optional)', 'hello-tools' ) } value={ blurb } allowedFormats={ [ 'core/bold', 'core/italic' ] } focusOnInsert={ false } /> </div> ); }
【问题讨论】:
标签: javascript wordpress wordpress-gutenberg gutenberg-blocks