@wordpress/block-editor 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +1 -0
- package/build/components/block-alignment-matrix-control/index.js +1 -6
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-content-overlay/index.js +4 -82
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.native.js +64 -0
- package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build/components/block-draggable/index.native.js +484 -0
- package/build/components/block-draggable/index.native.js.map +1 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build/components/block-list/block-list-context.native.js +195 -0
- package/build/components/block-list/block-list-context.native.js.map +1 -0
- package/build/components/block-list/block-list-item-cell.native.js +67 -0
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build/components/block-list/block-list-item.native.js +12 -9
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block.native.js +26 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +75 -23
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -4
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +9 -3
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/index.native.js +17 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-popover/inbetween.js +10 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +4 -16
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +1 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -29
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +10 -3
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +149 -44
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/iframe/index.js +51 -50
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +3 -1
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/index.js +5 -14
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -1
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/link-control/constants.js +11 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-results.js +4 -3
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +4 -4
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +0 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/url-input/index.js +4 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +167 -0
- package/build/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build/components/use-on-block-drop/index.native.js +95 -0
- package/build/components/use-on-block-drop/index.native.js.map +1 -0
- package/build/components/warning/index.js +6 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +2 -7
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +14 -7
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/style.js +14 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +6 -2
- package/build/hooks/typography.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -6
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +3 -78
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.native.js +50 -0
- package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build-module/components/block-draggable/index.native.js +449 -0
- package/build-module/components/block-draggable/index.native.js.map +1 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build-module/components/block-list/block-list-context.native.js +179 -0
- package/build-module/components/block-list/block-list-context.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item.native.js +12 -9
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +25 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +72 -23
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -5
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +8 -3
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +18 -5
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +10 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +4 -15
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +1 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +2 -29
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +11 -4
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +151 -46
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/iframe/index.js +52 -51
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -1
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/index.js +1 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +1 -1
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/link-control/constants.js +5 -0
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -4
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +5 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +0 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/url-input/index.js +4 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +148 -0
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.native.js +83 -0
- package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
- package/build-module/components/warning/index.js +6 -1
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +2 -7
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +11 -6
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/style.js +15 -14
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +6 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-style/style-rtl.css +60 -174
- package/build-style/style.css +60 -174
- package/package.json +28 -28
- package/src/components/block-alignment-matrix-control/index.js +1 -5
- package/src/components/block-content-overlay/index.js +8 -95
- package/src/components/block-content-overlay/style.scss +2 -11
- package/src/components/block-draggable/draggable-chip.native.js +49 -0
- package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
- package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
- package/src/components/block-draggable/index.native.js +458 -0
- package/src/components/block-draggable/style.native.scss +19 -0
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
- package/src/components/block-list/block-list-context.native.js +175 -0
- package/src/components/block-list/block-list-item-cell.native.js +49 -0
- package/src/components/block-list/block-list-item.native.js +7 -11
- package/src/components/block-list/block.native.js +36 -8
- package/src/components/block-list/index.native.js +54 -13
- package/src/components/block-list/test/block-list-context.native.js +253 -0
- package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
- package/src/components/block-list/use-block-props/index.js +10 -5
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-mobile-toolbar/index.native.js +8 -1
- package/src/components/block-mover/index.native.js +22 -6
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +6 -0
- package/src/components/block-popover/inbetween.js +9 -1
- package/src/components/block-popover/index.js +1 -16
- package/src/components/block-popover/style.scss +1 -0
- package/src/components/block-preview/index.js +1 -4
- package/src/components/block-switcher/style.scss +2 -39
- package/src/components/block-tools/selected-block-popover.js +1 -36
- package/src/components/block-tools/style.scss +1 -12
- package/src/components/border-radius-control/input-controls.js +16 -8
- package/src/components/border-radius-control/style.scss +3 -2
- package/src/components/colors-gradients/dropdown.js +156 -62
- package/src/components/colors-gradients/style.scss +51 -23
- package/src/components/duotone-control/style.scss +1 -7
- package/src/components/iframe/index.js +62 -54
- package/src/components/image-editor/use-save-image.js +2 -1
- package/src/components/index.js +1 -2
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/style.scss +2 -1
- package/src/components/link-control/constants.js +11 -0
- package/src/components/link-control/search-results.js +4 -5
- package/src/components/link-control/use-search-handler.js +11 -5
- package/src/components/list-view/drop-indicator.js +0 -1
- package/src/components/list-view/style.scss +2 -1
- package/src/components/navigable-toolbar/index.js +12 -2
- package/src/components/preview-options/style.scss +0 -4
- package/src/components/rich-text/format-toolbar-container.js +0 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/rich-text/style.scss +2 -8
- package/src/components/url-input/index.js +3 -1
- package/src/components/use-block-drop-zone/index.native.js +173 -0
- package/src/components/use-on-block-drop/index.native.js +119 -0
- package/src/components/warning/index.js +47 -42
- package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
- package/src/components/warning/test/index.js +1 -1
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +2 -11
- package/src/hooks/border.scss +0 -48
- package/src/hooks/color-panel.js +13 -9
- package/src/hooks/color.scss +0 -62
- package/src/hooks/style.js +25 -39
- package/src/hooks/typography.js +2 -0
- package/src/style.scss +0 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/src/components/block-alignment-matrix-control/style.scss +0 -10
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
|
@@ -7,7 +7,7 @@ import classnames from 'classnames';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { useRef, useEffect } from '@wordpress/element';
|
|
11
11
|
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
13
|
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
@@ -18,7 +18,6 @@ import { useViewportMatch } from '@wordpress/compose';
|
|
|
18
18
|
*/
|
|
19
19
|
import BlockSelectionButton from './block-selection-button';
|
|
20
20
|
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
21
|
-
import Inserter from '../inserter';
|
|
22
21
|
import { store as blockEditorStore } from '../../store';
|
|
23
22
|
import BlockPopover from '../block-popover';
|
|
24
23
|
|
|
@@ -77,7 +76,6 @@ function SelectedBlockPopover( {
|
|
|
77
76
|
);
|
|
78
77
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
79
78
|
const isToolbarForced = useRef( false );
|
|
80
|
-
const [ isInserterShown, setIsInserterShown ] = useState( false );
|
|
81
79
|
const { stopTyping } = useDispatch( blockEditorStore );
|
|
82
80
|
|
|
83
81
|
const showEmptyBlockSideInserter =
|
|
@@ -119,14 +117,6 @@ function SelectedBlockPopover( {
|
|
|
119
117
|
return null;
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
function onFocus() {
|
|
123
|
-
setIsInserterShown( true );
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function onBlur() {
|
|
127
|
-
setIsInserterShown( false );
|
|
128
|
-
}
|
|
129
|
-
|
|
130
120
|
return (
|
|
131
121
|
<BlockPopover
|
|
132
122
|
clientId={ capturingClientId || clientId }
|
|
@@ -137,31 +127,6 @@ function SelectedBlockPopover( {
|
|
|
137
127
|
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
138
128
|
__unstableContentRef={ __unstableContentRef }
|
|
139
129
|
>
|
|
140
|
-
{ shouldShowContextualToolbar && (
|
|
141
|
-
<div
|
|
142
|
-
onFocus={ onFocus }
|
|
143
|
-
onBlur={ onBlur }
|
|
144
|
-
// While ideally it would be enough to capture the
|
|
145
|
-
// bubbling focus event from the Inserter, due to the
|
|
146
|
-
// characteristics of click focusing of `button`s in
|
|
147
|
-
// Firefox and Safari, it is not reliable.
|
|
148
|
-
//
|
|
149
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
|
|
150
|
-
tabIndex={ -1 }
|
|
151
|
-
className={ classnames(
|
|
152
|
-
'block-editor-block-list__block-popover-inserter',
|
|
153
|
-
{
|
|
154
|
-
'is-visible': isInserterShown,
|
|
155
|
-
}
|
|
156
|
-
) }
|
|
157
|
-
>
|
|
158
|
-
<Inserter
|
|
159
|
-
clientId={ clientId }
|
|
160
|
-
rootClientId={ rootClientId }
|
|
161
|
-
__experimentalIsQuick
|
|
162
|
-
/>
|
|
163
|
-
</div>
|
|
164
|
-
) }
|
|
165
130
|
{ shouldShowContextualToolbar && (
|
|
166
131
|
<BlockContextualToolbar
|
|
167
132
|
// If the toolbar is being shown because of being forced
|
|
@@ -42,20 +42,9 @@
|
|
|
42
42
|
left: calc(50% - #{$button-size-small * 0.5});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
.block-editor-block-list__block-popover-inserter {
|
|
46
|
-
position: absolute;
|
|
47
|
-
top: -9999em;
|
|
48
|
-
margin-bottom: $block-padding;
|
|
49
|
-
|
|
50
|
-
&.is-visible {
|
|
51
|
-
position: static;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
45
|
// Sibling inserter / "inbetweenserter".
|
|
56
46
|
.block-editor-default-block-appender,
|
|
57
|
-
.block-editor-block-list__insertion-point-inserter
|
|
58
|
-
.block-editor-block-list__block-popover-inserter {
|
|
47
|
+
.block-editor-block-list__insertion-point-inserter {
|
|
59
48
|
.block-editor-inserter__toggle.components-button.has-icon {
|
|
60
49
|
// Basic look
|
|
61
50
|
background: $gray-900;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
__experimentalUnitControl as UnitControl,
|
|
6
|
+
Tooltip,
|
|
7
|
+
} from '@wordpress/components';
|
|
5
8
|
import { __ } from '@wordpress/i18n';
|
|
6
9
|
|
|
7
10
|
const CORNERS = {
|
|
@@ -39,16 +42,21 @@ export default function BoxInputControls( {
|
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
// Controls are wrapped in tooltips as visible labels aren't desired here.
|
|
45
|
+
// Tooltip rendering also requires the UnitControl to be wrapped. See:
|
|
46
|
+
// https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026
|
|
42
47
|
return (
|
|
43
48
|
<div className="components-border-radius-control__input-controls-wrapper">
|
|
44
49
|
{ Object.entries( CORNERS ).map( ( [ key, label ] ) => (
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
<Tooltip text={ label } position="top" key={ key }>
|
|
51
|
+
<div className="components-border-radius-control__tooltip-wrapper">
|
|
52
|
+
<UnitControl
|
|
53
|
+
{ ...props }
|
|
54
|
+
aria-label={ label }
|
|
55
|
+
value={ values[ key ] }
|
|
56
|
+
onChange={ createHandleOnChange( key ) }
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
</Tooltip>
|
|
52
60
|
) ) }
|
|
53
61
|
</div>
|
|
54
62
|
);
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
> .components-unit-control-wrapper {
|
|
14
14
|
width: 110px;
|
|
15
15
|
margin-bottom: 0;
|
|
16
|
-
margin-right: #{ $grid-unit-
|
|
16
|
+
margin-right: #{ $grid-unit-15 };
|
|
17
17
|
flex-shrink: 0;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
width: 70%;
|
|
42
42
|
flex-wrap: wrap;
|
|
43
43
|
|
|
44
|
-
.components-
|
|
44
|
+
.components-border-radius-control__tooltip-wrapper {
|
|
45
45
|
width: calc(50% - #{ $grid-unit-10 });
|
|
46
46
|
margin-bottom: $grid-unit-10;
|
|
47
47
|
margin-right: $grid-unit-10;
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
display: flex;
|
|
53
53
|
justify-content: center;
|
|
54
54
|
margin-left: 2px;
|
|
55
|
+
margin-top: 3px;
|
|
55
56
|
|
|
56
57
|
svg {
|
|
57
58
|
margin-right: 0;
|
|
@@ -7,12 +7,14 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
__experimentalItem as Item,
|
|
12
|
-
__experimentalHStack as HStack,
|
|
13
|
-
FlexItem,
|
|
10
|
+
Button,
|
|
14
11
|
ColorIndicator,
|
|
15
12
|
Dropdown,
|
|
13
|
+
FlexItem,
|
|
14
|
+
__experimentalHStack as HStack,
|
|
15
|
+
__experimentalItem as Item,
|
|
16
|
+
__experimentalItemGroup as ItemGroup,
|
|
17
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
16
18
|
} from '@wordpress/components';
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -20,77 +22,169 @@ import {
|
|
|
20
22
|
*/
|
|
21
23
|
import ColorGradientControl from './control';
|
|
22
24
|
|
|
25
|
+
// Conditionally wraps the `ColorGradientSettingsDropdown` color controls in an
|
|
26
|
+
// `ItemGroup` allowing for a standalone group of controls to be
|
|
27
|
+
// rendered semantically.
|
|
28
|
+
const WithItemGroup = ( { __experimentalIsItemGroup, children } ) => {
|
|
29
|
+
if ( ! __experimentalIsItemGroup ) {
|
|
30
|
+
return children;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<ItemGroup
|
|
35
|
+
isBordered
|
|
36
|
+
isSeparated
|
|
37
|
+
className="block-editor-panel-color-gradient-settings__item-group"
|
|
38
|
+
>
|
|
39
|
+
{ children }
|
|
40
|
+
</ItemGroup>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// When the `ColorGradientSettingsDropdown` controls are being rendered to a
|
|
45
|
+
// `ToolsPanel` they must be wrapped in a `ToolsPanelItem`.
|
|
46
|
+
const WithToolsPanelItem = ( {
|
|
47
|
+
__experimentalIsItemGroup,
|
|
48
|
+
settings,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
51
|
+
} ) => {
|
|
52
|
+
if ( __experimentalIsItemGroup ) {
|
|
53
|
+
return children;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<ToolsPanelItem
|
|
58
|
+
hasValue={ settings.hasValue }
|
|
59
|
+
label={ settings.label }
|
|
60
|
+
onDeselect={ settings.onDeselect }
|
|
61
|
+
isShownByDefault={ settings.isShownByDefault }
|
|
62
|
+
resetAllFilter={ settings.resetAllFilter }
|
|
63
|
+
{ ...props }
|
|
64
|
+
className="block-editor-tools-panel-color-gradient-settings__item"
|
|
65
|
+
>
|
|
66
|
+
{ children }
|
|
67
|
+
</ToolsPanelItem>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const LabeledColorIndicator = ( { colorValue, label } ) => (
|
|
72
|
+
<HStack justify="flex-start">
|
|
73
|
+
<ColorIndicator
|
|
74
|
+
className="block-editor-panel-color-gradient-settings__color-indicator"
|
|
75
|
+
colorValue={ colorValue }
|
|
76
|
+
/>
|
|
77
|
+
<FlexItem>{ label }</FlexItem>
|
|
78
|
+
</HStack>
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// Renders a color dropdown's toggle as an `Item` if it is within an `ItemGroup`
|
|
82
|
+
// or as a `Button` if it isn't e.g. the controls are being rendered in
|
|
83
|
+
// a `ToolsPanel`.
|
|
84
|
+
const renderToggle = ( settings ) => ( { onToggle, isOpen } ) => {
|
|
85
|
+
const { __experimentalIsItemGroup, colorValue, label } = settings;
|
|
86
|
+
|
|
87
|
+
// Determine component, `Item` or `Button`, to wrap color indicator with.
|
|
88
|
+
const ToggleComponent = __experimentalIsItemGroup ? Item : Button;
|
|
89
|
+
const toggleClassName = __experimentalIsItemGroup
|
|
90
|
+
? 'block-editor-panel-color-gradient-settings__item'
|
|
91
|
+
: 'block-editor-panel-color-gradient-settings__dropdown';
|
|
92
|
+
const toggleProps = {
|
|
93
|
+
onClick: onToggle,
|
|
94
|
+
className: classnames( toggleClassName, { 'is-open': isOpen } ),
|
|
95
|
+
'aria-expanded': __experimentalIsItemGroup ? undefined : isOpen,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<ToggleComponent { ...toggleProps }>
|
|
100
|
+
<LabeledColorIndicator colorValue={ colorValue } label={ label } />
|
|
101
|
+
</ToggleComponent>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Renders a collection of color controls as dropdowns. Depending upon the
|
|
106
|
+
// context in which these dropdowns are being rendered, they may be wrapped
|
|
107
|
+
// in an `ItemGroup` with each dropdown's toggle as an `Item`, or alternatively,
|
|
108
|
+
// the may be individually wrapped in a `ToolsPanelItem` with the toggle as
|
|
109
|
+
// a regular `Button`.
|
|
110
|
+
//
|
|
111
|
+
// For more context see: https://github.com/WordPress/gutenberg/pull/40084
|
|
23
112
|
export default function ColorGradientSettingsDropdown( {
|
|
24
113
|
colors,
|
|
25
|
-
gradients,
|
|
26
114
|
disableCustomColors,
|
|
27
115
|
disableCustomGradients,
|
|
28
|
-
__experimentalHasMultipleOrigins,
|
|
29
|
-
__experimentalIsRenderedInSidebar,
|
|
30
116
|
enableAlpha,
|
|
117
|
+
gradients,
|
|
118
|
+
__experimentalIsItemGroup = true,
|
|
31
119
|
settings,
|
|
120
|
+
__experimentalHasMultipleOrigins,
|
|
121
|
+
__experimentalIsRenderedInSidebar,
|
|
122
|
+
...props
|
|
32
123
|
} ) {
|
|
33
|
-
|
|
124
|
+
const dropdownClassName = __experimentalIsItemGroup
|
|
125
|
+
? 'block-editor-panel-color-gradient-settings__dropdown'
|
|
126
|
+
: 'block-editor-tools-panel-color-gradient-settings__dropdown';
|
|
127
|
+
let popoverProps;
|
|
34
128
|
if ( __experimentalIsRenderedInSidebar ) {
|
|
35
|
-
|
|
129
|
+
popoverProps = {
|
|
130
|
+
placement: 'left-start',
|
|
131
|
+
offset: 36,
|
|
132
|
+
};
|
|
36
133
|
}
|
|
37
134
|
|
|
38
135
|
return (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
136
|
+
// Only wrap with `ItemGroup` if these controls are being rendered
|
|
137
|
+
// semantically.
|
|
138
|
+
<WithItemGroup __experimentalIsItemGroup={ __experimentalIsItemGroup }>
|
|
139
|
+
{ settings.map( ( setting, index ) => {
|
|
140
|
+
const controlProps = {
|
|
141
|
+
clearable: __experimentalIsItemGroup ? undefined : false,
|
|
142
|
+
colorValue: setting.colorValue,
|
|
143
|
+
colors,
|
|
144
|
+
disableCustomColors,
|
|
145
|
+
disableCustomGradients,
|
|
146
|
+
enableAlpha,
|
|
147
|
+
gradientValue: setting.gradientValue,
|
|
148
|
+
gradients,
|
|
149
|
+
label: setting.label,
|
|
150
|
+
onColorChange: setting.onColorChange,
|
|
151
|
+
onGradientChange: setting.onGradientChange,
|
|
152
|
+
showTitle: false,
|
|
153
|
+
__experimentalHasMultipleOrigins,
|
|
154
|
+
__experimentalIsRenderedInSidebar,
|
|
155
|
+
...setting,
|
|
156
|
+
};
|
|
157
|
+
const toggleSettings = {
|
|
158
|
+
colorValue: setting.gradientValue ?? setting.colorValue,
|
|
159
|
+
__experimentalIsItemGroup,
|
|
160
|
+
label: setting.label,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return (
|
|
46
164
|
setting && (
|
|
47
|
-
|
|
165
|
+
// If not in an `ItemGroup` wrap the dropdown in a
|
|
166
|
+
// `ToolsPanelItem`
|
|
167
|
+
<WithToolsPanelItem
|
|
48
168
|
key={ index }
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
setting.gradientValue ??
|
|
66
|
-
setting.colorValue
|
|
67
|
-
}
|
|
68
|
-
/>
|
|
69
|
-
<FlexItem>
|
|
70
|
-
{ setting.label }
|
|
71
|
-
</FlexItem>
|
|
72
|
-
</HStack>
|
|
73
|
-
</Item>
|
|
74
|
-
);
|
|
75
|
-
} }
|
|
76
|
-
renderContent={ () => (
|
|
77
|
-
<ColorGradientControl
|
|
78
|
-
showTitle={ false }
|
|
79
|
-
{ ...{
|
|
80
|
-
colors,
|
|
81
|
-
gradients,
|
|
82
|
-
disableCustomColors,
|
|
83
|
-
disableCustomGradients,
|
|
84
|
-
__experimentalHasMultipleOrigins,
|
|
85
|
-
__experimentalIsRenderedInSidebar,
|
|
86
|
-
enableAlpha,
|
|
87
|
-
...setting,
|
|
88
|
-
} }
|
|
89
|
-
/>
|
|
90
|
-
) }
|
|
91
|
-
/>
|
|
169
|
+
__experimentalIsItemGroup={
|
|
170
|
+
__experimentalIsItemGroup
|
|
171
|
+
}
|
|
172
|
+
settings={ setting }
|
|
173
|
+
{ ...props }
|
|
174
|
+
>
|
|
175
|
+
<Dropdown
|
|
176
|
+
popoverProps={ popoverProps }
|
|
177
|
+
className={ dropdownClassName }
|
|
178
|
+
contentClassName="block-editor-panel-color-gradient-settings__dropdown-content"
|
|
179
|
+
renderToggle={ renderToggle( toggleSettings ) }
|
|
180
|
+
renderContent={ () => (
|
|
181
|
+
<ColorGradientControl { ...controlProps } />
|
|
182
|
+
) }
|
|
183
|
+
/>
|
|
184
|
+
</WithToolsPanelItem>
|
|
92
185
|
)
|
|
93
|
-
|
|
94
|
-
|
|
186
|
+
);
|
|
187
|
+
} ) }
|
|
188
|
+
</WithItemGroup>
|
|
95
189
|
);
|
|
96
190
|
}
|
|
@@ -59,25 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
.block-editor-panel-color-gradient-settings__dropdown-content .components-popover__content {
|
|
62
|
-
|
|
63
|
-
width: $sidebar-width;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@include break-medium() {
|
|
68
|
-
.block-editor-panel-color-gradient-settings__dropdown-content {
|
|
69
|
-
.components-popover__content {
|
|
70
|
-
margin-right: #{ math.div($sidebar-width, 2) + $grid-unit-20 } !important;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&.is-from-top .components-popover__content {
|
|
74
|
-
margin-top: #{ -($grid-unit-60 + $grid-unit-15) } !important;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&.is-from-bottom .components-popover__content {
|
|
78
|
-
margin-bottom: #{ -($grid-unit-60 + $grid-unit-15) } !important;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
62
|
+
width: $sidebar-width;
|
|
81
63
|
}
|
|
82
64
|
|
|
83
65
|
.block-editor-panel-color-gradient-settings__dropdown:last-child > div {
|
|
@@ -87,10 +69,6 @@
|
|
|
87
69
|
.block-editor-panel-color-gradient-settings__item {
|
|
88
70
|
padding-top: $grid-unit-15 !important;
|
|
89
71
|
padding-bottom: $grid-unit-15 !important;
|
|
90
|
-
.block-editor-panel-color-gradient-settings__color-indicator {
|
|
91
|
-
// Show a diagonal line (crossed out) for empty swatches.
|
|
92
|
-
background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
93
|
-
}
|
|
94
72
|
|
|
95
73
|
&.is-open {
|
|
96
74
|
background: $gray-100;
|
|
@@ -98,3 +76,53 @@
|
|
|
98
76
|
}
|
|
99
77
|
}
|
|
100
78
|
|
|
79
|
+
.block-editor-panel-color-gradient-settings__color-indicator {
|
|
80
|
+
// Show a diagonal line (crossed out) for empty swatches.
|
|
81
|
+
background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The following styles replicate the separated border of the
|
|
86
|
+
* `ItemGroup` component but allows for hidden items. This is because
|
|
87
|
+
* to maintain the order of `ToolsPanel` controls, each `ToolsPanelItem`
|
|
88
|
+
* must at least render a placeholder which would otherwise interfere
|
|
89
|
+
* with the `:last-child` styles.
|
|
90
|
+
*/
|
|
91
|
+
.block-editor-tools-panel-color-gradient-settings__item {
|
|
92
|
+
padding: 0;
|
|
93
|
+
|
|
94
|
+
// Border styles.
|
|
95
|
+
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
|
96
|
+
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
|
97
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
98
|
+
|
|
99
|
+
&.first {
|
|
100
|
+
border-top-left-radius: 2px;
|
|
101
|
+
border-top-right-radius: 2px;
|
|
102
|
+
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&.last {
|
|
106
|
+
border-bottom-left-radius: 2px;
|
|
107
|
+
border-bottom-right-radius: 2px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
> div,
|
|
111
|
+
> div > button {
|
|
112
|
+
border-radius: inherit;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.block-editor-tools-panel-color-gradient-settings__dropdown {
|
|
117
|
+
display: block;
|
|
118
|
+
padding: 0;
|
|
119
|
+
|
|
120
|
+
> button {
|
|
121
|
+
height: 46px;
|
|
122
|
+
|
|
123
|
+
&.is-open {
|
|
124
|
+
background: $gray-100;
|
|
125
|
+
color: var(--wp-admin-theme-color);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -9,7 +9,7 @@ $popover-padding: $grid-unit-20;
|
|
|
9
9
|
$swatch-columns: math.floor(math.div($popover-width + $swatch-gap - 2 * $popover-padding, $swatch-size + $swatch-gap));
|
|
10
10
|
|
|
11
11
|
.block-editor-duotone-control__popover {
|
|
12
|
-
> .components-popover__content
|
|
12
|
+
> .components-popover__content {
|
|
13
13
|
padding: $popover-padding;
|
|
14
14
|
width: $popover-width;
|
|
15
15
|
}
|
|
@@ -34,9 +34,3 @@ $swatch-columns: math.floor(math.div($popover-width + $swatch-gap - 2 * $popover
|
|
|
34
34
|
margin: $grid-unit-20 0;
|
|
35
35
|
font-size: $helptext-font-size;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
// Better align the popover under the swatch.
|
|
39
|
-
// @todo: when the positioning for popovers gets refactored, this can presumably be removed.
|
|
40
|
-
.block-editor-duotone-control__popover:not([data-y-axis="middle"][data-x-axis="right"]) > .components-popover__content {
|
|
41
|
-
margin-left: -14px;
|
|
42
|
-
}
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
useState,
|
|
11
11
|
createPortal,
|
|
12
12
|
forwardRef,
|
|
13
|
-
useEffect,
|
|
14
13
|
useMemo,
|
|
15
14
|
useReducer,
|
|
16
15
|
} from '@wordpress/element';
|
|
@@ -34,61 +33,66 @@ const BLOCK_PREFIX = 'wp-block';
|
|
|
34
33
|
*
|
|
35
34
|
* Ideally, this hook should be removed in the future and styles should be added
|
|
36
35
|
* explicitly as editor styles.
|
|
37
|
-
*
|
|
38
|
-
* @param {Document} doc The document to append cloned stylesheets to.
|
|
39
36
|
*/
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const { ownerNode, cssRules } = styleSheet;
|
|
52
|
-
|
|
53
|
-
if ( ! cssRules ) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
37
|
+
function useStylesCompatibility() {
|
|
38
|
+
return useRefEffect( ( node ) => {
|
|
39
|
+
// Search the document for stylesheets targetting the editor canvas.
|
|
40
|
+
Array.from( document.styleSheets ).forEach( ( styleSheet ) => {
|
|
41
|
+
try {
|
|
42
|
+
// May fail for external styles.
|
|
43
|
+
// eslint-disable-next-line no-unused-expressions
|
|
44
|
+
styleSheet.cssRules;
|
|
45
|
+
} catch ( e ) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
56
48
|
|
|
57
|
-
|
|
58
|
-
// stylesheet later, which may or may not match the selectors.
|
|
59
|
-
if ( ownerNode.tagName !== 'LINK' ) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
49
|
+
const { ownerNode, cssRules } = styleSheet;
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if ( ownerNode.id === 'wp-reset-editor-styles-css' ) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const isMatch = Array.from( cssRules ).find(
|
|
71
|
-
( { selectorText } ) =>
|
|
72
|
-
selectorText &&
|
|
73
|
-
( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||
|
|
74
|
-
selectorText.includes( `.${ BLOCK_PREFIX }` ) )
|
|
75
|
-
);
|
|
51
|
+
if ( ! cssRules ) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
76
54
|
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
55
|
+
// Generally, ignore inline styles. We add inline styles belonging to a
|
|
56
|
+
// stylesheet later, which may or may not match the selectors.
|
|
57
|
+
if ( ownerNode.tagName !== 'LINK' ) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
80
60
|
|
|
81
|
-
|
|
61
|
+
// Don't try to add the reset styles, which were removed as a dependency
|
|
62
|
+
// from `edit-blocks` for the iframe since we don't need to reset admin
|
|
63
|
+
// styles.
|
|
64
|
+
if ( ownerNode.id === 'wp-reset-editor-styles-css' ) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
82
67
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
const isMatch = Array.from( cssRules ).find(
|
|
69
|
+
( { selectorText } ) =>
|
|
70
|
+
selectorText &&
|
|
71
|
+
( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||
|
|
72
|
+
selectorText.includes( `.${ BLOCK_PREFIX }` ) )
|
|
73
|
+
);
|
|
86
74
|
|
|
87
|
-
if (
|
|
88
|
-
|
|
75
|
+
if (
|
|
76
|
+
isMatch &&
|
|
77
|
+
! node.ownerDocument.getElementById( ownerNode.id )
|
|
78
|
+
) {
|
|
79
|
+
// Display warning once we have a way to add style dependencies to the editor.
|
|
80
|
+
// See: https://github.com/WordPress/gutenberg/pull/37466.
|
|
81
|
+
node.appendChild( ownerNode.cloneNode( true ) );
|
|
82
|
+
|
|
83
|
+
// Add inline styles belonging to the stylesheet.
|
|
84
|
+
const inlineCssId = ownerNode.id.replace(
|
|
85
|
+
'-css',
|
|
86
|
+
'-inline-css'
|
|
87
|
+
);
|
|
88
|
+
const inlineCssElement = document.getElementById( inlineCssId );
|
|
89
|
+
|
|
90
|
+
if ( inlineCssElement ) {
|
|
91
|
+
node.appendChild( inlineCssElement.cloneNode( true ) );
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
|
-
}
|
|
91
|
-
} );
|
|
94
|
+
} );
|
|
95
|
+
}, [] );
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
/**
|
|
@@ -222,12 +226,7 @@ function Iframe(
|
|
|
222
226
|
} );
|
|
223
227
|
}, [] );
|
|
224
228
|
const bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );
|
|
225
|
-
|
|
226
|
-
useEffect( () => {
|
|
227
|
-
if ( iframeDocument ) {
|
|
228
|
-
styleSheetsCompat( iframeDocument );
|
|
229
|
-
}
|
|
230
|
-
}, [ iframeDocument ] );
|
|
229
|
+
const styleCompatibilityRef = useStylesCompatibility();
|
|
231
230
|
|
|
232
231
|
head = (
|
|
233
232
|
<>
|
|
@@ -275,6 +274,15 @@ function Iframe(
|
|
|
275
274
|
...bodyClasses
|
|
276
275
|
) }
|
|
277
276
|
>
|
|
277
|
+
{ /*
|
|
278
|
+
* This is a wrapper for the extra styles and scripts
|
|
279
|
+
* rendered imperatively by cloning the parent,
|
|
280
|
+
* it's important that this div's content remains uncontrolled.
|
|
281
|
+
*/ }
|
|
282
|
+
<div
|
|
283
|
+
style={ { display: 'none' } }
|
|
284
|
+
ref={ styleCompatibilityRef }
|
|
285
|
+
/>
|
|
278
286
|
<StyleProvider document={ iframeDocument }>
|
|
279
287
|
{ children }
|
|
280
288
|
</StyleProvider>
|
|
@@ -6,6 +6,7 @@ import { useDispatch } from '@wordpress/data';
|
|
|
6
6
|
import { useCallback, useMemo, useState } from '@wordpress/element';
|
|
7
7
|
import { __, sprintf } from '@wordpress/i18n';
|
|
8
8
|
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
9
10
|
|
|
10
11
|
export default function useSaveImage( {
|
|
11
12
|
crop,
|
|
@@ -60,7 +61,7 @@ export default function useSaveImage( {
|
|
|
60
61
|
sprintf(
|
|
61
62
|
/* translators: 1. Error message */
|
|
62
63
|
__( 'Could not edit image. %s' ),
|
|
63
|
-
error.message
|
|
64
|
+
stripHTML( error.message )
|
|
64
65
|
),
|
|
65
66
|
{
|
|
66
67
|
id: 'image-editing-error',
|