@wordpress/block-editor 8.5.4 → 9.0.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 +9 -0
- package/README.md +4 -2
- package/build/components/block-alignment-control/constants.js +48 -0
- package/build/components/block-alignment-control/constants.js.map +1 -0
- package/build/components/block-alignment-control/ui.js +9 -40
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +92 -0
- package/build/components/block-alignment-control/ui.native.js.map +1 -0
- 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-list/use-block-props/use-block-class-names.js +1 -7
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +34 -4
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +2 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +4 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- 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-navigation/dropdown.js +11 -5
- package/build/components/block-navigation/dropdown.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 +97 -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-styles/index.js +1 -10
- package/build/components/block-styles/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/color-style-selector/index.js +9 -0
- package/build/components/color-style-selector/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/index.js +0 -9
- package/build/components/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/list-view/block.js +15 -15
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/context.js +1 -4
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/list-view/index.js +15 -32
- package/build/components/list-view/index.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/url-input/index.js +7 -3
- package/build/components/url-input/index.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/components/use-setting/index.js +42 -18
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +3 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +64 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +60 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/settings.js +32 -0
- package/build/hooks/settings.js.map +1 -0
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +47 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +36 -0
- package/build-module/components/block-alignment-control/constants.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +4 -35
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +78 -0
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
- 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-list/use-block-props/use-block-class-names.js +1 -7
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -5
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +2 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +4 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- 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-navigation/dropdown.js +10 -5
- package/build-module/components/block-navigation/dropdown.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 +83 -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-styles/index.js +1 -9
- package/build-module/components/block-styles/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/color-style-selector/index.js +6 -0
- package/build-module/components/color-style-selector/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/index.js +0 -1
- package/build-module/components/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/list-view/block.js +15 -16
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -4
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -31
- package/build-module/components/list-view/index.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/url-input/index.js +7 -3
- package/build-module/components/url-input/index.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/components/use-setting/index.js +43 -19
- package/build-module/components/use-setting/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/dimensions.js +5 -5
- package/build-module/hooks/dimensions.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/margin.js +61 -13
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +57 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/settings.js +29 -0
- package/build-module/hooks/settings.js.map +1 -0
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -1
- package/build-module/store/defaults.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 +44 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +128 -276
- package/build-style/style.css +128 -276
- package/package.json +28 -28
- package/src/components/block-alignment-control/constants.js +45 -0
- package/src/components/block-alignment-control/ui.js +69 -109
- package/src/components/block-alignment-control/ui.native.js +86 -0
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-list/style.scss +7 -18
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
- package/src/components/block-lock/modal.js +42 -3
- package/src/components/block-lock/toolbar.js +2 -2
- package/src/components/block-lock/use-block-lock.js +4 -1
- 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-navigation/dropdown.js +12 -8
- 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 +90 -0
- package/src/components/block-popover/style.scss +27 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +0 -4
- 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/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/color-style-selector/index.js +18 -9
- 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/image-size-control/README.md +1 -1
- package/src/components/index.js +0 -1
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +25 -3
- package/src/components/list-view/block.js +24 -34
- package/src/components/list-view/branch.js +10 -20
- package/src/components/list-view/context.js +1 -4
- package/src/components/list-view/index.js +11 -41
- 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/url-input/index.js +6 -3
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/components/use-setting/index.js +57 -21
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/dimensions.js +44 -38
- package/src/hooks/index.js +2 -1
- package/src/hooks/margin.js +64 -15
- package/src/hooks/padding.js +60 -15
- package/src/hooks/padding.scss +12 -0
- package/src/hooks/settings.js +32 -0
- package/src/hooks/test/settings.js +48 -0
- package/src/hooks/use-border-props.js +15 -32
- package/src/store/actions.js +14 -2
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +46 -15
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +17 -19
- package/src/style.scss +2 -2
- package/tsconfig.tsbuildinfo +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/border-style-control/index.js +0 -60
- package/build/components/border-style-control/index.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/border-style-control/index.js +0 -50
- package/build-module/components/border-style-control/index.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/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { AccessibilityInfo, Platform } from 'react-native';
|
|
4
|
+
import { AccessibilityInfo, Platform, Text } from 'react-native';
|
|
5
5
|
import { delay } from 'lodash';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -15,6 +15,7 @@ import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
|
15
15
|
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
16
16
|
import {
|
|
17
17
|
Icon,
|
|
18
|
+
plus,
|
|
18
19
|
plusCircle,
|
|
19
20
|
plusCircleFilled,
|
|
20
21
|
insertAfter,
|
|
@@ -32,27 +33,51 @@ import { store as blockEditorStore } from '../../store';
|
|
|
32
33
|
|
|
33
34
|
const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
|
|
34
35
|
|
|
35
|
-
const defaultRenderToggle = ( {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
const defaultRenderToggle = ( {
|
|
37
|
+
onToggle,
|
|
38
|
+
disabled,
|
|
39
|
+
style,
|
|
40
|
+
containerStyle,
|
|
41
|
+
onLongPress,
|
|
42
|
+
useExpandedMode,
|
|
43
|
+
} ) => {
|
|
44
|
+
// The "expanded mode" refers to the editor's appearance when no blocks
|
|
45
|
+
// are currently selected. The "add block" button has a separate style
|
|
46
|
+
// for the "expanded mode", which are added via the below "expandedModeViewProps"
|
|
47
|
+
// and "expandedModeViewText" variables.
|
|
48
|
+
const expandedModeViewProps = useExpandedMode && {
|
|
49
|
+
icon: <Icon icon={ plus } style={ style } />,
|
|
50
|
+
customContainerStyles: containerStyle,
|
|
51
|
+
fixedRatio: false,
|
|
52
|
+
};
|
|
53
|
+
const expandedModeViewText = (
|
|
54
|
+
<Text style={ styles[ 'inserter-menu__add-block-button-text' ] }>
|
|
55
|
+
{ __( 'Add blocks' ) }
|
|
56
|
+
</Text>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<ToolbarButton
|
|
61
|
+
title={ _x(
|
|
62
|
+
'Add block',
|
|
63
|
+
'Generic label for block inserter button'
|
|
64
|
+
) }
|
|
65
|
+
icon={ <Icon icon={ plusCircleFilled } style={ style } /> }
|
|
66
|
+
onClick={ onToggle }
|
|
67
|
+
extraProps={ {
|
|
68
|
+
hint: __( 'Double tap to add a block' ),
|
|
69
|
+
// testID is present to disambiguate this element for native UI tests. It's not
|
|
70
|
+
// usually required for components. See: https://git.io/JeQ7G.
|
|
71
|
+
testID: 'add-block-button',
|
|
72
|
+
onLongPress,
|
|
73
|
+
} }
|
|
74
|
+
isDisabled={ disabled }
|
|
75
|
+
{ ...expandedModeViewProps }
|
|
76
|
+
>
|
|
77
|
+
{ useExpandedMode && expandedModeViewText }
|
|
78
|
+
</ToolbarButton>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
56
81
|
|
|
57
82
|
export class Inserter extends Component {
|
|
58
83
|
constructor() {
|
|
@@ -219,13 +244,21 @@ export class Inserter extends Component {
|
|
|
219
244
|
renderToggle = defaultRenderToggle,
|
|
220
245
|
getStylesFromColorScheme,
|
|
221
246
|
showSeparator,
|
|
247
|
+
useExpandedMode,
|
|
222
248
|
} = this.props;
|
|
223
249
|
if ( showSeparator && isOpen ) {
|
|
224
250
|
return <BlockInsertionPoint />;
|
|
225
251
|
}
|
|
226
|
-
const style =
|
|
227
|
-
styles
|
|
228
|
-
|
|
252
|
+
const style = useExpandedMode
|
|
253
|
+
? styles[ 'inserter-menu__add-block-button-icon--expanded' ]
|
|
254
|
+
: getStylesFromColorScheme(
|
|
255
|
+
styles[ 'inserter-menu__add-block-button-icon' ],
|
|
256
|
+
styles[ 'inserter-menu__add-block-button-icon--dark' ]
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
const containerStyle = getStylesFromColorScheme(
|
|
260
|
+
styles[ 'inserter-menu__add-block-button' ],
|
|
261
|
+
styles[ 'inserter-menu__add-block-button--dark' ]
|
|
229
262
|
);
|
|
230
263
|
|
|
231
264
|
const onPress = () => {
|
|
@@ -265,7 +298,9 @@ export class Inserter extends Component {
|
|
|
265
298
|
isOpen,
|
|
266
299
|
disabled,
|
|
267
300
|
style,
|
|
301
|
+
containerStyle,
|
|
268
302
|
onLongPress,
|
|
303
|
+
useExpandedMode,
|
|
269
304
|
} ) }
|
|
270
305
|
<Picker
|
|
271
306
|
ref={ ( instance ) => ( this.picker = instance ) }
|
|
@@ -1,13 +1,35 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
|
|
3
|
-
.
|
|
4
|
-
color: $blue-
|
|
3
|
+
.inserter-menu__add-block-button-icon {
|
|
4
|
+
color: $blue-50;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.
|
|
7
|
+
.inserter-menu__add-block-button-icon--dark {
|
|
8
8
|
color: $blue-30;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
.inserter-menu__add-block-button-icon--expanded {
|
|
12
|
+
color: $white;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.inserter-menu__add-block-button {
|
|
16
|
+
border-radius: 22px;
|
|
17
|
+
background-color: $blue-50;
|
|
18
|
+
margin: 8px;
|
|
19
|
+
padding: 6px 16px 6px 12px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.inserter-menu__add-block-button--dark {
|
|
23
|
+
background-color: $blue-30;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.inserter-menu__add-block-button-text {
|
|
27
|
+
color: $white;
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
align-self: center;
|
|
30
|
+
text-transform: capitalize;
|
|
31
|
+
}
|
|
32
|
+
|
|
11
33
|
.inserter-menu__list-wrapper {
|
|
12
34
|
flex: 1;
|
|
13
35
|
}
|
|
@@ -6,6 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
9
10
|
import {
|
|
10
11
|
__experimentalTreeGridCell as TreeGridCell,
|
|
11
12
|
__experimentalTreeGridItem as TreeGridItem,
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
useCallback,
|
|
20
21
|
memo,
|
|
21
22
|
} from '@wordpress/element';
|
|
22
|
-
import { useDispatch } from '@wordpress/data';
|
|
23
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
23
24
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -66,6 +67,19 @@ function ListViewBlock( {
|
|
|
66
67
|
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
67
68
|
|
|
68
69
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
70
|
+
const blockName = useSelect(
|
|
71
|
+
( select ) => select( blockEditorStore ).getBlockName( clientId ),
|
|
72
|
+
[ clientId ]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// When a block hides its toolbar it also hides the block settings menu,
|
|
76
|
+
// since that menu is part of the toolbar in the editor canvas.
|
|
77
|
+
// List View respects this by also hiding the block settings menu.
|
|
78
|
+
const showBlockActions = hasBlockSupport(
|
|
79
|
+
blockName,
|
|
80
|
+
'__experimentalToolbar',
|
|
81
|
+
true
|
|
82
|
+
);
|
|
69
83
|
const { isLocked } = useBlockLock( clientId );
|
|
70
84
|
const instanceId = useInstanceId( ListViewBlock );
|
|
71
85
|
const descriptionId = `list-view-block-select-button__${ instanceId }`;
|
|
@@ -98,14 +112,7 @@ function ListViewBlock( {
|
|
|
98
112
|
)
|
|
99
113
|
: __( 'Options' );
|
|
100
114
|
|
|
101
|
-
const {
|
|
102
|
-
__experimentalFeatures: withExperimentalFeatures,
|
|
103
|
-
__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,
|
|
104
|
-
__experimentalHideContainerBlockActions: hideContainerBlockActions,
|
|
105
|
-
isTreeGridMounted,
|
|
106
|
-
expand,
|
|
107
|
-
collapse,
|
|
108
|
-
} = useListViewContext();
|
|
115
|
+
const { isTreeGridMounted, expand, collapse } = useListViewContext();
|
|
109
116
|
|
|
110
117
|
const hasSiblings = siblingBlockCount > 0;
|
|
111
118
|
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
@@ -123,27 +130,19 @@ function ListViewBlock( {
|
|
|
123
130
|
// only focus the selected list item on mount; otherwise the list would always
|
|
124
131
|
// try to steal the focus from the editor canvas.
|
|
125
132
|
useEffect( () => {
|
|
126
|
-
if (
|
|
127
|
-
withExperimentalPersistentListViewFeatures &&
|
|
128
|
-
! isTreeGridMounted &&
|
|
129
|
-
isSelected
|
|
130
|
-
) {
|
|
133
|
+
if ( ! isTreeGridMounted && isSelected ) {
|
|
131
134
|
cellRef.current.focus();
|
|
132
135
|
}
|
|
133
136
|
}, [] );
|
|
134
137
|
|
|
135
|
-
const highlightBlock = withExperimentalPersistentListViewFeatures
|
|
136
|
-
? toggleBlockHighlight
|
|
137
|
-
: () => {};
|
|
138
|
-
|
|
139
138
|
const onMouseEnter = useCallback( () => {
|
|
140
139
|
setIsHovered( true );
|
|
141
|
-
|
|
142
|
-
}, [ clientId, setIsHovered,
|
|
140
|
+
toggleBlockHighlight( clientId, true );
|
|
141
|
+
}, [ clientId, setIsHovered, toggleBlockHighlight ] );
|
|
143
142
|
const onMouseLeave = useCallback( () => {
|
|
144
143
|
setIsHovered( false );
|
|
145
|
-
|
|
146
|
-
}, [ clientId, setIsHovered,
|
|
144
|
+
toggleBlockHighlight( clientId, false );
|
|
145
|
+
}, [ clientId, setIsHovered, toggleBlockHighlight ] );
|
|
147
146
|
|
|
148
147
|
const selectEditorBlock = useCallback(
|
|
149
148
|
( event ) => {
|
|
@@ -174,18 +173,10 @@ function ListViewBlock( {
|
|
|
174
173
|
[ clientId, expand, collapse, isExpanded ]
|
|
175
174
|
);
|
|
176
175
|
|
|
177
|
-
const showBlockActions =
|
|
178
|
-
withExperimentalFeatures &&
|
|
179
|
-
// hide actions for blocks like core/widget-areas
|
|
180
|
-
( ! hideContainerBlockActions ||
|
|
181
|
-
( hideContainerBlockActions && level > 1 ) );
|
|
182
|
-
|
|
183
|
-
const hideBlockActions = withExperimentalFeatures && ! showBlockActions;
|
|
184
|
-
|
|
185
176
|
let colSpan;
|
|
186
177
|
if ( hasRenderedMovers ) {
|
|
187
178
|
colSpan = 2;
|
|
188
|
-
} else if (
|
|
179
|
+
} else if ( ! showBlockActions ) {
|
|
189
180
|
colSpan = 3;
|
|
190
181
|
}
|
|
191
182
|
|
|
@@ -193,10 +184,9 @@ function ListViewBlock( {
|
|
|
193
184
|
'is-selected': isSelected,
|
|
194
185
|
'is-first-selected': isFirstSelectedBlock,
|
|
195
186
|
'is-last-selected': isLastSelectedBlock,
|
|
196
|
-
'is-branch-selected':
|
|
197
|
-
withExperimentalPersistentListViewFeatures && isBranchSelected,
|
|
187
|
+
'is-branch-selected': isBranchSelected,
|
|
198
188
|
'is-dragging': isDragged,
|
|
199
|
-
'has-single-cell':
|
|
189
|
+
'has-single-cell': ! showBlockActions,
|
|
200
190
|
} );
|
|
201
191
|
|
|
202
192
|
// Only include all selected blocks if the currently clicked on block
|
|
@@ -85,21 +85,16 @@ function ListViewBranch( props ) {
|
|
|
85
85
|
blocks,
|
|
86
86
|
selectBlock,
|
|
87
87
|
showBlockMovers,
|
|
88
|
-
showNestedBlocks,
|
|
89
88
|
selectedClientIds,
|
|
90
89
|
level = 1,
|
|
91
90
|
path = '',
|
|
92
91
|
isBranchSelected = false,
|
|
93
92
|
listPosition = 0,
|
|
94
93
|
fixedListWindow,
|
|
95
|
-
|
|
94
|
+
isExpanded,
|
|
96
95
|
} = props;
|
|
97
96
|
|
|
98
|
-
const {
|
|
99
|
-
expandedState,
|
|
100
|
-
draggedClientIds,
|
|
101
|
-
__experimentalPersistentListViewFeatures,
|
|
102
|
-
} = useListViewContext();
|
|
97
|
+
const { expandedState, draggedClientIds } = useListViewContext();
|
|
103
98
|
|
|
104
99
|
const filteredBlocks = compact( blocks );
|
|
105
100
|
const blockCount = filteredBlocks.length;
|
|
@@ -115,26 +110,22 @@ function ListViewBranch( props ) {
|
|
|
115
110
|
filteredBlocks[ index - 1 ],
|
|
116
111
|
expandedState,
|
|
117
112
|
draggedClientIds,
|
|
118
|
-
|
|
113
|
+
isExpanded
|
|
119
114
|
);
|
|
120
115
|
}
|
|
121
116
|
|
|
122
|
-
const usesWindowing = __experimentalPersistentListViewFeatures;
|
|
123
|
-
|
|
124
117
|
const { itemInView } = fixedListWindow;
|
|
125
|
-
const blockInView =
|
|
126
|
-
! usesWindowing || itemInView( nextPosition );
|
|
118
|
+
const blockInView = itemInView( nextPosition );
|
|
127
119
|
|
|
128
120
|
const position = index + 1;
|
|
129
121
|
const updatedPath =
|
|
130
122
|
path.length > 0
|
|
131
123
|
? `${ path }_${ position }`
|
|
132
124
|
: `${ position }`;
|
|
133
|
-
const hasNestedBlocks =
|
|
134
|
-
showNestedBlocks && !! innerBlocks && !! innerBlocks.length;
|
|
125
|
+
const hasNestedBlocks = !! innerBlocks?.length;
|
|
135
126
|
|
|
136
|
-
const
|
|
137
|
-
? expandedState[ clientId ] ??
|
|
127
|
+
const shouldExpand = hasNestedBlocks
|
|
128
|
+
? expandedState[ clientId ] ?? isExpanded
|
|
138
129
|
: undefined;
|
|
139
130
|
|
|
140
131
|
const isDragged = !! draggedClientIds?.includes( clientId );
|
|
@@ -164,7 +155,7 @@ function ListViewBranch( props ) {
|
|
|
164
155
|
siblingBlockCount={ blockCount }
|
|
165
156
|
showBlockMovers={ showBlockMovers }
|
|
166
157
|
path={ updatedPath }
|
|
167
|
-
isExpanded={
|
|
158
|
+
isExpanded={ shouldExpand }
|
|
168
159
|
listPosition={ nextPosition }
|
|
169
160
|
selectedClientIds={ selectedClientIds }
|
|
170
161
|
/>
|
|
@@ -174,19 +165,18 @@ function ListViewBranch( props ) {
|
|
|
174
165
|
<td className="block-editor-list-view-placeholder" />
|
|
175
166
|
</tr>
|
|
176
167
|
) }
|
|
177
|
-
{ hasNestedBlocks &&
|
|
168
|
+
{ hasNestedBlocks && shouldExpand && ! isDragged && (
|
|
178
169
|
<ListViewBranch
|
|
179
170
|
blocks={ innerBlocks }
|
|
180
171
|
selectBlock={ selectBlock }
|
|
181
172
|
showBlockMovers={ showBlockMovers }
|
|
182
|
-
showNestedBlocks={ showNestedBlocks }
|
|
183
173
|
level={ level + 1 }
|
|
184
174
|
path={ updatedPath }
|
|
185
175
|
listPosition={ nextPosition + 1 }
|
|
186
176
|
fixedListWindow={ fixedListWindow }
|
|
187
177
|
isBranchSelected={ isSelectedBranch }
|
|
188
178
|
selectedClientIds={ selectedClientIds }
|
|
189
|
-
|
|
179
|
+
isExpanded={ isExpanded }
|
|
190
180
|
/>
|
|
191
181
|
) }
|
|
192
182
|
</AsyncModeProvider>
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createContext, useContext } from '@wordpress/element';
|
|
5
5
|
|
|
6
|
-
export const ListViewContext = createContext( {
|
|
7
|
-
__experimentalFeatures: false,
|
|
8
|
-
__experimentalPersistentListViewFeatures: false,
|
|
9
|
-
} );
|
|
6
|
+
export const ListViewContext = createContext( {} );
|
|
10
7
|
|
|
11
8
|
export const useListViewContext = () => useContext( ListViewContext );
|
|
@@ -48,33 +48,17 @@ const expanded = ( state, action ) => {
|
|
|
48
48
|
export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
* recursive component (it renders itself), so this ensures TreeGrid is only
|
|
53
|
-
* present at the very top of the navigation grid.
|
|
51
|
+
* Show a hierarchical list of blocks.
|
|
54
52
|
*
|
|
55
|
-
* @param {Object} props
|
|
56
|
-
* @param {
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {boolean} props.showBlockMovers
|
|
59
|
-
* @param {boolean} props.
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)
|
|
62
|
-
* @param {string} props.id Unique identifier for the root list element (primarily for a11y purposes).
|
|
63
|
-
* @param {boolean} props.expandNested Flag to determine whether nested levels are expanded by default.
|
|
64
|
-
* @param {Object} ref Forwarded ref
|
|
53
|
+
* @param {Object} props Components props.
|
|
54
|
+
* @param {string} props.id An HTML element id for the root element of ListView.
|
|
55
|
+
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
56
|
+
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
57
|
+
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
|
|
58
|
+
* @param {Object} ref Forwarded ref
|
|
65
59
|
*/
|
|
66
60
|
function ListView(
|
|
67
|
-
{
|
|
68
|
-
blocks,
|
|
69
|
-
__experimentalFeatures,
|
|
70
|
-
__experimentalPersistentListViewFeatures,
|
|
71
|
-
__experimentalHideContainerBlockActions,
|
|
72
|
-
showNestedBlocks,
|
|
73
|
-
showBlockMovers,
|
|
74
|
-
id,
|
|
75
|
-
expandNested = false,
|
|
76
|
-
...props
|
|
77
|
-
},
|
|
61
|
+
{ id, blocks, showBlockMovers = false, isExpanded = false },
|
|
78
62
|
ref
|
|
79
63
|
) {
|
|
80
64
|
const {
|
|
@@ -131,7 +115,7 @@ function ListView(
|
|
|
131
115
|
BLOCK_LIST_ITEM_HEIGHT,
|
|
132
116
|
visibleBlockCount,
|
|
133
117
|
{
|
|
134
|
-
useWindowing:
|
|
118
|
+
useWindowing: true,
|
|
135
119
|
windowOverscan: 40,
|
|
136
120
|
}
|
|
137
121
|
);
|
|
@@ -181,25 +165,13 @@ function ListView(
|
|
|
181
165
|
|
|
182
166
|
const contextValue = useMemo(
|
|
183
167
|
() => ( {
|
|
184
|
-
__experimentalFeatures,
|
|
185
|
-
__experimentalPersistentListViewFeatures,
|
|
186
|
-
__experimentalHideContainerBlockActions,
|
|
187
168
|
isTreeGridMounted: isMounted.current,
|
|
188
169
|
draggedClientIds,
|
|
189
170
|
expandedState,
|
|
190
171
|
expand,
|
|
191
172
|
collapse,
|
|
192
173
|
} ),
|
|
193
|
-
[
|
|
194
|
-
__experimentalFeatures,
|
|
195
|
-
__experimentalPersistentListViewFeatures,
|
|
196
|
-
__experimentalHideContainerBlockActions,
|
|
197
|
-
isMounted.current,
|
|
198
|
-
draggedClientIds,
|
|
199
|
-
expandedState,
|
|
200
|
-
expand,
|
|
201
|
-
collapse,
|
|
202
|
-
]
|
|
174
|
+
[ isMounted.current, draggedClientIds, expandedState, expand, collapse ]
|
|
203
175
|
);
|
|
204
176
|
|
|
205
177
|
return (
|
|
@@ -221,12 +193,10 @@ function ListView(
|
|
|
221
193
|
<ListViewBranch
|
|
222
194
|
blocks={ clientIdsTree }
|
|
223
195
|
selectBlock={ selectEditorBlock }
|
|
224
|
-
showNestedBlocks={ showNestedBlocks }
|
|
225
196
|
showBlockMovers={ showBlockMovers }
|
|
226
197
|
fixedListWindow={ fixedListWindow }
|
|
227
198
|
selectedClientIds={ selectedClientIds }
|
|
228
|
-
|
|
229
|
-
{ ...props }
|
|
199
|
+
isExpanded={ isExpanded }
|
|
230
200
|
/>
|
|
231
201
|
</ListViewContext.Provider>
|
|
232
202
|
</TreeGrid>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# NavigableToolbar
|
|
2
|
+
|
|
3
|
+
A toolbar that can be navigated with a keyboard
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
The component accepts the following props. Props not included in this set will be applied to the element wrapping NavigableMenu content.
|
|
8
|
+
|
|
9
|
+
## `focusOnMount`
|
|
10
|
+
|
|
11
|
+
Whether to immediately focus when the component mounts.
|
|
12
|
+
|
|
13
|
+
- Type: `Boolean`
|
|
14
|
+
- Required: No
|
|
15
|
+
- Default: false
|
|
16
|
+
|
|
@@ -36,7 +36,6 @@ import { useBlockEditContext } from '../block-edit';
|
|
|
36
36
|
import FormatToolbarContainer from './format-toolbar-container';
|
|
37
37
|
import { store as blockEditorStore } from '../../store';
|
|
38
38
|
import { useUndoAutomaticChange } from './use-undo-automatic-change';
|
|
39
|
-
import { useCaretInFormat } from './use-caret-in-format';
|
|
40
39
|
import { useMarkPersistent } from './use-mark-persistent';
|
|
41
40
|
import { usePasteHandler } from './use-paste-handler';
|
|
42
41
|
import { useInputRules } from './use-input-rules';
|
|
@@ -268,7 +267,6 @@ function RichTextWrapper(
|
|
|
268
267
|
onChange,
|
|
269
268
|
} );
|
|
270
269
|
|
|
271
|
-
useCaretInFormat( { value } );
|
|
272
270
|
useMarkPersistent( { html: adjustedValue, value } );
|
|
273
271
|
|
|
274
272
|
const keyboardShortcuts = useRef( new Set() );
|
|
@@ -125,7 +125,6 @@ function RichTextWrapper(
|
|
|
125
125
|
const embedHandlerPickerRef = useRef();
|
|
126
126
|
const selector = ( select ) => {
|
|
127
127
|
const {
|
|
128
|
-
isCaretWithinFormattedText,
|
|
129
128
|
getSelectionStart,
|
|
130
129
|
getSelectionEnd,
|
|
131
130
|
getSettings,
|
|
@@ -163,7 +162,6 @@ function RichTextWrapper(
|
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
return {
|
|
166
|
-
isCaretWithinFormattedText: isCaretWithinFormattedText(),
|
|
167
165
|
selectionStart: isSelected ? selectionStart.offset : undefined,
|
|
168
166
|
selectionEnd: isSelected ? selectionEnd.offset : undefined,
|
|
169
167
|
isSelected,
|
|
@@ -177,7 +175,6 @@ function RichTextWrapper(
|
|
|
177
175
|
// retrieved from the store on merge.
|
|
178
176
|
// To do: fix this somehow.
|
|
179
177
|
const {
|
|
180
|
-
isCaretWithinFormattedText,
|
|
181
178
|
selectionStart,
|
|
182
179
|
selectionEnd,
|
|
183
180
|
isSelected,
|
|
@@ -600,7 +597,6 @@ function RichTextWrapper(
|
|
|
600
597
|
__unstableIsSelected={ isSelected }
|
|
601
598
|
__unstableInputRule={ inputRule }
|
|
602
599
|
__unstableMultilineTag={ multilineTag }
|
|
603
|
-
__unstableIsCaretWithinFormattedText={ isCaretWithinFormattedText }
|
|
604
600
|
__unstableOnEnterFormattedText={ enterFormattedText }
|
|
605
601
|
__unstableOnExitFormattedText={ exitFormattedText }
|
|
606
602
|
__unstableOnCreateUndoLevel={ __unstableMarkLastChangeAsPersistent }
|
|
@@ -418,7 +418,7 @@ class URLInput extends Component {
|
|
|
418
418
|
|
|
419
419
|
renderControl() {
|
|
420
420
|
const {
|
|
421
|
-
label,
|
|
421
|
+
label = null,
|
|
422
422
|
className,
|
|
423
423
|
isFullWidth,
|
|
424
424
|
instanceId,
|
|
@@ -435,8 +435,10 @@ class URLInput extends Component {
|
|
|
435
435
|
suggestionOptionIdPrefix,
|
|
436
436
|
} = this.state;
|
|
437
437
|
|
|
438
|
+
const inputId = `url-input-control-${ instanceId }`;
|
|
439
|
+
|
|
438
440
|
const controlProps = {
|
|
439
|
-
id:
|
|
441
|
+
id: inputId, // Passes attribute to label for the for attribute
|
|
440
442
|
label,
|
|
441
443
|
className: classnames( 'block-editor-url-input', className, {
|
|
442
444
|
'is-full-width': isFullWidth,
|
|
@@ -444,6 +446,7 @@ class URLInput extends Component {
|
|
|
444
446
|
};
|
|
445
447
|
|
|
446
448
|
const inputProps = {
|
|
449
|
+
id: inputId,
|
|
447
450
|
value,
|
|
448
451
|
required: true,
|
|
449
452
|
className: 'block-editor-url-input__input',
|
|
@@ -453,7 +456,7 @@ class URLInput extends Component {
|
|
|
453
456
|
placeholder,
|
|
454
457
|
onKeyDown: this.onKeyDown,
|
|
455
458
|
role: 'combobox',
|
|
456
|
-
'aria-label': __( 'URL' ),
|
|
459
|
+
'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label
|
|
457
460
|
'aria-expanded': showSuggestions,
|
|
458
461
|
'aria-autocomplete': 'list',
|
|
459
462
|
'aria-owns': suggestionsListboxId,
|
|
@@ -19,6 +19,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
19
19
|
* @property {string} title Human-readable block type label.
|
|
20
20
|
* @property {WPIcon} icon Block type icon.
|
|
21
21
|
* @property {string} description A detailed block type description.
|
|
22
|
+
* @property {string} anchor HTML anchor.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -63,6 +64,7 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
63
64
|
title: match.title || blockType.title,
|
|
64
65
|
icon: match.icon || blockType.icon,
|
|
65
66
|
description: match.description || blockType.description,
|
|
67
|
+
anchor: attributes?.anchor,
|
|
66
68
|
};
|
|
67
69
|
},
|
|
68
70
|
[ clientId ]
|