@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
package/src/components/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export {
|
|
|
14
14
|
export { default as __experimentalBlockFullHeightAligmentControl } from './block-full-height-alignment-control';
|
|
15
15
|
export { default as __experimentalBlockAlignmentMatrixControl } from './block-alignment-matrix-control';
|
|
16
16
|
export { default as BlockBreadcrumb } from './block-breadcrumb';
|
|
17
|
-
export { default as
|
|
17
|
+
export { default as __experimentalUseBlockOverlayActive } from './block-content-overlay';
|
|
18
18
|
export { BlockContextProvider } from './block-context';
|
|
19
19
|
export {
|
|
20
20
|
default as BlockControls,
|
|
@@ -51,7 +51,6 @@ export { default as __experimentalTextTransformControl } from './text-transform-
|
|
|
51
51
|
export { default as __experimentalColorGradientControl } from './colors-gradients/control';
|
|
52
52
|
export { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';
|
|
53
53
|
export { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';
|
|
54
|
-
export { default as __experimentalToolsPanelColorDropdown } from './colors-gradients/tools-panel-color-dropdown';
|
|
55
54
|
export {
|
|
56
55
|
default as __experimentalImageEditor,
|
|
57
56
|
ImageEditingProvider as __experimentalImageEditingProvider,
|
|
@@ -67,7 +67,7 @@ const defaultRenderToggle = ( {
|
|
|
67
67
|
extraProps={ {
|
|
68
68
|
hint: __( 'Double tap to add a block' ),
|
|
69
69
|
// testID is present to disambiguate this element for native UI tests. It's not
|
|
70
|
-
// usually required for components. See: https://
|
|
70
|
+
// usually required for components. See: https://github.com/WordPress/gutenberg/pull/18832#issuecomment-561411389.
|
|
71
71
|
testID: 'add-block-button',
|
|
72
72
|
onLongPress,
|
|
73
73
|
} }
|
|
@@ -23,6 +23,7 @@ $block-inserter-tabs-height: 44px;
|
|
|
23
23
|
.block-editor-inserter__popover.is-quick {
|
|
24
24
|
.components-popover__content {
|
|
25
25
|
border: none;
|
|
26
|
+
outline: none;
|
|
26
27
|
|
|
27
28
|
.block-editor-inserter__quick-inserter > * {
|
|
28
29
|
border-left: $border-width solid $gray-400;
|
|
@@ -310,7 +311,7 @@ $block-inserter-tabs-height: 44px;
|
|
|
310
311
|
border-top: $border-width solid $gray-300;
|
|
311
312
|
}
|
|
312
313
|
|
|
313
|
-
.block-editor-inserter__popover.is-quick > .components-popover__content
|
|
314
|
+
.block-editor-inserter__popover.is-quick > .components-popover__content {
|
|
314
315
|
padding: 0;
|
|
315
316
|
}
|
|
316
317
|
|
|
@@ -7,6 +7,17 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
// Used to help distinguish the "Create" suggestion within the search results in
|
|
8
8
|
// order to handle it as a unique case.
|
|
9
9
|
export const CREATE_TYPE = '__CREATE__';
|
|
10
|
+
export const TEL_TYPE = 'tel';
|
|
11
|
+
export const URL_TYPE = 'URL';
|
|
12
|
+
export const MAILTO_TYPE = 'mailto';
|
|
13
|
+
export const INTERNAL_TYPE = 'internal';
|
|
14
|
+
|
|
15
|
+
export const LINK_ENTRY_TYPES = [
|
|
16
|
+
URL_TYPE,
|
|
17
|
+
MAILTO_TYPE,
|
|
18
|
+
TEL_TYPE,
|
|
19
|
+
INTERNAL_TYPE,
|
|
20
|
+
];
|
|
10
21
|
|
|
11
22
|
export const DEFAULT_LINK_SETTINGS = [
|
|
12
23
|
{
|
|
@@ -15,7 +15,7 @@ import { createElement, Fragment } from '@wordpress/element';
|
|
|
15
15
|
*/
|
|
16
16
|
import LinkControlSearchCreate from './search-create-button';
|
|
17
17
|
import LinkControlSearchItem from './search-item';
|
|
18
|
-
import { CREATE_TYPE } from './constants';
|
|
18
|
+
import { CREATE_TYPE, LINK_ENTRY_TYPES } from './constants';
|
|
19
19
|
|
|
20
20
|
export default function LinkControlSearchResults( {
|
|
21
21
|
instanceId,
|
|
@@ -38,10 +38,9 @@ export default function LinkControlSearchResults( {
|
|
|
38
38
|
}
|
|
39
39
|
);
|
|
40
40
|
|
|
41
|
-
const directLinkEntryTypes = [ 'url', 'mailto', 'tel', 'internal' ];
|
|
42
41
|
const isSingleDirectEntryResult =
|
|
43
42
|
suggestions.length === 1 &&
|
|
44
|
-
|
|
43
|
+
LINK_ENTRY_TYPES.includes( suggestions[ 0 ].type );
|
|
45
44
|
const shouldShowCreateSuggestion =
|
|
46
45
|
withCreateSuggestion &&
|
|
47
46
|
! isSingleDirectEntryResult &&
|
|
@@ -127,8 +126,8 @@ export default function LinkControlSearchResults( {
|
|
|
127
126
|
handleSuggestionClick( suggestion );
|
|
128
127
|
} }
|
|
129
128
|
isSelected={ index === selectedSuggestion }
|
|
130
|
-
isURL={
|
|
131
|
-
suggestion.type
|
|
129
|
+
isURL={ LINK_ENTRY_TYPES.includes(
|
|
130
|
+
suggestion.type
|
|
132
131
|
) }
|
|
133
132
|
searchTerm={ currentInputValue }
|
|
134
133
|
shouldShowType={ shouldShowSuggestionsTypes }
|
|
@@ -14,26 +14,32 @@ import { startsWith } from 'lodash';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import isURLLike from './is-url-like';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
CREATE_TYPE,
|
|
19
|
+
TEL_TYPE,
|
|
20
|
+
MAILTO_TYPE,
|
|
21
|
+
INTERNAL_TYPE,
|
|
22
|
+
URL_TYPE,
|
|
23
|
+
} from './constants';
|
|
18
24
|
import { store as blockEditorStore } from '../../store';
|
|
19
25
|
|
|
20
26
|
export const handleNoop = () => Promise.resolve( [] );
|
|
21
27
|
|
|
22
28
|
export const handleDirectEntry = ( val ) => {
|
|
23
|
-
let type =
|
|
29
|
+
let type = URL_TYPE;
|
|
24
30
|
|
|
25
31
|
const protocol = getProtocol( val ) || '';
|
|
26
32
|
|
|
27
33
|
if ( protocol.includes( 'mailto' ) ) {
|
|
28
|
-
type =
|
|
34
|
+
type = MAILTO_TYPE;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
if ( protocol.includes( 'tel' ) ) {
|
|
32
|
-
type =
|
|
38
|
+
type = TEL_TYPE;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
if ( startsWith( val, '#' ) ) {
|
|
36
|
-
type =
|
|
42
|
+
type = INTERNAL_TYPE;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
return Promise.resolve( [
|
|
@@ -396,10 +396,11 @@ $block-navigation-max-indent: 8;
|
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
// Reset some popover defaults for the drop indicator.
|
|
399
|
-
.block-editor-list-view-drop-indicator
|
|
399
|
+
.block-editor-list-view-drop-indicator > .components-popover__content {
|
|
400
400
|
margin-left: 0;
|
|
401
401
|
border: none;
|
|
402
402
|
box-shadow: none;
|
|
403
|
+
outline: none;
|
|
403
404
|
}
|
|
404
405
|
|
|
405
406
|
.block-editor-list-view-placeholder {
|
|
@@ -29,7 +29,12 @@ function hasFocusWithin( container ) {
|
|
|
29
29
|
function focusFirstTabbableIn( container ) {
|
|
30
30
|
const [ firstTabbable ] = focus.tabbable.find( container );
|
|
31
31
|
if ( firstTabbable ) {
|
|
32
|
-
firstTabbable.focus(
|
|
32
|
+
firstTabbable.focus( {
|
|
33
|
+
// When focusing newly mounted toolbars,
|
|
34
|
+
// the position of the popover is often not right on the first render
|
|
35
|
+
// This prevents the layout shifts when focusing the dialogs.
|
|
36
|
+
preventScroll: true,
|
|
37
|
+
} );
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
|
|
@@ -119,7 +124,12 @@ function useToolbarFocus(
|
|
|
119
124
|
const items = getAllToolbarItemsIn( ref.current );
|
|
120
125
|
const index = initialIndex || 0;
|
|
121
126
|
if ( items[ index ] && hasFocusWithin( ref.current ) ) {
|
|
122
|
-
items[ index ].focus(
|
|
127
|
+
items[ index ].focus( {
|
|
128
|
+
// When focusing newly mounted toolbars,
|
|
129
|
+
// the position of the popover is often not right on the first render
|
|
130
|
+
// This prevents the layout shifts when focusing the dialogs.
|
|
131
|
+
preventScroll: true,
|
|
132
|
+
} );
|
|
123
133
|
}
|
|
124
134
|
} );
|
|
125
135
|
}
|
|
@@ -42,17 +42,11 @@ figcaption.block-editor-rich-text__editable [data-rich-text-placeholder]::before
|
|
|
42
42
|
min-width: auto;
|
|
43
43
|
margin-bottom: $grid-unit-10;
|
|
44
44
|
box-shadow: none;
|
|
45
|
-
|
|
46
|
-
// Block UI appearance.
|
|
47
|
-
border: $border-width solid $gray-900;
|
|
48
|
-
border-radius: $radius-block-ui;
|
|
49
|
-
background-color: $white;
|
|
45
|
+
outline: none;
|
|
50
46
|
}
|
|
51
47
|
|
|
52
|
-
.components-toolbar-group,
|
|
53
48
|
.components-toolbar {
|
|
54
|
-
|
|
55
|
-
border: none;
|
|
49
|
+
border-radius: $radius-block-ui;
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
.components-toolbar__control,
|
|
@@ -303,6 +303,7 @@ class URLInput extends Component {
|
|
|
303
303
|
|
|
304
304
|
// Submitting while loading should trigger onSubmit.
|
|
305
305
|
case ENTER: {
|
|
306
|
+
event.preventDefault();
|
|
306
307
|
if ( this.props.onSubmit ) {
|
|
307
308
|
this.props.onSubmit( null, event );
|
|
308
309
|
}
|
|
@@ -350,6 +351,7 @@ class URLInput extends Component {
|
|
|
350
351
|
break;
|
|
351
352
|
}
|
|
352
353
|
case ENTER: {
|
|
354
|
+
event.preventDefault();
|
|
353
355
|
if ( this.state.selectedSuggestion !== null ) {
|
|
354
356
|
this.selectLink( suggestion );
|
|
355
357
|
|
|
@@ -536,7 +538,7 @@ class URLInput extends Component {
|
|
|
536
538
|
!! suggestions.length
|
|
537
539
|
) {
|
|
538
540
|
return (
|
|
539
|
-
<Popover position="bottom"
|
|
541
|
+
<Popover position="bottom" focusOnMount={ false }>
|
|
540
542
|
<div
|
|
541
543
|
{ ...suggestionsListProps }
|
|
542
544
|
className={ classnames(
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { useCallback } from '@wordpress/element';
|
|
11
|
+
import { useThrottle } from '@wordpress/compose';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { store as blockEditorStore } from '../../store';
|
|
17
|
+
import { useBlockListContext } from '../block-list/block-list-context';
|
|
18
|
+
import { getDistanceToNearestEdge } from '../../utils/math';
|
|
19
|
+
import useOnBlockDrop from '../use-on-block-drop';
|
|
20
|
+
|
|
21
|
+
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The orientation of a block list.
|
|
25
|
+
*
|
|
26
|
+
* @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Given a list of blocks layouts finds the index that a block should be dropped at.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} blocksLayouts Blocks layouts object.
|
|
33
|
+
* @param {WPPoint} position The position of the item being dragged.
|
|
34
|
+
* @param {WPBlockListOrientation} orientation The orientation of a block list.
|
|
35
|
+
* @param {boolean} isRTL Check if current locale is RTL.
|
|
36
|
+
*
|
|
37
|
+
* @return {number|undefined} The block index that's closest to the drag position.
|
|
38
|
+
*/
|
|
39
|
+
export function getNearestBlockIndex(
|
|
40
|
+
blocksLayouts,
|
|
41
|
+
position,
|
|
42
|
+
orientation,
|
|
43
|
+
isRTL
|
|
44
|
+
) {
|
|
45
|
+
const allowedEdges =
|
|
46
|
+
orientation === 'horizontal'
|
|
47
|
+
? [ 'left', 'right' ]
|
|
48
|
+
: [ 'top', 'bottom' ];
|
|
49
|
+
|
|
50
|
+
const isRightToLeft = isRTL;
|
|
51
|
+
|
|
52
|
+
let candidateIndex;
|
|
53
|
+
let candidateDistance;
|
|
54
|
+
|
|
55
|
+
// Only enabled for root level blocks.
|
|
56
|
+
blocksLayouts.forEach( ( element, index ) => {
|
|
57
|
+
const { x, y, width, height } = element;
|
|
58
|
+
const rect = {
|
|
59
|
+
x: element.x,
|
|
60
|
+
y: element.y,
|
|
61
|
+
top: y,
|
|
62
|
+
right: x + width,
|
|
63
|
+
bottom: y + height,
|
|
64
|
+
left: x,
|
|
65
|
+
width,
|
|
66
|
+
height,
|
|
67
|
+
};
|
|
68
|
+
const [ distance, edge ] = getDistanceToNearestEdge(
|
|
69
|
+
position,
|
|
70
|
+
rect,
|
|
71
|
+
allowedEdges
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if ( candidateDistance === undefined || distance < candidateDistance ) {
|
|
75
|
+
// If the user is dropping to the trailing edge of the block
|
|
76
|
+
// add 1 to the index to represent dragging after.
|
|
77
|
+
// Take RTL languages into account where the left edge is
|
|
78
|
+
// the trailing edge.
|
|
79
|
+
const isTrailingEdge =
|
|
80
|
+
edge === 'bottom' ||
|
|
81
|
+
( ! isRightToLeft && edge === 'right' ) ||
|
|
82
|
+
( isRightToLeft && edge === 'left' );
|
|
83
|
+
const offset = isTrailingEdge ? 1 : 0;
|
|
84
|
+
|
|
85
|
+
// Update the currently known best candidate.
|
|
86
|
+
candidateDistance = distance;
|
|
87
|
+
candidateIndex = index + offset;
|
|
88
|
+
}
|
|
89
|
+
} );
|
|
90
|
+
return candidateIndex;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {Object} WPBlockDropZoneConfig
|
|
95
|
+
* @property {string} rootClientId The root client id for the block list.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A React hook that can be used to make a block list handle drag and drop.
|
|
100
|
+
*
|
|
101
|
+
* @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
|
|
102
|
+
*
|
|
103
|
+
* @return {Object} An object that contains `targetBlockIndex` and the event
|
|
104
|
+
* handlers `onBlockDragOver`, `onBlockDragEnd` and `onBlockDrop`.
|
|
105
|
+
*/
|
|
106
|
+
export default function useBlockDropZone( {
|
|
107
|
+
// An undefined value represents a top-level block. Default to an empty
|
|
108
|
+
// string for this so that `targetRootClientId` can be easily compared to
|
|
109
|
+
// values returned by the `getRootBlockClientId` selector, which also uses
|
|
110
|
+
// an empty string to represent top-level blocks.
|
|
111
|
+
rootClientId: targetRootClientId = '',
|
|
112
|
+
} = {} ) {
|
|
113
|
+
const targetBlockIndex = useSharedValue( null );
|
|
114
|
+
|
|
115
|
+
const { getBlockListSettings, getSettings } = useSelect( blockEditorStore );
|
|
116
|
+
const {
|
|
117
|
+
blocksLayouts,
|
|
118
|
+
getBlockLayoutsOrderedByYCoord,
|
|
119
|
+
} = useBlockListContext();
|
|
120
|
+
|
|
121
|
+
const getSortedBlocksLayouts = useCallback( () => {
|
|
122
|
+
return getBlockLayoutsOrderedByYCoord( blocksLayouts.current );
|
|
123
|
+
}, [ blocksLayouts.current ] );
|
|
124
|
+
|
|
125
|
+
const isRTL = getSettings().isRTL;
|
|
126
|
+
|
|
127
|
+
const onBlockDrop = useOnBlockDrop();
|
|
128
|
+
|
|
129
|
+
const throttled = useThrottle(
|
|
130
|
+
useCallback(
|
|
131
|
+
( event ) => {
|
|
132
|
+
const sortedBlockLayouts = getSortedBlocksLayouts();
|
|
133
|
+
|
|
134
|
+
const targetIndex = getNearestBlockIndex(
|
|
135
|
+
sortedBlockLayouts,
|
|
136
|
+
{ x: event.x, y: event.y },
|
|
137
|
+
getBlockListSettings( targetRootClientId )?.orientation,
|
|
138
|
+
isRTL
|
|
139
|
+
);
|
|
140
|
+
if ( targetIndex !== null ) {
|
|
141
|
+
targetBlockIndex.value = targetIndex ?? 0;
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
[
|
|
145
|
+
getSortedBlocksLayouts,
|
|
146
|
+
getNearestBlockIndex,
|
|
147
|
+
getBlockListSettings,
|
|
148
|
+
targetBlockIndex,
|
|
149
|
+
]
|
|
150
|
+
),
|
|
151
|
+
200
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
onBlockDragOver( event ) {
|
|
156
|
+
throttled( event );
|
|
157
|
+
},
|
|
158
|
+
onBlockDragEnd() {
|
|
159
|
+
throttled.cancel();
|
|
160
|
+
targetBlockIndex.value = null;
|
|
161
|
+
},
|
|
162
|
+
onBlockDrop: ( event ) => {
|
|
163
|
+
if ( targetBlockIndex.value !== null ) {
|
|
164
|
+
onBlockDrop( {
|
|
165
|
+
...event,
|
|
166
|
+
targetRootClientId,
|
|
167
|
+
targetBlockIndex: targetBlockIndex.value,
|
|
168
|
+
} );
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
targetBlockIndex,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { cloneBlock } from '@wordpress/blocks';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A function that returns an event handler function for block drop events.
|
|
14
|
+
*
|
|
15
|
+
* @param {Function} getBlockIndex A function that gets the index of a block.
|
|
16
|
+
* @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
|
|
17
|
+
* @param {Function} moveBlocksToPosition A function that moves blocks.
|
|
18
|
+
* @param {Function} insertBlocks A function that inserts blocks.
|
|
19
|
+
* @param {Function} clearSelectedBlock A function that clears block selection.
|
|
20
|
+
* @return {Function} The event handler for a block drop event.
|
|
21
|
+
*/
|
|
22
|
+
export function onBlockDrop(
|
|
23
|
+
getBlockIndex,
|
|
24
|
+
getClientIdsOfDescendants,
|
|
25
|
+
moveBlocksToPosition,
|
|
26
|
+
insertBlocks,
|
|
27
|
+
clearSelectedBlock
|
|
28
|
+
) {
|
|
29
|
+
return ( {
|
|
30
|
+
blocks,
|
|
31
|
+
srcClientIds: sourceClientIds,
|
|
32
|
+
srcRootClientId: sourceRootClientId,
|
|
33
|
+
targetBlockIndex,
|
|
34
|
+
targetRootClientId,
|
|
35
|
+
type: dropType,
|
|
36
|
+
} ) => {
|
|
37
|
+
// If the user is inserting a block.
|
|
38
|
+
if ( dropType === 'inserter' ) {
|
|
39
|
+
clearSelectedBlock();
|
|
40
|
+
const blocksToInsert = blocks.map( ( block ) =>
|
|
41
|
+
cloneBlock( block )
|
|
42
|
+
);
|
|
43
|
+
insertBlocks(
|
|
44
|
+
blocksToInsert,
|
|
45
|
+
targetBlockIndex,
|
|
46
|
+
targetRootClientId,
|
|
47
|
+
true,
|
|
48
|
+
null
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// If the user is moving a block.
|
|
53
|
+
if ( dropType === 'block' ) {
|
|
54
|
+
const sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );
|
|
55
|
+
|
|
56
|
+
// If the user is dropping to the same position, return early.
|
|
57
|
+
if (
|
|
58
|
+
sourceRootClientId === targetRootClientId &&
|
|
59
|
+
sourceBlockIndex === targetBlockIndex
|
|
60
|
+
) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// If the user is attempting to drop a block within its own
|
|
65
|
+
// nested blocks, return early as this would create infinite
|
|
66
|
+
// recursion.
|
|
67
|
+
if (
|
|
68
|
+
sourceClientIds.includes( targetRootClientId ) ||
|
|
69
|
+
getClientIdsOfDescendants( sourceClientIds ).some(
|
|
70
|
+
( id ) => id === targetRootClientId
|
|
71
|
+
)
|
|
72
|
+
) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const isAtSameLevel = sourceRootClientId === targetRootClientId;
|
|
77
|
+
const draggedBlockCount = sourceClientIds.length;
|
|
78
|
+
|
|
79
|
+
// If the block is kept at the same level and moved downwards,
|
|
80
|
+
// subtract to take into account that the blocks being dragged
|
|
81
|
+
// were removed from the block list above the insertion point.
|
|
82
|
+
const insertIndex =
|
|
83
|
+
isAtSameLevel && sourceBlockIndex < targetBlockIndex
|
|
84
|
+
? targetBlockIndex - draggedBlockCount
|
|
85
|
+
: targetBlockIndex;
|
|
86
|
+
|
|
87
|
+
moveBlocksToPosition(
|
|
88
|
+
sourceClientIds,
|
|
89
|
+
sourceRootClientId,
|
|
90
|
+
targetRootClientId,
|
|
91
|
+
insertIndex
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A React hook for handling block drop events.
|
|
99
|
+
*
|
|
100
|
+
* @return {Function} The event handler for a block drop event.
|
|
101
|
+
*/
|
|
102
|
+
export default function useOnBlockDrop() {
|
|
103
|
+
const { getBlockIndex, getClientIdsOfDescendants } = useSelect(
|
|
104
|
+
blockEditorStore
|
|
105
|
+
);
|
|
106
|
+
const {
|
|
107
|
+
insertBlocks,
|
|
108
|
+
moveBlocksToPosition,
|
|
109
|
+
clearSelectedBlock,
|
|
110
|
+
} = useDispatch( blockEditorStore );
|
|
111
|
+
|
|
112
|
+
return onBlockDrop(
|
|
113
|
+
getBlockIndex,
|
|
114
|
+
getClientIdsOfDescendants,
|
|
115
|
+
moveBlocksToPosition,
|
|
116
|
+
insertBlocks,
|
|
117
|
+
clearSelectedBlock
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -13,50 +13,55 @@ import { moreHorizontal } from '@wordpress/icons';
|
|
|
13
13
|
|
|
14
14
|
function Warning( { className, actions, children, secondaryActions } ) {
|
|
15
15
|
return (
|
|
16
|
-
<div
|
|
17
|
-
<div className=
|
|
18
|
-
<
|
|
16
|
+
<div style={ { display: 'contents', all: 'initial' } }>
|
|
17
|
+
<div className={ classnames( className, 'block-editor-warning' ) }>
|
|
18
|
+
<div className="block-editor-warning__contents">
|
|
19
|
+
<p className="block-editor-warning__message">
|
|
20
|
+
{ children }
|
|
21
|
+
</p>
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
{ ( Children.count( actions ) > 0 || secondaryActions ) && (
|
|
24
|
+
<div className="block-editor-warning__actions">
|
|
25
|
+
{ Children.count( actions ) > 0 &&
|
|
26
|
+
Children.map( actions, ( action, i ) => (
|
|
27
|
+
<span
|
|
28
|
+
key={ i }
|
|
29
|
+
className="block-editor-warning__action"
|
|
30
|
+
>
|
|
31
|
+
{ action }
|
|
32
|
+
</span>
|
|
33
|
+
) ) }
|
|
34
|
+
{ secondaryActions && (
|
|
35
|
+
<DropdownMenu
|
|
36
|
+
className="block-editor-warning__secondary"
|
|
37
|
+
icon={ moreHorizontal }
|
|
38
|
+
label={ __( 'More options' ) }
|
|
39
|
+
popoverProps={ {
|
|
40
|
+
position: 'bottom left',
|
|
41
|
+
className:
|
|
42
|
+
'block-editor-warning__dropdown',
|
|
43
|
+
} }
|
|
44
|
+
noIcons
|
|
27
45
|
>
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
onClick={ item.onClick }
|
|
48
|
-
key={ pos }
|
|
49
|
-
>
|
|
50
|
-
{ item.title }
|
|
51
|
-
</MenuItem>
|
|
52
|
-
)
|
|
53
|
-
) }
|
|
54
|
-
</MenuGroup>
|
|
55
|
-
) }
|
|
56
|
-
</DropdownMenu>
|
|
57
|
-
) }
|
|
58
|
-
</div>
|
|
59
|
-
) }
|
|
46
|
+
{ () => (
|
|
47
|
+
<MenuGroup>
|
|
48
|
+
{ secondaryActions.map(
|
|
49
|
+
( item, pos ) => (
|
|
50
|
+
<MenuItem
|
|
51
|
+
onClick={ item.onClick }
|
|
52
|
+
key={ pos }
|
|
53
|
+
>
|
|
54
|
+
{ item.title }
|
|
55
|
+
</MenuItem>
|
|
56
|
+
)
|
|
57
|
+
) }
|
|
58
|
+
</MenuGroup>
|
|
59
|
+
) }
|
|
60
|
+
</DropdownMenu>
|
|
61
|
+
) }
|
|
62
|
+
</div>
|
|
63
|
+
) }
|
|
64
|
+
</div>
|
|
60
65
|
</div>
|
|
61
66
|
</div>
|
|
62
67
|
);
|
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Warning should match snapshot 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"all": "initial",
|
|
8
|
+
"display": "contents",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
6
11
|
>
|
|
7
12
|
<div
|
|
8
|
-
className="block-editor-
|
|
13
|
+
className="block-editor-warning"
|
|
9
14
|
>
|
|
10
|
-
<
|
|
11
|
-
className="block-editor-
|
|
15
|
+
<div
|
|
16
|
+
className="block-editor-warning__contents"
|
|
12
17
|
>
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
<p
|
|
19
|
+
className="block-editor-warning__message"
|
|
20
|
+
>
|
|
21
|
+
error
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
15
24
|
</div>
|
|
16
25
|
</div>
|
|
17
26
|
`;
|