From 4c6c1d659ad1a033692c35bb73df77c4e1eda476 Mon Sep 17 00:00:00 2001 From: Douglas Henri Date: Tue, 23 Jul 2024 15:37:05 -0300 Subject: [PATCH] AI Assistant: Fix block inserter behavior when Breve is enabled (#38483) * move md5 check out of tree preparation * changelog --- .../changelog/fix-jetpack-ai-breve-block-inserter | 4 ++++ .../components/breve/highlight/index.tsx | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/fix-jetpack-ai-breve-block-inserter diff --git a/projects/plugins/jetpack/changelog/fix-jetpack-ai-breve-block-inserter b/projects/plugins/jetpack/changelog/fix-jetpack-ai-breve-block-inserter new file mode 100644 index 0000000000000..4b184317904b8 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-jetpack-ai-breve-block-inserter @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +AI Assistant: Fix block inserter behavior when Breve is enabled diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/highlight/index.tsx b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/highlight/index.tsx index 1bc0a3f6a8076..cc9543a63c735 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/highlight/index.tsx +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/breve/highlight/index.tsx @@ -248,28 +248,31 @@ export function registerBreveHighlights() { interactive: false, edit: () => {}, ...configSettings, - __experimentalGetPropsForEditableTreePreparation( _select, { blockClientId } ) { + __experimentalGetPropsForEditableTreePreparation() { return { isProofreadEnabled: ( globalSelect( 'jetpack/ai-breve' ) as BreveSelect ).isProofreadEnabled(), - currentMd5: ( globalSelect( 'jetpack/ai-breve' ) as BreveSelect ).getBlockMd5( - formatName, - blockClientId - ), isFeatureEnabled: ( globalSelect( 'jetpack/ai-breve' ) as BreveSelect ).isFeatureEnabled( config.name ), }; }, __experimentalCreatePrepareEditableTree( - { isProofreadEnabled, isFeatureEnabled, currentMd5 }, + { isProofreadEnabled, isFeatureEnabled }, { blockClientId, richTextIdentifier } ) { return ( formats: Array< RichTextFormatList >, text: string ) => { const record = { formats, text } as RichTextValue; const type = formatName; + // Has to be defined here, as adding it to __experimentalGetPropsForEditableTreePreparation + // causes an issue with the block inserter. ref p1721746774569699-slack-C054LN8RNVA + const currentMd5 = ( globalSelect( 'jetpack/ai-breve' ) as BreveSelect ).getBlockMd5( + formatName, + blockClientId + ); + if ( text && isProofreadEnabled && isFeatureEnabled ) { const block = globalSelect( 'core/block-editor' ).getBlock( blockClientId ); const blockContent = getBlockContent( block );