@wordpress/block-editor 15.8.1-next.dc3f6d3c1.0 → 15.9.1-next.6deb34194.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/README.md +12 -0
- package/build/components/block-alignment-matrix-control/index.js +1 -8
- package/build/components/block-alignment-matrix-control/index.js.map +2 -2
- package/build/components/block-bindings/attribute-control.js +172 -0
- package/build/components/block-bindings/attribute-control.js.map +7 -0
- package/build/components/block-bindings/index.js +47 -0
- package/build/components/block-bindings/index.js.map +7 -0
- package/build/components/block-bindings/source-fields-list.js +135 -0
- package/build/components/block-bindings/source-fields-list.js.map +7 -0
- package/build/components/block-bindings/use-block-bindings-utils.js +66 -0
- package/build/components/block-bindings/use-block-bindings-utils.js.map +7 -0
- package/build/components/block-edit/edit.js +1 -3
- package/build/components/block-edit/edit.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/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/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-styles/preview-panel.js +3 -5
- package/build/components/block-styles/preview-panel.js.map +2 -2
- package/build/components/block-styles/use-styles-for-block.js +2 -2
- package/build/components/block-styles/use-styles-for-block.js.map +2 -2
- package/build/components/block-toolbar/index.js +1 -8
- package/build/components/block-toolbar/index.js.map +3 -3
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- 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 +202 -44
- package/build/components/content-only-controls/index.js.map +3 -3
- package/build/components/content-only-controls/link/index.js +92 -103
- package/build/components/content-only-controls/link/index.js.map +3 -3
- package/build/components/content-only-controls/media/index.js +134 -134
- package/build/components/content-only-controls/media/index.js.map +3 -3
- package/build/components/content-only-controls/rich-text/index.js +66 -74
- package/build/components/content-only-controls/rich-text/index.js.map +3 -3
- package/build/components/dimensions-tool/width-height-tool.js +4 -16
- package/build/components/dimensions-tool/width-height-tool.js.map +3 -3
- 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/image-editor/cropper.js +3 -34
- package/build/components/image-editor/cropper.js.map +3 -3
- package/build/components/image-editor/index.js +9 -3
- package/build/components/image-editor/index.js.map +2 -2
- package/build/components/image-editor/use-transform-image.js +62 -32
- package/build/components/image-editor/use-transform-image.js.map +2 -2
- package/build/components/image-editor/zoom-dropdown.js +2 -2
- package/build/components/image-editor/zoom-dropdown.js.map +2 -2
- package/build/components/index.js +10 -3
- package/build/components/index.js.map +2 -2
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +2 -2
- package/build/components/inspector-controls-tabs/content-tab.js +3 -2
- package/build/components/inspector-controls-tabs/content-tab.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 +3 -11
- 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 +17 -4
- package/build/components/media-placeholder/index.js.map +2 -2
- 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 +20 -3
- package/build/components/media-replace-flow/index.js.map +2 -2
- package/build/components/tool-selector/index.js +46 -0
- package/build/components/tool-selector/index.js.map +7 -0
- 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-drop-zone/index.js +1 -5
- package/build/components/use-block-drop-zone/index.js.map +2 -2
- package/build/hooks/block-bindings.js +22 -260
- 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/utils.js +5 -1
- package/build/hooks/utils.js.map +2 -2
- package/build/layouts/grid.js +23 -28
- package/build/layouts/grid.js.map +2 -2
- package/build/store/private-selectors.js +43 -3
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +2 -1
- package/build/store/reducer.js.map +2 -2
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +2 -2
- package/build/utils/block-bindings.js +2 -44
- package/build/utils/block-bindings.js.map +3 -3
- package/build/utils/index.js +2 -5
- package/build/utils/index.js.map +2 -2
- package/build-module/components/block-alignment-matrix-control/index.js +1 -8
- package/build-module/components/block-alignment-matrix-control/index.js.map +2 -2
- package/build-module/components/block-bindings/attribute-control.js +150 -0
- package/build-module/components/block-bindings/attribute-control.js.map +7 -0
- package/build-module/components/block-bindings/index.js +10 -0
- package/build-module/components/block-bindings/index.js.map +7 -0
- package/build-module/components/block-bindings/source-fields-list.js +104 -0
- package/build-module/components/block-bindings/source-fields-list.js.map +7 -0
- package/build-module/components/block-bindings/use-block-bindings-utils.js +45 -0
- package/build-module/components/block-bindings/use-block-bindings-utils.js.map +7 -0
- package/build-module/components/block-edit/edit.js +1 -3
- package/build-module/components/block-edit/edit.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/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/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-styles/preview-panel.js +3 -5
- package/build-module/components/block-styles/preview-panel.js.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.js +2 -2
- package/build-module/components/block-styles/use-styles-for-block.js.map +2 -2
- package/build-module/components/block-toolbar/index.js +1 -8
- package/build-module/components/block-toolbar/index.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-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- 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 +206 -46
- package/build-module/components/content-only-controls/index.js.map +2 -2
- package/build-module/components/content-only-controls/link/index.js +92 -104
- package/build-module/components/content-only-controls/link/index.js.map +2 -2
- package/build-module/components/content-only-controls/media/index.js +134 -135
- package/build-module/components/content-only-controls/media/index.js.map +2 -2
- package/build-module/components/content-only-controls/rich-text/index.js +68 -81
- package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.js +4 -6
- package/build-module/components/dimensions-tool/width-height-tool.js.map +2 -2
- 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/image-editor/cropper.js +3 -34
- package/build-module/components/image-editor/cropper.js.map +2 -2
- package/build-module/components/image-editor/index.js +9 -3
- package/build-module/components/image-editor/index.js.map +2 -2
- package/build-module/components/image-editor/use-transform-image.js +63 -33
- package/build-module/components/image-editor/use-transform-image.js.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.js +2 -2
- package/build-module/components/image-editor/zoom-dropdown.js.map +2 -2
- package/build-module/components/index.js +74 -66
- package/build-module/components/index.js.map +2 -2
- package/build-module/components/inserter-draggable-blocks/index.js +8 -4
- package/build-module/components/inserter-draggable-blocks/index.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js +3 -2
- package/build-module/components/inspector-controls-tabs/content-tab.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 +3 -11
- 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 +18 -5
- 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 +20 -3
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/tool-selector/index.js +15 -0
- package/build-module/components/tool-selector/index.js.map +7 -0
- 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-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 +27 -270
- 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/utils.js +5 -1
- package/build-module/hooks/utils.js.map +2 -2
- package/build-module/layouts/grid.js +23 -28
- package/build-module/layouts/grid.js.map +2 -2
- package/build-module/store/private-selectors.js +39 -3
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +2 -1
- package/build-module/store/reducer.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/block-bindings.js +1 -42
- package/build-module/utils/block-bindings.js.map +2 -2
- package/build-module/utils/index.js +1 -3
- package/build-module/utils/index.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 +20 -11
- package/build-style/style.css +20 -11
- package/package.json +39 -39
- package/src/components/block-alignment-matrix-control/index.js +1 -5
- package/src/components/block-bindings/attribute-control.js +174 -0
- package/src/components/block-bindings/index.js +6 -0
- package/src/components/block-bindings/source-fields-list.js +130 -0
- package/src/components/block-bindings/use-block-bindings-utils.js +156 -0
- package/src/components/block-edit/edit.js +1 -3
- 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/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/index.js +1 -1
- package/src/components/block-styles/preview-panel.js +3 -5
- package/src/components/block-styles/use-styles-for-block.js +2 -2
- package/src/components/block-toolbar/index.js +1 -6
- package/src/components/block-toolbar/style.scss +6 -6
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
- package/src/components/content-only-controls/index.js +289 -50
- package/src/components/content-only-controls/link/index.js +62 -57
- package/src/components/content-only-controls/media/index.js +177 -156
- package/src/components/content-only-controls/rich-text/index.js +31 -44
- package/src/components/content-only-controls/styles.scss +10 -1
- package/src/components/dimensions-tool/width-height-tool.js +6 -13
- 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/image-editor/cropper.js +3 -32
- package/src/components/image-editor/index.js +34 -29
- package/src/components/image-editor/use-transform-image.js +80 -34
- package/src/components/image-editor/zoom-dropdown.js +2 -2
- package/src/components/index.js +9 -1
- package/src/components/inserter/style.scss +1 -1
- package/src/components/inserter-draggable-blocks/index.js +19 -8
- package/src/components/inspector-controls-tabs/content-tab.js +6 -2
- 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 +22 -30
- package/src/components/list-view/block.js +9 -7
- package/src/components/media-placeholder/index.js +20 -5
- 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 +22 -3
- package/src/components/tool-selector/index.js +19 -0
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/block-bindings.js +27 -347
- 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/utils.js +4 -0
- package/src/layouts/grid.js +40 -72
- package/src/layouts/test/grid.js +14 -0
- package/src/store/private-selectors.js +123 -6
- package/src/store/reducer.js +3 -0
- package/src/store/selectors.js +6 -4
- package/src/store/test/private-selectors.js +242 -0
- package/src/store/test/reducer.js +17 -7
- package/src/style.scss +0 -1
- package/src/utils/block-bindings.js +0 -157
- package/src/utils/index.js +0 -1
- package/tsconfig.json +2 -0
- package/build/components/block-toolbar/block-name-context.js +0 -30
- package/build/components/block-toolbar/block-name-context.js.map +0 -7
- package/build/components/content-only-controls/plain-text/index.js +0 -68
- package/build/components/content-only-controls/plain-text/index.js.map +0 -7
- package/build-module/components/block-toolbar/block-name-context.js +0 -9
- package/build-module/components/block-toolbar/block-name-context.js.map +0 -7
- package/build-module/components/content-only-controls/plain-text/index.js +0 -50
- package/build-module/components/content-only-controls/plain-text/index.js.map +0 -7
- package/src/components/block-toolbar/block-name-context.js +0 -9
- package/src/components/content-only-controls/plain-text/index.js +0 -49
- package/src/components/font-family/style.scss +0 -7
- /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/{utils → components/block-bindings}/test/use-block-bindings-utils.js +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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { getBlockBindingsSource } from '@wordpress/blocks';
|
|
10
|
+
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
12
|
+
import { useContext, useMemo } from '@wordpress/element';
|
|
13
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import useBlockBindingsUtils from './use-block-bindings-utils';
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
20
|
+
import BlockContext from '../block-context';
|
|
21
|
+
|
|
22
|
+
const { Menu } = unlock( componentsPrivateApis );
|
|
23
|
+
|
|
24
|
+
function BlockBindingsSourceFieldsListItem( {
|
|
25
|
+
args,
|
|
26
|
+
attribute,
|
|
27
|
+
field,
|
|
28
|
+
source,
|
|
29
|
+
sourceKey,
|
|
30
|
+
} ) {
|
|
31
|
+
const itemBindings = useMemo(
|
|
32
|
+
() => ( {
|
|
33
|
+
source: sourceKey,
|
|
34
|
+
args: field.args || {
|
|
35
|
+
key: field.key,
|
|
36
|
+
},
|
|
37
|
+
} ),
|
|
38
|
+
[ field.args, field.key, sourceKey ]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const blockContext = useContext( BlockContext );
|
|
42
|
+
const values = useSelect(
|
|
43
|
+
( select ) =>
|
|
44
|
+
source.getValues( {
|
|
45
|
+
select,
|
|
46
|
+
context: blockContext,
|
|
47
|
+
bindings: {
|
|
48
|
+
[ attribute ]: itemBindings,
|
|
49
|
+
},
|
|
50
|
+
} ),
|
|
51
|
+
[ attribute, blockContext, itemBindings, source ]
|
|
52
|
+
);
|
|
53
|
+
const { updateBlockBindings } = useBlockBindingsUtils();
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Menu.CheckboxItem
|
|
57
|
+
onChange={ () => {
|
|
58
|
+
const isCurrentlySelected =
|
|
59
|
+
fastDeepEqual( args, field.args ) ??
|
|
60
|
+
// Deprecate key dependency in 7.0.
|
|
61
|
+
field.key === args?.key;
|
|
62
|
+
|
|
63
|
+
if ( isCurrentlySelected ) {
|
|
64
|
+
// Unset if the same field is selected again.
|
|
65
|
+
updateBlockBindings( {
|
|
66
|
+
[ attribute ]: undefined,
|
|
67
|
+
} );
|
|
68
|
+
} else {
|
|
69
|
+
updateBlockBindings( {
|
|
70
|
+
[ attribute ]: itemBindings,
|
|
71
|
+
} );
|
|
72
|
+
}
|
|
73
|
+
} }
|
|
74
|
+
name={ attribute + '-binding' }
|
|
75
|
+
value={ values[ attribute ] }
|
|
76
|
+
checked={
|
|
77
|
+
fastDeepEqual( args, field.args ) ??
|
|
78
|
+
// Deprecate key dependency in 7.0.
|
|
79
|
+
field.key === args?.key
|
|
80
|
+
}
|
|
81
|
+
>
|
|
82
|
+
<Menu.ItemLabel>{ field.label }</Menu.ItemLabel>
|
|
83
|
+
<Menu.ItemHelpText>{ values[ attribute ] }</Menu.ItemHelpText>
|
|
84
|
+
</Menu.CheckboxItem>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default function BlockBindingsSourceFieldsList( {
|
|
89
|
+
args,
|
|
90
|
+
attribute,
|
|
91
|
+
sourceKey,
|
|
92
|
+
fields,
|
|
93
|
+
} ) {
|
|
94
|
+
const isMobile = useViewportMatch( 'medium', '<' );
|
|
95
|
+
|
|
96
|
+
// Only render source if it has compatible fields.
|
|
97
|
+
if ( ! fields || fields.length === 0 ) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const source = getBlockBindingsSource( sourceKey );
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<Menu
|
|
105
|
+
key={ sourceKey }
|
|
106
|
+
placement={ isMobile ? 'bottom-start' : 'left-start' }
|
|
107
|
+
>
|
|
108
|
+
<Menu.SubmenuTriggerItem>
|
|
109
|
+
<Menu.ItemLabel>{ source.label }</Menu.ItemLabel>
|
|
110
|
+
</Menu.SubmenuTriggerItem>
|
|
111
|
+
<Menu.Popover gutter={ 8 }>
|
|
112
|
+
<Menu.Group>
|
|
113
|
+
{ fields.map( ( field ) => (
|
|
114
|
+
<BlockBindingsSourceFieldsListItem
|
|
115
|
+
key={
|
|
116
|
+
sourceKey + JSON.stringify( field.args ) ||
|
|
117
|
+
field.key
|
|
118
|
+
}
|
|
119
|
+
args={ args }
|
|
120
|
+
attribute={ attribute }
|
|
121
|
+
field={ field }
|
|
122
|
+
source={ source }
|
|
123
|
+
sourceKey={ sourceKey }
|
|
124
|
+
/>
|
|
125
|
+
) ) }
|
|
126
|
+
</Menu.Group>
|
|
127
|
+
</Menu.Popover>
|
|
128
|
+
</Menu>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch, useRegistry } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as blockEditorStore } from '../../store';
|
|
10
|
+
import { useBlockEditContext } from '../block-edit';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the given object is empty.
|
|
14
|
+
*
|
|
15
|
+
* @param {?Object} object The object to check.
|
|
16
|
+
*
|
|
17
|
+
* @return {boolean} Whether the object is empty.
|
|
18
|
+
*/
|
|
19
|
+
function isObjectEmpty( object ) {
|
|
20
|
+
return ! object || Object.keys( object ).length === 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Contains utils to update the block `bindings` metadata.
|
|
25
|
+
*
|
|
26
|
+
* @typedef {Object} WPBlockBindingsUtils
|
|
27
|
+
*
|
|
28
|
+
* @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.
|
|
29
|
+
* @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the existing utils needed to update the block `bindings` metadata.
|
|
34
|
+
* They can be used to create, modify, or remove connections from the existing block attributes.
|
|
35
|
+
*
|
|
36
|
+
* It contains the following utils:
|
|
37
|
+
* - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.
|
|
38
|
+
* - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.
|
|
39
|
+
*
|
|
40
|
+
* @since 6.7.0 Introduced in WordPress core.
|
|
41
|
+
*
|
|
42
|
+
* @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.
|
|
43
|
+
*
|
|
44
|
+
* @return {?WPBlockBindingsUtils} Object containing the block bindings utils.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```js
|
|
48
|
+
* import { useBlockBindingsUtils } from '@wordpress/block-editor'
|
|
49
|
+
* const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();
|
|
50
|
+
*
|
|
51
|
+
* // Update url and alt attributes.
|
|
52
|
+
* updateBlockBindings( {
|
|
53
|
+
* url: {
|
|
54
|
+
* source: 'core/post-meta',
|
|
55
|
+
* args: {
|
|
56
|
+
* key: 'url_custom_field',
|
|
57
|
+
* },
|
|
58
|
+
* },
|
|
59
|
+
* alt: {
|
|
60
|
+
* source: 'core/post-meta',
|
|
61
|
+
* args: {
|
|
62
|
+
* key: 'text_custom_field',
|
|
63
|
+
* },
|
|
64
|
+
* },
|
|
65
|
+
* } );
|
|
66
|
+
*
|
|
67
|
+
* // Remove binding from url attribute.
|
|
68
|
+
* updateBlockBindings( { url: undefined } );
|
|
69
|
+
*
|
|
70
|
+
* // Remove bindings from all attributes.
|
|
71
|
+
* removeAllBlockBindings();
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export default function useBlockBindingsUtils( clientId ) {
|
|
75
|
+
const { clientId: contextClientId } = useBlockEditContext();
|
|
76
|
+
const blockClientId = clientId || contextClientId;
|
|
77
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
78
|
+
const { getBlockAttributes } = useRegistry().select( blockEditorStore );
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Updates the value of the bindings connected to block attributes.
|
|
82
|
+
* It removes the binding when the new value is `undefined`.
|
|
83
|
+
*
|
|
84
|
+
* @param {Object} bindings Bindings including the attributes to update and the new object.
|
|
85
|
+
* @param {string} bindings.source The source name to connect to.
|
|
86
|
+
* @param {Object} [bindings.args] Object containing the arguments needed by the source.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```js
|
|
90
|
+
* import { useBlockBindingsUtils } from '@wordpress/block-editor'
|
|
91
|
+
*
|
|
92
|
+
* const { updateBlockBindings } = useBlockBindingsUtils();
|
|
93
|
+
* updateBlockBindings( {
|
|
94
|
+
* url: {
|
|
95
|
+
* source: 'core/post-meta',
|
|
96
|
+
* args: {
|
|
97
|
+
* key: 'url_custom_field',
|
|
98
|
+
* },
|
|
99
|
+
* },
|
|
100
|
+
* alt: {
|
|
101
|
+
* source: 'core/post-meta',
|
|
102
|
+
* args: {
|
|
103
|
+
* key: 'text_custom_field',
|
|
104
|
+
* },
|
|
105
|
+
* }
|
|
106
|
+
* } );
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
const updateBlockBindings = ( bindings ) => {
|
|
110
|
+
const { metadata: { bindings: currentBindings, ...metadata } = {} } =
|
|
111
|
+
getBlockAttributes( blockClientId );
|
|
112
|
+
const newBindings = { ...currentBindings };
|
|
113
|
+
|
|
114
|
+
Object.entries( bindings ).forEach( ( [ attribute, binding ] ) => {
|
|
115
|
+
if ( ! binding && newBindings[ attribute ] ) {
|
|
116
|
+
delete newBindings[ attribute ];
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
newBindings[ attribute ] = binding;
|
|
120
|
+
} );
|
|
121
|
+
|
|
122
|
+
const newMetadata = {
|
|
123
|
+
...metadata,
|
|
124
|
+
bindings: newBindings,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
if ( isObjectEmpty( newMetadata.bindings ) ) {
|
|
128
|
+
delete newMetadata.bindings;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
updateBlockAttributes( blockClientId, {
|
|
132
|
+
metadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,
|
|
133
|
+
} );
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Removes the bindings property of the `metadata` attribute.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```js
|
|
141
|
+
* import { useBlockBindingsUtils } from '@wordpress/block-editor'
|
|
142
|
+
*
|
|
143
|
+
* const { removeAllBlockBindings } = useBlockBindingsUtils();
|
|
144
|
+
* removeAllBlockBindings();
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
const removeAllBlockBindings = () => {
|
|
148
|
+
const { metadata: { bindings, ...metadata } = {} } =
|
|
149
|
+
getBlockAttributes( blockClientId );
|
|
150
|
+
updateBlockAttributes( blockClientId, {
|
|
151
|
+
metadata: isObjectEmpty( metadata ) ? undefined : metadata,
|
|
152
|
+
} );
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return { updateBlockBindings, removeAllBlockBindings };
|
|
156
|
+
}
|
|
@@ -100,10 +100,10 @@ const EditWithGeneratedProps = ( props ) => {
|
|
|
100
100
|
),
|
|
101
101
|
};
|
|
102
102
|
}, [
|
|
103
|
-
name,
|
|
104
103
|
blockType?.usesContext,
|
|
105
104
|
blockContext,
|
|
106
105
|
attributes?.metadata?.bindings,
|
|
106
|
+
bindableAttributes,
|
|
107
107
|
registeredSources,
|
|
108
108
|
] );
|
|
109
109
|
|
|
@@ -180,7 +180,6 @@ const EditWithGeneratedProps = ( props ) => {
|
|
|
180
180
|
blockBindings,
|
|
181
181
|
clientId,
|
|
182
182
|
context,
|
|
183
|
-
name,
|
|
184
183
|
registeredSources,
|
|
185
184
|
]
|
|
186
185
|
);
|
|
@@ -262,7 +261,6 @@ const EditWithGeneratedProps = ( props ) => {
|
|
|
262
261
|
hasPatternOverrides,
|
|
263
262
|
setAttributes,
|
|
264
263
|
registeredSources,
|
|
265
|
-
name,
|
|
266
264
|
registry,
|
|
267
265
|
]
|
|
268
266
|
);
|
|
@@ -222,6 +222,11 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
|
|
|
222
222
|
cursor: grab;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
// Dragging multi selected blocks is not supported yet.
|
|
226
|
+
&.is-multi-selected {
|
|
227
|
+
cursor: default;
|
|
228
|
+
}
|
|
229
|
+
|
|
225
230
|
&[contenteditable],
|
|
226
231
|
[contenteditable] {
|
|
227
232
|
cursor: text;
|
|
@@ -226,6 +226,8 @@ function Items( {
|
|
|
226
226
|
rootClientId === selectedBlockClientId
|
|
227
227
|
);
|
|
228
228
|
|
|
229
|
+
const templateLock = getTemplateLock( rootClientId );
|
|
230
|
+
|
|
229
231
|
return {
|
|
230
232
|
order: _order,
|
|
231
233
|
selectedBlocks: selectedBlockClientIds,
|
|
@@ -238,7 +240,7 @@ function Items( {
|
|
|
238
240
|
rootClientId
|
|
239
241
|
) ) &&
|
|
240
242
|
getBlockEditingMode( rootClientId ) !== 'disabled' &&
|
|
241
|
-
!
|
|
243
|
+
( ! templateLock || templateLock === 'contentOnly' ) &&
|
|
242
244
|
hasAppender &&
|
|
243
245
|
! _isZoomOut() &&
|
|
244
246
|
( hasCustomAppender ||
|
|
@@ -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
|
};
|
|
@@ -50,7 +50,7 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
|
|
|
50
50
|
canToggleSelectedBlocksVisibility: getBlocksByClientId(
|
|
51
51
|
ids
|
|
52
52
|
).every( ( block ) =>
|
|
53
|
-
hasBlockSupport( block.name, '
|
|
53
|
+
hasBlockSupport( block.name, 'visibility', true )
|
|
54
54
|
),
|
|
55
55
|
};
|
|
56
56
|
},
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { getBlockType } from '@wordpress/blocks';
|
|
5
4
|
import { useMemo } from '@wordpress/element';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -16,11 +15,10 @@ export default function BlockStylesPreviewPanel( {
|
|
|
16
15
|
className,
|
|
17
16
|
activeStyle,
|
|
18
17
|
} ) {
|
|
19
|
-
const example = getBlockType( genericPreviewBlock.name )?.example;
|
|
20
18
|
const styleClassName = replaceActiveStyle( className, activeStyle, style );
|
|
21
19
|
const previewBlocks = useMemo( () => {
|
|
22
20
|
return {
|
|
23
|
-
|
|
21
|
+
name: genericPreviewBlock.name,
|
|
24
22
|
title: style.label || style.name,
|
|
25
23
|
description: style.description,
|
|
26
24
|
initialAttributes: {
|
|
@@ -29,9 +27,9 @@ export default function BlockStylesPreviewPanel( {
|
|
|
29
27
|
styleClassName +
|
|
30
28
|
' block-editor-block-styles__block-preview-container',
|
|
31
29
|
},
|
|
32
|
-
example,
|
|
30
|
+
example: genericPreviewBlock,
|
|
33
31
|
};
|
|
34
|
-
}, [ genericPreviewBlock, styleClassName ] );
|
|
32
|
+
}, [ genericPreviewBlock, style, styleClassName ] );
|
|
35
33
|
|
|
36
34
|
return <InserterPreviewPanel item={ previewBlocks } />;
|
|
37
35
|
}
|
|
@@ -37,7 +37,7 @@ function useGenericPreviewBlock( block, type ) {
|
|
|
37
37
|
if ( block ) {
|
|
38
38
|
return cloneBlock( block );
|
|
39
39
|
}
|
|
40
|
-
}, [ type?.example
|
|
40
|
+
}, [ block, type?.example, type?.name ] );
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -63,7 +63,7 @@ export default function useStylesForBlocks( { clientId, onSwitch } ) {
|
|
|
63
63
|
const { getBlockStyles } = select( blocksStore );
|
|
64
64
|
|
|
65
65
|
return {
|
|
66
|
-
block,
|
|
66
|
+
block: ! blockType?.example ? block : null,
|
|
67
67
|
blockType,
|
|
68
68
|
styles: getBlockStyles( block.name ),
|
|
69
69
|
className: block.attributes.className || '',
|
|
@@ -32,7 +32,6 @@ import { BlockGroupToolbar } from '../convert-to-group-buttons';
|
|
|
32
32
|
import BlockEditVisuallyButton from '../block-edit-visually-button';
|
|
33
33
|
import { useShowHoveredOrFocusedGestures } from './utils';
|
|
34
34
|
import { store as blockEditorStore } from '../../store';
|
|
35
|
-
import __unstableBlockNameContext from './block-name-context';
|
|
36
35
|
import NavigableToolbar from '../navigable-toolbar';
|
|
37
36
|
import { useHasBlockToolbar } from './use-has-block-toolbar';
|
|
38
37
|
import ChangeDesign from './change-design';
|
|
@@ -265,11 +264,7 @@ export function PrivateBlockToolbar( {
|
|
|
265
264
|
group="other"
|
|
266
265
|
className="block-editor-block-toolbar__slot"
|
|
267
266
|
/>
|
|
268
|
-
<
|
|
269
|
-
value={ blockType?.name }
|
|
270
|
-
>
|
|
271
|
-
<__unstableBlockToolbarLastItem.Slot />
|
|
272
|
-
</__unstableBlockNameContext.Provider>
|
|
267
|
+
<__unstableBlockToolbarLastItem.Slot />
|
|
273
268
|
</>
|
|
274
269
|
) }
|
|
275
270
|
<BlockEditVisuallyButton clientIds={ blockClientIds } />
|
|
@@ -193,6 +193,12 @@
|
|
|
193
193
|
font-size: $helptext-font-size;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
+
|
|
197
|
+
.block-editor-block-icon {
|
|
198
|
+
width: 0 !important;
|
|
199
|
+
height: 0 !important;
|
|
200
|
+
min-width: 0 !important;
|
|
201
|
+
}
|
|
196
202
|
}
|
|
197
203
|
|
|
198
204
|
// Padding overrides.
|
|
@@ -201,12 +207,6 @@
|
|
|
201
207
|
padding-right: 6px;
|
|
202
208
|
}
|
|
203
209
|
|
|
204
|
-
.block-editor-block-icon {
|
|
205
|
-
width: 0 !important;
|
|
206
|
-
height: 0 !important;
|
|
207
|
-
min-width: 0 !important;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
210
|
// Parent selector overrides
|
|
211
211
|
.block-editor-block-parent-selector .block-editor-block-parent-selector__button {
|
|
212
212
|
border-top-right-radius: 0;
|
|
@@ -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
|