Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RichText: Switch from disableEditing to standard html readonly attrib…
Browse files Browse the repository at this point in the history
…ute (WordPress#60327)

Co-authored-by: glendaviesnz <glendaviesnz@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: retrofox <retrofox@git.wordpress.org>
4 people authored and cbravobernal committed Apr 9, 2024
1 parent 7684da6 commit 57d03cc
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ export function RichTextWrapper(
__unstableDisableFormats: disableFormats,
disableLineBreaks,
__unstableAllowPrefixTransformations,
disableEditing,
readOnly,
...props
},
forwardedRef
@@ -202,7 +202,7 @@ export function RichTextWrapper(
[ blockBindings, blockName ]
);

const shouldDisableEditing = disableEditing || disableBoundBlocks;
const shouldDisableEditing = readOnly || disableBoundBlocks;

const { getSelectionStart, getSelectionEnd, getBlockRootClientId } =
useSelect( blockEditorStore );
@@ -485,9 +485,7 @@ PrivateRichText.isEmpty = ( value ) => {
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
*/
const PublicForwardedRichTextContainer = forwardRef( ( props, ref ) => {
return (
<PrivateRichText ref={ ref } { ...props } disableEditing={ false } />
);
return <PrivateRichText ref={ ref } { ...props } readOnly={ false } />;
} );

PublicForwardedRichTextContainer.Content = Content;
2 changes: 1 addition & 1 deletion packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
@@ -944,7 +944,7 @@ export default function Image( {
insertBlocksAfter={ insertBlocksAfter }
label={ __( 'Image caption text' ) }
showToolbarButton={ isSingleSelected && hasNonContentControls }
disableEditing={ lockCaption }
readOnly={ lockCaption }
/>
</>
);
4 changes: 2 additions & 2 deletions packages/block-library/src/utils/caption.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ export function Caption( {
label = __( 'Caption text' ),
showToolbarButton = true,
className,
disableEditing,
readOnly,
tagName = 'figcaption',
addLabel = __( 'Add caption' ),
removeLabel = __( 'Remove caption' ),
@@ -111,7 +111,7 @@ export function Caption( {
createBlock( getDefaultBlockName() )
)
}
disableEditing={ disableEditing }
readOnly={ readOnly }
{ ...props }
/>
) }

0 comments on commit 57d03cc

Please sign in to comment.