@wordpress/block-editor 8.5.0 → 8.6.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-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-lock/index.js +8 -0
- package/build/components/block-lock/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +5 -20
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +33 -12
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +7 -20
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +50 -0
- package/build/components/block-lock/use-block-lock.js.map +1 -0
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +37 -22
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +82 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-preview/auto.js +6 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +4 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -2
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/copy-handler/index.js +44 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/link-control/index.js +6 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -10
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +66 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +8 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +36 -31
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +131 -6
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +27 -0
- package/build/store/utils.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-lock/index.js +1 -0
- package/build-module/components/block-lock/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +4 -18
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +31 -12
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +6 -18
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +41 -0
- package/build-module/components/block-lock/use-block-lock.js.map +1 -0
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +39 -24
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +67 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-preview/auto.js +6 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +7 -2
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/copy-handler/index.js +44 -9
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/link-control/index.js +6 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -9
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +13 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +63 -16
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +19 -16
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +120 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +20 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-style/style-rtl.css +145 -272
- package/build-style/style.css +145 -272
- package/package.json +28 -28
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-lock/index.js +1 -0
- package/src/components/block-lock/menu-item.js +3 -23
- package/src/components/block-lock/modal.js +37 -13
- package/src/components/block-lock/style.scss +1 -2
- package/src/components/block-lock/toolbar.js +4 -21
- package/src/components/block-lock/use-block-lock.js +45 -0
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-pattern-setup/index.js +84 -59
- package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
- package/src/components/block-pattern-setup/style.scss +32 -26
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +73 -0
- package/src/components/block-popover/style.scss +24 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-preview/auto.js +10 -1
- package/src/components/block-preview/index.js +2 -0
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/index.js +13 -1
- package/src/components/block-switcher/style.scss +4 -4
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/copy-handler/index.js +52 -10
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +24 -3
- package/src/components/link-control/index.js +5 -5
- package/src/components/list-view/block-select-button.js +2 -10
- package/src/components/list-view/block.js +16 -7
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/duotone.js +98 -62
- package/src/hooks/index.js +2 -1
- package/src/hooks/use-border-props.js +15 -32
- package/src/index.js +1 -0
- package/src/store/actions.js +19 -15
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +160 -5
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +0 -19
- package/src/store/utils.js +19 -0
- package/src/style.scss +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -15,16 +15,12 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
15
15
|
|
|
16
16
|
var _blocks = require("@wordpress/blocks");
|
|
17
17
|
|
|
18
|
-
var _components = require("@wordpress/components");
|
|
19
|
-
|
|
20
18
|
var _data = require("@wordpress/data");
|
|
21
19
|
|
|
22
20
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
23
21
|
|
|
24
22
|
var _compose = require("@wordpress/compose");
|
|
25
23
|
|
|
26
|
-
var _dom = require("@wordpress/dom");
|
|
27
|
-
|
|
28
24
|
var _blockSelectionButton = _interopRequireDefault(require("./block-selection-button"));
|
|
29
25
|
|
|
30
26
|
var _blockContextualToolbar = _interopRequireDefault(require("./block-contextual-toolbar"));
|
|
@@ -33,9 +29,7 @@ var _inserter = _interopRequireDefault(require("../inserter"));
|
|
|
33
29
|
|
|
34
30
|
var _store = require("../../store");
|
|
35
31
|
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var _usePopoverScroll = require("./use-popover-scroll");
|
|
32
|
+
var _blockPopover = _interopRequireDefault(require("../block-popover"));
|
|
39
33
|
|
|
40
34
|
/**
|
|
41
35
|
* External dependencies
|
|
@@ -54,7 +48,6 @@ function selector(select) {
|
|
|
54
48
|
isMultiSelecting,
|
|
55
49
|
hasMultiSelection,
|
|
56
50
|
isTyping,
|
|
57
|
-
isCaretWithinFormattedText,
|
|
58
51
|
getSettings,
|
|
59
52
|
getLastMultiSelectedBlockClientId
|
|
60
53
|
} = select(_store.store);
|
|
@@ -62,18 +55,15 @@ function selector(select) {
|
|
|
62
55
|
isNavigationMode: isNavigationMode(),
|
|
63
56
|
isMultiSelecting: isMultiSelecting(),
|
|
64
57
|
isTyping: isTyping(),
|
|
65
|
-
isCaretWithinFormattedText: isCaretWithinFormattedText(),
|
|
66
|
-
hasMultiSelection: hasMultiSelection(),
|
|
67
58
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
68
|
-
lastClientId: getLastMultiSelectedBlockClientId()
|
|
59
|
+
lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null
|
|
69
60
|
};
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
function
|
|
63
|
+
function SelectedBlockPopover(_ref) {
|
|
73
64
|
let {
|
|
74
65
|
clientId,
|
|
75
66
|
rootClientId,
|
|
76
|
-
isValid,
|
|
77
67
|
isEmptyDefaultBlock,
|
|
78
68
|
capturingClientId,
|
|
79
69
|
__unstablePopoverSlot,
|
|
@@ -83,8 +73,6 @@ function BlockPopover(_ref) {
|
|
|
83
73
|
isNavigationMode,
|
|
84
74
|
isMultiSelecting,
|
|
85
75
|
isTyping,
|
|
86
|
-
isCaretWithinFormattedText,
|
|
87
|
-
hasMultiSelection,
|
|
88
76
|
hasFixedToolbar,
|
|
89
77
|
lastClientId
|
|
90
78
|
} = (0, _data.useSelect)(selector, []);
|
|
@@ -104,108 +92,49 @@ function BlockPopover(_ref) {
|
|
|
104
92
|
return order[insertionPoint.index] === clientId;
|
|
105
93
|
}, [clientId]);
|
|
106
94
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
107
|
-
const
|
|
95
|
+
const isToolbarForced = (0, _element.useRef)(false);
|
|
108
96
|
const [isInserterShown, setIsInserterShown] = (0, _element.useState)(false);
|
|
109
97
|
const {
|
|
110
98
|
stopTyping
|
|
111
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
|
|
99
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
100
|
+
const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock;
|
|
115
101
|
const shouldShowBreadcrumb = isNavigationMode;
|
|
116
|
-
const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !
|
|
102
|
+
const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !isMultiSelecting && !showEmptyBlockSideInserter && !isTyping;
|
|
117
103
|
const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
|
|
118
104
|
(0, _keyboardShortcuts.useShortcut)('core/block-editor/focus-toolbar', () => {
|
|
119
|
-
|
|
105
|
+
isToolbarForced.current = true;
|
|
120
106
|
stopTyping(true);
|
|
121
107
|
}, {
|
|
122
108
|
isDisabled: !canFocusHiddenToolbar
|
|
123
109
|
});
|
|
124
110
|
(0, _element.useEffect)(() => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
}, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
|
|
111
|
+
isToolbarForced.current = false;
|
|
112
|
+
}); // Stores the active toolbar item index so the block toolbar can return focus
|
|
129
113
|
// to it when re-mounting.
|
|
130
114
|
|
|
131
115
|
const initialToolbarItemIndexRef = (0, _element.useRef)();
|
|
132
|
-
const selectedElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
|
|
133
|
-
const lastSelectedElement = (0, _useBlockRefs.__unstableUseBlockElement)(lastClientId);
|
|
134
|
-
const capturingElement = (0, _useBlockRefs.__unstableUseBlockElement)(capturingClientId);
|
|
135
|
-
const popoverScrollRef = (0, _usePopoverScroll.usePopoverScroll)(__unstableContentRef);
|
|
136
116
|
|
|
137
|
-
if (!shouldShowBreadcrumb && !shouldShowContextualToolbar
|
|
117
|
+
if (!shouldShowBreadcrumb && !shouldShowContextualToolbar) {
|
|
138
118
|
return null;
|
|
139
119
|
}
|
|
140
120
|
|
|
141
|
-
let node = selectedElement;
|
|
142
|
-
|
|
143
|
-
if (!node) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (capturingClientId) {
|
|
148
|
-
node = capturingElement;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
let anchorRef = node;
|
|
152
|
-
|
|
153
|
-
if (hasMultiSelection) {
|
|
154
|
-
// Wait to render the popover until the bottom reference is available
|
|
155
|
-
// as well.
|
|
156
|
-
if (!lastSelectedElement) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
anchorRef = {
|
|
161
|
-
top: node,
|
|
162
|
-
bottom: lastSelectedElement
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
121
|
function onFocus() {
|
|
167
122
|
setIsInserterShown(true);
|
|
168
123
|
}
|
|
169
124
|
|
|
170
125
|
function onBlur() {
|
|
171
126
|
setIsInserterShown(false);
|
|
172
|
-
}
|
|
173
|
-
// left corner. For the side inserter, pop out towards the left, and
|
|
174
|
-
// position in the right corner.
|
|
175
|
-
// To do: refactor `Popover` to make this prop clearer.
|
|
176
|
-
|
|
127
|
+
}
|
|
177
128
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
} = node;
|
|
182
|
-
const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
|
|
183
|
-
// the block toolbar becomes sticky when the block scolls out of view.
|
|
184
|
-
// In case of an iframe, this should be the iframe boundary, otherwise
|
|
185
|
-
// the scroll container.
|
|
186
|
-
ownerDocument.defaultView.frameElement || (0, _dom.getScrollContainer)(node) || ownerDocument.body;
|
|
187
|
-
return (0, _element.createElement)(_components.Popover, {
|
|
188
|
-
ref: popoverScrollRef,
|
|
189
|
-
noArrow: true,
|
|
190
|
-
animate: false,
|
|
191
|
-
position: popoverPosition,
|
|
192
|
-
focusOnMount: false,
|
|
193
|
-
anchorRef: anchorRef,
|
|
129
|
+
return (0, _element.createElement)(_blockPopover.default, {
|
|
130
|
+
clientId: capturingClientId || clientId,
|
|
131
|
+
bottomClientId: lastClientId,
|
|
194
132
|
className: (0, _classnames.default)('block-editor-block-list__block-popover', {
|
|
195
133
|
'is-insertion-point-visible': isInsertionPointVisible
|
|
196
134
|
}),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
__unstableSlotName: __unstablePopoverSlot || null,
|
|
201
|
-
__unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
|
|
202
|
-
,
|
|
203
|
-
__unstableObserveElement: node,
|
|
204
|
-
shouldAnchorIncludePadding: true // Used to safeguard sticky position behavior against cases where it would permanently
|
|
205
|
-
// obscure specific sections of a block.
|
|
206
|
-
,
|
|
207
|
-
__unstableEditorCanvasWrapper: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current
|
|
208
|
-
}, (shouldShowContextualToolbar || isToolbarForced) && (0, _element.createElement)("div", {
|
|
135
|
+
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
136
|
+
__unstableContentRef: __unstableContentRef
|
|
137
|
+
}, shouldShowContextualToolbar && (0, _element.createElement)("div", {
|
|
209
138
|
onFocus: onFocus,
|
|
210
139
|
onBlur: onBlur // While ideally it would be enough to capture the
|
|
211
140
|
// bubbling focus event from the Inserter, due to the
|
|
@@ -222,10 +151,10 @@ function BlockPopover(_ref) {
|
|
|
222
151
|
clientId: clientId,
|
|
223
152
|
rootClientId: rootClientId,
|
|
224
153
|
__experimentalIsQuick: true
|
|
225
|
-
})),
|
|
154
|
+
})), shouldShowContextualToolbar && (0, _element.createElement)(_blockContextualToolbar.default // If the toolbar is being shown because of being forced
|
|
226
155
|
// it should focus the toolbar right after the mount.
|
|
227
156
|
, {
|
|
228
|
-
focusOnMount: isToolbarForced,
|
|
157
|
+
focusOnMount: isToolbarForced.current,
|
|
229
158
|
__experimentalInitialIndex: initialToolbarItemIndexRef.current,
|
|
230
159
|
__experimentalOnIndexChange: index => {
|
|
231
160
|
initialToolbarItemIndexRef.current = index;
|
|
@@ -235,16 +164,8 @@ function BlockPopover(_ref) {
|
|
|
235
164
|
key: clientId
|
|
236
165
|
}), shouldShowBreadcrumb && (0, _element.createElement)(_blockSelectionButton.default, {
|
|
237
166
|
clientId: clientId,
|
|
238
|
-
rootClientId: rootClientId
|
|
239
|
-
|
|
240
|
-
}), showEmptyBlockSideInserter && (0, _element.createElement)("div", {
|
|
241
|
-
className: "block-editor-block-list__empty-block-inserter"
|
|
242
|
-
}, (0, _element.createElement)(_inserter.default, {
|
|
243
|
-
position: "bottom right",
|
|
244
|
-
rootClientId: rootClientId,
|
|
245
|
-
clientId: clientId,
|
|
246
|
-
__experimentalIsQuick: true
|
|
247
|
-
})));
|
|
167
|
+
rootClientId: rootClientId
|
|
168
|
+
}));
|
|
248
169
|
}
|
|
249
170
|
|
|
250
171
|
function wrapperSelector(select) {
|
|
@@ -264,8 +185,7 @@ function wrapperSelector(select) {
|
|
|
264
185
|
|
|
265
186
|
const {
|
|
266
187
|
name,
|
|
267
|
-
attributes = {}
|
|
268
|
-
isValid
|
|
188
|
+
attributes = {}
|
|
269
189
|
} = getBlock(clientId) || {};
|
|
270
190
|
const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId.
|
|
271
191
|
|
|
@@ -281,7 +201,6 @@ function wrapperSelector(select) {
|
|
|
281
201
|
clientId,
|
|
282
202
|
rootClientId: getBlockRootClientId(clientId),
|
|
283
203
|
name,
|
|
284
|
-
isValid,
|
|
285
204
|
isEmptyDefaultBlock: name && (0, _blocks.isUnmodifiedDefaultBlock)({
|
|
286
205
|
name,
|
|
287
206
|
attributes
|
|
@@ -305,7 +224,6 @@ function WrappedBlockPopover(_ref2) {
|
|
|
305
224
|
clientId,
|
|
306
225
|
rootClientId,
|
|
307
226
|
name,
|
|
308
|
-
isValid,
|
|
309
227
|
isEmptyDefaultBlock,
|
|
310
228
|
capturingClientId
|
|
311
229
|
} = selected;
|
|
@@ -314,14 +232,13 @@ function WrappedBlockPopover(_ref2) {
|
|
|
314
232
|
return null;
|
|
315
233
|
}
|
|
316
234
|
|
|
317
|
-
return (0, _element.createElement)(
|
|
235
|
+
return (0, _element.createElement)(SelectedBlockPopover, {
|
|
318
236
|
clientId: clientId,
|
|
319
237
|
rootClientId: rootClientId,
|
|
320
|
-
isValid: isValid,
|
|
321
238
|
isEmptyDefaultBlock: isEmptyDefaultBlock,
|
|
322
239
|
capturingClientId: capturingClientId,
|
|
323
240
|
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
324
241
|
__unstableContentRef: __unstableContentRef
|
|
325
242
|
});
|
|
326
243
|
}
|
|
327
|
-
//# sourceMappingURL=block-popover.js.map
|
|
244
|
+
//# sourceMappingURL=selected-block-popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","isInserterShown","setIsInserterShown","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","onFocus","onBlur","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAOA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOFN,MAAM,CAAEO,YAAF,CAPV;AAQA,SAAO;AACNN,IAAAA,gBAAgB,EAAEA,gBAAgB,EAD5B;AAENC,IAAAA,gBAAgB,EAAEA,gBAAgB,EAF5B;AAGNE,IAAAA,QAAQ,EAAEA,QAAQ,EAHZ;AAINI,IAAAA,eAAe,EAAEH,WAAW,GAAGG,eAJzB;AAKNC,IAAAA,YAAY,EAAEN,iBAAiB,KAC5BG,iCAAiC,EADL,GAE5B;AAPG,GAAP;AASA;;AAED,SAASI,oBAAT,OAOI;AAAA,MAP2B;AAC9BC,IAAAA,QAD8B;AAE9BC,IAAAA,YAF8B;AAG9BC,IAAAA,mBAH8B;AAI9BC,IAAAA,iBAJ8B;AAK9BC,IAAAA,qBAL8B;AAM9BC,IAAAA;AAN8B,GAO3B;AACH,QAAM;AACLf,IAAAA,gBADK;AAELC,IAAAA,gBAFK;AAGLE,IAAAA,QAHK;AAILI,IAAAA,eAJK;AAKLC,IAAAA;AALK,MAMF,qBAAWV,QAAX,EAAqB,EAArB,CANJ;AAOA,QAAM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GAAG,qBAAWd,eAAX,EAA4B,EAA5B,CAAjB;;AAEA,MAAK,CAAEc,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACLzC,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGLiC,IAAAA,IAHK;AAILhC,IAAAA,mBAJK;AAKLC,IAAAA;AALK,MAMFsC,QANJ;;AAQA,MAAK,CAAEP,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAGlC,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst [ isInserterShown, setIsInserterShown ] = useState( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\tfunction onFocus() {\n\t\tsetIsInserterShown( true );\n\t}\n\n\tfunction onBlur() {\n\t\tsetIsInserterShown( false );\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<div\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\t// While ideally it would be enough to capture the\n\t\t\t\t\t// bubbling focus event from the Inserter, due to the\n\t\t\t\t\t// characteristics of click focusing of `button`s in\n\t\t\t\t\t// Firefox and Safari, it is not reliable.\n\t\t\t\t\t//\n\t\t\t\t\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-list__block-popover-inserter',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-visible': isInserterShown,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -70,12 +70,18 @@ function useClipboardHandler() {
|
|
|
70
70
|
getBlocksByClientId,
|
|
71
71
|
getSelectedBlockClientIds,
|
|
72
72
|
hasMultiSelection,
|
|
73
|
-
getSettings
|
|
73
|
+
getSettings,
|
|
74
|
+
__unstableIsFullySelected,
|
|
75
|
+
__unstableIsSelectionCollapsed,
|
|
76
|
+
__unstableIsSelectionMergeable,
|
|
77
|
+
__unstableGetSelectedBlocksWithPartialSelection
|
|
74
78
|
} = (0, _data.useSelect)(_store.store);
|
|
75
79
|
const {
|
|
76
80
|
flashBlock,
|
|
77
81
|
removeBlocks,
|
|
78
|
-
replaceBlocks
|
|
82
|
+
replaceBlocks,
|
|
83
|
+
__unstableDeleteSelection,
|
|
84
|
+
__unstableExpandSelection
|
|
79
85
|
} = (0, _data.useDispatch)(_store.store);
|
|
80
86
|
const notifyCopy = useNotifyCopy();
|
|
81
87
|
return (0, _compose.useRefEffect)(node => {
|
|
@@ -110,20 +116,49 @@ function useClipboardHandler() {
|
|
|
110
116
|
const eventDefaultPrevented = event.defaultPrevented;
|
|
111
117
|
event.preventDefault();
|
|
112
118
|
|
|
119
|
+
const isSelectionMergeable = __unstableIsSelectionMergeable();
|
|
120
|
+
|
|
121
|
+
const shouldHandleWholeBlocks = __unstableIsSelectionCollapsed() || __unstableIsFullySelected();
|
|
122
|
+
|
|
123
|
+
const expandSelectionIsNeeded = !shouldHandleWholeBlocks && !isSelectionMergeable;
|
|
124
|
+
|
|
113
125
|
if (event.type === 'copy' || event.type === 'cut') {
|
|
114
126
|
if (selectedBlockClientIds.length === 1) {
|
|
115
127
|
flashBlock(selectedBlockClientIds[0]);
|
|
116
|
-
}
|
|
128
|
+
} // If we have a partial selection that is not mergeable, just
|
|
129
|
+
// expand the selection to the whole blocks.
|
|
130
|
+
|
|
117
131
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
if (expandSelectionIsNeeded) {
|
|
133
|
+
__unstableExpandSelection();
|
|
134
|
+
} else {
|
|
135
|
+
notifyCopy(event.type, selectedBlockClientIds);
|
|
136
|
+
let blocks; // Check if we have partial selection.
|
|
137
|
+
|
|
138
|
+
if (shouldHandleWholeBlocks) {
|
|
139
|
+
blocks = getBlocksByClientId(selectedBlockClientIds);
|
|
140
|
+
} else {
|
|
141
|
+
const [head, tail] = __unstableGetSelectedBlocksWithPartialSelection();
|
|
142
|
+
|
|
143
|
+
const inBetweenBlocks = getBlocksByClientId(selectedBlockClientIds.slice(1, selectedBlockClientIds.length - 1));
|
|
144
|
+
blocks = [head, ...inBetweenBlocks, tail];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const serialized = (0, _blocks.serialize)(blocks);
|
|
148
|
+
event.clipboardData.setData('text/plain', serialized);
|
|
149
|
+
event.clipboardData.setData('text/html', serialized);
|
|
150
|
+
}
|
|
123
151
|
}
|
|
124
152
|
|
|
125
153
|
if (event.type === 'cut') {
|
|
126
|
-
|
|
154
|
+
// We need to also check if at the start we needed to
|
|
155
|
+
// expand the selection, as in this point we might have
|
|
156
|
+
// programmatically fully selected the blocks above.
|
|
157
|
+
if (shouldHandleWholeBlocks && !expandSelectionIsNeeded) {
|
|
158
|
+
removeBlocks(selectedBlockClientIds);
|
|
159
|
+
} else {
|
|
160
|
+
__unstableDeleteSelection();
|
|
161
|
+
}
|
|
127
162
|
} else if (event.type === 'paste') {
|
|
128
163
|
if (eventDefaultPrevented) {
|
|
129
164
|
// This was likely already handled in rich-text/use-paste-handler.js.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/copy-handler/index.js"],"names":["useNotifyCopy","getBlockName","blockEditorStore","getBlockType","blocksStore","createSuccessNotice","noticesStore","eventType","selectedBlockClientIds","notice","length","clientId","title","type","useClipboardHandler","getBlocksByClientId","getSelectedBlockClientIds","hasMultiSelection","getSettings","flashBlock","removeBlocks","replaceBlocks","notifyCopy","node","handler","event","target","ownerDocument","hasSelection","contains","activeElement","eventDefaultPrevented","defaultPrevented","preventDefault","blocks","serialized","clipboardData","setData","__experimentalCanUserUseUnfilteredHTML","canUserUseUnfilteredHTML","plainText","html","HTML","mode","addEventListener","removeEventListener","CopyHandler","children"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAtBA;AACA;AACA;;AAgBA;AACA;AACA;AAIO,SAASA,aAAT,GAAyB;AAC/B,QAAM;AAAEC,IAAAA;AAAF,MAAmB,qBAAWC,YAAX,CAAzB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAmB,qBAAWC,aAAX,CAAzB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA0B,uBAAaC,cAAb,CAAhC;AAEA,SAAO,0BAAa,CAAEC,SAAF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MAAf;AAAEC,IAAAA;AAAF,GAAe;AACpC,SAAO;AAAK,IAAA,GAAG,EAAGjC,mBAAmB;AAA9B,KAAqCiC,QAArC,CAAP;AACA;AAED;AACA;AACA;;;eACeD,W","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tserialize,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useNotifyCopy() {\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\tconst { getBlockType } = useSelect( blocksStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\treturn useCallback( ( eventType, selectedBlockClientIds ) => {\n\t\tlet notice = '';\n\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\tconst clientId = selectedBlockClientIds[ 0 ];\n\t\t\tconst title = getBlockType( getBlockName( clientId ) )?.title;\n\t\t\tnotice =\n\t\t\t\teventType === 'copy'\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: Name of the block being copied, e.g. \"Paragraph\".\n\t\t\t\t\t\t\t__( 'Copied \"%s\" to clipboard.' ),\n\t\t\t\t\t\t\ttitle\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: Name of the block being cut, e.g. \"Paragraph\".\n\t\t\t\t\t\t\t__( 'Moved \"%s\" to clipboard.' ),\n\t\t\t\t\t\t\ttitle\n\t\t\t\t\t );\n\t\t} else {\n\t\t\tnotice =\n\t\t\t\teventType === 'copy'\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: %d: Number of blocks being copied.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Copied %d block to clipboard.',\n\t\t\t\t\t\t\t\t'Copied %d blocks to clipboard.',\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: %d: Number of blocks being cut.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Moved %d block to clipboard.',\n\t\t\t\t\t\t\t\t'Moved %d blocks to clipboard.',\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t );\n\t\t}\n\t\tcreateSuccessNotice( notice, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}, [] );\n}\n\nexport function useClipboardHandler() {\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t} = useSelect( blockEditorStore );\n\tconst { flashBlock, removeBlocks, replaceBlocks } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument );\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! node.contains( event.target.ownerDocument.activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst eventDefaultPrevented = event.defaultPrevented;\n\t\t\tevent.preventDefault();\n\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\tconst blocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\tconst serialized = serialize( blocks );\n\n\t\t\t\tevent.clipboardData.setData( 'text/plain', serialized );\n\t\t\t\tevent.clipboardData.setData( 'text/html', serialized );\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tif ( eventDefaultPrevented ) {\n\t\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst { plainText, html } = getPasteEventData( event );\n\t\t\t\tconst blocks = pasteHandler( {\n\t\t\t\t\tHTML: html,\n\t\t\t\t\tplainText,\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t} );\n\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\tblocks,\n\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t-1\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n\nfunction CopyHandler( { children } ) {\n\treturn <div ref={ useClipboardHandler() }>{ children }</div>;\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/copy-handler/README.md\n */\nexport default CopyHandler;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/copy-handler/index.js"],"names":["useNotifyCopy","getBlockName","blockEditorStore","getBlockType","blocksStore","createSuccessNotice","noticesStore","eventType","selectedBlockClientIds","notice","length","clientId","title","type","useClipboardHandler","getBlocksByClientId","getSelectedBlockClientIds","hasMultiSelection","getSettings","__unstableIsFullySelected","__unstableIsSelectionCollapsed","__unstableIsSelectionMergeable","__unstableGetSelectedBlocksWithPartialSelection","flashBlock","removeBlocks","replaceBlocks","__unstableDeleteSelection","__unstableExpandSelection","notifyCopy","node","handler","event","target","ownerDocument","hasSelection","contains","activeElement","eventDefaultPrevented","defaultPrevented","preventDefault","isSelectionMergeable","shouldHandleWholeBlocks","expandSelectionIsNeeded","blocks","head","tail","inBetweenBlocks","slice","serialized","clipboardData","setData","__experimentalCanUserUseUnfilteredHTML","canUserUseUnfilteredHTML","plainText","html","HTML","mode","addEventListener","removeEventListener","CopyHandler","children"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAtBA;AACA;AACA;;AAgBA;AACA;AACA;AAIO,SAASA,aAAT,GAAyB;AAC/B,QAAM;AAAEC,IAAAA;AAAF,MAAmB,qBAAWC,YAAX,CAAzB;AACA,QA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;AACLc,UAAAA,sCAAsC,EAAEC;AADnC,YAEFlC,WAAW,EAFf;AAGA,cAAM;AAAEmC,UAAAA,SAAF;AAAaC,UAAAA;AAAb,YAAsB,gCAAmBvB,KAAnB,CAA5B;AACA,cAAMY,MAAM,GAAG,0BAAc;AAC5BY,UAAAA,IAAI,EAAED,IADsB;AAE5BD,UAAAA,SAF4B;AAG5BG,UAAAA,IAAI,EAAE,QAHsB;AAI5BJ,UAAAA;AAJ4B,SAAd,CAAf;AAOA3B,QAAAA,aAAa,CACZjB,sBADY,EAEZmC,MAFY,EAGZA,MAAM,CAACjC,MAAP,GAAgB,CAHJ,EAIZ,CAAC,CAJW,CAAb;AAMA;AACD;;AAEDmB,IAAAA,IAAI,CAACI,aAAL,CAAmBwB,gBAAnB,CAAqC,MAArC,EAA6C3B,OAA7C;AACAD,IAAAA,IAAI,CAACI,aAAL,CAAmBwB,gBAAnB,CAAqC,KAArC,EAA4C3B,OAA5C;AACAD,IAAAA,IAAI,CAACI,aAAL,CAAmBwB,gBAAnB,CAAqC,OAArC,EAA8C3B,OAA9C;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACI,aAAL,CAAmByB,mBAAnB,CAAwC,MAAxC,EAAgD5B,OAAhD;AACAD,MAAAA,IAAI,CAACI,aAAL,CAAmByB,mBAAnB,CAAwC,KAAxC,EAA+C5B,OAA/C;AACAD,MAAAA,IAAI,CAACI,aAAL,CAAmByB,mBAAnB,CAAwC,OAAxC,EAAiD5B,OAAjD;AACA,KAJD;AAKA,GAlHM,EAkHJ,EAlHI,CAAP;AAmHA;;AAED,SAAS6B,WAAT,OAAqC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACpC,SAAO;AAAK,IAAA,GAAG,EAAG9C,mBAAmB;AAA9B,KAAqC8C,QAArC,CAAP;AACA;AAED;AACA;AACA;;;eACeD,W","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tserialize,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useNotifyCopy() {\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\tconst { getBlockType } = useSelect( blocksStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\treturn useCallback( ( eventType, selectedBlockClientIds ) => {\n\t\tlet notice = '';\n\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\tconst clientId = selectedBlockClientIds[ 0 ];\n\t\t\tconst title = getBlockType( getBlockName( clientId ) )?.title;\n\t\t\tnotice =\n\t\t\t\teventType === 'copy'\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: Name of the block being copied, e.g. \"Paragraph\".\n\t\t\t\t\t\t\t__( 'Copied \"%s\" to clipboard.' ),\n\t\t\t\t\t\t\ttitle\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: Name of the block being cut, e.g. \"Paragraph\".\n\t\t\t\t\t\t\t__( 'Moved \"%s\" to clipboard.' ),\n\t\t\t\t\t\t\ttitle\n\t\t\t\t\t );\n\t\t} else {\n\t\t\tnotice =\n\t\t\t\teventType === 'copy'\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: %d: Number of blocks being copied.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Copied %d block to clipboard.',\n\t\t\t\t\t\t\t\t'Copied %d blocks to clipboard.',\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: %d: Number of blocks being cut.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Moved %d block to clipboard.',\n\t\t\t\t\t\t\t\t'Moved %d blocks to clipboard.',\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t );\n\t\t}\n\t\tcreateSuccessNotice( notice, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}, [] );\n}\n\nexport function useClipboardHandler() {\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t\t__unstableIsFullySelected,\n\t\t__unstableIsSelectionCollapsed,\n\t\t__unstableIsSelectionMergeable,\n\t\t__unstableGetSelectedBlocksWithPartialSelection,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tflashBlock,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t} = useDispatch( blockEditorStore );\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument );\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! node.contains( event.target.ownerDocument.activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst eventDefaultPrevented = event.defaultPrevented;\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isSelectionMergeable = __unstableIsSelectionMergeable();\n\t\t\tconst shouldHandleWholeBlocks =\n\t\t\t\t__unstableIsSelectionCollapsed() || __unstableIsFullySelected();\n\t\t\tconst expandSelectionIsNeeded =\n\t\t\t\t! shouldHandleWholeBlocks && ! isSelectionMergeable;\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\t// If we have a partial selection that is not mergeable, just\n\t\t\t\t// expand the selection to the whole blocks.\n\t\t\t\tif ( expandSelectionIsNeeded ) {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t} else {\n\t\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\t\tlet blocks;\n\t\t\t\t\t// Check if we have partial selection.\n\t\t\t\t\tif ( shouldHandleWholeBlocks ) {\n\t\t\t\t\t\tblocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [\n\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\ttail,\n\t\t\t\t\t\t] = __unstableGetSelectedBlocksWithPartialSelection();\n\t\t\t\t\t\tconst inBetweenBlocks = getBlocksByClientId(\n\t\t\t\t\t\t\tselectedBlockClientIds.slice(\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length - 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tblocks = [ head, ...inBetweenBlocks, tail ];\n\t\t\t\t\t}\n\t\t\t\t\tconst serialized = serialize( blocks );\n\n\t\t\t\t\tevent.clipboardData.setData( 'text/plain', serialized );\n\t\t\t\t\tevent.clipboardData.setData( 'text/html', serialized );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\t// We need to also check if at the start we needed to\n\t\t\t\t// expand the selection, as in this point we might have\n\t\t\t\t// programmatically fully selected the blocks above.\n\t\t\t\tif ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {\n\t\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableDeleteSelection();\n\t\t\t\t}\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tif ( eventDefaultPrevented ) {\n\t\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst { plainText, html } = getPasteEventData( event );\n\t\t\t\tconst blocks = pasteHandler( {\n\t\t\t\t\tHTML: html,\n\t\t\t\t\tplainText,\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t} );\n\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\tblocks,\n\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t-1\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n\nfunction CopyHandler( { children } ) {\n\treturn <div ref={ useClipboardHandler() }>{ children }</div>;\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/copy-handler/README.md\n */\nexport default CopyHandler;\n"]}
|
|
@@ -13,6 +13,8 @@ var _i18n = require("@wordpress/i18n");
|
|
|
13
13
|
|
|
14
14
|
var _keycodes = require("@wordpress/keycodes");
|
|
15
15
|
|
|
16
|
+
var _icons = require("@wordpress/icons");
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* WordPress dependencies
|
|
18
20
|
*/
|
|
@@ -51,8 +53,10 @@ function DuotoneControl(_ref) {
|
|
|
51
53
|
"aria-expanded": isOpen,
|
|
52
54
|
onKeyDown: openOnArrowDown,
|
|
53
55
|
label: (0, _i18n.__)('Apply duotone filter'),
|
|
54
|
-
icon: (0, _element.createElement)(_components.DuotoneSwatch, {
|
|
56
|
+
icon: value ? (0, _element.createElement)(_components.DuotoneSwatch, {
|
|
55
57
|
values: value
|
|
58
|
+
}) : (0, _element.createElement)(_icons.Icon, {
|
|
59
|
+
icon: _icons.filter
|
|
56
60
|
})
|
|
57
61
|
});
|
|
58
62
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/duotone-control/index.js"],"names":["DuotoneControl","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","className","headerTitle","isAlternate","isOpen","onToggle","openOnArrowDown","event","keyCode","DOWN","preventDefault"],"mappings":";;;;;;;;;AAGA;;AAOA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/duotone-control/index.js"],"names":["DuotoneControl","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","className","headerTitle","isAlternate","isOpen","onToggle","openOnArrowDown","event","keyCode","DOWN","preventDefault","filter"],"mappings":";;;;;;;;;AAGA;;AAOA;;AACA;;AACA;;AAZA;AACA;AACA;AAYA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mBAHvB;AAIC,MAAA,oBAAoB,EAAGC,oBAJxB;AAKC,MAAA,KAAK,EAAGC,KALT;AAMC,MAAA,QAAQ,EAAGC;AANZ,MAND;AAhCF,IADD;AAmDA;;eAEcN,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tDuotonePicker,\n\tDuotoneSwatch,\n\tMenuGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport { Icon, filter } from '@wordpress/icons';\n\nfunction DuotoneControl( {\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ {\n\t\t\t\tclassName: 'block-editor-duotone-control__popover',\n\t\t\t\theaderTitle: __( 'Duotone' ),\n\t\t\t\tisAlternate: true,\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\tlabel={ __( 'Apply duotone filter' ) }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tvalue ? (\n\t\t\t\t\t\t\t\t<DuotoneSwatch values={ value } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Icon icon={ filter } />\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);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<MenuGroup label={ __( 'Duotone' ) }>\n\t\t\t\t\t<div className=\"block-editor-duotone-control__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Create a two-tone color effect without losing your original image.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t\t<DuotonePicker\n\t\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default DuotoneControl;\n"]}
|
|
@@ -9,6 +9,8 @@ exports.default = exports.Inserter = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _reactNative = require("react-native");
|
|
13
15
|
|
|
14
16
|
var _lodash = require("lodash");
|
|
@@ -53,14 +55,30 @@ const defaultRenderToggle = _ref => {
|
|
|
53
55
|
onToggle,
|
|
54
56
|
disabled,
|
|
55
57
|
style,
|
|
56
|
-
|
|
58
|
+
containerStyle,
|
|
59
|
+
onLongPress,
|
|
60
|
+
useExpandedMode
|
|
57
61
|
} = _ref;
|
|
58
|
-
|
|
62
|
+
// The "expanded mode" refers to the editor's appearance when no blocks
|
|
63
|
+
// are currently selected. The "add block" button has a separate style
|
|
64
|
+
// for the "expanded mode", which are added via the below "expandedModeViewProps"
|
|
65
|
+
// and "expandedModeViewText" variables.
|
|
66
|
+
const expandedModeViewProps = useExpandedMode && {
|
|
67
|
+
icon: (0, _element.createElement)(_icons.Icon, {
|
|
68
|
+
icon: _icons.plus,
|
|
69
|
+
style: style
|
|
70
|
+
}),
|
|
71
|
+
customContainerStyles: containerStyle,
|
|
72
|
+
fixedRatio: false
|
|
73
|
+
};
|
|
74
|
+
const expandedModeViewText = (0, _element.createElement)(_reactNative.Text, {
|
|
75
|
+
style: _style.default['inserter-menu__add-block-button-text']
|
|
76
|
+
}, (0, _i18n.__)('Add Blocks'));
|
|
77
|
+
return (0, _element.createElement)(_components.ToolbarButton, (0, _extends2.default)({
|
|
59
78
|
title: (0, _i18n._x)('Add block', 'Generic label for block inserter button'),
|
|
60
79
|
icon: (0, _element.createElement)(_icons.Icon, {
|
|
61
80
|
icon: _icons.plusCircleFilled,
|
|
62
|
-
style: style
|
|
63
|
-
color: style.color
|
|
81
|
+
style: style
|
|
64
82
|
}),
|
|
65
83
|
onClick: onToggle,
|
|
66
84
|
extraProps: {
|
|
@@ -71,7 +89,7 @@ const defaultRenderToggle = _ref => {
|
|
|
71
89
|
onLongPress
|
|
72
90
|
},
|
|
73
91
|
isDisabled: disabled
|
|
74
|
-
});
|
|
92
|
+
}, expandedModeViewProps), useExpandedMode && expandedModeViewText);
|
|
75
93
|
};
|
|
76
94
|
|
|
77
95
|
class Inserter extends _element.Component {
|
|
@@ -232,14 +250,16 @@ class Inserter extends _element.Component {
|
|
|
232
250
|
disabled,
|
|
233
251
|
renderToggle = defaultRenderToggle,
|
|
234
252
|
getStylesFromColorScheme,
|
|
235
|
-
showSeparator
|
|
253
|
+
showSeparator,
|
|
254
|
+
useExpandedMode
|
|
236
255
|
} = this.props;
|
|
237
256
|
|
|
238
257
|
if (showSeparator && isOpen) {
|
|
239
258
|
return (0, _element.createElement)(_insertionPoint.default, null);
|
|
240
259
|
}
|
|
241
260
|
|
|
242
|
-
const style = getStylesFromColorScheme(_style.default
|
|
261
|
+
const style = useExpandedMode ? _style.default['inserter-menu__add-block-button-icon--expanded'] : getStylesFromColorScheme(_style.default['inserter-menu__add-block-button-icon'], _style.default['inserter-menu__add-block-button-icon--dark']);
|
|
262
|
+
const containerStyle = getStylesFromColorScheme(_style.default['inserter-menu__add-block-button'], _style.default['inserter-menu__add-block-button--dark']);
|
|
243
263
|
|
|
244
264
|
const onPress = () => {
|
|
245
265
|
this.setState({
|
|
@@ -268,7 +288,9 @@ class Inserter extends _element.Component {
|
|
|
268
288
|
isOpen,
|
|
269
289
|
disabled,
|
|
270
290
|
style,
|
|
271
|
-
|
|
291
|
+
containerStyle,
|
|
292
|
+
onLongPress,
|
|
293
|
+
useExpandedMode
|
|
272
294
|
}), (0, _element.createElement)(_components.Picker, {
|
|
273
295
|
ref: instance => this.picker = instance,
|
|
274
296
|
options: this.getInsertionOptions(),
|