@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
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
// packages/block-editor/src/utils/block-bindings.js
|
|
2
|
-
import { useDispatch, useRegistry } from "@wordpress/data";
|
|
3
|
-
import { store as blockEditorStore } from "../store";
|
|
4
|
-
import { useBlockEditContext } from "../components/block-edit";
|
|
5
2
|
var DEFAULT_ATTRIBUTE = "__default";
|
|
6
3
|
var PATTERN_OVERRIDES_SOURCE = "core/pattern-overrides";
|
|
7
|
-
function isObjectEmpty(object) {
|
|
8
|
-
return !object || Object.keys(object).length === 0;
|
|
9
|
-
}
|
|
10
4
|
function hasPatternOverridesDefaultBinding(bindings) {
|
|
11
5
|
return bindings?.[DEFAULT_ATTRIBUTE]?.source === PATTERN_OVERRIDES_SOURCE;
|
|
12
6
|
}
|
|
@@ -21,43 +15,8 @@ function replacePatternOverridesDefaultBinding(bindings, supportedAttributes) {
|
|
|
21
15
|
}
|
|
22
16
|
return bindings;
|
|
23
17
|
}
|
|
24
|
-
function useBlockBindingsUtils(clientId) {
|
|
25
|
-
const { clientId: contextClientId } = useBlockEditContext();
|
|
26
|
-
const blockClientId = clientId || contextClientId;
|
|
27
|
-
const { updateBlockAttributes } = useDispatch(blockEditorStore);
|
|
28
|
-
const { getBlockAttributes } = useRegistry().select(blockEditorStore);
|
|
29
|
-
const updateBlockBindings = (bindings) => {
|
|
30
|
-
const { metadata: { bindings: currentBindings, ...metadata } = {} } = getBlockAttributes(blockClientId);
|
|
31
|
-
const newBindings = { ...currentBindings };
|
|
32
|
-
Object.entries(bindings).forEach(([attribute, binding]) => {
|
|
33
|
-
if (!binding && newBindings[attribute]) {
|
|
34
|
-
delete newBindings[attribute];
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
newBindings[attribute] = binding;
|
|
38
|
-
});
|
|
39
|
-
const newMetadata = {
|
|
40
|
-
...metadata,
|
|
41
|
-
bindings: newBindings
|
|
42
|
-
};
|
|
43
|
-
if (isObjectEmpty(newMetadata.bindings)) {
|
|
44
|
-
delete newMetadata.bindings;
|
|
45
|
-
}
|
|
46
|
-
updateBlockAttributes(blockClientId, {
|
|
47
|
-
metadata: isObjectEmpty(newMetadata) ? void 0 : newMetadata
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
const removeAllBlockBindings = () => {
|
|
51
|
-
const { metadata: { bindings, ...metadata } = {} } = getBlockAttributes(blockClientId);
|
|
52
|
-
updateBlockAttributes(blockClientId, {
|
|
53
|
-
metadata: isObjectEmpty(metadata) ? void 0 : metadata
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
return { updateBlockBindings, removeAllBlockBindings };
|
|
57
|
-
}
|
|
58
18
|
export {
|
|
59
19
|
hasPatternOverridesDefaultBinding,
|
|
60
|
-
replacePatternOverridesDefaultBinding
|
|
61
|
-
useBlockBindingsUtils
|
|
20
|
+
replacePatternOverridesDefaultBinding
|
|
62
21
|
};
|
|
63
22
|
//# sourceMappingURL=block-bindings.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/block-bindings.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["const DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {boolean} Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding( bindings ) {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n * @param {string[]} supportedAttributes The block's attributes which are supported by block bindings.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding(\n\tbindings,\n\tsupportedAttributes\n) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( hasPatternOverridesDefaultBinding( bindings ) ) {\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: PATTERN_OVERRIDES_SOURCE };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,IAAM,oBAAoB;AAC1B,IAAM,2BAA2B;AAS1B,SAAS,kCAAmC,UAAW;AAC7D,SAAO,WAAY,iBAAkB,GAAG,WAAW;AACpD;AAcO,SAAS,sCACf,UACA,qBACC;AAED,MAAK,kCAAmC,QAAS,GAAI;AACpD,UAAM,uBAAuB,CAAC;AAC9B,eAAY,iBAAiB,qBAAsB;AAElD,YAAM,gBAAgB,SAAU,aAAc,IAC3C,SAAU,aAAc,IACxB,EAAE,QAAQ,yBAAyB;AACtC,2BAAsB,aAAc,IAAI;AAAA,IACzC;AAEA,WAAO;AAAA,EACR;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// packages/block-editor/src/utils/index.js
|
|
2
2
|
import { default as default2 } from "./transform-styles";
|
|
3
3
|
import { default as default3 } from "./get-px-from-css-unit";
|
|
4
|
-
import { useBlockBindingsUtils } from "./block-bindings";
|
|
5
4
|
export {
|
|
6
5
|
default3 as getPxFromCssUnit,
|
|
7
|
-
default2 as transformStyles
|
|
8
|
-
useBlockBindingsUtils
|
|
6
|
+
default2 as transformStyles
|
|
9
7
|
};
|
|
10
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/index.js"],
|
|
4
|
-
"sourcesContent": ["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\
|
|
5
|
-
"mappings": ";AAAA,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAmC;
|
|
4
|
+
"sourcesContent": ["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAmC;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -279,6 +279,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
|
|
|
279
279
|
.block-editor-block-list__layout .block-editor-block-list__block[draggable=true], .block-editor-block-list__layout .block-editor-block-list__block[data-draggable=true] {
|
|
280
280
|
cursor: grab;
|
|
281
281
|
}
|
|
282
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-multi-selected {
|
|
283
|
+
cursor: default;
|
|
284
|
+
}
|
|
282
285
|
.block-editor-block-list__layout .block-editor-block-list__block[contenteditable],
|
|
283
286
|
.block-editor-block-list__layout .block-editor-block-list__block [contenteditable] {
|
|
284
287
|
cursor: text;
|
package/build-style/content.css
CHANGED
|
@@ -279,6 +279,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
|
|
|
279
279
|
.block-editor-block-list__layout .block-editor-block-list__block[draggable=true], .block-editor-block-list__layout .block-editor-block-list__block[data-draggable=true] {
|
|
280
280
|
cursor: grab;
|
|
281
281
|
}
|
|
282
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-multi-selected {
|
|
283
|
+
cursor: default;
|
|
284
|
+
}
|
|
282
285
|
.block-editor-block-list__layout .block-editor-block-list__block[contenteditable],
|
|
283
286
|
.block-editor-block-list__layout .block-editor-block-list__block [contenteditable] {
|
|
284
287
|
cursor: text;
|
|
@@ -531,6 +531,10 @@ iframe[name=editor-canvas] {
|
|
|
531
531
|
right: 50%;
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
+
.block-editor-block-tools--is-dragging > .popover-slot {
|
|
535
|
+
display: none;
|
|
536
|
+
}
|
|
537
|
+
|
|
534
538
|
.block-editor-block-lock-modal {
|
|
535
539
|
z-index: 1000001;
|
|
536
540
|
}
|
|
@@ -1735,7 +1739,7 @@ block-editor-content-only-controls__media-thumbnail {
|
|
|
1735
1739
|
}
|
|
1736
1740
|
|
|
1737
1741
|
.block-editor-content-only-controls__screen.components-navigator-screen {
|
|
1738
|
-
padding: 8px 0
|
|
1742
|
+
padding: 8px 0 16px 0;
|
|
1739
1743
|
}
|
|
1740
1744
|
.block-editor-content-only-controls__screen {
|
|
1741
1745
|
border-top: 1px solid #e0e0e0;
|
|
@@ -1755,6 +1759,15 @@ block-editor-content-only-controls__media-thumbnail {
|
|
|
1755
1759
|
width: 100%;
|
|
1756
1760
|
}
|
|
1757
1761
|
|
|
1762
|
+
.block-editor-content-only-controls__fields-container {
|
|
1763
|
+
padding: 0 16px;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
.block-editor-content-only-controls__fields-header {
|
|
1767
|
+
padding: 8px 0;
|
|
1768
|
+
margin-bottom: 4px;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1758
1771
|
.block-editor-date-format-picker {
|
|
1759
1772
|
margin: 0 0 16px;
|
|
1760
1773
|
padding: 0;
|
|
@@ -1788,10 +1801,6 @@ block-editor-content-only-controls__media-thumbnail {
|
|
|
1788
1801
|
text-transform: capitalize;
|
|
1789
1802
|
}
|
|
1790
1803
|
|
|
1791
|
-
.block-editor-font-family-control:not(.is-next-has-no-margin-bottom) {
|
|
1792
|
-
margin-bottom: 8px;
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
1804
|
.block-editor-global-styles__toggle-icon {
|
|
1796
1805
|
fill: currentColor;
|
|
1797
1806
|
}
|
|
@@ -3773,15 +3782,15 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3773
3782
|
content: attr(aria-label);
|
|
3774
3783
|
font-size: 12px;
|
|
3775
3784
|
}
|
|
3776
|
-
.show-icon-labels .
|
|
3777
|
-
padding-right: 6px;
|
|
3778
|
-
padding-left: 6px;
|
|
3779
|
-
}
|
|
3780
|
-
.show-icon-labels .block-editor-block-icon {
|
|
3785
|
+
.show-icon-labels .block-editor-block-toolbar .block-editor-block-icon {
|
|
3781
3786
|
width: 0 !important;
|
|
3782
3787
|
height: 0 !important;
|
|
3783
3788
|
min-width: 0 !important;
|
|
3784
3789
|
}
|
|
3790
|
+
.show-icon-labels .components-accessible-toolbar .components-toolbar-group > div:first-child:last-child > .components-button.has-icon {
|
|
3791
|
+
padding-right: 6px;
|
|
3792
|
+
padding-left: 6px;
|
|
3793
|
+
}
|
|
3785
3794
|
.show-icon-labels .block-editor-block-parent-selector .block-editor-block-parent-selector__button {
|
|
3786
3795
|
border-top-left-radius: 0;
|
|
3787
3796
|
border-bottom-left-radius: 0;
|
|
@@ -4210,7 +4219,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
4210
4219
|
right: 0;
|
|
4211
4220
|
bottom: 0;
|
|
4212
4221
|
width: 280px;
|
|
4213
|
-
padding: 24px
|
|
4222
|
+
padding: 24px 24px 24px;
|
|
4214
4223
|
overflow-x: visible;
|
|
4215
4224
|
overflow-y: auto;
|
|
4216
4225
|
}
|
package/build-style/style.css
CHANGED
|
@@ -531,6 +531,10 @@ iframe[name=editor-canvas] {
|
|
|
531
531
|
left: 50%;
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
+
.block-editor-block-tools--is-dragging > .popover-slot {
|
|
535
|
+
display: none;
|
|
536
|
+
}
|
|
537
|
+
|
|
534
538
|
.block-editor-block-lock-modal {
|
|
535
539
|
z-index: 1000001;
|
|
536
540
|
}
|
|
@@ -1735,7 +1739,7 @@ block-editor-content-only-controls__media-thumbnail {
|
|
|
1735
1739
|
}
|
|
1736
1740
|
|
|
1737
1741
|
.block-editor-content-only-controls__screen.components-navigator-screen {
|
|
1738
|
-
padding: 8px 0
|
|
1742
|
+
padding: 8px 0 16px 0;
|
|
1739
1743
|
}
|
|
1740
1744
|
.block-editor-content-only-controls__screen {
|
|
1741
1745
|
border-top: 1px solid #e0e0e0;
|
|
@@ -1755,6 +1759,15 @@ block-editor-content-only-controls__media-thumbnail {
|
|
|
1755
1759
|
width: 100%;
|
|
1756
1760
|
}
|
|
1757
1761
|
|
|
1762
|
+
.block-editor-content-only-controls__fields-container {
|
|
1763
|
+
padding: 0 16px;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
.block-editor-content-only-controls__fields-header {
|
|
1767
|
+
padding: 8px 0;
|
|
1768
|
+
margin-bottom: 4px;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1758
1771
|
.block-editor-date-format-picker {
|
|
1759
1772
|
margin: 0 0 16px;
|
|
1760
1773
|
padding: 0;
|
|
@@ -1788,10 +1801,6 @@ block-editor-content-only-controls__media-thumbnail {
|
|
|
1788
1801
|
text-transform: capitalize;
|
|
1789
1802
|
}
|
|
1790
1803
|
|
|
1791
|
-
.block-editor-font-family-control:not(.is-next-has-no-margin-bottom) {
|
|
1792
|
-
margin-bottom: 8px;
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
1804
|
.block-editor-global-styles__toggle-icon {
|
|
1796
1805
|
fill: currentColor;
|
|
1797
1806
|
}
|
|
@@ -3775,15 +3784,15 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3775
3784
|
content: attr(aria-label);
|
|
3776
3785
|
font-size: 12px;
|
|
3777
3786
|
}
|
|
3778
|
-
.show-icon-labels .
|
|
3779
|
-
padding-left: 6px;
|
|
3780
|
-
padding-right: 6px;
|
|
3781
|
-
}
|
|
3782
|
-
.show-icon-labels .block-editor-block-icon {
|
|
3787
|
+
.show-icon-labels .block-editor-block-toolbar .block-editor-block-icon {
|
|
3783
3788
|
width: 0 !important;
|
|
3784
3789
|
height: 0 !important;
|
|
3785
3790
|
min-width: 0 !important;
|
|
3786
3791
|
}
|
|
3792
|
+
.show-icon-labels .components-accessible-toolbar .components-toolbar-group > div:first-child:last-child > .components-button.has-icon {
|
|
3793
|
+
padding-left: 6px;
|
|
3794
|
+
padding-right: 6px;
|
|
3795
|
+
}
|
|
3787
3796
|
.show-icon-labels .block-editor-block-parent-selector .block-editor-block-parent-selector__button {
|
|
3788
3797
|
border-top-right-radius: 0;
|
|
3789
3798
|
border-bottom-right-radius: 0;
|
|
@@ -4212,7 +4221,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
4212
4221
|
left: 0;
|
|
4213
4222
|
bottom: 0;
|
|
4214
4223
|
width: 280px;
|
|
4215
|
-
padding: 24px
|
|
4224
|
+
padding: 24px 24px 24px;
|
|
4216
4225
|
overflow-x: visible;
|
|
4217
4226
|
overflow-y: auto;
|
|
4218
4227
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.9.1-next.6deb34194.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -52,44 +52,44 @@
|
|
|
52
52
|
"build-module/hooks/**"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@emotion/react": "^11.7.1",
|
|
56
|
-
"@emotion/styled": "^11.6.0",
|
|
57
55
|
"@react-spring/web": "^9.4.5",
|
|
58
|
-
"@wordpress/a11y": "^4.
|
|
59
|
-
"@wordpress/api-fetch": "^7.
|
|
60
|
-
"@wordpress/base-styles": "^6.
|
|
61
|
-
"@wordpress/blob": "^4.
|
|
62
|
-
"@wordpress/block-serialization-default-parser": "^5.
|
|
63
|
-
"@wordpress/blocks": "^15.
|
|
64
|
-
"@wordpress/commands": "^1.
|
|
65
|
-
"@wordpress/components": "^
|
|
66
|
-
"@wordpress/compose": "^7.
|
|
67
|
-
"@wordpress/data": "^10.
|
|
68
|
-
"@wordpress/
|
|
69
|
-
"@wordpress/
|
|
70
|
-
"@wordpress/
|
|
71
|
-
"@wordpress/
|
|
72
|
-
"@wordpress/
|
|
73
|
-
"@wordpress/
|
|
74
|
-
"@wordpress/
|
|
75
|
-
"@wordpress/
|
|
76
|
-
"@wordpress/
|
|
77
|
-
"@wordpress/
|
|
78
|
-
"@wordpress/
|
|
79
|
-
"@wordpress/
|
|
80
|
-
"@wordpress/
|
|
81
|
-
"@wordpress/
|
|
82
|
-
"@wordpress/
|
|
83
|
-
"@wordpress/
|
|
84
|
-
"@wordpress/
|
|
85
|
-
"@wordpress/
|
|
86
|
-
"@wordpress/
|
|
87
|
-
"@wordpress/
|
|
88
|
-
"@wordpress/
|
|
89
|
-
"@wordpress/
|
|
90
|
-
"@wordpress/
|
|
91
|
-
"@wordpress/
|
|
92
|
-
"@wordpress/
|
|
56
|
+
"@wordpress/a11y": "^4.36.1-next.6deb34194.0",
|
|
57
|
+
"@wordpress/api-fetch": "^7.36.1-next.6deb34194.0",
|
|
58
|
+
"@wordpress/base-styles": "^6.12.1-next.6deb34194.0",
|
|
59
|
+
"@wordpress/blob": "^4.36.1-next.6deb34194.0",
|
|
60
|
+
"@wordpress/block-serialization-default-parser": "^5.36.1-next.6deb34194.0",
|
|
61
|
+
"@wordpress/blocks": "^15.9.1-next.6deb34194.0",
|
|
62
|
+
"@wordpress/commands": "^1.36.1-next.6deb34194.0",
|
|
63
|
+
"@wordpress/components": "^31.0.1-next.6deb34194.0",
|
|
64
|
+
"@wordpress/compose": "^7.36.1-next.6deb34194.0",
|
|
65
|
+
"@wordpress/data": "^10.36.1-next.6deb34194.0",
|
|
66
|
+
"@wordpress/dataviews": "^11.1.1-next.6deb34194.0",
|
|
67
|
+
"@wordpress/date": "^5.36.1-next.6deb34194.0",
|
|
68
|
+
"@wordpress/deprecated": "^4.36.1-next.6deb34194.0",
|
|
69
|
+
"@wordpress/dom": "^4.36.1-next.6deb34194.0",
|
|
70
|
+
"@wordpress/element": "^6.36.1-next.6deb34194.0",
|
|
71
|
+
"@wordpress/escape-html": "^3.36.1-next.6deb34194.0",
|
|
72
|
+
"@wordpress/global-styles-engine": "^1.3.1-next.6deb34194.0",
|
|
73
|
+
"@wordpress/hooks": "^4.36.1-next.6deb34194.0",
|
|
74
|
+
"@wordpress/html-entities": "^4.36.1-next.6deb34194.0",
|
|
75
|
+
"@wordpress/i18n": "^6.9.1-next.6deb34194.0",
|
|
76
|
+
"@wordpress/icons": "^11.3.1-next.6deb34194.0",
|
|
77
|
+
"@wordpress/image-cropper": "^1.0.1-next.6deb34194.0",
|
|
78
|
+
"@wordpress/interactivity": "^6.36.1-next.6deb34194.0",
|
|
79
|
+
"@wordpress/is-shallow-equal": "^5.36.1-next.6deb34194.0",
|
|
80
|
+
"@wordpress/keyboard-shortcuts": "^5.36.1-next.6deb34194.0",
|
|
81
|
+
"@wordpress/keycodes": "^4.36.1-next.6deb34194.0",
|
|
82
|
+
"@wordpress/notices": "^5.36.1-next.6deb34194.0",
|
|
83
|
+
"@wordpress/preferences": "^4.36.1-next.6deb34194.0",
|
|
84
|
+
"@wordpress/priority-queue": "^3.36.1-next.6deb34194.0",
|
|
85
|
+
"@wordpress/private-apis": "^1.36.1-next.6deb34194.0",
|
|
86
|
+
"@wordpress/rich-text": "^7.36.1-next.6deb34194.0",
|
|
87
|
+
"@wordpress/style-engine": "^2.36.1-next.6deb34194.0",
|
|
88
|
+
"@wordpress/token-list": "^3.36.1-next.6deb34194.0",
|
|
89
|
+
"@wordpress/upload-media": "^0.21.1-next.6deb34194.0",
|
|
90
|
+
"@wordpress/url": "^4.36.1-next.6deb34194.0",
|
|
91
|
+
"@wordpress/warning": "^3.36.1-next.6deb34194.0",
|
|
92
|
+
"@wordpress/wordcount": "^4.36.1-next.6deb34194.0",
|
|
93
93
|
"change-case": "^4.1.2",
|
|
94
94
|
"clsx": "^2.1.1",
|
|
95
95
|
"colord": "^2.7.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"publishConfig": {
|
|
113
113
|
"access": "public"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "457096e9e9b3896d2d4fe54fc19d7fb571ee9a44"
|
|
116
116
|
}
|
|
@@ -77,11 +77,7 @@ function BlockAlignmentMatrixControl( props ) {
|
|
|
77
77
|
);
|
|
78
78
|
} }
|
|
79
79
|
renderContent={ () => (
|
|
80
|
-
<AlignmentMatrixControl
|
|
81
|
-
hasFocusBorder={ false }
|
|
82
|
-
onChange={ onChange }
|
|
83
|
-
value={ value }
|
|
84
|
-
/>
|
|
80
|
+
<AlignmentMatrixControl onChange={ onChange } value={ value } />
|
|
85
81
|
) }
|
|
86
82
|
/>
|
|
87
83
|
);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import {
|
|
11
|
+
getBlockBindingsSource,
|
|
12
|
+
store as blocksStore,
|
|
13
|
+
} from '@wordpress/blocks';
|
|
14
|
+
import {
|
|
15
|
+
__experimentalItem as Item,
|
|
16
|
+
__experimentalText as Text,
|
|
17
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
18
|
+
__experimentalVStack as VStack,
|
|
19
|
+
privateApis as componentsPrivateApis,
|
|
20
|
+
} from '@wordpress/components';
|
|
21
|
+
import { useSelect } from '@wordpress/data';
|
|
22
|
+
import { useContext } from '@wordpress/element';
|
|
23
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
|
+
import BlockContext from '../block-context';
|
|
29
|
+
import BlockBindingsSourceFieldsList from './source-fields-list';
|
|
30
|
+
import useBlockBindingsUtils from './use-block-bindings-utils';
|
|
31
|
+
import { unlock } from '../../lock-unlock';
|
|
32
|
+
import { store as blockEditorStore } from '../../store';
|
|
33
|
+
|
|
34
|
+
const { Menu } = unlock( componentsPrivateApis );
|
|
35
|
+
|
|
36
|
+
export default function BlockBindingsAttributeControl( {
|
|
37
|
+
attribute,
|
|
38
|
+
binding,
|
|
39
|
+
blockName,
|
|
40
|
+
} ) {
|
|
41
|
+
const { updateBlockBindings } = useBlockBindingsUtils();
|
|
42
|
+
const isMobile = useViewportMatch( 'medium', '<' );
|
|
43
|
+
|
|
44
|
+
const blockContext = useContext( BlockContext );
|
|
45
|
+
const compatibleFields = useSelect(
|
|
46
|
+
( select ) => {
|
|
47
|
+
const {
|
|
48
|
+
getAllBlockBindingsSources,
|
|
49
|
+
getBlockBindingsSourceFieldsList,
|
|
50
|
+
getBlockType,
|
|
51
|
+
} = unlock( select( blocksStore ) );
|
|
52
|
+
|
|
53
|
+
const _attributeType =
|
|
54
|
+
getBlockType( blockName ).attributes?.[ attribute ]?.type;
|
|
55
|
+
const attributeType =
|
|
56
|
+
_attributeType === 'rich-text' ? 'string' : _attributeType;
|
|
57
|
+
|
|
58
|
+
const sourceFields = {};
|
|
59
|
+
Object.entries( getAllBlockBindingsSources() ).forEach(
|
|
60
|
+
( [ sourceName, source ] ) => {
|
|
61
|
+
const fieldsList = getBlockBindingsSourceFieldsList(
|
|
62
|
+
source,
|
|
63
|
+
blockContext
|
|
64
|
+
);
|
|
65
|
+
if ( ! fieldsList?.length ) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const compatibleFieldsList = fieldsList.filter(
|
|
69
|
+
( field ) => field.type === attributeType
|
|
70
|
+
);
|
|
71
|
+
if ( compatibleFieldsList.length ) {
|
|
72
|
+
sourceFields[ sourceName ] = compatibleFieldsList;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
return sourceFields;
|
|
77
|
+
},
|
|
78
|
+
[ attribute, blockName, blockContext ]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const { canUpdateBlockBindings } = useSelect( ( select ) => ( {
|
|
82
|
+
canUpdateBlockBindings:
|
|
83
|
+
select( blockEditorStore ).getSettings().canUpdateBlockBindings,
|
|
84
|
+
} ) );
|
|
85
|
+
|
|
86
|
+
const hasCompatibleFields = Object.keys( compatibleFields ).length > 0;
|
|
87
|
+
|
|
88
|
+
// Lock the UI when the user can't update bindings or there are no fields to connect to.
|
|
89
|
+
const isAttributeReadOnly =
|
|
90
|
+
! canUpdateBlockBindings || ! hasCompatibleFields;
|
|
91
|
+
|
|
92
|
+
const { source: boundSourceName, args } = binding || {};
|
|
93
|
+
const source = getBlockBindingsSource( boundSourceName );
|
|
94
|
+
|
|
95
|
+
let displayText;
|
|
96
|
+
let isValid = true;
|
|
97
|
+
|
|
98
|
+
if ( binding === undefined ) {
|
|
99
|
+
if ( ! hasCompatibleFields ) {
|
|
100
|
+
displayText = __( 'No sources available' );
|
|
101
|
+
} else {
|
|
102
|
+
displayText = __( 'Not connected' );
|
|
103
|
+
}
|
|
104
|
+
isValid = true;
|
|
105
|
+
} else if ( ! source ) {
|
|
106
|
+
// If there's a binding but the source is not found, it's invalid.
|
|
107
|
+
isValid = false;
|
|
108
|
+
displayText = __( 'Source not registered' );
|
|
109
|
+
} else {
|
|
110
|
+
displayText =
|
|
111
|
+
compatibleFields?.[ boundSourceName ]?.find( ( field ) =>
|
|
112
|
+
fastDeepEqual( field.args, args )
|
|
113
|
+
)?.label ||
|
|
114
|
+
source?.label ||
|
|
115
|
+
boundSourceName;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<ToolsPanelItem
|
|
120
|
+
hasValue={ () => !! binding }
|
|
121
|
+
label={ attribute }
|
|
122
|
+
onDeselect={
|
|
123
|
+
!! hasCompatibleFields &&
|
|
124
|
+
( () => {
|
|
125
|
+
updateBlockBindings( {
|
|
126
|
+
[ attribute ]: undefined,
|
|
127
|
+
} );
|
|
128
|
+
} )
|
|
129
|
+
}
|
|
130
|
+
>
|
|
131
|
+
<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>
|
|
132
|
+
<Menu.TriggerButton
|
|
133
|
+
render={ <Item /> }
|
|
134
|
+
disabled={ ! hasCompatibleFields }
|
|
135
|
+
>
|
|
136
|
+
<VStack
|
|
137
|
+
className="block-editor-bindings__item"
|
|
138
|
+
spacing={ 0 }
|
|
139
|
+
>
|
|
140
|
+
<Text truncate>{ attribute }</Text>
|
|
141
|
+
<Text
|
|
142
|
+
truncate
|
|
143
|
+
variant={ isValid ? 'muted' : undefined }
|
|
144
|
+
isDestructive={ ! isValid }
|
|
145
|
+
>
|
|
146
|
+
{ displayText }
|
|
147
|
+
</Text>
|
|
148
|
+
</VStack>
|
|
149
|
+
</Menu.TriggerButton>
|
|
150
|
+
{ ! isAttributeReadOnly && (
|
|
151
|
+
<Menu.Popover gutter={ isMobile ? 8 : 36 }>
|
|
152
|
+
<Menu
|
|
153
|
+
placement={
|
|
154
|
+
isMobile ? 'bottom-start' : 'left-start'
|
|
155
|
+
}
|
|
156
|
+
>
|
|
157
|
+
{ Object.entries( compatibleFields ).map(
|
|
158
|
+
( [ sourceKey, fields ] ) => (
|
|
159
|
+
<BlockBindingsSourceFieldsList
|
|
160
|
+
key={ sourceKey }
|
|
161
|
+
args={ binding?.args }
|
|
162
|
+
attribute={ attribute }
|
|
163
|
+
sourceKey={ sourceKey }
|
|
164
|
+
fields={ fields }
|
|
165
|
+
/>
|
|
166
|
+
)
|
|
167
|
+
) }
|
|
168
|
+
</Menu>
|
|
169
|
+
</Menu.Popover>
|
|
170
|
+
) }
|
|
171
|
+
</Menu>
|
|
172
|
+
</ToolsPanelItem>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
export { default as BlockBindingsAttributeControl } from './attribute-control';
|
|
5
|
+
export { default as BlockBindingsSourceFieldsList } from './source-fields-list';
|
|
6
|
+
export { default as useBlockBindingsUtils } from './use-block-bindings-utils';
|