@wordpress/edit-site 4.14.4 → 4.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js CHANGED
@@ -18,6 +18,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
18
18
  import { __ } from '@wordpress/i18n';
19
19
  import { store as viewportStore } from '@wordpress/viewport';
20
20
  import { getQueryArgs } from '@wordpress/url';
21
+ import { addFilter } from '@wordpress/hooks';
21
22
 
22
23
  /**
23
24
  * Internal dependencies
@@ -51,6 +52,26 @@ export function reinitializeEditor( target, settings ) {
51
52
  return;
52
53
  }
53
54
 
55
+ /*
56
+ * Prevent adding the Clasic block in the site editor.
57
+ * Only add the filter when the site editor is initialized, not imported.
58
+ * Also only add the filter(s) after registerCoreBlocks()
59
+ * so that common filters in the block library are not overwritten.
60
+ *
61
+ * This usage here is inspired by previous usage of the filter in the post editor:
62
+ * https://github.com/WordPress/gutenberg/pull/37157
63
+ */
64
+ addFilter(
65
+ 'blockEditor.__unstableCanInsertBlockType',
66
+ 'removeClassicBlockFromInserter',
67
+ ( canInsert, blockType ) => {
68
+ if ( blockType.name === 'core/freeform' ) {
69
+ return false;
70
+ }
71
+ return canInsert;
72
+ }
73
+ );
74
+
54
75
  // This will be a no-op if the target doesn't have any React nodes.
55
76
  unmountComponentAtNode( target );
56
77
  const reboot = reinitializeEditor.bind( null, target, settings );