@wordpress/block-editor 15.8.1-next.16d95556a.0 → 15.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-inspector/edit-contents.js +19 -23
- package/build/components/block-inspector/edit-contents.js.map +3 -3
- package/build/components/block-inspector/index.js +7 -1
- package/build/components/block-inspector/index.js.map +2 -2
- package/build/components/block-list/block.js +4 -0
- package/build/components/block-list/block.js.map +2 -2
- package/build/components/block-list/index.js +2 -1
- package/build/components/block-list/index.js.map +2 -2
- package/build/components/block-list/use-block-props/index.js +3 -1
- package/build/components/block-list/use-block-props/index.js.map +2 -2
- package/build/components/block-list/use-block-props/use-is-hovered.js +16 -10
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build/components/block-lock/modal.js +5 -5
- package/build/components/block-lock/modal.js.map +2 -2
- package/build/components/block-lock/use-block-lock.js +10 -13
- package/build/components/block-lock/use-block-lock.js.map +2 -2
- package/build/components/block-settings-menu-controls/edit-section-menu-item.js +64 -0
- package/build/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
- package/build/components/block-settings-menu-controls/index.js +9 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.js +9 -9
- package/build/components/block-toolbar/block-toolbar-icon.js.map +2 -2
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-variation-transforms/index.js +32 -5
- package/build/components/block-variation-transforms/index.js.map +2 -2
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- package/build/components/border-radius-control/single-input-control.js +1 -0
- package/build/components/border-radius-control/single-input-control.js.map +2 -2
- package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
- package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build/components/content-only-controls/index.js +444 -0
- package/build/components/content-only-controls/index.js.map +7 -0
- package/build/components/content-only-controls/link/index.js +193 -0
- package/build/components/content-only-controls/link/index.js.map +7 -0
- package/build/components/content-only-controls/media/index.js +264 -0
- package/build/components/content-only-controls/media/index.js.map +7 -0
- package/build/components/content-only-controls/rich-text/index.js +188 -0
- package/build/components/content-only-controls/rich-text/index.js.map +7 -0
- package/build/components/content-only-controls/use-inspector-popover-placement.js +41 -0
- package/build/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
- package/build/components/font-family/index.js +1 -15
- package/build/components/font-family/index.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +35 -2
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +1 -2
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/inserter/media-tab/media-tab.js +1 -33
- package/build/components/inserter/media-tab/media-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/content-tab.js +6 -2
- package/build/components/inspector-controls-tabs/content-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/index.js +7 -1
- package/build/components/inspector-controls-tabs/index.js.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build/components/link-control/index.js +15 -7
- package/build/components/link-control/index.js.map +2 -2
- package/build/components/list-view/block-select-button.js +7 -8
- package/build/components/list-view/block-select-button.js.map +2 -2
- package/build/components/list-view/block.js +9 -7
- package/build/components/list-view/block.js.map +2 -2
- package/build/components/media-placeholder/index.js +18 -35
- package/build/components/media-placeholder/index.js.map +3 -3
- package/build/components/media-placeholder/utils.js +60 -0
- package/build/components/media-placeholder/utils.js.map +7 -0
- package/build/components/media-replace-flow/index.js +24 -33
- package/build/components/media-replace-flow/index.js.map +3 -3
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +2 -2
- package/build/components/use-block-display-information/index.js +21 -1
- package/build/components/use-block-display-information/index.js.map +3 -3
- package/build/components/use-block-drop-zone/index.js +1 -5
- package/build/components/use-block-drop-zone/index.js.map +2 -2
- package/build/hooks/block-bindings.js +52 -61
- package/build/hooks/block-bindings.js.map +3 -3
- package/build/hooks/dimensions.js +3 -3
- package/build/hooks/dimensions.js.map +2 -2
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/use-content-only-section-edit.js +67 -0
- package/build/hooks/use-content-only-section-edit.js.map +7 -0
- package/build/hooks/utils.js +5 -1
- package/build/hooks/utils.js.map +2 -2
- package/build/layouts/constrained.js +2 -2
- package/build/layouts/constrained.js.map +2 -2
- package/build/private-apis.js +2 -3
- package/build/private-apis.js.map +3 -3
- package/build/store/private-keys.js +3 -0
- package/build/store/private-keys.js.map +2 -2
- package/build/store/private-selectors.js +41 -2
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +2 -2
- package/build/utils/fit-text-utils.js +9 -1
- package/build/utils/fit-text-utils.js.map +2 -2
- package/build-module/components/block-inspector/edit-contents.js +9 -23
- package/build-module/components/block-inspector/edit-contents.js.map +2 -2
- package/build-module/components/block-inspector/index.js +7 -1
- package/build-module/components/block-inspector/index.js.map +2 -2
- package/build-module/components/block-list/block.js +4 -0
- package/build-module/components/block-list/block.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -1
- package/build-module/components/block-list/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/index.js +3 -1
- package/build-module/components/block-list/use-block-props/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +16 -10
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build-module/components/block-lock/modal.js +5 -5
- package/build-module/components/block-lock/modal.js.map +2 -2
- package/build-module/components/block-lock/use-block-lock.js +10 -13
- package/build-module/components/block-lock/use-block-lock.js.map +2 -2
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js +29 -0
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
- package/build-module/components/block-settings-menu-controls/index.js +9 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.js +10 -10
- package/build-module/components/block-toolbar/block-toolbar-icon.js.map +2 -2
- package/build-module/components/block-tools/index.js +56 -45
- package/build-module/components/block-tools/index.js.map +2 -2
- package/build-module/components/block-variation-transforms/index.js +32 -5
- package/build-module/components/block-variation-transforms/index.js.map +2 -2
- package/build-module/components/block-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- package/build-module/components/border-radius-control/single-input-control.js +1 -0
- package/build-module/components/border-radius-control/single-input-control.js.map +2 -2
- package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
- package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build-module/components/content-only-controls/index.js +420 -0
- package/build-module/components/content-only-controls/index.js.map +7 -0
- package/build-module/components/content-only-controls/link/index.js +160 -0
- package/build-module/components/content-only-controls/link/index.js.map +7 -0
- package/build-module/components/content-only-controls/media/index.js +242 -0
- package/build-module/components/content-only-controls/media/index.js.map +7 -0
- package/build-module/components/content-only-controls/rich-text/index.js +160 -0
- package/build-module/components/content-only-controls/rich-text/index.js.map +7 -0
- package/build-module/components/content-only-controls/use-inspector-popover-placement.js +16 -0
- package/build-module/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
- package/build-module/components/font-family/index.js +1 -15
- package/build-module/components/font-family/index.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +35 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.js +2 -34
- package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js +7 -3
- package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.js +7 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build-module/components/link-control/index.js +16 -8
- package/build-module/components/link-control/index.js.map +2 -2
- package/build-module/components/list-view/block-select-button.js +14 -9
- package/build-module/components/list-view/block-select-button.js.map +2 -2
- package/build-module/components/list-view/block.js +9 -7
- package/build-module/components/list-view/block.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +19 -36
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-placeholder/utils.js +35 -0
- package/build-module/components/media-placeholder/utils.js.map +7 -0
- package/build-module/components/media-replace-flow/index.js +24 -33
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +2 -2
- package/build-module/components/use-block-display-information/index.js +21 -1
- package/build-module/components/use-block-display-information/index.js.map +3 -3
- package/build-module/components/use-block-drop-zone/index.js +1 -5
- package/build-module/components/use-block-drop-zone/index.js.map +2 -2
- package/build-module/hooks/block-bindings.js +57 -62
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/dimensions.js +3 -3
- package/build-module/hooks/dimensions.js.map +2 -2
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/use-content-only-section-edit.js +46 -0
- package/build-module/hooks/use-content-only-section-edit.js.map +7 -0
- package/build-module/hooks/utils.js +5 -1
- package/build-module/hooks/utils.js.map +2 -2
- package/build-module/layouts/constrained.js +2 -2
- package/build-module/layouts/constrained.js.map +2 -2
- package/build-module/private-apis.js +3 -3
- package/build-module/private-apis.js.map +2 -2
- package/build-module/store/private-keys.js +2 -0
- package/build-module/store/private-keys.js.map +2 -2
- package/build-module/store/private-selectors.js +37 -2
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/selectors.js +6 -4
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/utils/fit-text-utils.js +9 -1
- package/build-module/utils/fit-text-utils.js.map +2 -2
- package/build-style/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +145 -4
- package/build-style/style.css +145 -4
- package/package.json +38 -37
- package/src/components/block-inspector/edit-contents.js +10 -29
- package/src/components/block-inspector/index.js +4 -2
- package/src/components/block-list/block.js +6 -0
- package/src/components/block-list/content.scss +5 -0
- package/src/components/block-list/index.js +3 -1
- package/src/components/block-list/use-block-props/index.js +3 -1
- package/src/components/block-list/use-block-props/use-is-hovered.js +24 -12
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
- package/src/components/block-lock/modal.js +6 -5
- package/src/components/block-lock/use-block-lock.js +10 -14
- package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
- package/src/components/block-settings-menu-controls/edit-section-menu-item.js +39 -0
- package/src/components/block-settings-menu-controls/index.js +8 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +14 -10
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-variation-transforms/index.js +96 -35
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/border-radius-control/single-input-control.js +1 -0
- package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
- package/src/components/content-only-controls/index.js +560 -0
- package/src/components/content-only-controls/link/index.js +200 -0
- package/src/components/content-only-controls/link/styles.scss +23 -0
- package/src/components/content-only-controls/media/index.js +306 -0
- package/src/components/content-only-controls/media/styles.scss +47 -0
- package/src/components/content-only-controls/rich-text/index.js +179 -0
- package/src/components/content-only-controls/rich-text/styles.scss +24 -0
- package/src/components/content-only-controls/styles.scss +44 -0
- package/src/components/content-only-controls/use-inspector-popover-placement.js +19 -0
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +1 -16
- package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
- package/src/components/global-styles/dimensions-panel.js +36 -0
- package/src/components/global-styles/hooks.js +1 -1
- package/src/components/global-styles/typography-panel.js +0 -1
- package/src/components/inserter/media-tab/media-tab.js +2 -44
- package/src/components/inspector-controls-tabs/content-tab.js +12 -4
- package/src/components/inspector-controls-tabs/index.js +4 -1
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
- package/src/components/link-control/index.js +36 -12
- package/src/components/list-view/block-select-button.js +15 -10
- package/src/components/list-view/block.js +9 -7
- package/src/components/media-placeholder/index.js +21 -46
- package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
- package/src/components/media-placeholder/utils.js +65 -0
- package/src/components/media-replace-flow/index.js +25 -42
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-display-information/index.js +30 -2
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/block-bindings.js +71 -82
- package/src/hooks/dimensions.js +8 -3
- package/src/hooks/metadata.js +1 -1
- package/src/hooks/test/metadata.js +1 -1
- package/src/hooks/use-content-only-section-edit.js +63 -0
- package/src/hooks/utils.js +4 -0
- package/src/layouts/constrained.js +8 -2
- package/src/private-apis.js +2 -2
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +121 -5
- package/src/store/selectors.js +6 -4
- package/src/store/test/private-selectors.js +242 -0
- package/src/style.scss +1 -1
- package/src/utils/fit-text-utils.js +19 -1
- package/tsconfig.json +1 -0
- package/build/components/media-upload-modal/index.js +0 -29
- package/build/components/media-upload-modal/index.js.map +0 -7
- package/build-module/components/media-upload-modal/index.js +0 -8
- package/build-module/components/media-upload-modal/index.js.map +0 -7
- package/src/components/font-family/style.scss +0 -7
- package/src/components/media-upload-modal/index.js +0 -18
- /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
- /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
- /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
|
@@ -7,7 +7,11 @@ import fastDeepEqual from 'fast-deep-equal/es6';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
getBlockBindingsSource,
|
|
12
|
+
getBlockType,
|
|
13
|
+
store as blockStore,
|
|
14
|
+
} from '@wordpress/blocks';
|
|
11
15
|
import {
|
|
12
16
|
__experimentalItemGroup as ItemGroup,
|
|
13
17
|
__experimentalItem as Item,
|
|
@@ -33,8 +37,6 @@ import { store as blockEditorStore } from '../store';
|
|
|
33
37
|
|
|
34
38
|
const { Menu } = unlock( componentsPrivateApis );
|
|
35
39
|
|
|
36
|
-
const EMPTY_OBJECT = {};
|
|
37
|
-
|
|
38
40
|
/**
|
|
39
41
|
* Get the normalized attribute type for block bindings.
|
|
40
42
|
* Converts 'rich-text' to 'string' since rich-text is stored as string.
|
|
@@ -80,10 +82,10 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
80
82
|
);
|
|
81
83
|
return (
|
|
82
84
|
<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>
|
|
83
|
-
{ Object.entries( sources ).map( ( [ sourceKey,
|
|
85
|
+
{ Object.entries( sources ).map( ( [ sourceKey, data ] ) => {
|
|
84
86
|
// Only show sources that have compatible data for this specific attribute.
|
|
85
|
-
const sourceDataItems =
|
|
86
|
-
( item ) => item
|
|
87
|
+
const sourceDataItems = data.filter(
|
|
88
|
+
( item ) => item.type === attributeType
|
|
87
89
|
);
|
|
88
90
|
|
|
89
91
|
const noItemsAvailable =
|
|
@@ -93,6 +95,8 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
93
95
|
return null;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
const source = getBlockBindingsSource( sourceKey );
|
|
99
|
+
|
|
96
100
|
return (
|
|
97
101
|
<Menu
|
|
98
102
|
key={ sourceKey }
|
|
@@ -106,17 +110,21 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
106
110
|
{ sourceDataItems.map( ( item ) => {
|
|
107
111
|
const itemBindings = {
|
|
108
112
|
source: sourceKey,
|
|
109
|
-
args: item
|
|
113
|
+
args: item.args || {
|
|
110
114
|
key: item.key,
|
|
111
115
|
},
|
|
112
116
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
let values = {};
|
|
118
|
+
try {
|
|
119
|
+
values = source.getValues( {
|
|
120
|
+
select,
|
|
121
|
+
context: blockContext,
|
|
122
|
+
bindings: {
|
|
123
|
+
[ attribute ]: itemBindings,
|
|
124
|
+
},
|
|
125
|
+
} );
|
|
126
|
+
} catch ( e ) {}
|
|
127
|
+
|
|
120
128
|
return (
|
|
121
129
|
<Menu.CheckboxItem
|
|
122
130
|
key={
|
|
@@ -160,7 +168,7 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
160
168
|
}
|
|
161
169
|
>
|
|
162
170
|
<Menu.ItemLabel>
|
|
163
|
-
{ item
|
|
171
|
+
{ item.label }
|
|
164
172
|
</Menu.ItemLabel>
|
|
165
173
|
<Menu.ItemHelpText>
|
|
166
174
|
{ values[ attribute ] }
|
|
@@ -179,7 +187,8 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
|
|
|
179
187
|
|
|
180
188
|
function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
|
|
181
189
|
const { source: sourceName, args } = binding || {};
|
|
182
|
-
const
|
|
190
|
+
const data = sources?.[ sourceName ];
|
|
191
|
+
const source = getBlockBindingsSource( sourceName );
|
|
183
192
|
|
|
184
193
|
let displayText;
|
|
185
194
|
let isValid = true;
|
|
@@ -189,8 +198,8 @@ function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
|
|
|
189
198
|
// Check if there are any compatible sources for this attribute type.
|
|
190
199
|
const attributeType = getAttributeType( blockName, attribute );
|
|
191
200
|
|
|
192
|
-
const hasCompatibleSources = Object.values( sources ).some( (
|
|
193
|
-
|
|
201
|
+
const hasCompatibleSources = Object.values( sources ).some( ( items ) =>
|
|
202
|
+
items.some( ( item ) => item.type === attributeType )
|
|
194
203
|
);
|
|
195
204
|
|
|
196
205
|
if ( ! hasCompatibleSources ) {
|
|
@@ -203,14 +212,10 @@ function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
|
|
|
203
212
|
// If there's a binding but the source is not found, it's invalid.
|
|
204
213
|
isValid = false;
|
|
205
214
|
displayText = __( 'Source not registered' );
|
|
206
|
-
if ( Object.keys( sources ).length === 0 ) {
|
|
207
|
-
displayText = __( 'No sources available' );
|
|
208
|
-
}
|
|
209
215
|
} else {
|
|
210
216
|
displayText =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
source.label ||
|
|
217
|
+
data?.find( ( item ) => fastDeepEqual( item.args, args ) )?.label ||
|
|
218
|
+
source?.label ||
|
|
214
219
|
sourceName;
|
|
215
220
|
}
|
|
216
221
|
|
|
@@ -299,68 +304,57 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
|
299
304
|
|
|
300
305
|
// Use useSelect to ensure sources are updated whenever there are updates in block context
|
|
301
306
|
// or when underlying data changes.
|
|
302
|
-
|
|
303
|
-
const _sources = {};
|
|
304
|
-
const { sources, canUpdateBlockBindings, bindableAttributes } = useSelect(
|
|
307
|
+
const { canUpdateBlockBindings, bindableAttributes } = useSelect(
|
|
305
308
|
( select ) => {
|
|
306
309
|
const { __experimentalBlockBindingsSupportedAttributes } =
|
|
307
310
|
select( blockEditorStore ).getSettings();
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
canUpdateBlockBindings:
|
|
314
|
+
select( blockEditorStore ).getSettings()
|
|
315
|
+
.canUpdateBlockBindings,
|
|
316
|
+
bindableAttributes:
|
|
317
|
+
__experimentalBlockBindingsSupportedAttributes?.[
|
|
318
|
+
blockName
|
|
319
|
+
],
|
|
320
|
+
};
|
|
321
|
+
},
|
|
322
|
+
[ blockName ]
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
const sources = useSelect(
|
|
326
|
+
( select ) => {
|
|
327
|
+
const { getAllBlockBindingsSources } = unlock(
|
|
328
|
+
select( blockStore )
|
|
329
|
+
);
|
|
330
|
+
const data = {};
|
|
331
|
+
Object.entries( getAllBlockBindingsSources() ).forEach(
|
|
332
|
+
( [ sourceName, source ] ) => {
|
|
333
|
+
if ( ! source.getFieldsList ) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
321
337
|
const context = {};
|
|
322
|
-
if ( usesContext?.length ) {
|
|
323
|
-
for ( const key of usesContext ) {
|
|
338
|
+
if ( source.usesContext?.length ) {
|
|
339
|
+
for ( const key of source.usesContext ) {
|
|
324
340
|
context[ key ] = blockContext[ key ];
|
|
325
341
|
}
|
|
326
342
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
label,
|
|
335
|
-
getValues,
|
|
336
|
-
};
|
|
337
|
-
} else {
|
|
338
|
-
/*
|
|
339
|
-
* Include sources without getFieldsList if they are already used in a binding.
|
|
340
|
-
* This allows them to be displayed in read-only mode.
|
|
341
|
-
*/
|
|
342
|
-
_sources[ sourceName ] = {
|
|
343
|
-
data: [],
|
|
344
|
-
label,
|
|
345
|
-
getValues,
|
|
346
|
-
};
|
|
343
|
+
|
|
344
|
+
const items = source.getFieldsList( {
|
|
345
|
+
select,
|
|
346
|
+
context,
|
|
347
|
+
} );
|
|
348
|
+
if ( items?.length ) {
|
|
349
|
+
data[ sourceName ] = items;
|
|
347
350
|
}
|
|
348
351
|
}
|
|
349
352
|
);
|
|
350
|
-
|
|
351
|
-
return {
|
|
352
|
-
sources:
|
|
353
|
-
Object.values( _sources ).length > 0
|
|
354
|
-
? _sources
|
|
355
|
-
: EMPTY_OBJECT,
|
|
356
|
-
canUpdateBlockBindings:
|
|
357
|
-
select( blockEditorStore ).getSettings()
|
|
358
|
-
.canUpdateBlockBindings,
|
|
359
|
-
bindableAttributes: _bindableAttributes,
|
|
360
|
-
};
|
|
353
|
+
return data;
|
|
361
354
|
},
|
|
362
|
-
[ blockContext
|
|
355
|
+
[ blockContext ]
|
|
363
356
|
);
|
|
357
|
+
|
|
364
358
|
// Return early if there are no bindable attributes.
|
|
365
359
|
if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
|
|
366
360
|
return null;
|
|
@@ -368,10 +362,7 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
|
368
362
|
|
|
369
363
|
const { bindings } = metadata || {};
|
|
370
364
|
|
|
371
|
-
|
|
372
|
-
const hasCompatibleData = Object.values( sources ).some(
|
|
373
|
-
( source ) => source.data && source.data.length > 0
|
|
374
|
-
);
|
|
365
|
+
const hasCompatibleData = Object.keys( sources ).length > 0;
|
|
375
366
|
|
|
376
367
|
// Lock the UI when the user can't update bindings or there are no fields to connect to.
|
|
377
368
|
const readOnly = ! canUpdateBlockBindings || ! hasCompatibleData;
|
|
@@ -402,10 +393,8 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
|
402
393
|
|
|
403
394
|
const hasCompatibleDataForAttribute = Object.values(
|
|
404
395
|
sources
|
|
405
|
-
).some( (
|
|
406
|
-
|
|
407
|
-
( item ) => item?.type === attributeType
|
|
408
|
-
)
|
|
396
|
+
).some( ( data ) =>
|
|
397
|
+
data.some( ( item ) => item.type === attributeType )
|
|
409
398
|
);
|
|
410
399
|
|
|
411
400
|
const isAttributeReadOnly =
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -81,6 +81,7 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
81
81
|
},
|
|
82
82
|
[ clientId, isEnabled ]
|
|
83
83
|
);
|
|
84
|
+
|
|
84
85
|
const [ visualizedProperty, setVisualizedProperty ] = useVisualizer();
|
|
85
86
|
const onChange = ( newStyle ) => {
|
|
86
87
|
setAttributes( {
|
|
@@ -156,7 +157,11 @@ export function hasDimensionsSupport( blockName, feature = 'any' ) {
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
if ( feature === 'any' ) {
|
|
159
|
-
return !! (
|
|
160
|
+
return !! (
|
|
161
|
+
support?.aspectRatio ||
|
|
162
|
+
!! support?.minHeight ||
|
|
163
|
+
!! support?.width
|
|
164
|
+
);
|
|
160
165
|
}
|
|
161
166
|
|
|
162
167
|
return !! support?.[ feature ];
|
|
@@ -164,9 +169,9 @@ export function hasDimensionsSupport( blockName, feature = 'any' ) {
|
|
|
164
169
|
|
|
165
170
|
export default {
|
|
166
171
|
useBlockProps,
|
|
167
|
-
attributeKeys: [ 'minHeight', 'style' ],
|
|
172
|
+
attributeKeys: [ 'minHeight', 'width', 'style' ],
|
|
168
173
|
hasSupport( name ) {
|
|
169
|
-
return hasDimensionsSupport( name
|
|
174
|
+
return hasDimensionsSupport( name );
|
|
170
175
|
},
|
|
171
176
|
};
|
|
172
177
|
|
package/src/hooks/metadata.js
CHANGED
|
@@ -91,7 +91,7 @@ export function addTransforms( result, source, index, results ) {
|
|
|
91
91
|
if (
|
|
92
92
|
sourceMetadata.blockVisibility !== undefined &&
|
|
93
93
|
! result.attributes?.metadata?.blockVisibility &&
|
|
94
|
-
hasBlockSupport( result.name, '
|
|
94
|
+
hasBlockSupport( result.name, 'visibility', true )
|
|
95
95
|
) {
|
|
96
96
|
preservedMetadata.blockVisibility = sourceMetadata.blockVisibility;
|
|
97
97
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as blockEditorStore } from '../store';
|
|
10
|
+
import { unlock } from '../lock-unlock';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Hook that provides section block editing state and actions.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} clientId Block client ID.
|
|
16
|
+
* @return {Object} Object containing section block state and actions.
|
|
17
|
+
*/
|
|
18
|
+
export default function useContentOnlySectionEdit( clientId ) {
|
|
19
|
+
const {
|
|
20
|
+
isSectionBlock,
|
|
21
|
+
isWithinSection,
|
|
22
|
+
isWithinEditedSection,
|
|
23
|
+
isEditingContentOnlySection,
|
|
24
|
+
editedContentOnlySection,
|
|
25
|
+
} = useSelect(
|
|
26
|
+
( select ) => {
|
|
27
|
+
const {
|
|
28
|
+
isSectionBlock: _isSectionBlock,
|
|
29
|
+
getParentSectionBlock,
|
|
30
|
+
getEditedContentOnlySection,
|
|
31
|
+
isWithinEditedContentOnlySection,
|
|
32
|
+
} = unlock( select( blockEditorStore ) );
|
|
33
|
+
|
|
34
|
+
const editedSection = getEditedContentOnlySection();
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
isSectionBlock: _isSectionBlock( clientId ),
|
|
38
|
+
isWithinSection:
|
|
39
|
+
_isSectionBlock( clientId ) ||
|
|
40
|
+
!! getParentSectionBlock( clientId ),
|
|
41
|
+
isWithinEditedSection:
|
|
42
|
+
isWithinEditedContentOnlySection( clientId ),
|
|
43
|
+
isEditingContentOnlySection: editedSection === clientId,
|
|
44
|
+
editedContentOnlySection: editedSection,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
[ clientId ]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const blockEditorActions = useDispatch( blockEditorStore );
|
|
51
|
+
const { editContentOnlySection, stopEditingContentOnlySection } =
|
|
52
|
+
unlock( blockEditorActions );
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
isSectionBlock,
|
|
56
|
+
isWithinSection,
|
|
57
|
+
isWithinEditedSection,
|
|
58
|
+
isEditingContentOnlySection,
|
|
59
|
+
editedContentOnlySection,
|
|
60
|
+
editContentOnlySection,
|
|
61
|
+
stopEditingContentOnlySection,
|
|
62
|
+
};
|
|
63
|
+
}
|
package/src/hooks/utils.js
CHANGED
|
@@ -263,6 +263,7 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
263
263
|
units,
|
|
264
264
|
aspectRatio,
|
|
265
265
|
minHeight,
|
|
266
|
+
width,
|
|
266
267
|
layout,
|
|
267
268
|
borderColor,
|
|
268
269
|
borderRadius,
|
|
@@ -321,6 +322,7 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
321
322
|
'spacing.units',
|
|
322
323
|
'dimensions.aspectRatio',
|
|
323
324
|
'dimensions.minHeight',
|
|
325
|
+
'dimensions.width',
|
|
324
326
|
'layout',
|
|
325
327
|
'border.color',
|
|
326
328
|
'border.radius',
|
|
@@ -430,6 +432,7 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
430
432
|
dimensions: {
|
|
431
433
|
aspectRatio,
|
|
432
434
|
minHeight,
|
|
435
|
+
width,
|
|
433
436
|
},
|
|
434
437
|
layout,
|
|
435
438
|
parentLayout,
|
|
@@ -466,6 +469,7 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
466
469
|
units,
|
|
467
470
|
aspectRatio,
|
|
468
471
|
minHeight,
|
|
472
|
+
width,
|
|
469
473
|
layout,
|
|
470
474
|
parentLayout,
|
|
471
475
|
borderColor,
|
|
@@ -89,7 +89,10 @@ export default {
|
|
|
89
89
|
: nextWidth;
|
|
90
90
|
onChange( {
|
|
91
91
|
...layout,
|
|
92
|
-
contentSize:
|
|
92
|
+
contentSize:
|
|
93
|
+
nextWidth !== ''
|
|
94
|
+
? nextWidth
|
|
95
|
+
: undefined,
|
|
93
96
|
} );
|
|
94
97
|
} }
|
|
95
98
|
units={ units }
|
|
@@ -111,7 +114,10 @@ export default {
|
|
|
111
114
|
: nextWidth;
|
|
112
115
|
onChange( {
|
|
113
116
|
...layout,
|
|
114
|
-
wideSize:
|
|
117
|
+
wideSize:
|
|
118
|
+
nextWidth !== ''
|
|
119
|
+
? nextWidth
|
|
120
|
+
: undefined,
|
|
115
121
|
} );
|
|
116
122
|
} }
|
|
117
123
|
units={ units }
|
package/src/private-apis.js
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
globalStylesLinksDataKey,
|
|
41
41
|
sectionRootClientIdKey,
|
|
42
42
|
mediaEditKey,
|
|
43
|
+
getMediaSelectKey,
|
|
43
44
|
essentialFormatKey,
|
|
44
45
|
} from './store/private-keys';
|
|
45
46
|
import { requiresWrapperOnCopy } from './components/writing-flow/utils';
|
|
@@ -57,7 +58,6 @@ import {
|
|
|
57
58
|
useBlockElementRef,
|
|
58
59
|
useBlockElement,
|
|
59
60
|
} from './components/block-list/use-block-props/use-block-refs';
|
|
60
|
-
import { default as MediaUploadModal } from './components/media-upload-modal';
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Private @wordpress/block-editor APIs.
|
|
@@ -108,8 +108,8 @@ lock( privateApis, {
|
|
|
108
108
|
CommentIconSlotFill,
|
|
109
109
|
CommentIconToolbarSlotFill,
|
|
110
110
|
mediaEditKey,
|
|
111
|
+
getMediaSelectKey,
|
|
111
112
|
essentialFormatKey,
|
|
112
113
|
useBlockElement,
|
|
113
114
|
useBlockElementRef,
|
|
114
|
-
MediaUploadModal,
|
|
115
115
|
} );
|
|
@@ -4,4 +4,5 @@ export const selectBlockPatternsKey = Symbol( 'selectBlockPatternsKey' );
|
|
|
4
4
|
export const reusableBlocksSelectKey = Symbol( 'reusableBlocksSelect' );
|
|
5
5
|
export const sectionRootClientIdKey = Symbol( 'sectionRootClientIdKey' );
|
|
6
6
|
export const mediaEditKey = Symbol( 'mediaEditKey' );
|
|
7
|
+
export const getMediaSelectKey = Symbol( 'getMediaSelect' );
|
|
7
8
|
export const essentialFormatKey = Symbol( 'essentialFormat' );
|
|
@@ -518,10 +518,7 @@ export function isSectionBlock( state, clientId ) {
|
|
|
518
518
|
}
|
|
519
519
|
|
|
520
520
|
const blockName = getBlockName( state, clientId );
|
|
521
|
-
if (
|
|
522
|
-
blockName === 'core/block' ||
|
|
523
|
-
getTemplateLock( state, clientId ) === 'contentOnly'
|
|
524
|
-
) {
|
|
521
|
+
if ( blockName === 'core/block' ) {
|
|
525
522
|
return true;
|
|
526
523
|
}
|
|
527
524
|
|
|
@@ -533,6 +530,19 @@ export function isSectionBlock( state, clientId ) {
|
|
|
533
530
|
) {
|
|
534
531
|
return true;
|
|
535
532
|
}
|
|
533
|
+
|
|
534
|
+
// TemplateLock cascades to all inner parent blocks. Only the top-level
|
|
535
|
+
// block that's contentOnly templateLocked is the true contentLocker,
|
|
536
|
+
// all the others are mere imitators.
|
|
537
|
+
const hasContentOnlyTempateLock =
|
|
538
|
+
getTemplateLock( state, clientId ) === 'contentOnly';
|
|
539
|
+
const rootClientId = getBlockRootClientId( state, clientId );
|
|
540
|
+
const hasRootContentOnlyTemplateLock =
|
|
541
|
+
getTemplateLock( state, rootClientId ) === 'contentOnly';
|
|
542
|
+
if ( hasContentOnlyTempateLock && ! hasRootContentOnlyTemplateLock ) {
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
|
|
536
546
|
return false;
|
|
537
547
|
}
|
|
538
548
|
|
|
@@ -700,7 +710,7 @@ export function getInsertionPoint( state ) {
|
|
|
700
710
|
*/
|
|
701
711
|
export const isBlockHidden = ( state, clientId ) => {
|
|
702
712
|
const blockName = getBlockName( state, clientId );
|
|
703
|
-
if ( ! hasBlockSupport( state, blockName, '
|
|
713
|
+
if ( ! hasBlockSupport( state, blockName, 'visibility', true ) ) {
|
|
704
714
|
return false;
|
|
705
715
|
}
|
|
706
716
|
const attributes = state.blocks.attributes.get( clientId );
|
|
@@ -720,3 +730,109 @@ export const isBlockHidden = ( state, clientId ) => {
|
|
|
720
730
|
export function hasBlockSpotlight( state ) {
|
|
721
731
|
return !! state.hasBlockSpotlight || !! state.editedContentOnlySection;
|
|
722
732
|
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Returns whether a block is locked to prevent editing.
|
|
736
|
+
*
|
|
737
|
+
* This selector only reasons about block lock, not associated features
|
|
738
|
+
* like `blockEditingMode` that might prevent user modifications to a block.
|
|
739
|
+
* Currently there's also no way to prevent editing via `templateLock`.
|
|
740
|
+
*
|
|
741
|
+
* This distinction is important as this selector specifically drives the block lock UI
|
|
742
|
+
* that a user interacts with. `blockEditingModes` aren't included as a user can't change
|
|
743
|
+
* them.
|
|
744
|
+
*
|
|
745
|
+
* @param {Object} state Global application state.
|
|
746
|
+
* @param {string} clientId ClientId of the block.
|
|
747
|
+
*
|
|
748
|
+
* @return {boolean} Whether the block is currently locked.
|
|
749
|
+
*/
|
|
750
|
+
export function isEditLockedBlock( state, clientId ) {
|
|
751
|
+
const attributes = getBlockAttributes( state, clientId );
|
|
752
|
+
return !! attributes?.lock?.edit;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Returns whether a block is locked to prevent moving.
|
|
757
|
+
*
|
|
758
|
+
* This selector only reasons about templateLock and block lock, not associated features
|
|
759
|
+
* like `blockEditingMode` that might prevent user modifications to a block.
|
|
760
|
+
*
|
|
761
|
+
* This distinction is important as this selector specifically drives the block lock UI
|
|
762
|
+
* that a user interacts with. `blockEditingModes` are excluded as a user can't change
|
|
763
|
+
* them.
|
|
764
|
+
*
|
|
765
|
+
* @param {Object} state Global application state.
|
|
766
|
+
* @param {string} clientId ClientId of the block.
|
|
767
|
+
*
|
|
768
|
+
* @return {boolean} Whether the block is currently locked.
|
|
769
|
+
*/
|
|
770
|
+
export function isMoveLockedBlock( state, clientId ) {
|
|
771
|
+
const attributes = getBlockAttributes( state, clientId );
|
|
772
|
+
// If a block explicitly has `move` set to `false`, it turns off
|
|
773
|
+
// any locking that might be inherited from a parent.
|
|
774
|
+
if ( attributes?.lock?.move !== undefined ) {
|
|
775
|
+
return !! attributes?.lock?.move;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
const rootClientId = getBlockRootClientId( state, clientId );
|
|
779
|
+
const templateLock = getTemplateLock( state, rootClientId );
|
|
780
|
+
|
|
781
|
+
// While `contentOnly` templateLock does sometimes prevent moving, a user can't modify
|
|
782
|
+
// this, so don't include it in this function. See the `canMoveBlock` selector
|
|
783
|
+
// as an alternative.
|
|
784
|
+
return templateLock === 'all';
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Returns whether a block is locked to prevent removal.
|
|
789
|
+
*
|
|
790
|
+
* This selector only reasons about templateLock and block lock, not associated features
|
|
791
|
+
* like `blockEditingMode` that might prevent user modifications to a block.
|
|
792
|
+
*
|
|
793
|
+
* This distinction is important as this selector specifically drives the block lock UI
|
|
794
|
+
* that a user interacts with. `blockEditingModes` are excluded as a user can't change
|
|
795
|
+
* them.
|
|
796
|
+
*
|
|
797
|
+
* @param {Object} state Global application state.
|
|
798
|
+
* @param {string} clientId ClientId of the block.
|
|
799
|
+
*
|
|
800
|
+
* @return {boolean} Whether the block is currently locked.
|
|
801
|
+
*/
|
|
802
|
+
export function isRemoveLockedBlock( state, clientId ) {
|
|
803
|
+
const attributes = getBlockAttributes( state, clientId );
|
|
804
|
+
if ( attributes?.lock?.remove !== undefined ) {
|
|
805
|
+
return !! attributes?.lock?.remove;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
const rootClientId = getBlockRootClientId( state, clientId );
|
|
809
|
+
const templateLock = getTemplateLock( state, rootClientId );
|
|
810
|
+
|
|
811
|
+
// While `contentOnly` templateLock does sometimes prevent removal, a user can't modify
|
|
812
|
+
// this, so don't include it in this function. See the `canRemoveBlock` selector
|
|
813
|
+
// as an alternative.
|
|
814
|
+
return templateLock === 'all' || templateLock === 'insert';
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Returns whether a block is locked.
|
|
819
|
+
*
|
|
820
|
+
* This selector only reasons about templateLock and block lock, not associated features
|
|
821
|
+
* like `blockEditingMode` that might prevent user modifications to a block.
|
|
822
|
+
*
|
|
823
|
+
* This distinction is important as this selector specifically drives the block lock UI
|
|
824
|
+
* that a user interacts with. `blockEditingModes` are excluded as a user can't change
|
|
825
|
+
* them.
|
|
826
|
+
*
|
|
827
|
+
* @param {Object} state Global application state.
|
|
828
|
+
* @param {string} clientId ClientId of the block.
|
|
829
|
+
*
|
|
830
|
+
* @return {boolean} Whether the block is currently locked.
|
|
831
|
+
*/
|
|
832
|
+
export function isLockedBlock( state, clientId ) {
|
|
833
|
+
return (
|
|
834
|
+
isEditLockedBlock( state, clientId ) ||
|
|
835
|
+
isMoveLockedBlock( state, clientId ) ||
|
|
836
|
+
isRemoveLockedBlock( state, clientId )
|
|
837
|
+
);
|
|
838
|
+
}
|
package/src/store/selectors.js
CHANGED
|
@@ -1693,7 +1693,8 @@ const canInsertBlockTypeUnmemoized = (
|
|
|
1693
1693
|
blockType = getBlockType( blockName );
|
|
1694
1694
|
}
|
|
1695
1695
|
|
|
1696
|
-
|
|
1696
|
+
const rootTemplateLock = getTemplateLock( state, rootClientId );
|
|
1697
|
+
if ( rootTemplateLock && rootTemplateLock !== 'contentOnly' ) {
|
|
1697
1698
|
return false;
|
|
1698
1699
|
}
|
|
1699
1700
|
|
|
@@ -1876,7 +1877,8 @@ export function canRemoveBlock( state, clientId ) {
|
|
|
1876
1877
|
}
|
|
1877
1878
|
|
|
1878
1879
|
const rootClientId = getBlockRootClientId( state, clientId );
|
|
1879
|
-
|
|
1880
|
+
const rootTemplateLock = getTemplateLock( state, rootClientId );
|
|
1881
|
+
if ( rootTemplateLock && rootTemplateLock !== 'contentOnly' ) {
|
|
1880
1882
|
return false;
|
|
1881
1883
|
}
|
|
1882
1884
|
|
|
@@ -1937,8 +1939,8 @@ export function canMoveBlock( state, clientId ) {
|
|
|
1937
1939
|
}
|
|
1938
1940
|
|
|
1939
1941
|
const rootClientId = getBlockRootClientId( state, clientId );
|
|
1940
|
-
const
|
|
1941
|
-
if (
|
|
1942
|
+
const rootTemplateLock = getTemplateLock( state, rootClientId );
|
|
1943
|
+
if ( rootTemplateLock === 'all' ) {
|
|
1942
1944
|
return false;
|
|
1943
1945
|
}
|
|
1944
1946
|
|