@wordpress/block-editor 15.8.1-next.16d95556a.0 → 15.9.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-inspector/edit-contents.js +19 -23
- package/build/components/block-inspector/edit-contents.js.map +3 -3
- package/build/components/block-inspector/index.js +7 -1
- package/build/components/block-inspector/index.js.map +2 -2
- package/build/components/block-list/block.js +4 -0
- package/build/components/block-list/block.js.map +2 -2
- package/build/components/block-list/index.js +2 -1
- package/build/components/block-list/index.js.map +2 -2
- package/build/components/block-list/use-block-props/index.js +3 -1
- package/build/components/block-list/use-block-props/index.js.map +2 -2
- package/build/components/block-list/use-block-props/use-is-hovered.js +16 -10
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build/components/block-lock/modal.js +5 -5
- package/build/components/block-lock/modal.js.map +2 -2
- package/build/components/block-lock/use-block-lock.js +10 -13
- package/build/components/block-lock/use-block-lock.js.map +2 -2
- package/build/components/block-settings-menu-controls/edit-section-menu-item.js +64 -0
- package/build/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
- package/build/components/block-settings-menu-controls/index.js +9 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.js +9 -9
- package/build/components/block-toolbar/block-toolbar-icon.js.map +2 -2
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-variation-transforms/index.js +32 -5
- package/build/components/block-variation-transforms/index.js.map +2 -2
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- package/build/components/border-radius-control/single-input-control.js +1 -0
- package/build/components/border-radius-control/single-input-control.js.map +2 -2
- package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
- package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build/components/content-only-controls/index.js +444 -0
- package/build/components/content-only-controls/index.js.map +7 -0
- package/build/components/content-only-controls/link/index.js +193 -0
- package/build/components/content-only-controls/link/index.js.map +7 -0
- package/build/components/content-only-controls/media/index.js +264 -0
- package/build/components/content-only-controls/media/index.js.map +7 -0
- package/build/components/content-only-controls/rich-text/index.js +188 -0
- package/build/components/content-only-controls/rich-text/index.js.map +7 -0
- package/build/components/content-only-controls/use-inspector-popover-placement.js +41 -0
- package/build/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
- package/build/components/font-family/index.js +1 -15
- package/build/components/font-family/index.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +35 -2
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +1 -2
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/inserter/media-tab/media-tab.js +1 -33
- package/build/components/inserter/media-tab/media-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/content-tab.js +6 -2
- package/build/components/inspector-controls-tabs/content-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/index.js +7 -1
- package/build/components/inspector-controls-tabs/index.js.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build/components/link-control/index.js +15 -7
- package/build/components/link-control/index.js.map +2 -2
- package/build/components/list-view/block-select-button.js +7 -8
- package/build/components/list-view/block-select-button.js.map +2 -2
- package/build/components/list-view/block.js +9 -7
- package/build/components/list-view/block.js.map +2 -2
- package/build/components/media-placeholder/index.js +18 -35
- package/build/components/media-placeholder/index.js.map +3 -3
- package/build/components/media-placeholder/utils.js +60 -0
- package/build/components/media-placeholder/utils.js.map +7 -0
- package/build/components/media-replace-flow/index.js +24 -33
- package/build/components/media-replace-flow/index.js.map +3 -3
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +2 -2
- package/build/components/use-block-display-information/index.js +21 -1
- package/build/components/use-block-display-information/index.js.map +3 -3
- package/build/components/use-block-drop-zone/index.js +1 -5
- package/build/components/use-block-drop-zone/index.js.map +2 -2
- package/build/hooks/block-bindings.js +52 -61
- package/build/hooks/block-bindings.js.map +3 -3
- package/build/hooks/dimensions.js +3 -3
- package/build/hooks/dimensions.js.map +2 -2
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/use-content-only-section-edit.js +67 -0
- package/build/hooks/use-content-only-section-edit.js.map +7 -0
- package/build/hooks/utils.js +5 -1
- package/build/hooks/utils.js.map +2 -2
- package/build/layouts/constrained.js +2 -2
- package/build/layouts/constrained.js.map +2 -2
- package/build/private-apis.js +2 -3
- package/build/private-apis.js.map +3 -3
- package/build/store/private-keys.js +3 -0
- package/build/store/private-keys.js.map +2 -2
- package/build/store/private-selectors.js +41 -2
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +2 -2
- package/build/utils/fit-text-utils.js +9 -1
- package/build/utils/fit-text-utils.js.map +2 -2
- package/build-module/components/block-inspector/edit-contents.js +9 -23
- package/build-module/components/block-inspector/edit-contents.js.map +2 -2
- package/build-module/components/block-inspector/index.js +7 -1
- package/build-module/components/block-inspector/index.js.map +2 -2
- package/build-module/components/block-list/block.js +4 -0
- package/build-module/components/block-list/block.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -1
- package/build-module/components/block-list/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/index.js +3 -1
- package/build-module/components/block-list/use-block-props/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +16 -10
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build-module/components/block-lock/modal.js +5 -5
- package/build-module/components/block-lock/modal.js.map +2 -2
- package/build-module/components/block-lock/use-block-lock.js +10 -13
- package/build-module/components/block-lock/use-block-lock.js.map +2 -2
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js +29 -0
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
- package/build-module/components/block-settings-menu-controls/index.js +9 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.js +10 -10
- package/build-module/components/block-toolbar/block-toolbar-icon.js.map +2 -2
- package/build-module/components/block-tools/index.js +56 -45
- package/build-module/components/block-tools/index.js.map +2 -2
- package/build-module/components/block-variation-transforms/index.js +32 -5
- package/build-module/components/block-variation-transforms/index.js.map +2 -2
- package/build-module/components/block-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- package/build-module/components/border-radius-control/single-input-control.js +1 -0
- package/build-module/components/border-radius-control/single-input-control.js.map +2 -2
- package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
- package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build-module/components/content-only-controls/index.js +420 -0
- package/build-module/components/content-only-controls/index.js.map +7 -0
- package/build-module/components/content-only-controls/link/index.js +160 -0
- package/build-module/components/content-only-controls/link/index.js.map +7 -0
- package/build-module/components/content-only-controls/media/index.js +242 -0
- package/build-module/components/content-only-controls/media/index.js.map +7 -0
- package/build-module/components/content-only-controls/rich-text/index.js +160 -0
- package/build-module/components/content-only-controls/rich-text/index.js.map +7 -0
- package/build-module/components/content-only-controls/use-inspector-popover-placement.js +16 -0
- package/build-module/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
- package/build-module/components/font-family/index.js +1 -15
- package/build-module/components/font-family/index.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +35 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.js +2 -34
- package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js +7 -3
- package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.js +7 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build-module/components/link-control/index.js +16 -8
- package/build-module/components/link-control/index.js.map +2 -2
- package/build-module/components/list-view/block-select-button.js +14 -9
- package/build-module/components/list-view/block-select-button.js.map +2 -2
- package/build-module/components/list-view/block.js +9 -7
- package/build-module/components/list-view/block.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +19 -36
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-placeholder/utils.js +35 -0
- package/build-module/components/media-placeholder/utils.js.map +7 -0
- package/build-module/components/media-replace-flow/index.js +24 -33
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +2 -2
- package/build-module/components/use-block-display-information/index.js +21 -1
- package/build-module/components/use-block-display-information/index.js.map +3 -3
- package/build-module/components/use-block-drop-zone/index.js +1 -5
- package/build-module/components/use-block-drop-zone/index.js.map +2 -2
- package/build-module/hooks/block-bindings.js +57 -62
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/dimensions.js +3 -3
- package/build-module/hooks/dimensions.js.map +2 -2
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/use-content-only-section-edit.js +46 -0
- package/build-module/hooks/use-content-only-section-edit.js.map +7 -0
- package/build-module/hooks/utils.js +5 -1
- package/build-module/hooks/utils.js.map +2 -2
- package/build-module/layouts/constrained.js +2 -2
- package/build-module/layouts/constrained.js.map +2 -2
- package/build-module/private-apis.js +3 -3
- package/build-module/private-apis.js.map +2 -2
- package/build-module/store/private-keys.js +2 -0
- package/build-module/store/private-keys.js.map +2 -2
- package/build-module/store/private-selectors.js +37 -2
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/selectors.js +6 -4
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/utils/fit-text-utils.js +9 -1
- package/build-module/utils/fit-text-utils.js.map +2 -2
- package/build-style/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +145 -4
- package/build-style/style.css +145 -4
- package/package.json +38 -37
- package/src/components/block-inspector/edit-contents.js +10 -29
- package/src/components/block-inspector/index.js +4 -2
- package/src/components/block-list/block.js +6 -0
- package/src/components/block-list/content.scss +5 -0
- package/src/components/block-list/index.js +3 -1
- package/src/components/block-list/use-block-props/index.js +3 -1
- package/src/components/block-list/use-block-props/use-is-hovered.js +24 -12
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
- package/src/components/block-lock/modal.js +6 -5
- package/src/components/block-lock/use-block-lock.js +10 -14
- package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
- package/src/components/block-settings-menu-controls/edit-section-menu-item.js +39 -0
- package/src/components/block-settings-menu-controls/index.js +8 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +14 -10
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-variation-transforms/index.js +96 -35
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/border-radius-control/single-input-control.js +1 -0
- package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
- package/src/components/content-only-controls/index.js +560 -0
- package/src/components/content-only-controls/link/index.js +200 -0
- package/src/components/content-only-controls/link/styles.scss +23 -0
- package/src/components/content-only-controls/media/index.js +306 -0
- package/src/components/content-only-controls/media/styles.scss +47 -0
- package/src/components/content-only-controls/rich-text/index.js +179 -0
- package/src/components/content-only-controls/rich-text/styles.scss +24 -0
- package/src/components/content-only-controls/styles.scss +44 -0
- package/src/components/content-only-controls/use-inspector-popover-placement.js +19 -0
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +1 -16
- package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
- package/src/components/global-styles/dimensions-panel.js +36 -0
- package/src/components/global-styles/hooks.js +1 -1
- package/src/components/global-styles/typography-panel.js +0 -1
- package/src/components/inserter/media-tab/media-tab.js +2 -44
- package/src/components/inspector-controls-tabs/content-tab.js +12 -4
- package/src/components/inspector-controls-tabs/index.js +4 -1
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
- package/src/components/link-control/index.js +36 -12
- package/src/components/list-view/block-select-button.js +15 -10
- package/src/components/list-view/block.js +9 -7
- package/src/components/media-placeholder/index.js +21 -46
- package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
- package/src/components/media-placeholder/utils.js +65 -0
- package/src/components/media-replace-flow/index.js +25 -42
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-display-information/index.js +30 -2
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/block-bindings.js +71 -82
- package/src/hooks/dimensions.js +8 -3
- package/src/hooks/metadata.js +1 -1
- package/src/hooks/test/metadata.js +1 -1
- package/src/hooks/use-content-only-section-edit.js +63 -0
- package/src/hooks/utils.js +4 -0
- package/src/layouts/constrained.js +8 -2
- package/src/private-apis.js +2 -2
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +121 -5
- package/src/store/selectors.js +6 -4
- package/src/store/test/private-selectors.js +242 -0
- package/src/style.scss +1 -1
- package/src/utils/fit-text-utils.js +19 -1
- package/tsconfig.json +1 -0
- package/build/components/media-upload-modal/index.js +0 -29
- package/build/components/media-upload-modal/index.js.map +0 -7
- package/build-module/components/media-upload-modal/index.js +0 -8
- package/build-module/components/media-upload-modal/index.js.map +0 -7
- package/src/components/font-family/style.scss +0 -7
- package/src/components/media-upload-modal/index.js +0 -18
- /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
- /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
- /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
|
@@ -15,21 +15,33 @@ function listener( event ) {
|
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
19
|
* Adds `is-hovered` class when the block is hovered and in navigation or
|
|
20
20
|
* outline mode.
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} options Options object.
|
|
23
|
+
* @param {boolean} [options.isEnabled=true] Whether to enable hover detection.
|
|
24
|
+
*
|
|
25
|
+
* @return {Function} Ref callback.
|
|
21
26
|
*/
|
|
22
|
-
export function useIsHovered() {
|
|
23
|
-
return useRefEffect(
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
export function useIsHovered( { isEnabled = true } = {} ) {
|
|
28
|
+
return useRefEffect(
|
|
29
|
+
( node ) => {
|
|
30
|
+
if ( ! isEnabled ) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
node.addEventListener( 'mouseout', listener );
|
|
35
|
+
node.addEventListener( 'mouseover', listener );
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
return () => {
|
|
38
|
+
node.removeEventListener( 'mouseout', listener );
|
|
39
|
+
node.removeEventListener( 'mouseover', listener );
|
|
30
40
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
// Remove class in case it lingers.
|
|
42
|
+
node.classList.remove( 'is-hovered' );
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
[ isEnabled ]
|
|
46
|
+
);
|
|
35
47
|
}
|
|
@@ -25,15 +25,20 @@ function isColorTransparent( color ) {
|
|
|
25
25
|
* @param {string} clientId Block client ID.
|
|
26
26
|
*/
|
|
27
27
|
export function useEventHandlers( { clientId, isSelected } ) {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const {
|
|
29
|
+
getBlockRootClientId,
|
|
30
|
+
isZoomOut,
|
|
31
|
+
hasMultiSelection,
|
|
32
|
+
isSectionBlock,
|
|
33
|
+
editedContentOnlySection,
|
|
34
|
+
} = unlock( useSelect( blockEditorStore ) );
|
|
31
35
|
const {
|
|
32
36
|
insertAfterBlock,
|
|
33
37
|
removeBlock,
|
|
34
38
|
resetZoomLevel,
|
|
35
39
|
startDraggingBlocks,
|
|
36
40
|
stopDraggingBlocks,
|
|
41
|
+
editContentOnlySection,
|
|
37
42
|
} = unlock( useDispatch( blockEditorStore ) );
|
|
38
43
|
|
|
39
44
|
return useRefEffect(
|
|
@@ -282,9 +287,32 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
282
287
|
node.addEventListener( 'keydown', onKeyDown );
|
|
283
288
|
node.addEventListener( 'dragstart', onDragStart );
|
|
284
289
|
|
|
290
|
+
/**
|
|
291
|
+
* Handles double-click events on section blocks to edit content only section.
|
|
292
|
+
*
|
|
293
|
+
* @param {MouseEvent} event Double-click event.
|
|
294
|
+
*/
|
|
295
|
+
function onDoubleClick( event ) {
|
|
296
|
+
const isSection = isSectionBlock( clientId );
|
|
297
|
+
const isAlreadyEditing = editedContentOnlySection === clientId;
|
|
298
|
+
|
|
299
|
+
if ( isSection && ! isAlreadyEditing ) {
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
editContentOnlySection( clientId );
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Only add double-click listener if experimental flag is enabled
|
|
306
|
+
if ( window?.__experimentalContentOnlyPatternInsertion ) {
|
|
307
|
+
node.addEventListener( 'dblclick', onDoubleClick );
|
|
308
|
+
}
|
|
309
|
+
|
|
285
310
|
return () => {
|
|
286
311
|
node.removeEventListener( 'keydown', onKeyDown );
|
|
287
312
|
node.removeEventListener( 'dragstart', onDragStart );
|
|
313
|
+
if ( window?.__experimentalContentOnlyPatternInsertion ) {
|
|
314
|
+
node.removeEventListener( 'dblclick', onDoubleClick );
|
|
315
|
+
}
|
|
288
316
|
};
|
|
289
317
|
},
|
|
290
318
|
[
|
|
@@ -298,6 +326,9 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
298
326
|
hasMultiSelection,
|
|
299
327
|
startDraggingBlocks,
|
|
300
328
|
stopDraggingBlocks,
|
|
329
|
+
isSectionBlock,
|
|
330
|
+
editedContentOnlySection,
|
|
331
|
+
editContentOnlySection,
|
|
301
332
|
]
|
|
302
333
|
);
|
|
303
334
|
}
|
|
@@ -42,7 +42,8 @@ function getTemplateLockValue( lock ) {
|
|
|
42
42
|
|
|
43
43
|
export default function BlockLockModal( { clientId, onClose } ) {
|
|
44
44
|
const [ lock, setLock ] = useState( { move: false, remove: false } );
|
|
45
|
-
const {
|
|
45
|
+
const { isEditLocked, isMoveLocked, isRemoveLocked } =
|
|
46
|
+
useBlockLock( clientId );
|
|
46
47
|
const { allowsEditLocking, templateLock, hasTemplateLock } = useSelect(
|
|
47
48
|
( select ) => {
|
|
48
49
|
const { getBlockName, getBlockAttributes } =
|
|
@@ -66,11 +67,11 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
66
67
|
|
|
67
68
|
useEffect( () => {
|
|
68
69
|
setLock( {
|
|
69
|
-
move:
|
|
70
|
-
remove:
|
|
71
|
-
...( allowsEditLocking ? { edit:
|
|
70
|
+
move: isMoveLocked,
|
|
71
|
+
remove: isRemoveLocked,
|
|
72
|
+
...( allowsEditLocking ? { edit: isEditLocked } : {} ),
|
|
72
73
|
} );
|
|
73
|
-
}, [
|
|
74
|
+
}, [ isEditLocked, isMoveLocked, isRemoveLocked, allowsEditLocking ] );
|
|
74
75
|
|
|
75
76
|
const isAllChecked = Object.values( lock ).every( Boolean );
|
|
76
77
|
const isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;
|
|
@@ -7,6 +7,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { store as blockEditorStore } from '../../store';
|
|
10
|
+
import { unlock } from '../../lock-unlock';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Return details about the block lock status.
|
|
@@ -19,25 +20,20 @@ export default function useBlockLock( clientId ) {
|
|
|
19
20
|
return useSelect(
|
|
20
21
|
( select ) => {
|
|
21
22
|
const {
|
|
22
|
-
canEditBlock,
|
|
23
|
-
canMoveBlock,
|
|
24
|
-
canRemoveBlock,
|
|
25
23
|
canLockBlockType,
|
|
26
24
|
getBlockName,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const canRemove = canRemoveBlock( clientId );
|
|
25
|
+
isEditLockedBlock,
|
|
26
|
+
isMoveLockedBlock,
|
|
27
|
+
isRemoveLockedBlock,
|
|
28
|
+
isLockedBlock,
|
|
29
|
+
} = unlock( select( blockEditorStore ) );
|
|
33
30
|
|
|
34
31
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
isEditLocked: isEditLockedBlock( clientId ),
|
|
33
|
+
isMoveLocked: isMoveLockedBlock( clientId ),
|
|
34
|
+
isRemoveLocked: isRemoveLockedBlock( clientId ),
|
|
38
35
|
canLock: canLockBlockType( getBlockName( clientId ) ),
|
|
39
|
-
|
|
40
|
-
isLocked: ! canEdit || ! canMove || ! canRemove,
|
|
36
|
+
isLocked: isLockedBlock( clientId ),
|
|
41
37
|
};
|
|
42
38
|
},
|
|
43
39
|
[ clientId ]
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import blockLibraryStyles from '!!raw-loader!../../../../../block-library/build-style/style.css';
|
|
5
|
+
import { fn } from '@storybook/test';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -32,6 +33,8 @@ export const Default = {
|
|
|
32
33
|
isDraggable: false,
|
|
33
34
|
label: 'Block patterns story',
|
|
34
35
|
showTitlesAsTooltip: false,
|
|
36
|
+
onClickPattern: fn(),
|
|
37
|
+
onHover: fn(),
|
|
35
38
|
},
|
|
36
39
|
argTypes: {
|
|
37
40
|
blockPatterns: { description: 'The patterns to render.' },
|
|
@@ -58,7 +61,6 @@ export const Default = {
|
|
|
58
61
|
},
|
|
59
62
|
},
|
|
60
63
|
parameters: {
|
|
61
|
-
actions: { argTypesRegex: '^on.*' },
|
|
62
64
|
controls: { expanded: true },
|
|
63
65
|
},
|
|
64
66
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { MenuItem } from '@wordpress/components';
|
|
5
|
+
import { _x } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import useContentOnlySectionEdit from '../../hooks/use-content-only-section-edit';
|
|
11
|
+
|
|
12
|
+
export function EditSectionMenuItem( { clientId, onClose } ) {
|
|
13
|
+
const {
|
|
14
|
+
isSectionBlock,
|
|
15
|
+
isEditingContentOnlySection,
|
|
16
|
+
editContentOnlySection,
|
|
17
|
+
} = useContentOnlySectionEdit( clientId );
|
|
18
|
+
|
|
19
|
+
// Only show when the experiment is enabled, the block is a section block,
|
|
20
|
+
// and we're not already editing it
|
|
21
|
+
if (
|
|
22
|
+
! window?.__experimentalContentOnlyPatternInsertion ||
|
|
23
|
+
! isSectionBlock ||
|
|
24
|
+
isEditingContentOnlySection
|
|
25
|
+
) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<MenuItem
|
|
31
|
+
onClick={ () => {
|
|
32
|
+
editContentOnlySection( clientId );
|
|
33
|
+
onClose();
|
|
34
|
+
} }
|
|
35
|
+
>
|
|
36
|
+
{ _x( 'Edit section', 'Editing a section in the Editor' ) }
|
|
37
|
+
</MenuItem>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -22,6 +22,7 @@ import BlockModeToggle from '../block-settings-menu/block-mode-toggle';
|
|
|
22
22
|
import { ModifyContentOnlySectionMenuItem } from '../content-lock';
|
|
23
23
|
import { BlockRenameControl, useBlockRename } from '../block-rename';
|
|
24
24
|
import { BlockVisibilityMenuItem } from '../block-visibility';
|
|
25
|
+
import { EditSectionMenuItem } from './edit-section-menu-item';
|
|
25
26
|
|
|
26
27
|
const { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );
|
|
27
28
|
|
|
@@ -49,7 +50,7 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
|
|
|
49
50
|
canToggleSelectedBlocksVisibility: getBlocksByClientId(
|
|
50
51
|
ids
|
|
51
52
|
).every( ( block ) =>
|
|
52
|
-
hasBlockSupport( block.name, '
|
|
53
|
+
hasBlockSupport( block.name, 'visibility', true )
|
|
53
54
|
),
|
|
54
55
|
};
|
|
55
56
|
},
|
|
@@ -98,6 +99,12 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
|
|
|
98
99
|
onClose={ fillProps?.onClose }
|
|
99
100
|
/>
|
|
100
101
|
) }
|
|
102
|
+
{ selectedClientIds.length === 1 && (
|
|
103
|
+
<EditSectionMenuItem
|
|
104
|
+
clientId={ selectedClientIds[ 0 ] }
|
|
105
|
+
onClose={ fillProps?.onClose }
|
|
106
|
+
/>
|
|
107
|
+
) }
|
|
101
108
|
{ showLockButton && (
|
|
102
109
|
<BlockLockMenuItem
|
|
103
110
|
clientId={ selectedClientIds[ 0 ] }
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { ToolbarButton } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
-
import { copy } from '@wordpress/icons';
|
|
7
|
+
import { copy, symbol } from '@wordpress/icons';
|
|
8
8
|
import { getBlockType, store as blocksStore } from '@wordpress/blocks';
|
|
9
9
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
10
10
|
|
|
@@ -24,7 +24,6 @@ function getBlockIconVariant( { select, clientIds } ) {
|
|
|
24
24
|
getBlockName,
|
|
25
25
|
getBlockAttributes,
|
|
26
26
|
getBlockParentsByBlockName,
|
|
27
|
-
isSectionBlock,
|
|
28
27
|
canRemoveBlocks,
|
|
29
28
|
getTemplateLock,
|
|
30
29
|
getBlockEditingMode,
|
|
@@ -40,8 +39,8 @@ function getBlockIconVariant( { select, clientIds } ) {
|
|
|
40
39
|
const blockName = isSingleBlock && getBlockName( clientIds[ 0 ] );
|
|
41
40
|
const hasBlockStyles =
|
|
42
41
|
isSingleBlock && !! getBlockStyles( blockName )?.length;
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
const hasPatternNameInSelection = clientIds.some(
|
|
43
|
+
( id ) => !! getBlockAttributes( id )?.metadata?.patternName
|
|
45
44
|
);
|
|
46
45
|
const hasPatternOverrides = clientIds.every( ( clientId ) =>
|
|
47
46
|
hasPatternOverridesDefaultBinding(
|
|
@@ -59,7 +58,7 @@ function getBlockIconVariant( { select, clientIds } ) {
|
|
|
59
58
|
getBlockEditingMode( clientIds[ 0 ] ) === 'default';
|
|
60
59
|
const _hideTransformsForSections =
|
|
61
60
|
window?.__experimentalContentOnlyPatternInsertion &&
|
|
62
|
-
|
|
61
|
+
hasPatternNameInSelection;
|
|
63
62
|
const _showBlockSwitcher =
|
|
64
63
|
! _hideTransformsForSections &&
|
|
65
64
|
isDefaultEditingMode &&
|
|
@@ -81,19 +80,24 @@ function getBlockIcon( { select, clientIds } ) {
|
|
|
81
80
|
const { getBlockName, getBlockAttributes } = unlock(
|
|
82
81
|
select( blockEditorStore )
|
|
83
82
|
);
|
|
84
|
-
const { getActiveBlockVariation } = select( blocksStore );
|
|
85
83
|
|
|
86
84
|
const _isSingleBlock = clientIds.length === 1;
|
|
87
85
|
const firstClientId = clientIds[ 0 ];
|
|
86
|
+
const blockAttributes = getBlockAttributes( firstClientId );
|
|
87
|
+
if (
|
|
88
|
+
_isSingleBlock &&
|
|
89
|
+
blockAttributes?.metadata?.patternName &&
|
|
90
|
+
window?.__experimentalContentOnlyPatternInsertion
|
|
91
|
+
) {
|
|
92
|
+
return symbol;
|
|
93
|
+
}
|
|
88
94
|
|
|
89
95
|
const blockName = getBlockName( firstClientId );
|
|
90
96
|
const blockType = getBlockType( blockName );
|
|
91
97
|
|
|
92
98
|
if ( _isSingleBlock ) {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
getBlockAttributes( firstClientId )
|
|
96
|
-
);
|
|
99
|
+
const { getActiveBlockVariation } = select( blocksStore );
|
|
100
|
+
const match = getActiveBlockVariation( blockName, blockAttributes );
|
|
97
101
|
return match?.icon || blockType?.icon;
|
|
98
102
|
}
|
|
99
103
|
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -219,7 +224,7 @@ export default function BlockTools( {
|
|
|
219
224
|
const canToggleBlockVisibility = blocks.every( ( block ) =>
|
|
220
225
|
hasBlockSupport(
|
|
221
226
|
getBlockName( block.clientId ),
|
|
222
|
-
'
|
|
227
|
+
'visibility',
|
|
223
228
|
true
|
|
224
229
|
)
|
|
225
230
|
);
|
|
@@ -262,7 +267,15 @@ export default function BlockTools( {
|
|
|
262
267
|
|
|
263
268
|
return (
|
|
264
269
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
265
|
-
<div
|
|
270
|
+
<div
|
|
271
|
+
{ ...props }
|
|
272
|
+
onKeyDown={ onKeyDown }
|
|
273
|
+
// Popover slots cannot be unmounted during dragging because the
|
|
274
|
+
// will just be rendered in a fallback popover slot instead.
|
|
275
|
+
className={ clsx( props.className, {
|
|
276
|
+
'block-editor-block-tools--is-dragging': isDragging,
|
|
277
|
+
} ) }
|
|
278
|
+
>
|
|
266
279
|
<InsertionPointOpenRef.Provider value={ useRef( false ) }>
|
|
267
280
|
{ ! isTyping && ! isZoomOutMode && (
|
|
268
281
|
<InsertionPoint
|
|
@@ -147,41 +147,102 @@ function VariationsToggleGroupControl( {
|
|
|
147
147
|
|
|
148
148
|
function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
149
149
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
150
|
-
const {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
150
|
+
const {
|
|
151
|
+
activeBlockVariation,
|
|
152
|
+
unfilteredVariations,
|
|
153
|
+
blockName,
|
|
154
|
+
isContentOnly,
|
|
155
|
+
isSection,
|
|
156
|
+
} = useSelect(
|
|
157
|
+
( select ) => {
|
|
158
|
+
const { getActiveBlockVariation, getBlockVariations } =
|
|
159
|
+
select( blocksStore );
|
|
160
|
+
|
|
161
|
+
const {
|
|
162
|
+
getBlockName,
|
|
163
|
+
getBlockAttributes,
|
|
164
|
+
getBlockEditingMode,
|
|
165
|
+
isSectionBlock,
|
|
166
|
+
} = unlock( select( blockEditorStore ) );
|
|
167
|
+
|
|
168
|
+
const name = blockClientId && getBlockName( blockClientId );
|
|
169
|
+
|
|
170
|
+
const { hasContentRoleAttribute } = unlock( select( blocksStore ) );
|
|
171
|
+
const isContentBlock = hasContentRoleAttribute( name );
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
activeBlockVariation: getActiveBlockVariation(
|
|
175
|
+
name,
|
|
176
|
+
getBlockAttributes( blockClientId ),
|
|
177
|
+
'transform'
|
|
178
|
+
),
|
|
179
|
+
unfilteredVariations:
|
|
180
|
+
name && getBlockVariations( name, 'transform' ),
|
|
181
|
+
blockName: name,
|
|
182
|
+
isContentOnly:
|
|
183
|
+
getBlockEditingMode( blockClientId ) === 'contentOnly' &&
|
|
184
|
+
! isContentBlock,
|
|
185
|
+
isSection: isSectionBlock( blockClientId ),
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
[ blockClientId ]
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
/*
|
|
192
|
+
* Hack for WordPress 6.9
|
|
193
|
+
*
|
|
194
|
+
* The Stretchy blocks shipped in 6.9 were ultimately
|
|
195
|
+
* implemented as block variations of the base types Paragraph
|
|
196
|
+
* and Heading. See #73056 for discussion and trade-offs.
|
|
197
|
+
*
|
|
198
|
+
* The main drawback of this choice is that the Variations API
|
|
199
|
+
* doesn't offer enough control over how prominent and how tied
|
|
200
|
+
* to the base type a variation should be.
|
|
201
|
+
*
|
|
202
|
+
* In order to ship these new "blocks" with an acceptable UX,
|
|
203
|
+
* we need two hacks until the Variations API is improved:
|
|
204
|
+
*
|
|
205
|
+
* - Don't show the variations switcher in the block inspector
|
|
206
|
+
* for Paragraph, Heading, Stretchy Paragraph and Stretchy
|
|
207
|
+
* Heading (implemented below). Transformations are still
|
|
208
|
+
* available in the block switcher.
|
|
209
|
+
*
|
|
210
|
+
* - Move the stretchy variations to the end of the core blocks
|
|
211
|
+
* list in the block inserter (implemented in
|
|
212
|
+
* getInserterItems in #73056).
|
|
213
|
+
*/
|
|
214
|
+
const variations = useMemo( () => {
|
|
215
|
+
if ( blockName === 'core/paragraph' ) {
|
|
216
|
+
// Always hide options when active variation is stretchy, but
|
|
217
|
+
// ensure that there are no third-party variations before doing the
|
|
218
|
+
// same elsewhere.
|
|
219
|
+
if (
|
|
220
|
+
activeBlockVariation?.name === 'stretchy-paragraph' ||
|
|
221
|
+
unfilteredVariations.every( ( v ) =>
|
|
222
|
+
[ 'paragraph', 'stretchy-paragraph' ].includes( v.name )
|
|
223
|
+
)
|
|
224
|
+
) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
// If there are other variations, only hide the stretchy one.
|
|
228
|
+
return unfilteredVariations.filter(
|
|
229
|
+
( v ) => v.name !== 'stretchy-paragraph'
|
|
230
|
+
);
|
|
231
|
+
} else if ( blockName === 'core/heading' ) {
|
|
232
|
+
if (
|
|
233
|
+
activeBlockVariation?.name === 'stretchy-heading' ||
|
|
234
|
+
unfilteredVariations.every( ( v ) =>
|
|
235
|
+
[ 'heading', 'stretchy-heading' ].includes( v.name )
|
|
236
|
+
)
|
|
237
|
+
) {
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
return unfilteredVariations.filter(
|
|
241
|
+
( v ) => v.name !== 'stretchy-heading'
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
return unfilteredVariations;
|
|
245
|
+
}, [ activeBlockVariation?.name, blockName, unfilteredVariations ] );
|
|
185
246
|
|
|
186
247
|
const selectedValue = activeBlockVariation?.name;
|
|
187
248
|
|
|
@@ -74,6 +74,7 @@ export default function SingleInputControl( {
|
|
|
74
74
|
const onChangeUnit = ( next ) => {
|
|
75
75
|
const newUnits = { ...selectedUnits };
|
|
76
76
|
if ( corner === 'all' ) {
|
|
77
|
+
newUnits.flat = next;
|
|
77
78
|
newUnits.topLeft = next;
|
|
78
79
|
newUnits.topRight = next;
|
|
79
80
|
newUnits.bottomLeft = next;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
5
|
+
import { moreVertical, check } from '@wordpress/icons';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { useInspectorPopoverPlacement } from './use-inspector-popover-placement';
|
|
12
|
+
|
|
13
|
+
export default function FieldsDropdownMenu( {
|
|
14
|
+
fields,
|
|
15
|
+
visibleFields,
|
|
16
|
+
onToggleField,
|
|
17
|
+
} ) {
|
|
18
|
+
const { popoverProps } = useInspectorPopoverPlacement();
|
|
19
|
+
|
|
20
|
+
if ( ! fields || fields.length === 0 ) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<DropdownMenu
|
|
26
|
+
icon={ moreVertical }
|
|
27
|
+
label={ __( 'Options' ) }
|
|
28
|
+
popoverProps={ popoverProps }
|
|
29
|
+
>
|
|
30
|
+
{ ( { onClose } ) => (
|
|
31
|
+
<MenuGroup label={ __( 'Show / Hide' ) }>
|
|
32
|
+
{ fields.map( ( field ) => {
|
|
33
|
+
const isVisible = visibleFields.includes( field.id );
|
|
34
|
+
return (
|
|
35
|
+
<MenuItem
|
|
36
|
+
key={ field.id }
|
|
37
|
+
isSelected={ isVisible }
|
|
38
|
+
onClick={ () => {
|
|
39
|
+
onToggleField( field.id );
|
|
40
|
+
onClose();
|
|
41
|
+
} }
|
|
42
|
+
role="menuitemcheckbox"
|
|
43
|
+
icon={ isVisible ? check : null }
|
|
44
|
+
>
|
|
45
|
+
{ field.label }
|
|
46
|
+
</MenuItem>
|
|
47
|
+
);
|
|
48
|
+
} ) }
|
|
49
|
+
</MenuGroup>
|
|
50
|
+
) }
|
|
51
|
+
</DropdownMenu>
|
|
52
|
+
);
|
|
53
|
+
}
|