Skip to content

Commit

Permalink
Fix use of __experimentalCreatePrepareEditableTree without __experime…
Browse files Browse the repository at this point in the history
…ntalCreateOnChangeEditableValue
  • Loading branch information
ellatrix committed Mar 6, 2019
1 parent 078041b commit c3adf18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions packages/rich-text/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ function toFormat( { type, attributes } ) {
return attributes ? { type, attributes } : { type };
}

if (
formatType.__experimentalCreatePrepareEditableTree &&
! formatType.__experimentalCreateOnChangeEditableValue
) {
return null;
}

if ( ! attributes ) {
return { type: formatType.name };
}
Expand Down
12 changes: 7 additions & 5 deletions packages/rich-text/src/register-format-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function registerFormatType( name, settings ) {
} );

if (
settings.__experimentalGetPropsForEditableTreePreparation
settings.__experimentalCreatePrepareEditableTree
) {
addFilter( 'experimentalRichText', name, ( OriginalComponent ) => {
let Component = OriginalComponent;
Expand Down Expand Up @@ -193,17 +193,19 @@ export function registerFormatType( name, settings ) {
};
}

const hocs = [
withSelect( ( sel, { clientId, identifier } ) => ( {
const hocs = [];

if ( settings.__experimentalGetPropsForEditableTreePreparation ) {
hocs.push( withSelect( ( sel, { clientId, identifier } ) => ( {
[ `format_${ name }` ]: settings.__experimentalGetPropsForEditableTreePreparation(
sel,
{
richTextIdentifier: identifier,
blockClientId: clientId,
}
),
} ) ),
];
} ) ) );
}

if ( settings.__experimentalGetPropsForEditableTreeChangeHandler ) {
hocs.push( withDispatch( ( disp, { clientId, identifier } ) => {
Expand Down

0 comments on commit c3adf18

Please sign in to comment.