Skip to content

Commit

Permalink
PCH Smart Linking: Prevent Smart Linking from running on Freeform (Cl…
Browse files Browse the repository at this point in the history
…assic) blocks (#2570)

* Prevent running Smart Linking on Freeform (classic editor) blocks

* Rebuild assets

* Rebuild assets
  • Loading branch information
vaurdan authored Jun 17, 2024
1 parent 9340d4f commit 4461ad7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/content-helper/editor-sidebar.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '522de0292215b3a83c9d');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '8e33f3e052f7f8d51f0a');
22 changes: 11 additions & 11 deletions build/content-helper/editor-sidebar.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/content-helper/editor-sidebar/smart-linking/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,22 @@ export const SmartLinkingPanel = ( {
context,
} );

// When the Freeform block is present, applying Smart Links does not work reliably.
// If the selected block is a Freeform block or if the Freeform block is present in
// the content, and the user wants to apply Smart Links to the entire content,
// show an error message and return early.
const hasFreeformBlocks = allBlocks.some( ( block ) => block.name === 'core/freeform' );
if (
( selectedBlock?.name === 'core/freeform' && ! isFullContent ) ||
( hasFreeformBlocks && isFullContent )
) {
createNotice( 'error', __( 'Smart Linking is not supported for the Freeform block.', 'wp-parsely' ), {
type: 'snackbar',
} );
setLoading( false );
return;
}

// If selected block is not set, the overlay will be applied to the entire content.
await applyOverlay( isFullContent ? 'all' : selectedBlock?.clientId );

Expand Down

0 comments on commit 4461ad7

Please sign in to comment.