@wordpress/block-editor 15.10.1-next.v.0 → 15.11.1-next.v.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-controls/index.cjs +1 -1
- package/build/components/block-controls/index.cjs.map +2 -2
- package/build/components/block-edit/context.cjs +5 -0
- package/build/components/block-edit/context.cjs.map +2 -2
- package/build/components/block-edit/index.cjs +3 -0
- package/build/components/block-edit/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +7 -27
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-list/block.cjs +3 -0
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +37 -13
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/index.cjs +1 -1
- package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +1 -1
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-tools/index.cjs +2 -26
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-visibility/index.cjs +7 -9
- package/build/components/block-visibility/index.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs +13 -11
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +1 -1
- package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
- package/build/components/block-visibility/utils.cjs +5 -1
- package/build/components/block-visibility/utils.cjs.map +2 -2
- package/build/components/block-visibility/viewport-menu-item.cjs +11 -4
- package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
- package/build/components/block-visibility/viewport-toolbar.cjs +4 -6
- package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs +121 -0
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +7 -0
- package/build/components/button-block-appender/index.cjs +23 -19
- package/build/components/button-block-appender/index.cjs.map +2 -2
- package/build/components/color-palette/with-color-context.cjs +1 -1
- package/build/components/color-palette/with-color-context.cjs.map +2 -2
- package/build/components/color-style-selector/index.cjs +1 -1
- package/build/components/color-style-selector/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +5 -3
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +1 -1
- package/build/components/colors-gradients/dropdown.cjs.map +2 -2
- package/build/components/editable-text/index.cjs +5 -1
- package/build/components/editable-text/index.cjs.map +2 -2
- package/build/components/font-sizes/font-size-picker.cjs +2 -1
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/font-sizes/with-font-sizes.cjs +5 -3
- package/build/components/font-sizes/with-font-sizes.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +26 -13
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +1 -1
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +1 -1
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/gradients/with-gradient.cjs +1 -1
- package/build/components/gradients/with-gradient.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +14 -25
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/index.cjs +1 -1
- package/build/components/inspector-controls/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs +1 -1
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +7 -7
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +8 -16
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +29 -34
- package/build/components/list-view/block.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +3 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/provider/index.cjs +7 -8
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/with-registry-provider.cjs +1 -1
- package/build/components/provider/with-registry-provider.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +2 -34
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/hooks/block-fields/index.cjs +52 -86
- package/build/hooks/block-fields/index.cjs.map +3 -3
- package/build/hooks/block-fields/link/index.cjs +2 -11
- package/build/hooks/block-fields/link/index.cjs.map +2 -2
- package/build/hooks/block-fields/media/index.cjs +9 -14
- package/build/hooks/block-fields/media/index.cjs.map +2 -2
- package/build/hooks/cross-origin-isolation.cjs +1 -1
- package/build/hooks/cross-origin-isolation.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +141 -0
- package/build/hooks/custom-css.cjs.map +7 -0
- package/build/hooks/fit-text.cjs +14 -7
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +1 -1
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/index.cjs +6 -1
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/layout.cjs +10 -4
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +32 -11
- package/build/hooks/list-view.cjs.map +3 -3
- package/build/hooks/utils.cjs +5 -4
- package/build/hooks/utils.cjs.map +2 -2
- package/build/layouts/grid.cjs +12 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/store/defaults.cjs +3 -0
- package/build/store/defaults.cjs.map +2 -2
- package/build/store/private-selectors.cjs +45 -37
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/selectors.cjs +7 -1
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/fit-text-utils.cjs +5 -1
- package/build/utils/fit-text-utils.cjs.map +2 -2
- package/build-module/components/block-controls/index.mjs +1 -1
- package/build-module/components/block-controls/index.mjs.map +2 -2
- package/build-module/components/block-edit/context.mjs +4 -0
- package/build-module/components/block-edit/context.mjs.map +2 -2
- package/build-module/components/block-edit/index.mjs +4 -0
- package/build-module/components/block-edit/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +7 -27
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +3 -0
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +37 -13
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +2 -2
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-tools/index.mjs +2 -26
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-visibility/index.mjs +6 -9
- package/build-module/components/block-visibility/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +13 -11
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +1 -1
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +5 -1
- package/build-module/components/block-visibility/utils.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-menu-item.mjs +11 -4
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-toolbar.mjs +4 -6
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +95 -0
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +7 -0
- package/build-module/components/button-block-appender/index.mjs +23 -19
- package/build-module/components/button-block-appender/index.mjs.map +2 -2
- package/build-module/components/color-palette/with-color-context.mjs +1 -1
- package/build-module/components/color-palette/with-color-context.mjs.map +2 -2
- package/build-module/components/color-style-selector/index.mjs +1 -1
- package/build-module/components/color-style-selector/index.mjs.map +2 -2
- package/build-module/components/colors/with-colors.mjs +5 -3
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +1 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/editable-text/index.mjs +5 -1
- package/build-module/components/editable-text/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +2 -1
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/font-sizes/with-font-sizes.mjs +5 -3
- package/build-module/components/font-sizes/with-font-sizes.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +22 -13
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +1 -1
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +1 -1
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/gradients/with-gradient.mjs +1 -1
- package/build-module/components/gradients/with-gradient.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +16 -22
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/index.mjs +1 -1
- package/build-module/components/inspector-controls/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +7 -7
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +8 -16
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +31 -36
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs +3 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +7 -8
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/with-registry-provider.mjs +1 -1
- package/build-module/components/provider/with-registry-provider.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +3 -37
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +45 -87
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +2 -11
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +9 -14
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +1 -1
- package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +112 -0
- package/build-module/hooks/custom-css.mjs.map +7 -0
- package/build-module/hooks/fit-text.mjs +14 -7
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +1 -1
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/index.mjs +6 -1
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +10 -4
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +33 -12
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +7 -5
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +12 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/store/defaults.mjs +3 -0
- package/build-module/store/defaults.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +42 -40
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +7 -1
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/fit-text-utils.mjs +5 -1
- package/build-module/utils/fit-text-utils.mjs.map +2 -2
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/package.json +39 -39
- package/src/components/block-controls/index.js +1 -1
- package/src/components/block-controls/test/index.js +1 -0
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +6 -0
- package/src/components/block-edit/test/edit.js +10 -0
- package/src/components/block-inspector/index.js +16 -38
- package/src/components/block-list/block.js +3 -0
- package/src/components/block-list/block.native.js +5 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +49 -29
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-preview/test/index.js +11 -7
- package/src/components/block-settings-menu-controls/index.js +2 -2
- package/src/components/block-switcher/test/index.js +2 -0
- package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
- package/src/components/block-switcher/test/utils.js +2 -0
- package/src/components/block-toolbar/index.js +2 -2
- package/src/components/block-tools/index.js +2 -29
- package/src/components/block-visibility/index.js +3 -19
- package/src/components/block-visibility/modal.js +16 -14
- package/src/components/block-visibility/test/use-block-visibility.js +27 -25
- package/src/components/block-visibility/test/utils.js +24 -8
- package/src/components/block-visibility/use-block-visibility.js +1 -4
- package/src/components/block-visibility/utils.js +9 -1
- package/src/components/block-visibility/viewport-menu-item.js +11 -5
- package/src/components/block-visibility/viewport-toolbar.js +5 -6
- package/src/components/block-visibility/viewport-visibility-info.js +131 -0
- package/src/components/button-block-appender/index.js +2 -2
- package/src/components/color-palette/with-color-context.js +1 -1
- package/src/components/color-style-selector/index.js +2 -3
- package/src/components/colors/with-colors.js +23 -20
- package/src/components/colors-gradients/dropdown.js +2 -3
- package/src/components/editable-text/index.js +5 -1
- package/src/components/font-sizes/font-size-picker.js +1 -0
- package/src/components/font-sizes/with-font-sizes.js +13 -10
- package/src/components/global-styles/advanced-panel.js +35 -16
- package/src/components/global-styles/filters-panel.js +2 -3
- package/src/components/global-styles/shadow-panel-components.js +1 -1
- package/src/components/global-styles/style.scss +9 -5
- package/src/components/gradients/with-gradient.js +7 -4
- package/src/components/inner-blocks/test/index.js +2 -0
- package/src/components/inspector-controls/fill.js +30 -20
- package/src/components/inspector-controls/index.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +5 -1
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -11
- package/src/components/link-control/test/index.js +6 -1
- package/src/components/list-view/block-select-button.js +16 -25
- package/src/components/list-view/block.js +38 -43
- package/src/components/list-view/utils.js +4 -2
- package/src/components/media-replace-flow/test/index.js +13 -11
- package/src/components/provider/index.js +11 -10
- package/src/components/provider/test/use-block-sync.js +1 -0
- package/src/components/provider/with-registry-provider.js +1 -1
- package/src/components/use-block-commands/index.js +0 -41
- package/src/hooks/block-fields/index.js +66 -111
- package/src/hooks/block-fields/link/index.js +2 -14
- package/src/hooks/block-fields/media/index.js +9 -21
- package/src/hooks/cross-origin-isolation.js +19 -18
- package/src/hooks/custom-css.js +176 -0
- package/src/hooks/fit-text.js +20 -5
- package/src/hooks/grid-visualizer.js +15 -14
- package/src/hooks/index.js +6 -1
- package/src/hooks/layout.js +55 -43
- package/src/hooks/list-view.js +46 -12
- package/src/hooks/test/align.js +1 -0
- package/src/hooks/test/allowed-blocks.js +8 -0
- package/src/hooks/test/auto-inspector-controls.js +4 -0
- package/src/hooks/test/font-size.js +1 -0
- package/src/hooks/test/metadata.js +4 -0
- package/src/hooks/test/text-align.js +1 -0
- package/src/hooks/utils.js +124 -116
- package/src/layouts/grid.js +19 -3
- package/src/layouts/test/grid.js +1 -1
- package/src/store/defaults.js +4 -0
- package/src/store/private-selectors.js +94 -63
- package/src/store/selectors.js +14 -6
- package/src/store/test/actions.js +7 -0
- package/src/store/test/private-selectors.js +116 -119
- package/src/store/test/reducer.js +4 -0
- package/src/store/test/registry-selectors.js +2 -0
- package/src/store/test/selectors.js +19 -0
- package/src/utils/fit-text-utils.js +12 -2
- package/build/components/block-visibility/block-visibility-info.cjs +0 -63
- package/build/components/block-visibility/block-visibility-info.cjs.map +0 -7
- package/build/components/block-visibility/menu-item.cjs +0 -109
- package/build/components/block-visibility/menu-item.cjs.map +0 -7
- package/build/components/block-visibility/toolbar.cjs +0 -92
- package/build/components/block-visibility/toolbar.cjs.map +0 -7
- package/build-module/components/block-visibility/block-visibility-info.mjs +0 -47
- package/build-module/components/block-visibility/block-visibility-info.mjs.map +0 -7
- package/build-module/components/block-visibility/menu-item.mjs +0 -88
- package/build-module/components/block-visibility/menu-item.mjs.map +0 -7
- package/build-module/components/block-visibility/toolbar.mjs +0 -71
- package/build-module/components/block-visibility/toolbar.mjs.map +0 -7
- package/src/components/block-visibility/block-visibility-info.js +0 -62
- package/src/components/block-visibility/menu-item.js +0 -96
- package/src/components/block-visibility/toolbar.js +0 -88
- /package/src/components/block-icon/stories/{index.story.js → index.story.ts} +0 -0
- /package/src/components/contrast-checker/stories/{index.story.js → index.story.ts} +0 -0
|
@@ -23,6 +23,7 @@ __export(use_selected_block_event_handlers_exports, {
|
|
|
23
23
|
useEventHandlers: () => useEventHandlers
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(use_selected_block_event_handlers_exports);
|
|
26
|
+
var import_blocks = require("@wordpress/blocks");
|
|
26
27
|
var import_dom = require("@wordpress/dom");
|
|
27
28
|
var import_keycodes = require("@wordpress/keycodes");
|
|
28
29
|
var import_data = require("@wordpress/data");
|
|
@@ -38,7 +39,8 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
38
39
|
isZoomOut,
|
|
39
40
|
hasMultiSelection,
|
|
40
41
|
isSectionBlock,
|
|
41
|
-
editedContentOnlySection
|
|
42
|
+
editedContentOnlySection,
|
|
43
|
+
getBlock
|
|
42
44
|
} = (0, import_lock_unlock.unlock)((0, import_data.useSelect)(import_store.store));
|
|
43
45
|
const {
|
|
44
46
|
insertAfterBlock,
|
|
@@ -95,11 +97,11 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
95
97
|
ownerDocument.body.appendChild(dragElement);
|
|
96
98
|
event.dataTransfer.setDragImage(dragElement, 0, 0);
|
|
97
99
|
const rect = node.getBoundingClientRect();
|
|
98
|
-
const clone = node.cloneNode(true);
|
|
99
|
-
clone.style.visibility = "hidden";
|
|
100
|
-
clone.style.display = "none";
|
|
101
100
|
const id = node.id;
|
|
101
|
+
const clone = node.cloneNode();
|
|
102
|
+
clone.style.display = "none";
|
|
102
103
|
node.id = null;
|
|
104
|
+
node.after(clone);
|
|
103
105
|
let _scale = 1;
|
|
104
106
|
{
|
|
105
107
|
let parentElement = node;
|
|
@@ -112,7 +114,6 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
const inverted = 1 / _scale;
|
|
115
|
-
node.after(clone);
|
|
116
117
|
const originalNodeProperties = {};
|
|
117
118
|
for (const property of [
|
|
118
119
|
"transform",
|
|
@@ -158,18 +159,34 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
158
159
|
node.style.backgroundColor = bgColor;
|
|
159
160
|
}
|
|
160
161
|
let hasStarted = false;
|
|
161
|
-
|
|
162
|
+
let lastClientX = originClientX;
|
|
163
|
+
let lastClientY = originClientY;
|
|
164
|
+
function dragOver(e) {
|
|
165
|
+
if (e.clientX === lastClientX && e.clientY === lastClientY) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
lastClientX = e.clientX;
|
|
169
|
+
lastClientY = e.clientY;
|
|
170
|
+
over();
|
|
171
|
+
}
|
|
172
|
+
function over() {
|
|
162
173
|
if (!hasStarted) {
|
|
163
174
|
hasStarted = true;
|
|
164
175
|
node.style.pointerEvents = "none";
|
|
165
176
|
}
|
|
177
|
+
const pointerYDelta = lastClientY - originClientY;
|
|
178
|
+
const pointerXDelta = lastClientX - originClientX;
|
|
166
179
|
const scrollTop = defaultView.scrollY;
|
|
167
180
|
const scrollLeft = defaultView.scrollX;
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
const scrollTopDelta = scrollTop - originScrollTop;
|
|
182
|
+
const scrollLeftDelta = scrollLeft - originScrollLeft;
|
|
183
|
+
const topDelta = pointerYDelta + scrollTopDelta;
|
|
184
|
+
const leftDelta = pointerXDelta + scrollLeftDelta;
|
|
185
|
+
node.style.top = `${topDelta * inverted}px`;
|
|
186
|
+
node.style.left = `${leftDelta * inverted}px`;
|
|
170
187
|
}
|
|
171
188
|
function end() {
|
|
172
|
-
ownerDocument.removeEventListener("dragover",
|
|
189
|
+
ownerDocument.removeEventListener("dragover", dragOver);
|
|
173
190
|
ownerDocument.removeEventListener("dragend", end);
|
|
174
191
|
ownerDocument.removeEventListener("drop", end);
|
|
175
192
|
ownerDocument.removeEventListener("scroll", over);
|
|
@@ -189,7 +206,7 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
189
206
|
"is-dragging"
|
|
190
207
|
);
|
|
191
208
|
}
|
|
192
|
-
ownerDocument.addEventListener("dragover",
|
|
209
|
+
ownerDocument.addEventListener("dragover", dragOver);
|
|
193
210
|
ownerDocument.addEventListener("dragend", end);
|
|
194
211
|
ownerDocument.addEventListener("drop", end);
|
|
195
212
|
ownerDocument.addEventListener("scroll", over);
|
|
@@ -203,11 +220,15 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
203
220
|
node.addEventListener("dragstart", onDragStart);
|
|
204
221
|
function onDoubleClick(event) {
|
|
205
222
|
const isSection = isSectionBlock(clientId);
|
|
223
|
+
const block = getBlock(clientId);
|
|
224
|
+
const isSyncedPattern = (0, import_blocks.isReusableBlock)(block);
|
|
225
|
+
const isTemplatePartBlock = (0, import_blocks.isTemplatePart)(block);
|
|
206
226
|
const isAlreadyEditing = editedContentOnlySection === clientId;
|
|
207
|
-
if (isSection
|
|
208
|
-
|
|
209
|
-
editContentOnlySection(clientId);
|
|
227
|
+
if (!isSection || isAlreadyEditing || isSyncedPattern || isTemplatePartBlock) {
|
|
228
|
+
return;
|
|
210
229
|
}
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
editContentOnlySection(clientId);
|
|
211
232
|
}
|
|
212
233
|
if (window?.__experimentalContentOnlyPatternInsertion) {
|
|
213
234
|
node.addEventListener("dblclick", onDoubleClick);
|
|
@@ -224,6 +245,9 @@ function useEventHandlers({ clientId, isSelected }) {
|
|
|
224
245
|
clientId,
|
|
225
246
|
isSelected,
|
|
226
247
|
getBlockRootClientId,
|
|
248
|
+
getBlock,
|
|
249
|
+
import_blocks.isReusableBlock,
|
|
250
|
+
import_blocks.isTemplatePart,
|
|
227
251
|
insertAfterBlock,
|
|
228
252
|
removeBlock,
|
|
229
253
|
isZoomOut,
|
package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/block-list/use-block-props/use-selected-block-event-handlers.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isTextField } from '@wordpress/dom';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction isColorTransparent( color ) {\n\treturn ! color || color === 'transparent' || color === 'rgba(0, 0, 0, 0)';\n}\n\n/**\n * Adds block behaviour:\n * - Removes the block on BACKSPACE.\n * - Inserts a default block on ENTER.\n * - Disables dragging of block contents.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useEventHandlers( { clientId, isSelected } ) {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tisZoomOut,\n\t\thasMultiSelection,\n\t\tisSectionBlock,\n\t\teditedContentOnlySection,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tinsertAfterBlock,\n\t\tremoveBlock,\n\t\tresetZoomLevel,\n\t\tstartDraggingBlocks,\n\t\tstopDraggingBlocks,\n\t\teditContentOnlySection,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Interprets keydown event intent to remove or insert after block if\n\t\t\t * key event occurs on wrapper node. This can occur when the block has\n\t\t\t * no text fields of its own, particularly after initial insertion, to\n\t\t\t * allow for easy deletion and continuous writing flow to add additional\n\t\t\t * content.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keydown event.\n\t\t\t */\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tconst { keyCode, target } = event;\n\n\t\t\t\tif (\n\t\t\t\t\tkeyCode !== ENTER &&\n\t\t\t\t\tkeyCode !== BACKSPACE &&\n\t\t\t\t\tkeyCode !== DELETE\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( target !== node || isTextField( target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( keyCode === ENTER && isZoomOut() ) {\n\t\t\t\t\tresetZoomLevel();\n\t\t\t\t} else if ( keyCode === ENTER ) {\n\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tremoveBlock( clientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Prevents default dragging behavior within a block. To do: we must\n\t\t\t * handle this in the future and clean up the drag target.\n\t\t\t *\n\t\t\t * @param {DragEvent} event Drag event.\n\t\t\t */\n\t\t\tfunction onDragStart( event ) {\n\t\t\t\tif (\n\t\t\t\t\tnode !== event.target ||\n\t\t\t\t\tnode.isContentEditable ||\n\t\t\t\t\tnode.ownerDocument.activeElement !== node ||\n\t\t\t\t\thasMultiSelection()\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = JSON.stringify( {\n\t\t\t\t\ttype: 'block',\n\t\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\t\tsrcRootClientId: getBlockRootClientId( clientId ),\n\t\t\t\t} );\n\t\t\t\tevent.dataTransfer.effectAllowed = 'move'; // remove \"+\" cursor\n\t\t\t\tevent.dataTransfer.clearData();\n\t\t\t\tevent.dataTransfer.setData( 'wp-blocks', data );\n\t\t\t\tconst { ownerDocument } = node;\n\t\t\t\tconst { defaultView } = ownerDocument;\n\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\tselection.removeAllRanges();\n\n\t\t\t\t// Setting the drag chip as the drag image actually works, but\n\t\t\t\t// the behaviour is slightly different in every browser. In\n\t\t\t\t// Safari, it animates, in Firefox it's slightly transparent...\n\t\t\t\t// So we set a fake drag image and have to reposition it\n\t\t\t\t// ourselves.\n\t\t\t\tconst dragElement = ownerDocument.createElement( 'div' );\n\t\t\t\t// Chrome will show a globe icon if the drag element does not\n\t\t\t\t// have dimensions.\n\t\t\t\tdragElement.style.width = '1px';\n\t\t\t\tdragElement.style.height = '1px';\n\t\t\t\tdragElement.style.position = 'fixed';\n\t\t\t\tdragElement.style.visibility = 'hidden';\n\t\t\t\townerDocument.body.appendChild( dragElement );\n\t\t\t\tevent.dataTransfer.setDragImage( dragElement, 0, 0 );\n\n\t\t\t\tconst rect = node.getBoundingClientRect();\n\n\t\t\t\tconst clone = node.cloneNode( true );\n\t\t\t\tclone.style.visibility = 'hidden';\n\t\t\t\t// Maybe remove the clone now that it's relative?\n\t\t\t\tclone.style.display = 'none';\n\n\t\t\t\t// Remove the id and leave it on the clone so that drop target\n\t\t\t\t// calculations are correct.\n\t\t\t\tconst id = node.id;\n\t\t\t\tnode.id = null;\n\n\t\t\t\tlet _scale = 1;\n\n\t\t\t\t{\n\t\t\t\t\tlet parentElement = node;\n\t\t\t\t\twhile ( ( parentElement = parentElement.parentElement ) ) {\n\t\t\t\t\t\tconst { scale } =\n\t\t\t\t\t\t\tdefaultView.getComputedStyle( parentElement );\n\t\t\t\t\t\tif ( scale && scale !== 'none' ) {\n\t\t\t\t\t\t\t_scale = parseFloat( scale );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst inverted = 1 / _scale;\n\n\t\t\t\tnode.after( clone );\n\n\t\t\t\tconst originalNodeProperties = {};\n\t\t\t\tfor ( const property of [\n\t\t\t\t\t'transform',\n\t\t\t\t\t'transformOrigin',\n\t\t\t\t\t'transition',\n\t\t\t\t\t'zIndex',\n\t\t\t\t\t'position',\n\t\t\t\t\t'top',\n\t\t\t\t\t'left',\n\t\t\t\t\t'pointerEvents',\n\t\t\t\t\t'opacity',\n\t\t\t\t\t'backgroundColor',\n\t\t\t\t] ) {\n\t\t\t\t\toriginalNodeProperties[ property ] = node.style[ property ];\n\t\t\t\t}\n\n\t\t\t\t// Get scroll position.\n\t\t\t\tconst originScrollTop = defaultView.scrollY;\n\t\t\t\tconst originScrollLeft = defaultView.scrollX;\n\t\t\t\tconst originClientX = event.clientX;\n\t\t\t\tconst originClientY = event.clientY;\n\n\t\t\t\t// We can't use position fixed because it will behave different\n\t\t\t\t// if the html element is scaled or transformed (position will\n\t\t\t\t// no longer be relative to the viewport). The downside of\n\t\t\t\t// relative is that we have to listen to scroll events. On the\n\t\t\t\t// upside we don't have to clone to keep a space. Absolute\n\t\t\t\t// positioning might be weird because it will be based on the\n\t\t\t\t// positioned parent, but it might be worth a try.\n\t\t\t\tnode.style.position = 'relative';\n\t\t\t\tnode.style.top = `${ 0 }px`;\n\t\t\t\tnode.style.left = `${ 0 }px`;\n\n\t\t\t\tconst originX = event.clientX - rect.left;\n\t\t\t\tconst originY = event.clientY - rect.top;\n\n\t\t\t\t// Scale everything to 200px.\n\t\t\t\tconst dragScale = rect.height > 200 ? 200 / rect.height : 1;\n\n\t\t\t\tnode.style.zIndex = '1000';\n\t\t\t\tnode.style.transformOrigin = `${ originX * inverted }px ${\n\t\t\t\t\toriginY * inverted\n\t\t\t\t}px`;\n\t\t\t\tnode.style.transition = 'transform 0.2s ease-out';\n\t\t\t\tnode.style.transform = `scale(${ dragScale })`;\n\t\t\t\tnode.style.opacity = '0.9';\n\n\t\t\t\t// If the block has no background color, use the parent's\n\t\t\t\t// background color.\n\t\t\t\tif (\n\t\t\t\t\tisColorTransparent(\n\t\t\t\t\t\tdefaultView.getComputedStyle( node ).backgroundColor\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlet bgColor = 'transparent';\n\t\t\t\t\tlet parentElement = node;\n\t\t\t\t\twhile ( ( parentElement = parentElement.parentElement ) ) {\n\t\t\t\t\t\tconst { backgroundColor } =\n\t\t\t\t\t\t\tdefaultView.getComputedStyle( parentElement );\n\t\t\t\t\t\tif ( ! isColorTransparent( backgroundColor ) ) {\n\t\t\t\t\t\t\tbgColor = backgroundColor;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.style.backgroundColor = bgColor;\n\t\t\t\t}\n\n\t\t\t\tlet hasStarted = false;\n\n\t\t\t\tfunction over( e ) {\n\t\t\t\t\tif ( ! hasStarted ) {\n\t\t\t\t\t\thasStarted = true;\n\t\t\t\t\t\tnode.style.pointerEvents = 'none';\n\t\t\t\t\t}\n\t\t\t\t\tconst scrollTop = defaultView.scrollY;\n\t\t\t\t\tconst scrollLeft = defaultView.scrollX;\n\t\t\t\t\tnode.style.top = `${\n\t\t\t\t\t\t( e.clientY -\n\t\t\t\t\t\t\toriginClientY +\n\t\t\t\t\t\t\tscrollTop -\n\t\t\t\t\t\t\toriginScrollTop ) *\n\t\t\t\t\t\tinverted\n\t\t\t\t\t}px`;\n\t\t\t\t\tnode.style.left = `${\n\t\t\t\t\t\t( e.clientX -\n\t\t\t\t\t\t\toriginClientX +\n\t\t\t\t\t\t\tscrollLeft -\n\t\t\t\t\t\t\toriginScrollLeft ) *\n\t\t\t\t\t\tinverted\n\t\t\t\t\t}px`;\n\t\t\t\t}\n\n\t\t\t\tfunction end() {\n\t\t\t\t\townerDocument.removeEventListener( 'dragover', over );\n\t\t\t\t\townerDocument.removeEventListener( 'dragend', end );\n\t\t\t\t\townerDocument.removeEventListener( 'drop', end );\n\t\t\t\t\townerDocument.removeEventListener( 'scroll', over );\n\t\t\t\t\tfor ( const [ property, value ] of Object.entries(\n\t\t\t\t\t\toriginalNodeProperties\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tnode.style[ property ] = value;\n\t\t\t\t\t}\n\t\t\t\t\tclone.remove();\n\t\t\t\t\tnode.id = id;\n\t\t\t\t\tdragElement.remove();\n\t\t\t\t\tstopDraggingBlocks();\n\t\t\t\t\tdocument.body.classList.remove(\n\t\t\t\t\t\t'is-dragging-components-draggable'\n\t\t\t\t\t);\n\t\t\t\t\townerDocument.documentElement.classList.remove(\n\t\t\t\t\t\t'is-dragging'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\townerDocument.addEventListener( 'dragover', over );\n\t\t\t\townerDocument.addEventListener( 'dragend', end );\n\t\t\t\townerDocument.addEventListener( 'drop', end );\n\t\t\t\townerDocument.addEventListener( 'scroll', over );\n\n\t\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\t\t// Important because it hides the block toolbar.\n\t\t\t\tdocument.body.classList.add(\n\t\t\t\t\t'is-dragging-components-draggable'\n\t\t\t\t);\n\t\t\t\townerDocument.documentElement.classList.add( 'is-dragging' );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'dragstart', onDragStart );\n\n\t\t\t/**\n\t\t\t * Handles double-click events on section blocks to edit content only section.\n\t\t\t *\n\t\t\t * @param {MouseEvent} event Double-click event.\n\t\t\t */\n\t\t\tfunction onDoubleClick( event ) {\n\t\t\t\tconst isSection = isSectionBlock( clientId );\n\t\t\t\tconst isAlreadyEditing = editedContentOnlySection === clientId;\n\n\t\t\t\tif ( isSection && ! isAlreadyEditing ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\teditContentOnlySection( clientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Only add double-click listener if experimental flag is enabled\n\t\t\tif ( window?.__experimentalContentOnlyPatternInsertion ) {\n\t\t\t\tnode.addEventListener( 'dblclick', onDoubleClick );\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'dragstart', onDragStart );\n\t\t\t\tif ( window?.__experimentalContentOnlyPatternInsertion ) {\n\t\t\t\t\tnode.removeEventListener( 'dblclick', onDoubleClick );\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tclientId,\n\t\t\tisSelected,\n\t\t\tgetBlockRootClientId,\n\t\t\tinsertAfterBlock,\n\t\t\tremoveBlock,\n\t\t\tisZoomOut,\n\t\t\tresetZoomLevel,\n\t\t\thasMultiSelection,\n\t\t\tstartDraggingBlocks,\n\t\t\tstopDraggingBlocks,\n\t\t\tisSectionBlock,\n\t\t\teditedContentOnlySection,\n\t\t\teditContentOnlySection,\n\t\t]\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA4B;AAC5B,sBAAyC;AACzC,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAC1C,yBAAuB;AAEvB,SAAS,mBAAoB,OAAQ;AACpC,SAAO,CAAE,SAAS,UAAU,iBAAiB,UAAU;AACxD;AAUO,SAAS,iBAAkB,EAAE,UAAU,WAAW,GAAI;AAC5D,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,+BAAQ,uBAAW,aAAAA,KAAiB,CAAE;AAC1C,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,+BAAQ,yBAAa,aAAAA,KAAiB,CAAE;AAE5C,aAAO;AAAA,IACN,CAAE,SAAU;AACX,UAAK,CAAE,YAAa;AACnB;AAAA,MACD;AAWA,eAAS,UAAW,OAAQ;AAC3B,cAAM,EAAE,SAAS,OAAO,IAAI;AAE5B,YACC,YAAY,yBACZ,YAAY,6BACZ,YAAY,wBACX;AACD;AAAA,QACD;AAEA,YAAK,WAAW,YAAQ,wBAAa,MAAO,GAAI;AAC/C;AAAA,QACD;AAEA,cAAM,eAAe;AAErB,YAAK,YAAY,yBAAS,UAAU,GAAI;AACvC,yBAAe;AAAA,QAChB,WAAY,YAAY,uBAAQ;AAC/B,2BAAkB,QAAS;AAAA,QAC5B,OAAO;AACN,sBAAa,QAAS;AAAA,QACvB;AAAA,MACD;AAQA,eAAS,YAAa,OAAQ;AAC7B,YACC,SAAS,MAAM,UACf,KAAK,qBACL,KAAK,cAAc,kBAAkB,QACrC,kBAAkB,GACjB;AACD,gBAAM,eAAe;AACrB;AAAA,QACD;AACA,cAAM,OAAO,KAAK,UAAW;AAAA,UAC5B,MAAM;AAAA,UACN,cAAc,CAAE,QAAS;AAAA,UACzB,iBAAiB,qBAAsB,QAAS;AAAA,QACjD,CAAE;AACF,cAAM,aAAa,gBAAgB;AACnC,cAAM,aAAa,UAAU;AAC7B,cAAM,aAAa,QAAS,aAAa,IAAK;AAC9C,cAAM,EAAE,cAAc,IAAI;AAC1B,cAAM,EAAE,YAAY,IAAI;AACxB,cAAM,YAAY,YAAY,aAAa;AAC3C,kBAAU,gBAAgB;AAO1B,cAAM,cAAc,cAAc,cAAe,KAAM;AAGvD,oBAAY,MAAM,QAAQ;AAC1B,oBAAY,MAAM,SAAS;AAC3B,oBAAY,MAAM,WAAW;AAC7B,oBAAY,MAAM,aAAa;AAC/B,sBAAc,KAAK,YAAa,WAAY;AAC5C,cAAM,aAAa,aAAc,aAAa,GAAG,CAAE;AAEnD,cAAM,OAAO,KAAK,sBAAsB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isReusableBlock, isTemplatePart } from '@wordpress/blocks';\nimport { isTextField } from '@wordpress/dom';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction isColorTransparent( color ) {\n\treturn ! color || color === 'transparent' || color === 'rgba(0, 0, 0, 0)';\n}\n\n/**\n * Adds block behaviour:\n * - Removes the block on BACKSPACE.\n * - Inserts a default block on ENTER.\n * - Disables dragging of block contents.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useEventHandlers( { clientId, isSelected } ) {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tisZoomOut,\n\t\thasMultiSelection,\n\t\tisSectionBlock,\n\t\teditedContentOnlySection,\n\t\tgetBlock,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tinsertAfterBlock,\n\t\tremoveBlock,\n\t\tresetZoomLevel,\n\t\tstartDraggingBlocks,\n\t\tstopDraggingBlocks,\n\t\teditContentOnlySection,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Interprets keydown event intent to remove or insert after block if\n\t\t\t * key event occurs on wrapper node. This can occur when the block has\n\t\t\t * no text fields of its own, particularly after initial insertion, to\n\t\t\t * allow for easy deletion and continuous writing flow to add additional\n\t\t\t * content.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keydown event.\n\t\t\t */\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tconst { keyCode, target } = event;\n\n\t\t\t\tif (\n\t\t\t\t\tkeyCode !== ENTER &&\n\t\t\t\t\tkeyCode !== BACKSPACE &&\n\t\t\t\t\tkeyCode !== DELETE\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( target !== node || isTextField( target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( keyCode === ENTER && isZoomOut() ) {\n\t\t\t\t\tresetZoomLevel();\n\t\t\t\t} else if ( keyCode === ENTER ) {\n\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tremoveBlock( clientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Prevents default dragging behavior within a block. To do: we must\n\t\t\t * handle this in the future and clean up the drag target.\n\t\t\t *\n\t\t\t * @param {DragEvent} event Drag event.\n\t\t\t */\n\t\t\tfunction onDragStart( event ) {\n\t\t\t\tif (\n\t\t\t\t\tnode !== event.target ||\n\t\t\t\t\tnode.isContentEditable ||\n\t\t\t\t\tnode.ownerDocument.activeElement !== node ||\n\t\t\t\t\thasMultiSelection()\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = JSON.stringify( {\n\t\t\t\t\ttype: 'block',\n\t\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\t\tsrcRootClientId: getBlockRootClientId( clientId ),\n\t\t\t\t} );\n\t\t\t\tevent.dataTransfer.effectAllowed = 'move'; // remove \"+\" cursor\n\t\t\t\tevent.dataTransfer.clearData();\n\t\t\t\tevent.dataTransfer.setData( 'wp-blocks', data );\n\t\t\t\tconst { ownerDocument } = node;\n\t\t\t\tconst { defaultView } = ownerDocument;\n\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\tselection.removeAllRanges();\n\n\t\t\t\t// Setting the drag chip as the drag image actually works, but\n\t\t\t\t// the behaviour is slightly different in every browser. In\n\t\t\t\t// Safari, it animates, in Firefox it's slightly transparent...\n\t\t\t\t// So we set a fake drag image and have to reposition it\n\t\t\t\t// ourselves.\n\t\t\t\tconst dragElement = ownerDocument.createElement( 'div' );\n\t\t\t\t// Chrome will show a globe icon if the drag element does not\n\t\t\t\t// have dimensions.\n\t\t\t\tdragElement.style.width = '1px';\n\t\t\t\tdragElement.style.height = '1px';\n\t\t\t\tdragElement.style.position = 'fixed';\n\t\t\t\tdragElement.style.visibility = 'hidden';\n\t\t\t\townerDocument.body.appendChild( dragElement );\n\t\t\t\tevent.dataTransfer.setDragImage( dragElement, 0, 0 );\n\n\t\t\t\tconst rect = node.getBoundingClientRect();\n\n\t\t\t\t// Remove the id and leave it on a shallow clone so that drop\n\t\t\t\t// target calculations are correct.\n\t\t\t\tconst id = node.id;\n\t\t\t\tconst clone = node.cloneNode();\n\t\t\t\tclone.style.display = 'none';\n\t\t\t\tnode.id = null;\n\t\t\t\tnode.after( clone );\n\n\t\t\t\tlet _scale = 1;\n\n\t\t\t\t{\n\t\t\t\t\tlet parentElement = node;\n\t\t\t\t\twhile ( ( parentElement = parentElement.parentElement ) ) {\n\t\t\t\t\t\tconst { scale } =\n\t\t\t\t\t\t\tdefaultView.getComputedStyle( parentElement );\n\t\t\t\t\t\tif ( scale && scale !== 'none' ) {\n\t\t\t\t\t\t\t_scale = parseFloat( scale );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst inverted = 1 / _scale;\n\n\t\t\t\tconst originalNodeProperties = {};\n\t\t\t\tfor ( const property of [\n\t\t\t\t\t'transform',\n\t\t\t\t\t'transformOrigin',\n\t\t\t\t\t'transition',\n\t\t\t\t\t'zIndex',\n\t\t\t\t\t'position',\n\t\t\t\t\t'top',\n\t\t\t\t\t'left',\n\t\t\t\t\t'pointerEvents',\n\t\t\t\t\t'opacity',\n\t\t\t\t\t'backgroundColor',\n\t\t\t\t] ) {\n\t\t\t\t\toriginalNodeProperties[ property ] = node.style[ property ];\n\t\t\t\t}\n\n\t\t\t\t// Get scroll position.\n\t\t\t\tconst originScrollTop = defaultView.scrollY;\n\t\t\t\tconst originScrollLeft = defaultView.scrollX;\n\t\t\t\tconst originClientX = event.clientX;\n\t\t\t\tconst originClientY = event.clientY;\n\n\t\t\t\t// We can't use position fixed because it will behave different\n\t\t\t\t// if the html element is scaled or transformed (position will\n\t\t\t\t// no longer be relative to the viewport). The downside of\n\t\t\t\t// relative is that we have to listen to scroll events. On the\n\t\t\t\t// upside we don't have to clone to keep a space. Absolute\n\t\t\t\t// positioning might be weird because it will be based on the\n\t\t\t\t// positioned parent, but it might be worth a try.\n\t\t\t\tnode.style.position = 'relative';\n\t\t\t\tnode.style.top = `${ 0 }px`;\n\t\t\t\tnode.style.left = `${ 0 }px`;\n\n\t\t\t\tconst originX = event.clientX - rect.left;\n\t\t\t\tconst originY = event.clientY - rect.top;\n\n\t\t\t\t// Scale everything to 200px.\n\t\t\t\tconst dragScale = rect.height > 200 ? 200 / rect.height : 1;\n\n\t\t\t\tnode.style.zIndex = '1000';\n\t\t\t\tnode.style.transformOrigin = `${ originX * inverted }px ${\n\t\t\t\t\toriginY * inverted\n\t\t\t\t}px`;\n\t\t\t\tnode.style.transition = 'transform 0.2s ease-out';\n\t\t\t\tnode.style.transform = `scale(${ dragScale })`;\n\t\t\t\tnode.style.opacity = '0.9';\n\n\t\t\t\t// If the block has no background color, use the parent's\n\t\t\t\t// background color.\n\t\t\t\tif (\n\t\t\t\t\tisColorTransparent(\n\t\t\t\t\t\tdefaultView.getComputedStyle( node ).backgroundColor\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlet bgColor = 'transparent';\n\t\t\t\t\tlet parentElement = node;\n\t\t\t\t\twhile ( ( parentElement = parentElement.parentElement ) ) {\n\t\t\t\t\t\tconst { backgroundColor } =\n\t\t\t\t\t\t\tdefaultView.getComputedStyle( parentElement );\n\t\t\t\t\t\tif ( ! isColorTransparent( backgroundColor ) ) {\n\t\t\t\t\t\t\tbgColor = backgroundColor;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.style.backgroundColor = bgColor;\n\t\t\t\t}\n\n\t\t\t\tlet hasStarted = false;\n\t\t\t\tlet lastClientX = originClientX;\n\t\t\t\tlet lastClientY = originClientY;\n\n\t\t\t\tfunction dragOver( e ) {\n\t\t\t\t\t// Only trigger `over` if the mouse has moved.\n\t\t\t\t\tif (\n\t\t\t\t\t\te.clientX === lastClientX &&\n\t\t\t\t\t\te.clientY === lastClientY\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlastClientX = e.clientX;\n\t\t\t\t\tlastClientY = e.clientY;\n\t\t\t\t\tover();\n\t\t\t\t}\n\n\t\t\t\tfunction over() {\n\t\t\t\t\tif ( ! hasStarted ) {\n\t\t\t\t\t\thasStarted = true;\n\t\t\t\t\t\tnode.style.pointerEvents = 'none';\n\t\t\t\t\t}\n\t\t\t\t\tconst pointerYDelta = lastClientY - originClientY;\n\t\t\t\t\tconst pointerXDelta = lastClientX - originClientX;\n\t\t\t\t\tconst scrollTop = defaultView.scrollY;\n\t\t\t\t\tconst scrollLeft = defaultView.scrollX;\n\t\t\t\t\tconst scrollTopDelta = scrollTop - originScrollTop;\n\t\t\t\t\tconst scrollLeftDelta = scrollLeft - originScrollLeft;\n\t\t\t\t\tconst topDelta = pointerYDelta + scrollTopDelta;\n\t\t\t\t\tconst leftDelta = pointerXDelta + scrollLeftDelta;\n\t\t\t\t\tnode.style.top = `${ topDelta * inverted }px`;\n\t\t\t\t\tnode.style.left = `${ leftDelta * inverted }px`;\n\t\t\t\t}\n\n\t\t\t\tfunction end() {\n\t\t\t\t\townerDocument.removeEventListener( 'dragover', dragOver );\n\t\t\t\t\townerDocument.removeEventListener( 'dragend', end );\n\t\t\t\t\townerDocument.removeEventListener( 'drop', end );\n\t\t\t\t\townerDocument.removeEventListener( 'scroll', over );\n\t\t\t\t\tfor ( const [ property, value ] of Object.entries(\n\t\t\t\t\t\toriginalNodeProperties\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tnode.style[ property ] = value;\n\t\t\t\t\t}\n\t\t\t\t\tclone.remove();\n\t\t\t\t\tnode.id = id;\n\t\t\t\t\tdragElement.remove();\n\t\t\t\t\tstopDraggingBlocks();\n\t\t\t\t\tdocument.body.classList.remove(\n\t\t\t\t\t\t'is-dragging-components-draggable'\n\t\t\t\t\t);\n\t\t\t\t\townerDocument.documentElement.classList.remove(\n\t\t\t\t\t\t'is-dragging'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\townerDocument.addEventListener( 'dragover', dragOver );\n\t\t\t\townerDocument.addEventListener( 'dragend', end );\n\t\t\t\townerDocument.addEventListener( 'drop', end );\n\t\t\t\townerDocument.addEventListener( 'scroll', over );\n\n\t\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\t\t// Important because it hides the block toolbar.\n\t\t\t\tdocument.body.classList.add(\n\t\t\t\t\t'is-dragging-components-draggable'\n\t\t\t\t);\n\t\t\t\townerDocument.documentElement.classList.add( 'is-dragging' );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'dragstart', onDragStart );\n\n\t\t\t/**\n\t\t\t * Handles double-click events on section blocks to edit content only section.\n\t\t\t *\n\t\t\t * @param {MouseEvent} event Double-click event.\n\t\t\t */\n\t\t\tfunction onDoubleClick( event ) {\n\t\t\t\tconst isSection = isSectionBlock( clientId );\n\t\t\t\tconst block = getBlock( clientId );\n\t\t\t\tconst isSyncedPattern = isReusableBlock( block );\n\t\t\t\tconst isTemplatePartBlock = isTemplatePart( block );\n\t\t\t\tconst isAlreadyEditing = editedContentOnlySection === clientId;\n\n\t\t\t\tif (\n\t\t\t\t\t! isSection ||\n\t\t\t\t\tisAlreadyEditing ||\n\t\t\t\t\tisSyncedPattern ||\n\t\t\t\t\tisTemplatePartBlock\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\t\t\t\teditContentOnlySection( clientId );\n\t\t\t}\n\n\t\t\t// Only add double-click listener if experimental flag is enabled\n\t\t\tif ( window?.__experimentalContentOnlyPatternInsertion ) {\n\t\t\t\tnode.addEventListener( 'dblclick', onDoubleClick );\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'dragstart', onDragStart );\n\t\t\t\tif ( window?.__experimentalContentOnlyPatternInsertion ) {\n\t\t\t\t\tnode.removeEventListener( 'dblclick', onDoubleClick );\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tclientId,\n\t\t\tisSelected,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlock,\n\t\t\tisReusableBlock,\n\t\t\tisTemplatePart,\n\t\t\tinsertAfterBlock,\n\t\t\tremoveBlock,\n\t\t\tisZoomOut,\n\t\t\tresetZoomLevel,\n\t\t\thasMultiSelection,\n\t\t\tstartDraggingBlocks,\n\t\t\tstopDraggingBlocks,\n\t\t\tisSectionBlock,\n\t\t\teditedContentOnlySection,\n\t\t\teditContentOnlySection,\n\t\t]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAgD;AAChD,iBAA4B;AAC5B,sBAAyC;AACzC,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAC1C,yBAAuB;AAEvB,SAAS,mBAAoB,OAAQ;AACpC,SAAO,CAAE,SAAS,UAAU,iBAAiB,UAAU;AACxD;AAUO,SAAS,iBAAkB,EAAE,UAAU,WAAW,GAAI;AAC5D,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,+BAAQ,uBAAW,aAAAA,KAAiB,CAAE;AAC1C,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,+BAAQ,yBAAa,aAAAA,KAAiB,CAAE;AAE5C,aAAO;AAAA,IACN,CAAE,SAAU;AACX,UAAK,CAAE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Q,GAAI;AAC5C,sBAAc,iBAAkB,UAAU,IAAK;AAE/C,4BAAqB,CAAE,QAAS,CAAE;AAElC,iBAAS,KAAK,UAAU;AAAA,UACvB;AAAA,QACD;AACA,sBAAc,gBAAgB,UAAU,IAAK,aAAc;AAAA,MAC5D;AAEA,WAAK,iBAAkB,WAAW,SAAU;AAC5C,WAAK,iBAAkB,aAAa,WAAY;AAOhD,eAAS,cAAe,OAAQ;AAC/B,cAAM,YAAY,eAAgB,QAAS;AAC3C,cAAM,QAAQ,SAAU,QAAS;AACjC,cAAM,sBAAkB,+BAAiB,KAAM;AAC/C,cAAM,0BAAsB,8BAAgB,KAAM;AAClD,cAAM,mBAAmB,6BAA6B;AAEtD,YACC,CAAE,aACF,oBACA,mBACA,qBACC;AACD;AAAA,QACD;AAEA,cAAM,eAAe;AACrB,+BAAwB,QAAS;AAAA,MAClC;AAGA,UAAK,QAAQ,2CAA4C;AACxD,aAAK,iBAAkB,YAAY,aAAc;AAAA,MAClD;AAEA,aAAO,MAAM;AACZ,aAAK,oBAAqB,WAAW,SAAU;AAC/C,aAAK,oBAAqB,aAAa,WAAY;AACnD,YAAK,QAAQ,2CAA4C;AACxD,eAAK,oBAAqB,YAAY,aAAc;AAAA,QACrD;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -122,7 +122,7 @@ var BlockSettingsMenuControlsSlot = ({ fillProps, clientIds = null }) => {
|
|
|
122
122
|
}
|
|
123
123
|
),
|
|
124
124
|
showVisibilityButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
-
import_block_visibility.
|
|
125
|
+
import_block_visibility.BlockVisibilityViewportMenuItem,
|
|
126
126
|
{
|
|
127
127
|
clientIds: selectedClientIds
|
|
128
128
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-settings-menu-controls/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tcreateSlotFill,\n\tMenuGroup,\n\t__experimentalStyleProvider as StyleProvider,\n} from '@wordpress/components';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseConvertToGroupButtonProps,\n\tConvertToGroupButton,\n} from '../convert-to-group-buttons';\nimport { BlockLockMenuItem, useBlockLock } from '../block-lock';\nimport { store as blockEditorStore } from '../../store';\nimport BlockModeToggle from '../block-settings-menu/block-mode-toggle';\nimport { ModifyContentOnlySectionMenuItem } from '../content-lock';\nimport { BlockRenameControl, useBlockRename } from '../block-rename';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,oBAAgC;AAChC,kBAA0B;AAK1B,sCAGO;AACP,wBAAgD;AAChD,mBAA0C;AAC1C,+BAA4B;AAC5B,0BAAiD;AACjD,0BAAmD;AACnD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tcreateSlotFill,\n\tMenuGroup,\n\t__experimentalStyleProvider as StyleProvider,\n} from '@wordpress/components';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseConvertToGroupButtonProps,\n\tConvertToGroupButton,\n} from '../convert-to-group-buttons';\nimport { BlockLockMenuItem, useBlockLock } from '../block-lock';\nimport { store as blockEditorStore } from '../../store';\nimport BlockModeToggle from '../block-settings-menu/block-mode-toggle';\nimport { ModifyContentOnlySectionMenuItem } from '../content-lock';\nimport { BlockRenameControl, useBlockRename } from '../block-rename';\nimport { BlockVisibilityViewportMenuItem } from '../block-visibility';\nimport { EditSectionMenuItem } from './edit-section-menu-item';\n\nconst { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );\n\nconst BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {\n\tconst {\n\t\tselectedBlocks,\n\t\tselectedClientIds,\n\t\tisContentOnly,\n\t\tcanToggleSelectedBlocksVisibility,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst ids =\n\t\t\t\tclientIds !== null ? clientIds : getSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\tselectedBlocks: getBlockNamesByClientId( ids ),\n\t\t\t\tselectedClientIds: ids,\n\t\t\t\tisContentOnly:\n\t\t\t\t\tgetBlockEditingMode( ids[ 0 ] ) === 'contentOnly',\n\t\t\t\tcanToggleSelectedBlocksVisibility: getBlocksByClientId(\n\t\t\t\t\tids\n\t\t\t\t).every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, 'visibility', true )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst { canLock } = useBlockLock( selectedClientIds[ 0 ] );\n\tconst { canRename } = useBlockRename( selectedBlocks[ 0 ] );\n\tconst showLockButton =\n\t\tselectedClientIds.length === 1 && canLock && ! isContentOnly;\n\tconst showRenameButton =\n\t\tselectedClientIds.length === 1 && canRename && ! isContentOnly;\n\tconst showVisibilityButton =\n\t\tcanToggleSelectedBlocksVisibility && ! isContentOnly;\n\n\t// Check if current selection of blocks is Groupable or Ungroupable\n\t// and pass this props down to ConvertToGroupButton.\n\tconst convertToGroupButtonProps =\n\t\tuseConvertToGroupButtonProps( selectedClientIds );\n\tconst { isGroupable, isUngroupable } = convertToGroupButtonProps;\n\tconst showConvertToGroupButton =\n\t\t( isGroupable || isUngroupable ) && ! isContentOnly;\n\n\treturn (\n\t\t<Slot\n\t\t\tfillProps={ {\n\t\t\t\t...fillProps,\n\t\t\t\tselectedBlocks,\n\t\t\t\tselectedClientIds,\n\t\t\t} }\n\t\t>\n\t\t\t{ ( fills ) => {\n\t\t\t\tif (\n\t\t\t\t\t! fills?.length > 0 &&\n\t\t\t\t\t! showConvertToGroupButton &&\n\t\t\t\t\t! showLockButton\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t{ showConvertToGroupButton && (\n\t\t\t\t\t\t\t<ConvertToGroupButton\n\t\t\t\t\t\t\t\t{ ...convertToGroupButtonProps }\n\t\t\t\t\t\t\t\tonClose={ fillProps?.onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t\t<EditSectionMenuItem\n\t\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\t\tonClose={ fillProps?.onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showLockButton && (\n\t\t\t\t\t\t\t<BlockLockMenuItem\n\t\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showRenameButton && (\n\t\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showVisibilityButton && (\n\t\t\t\t\t\t\t<BlockVisibilityViewportMenuItem\n\t\t\t\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t\t<ModifyContentOnlySectionMenuItem\n\t\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\t\tonClose={ fillProps?.onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ fillProps?.count === 1 && ! isContentOnly && (\n\t\t\t\t\t\t\t<BlockModeToggle\n\t\t\t\t\t\t\t\tclientId={ fillProps?.firstBlockClientId }\n\t\t\t\t\t\t\t\tonToggle={ fillProps?.onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t);\n\t\t\t} }\n\t\t</Slot>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md\n *\n * @param {Object} props Fill props.\n * @return {Element} Element.\n */\nfunction BlockSettingsMenuControls( { ...props } ) {\n\treturn (\n\t\t<StyleProvider document={ document }>\n\t\t\t<Fill { ...props } />\n\t\t</StyleProvider>\n\t);\n}\n\nBlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot;\n\nexport default BlockSettingsMenuControls;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,oBAAgC;AAChC,kBAA0B;AAK1B,sCAGO;AACP,wBAAgD;AAChD,mBAA0C;AAC1C,+BAA4B;AAC5B,0BAAiD;AACjD,0BAAmD;AACnD,8BAAgD;AAChD,oCAAoC;AAsE/B;AApEL,IAAM,EAAE,MAAM,KAAK,QAAI,kCAAgB,2BAA4B;AAEnE,IAAM,gCAAgC,CAAE,EAAE,WAAW,YAAY,KAAK,MAAO;AAC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A,YAAC;AAAA;AAAA,cACA,UAAW,kBAAmB,CAAE;AAAA,cAChC,SAAU,WAAW;AAAA;AAAA,UACtB;AAAA,UAEC,kBACD;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,kBAAmB,CAAE;AAAA;AAAA,UACjC;AAAA,UAEC,oBACD;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,kBAAmB,CAAE;AAAA;AAAA,UACjC;AAAA,UAEC,wBACD;AAAA,YAAC;AAAA;AAAA,cACA,WAAY;AAAA;AAAA,UACb;AAAA,UAEC;AAAA,UACA,kBAAkB,WAAW,KAC9B;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,kBAAmB,CAAE;AAAA,cAChC,SAAU,WAAW;AAAA;AAAA,UACtB;AAAA,UAEC,WAAW,UAAU,KAAK,CAAE,iBAC7B;AAAA,YAAC,yBAAAC;AAAA,YAAA;AAAA,cACA,UAAW,WAAW;AAAA,cACtB,UAAW,WAAW;AAAA;AAAA,UACvB;AAAA,WAEF;AAAA,MAEF;AAAA;AAAA,EACD;AAEF;AAQA,SAAS,0BAA2B,EAAE,GAAG,MAAM,GAAI;AAClD,SACC,4CAAC,kBAAAC,6BAAA,EAAc,UACd,sDAAC,QAAO,GAAG,OAAQ,GACpB;AAEF;AAEA,0BAA0B,OAAO;AAEjC,IAAO,uCAAQ;",
|
|
6
6
|
"names": ["blockEditorStore", "BlockModeToggle", "StyleProvider"]
|
|
7
7
|
}
|
|
@@ -185,7 +185,7 @@ function PrivateBlockToolbar({
|
|
|
185
185
|
}
|
|
186
186
|
),
|
|
187
187
|
isDefaultEditingMode && showBlockVisibilityButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
188
|
-
import_block_visibility.
|
|
188
|
+
import_block_visibility.ViewportVisibilityToolbar,
|
|
189
189
|
{
|
|
190
190
|
clientIds: blockClientIds
|
|
191
191
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-toolbar/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tgetBlockType,\n\thasBlockSupport,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { BlockVisibilityToolbar } from '../block-visibility';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowHoveredOrFocusedGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport NavigableToolbar from '../navigable-toolbar';\nimport { useHasBlockToolbar } from './use-has-block-toolbar';\nimport ChangeDesign from './change-design';\nimport SwitchSectionStyle from './switch-section-style';\nimport { unlock } from '../../lock-unlock';\nimport BlockToolbarIcon from './block-toolbar-icon';\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {boolean} props.focusOnMount Focus the toolbar when mounted.\n * @param {number} props.__experimentalInitialIndex The initial index of the toolbar item to focus.\n * @param {Function} props.__experimentalOnIndexChange Callback function to be called when the index of the focused toolbar item changes.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport function PrivateBlockToolbar( {\n\thideDragHandle,\n\tfocusOnMount,\n\t__experimentalInitialIndex,\n\t__experimentalOnIndexChange,\n\tvariant = 'unstyled',\n} ) {\n\tconst {\n\t\tblockClientId,\n\t\tblockClientIds,\n\t\tisDefaultEditingMode,\n\t\tblockType,\n\t\ttoolbarKey,\n\t\tshouldShowVisualToolbar,\n\t\tshowParentSelector,\n\t\tisUsingBindings,\n\t\tisSectionContainer,\n\t\thasContentOnlyLocking,\n\t\tshowShuffleButton,\n\t\tshowSlots,\n\t\tshowGroupButtons,\n\t\tshowLockButtons,\n\t\tshowBlockVisibilityButton,\n\t\tshowSwitchSectionStyleButton,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockMode,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisBlockValid,\n\t\t\tgetBlockEditingMode,\n\t\t\tgetBlockAttributes,\n\t\t\tgetTemplateLock,\n\t\t\tgetParentSectionBlock,\n\t\t\tisZoomOut,\n\t\t\tisSectionBlock,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\tconst parentSection = getParentSectionBlock( selectedBlockClientId );\n\t\tconst parentClientId = parentSection ?? parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\t\tconst editingMode = getBlockEditingMode( selectedBlockClientId );\n\t\tconst _isDefaultEditingMode = editingMode === 'default';\n\t\tconst _blockName = getBlockName( selectedBlockClientId );\n\t\tconst isValid = selectedBlockClientIds.every( ( id ) =>\n\t\t\tisBlockValid( id )\n\t\t);\n\t\tconst isVisual = selectedBlockClientIds.every(\n\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t);\n\t\tconst _isUsingBindings = selectedBlockClientIds.every(\n\t\t\t( clientId ) =>\n\t\t\t\t!! getBlockAttributes( clientId )?.metadata?.bindings\n\t\t);\n\n\t\t// If one or more selected blocks are locked, do not show the BlockGroupToolbar.\n\t\tconst _hasTemplateLock = selectedBlockClientIds.some(\n\t\t\t( id ) => getTemplateLock( id ) === 'contentOnly'\n\t\t);\n\n\t\tconst _isZoomOut = isZoomOut();\n\n\t\tconst _isSectionBlock = isSectionBlock( selectedBlockClientId );\n\n\t\t// The switch style button appears more prominently with the\n\t\t// content only pattern experiment.\n\t\tconst _showSwitchSectionStyleButton =\n\t\t\twindow?.__experimentalContentOnlyPatternInsertion &&\n\t\t\t( _isZoomOut || _isSectionBlock );\n\n\t\treturn {\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\tisDefaultEditingMode: _isDefaultEditingMode,\n\t\t\tblockType: selectedBlockClientId && getBlockType( _blockName ),\n\t\t\tshouldShowVisualToolbar: isValid && isVisual,\n\t\t\ttoolbarKey: `${ selectedBlockClientId }${ parentClientId }`,\n\t\t\tshowParentSelector:\n\t\t\t\t! _isZoomOut &&\n\t\t\t\tparentBlockType &&\n\t\t\t\teditingMode !== 'contentOnly' &&\n\t\t\t\tgetBlockEditingMode( parentClientId ) !== 'disabled' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length === 1,\n\t\t\tisUsingBindings: _isUsingBindings,\n\t\t\tisSectionContainer: _isSectionBlock,\n\t\t\thasContentOnlyLocking: _hasTemplateLock,\n\t\t\tshowShuffleButton: _isZoomOut,\n\t\t\tshowSlots: ! _isZoomOut,\n\t\t\tshowGroupButtons: ! _isZoomOut,\n\t\t\tshowLockButtons: ! _isZoomOut,\n\t\t\tshowBlockVisibilityButton: ! _isZoomOut,\n\t\t\tshowSwitchSectionStyleButton: _showSwitchSectionStyleButton,\n\t\t};\n\t}, [] );\n\n\tconst toolbarWrapperRef = useRef( null );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst nodeRef = useRef();\n\tconst showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {\n\t\tref: nodeRef,\n\t} );\n\n\tconst isLargeViewport = ! useViewportMatch( 'medium', '<' );\n\n\tconst hasBlockToolbar = useHasBlockToolbar();\n\tif ( ! hasBlockToolbar ) {\n\t\treturn null;\n\t}\n\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\tconst isSynced =\n\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = clsx( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': showParentSelector,\n\t} );\n\n\tconst innerClasses = clsx( 'block-editor-block-toolbar', {\n\t\t'is-synced': isSynced,\n\t\t'is-connected': isUsingBindings,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusEditorOnEscape\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t// The variant is applied as \"toolbar\" when undefined, which is the black border style of the dropdown from the toolbar popover.\n\t\t\tvariant={ variant === 'toolbar' ? undefined : variant }\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\t__experimentalInitialIndex={ __experimentalInitialIndex }\n\t\t\t__experimentalOnIndexChange={ __experimentalOnIndexChange }\n\t\t\t// Resets the index whenever the active block changes so\n\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\tkey={ toolbarKey }\n\t\t>\n\t\t\t<div ref={ toolbarWrapperRef } className={ innerClasses }>\n\t\t\t\t{ showParentSelector && ! isMultiToolbar && isLargeViewport && (\n\t\t\t\t\t<BlockParentSelector />\n\t\t\t\t) }\n\t\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) && (\n\t\t\t\t\t<div ref={ nodeRef } { ...showHoveredOrFocusedGestures }>\n\t\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t\t<BlockToolbarIcon\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\tisSynced={ isSynced }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isDefaultEditingMode &&\n\t\t\t\t\t\t\t\tshowBlockVisibilityButton && (\n\t\t\t\t\t\t\t\t\t<BlockVisibilityToolbar\n\t\t\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! isMultiToolbar &&\n\t\t\t\t\t\t\t\tisDefaultEditingMode &&\n\t\t\t\t\t\t\t\tshowLockButtons && (\n\t\t\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\t\t\tclientId={ blockClientId }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\thideDragHandle={ hideDragHandle }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t{ ! hasContentOnlyLocking &&\n\t\t\t\t\tshouldShowVisualToolbar &&\n\t\t\t\t\tisMultiToolbar &&\n\t\t\t\t\tshowGroupButtons && <BlockGroupToolbar /> }\n\t\t\t\t{ showShuffleButton && (\n\t\t\t\t\t<ChangeDesign clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t) }\n\t\t\t\t{ showSwitchSectionStyleButton && (\n\t\t\t\t\t<SwitchSectionStyle clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t) }\n\t\t\t\t{ shouldShowVisualToolbar && showSlots && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ ! isSectionContainer && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport default function BlockToolbar( { hideDragHandle, variant } ) {\n\treturn (\n\t\t<PrivateBlockToolbar\n\t\t\thideDragHandle={ hideDragHandle }\n\t\t\tvariant={ variant }\n\t\t\tfocusOnMount={ undefined }\n\t\t\t__experimentalInitialIndex={ undefined }\n\t\t\t__experimentalOnIndexChange={ undefined }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,kBAA0B;AAC1B,qBAAuB;AACvB,qBAAiC;AACjC,oBAKO;AACP,wBAA6B;AAK7B,yBAAuB;AACvB,mCAAgC;AAChC,4BAA0B;AAC1B,qCAA2C;AAC3C,iCAA8B;AAC9B,wBAAiC;AACjC,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tgetBlockType,\n\thasBlockSupport,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { ViewportVisibilityToolbar } from '../block-visibility';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowHoveredOrFocusedGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport NavigableToolbar from '../navigable-toolbar';\nimport { useHasBlockToolbar } from './use-has-block-toolbar';\nimport ChangeDesign from './change-design';\nimport SwitchSectionStyle from './switch-section-style';\nimport { unlock } from '../../lock-unlock';\nimport BlockToolbarIcon from './block-toolbar-icon';\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {boolean} props.focusOnMount Focus the toolbar when mounted.\n * @param {number} props.__experimentalInitialIndex The initial index of the toolbar item to focus.\n * @param {Function} props.__experimentalOnIndexChange Callback function to be called when the index of the focused toolbar item changes.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport function PrivateBlockToolbar( {\n\thideDragHandle,\n\tfocusOnMount,\n\t__experimentalInitialIndex,\n\t__experimentalOnIndexChange,\n\tvariant = 'unstyled',\n} ) {\n\tconst {\n\t\tblockClientId,\n\t\tblockClientIds,\n\t\tisDefaultEditingMode,\n\t\tblockType,\n\t\ttoolbarKey,\n\t\tshouldShowVisualToolbar,\n\t\tshowParentSelector,\n\t\tisUsingBindings,\n\t\tisSectionContainer,\n\t\thasContentOnlyLocking,\n\t\tshowShuffleButton,\n\t\tshowSlots,\n\t\tshowGroupButtons,\n\t\tshowLockButtons,\n\t\tshowBlockVisibilityButton,\n\t\tshowSwitchSectionStyleButton,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockMode,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisBlockValid,\n\t\t\tgetBlockEditingMode,\n\t\t\tgetBlockAttributes,\n\t\t\tgetTemplateLock,\n\t\t\tgetParentSectionBlock,\n\t\t\tisZoomOut,\n\t\t\tisSectionBlock,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\tconst parentSection = getParentSectionBlock( selectedBlockClientId );\n\t\tconst parentClientId = parentSection ?? parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\t\tconst editingMode = getBlockEditingMode( selectedBlockClientId );\n\t\tconst _isDefaultEditingMode = editingMode === 'default';\n\t\tconst _blockName = getBlockName( selectedBlockClientId );\n\t\tconst isValid = selectedBlockClientIds.every( ( id ) =>\n\t\t\tisBlockValid( id )\n\t\t);\n\t\tconst isVisual = selectedBlockClientIds.every(\n\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t);\n\t\tconst _isUsingBindings = selectedBlockClientIds.every(\n\t\t\t( clientId ) =>\n\t\t\t\t!! getBlockAttributes( clientId )?.metadata?.bindings\n\t\t);\n\n\t\t// If one or more selected blocks are locked, do not show the BlockGroupToolbar.\n\t\tconst _hasTemplateLock = selectedBlockClientIds.some(\n\t\t\t( id ) => getTemplateLock( id ) === 'contentOnly'\n\t\t);\n\n\t\tconst _isZoomOut = isZoomOut();\n\n\t\tconst _isSectionBlock = isSectionBlock( selectedBlockClientId );\n\n\t\t// The switch style button appears more prominently with the\n\t\t// content only pattern experiment.\n\t\tconst _showSwitchSectionStyleButton =\n\t\t\twindow?.__experimentalContentOnlyPatternInsertion &&\n\t\t\t( _isZoomOut || _isSectionBlock );\n\n\t\treturn {\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\tisDefaultEditingMode: _isDefaultEditingMode,\n\t\t\tblockType: selectedBlockClientId && getBlockType( _blockName ),\n\t\t\tshouldShowVisualToolbar: isValid && isVisual,\n\t\t\ttoolbarKey: `${ selectedBlockClientId }${ parentClientId }`,\n\t\t\tshowParentSelector:\n\t\t\t\t! _isZoomOut &&\n\t\t\t\tparentBlockType &&\n\t\t\t\teditingMode !== 'contentOnly' &&\n\t\t\t\tgetBlockEditingMode( parentClientId ) !== 'disabled' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length === 1,\n\t\t\tisUsingBindings: _isUsingBindings,\n\t\t\tisSectionContainer: _isSectionBlock,\n\t\t\thasContentOnlyLocking: _hasTemplateLock,\n\t\t\tshowShuffleButton: _isZoomOut,\n\t\t\tshowSlots: ! _isZoomOut,\n\t\t\tshowGroupButtons: ! _isZoomOut,\n\t\t\tshowLockButtons: ! _isZoomOut,\n\t\t\tshowBlockVisibilityButton: ! _isZoomOut,\n\t\t\tshowSwitchSectionStyleButton: _showSwitchSectionStyleButton,\n\t\t};\n\t}, [] );\n\n\tconst toolbarWrapperRef = useRef( null );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst nodeRef = useRef();\n\tconst showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {\n\t\tref: nodeRef,\n\t} );\n\n\tconst isLargeViewport = ! useViewportMatch( 'medium', '<' );\n\n\tconst hasBlockToolbar = useHasBlockToolbar();\n\tif ( ! hasBlockToolbar ) {\n\t\treturn null;\n\t}\n\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\tconst isSynced =\n\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = clsx( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': showParentSelector,\n\t} );\n\n\tconst innerClasses = clsx( 'block-editor-block-toolbar', {\n\t\t'is-synced': isSynced,\n\t\t'is-connected': isUsingBindings,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusEditorOnEscape\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t// The variant is applied as \"toolbar\" when undefined, which is the black border style of the dropdown from the toolbar popover.\n\t\t\tvariant={ variant === 'toolbar' ? undefined : variant }\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\t__experimentalInitialIndex={ __experimentalInitialIndex }\n\t\t\t__experimentalOnIndexChange={ __experimentalOnIndexChange }\n\t\t\t// Resets the index whenever the active block changes so\n\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\tkey={ toolbarKey }\n\t\t>\n\t\t\t<div ref={ toolbarWrapperRef } className={ innerClasses }>\n\t\t\t\t{ showParentSelector && ! isMultiToolbar && isLargeViewport && (\n\t\t\t\t\t<BlockParentSelector />\n\t\t\t\t) }\n\t\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) && (\n\t\t\t\t\t<div ref={ nodeRef } { ...showHoveredOrFocusedGestures }>\n\t\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t\t<BlockToolbarIcon\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\tisSynced={ isSynced }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isDefaultEditingMode &&\n\t\t\t\t\t\t\t\tshowBlockVisibilityButton && (\n\t\t\t\t\t\t\t\t\t<ViewportVisibilityToolbar\n\t\t\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! isMultiToolbar &&\n\t\t\t\t\t\t\t\tisDefaultEditingMode &&\n\t\t\t\t\t\t\t\tshowLockButtons && (\n\t\t\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\t\t\tclientId={ blockClientId }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\thideDragHandle={ hideDragHandle }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t{ ! hasContentOnlyLocking &&\n\t\t\t\t\tshouldShowVisualToolbar &&\n\t\t\t\t\tisMultiToolbar &&\n\t\t\t\t\tshowGroupButtons && <BlockGroupToolbar /> }\n\t\t\t\t{ showShuffleButton && (\n\t\t\t\t\t<ChangeDesign clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t) }\n\t\t\t\t{ showSwitchSectionStyleButton && (\n\t\t\t\t\t<SwitchSectionStyle clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t) }\n\t\t\t\t{ shouldShowVisualToolbar && showSlots && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ ! isSectionContainer && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport default function BlockToolbar( { hideDragHandle, variant } ) {\n\treturn (\n\t\t<PrivateBlockToolbar\n\t\t\thideDragHandle={ hideDragHandle }\n\t\t\tvariant={ variant }\n\t\t\tfocusOnMount={ undefined }\n\t\t\t__experimentalInitialIndex={ undefined }\n\t\t\t__experimentalOnIndexChange={ undefined }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,kBAA0B;AAC1B,qBAAuB;AACvB,qBAAiC;AACjC,oBAKO;AACP,wBAA6B;AAK7B,yBAAuB;AACvB,mCAAgC;AAChC,4BAA0B;AAC1B,qCAA2C;AAC3C,iCAA8B;AAC9B,wBAAiC;AACjC,8BAA0C;AAC1C,sCAAkC;AAClC,wCAAoC;AACpC,mBAAgD;AAChD,mBAA0C;AAC1C,+BAA6B;AAC7B,mCAAmC;AACnC,2BAAyB;AACzB,kCAA+B;AAC/B,yBAAuB;AACvB,gCAA6B;AAqKxB;AAvJE,SAAS,oBAAqB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AACX,GAAI;AACH,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,CAAE,WAAY;AAC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AAC,SAAA,EAAkB,WAAY,gBAAiB;AAAA,SACjD;AAAA;AAAA,IAvEM;AAAA,EAwEP;AAEF;AAWe,SAAR,aAA+B,EAAE,gBAAgB,QAAQ,GAAI;AACnE,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAe;AAAA,MACf,4BAA6B;AAAA,MAC7B,6BAA8B;AAAA;AAAA,EAC/B;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "clsx", "NavigableToolbar", "BlockParentSelector", "BlockToolbarIcon", "BlockMover", "ChangeDesign", "SwitchSectionStyle", "BlockControls", "__unstableBlockToolbarLastItem", "BlockEditVisuallyButton", "BlockSettingsMenu"]
|
|
7
7
|
}
|
|
@@ -52,7 +52,6 @@ var import_use_show_block_tools = require("./use-show-block-tools.cjs");
|
|
|
52
52
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
53
53
|
var import_use_paste_styles = __toESM(require("../use-paste-styles/index.cjs"));
|
|
54
54
|
var import_block_visibility = require("../block-visibility/index.cjs");
|
|
55
|
-
var import_utils = require("../../hooks/utils.cjs");
|
|
56
55
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
57
56
|
function selector(select) {
|
|
58
57
|
const {
|
|
@@ -100,8 +99,7 @@ function BlockTools({
|
|
|
100
99
|
moveBlocksUp,
|
|
101
100
|
moveBlocksDown,
|
|
102
101
|
expandBlock,
|
|
103
|
-
stopEditingContentOnlySection
|
|
104
|
-
updateBlockAttributes
|
|
102
|
+
stopEditingContentOnlySection
|
|
105
103
|
} = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store));
|
|
106
104
|
function onKeyDown(event) {
|
|
107
105
|
if (event.defaultPrevented) {
|
|
@@ -202,29 +200,7 @@ function BlockTools({
|
|
|
202
200
|
if (!supportsBlockVisibility) {
|
|
203
201
|
return;
|
|
204
202
|
}
|
|
205
|
-
|
|
206
|
-
setVisibilityModalClientIds(clientIds);
|
|
207
|
-
} else {
|
|
208
|
-
const hasHiddenBlock = blocks.some(
|
|
209
|
-
(block) => block.attributes.metadata?.blockVisibility === false
|
|
210
|
-
);
|
|
211
|
-
const attributesByClientId = Object.fromEntries(
|
|
212
|
-
blocks.map(
|
|
213
|
-
({ clientId: mapClientId, attributes }) => [
|
|
214
|
-
mapClientId,
|
|
215
|
-
{
|
|
216
|
-
metadata: (0, import_utils.cleanEmptyObject)({
|
|
217
|
-
...attributes?.metadata,
|
|
218
|
-
blockVisibility: hasHiddenBlock ? void 0 : false
|
|
219
|
-
})
|
|
220
|
-
}
|
|
221
|
-
]
|
|
222
|
-
)
|
|
223
|
-
);
|
|
224
|
-
updateBlockAttributes(clientIds, attributesByClientId, {
|
|
225
|
-
uniqueByBlock: true
|
|
226
|
-
});
|
|
227
|
-
}
|
|
203
|
+
setVisibilityModalClientIds(clientIds);
|
|
228
204
|
}
|
|
229
205
|
}
|
|
230
206
|
if (isMatch("core/block-editor/stop-editing-as-blocks", event)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-tools/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\tswitchToBlockType,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\nimport usePasteStyles from '../use-paste-styles';\nimport { BlockVisibilityModal } from '../block-visibility';\nimport { cleanEmptyObject } from '../../hooks/utils';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =\n\t\tuseSelect( selector, [] );\n\tconst [ visibilityModalClientIds, setVisibilityModalClientIds ] =\n\t\tuseState( null );\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tisGroupable,\n\t\tgetEditedContentOnlySection,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\tconst pasteStyles = usePasteStyles();\n\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t\tstopEditingContentOnlySection,\n\t\tupdateBlockAttributes,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tpasteStyles( blocks );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst supportsBlockVisibility = blocks.every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, 'visibility', true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! supportsBlockVisibility ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( window.__experimentalHideBlocksBasedOnScreenSize ) {\n\t\t\t\t\t// Open the visibility breakpoints modal.\n\t\t\t\t\tsetVisibilityModalClientIds( clientIds );\n\t\t\t\t} else {\n\t\t\t\t\tconst hasHiddenBlock = blocks.some(\n\t\t\t\t\t\t( block ) =>\n\t\t\t\t\t\t\tblock.attributes.metadata?.blockVisibility === false\n\t\t\t\t\t);\n\t\t\t\t\tconst attributesByClientId = Object.fromEntries(\n\t\t\t\t\t\tblocks.map(\n\t\t\t\t\t\t\t( { clientId: mapClientId, attributes } ) => [\n\t\t\t\t\t\t\t\tmapClientId,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\t\t\tblockVisibility: hasHiddenBlock\n\t\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tupdateBlockAttributes( clientIds, attributesByClientId, {\n\t\t\t\t\t\tuniqueByBlock: true,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Has the same keyboard shortcut as 'unselect', so can't be within the\n\t\t// if/else chain above.\n\t\tif ( isMatch( 'core/block-editor/stop-editing-as-blocks', event ) ) {\n\t\t\tif ( getEditedContentOnlySection() ) {\n\t\t\t\tstopEditingContentOnlySection();\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\t// Popover slots cannot be unmounted during dragging because the\n\t\t\t// will just be rendered in a fallback popover slot instead.\n\t\t\tclassName={ clsx( props.className, {\n\t\t\t\t'block-editor-block-tools--is-dragging': isDragging,\n\t\t\t} ) }\n\t\t>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t\t{ visibilityModalClientIds && (\n\t\t\t\t<BlockVisibilityModal\n\t\t\t\t\tclientIds={ visibilityModalClientIds }\n\t\t\t\t\tonClose={ () => setVisibilityModalClientIds( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAuC;AACvC,iBAA4B;AAC5B,wBAAwB;AACxB,gCAAyE;AACzE,qBAAiC;AACjC,oBAIO;AACP,kBAAsB;AACtB,kBAAgC;AAKhC,kCAA+B;AAC/B,6BAGO;AACP,mCAAgC;AAChC,mBAA0C;AAC1C,gCAA6B;AAC7B,qCAAiC;AACjC,kCAAkC;AAClC,yBAAuB;AACvB,8BAA2B;AAC3B,8BAAqC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\tswitchToBlockType,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\nimport usePasteStyles from '../use-paste-styles';\nimport { BlockVisibilityModal } from '../block-visibility';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =\n\t\tuseSelect( selector, [] );\n\tconst [ visibilityModalClientIds, setVisibilityModalClientIds ] =\n\t\tuseState( null );\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tisGroupable,\n\t\tgetEditedContentOnlySection,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\tconst pasteStyles = usePasteStyles();\n\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t\tstopEditingContentOnlySection,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tpasteStyles( blocks );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst supportsBlockVisibility = blocks.every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, 'visibility', true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! supportsBlockVisibility ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Open the visibility breakpoints modal.\n\t\t\t\tsetVisibilityModalClientIds( clientIds );\n\t\t\t}\n\t\t}\n\n\t\t// Has the same keyboard shortcut as 'unselect', so can't be within the\n\t\t// if/else chain above.\n\t\tif ( isMatch( 'core/block-editor/stop-editing-as-blocks', event ) ) {\n\t\t\tif ( getEditedContentOnlySection() ) {\n\t\t\t\tstopEditingContentOnlySection();\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\t// Popover slots cannot be unmounted during dragging because the\n\t\t\t// will just be rendered in a fallback popover slot instead.\n\t\t\tclassName={ clsx( props.className, {\n\t\t\t\t'block-editor-block-tools--is-dragging': isDragging,\n\t\t\t} ) }\n\t\t>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t\t{ visibilityModalClientIds && (\n\t\t\t\t<BlockVisibilityModal\n\t\t\t\t\tclientIds={ visibilityModalClientIds }\n\t\t\t\t\tonClose={ () => setVisibilityModalClientIds( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAuC;AACvC,iBAA4B;AAC5B,wBAAwB;AACxB,gCAAyE;AACzE,qBAAiC;AACjC,oBAIO;AACP,kBAAsB;AACtB,kBAAgC;AAKhC,kCAA+B;AAC/B,6BAGO;AACP,mCAAgC;AAChC,mBAA0C;AAC1C,gCAA6B;AAC7B,qCAAiC;AACjC,kCAAkC;AAClC,yBAAuB;AACvB,8BAA2B;AAC3B,8BAAqC;AA6NlC;AA3NH,SAAS,SAAU,QAAS;AAC3B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAiB,CAAE;AAEvC,QAAM,WACL,yBAAyB,KAAK,mCAAmC;AAElE,SAAO;AAAA,IACN;AAAA,IACA,iBAAiB,YAAY,EAAE;AAAA,IAC/B,UAAU,SAAS;AAAA,IACnB,eAAe,UAAU;AAAA,I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ACD;AAAA,YAGC,8BACD;AAAA,cAAC,4BAAAC;AAAA,cAAA;AAAA,gBACA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA,YAGC,2BACD;AAAA,cAAC,6BAAAC;AAAA,cAAA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA,YAIC,CAAE,iBAAiB,CAAE,mBACtB;AAAA,cAAC,0BAAQ;AAAA,cAAR;AAAA,gBACA,MAAK;AAAA,gBACL,KAAM;AAAA;AAAA,YACP;AAAA,YAEC;AAAA,YAEF;AAAA,cAAC,0BAAQ;AAAA,cAAR;AAAA,gBACA,MAAK;AAAA,gBACL,KAAM;AAAA;AAAA,YACP;AAAA,YACE,iBAAiB,CAAE,cACpB;AAAA,cAAC,+BAAAC;AAAA,cAAA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA,aAEF;AAAA,UACE,4BACD;AAAA,YAAC;AAAA;AAAA,cACA,WAAY;AAAA,cACZ,SAAU,MAAM,4BAA6B,IAAK;AAAA;AAAA,UACnD;AAAA;AAAA;AAAA,IAEF;AAAA;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "useShortcutEventMatch", "blocksStore", "usePasteStyles", "usePopoverScroll", "clsx", "InsertionPoint", "EmptyBlockInserter", "BlockToolbarPopover", "ZoomOutModeInserters"]
|
|
7
7
|
}
|
|
@@ -30,26 +30,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// packages/block-editor/src/components/block-visibility/index.js
|
|
31
31
|
var block_visibility_exports = {};
|
|
32
32
|
__export(block_visibility_exports, {
|
|
33
|
-
BlockVisibilityMenuItem: () => BlockVisibilityMenuItem,
|
|
34
33
|
BlockVisibilityModal: () => import_modal.default,
|
|
35
|
-
|
|
34
|
+
BlockVisibilityViewportMenuItem: () => import_viewport_menu_item.default,
|
|
35
|
+
ViewportVisibilityInfo: () => import_viewport_visibility_info.default,
|
|
36
|
+
ViewportVisibilityToolbar: () => import_viewport_toolbar.default,
|
|
36
37
|
useBlockVisibility: () => import_use_block_visibility.default
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(block_visibility_exports);
|
|
39
40
|
var import_modal = __toESM(require("./modal.cjs"));
|
|
40
41
|
var import_use_block_visibility = __toESM(require("./use-block-visibility.cjs"));
|
|
41
|
-
var import_toolbar = __toESM(require("./toolbar.cjs"));
|
|
42
42
|
var import_viewport_toolbar = __toESM(require("./viewport-toolbar.cjs"));
|
|
43
|
-
var import_menu_item = __toESM(require("./menu-item.cjs"));
|
|
44
43
|
var import_viewport_menu_item = __toESM(require("./viewport-menu-item.cjs"));
|
|
45
|
-
var
|
|
46
|
-
var BlockVisibilityMenuItem = hasViewportVisibilityExperiment ? import_viewport_menu_item.default : import_menu_item.default;
|
|
47
|
-
var BlockVisibilityToolbar = hasViewportVisibilityExperiment ? import_viewport_toolbar.default : import_toolbar.default;
|
|
44
|
+
var import_viewport_visibility_info = __toESM(require("./viewport-visibility-info.cjs"));
|
|
48
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
46
|
0 && (module.exports = {
|
|
50
|
-
BlockVisibilityMenuItem,
|
|
51
47
|
BlockVisibilityModal,
|
|
52
|
-
|
|
48
|
+
BlockVisibilityViewportMenuItem,
|
|
49
|
+
ViewportVisibilityInfo,
|
|
50
|
+
ViewportVisibilityToolbar,
|
|
53
51
|
useBlockVisibility
|
|
54
52
|
});
|
|
55
53
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-visibility/index.js"],
|
|
4
|
-
"sourcesContent": ["export { default as BlockVisibilityModal } from './modal';\nexport { default as useBlockVisibility } from './use-block-visibility';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAChD,kCAA8C;
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["export { default as BlockVisibilityModal } from './modal';\nexport { default as useBlockVisibility } from './use-block-visibility';\nexport { default as ViewportVisibilityToolbar } from './viewport-toolbar';\nexport { default as BlockVisibilityViewportMenuItem } from './viewport-menu-item';\nexport { default as ViewportVisibilityInfo } from './viewport-visibility-info';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAChD,kCAA8C;AAC9C,8BAAqD;AACrD,gCAA2D;AAC3D,sCAAkD;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -196,7 +196,7 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
196
196
|
return (0, import_i18n.sprintf)(
|
|
197
197
|
// translators: %s: The shortcut key to access the List View.
|
|
198
198
|
(0, import_i18n.__)(
|
|
199
|
-
"Block visibility settings
|
|
199
|
+
"Block visibility settings updated. You can access them via the List View (%s)."
|
|
200
200
|
),
|
|
201
201
|
listViewShortcut
|
|
202
202
|
);
|
|
@@ -231,15 +231,17 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
231
231
|
const handleSubmit = (0, import_element.useCallback)(
|
|
232
232
|
(event) => {
|
|
233
233
|
event.preventDefault();
|
|
234
|
-
const newVisibility = hideEverywhere ? false :
|
|
235
|
-
(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
234
|
+
const newVisibility = hideEverywhere ? false : {
|
|
235
|
+
viewport: import_constants.BLOCK_VISIBILITY_VIEWPORT_ENTRIES.reduce(
|
|
236
|
+
(acc, [, { key }]) => {
|
|
237
|
+
if (viewportChecked[key]) {
|
|
238
|
+
acc[key] = false;
|
|
239
|
+
}
|
|
240
|
+
return acc;
|
|
241
|
+
},
|
|
242
|
+
{}
|
|
243
|
+
)
|
|
244
|
+
};
|
|
243
245
|
const attributesByClientId = Object.fromEntries(
|
|
244
246
|
blocks.map(({ clientId, attributes }) => [
|
|
245
247
|
clientId,
|
|
@@ -255,7 +257,7 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
255
257
|
uniqueByBlock: true
|
|
256
258
|
});
|
|
257
259
|
createSuccessNotice(noticeMessage, {
|
|
258
|
-
id: hideEverywhere ? "block-visibility-hidden" : "block-visibility-viewports-
|
|
260
|
+
id: hideEverywhere ? "block-visibility-hidden" : "block-visibility-viewports-updated",
|
|
259
261
|
type: "snackbar"
|
|
260
262
|
});
|
|
261
263
|
onClose();
|