@wordpress/block-editor 15.10.1-next.v.0 → 15.11.1-next.v.0
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/CHANGELOG.md +2 -0
- package/build/components/block-controls/index.cjs +1 -1
- package/build/components/block-controls/index.cjs.map +2 -2
- package/build/components/block-edit/context.cjs +5 -0
- package/build/components/block-edit/context.cjs.map +2 -2
- package/build/components/block-edit/index.cjs +3 -0
- package/build/components/block-edit/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +7 -27
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-list/block.cjs +3 -0
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +37 -13
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/index.cjs +1 -1
- package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +1 -1
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-tools/index.cjs +2 -26
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-visibility/index.cjs +7 -9
- package/build/components/block-visibility/index.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs +13 -11
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +1 -1
- package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
- package/build/components/block-visibility/utils.cjs +5 -1
- package/build/components/block-visibility/utils.cjs.map +2 -2
- package/build/components/block-visibility/viewport-menu-item.cjs +11 -4
- package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
- package/build/components/block-visibility/viewport-toolbar.cjs +4 -6
- package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs +121 -0
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +7 -0
- package/build/components/button-block-appender/index.cjs +23 -19
- package/build/components/button-block-appender/index.cjs.map +2 -2
- package/build/components/color-palette/with-color-context.cjs +1 -1
- package/build/components/color-palette/with-color-context.cjs.map +2 -2
- package/build/components/color-style-selector/index.cjs +1 -1
- package/build/components/color-style-selector/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +5 -3
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +1 -1
- package/build/components/colors-gradients/dropdown.cjs.map +2 -2
- package/build/components/editable-text/index.cjs +5 -1
- package/build/components/editable-text/index.cjs.map +2 -2
- package/build/components/font-sizes/font-size-picker.cjs +2 -1
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/font-sizes/with-font-sizes.cjs +5 -3
- package/build/components/font-sizes/with-font-sizes.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +26 -13
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +1 -1
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +1 -1
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/gradients/with-gradient.cjs +1 -1
- package/build/components/gradients/with-gradient.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +14 -25
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/index.cjs +1 -1
- package/build/components/inspector-controls/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs +1 -1
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +7 -7
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +8 -16
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +29 -34
- package/build/components/list-view/block.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +3 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/provider/index.cjs +7 -8
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/with-registry-provider.cjs +1 -1
- package/build/components/provider/with-registry-provider.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +2 -34
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/hooks/block-fields/index.cjs +52 -86
- package/build/hooks/block-fields/index.cjs.map +3 -3
- package/build/hooks/block-fields/link/index.cjs +2 -11
- package/build/hooks/block-fields/link/index.cjs.map +2 -2
- package/build/hooks/block-fields/media/index.cjs +9 -14
- package/build/hooks/block-fields/media/index.cjs.map +2 -2
- package/build/hooks/cross-origin-isolation.cjs +1 -1
- package/build/hooks/cross-origin-isolation.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +141 -0
- package/build/hooks/custom-css.cjs.map +7 -0
- package/build/hooks/fit-text.cjs +14 -7
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +1 -1
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/index.cjs +6 -1
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/layout.cjs +10 -4
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +32 -11
- package/build/hooks/list-view.cjs.map +3 -3
- package/build/hooks/utils.cjs +5 -4
- package/build/hooks/utils.cjs.map +2 -2
- package/build/layouts/grid.cjs +12 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/store/defaults.cjs +3 -0
- package/build/store/defaults.cjs.map +2 -2
- package/build/store/private-selectors.cjs +45 -37
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/selectors.cjs +7 -1
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/fit-text-utils.cjs +5 -1
- package/build/utils/fit-text-utils.cjs.map +2 -2
- package/build-module/components/block-controls/index.mjs +1 -1
- package/build-module/components/block-controls/index.mjs.map +2 -2
- package/build-module/components/block-edit/context.mjs +4 -0
- package/build-module/components/block-edit/context.mjs.map +2 -2
- package/build-module/components/block-edit/index.mjs +4 -0
- package/build-module/components/block-edit/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +7 -27
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +3 -0
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +37 -13
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +2 -2
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-tools/index.mjs +2 -26
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-visibility/index.mjs +6 -9
- package/build-module/components/block-visibility/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +13 -11
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +1 -1
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +5 -1
- package/build-module/components/block-visibility/utils.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-menu-item.mjs +11 -4
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-toolbar.mjs +4 -6
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +95 -0
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +7 -0
- package/build-module/components/button-block-appender/index.mjs +23 -19
- package/build-module/components/button-block-appender/index.mjs.map +2 -2
- package/build-module/components/color-palette/with-color-context.mjs +1 -1
- package/build-module/components/color-palette/with-color-context.mjs.map +2 -2
- package/build-module/components/color-style-selector/index.mjs +1 -1
- package/build-module/components/color-style-selector/index.mjs.map +2 -2
- package/build-module/components/colors/with-colors.mjs +5 -3
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +1 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/editable-text/index.mjs +5 -1
- package/build-module/components/editable-text/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +2 -1
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/font-sizes/with-font-sizes.mjs +5 -3
- package/build-module/components/font-sizes/with-font-sizes.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +22 -13
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +1 -1
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +1 -1
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/gradients/with-gradient.mjs +1 -1
- package/build-module/components/gradients/with-gradient.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +16 -22
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/index.mjs +1 -1
- package/build-module/components/inspector-controls/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +7 -7
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +8 -16
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +31 -36
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs +3 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +7 -8
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/with-registry-provider.mjs +1 -1
- package/build-module/components/provider/with-registry-provider.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +3 -37
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +45 -87
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +2 -11
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +9 -14
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +1 -1
- package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +112 -0
- package/build-module/hooks/custom-css.mjs.map +7 -0
- package/build-module/hooks/fit-text.mjs +14 -7
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +1 -1
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/index.mjs +6 -1
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +10 -4
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +33 -12
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +7 -5
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +12 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/store/defaults.mjs +3 -0
- package/build-module/store/defaults.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +42 -40
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +7 -1
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/fit-text-utils.mjs +5 -1
- package/build-module/utils/fit-text-utils.mjs.map +2 -2
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/package.json +39 -39
- package/src/components/block-controls/index.js +1 -1
- package/src/components/block-controls/test/index.js +1 -0
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +6 -0
- package/src/components/block-edit/test/edit.js +10 -0
- package/src/components/block-inspector/index.js +16 -38
- package/src/components/block-list/block.js +3 -0
- package/src/components/block-list/block.native.js +5 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +49 -29
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-preview/test/index.js +11 -7
- package/src/components/block-settings-menu-controls/index.js +2 -2
- package/src/components/block-switcher/test/index.js +2 -0
- package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
- package/src/components/block-switcher/test/utils.js +2 -0
- package/src/components/block-toolbar/index.js +2 -2
- package/src/components/block-tools/index.js +2 -29
- package/src/components/block-visibility/index.js +3 -19
- package/src/components/block-visibility/modal.js +16 -14
- package/src/components/block-visibility/test/use-block-visibility.js +27 -25
- package/src/components/block-visibility/test/utils.js +24 -8
- package/src/components/block-visibility/use-block-visibility.js +1 -4
- package/src/components/block-visibility/utils.js +9 -1
- package/src/components/block-visibility/viewport-menu-item.js +11 -5
- package/src/components/block-visibility/viewport-toolbar.js +5 -6
- package/src/components/block-visibility/viewport-visibility-info.js +131 -0
- package/src/components/button-block-appender/index.js +2 -2
- package/src/components/color-palette/with-color-context.js +1 -1
- package/src/components/color-style-selector/index.js +2 -3
- package/src/components/colors/with-colors.js +23 -20
- package/src/components/colors-gradients/dropdown.js +2 -3
- package/src/components/editable-text/index.js +5 -1
- package/src/components/font-sizes/font-size-picker.js +1 -0
- package/src/components/font-sizes/with-font-sizes.js +13 -10
- package/src/components/global-styles/advanced-panel.js +35 -16
- package/src/components/global-styles/filters-panel.js +2 -3
- package/src/components/global-styles/shadow-panel-components.js +1 -1
- package/src/components/global-styles/style.scss +9 -5
- package/src/components/gradients/with-gradient.js +7 -4
- package/src/components/inner-blocks/test/index.js +2 -0
- package/src/components/inspector-controls/fill.js +30 -20
- package/src/components/inspector-controls/index.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +5 -1
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -11
- package/src/components/link-control/test/index.js +6 -1
- package/src/components/list-view/block-select-button.js +16 -25
- package/src/components/list-view/block.js +38 -43
- package/src/components/list-view/utils.js +4 -2
- package/src/components/media-replace-flow/test/index.js +13 -11
- package/src/components/provider/index.js +11 -10
- package/src/components/provider/test/use-block-sync.js +1 -0
- package/src/components/provider/with-registry-provider.js +1 -1
- package/src/components/use-block-commands/index.js +0 -41
- package/src/hooks/block-fields/index.js +66 -111
- package/src/hooks/block-fields/link/index.js +2 -14
- package/src/hooks/block-fields/media/index.js +9 -21
- package/src/hooks/cross-origin-isolation.js +19 -18
- package/src/hooks/custom-css.js +176 -0
- package/src/hooks/fit-text.js +20 -5
- package/src/hooks/grid-visualizer.js +15 -14
- package/src/hooks/index.js +6 -1
- package/src/hooks/layout.js +55 -43
- package/src/hooks/list-view.js +46 -12
- package/src/hooks/test/align.js +1 -0
- package/src/hooks/test/allowed-blocks.js +8 -0
- package/src/hooks/test/auto-inspector-controls.js +4 -0
- package/src/hooks/test/font-size.js +1 -0
- package/src/hooks/test/metadata.js +4 -0
- package/src/hooks/test/text-align.js +1 -0
- package/src/hooks/utils.js +124 -116
- package/src/layouts/grid.js +19 -3
- package/src/layouts/test/grid.js +1 -1
- package/src/store/defaults.js +4 -0
- package/src/store/private-selectors.js +94 -63
- package/src/store/selectors.js +14 -6
- package/src/store/test/actions.js +7 -0
- package/src/store/test/private-selectors.js +116 -119
- package/src/store/test/reducer.js +4 -0
- package/src/store/test/registry-selectors.js +2 -0
- package/src/store/test/selectors.js +19 -0
- package/src/utils/fit-text-utils.js +12 -2
- package/build/components/block-visibility/block-visibility-info.cjs +0 -63
- package/build/components/block-visibility/block-visibility-info.cjs.map +0 -7
- package/build/components/block-visibility/menu-item.cjs +0 -109
- package/build/components/block-visibility/menu-item.cjs.map +0 -7
- package/build/components/block-visibility/toolbar.cjs +0 -92
- package/build/components/block-visibility/toolbar.cjs.map +0 -7
- package/build-module/components/block-visibility/block-visibility-info.mjs +0 -47
- package/build-module/components/block-visibility/block-visibility-info.mjs.map +0 -7
- package/build-module/components/block-visibility/menu-item.mjs +0 -88
- package/build-module/components/block-visibility/menu-item.mjs.map +0 -7
- package/build-module/components/block-visibility/toolbar.mjs +0 -71
- package/build-module/components/block-visibility/toolbar.mjs.map +0 -7
- package/src/components/block-visibility/block-visibility-info.js +0 -62
- package/src/components/block-visibility/menu-item.js +0 -96
- package/src/components/block-visibility/toolbar.js +0 -88
- /package/src/components/block-icon/stories/{index.story.js → index.story.ts} +0 -0
- /package/src/components/contrast-checker/stories/{index.story.js → index.story.ts} +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
7
|
+
import { getBlockType, hasBlockSupport } from '@wordpress/blocks';
|
|
8
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
9
|
+
import { processCSSNesting } from '@wordpress/global-styles-engine';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import InspectorControls from '../components/inspector-controls';
|
|
15
|
+
import AdvancedPanel, {
|
|
16
|
+
validateCSS,
|
|
17
|
+
} from '../components/global-styles/advanced-panel';
|
|
18
|
+
import { cleanEmptyObject, useStyleOverride } from './utils';
|
|
19
|
+
import { store as blockEditorStore } from '../store';
|
|
20
|
+
|
|
21
|
+
// Stable reference for useInstanceId.
|
|
22
|
+
const CUSTOM_CSS_INSTANCE_REFERENCE = {};
|
|
23
|
+
|
|
24
|
+
// Stable empty object reference for useSelect.
|
|
25
|
+
const EMPTY_STYLE = {};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Inspector control for custom CSS.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} props Component props.
|
|
31
|
+
* @param {string} props.blockName Block name.
|
|
32
|
+
* @param {Function} props.setAttributes Function to set block attributes.
|
|
33
|
+
* @param {Object} props.style Block style attribute.
|
|
34
|
+
*/
|
|
35
|
+
function CustomCSSControl( { blockName, setAttributes, style } ) {
|
|
36
|
+
const blockType = getBlockType( blockName );
|
|
37
|
+
|
|
38
|
+
function onChange( newStyle ) {
|
|
39
|
+
// Normalize whitespace-only CSS to undefined so it gets cleaned up.
|
|
40
|
+
const css = newStyle?.css?.trim() ? newStyle.css : undefined;
|
|
41
|
+
setAttributes( {
|
|
42
|
+
style: cleanEmptyObject( { ...newStyle, css } ),
|
|
43
|
+
} );
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const cssHelpText = sprintf(
|
|
47
|
+
// translators: %s: is the name of a block e.g., 'Image' or 'Quote'.
|
|
48
|
+
__(
|
|
49
|
+
'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value, e.g. color: red;.'
|
|
50
|
+
),
|
|
51
|
+
blockType?.title
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<InspectorControls group="advanced">
|
|
56
|
+
<AdvancedPanel
|
|
57
|
+
value={ style }
|
|
58
|
+
onChange={ onChange }
|
|
59
|
+
inheritedValue={ style }
|
|
60
|
+
help={ cssHelpText }
|
|
61
|
+
/>
|
|
62
|
+
</InspectorControls>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function CustomCSSEdit( { clientId, name, setAttributes } ) {
|
|
67
|
+
const { style, canEditCSS } = useSelect(
|
|
68
|
+
( select ) => {
|
|
69
|
+
const { getBlockAttributes, getSettings } =
|
|
70
|
+
select( blockEditorStore );
|
|
71
|
+
return {
|
|
72
|
+
style: getBlockAttributes( clientId )?.style || EMPTY_STYLE,
|
|
73
|
+
canEditCSS: getSettings().canEditCSS,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
[ clientId ]
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Don't render the panel if user lacks edit_css capability.
|
|
80
|
+
if ( ! canEditCSS ) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<CustomCSSControl
|
|
86
|
+
blockName={ name }
|
|
87
|
+
setAttributes={ setAttributes }
|
|
88
|
+
style={ style }
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Hook to handle custom CSS for a block in the editor.
|
|
95
|
+
* Generates a unique class and applies scoped CSS via style override.
|
|
96
|
+
*
|
|
97
|
+
* @param {Object} props Block props.
|
|
98
|
+
* @param {Object} props.style Block style attribute.
|
|
99
|
+
* @return {Object} Block props including className for custom CSS scoping.
|
|
100
|
+
*/
|
|
101
|
+
function useBlockProps( { style } ) {
|
|
102
|
+
const customCSS = style?.css;
|
|
103
|
+
|
|
104
|
+
// Validate CSS is non-empty and passes validation checks.
|
|
105
|
+
const isValidCSS =
|
|
106
|
+
typeof customCSS === 'string' &&
|
|
107
|
+
customCSS.trim().length > 0 &&
|
|
108
|
+
validateCSS( customCSS );
|
|
109
|
+
|
|
110
|
+
const customCSSIdentifier = useInstanceId(
|
|
111
|
+
CUSTOM_CSS_INSTANCE_REFERENCE,
|
|
112
|
+
'wp-custom-css'
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const customCSSSelector = `.${ customCSSIdentifier }`;
|
|
116
|
+
|
|
117
|
+
// Transform the custom CSS using the same logic as global styles.
|
|
118
|
+
// Only process if CSS is valid (doesn't contain HTML markup).
|
|
119
|
+
const transformedCSS = useMemo( () => {
|
|
120
|
+
if ( ! isValidCSS ) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
return processCSSNesting( customCSS, customCSSSelector );
|
|
124
|
+
}, [ customCSS, customCSSSelector, isValidCSS ] );
|
|
125
|
+
|
|
126
|
+
// Inject the CSS via style override.
|
|
127
|
+
useStyleOverride( { css: transformedCSS } );
|
|
128
|
+
|
|
129
|
+
// Only add the class if there's valid custom CSS.
|
|
130
|
+
if ( ! isValidCSS ) {
|
|
131
|
+
return {};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
className: customCSSIdentifier,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Adds a marker class to blocks with custom CSS for server-side rendering.
|
|
141
|
+
*
|
|
142
|
+
* @param {Object} props Additional props applied to save element.
|
|
143
|
+
* @param {Object} blockType Block type definition.
|
|
144
|
+
* @param {Object} attributes Block's attributes.
|
|
145
|
+
* @return {Object} Filtered props applied to save element.
|
|
146
|
+
*/
|
|
147
|
+
function addSaveProps( props, blockType, attributes ) {
|
|
148
|
+
if ( ! hasBlockSupport( blockType, 'customCSS', true ) ) {
|
|
149
|
+
return props;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if ( ! attributes?.style?.css?.trim() ) {
|
|
153
|
+
return props;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Add a class to indicate this block has custom CSS.
|
|
157
|
+
// The actual CSS is rendered server-side using the render_block filter.
|
|
158
|
+
const className = props.className
|
|
159
|
+
? `${ props.className } has-custom-css`
|
|
160
|
+
: 'has-custom-css';
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
...props,
|
|
164
|
+
className,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export default {
|
|
169
|
+
edit: CustomCSSEdit,
|
|
170
|
+
useBlockProps,
|
|
171
|
+
addSaveProps,
|
|
172
|
+
attributeKeys: [ 'style' ],
|
|
173
|
+
hasSupport( name ) {
|
|
174
|
+
return hasBlockSupport( name, 'customCSS', true );
|
|
175
|
+
},
|
|
176
|
+
};
|
package/src/hooks/fit-text.js
CHANGED
|
@@ -68,18 +68,25 @@ function useFitText( { fitText, name, clientId } ) {
|
|
|
68
68
|
const hasFitTextSupport = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );
|
|
69
69
|
const blockElement = useBlockElement( clientId );
|
|
70
70
|
|
|
71
|
-
// Monitor block attribute changes, and
|
|
71
|
+
// Monitor block attribute changes, parent changes, and block mode.
|
|
72
72
|
// Any attribute or parent change may change the available space.
|
|
73
|
-
|
|
73
|
+
// Block mode is needed to disable fit text when in HTML editing mode.
|
|
74
|
+
const { blockAttributes, parentId, blockMode } = useSelect(
|
|
74
75
|
( select ) => {
|
|
75
76
|
if ( ! clientId || ! hasFitTextSupport || ! fitText ) {
|
|
76
77
|
return EMPTY_OBJECT;
|
|
77
78
|
}
|
|
79
|
+
const _blockMode =
|
|
80
|
+
select( blockEditorStore ).getBlockMode( clientId );
|
|
81
|
+
if ( _blockMode === 'html' ) {
|
|
82
|
+
return { blockMode: _blockMode };
|
|
83
|
+
}
|
|
78
84
|
return {
|
|
79
85
|
blockAttributes:
|
|
80
86
|
select( blockEditorStore ).getBlockAttributes( clientId ),
|
|
81
87
|
parentId:
|
|
82
88
|
select( blockEditorStore ).getBlockRootClientId( clientId ),
|
|
89
|
+
blockMode: _blockMode,
|
|
83
90
|
};
|
|
84
91
|
},
|
|
85
92
|
[ clientId, hasFitTextSupport, fitText ]
|
|
@@ -118,7 +125,8 @@ function useFitText( { fitText, name, clientId } ) {
|
|
|
118
125
|
! fitText ||
|
|
119
126
|
! blockElement ||
|
|
120
127
|
! clientId ||
|
|
121
|
-
! hasFitTextSupport
|
|
128
|
+
! hasFitTextSupport ||
|
|
129
|
+
blockMode === 'html'
|
|
122
130
|
) {
|
|
123
131
|
return;
|
|
124
132
|
}
|
|
@@ -189,11 +197,17 @@ function useFitText( { fitText, name, clientId } ) {
|
|
|
189
197
|
applyFitText,
|
|
190
198
|
blockElement,
|
|
191
199
|
hasFitTextSupport,
|
|
200
|
+
blockMode,
|
|
192
201
|
] );
|
|
193
202
|
|
|
194
203
|
// Trigger fit text recalculation when content changes
|
|
195
204
|
useEffect( () => {
|
|
196
|
-
if (
|
|
205
|
+
if (
|
|
206
|
+
fitText &&
|
|
207
|
+
blockElement &&
|
|
208
|
+
hasFitTextSupport &&
|
|
209
|
+
blockMode !== 'html'
|
|
210
|
+
) {
|
|
197
211
|
// Wait for next frame to ensure DOM has updated after content changes
|
|
198
212
|
const frameId = window.requestAnimationFrame( () => {
|
|
199
213
|
if ( blockElement ) {
|
|
@@ -209,6 +223,7 @@ function useFitText( { fitText, name, clientId } ) {
|
|
|
209
223
|
applyFitText,
|
|
210
224
|
blockElement,
|
|
211
225
|
hasFitTextSupport,
|
|
226
|
+
blockMode,
|
|
212
227
|
] );
|
|
213
228
|
|
|
214
229
|
return { fontSize };
|
|
@@ -360,7 +375,7 @@ function WithFitTextFontSize( { fitText, name, clientId, children } ) {
|
|
|
360
375
|
* `editor.BlockEdit` filter.
|
|
361
376
|
*/
|
|
362
377
|
const addFitTextControl = createHigherOrderComponent( ( BlockEdit ) => {
|
|
363
|
-
return ( props )
|
|
378
|
+
return function AddFitTextControl( props ) {
|
|
364
379
|
const { name, attributes, clientId, isSelected, setAttributes } = props;
|
|
365
380
|
const { fitText } = attributes;
|
|
366
381
|
const supportsFitText = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );
|
|
@@ -51,21 +51,22 @@ function GridTools( { clientId, layout } ) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const addGridVisualizerToBlockEdit = createHigherOrderComponent(
|
|
54
|
-
( BlockEdit ) =>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
( BlockEdit ) =>
|
|
55
|
+
function AddGridVisualizerToBlockEdit( props ) {
|
|
56
|
+
if ( props.attributes.layout?.type !== 'grid' ) {
|
|
57
|
+
return <BlockEdit key="edit" { ...props } />;
|
|
58
|
+
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<GridTools
|
|
63
|
+
clientId={ props.clientId }
|
|
64
|
+
layout={ props.attributes.layout }
|
|
65
|
+
/>
|
|
66
|
+
<BlockEdit key="edit" { ...props } />
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
},
|
|
69
70
|
'addGridVisualizerToBlockEdit'
|
|
70
71
|
);
|
|
71
72
|
|
package/src/hooks/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import './lock';
|
|
|
14
14
|
import allowedBlocks from './allowed-blocks';
|
|
15
15
|
import anchor from './anchor';
|
|
16
16
|
import ariaLabel from './aria-label';
|
|
17
|
-
import './block-fields';
|
|
17
|
+
import blockFields from './block-fields';
|
|
18
18
|
import customClassName from './custom-class-name';
|
|
19
19
|
import './generated-class-name';
|
|
20
20
|
import style from './style';
|
|
@@ -27,6 +27,7 @@ import fontSize from './font-size';
|
|
|
27
27
|
import textAlign from './text-align';
|
|
28
28
|
import fitText from './fit-text';
|
|
29
29
|
import border from './border';
|
|
30
|
+
import customCSS from './custom-css';
|
|
30
31
|
import position from './position';
|
|
31
32
|
import blockStyleVariation from './block-style-variation';
|
|
32
33
|
import layout from './layout';
|
|
@@ -47,6 +48,7 @@ createBlockEditFilter(
|
|
|
47
48
|
anchor,
|
|
48
49
|
customClassName,
|
|
49
50
|
style,
|
|
51
|
+
customCSS,
|
|
50
52
|
duotone,
|
|
51
53
|
fitText,
|
|
52
54
|
position,
|
|
@@ -56,6 +58,7 @@ createBlockEditFilter(
|
|
|
56
58
|
blockBindingsPanel,
|
|
57
59
|
childLayout,
|
|
58
60
|
allowedBlocks,
|
|
61
|
+
blockFields,
|
|
59
62
|
listView,
|
|
60
63
|
autoInspectorControls,
|
|
61
64
|
].filter( Boolean )
|
|
@@ -72,6 +75,7 @@ createBlockListBlockFilter( [
|
|
|
72
75
|
fontSize,
|
|
73
76
|
fitText,
|
|
74
77
|
border,
|
|
78
|
+
customCSS,
|
|
75
79
|
position,
|
|
76
80
|
blockStyleVariation,
|
|
77
81
|
childLayout,
|
|
@@ -83,6 +87,7 @@ createBlockSaveFilter( [
|
|
|
83
87
|
ariaLabel,
|
|
84
88
|
customClassName,
|
|
85
89
|
border,
|
|
90
|
+
customCSS,
|
|
86
91
|
fitText,
|
|
87
92
|
color,
|
|
88
93
|
style,
|
package/src/hooks/layout.js
CHANGED
|
@@ -30,6 +30,7 @@ import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
|
30
30
|
import { LAYOUT_DEFINITIONS } from '../layouts/definitions';
|
|
31
31
|
import { useBlockSettings, useStyleOverride } from './utils';
|
|
32
32
|
import { unlock } from '../lock-unlock';
|
|
33
|
+
import { globalStylesDataKey } from '../store/private-keys';
|
|
33
34
|
|
|
34
35
|
const layoutBlockSupportKey = 'layout';
|
|
35
36
|
const { kebabCase } = unlock( componentsPrivateApis );
|
|
@@ -367,6 +368,7 @@ function BlockWithLayoutStyles( {
|
|
|
367
368
|
block: BlockListBlock,
|
|
368
369
|
props,
|
|
369
370
|
blockGapSupport,
|
|
371
|
+
globalBlockGapValue,
|
|
370
372
|
layoutClasses,
|
|
371
373
|
} ) {
|
|
372
374
|
const { name, attributes } = props;
|
|
@@ -393,6 +395,7 @@ function BlockWithLayoutStyles( {
|
|
|
393
395
|
layout: usedLayout,
|
|
394
396
|
style: attributes?.style,
|
|
395
397
|
hasBlockGapSupport,
|
|
398
|
+
globalBlockGapValue,
|
|
396
399
|
} );
|
|
397
400
|
|
|
398
401
|
// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
|
|
@@ -421,56 +424,65 @@ function BlockWithLayoutStyles( {
|
|
|
421
424
|
* @return {Function} Wrapped component.
|
|
422
425
|
*/
|
|
423
426
|
export const withLayoutStyles = createHigherOrderComponent(
|
|
424
|
-
( BlockListBlock ) =>
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
const { getSettings, getBlockSettings } = unlock(
|
|
436
|
-
select( blockEditorStore )
|
|
437
|
-
);
|
|
438
|
-
const { disableLayoutStyles } = getSettings();
|
|
427
|
+
( BlockListBlock ) =>
|
|
428
|
+
function WithLayoutStyles( props ) {
|
|
429
|
+
const { clientId, name, attributes } = props;
|
|
430
|
+
const blockSupportsLayout = hasLayoutBlockSupport( name );
|
|
431
|
+
const layoutClasses = useLayoutClasses( attributes, name );
|
|
432
|
+
const extraProps = useSelect(
|
|
433
|
+
( select ) => {
|
|
434
|
+
// The callback returns early to avoid block editor subscription.
|
|
435
|
+
if ( ! blockSupportsLayout ) {
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
439
438
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
439
|
+
const { getSettings, getBlockSettings } = unlock(
|
|
440
|
+
select( blockEditorStore )
|
|
441
|
+
);
|
|
442
|
+
const settings = getSettings();
|
|
443
|
+
const { disableLayoutStyles } = settings;
|
|
443
444
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
);
|
|
445
|
+
if ( disableLayoutStyles ) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
448
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
449
|
+
const [ blockGapSupport ] = getBlockSettings(
|
|
450
|
+
clientId,
|
|
451
|
+
'spacing.blockGap'
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
// Get default blockGap value from global styles for use in layouts like grid.
|
|
455
|
+
// Check block-specific styles first, then fall back to root styles.
|
|
456
|
+
const globalStyles = settings[ globalStylesDataKey ];
|
|
457
|
+
const globalBlockGapValue =
|
|
458
|
+
globalStyles?.blocks?.[ name ]?.spacing?.blockGap ??
|
|
459
|
+
globalStyles?.spacing?.blockGap;
|
|
460
|
+
|
|
461
|
+
return { blockGapSupport, globalBlockGapValue };
|
|
462
|
+
},
|
|
463
|
+
[ blockSupportsLayout, clientId ]
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
if ( ! extraProps ) {
|
|
467
|
+
return (
|
|
468
|
+
<BlockListBlock
|
|
469
|
+
{ ...props }
|
|
470
|
+
__unstableLayoutClassNames={
|
|
471
|
+
blockSupportsLayout ? layoutClasses : undefined
|
|
472
|
+
}
|
|
473
|
+
/>
|
|
474
|
+
);
|
|
475
|
+
}
|
|
453
476
|
|
|
454
|
-
if ( ! extraProps ) {
|
|
455
477
|
return (
|
|
456
|
-
<
|
|
457
|
-
{
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
478
|
+
<BlockWithLayoutStyles
|
|
479
|
+
block={ BlockListBlock }
|
|
480
|
+
props={ props }
|
|
481
|
+
layoutClasses={ layoutClasses }
|
|
482
|
+
{ ...extraProps }
|
|
461
483
|
/>
|
|
462
484
|
);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return (
|
|
466
|
-
<BlockWithLayoutStyles
|
|
467
|
-
block={ BlockListBlock }
|
|
468
|
-
props={ props }
|
|
469
|
-
layoutClasses={ layoutClasses }
|
|
470
|
-
{ ...extraProps }
|
|
471
|
-
/>
|
|
472
|
-
);
|
|
473
|
-
},
|
|
485
|
+
},
|
|
474
486
|
'withLayoutStyles'
|
|
475
487
|
);
|
|
476
488
|
|
package/src/hooks/list-view.js
CHANGED
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { PanelBody } from '@wordpress/components';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
-
import {
|
|
7
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
8
|
+
import { useContext } from '@wordpress/element';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
|
-
import InspectorControls from '../components/inspector-controls';
|
|
13
13
|
import { store as blockEditorStore } from '../store';
|
|
14
14
|
import { PrivateListView } from '../components/list-view';
|
|
15
|
+
import InspectorControls from '../components/inspector-controls/fill';
|
|
16
|
+
import { PrivateBlockContext } from '../components/block-list/private-block-context';
|
|
17
|
+
import useBlockDisplayTitle from '../components/block-title/use-block-display-title';
|
|
15
18
|
|
|
16
19
|
export const LIST_VIEW_SUPPORT_KEY = 'listView';
|
|
17
20
|
|
|
@@ -34,23 +37,53 @@ export function hasListViewSupport( nameOrType ) {
|
|
|
34
37
|
* @return {Element|null} List view inspector controls or null.
|
|
35
38
|
*/
|
|
36
39
|
export function ListViewPanel( { clientId, name } ) {
|
|
40
|
+
const { isSelectionWithinCurrentSection } =
|
|
41
|
+
useContext( PrivateBlockContext );
|
|
37
42
|
const isEnabled = hasListViewSupport( name );
|
|
38
|
-
const { hasChildren,
|
|
39
|
-
( select ) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const { hasChildren, isNestedListView } = useSelect(
|
|
44
|
+
( select ) => {
|
|
45
|
+
const { getBlockCount, getBlockParents, getBlockName } =
|
|
46
|
+
select( blockEditorStore );
|
|
47
|
+
|
|
48
|
+
// When the ListView is shown in a section, avoid showing List Views
|
|
49
|
+
// for both parent and child blocks that have support. In this situation
|
|
50
|
+
// the parent will show the child anyway in its List.
|
|
51
|
+
// Search parents to see if there's one that also has support, and if so
|
|
52
|
+
// skip rendering.
|
|
53
|
+
// This matches closely the logic in the `BlockCard` component.
|
|
54
|
+
let _isNestedListView = false;
|
|
55
|
+
if ( isSelectionWithinCurrentSection ) {
|
|
56
|
+
const parents = getBlockParents( clientId, true );
|
|
57
|
+
_isNestedListView = parents.find( ( parentId ) => {
|
|
58
|
+
const parentName = getBlockName( parentId );
|
|
59
|
+
return (
|
|
60
|
+
parentName === 'core/navigation' ||
|
|
61
|
+
hasBlockSupport( parentName, 'listView' )
|
|
62
|
+
);
|
|
63
|
+
} );
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
hasChildren: !! getBlockCount( clientId ),
|
|
68
|
+
isNestedListView: _isNestedListView,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
[ clientId, isSelectionWithinCurrentSection ]
|
|
45
72
|
);
|
|
73
|
+
const title = useBlockDisplayTitle( {
|
|
74
|
+
clientId,
|
|
75
|
+
context: 'list-view',
|
|
76
|
+
} );
|
|
46
77
|
|
|
47
|
-
if ( ! isEnabled ) {
|
|
78
|
+
if ( ! isEnabled || isNestedListView ) {
|
|
48
79
|
return null;
|
|
49
80
|
}
|
|
50
81
|
|
|
82
|
+
const showBlockTitle = isSelectionWithinCurrentSection;
|
|
83
|
+
|
|
51
84
|
return (
|
|
52
85
|
<InspectorControls group="list">
|
|
53
|
-
<PanelBody title={
|
|
86
|
+
<PanelBody title={ showBlockTitle ? title : undefined }>
|
|
54
87
|
{ ! hasChildren && (
|
|
55
88
|
<p className="block-editor-block-inspector__no-blocks">
|
|
56
89
|
{ __( 'No items yet.' ) }
|
|
@@ -59,7 +92,7 @@ export function ListViewPanel( { clientId, name } ) {
|
|
|
59
92
|
<PrivateListView
|
|
60
93
|
rootClientId={ clientId }
|
|
61
94
|
isExpanded
|
|
62
|
-
description={
|
|
95
|
+
description={ title }
|
|
63
96
|
showAppender
|
|
64
97
|
/>
|
|
65
98
|
</PanelBody>
|
|
@@ -74,4 +107,5 @@ export default {
|
|
|
74
107
|
edit: ListViewPanel,
|
|
75
108
|
hasSupport: hasListViewSupport,
|
|
76
109
|
attributeKeys: [],
|
|
110
|
+
supportsPatternEditing: true,
|
|
77
111
|
};
|
package/src/hooks/test/align.js
CHANGED
|
@@ -22,6 +22,7 @@ describe( 'allowedBlocks', () => {
|
|
|
22
22
|
describe( 'addTransforms()', () => {
|
|
23
23
|
it( 'should not preserve allowedBlocks in wrapping transforms', () => {
|
|
24
24
|
registerBlockType( 'core/bar', {
|
|
25
|
+
apiVersion: 3,
|
|
25
26
|
title: 'Bar',
|
|
26
27
|
supports: { allowedBlocks: true },
|
|
27
28
|
} );
|
|
@@ -53,6 +54,7 @@ describe( 'allowedBlocks', () => {
|
|
|
53
54
|
|
|
54
55
|
it( 'should not preserve allowedBlocks in one-to-many transforms', () => {
|
|
55
56
|
registerBlockType( 'core/bar', {
|
|
57
|
+
apiVersion: 3,
|
|
56
58
|
title: 'Bar',
|
|
57
59
|
supports: { allowedBlocks: true },
|
|
58
60
|
} );
|
|
@@ -83,6 +85,7 @@ describe( 'allowedBlocks', () => {
|
|
|
83
85
|
|
|
84
86
|
it( 'should not preserve allowedBlocks in many-to-one transforms', () => {
|
|
85
87
|
registerBlockType( 'core/bar', {
|
|
88
|
+
apiVersion: 3,
|
|
86
89
|
title: 'Bar',
|
|
87
90
|
supports: { allowedBlocks: true },
|
|
88
91
|
} );
|
|
@@ -114,6 +117,7 @@ describe( 'allowedBlocks', () => {
|
|
|
114
117
|
|
|
115
118
|
it( 'should not preserve allowedBlocks in many-to-many transforms with different counts', () => {
|
|
116
119
|
registerBlockType( 'core/bar', {
|
|
120
|
+
apiVersion: 3,
|
|
117
121
|
title: 'Bar',
|
|
118
122
|
supports: { allowedBlocks: true },
|
|
119
123
|
} );
|
|
@@ -155,6 +159,7 @@ describe( 'allowedBlocks', () => {
|
|
|
155
159
|
|
|
156
160
|
it( 'should preserve allowedBlocks in many-to-many transforms with same counts', () => {
|
|
157
161
|
registerBlockType( 'core/bar', {
|
|
162
|
+
apiVersion: 3,
|
|
158
163
|
title: 'Bar',
|
|
159
164
|
supports: { allowedBlocks: true },
|
|
160
165
|
} );
|
|
@@ -194,6 +199,7 @@ describe( 'allowedBlocks', () => {
|
|
|
194
199
|
|
|
195
200
|
it( "should filter allowedBlocks based on destination block's allowedBlocks", () => {
|
|
196
201
|
registerBlockType( 'core/bar', {
|
|
202
|
+
apiVersion: 3,
|
|
197
203
|
title: 'Bar',
|
|
198
204
|
supports: { allowedBlocks: true },
|
|
199
205
|
allowedBlocks: [ 'core/paragraph' ],
|
|
@@ -227,6 +233,7 @@ describe( 'allowedBlocks', () => {
|
|
|
227
233
|
|
|
228
234
|
it( 'should not override existing allowedBlocks in target block', () => {
|
|
229
235
|
registerBlockType( 'core/bar', {
|
|
236
|
+
apiVersion: 3,
|
|
230
237
|
title: 'Bar',
|
|
231
238
|
supports: { allowedBlocks: true },
|
|
232
239
|
} );
|
|
@@ -253,6 +260,7 @@ describe( 'allowedBlocks', () => {
|
|
|
253
260
|
|
|
254
261
|
it( 'should not preserve allowedBlocks when target block does not support allowedBlocks', () => {
|
|
255
262
|
registerBlockType( 'core/bar', {
|
|
263
|
+
apiVersion: 3,
|
|
256
264
|
title: 'Bar',
|
|
257
265
|
} );
|
|
258
266
|
|
|
@@ -24,6 +24,7 @@ describe( 'auto-inspector-controls', () => {
|
|
|
24
24
|
describe( 'hasSupport()', () => {
|
|
25
25
|
it( 'should return false for blocks without __experimentalAutoInspectorControl markers', () => {
|
|
26
26
|
registerBlockType( blockName, {
|
|
27
|
+
apiVersion: 3,
|
|
27
28
|
title: 'Test Block',
|
|
28
29
|
category: 'text',
|
|
29
30
|
attributes: {
|
|
@@ -42,6 +43,7 @@ describe( 'auto-inspector-controls', () => {
|
|
|
42
43
|
|
|
43
44
|
it( 'should return true for blocks with __experimentalAutoInspectorControl markers', () => {
|
|
44
45
|
registerBlockType( blockName, {
|
|
46
|
+
apiVersion: 3,
|
|
45
47
|
title: 'Test Block',
|
|
46
48
|
category: 'text',
|
|
47
49
|
attributes: {
|
|
@@ -71,6 +73,7 @@ describe( 'auto-inspector-controls', () => {
|
|
|
71
73
|
|
|
72
74
|
it( 'should return false for blocks with no attributes', () => {
|
|
73
75
|
registerBlockType( blockName, {
|
|
76
|
+
apiVersion: 3,
|
|
74
77
|
title: 'Test Block',
|
|
75
78
|
category: 'text',
|
|
76
79
|
edit: () => null,
|
|
@@ -84,6 +87,7 @@ describe( 'auto-inspector-controls', () => {
|
|
|
84
87
|
|
|
85
88
|
it( 'should return true when at least one attribute has __experimentalAutoInspectorControl', () => {
|
|
86
89
|
registerBlockType( blockName, {
|
|
90
|
+
apiVersion: 3,
|
|
87
91
|
title: 'Test Block',
|
|
88
92
|
category: 'text',
|
|
89
93
|
attributes: {
|