@wordpress/block-editor 11.4.0 → 11.5.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 +6 -0
- package/build/components/block-inspector/index.js +11 -10
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +72 -36
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +20 -6
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +25 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +10 -11
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +5 -108
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +242 -0
- package/build/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +1 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +1 -0
- package/build/components/link-control/settings.js.map +1 -1
- package/build/components/list-view/block.js +17 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -2
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/leaf.js +10 -6
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
- package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build/components/off-canvas-editor/appender.js +5 -10
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +1 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +7 -3
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +1 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/index.js +9 -43
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/dimensions.js +72 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +0 -202
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +14 -5
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/typography.js +50 -65
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +75 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +24 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +28 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +5 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +36 -3
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-inspector/index.js +9 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +71 -33
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +26 -11
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +10 -11
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +6 -105
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +222 -0
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +1 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +1 -0
- package/build-module/components/link-control/settings.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -2
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/leaf.js +8 -4
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
- package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build-module/components/off-canvas-editor/appender.js +5 -10
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +1 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +7 -3
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -43
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/dimensions.js +75 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +0 -183
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +14 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/typography.js +52 -65
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +70 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +24 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +28 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +5 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +36 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +33 -21
- package/build-style/style.css +33 -21
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-inspector/index.js +11 -14
- package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +88 -45
- package/src/components/global-styles/index.js +5 -1
- package/src/components/global-styles/typography-panel.js +33 -8
- package/src/components/global-styles/use-global-styles-output.js +4 -3
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/media-tab/hooks.js +9 -8
- package/src/components/inserter/media-tab/media-list.js +3 -122
- package/src/components/inserter/media-tab/media-preview.js +268 -0
- package/src/components/inserter/style.scss +22 -0
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/settings-drawer.js +2 -1
- package/src/components/link-control/settings.js +1 -0
- package/src/components/link-control/style.scss +18 -8
- package/src/components/link-control/test/index.js +3 -3
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/branch.js +1 -2
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/leaf.js +43 -29
- package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/off-canvas-editor/appender.js +13 -16
- package/src/components/off-canvas-editor/branch.js +1 -0
- package/src/components/off-canvas-editor/index.js +8 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
- package/src/components/off-canvas-editor/link-ui.js +1 -0
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/index.js +8 -44
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/spacing-sizes-control/style.scss +1 -1
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/dimensions.js +85 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/gap.js +0 -208
- package/src/hooks/layout.js +19 -6
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/typography.js +66 -88
- package/src/hooks/utils.js +90 -0
- package/src/layouts/flex.js +1 -0
- package/src/store/actions.js +12 -4
- package/src/store/defaults.js +14 -1
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +8 -1
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +35 -5
- package/src/utils/test/parse-css-unit-to-px.js +12 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/min-height.js +0 -104
|
@@ -8,6 +8,8 @@ import classnames from 'classnames';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { __experimentalTreeGridRow as TreeGridRow } from '@wordpress/components';
|
|
11
|
+
import { useMergeRefs } from '@wordpress/compose';
|
|
12
|
+
import { forwardRef } from '@wordpress/element';
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Internal dependencies
|
|
@@ -16,33 +18,45 @@ import useMovingAnimation from '../use-moving-animation';
|
|
|
16
18
|
|
|
17
19
|
const AnimatedTreeGridRow = animated( TreeGridRow );
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
const ListViewLeaf = forwardRef(
|
|
22
|
+
(
|
|
23
|
+
{
|
|
24
|
+
isSelected,
|
|
25
|
+
position,
|
|
26
|
+
level,
|
|
27
|
+
rowCount,
|
|
28
|
+
children,
|
|
29
|
+
className,
|
|
30
|
+
path,
|
|
31
|
+
...props
|
|
32
|
+
},
|
|
33
|
+
ref
|
|
34
|
+
) => {
|
|
35
|
+
const animationRef = useMovingAnimation( {
|
|
36
|
+
isSelected,
|
|
37
|
+
adjustScrolling: false,
|
|
38
|
+
enableAnimation: true,
|
|
39
|
+
triggerAnimationOnChange: path,
|
|
40
|
+
} );
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
42
|
+
const mergedRef = useMergeRefs( [ ref, animationRef ] );
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<AnimatedTreeGridRow
|
|
46
|
+
ref={ mergedRef }
|
|
47
|
+
className={ classnames(
|
|
48
|
+
'block-editor-list-view-leaf',
|
|
49
|
+
className
|
|
50
|
+
) }
|
|
51
|
+
level={ level }
|
|
52
|
+
positionInSet={ position }
|
|
53
|
+
setSize={ rowCount }
|
|
54
|
+
{ ...props }
|
|
55
|
+
>
|
|
56
|
+
{ children }
|
|
57
|
+
</AnimatedTreeGridRow>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export default ListViewLeaf;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getScrollContainer } from '@wordpress/dom';
|
|
5
|
+
import { useLayoutEffect } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
export default function useListViewScrollIntoView( {
|
|
8
|
+
isSelected,
|
|
9
|
+
selectedClientIds,
|
|
10
|
+
rowItemRef,
|
|
11
|
+
} ) {
|
|
12
|
+
const isSingleSelection = selectedClientIds.length === 1;
|
|
13
|
+
|
|
14
|
+
useLayoutEffect( () => {
|
|
15
|
+
// Skip scrolling into view if this particular block isn't selected,
|
|
16
|
+
// or if more than one block is selected overall. This is to avoid
|
|
17
|
+
// scrolling the view in a multi selection where the user has intentionally
|
|
18
|
+
// selected multiple blocks within the list view, but the initially
|
|
19
|
+
// selected block may be out of view.
|
|
20
|
+
if ( ! isSelected || ! isSingleSelection || ! rowItemRef.current ) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const scrollContainer = getScrollContainer( rowItemRef.current );
|
|
25
|
+
const { ownerDocument } = rowItemRef.current;
|
|
26
|
+
|
|
27
|
+
const windowScroll =
|
|
28
|
+
scrollContainer === ownerDocument.body ||
|
|
29
|
+
scrollContainer === ownerDocument.documentElement;
|
|
30
|
+
|
|
31
|
+
// If the there is no scroll container, of if the scroll container is the window,
|
|
32
|
+
// do not scroll into view, as the block is already in view.
|
|
33
|
+
if ( windowScroll || ! scrollContainer ) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const rowRect = rowItemRef.current.getBoundingClientRect();
|
|
38
|
+
const scrollContainerRect = scrollContainer.getBoundingClientRect();
|
|
39
|
+
|
|
40
|
+
// If the selected block is not currently visible, scroll to it.
|
|
41
|
+
if (
|
|
42
|
+
rowRect.top < scrollContainerRect.top ||
|
|
43
|
+
rowRect.bottom > scrollContainerRect.bottom
|
|
44
|
+
) {
|
|
45
|
+
rowItemRef.current.scrollIntoView();
|
|
46
|
+
}
|
|
47
|
+
}, [ isSelected, isSingleSelection, rowItemRef ] );
|
|
48
|
+
}
|
|
@@ -23,24 +23,22 @@
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.block-editor-link-control {
|
|
26
|
-
width:
|
|
26
|
+
width: 300px; // Hardcoded width avoids resizing of control when switching between preview/edit.
|
|
27
27
|
|
|
28
28
|
.block-editor-url-input {
|
|
29
29
|
padding: 0; // Cancel unnecessary default 1px padding in this case.
|
|
30
30
|
margin: 0; // Reset default LinkControl margins.
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.block-editor-link-control__search-item-title {
|
|
38
|
-
max-width: 180px;
|
|
33
|
+
.block-editor-link-control__search-item-title,
|
|
34
|
+
.block-editor-link-control__search-item-info {
|
|
35
|
+
max-width: 200px;
|
|
39
36
|
white-space: nowrap;
|
|
40
37
|
}
|
|
41
38
|
|
|
42
|
-
.block-editor-link-
|
|
43
|
-
|
|
39
|
+
.block-editor-link-control__tools {
|
|
40
|
+
justify-content: flex-end;
|
|
41
|
+
padding: $grid-unit-20 var(--wp-admin-border-width-focus) var(--wp-admin-border-width-focus);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
.block-editor-link-control__search-item.is-current {
|
|
@@ -15,26 +15,23 @@ import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
|
15
15
|
import Inserter from '../inserter';
|
|
16
16
|
|
|
17
17
|
export const Appender = forwardRef(
|
|
18
|
-
( { nestingLevel, blockCount, ...props }, ref ) => {
|
|
18
|
+
( { nestingLevel, blockCount, clientId, ...props }, ref ) => {
|
|
19
19
|
const [ insertedBlock, setInsertedBlock ] = useState( null );
|
|
20
20
|
|
|
21
21
|
const instanceId = useInstanceId( Appender );
|
|
22
|
-
const { hideInserter
|
|
23
|
-
|
|
24
|
-
getTemplateLock,
|
|
25
|
-
|
|
26
|
-
getSelectedBlockClientId,
|
|
27
|
-
} = select( blockEditorStore );
|
|
22
|
+
const { hideInserter } = useSelect(
|
|
23
|
+
( select ) => {
|
|
24
|
+
const { getTemplateLock, __unstableGetEditorMode } =
|
|
25
|
+
select( blockEditorStore );
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, [] );
|
|
27
|
+
return {
|
|
28
|
+
hideInserter:
|
|
29
|
+
!! getTemplateLock( clientId ) ||
|
|
30
|
+
__unstableGetEditorMode() === 'zoom-out',
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
[ clientId ]
|
|
34
|
+
);
|
|
38
35
|
|
|
39
36
|
const blockTitle = useBlockDisplayTitle( {
|
|
40
37
|
clientId,
|
|
@@ -80,9 +80,10 @@ function OffCanvasEditor(
|
|
|
80
80
|
const { clientIdsTree, draggedClientIds, selectedClientIds } =
|
|
81
81
|
useListViewClientIds( blocks );
|
|
82
82
|
|
|
83
|
-
const { visibleBlockCount, shouldShowInnerBlocks } = useSelect(
|
|
83
|
+
const { visibleBlockCount, shouldShowInnerBlocks, parentId } = useSelect(
|
|
84
84
|
( select ) => {
|
|
85
85
|
const {
|
|
86
|
+
getBlockRootClientId,
|
|
86
87
|
getGlobalBlockCount,
|
|
87
88
|
getClientIdsOfDescendants,
|
|
88
89
|
__unstableGetEditorMode,
|
|
@@ -94,9 +95,13 @@ function OffCanvasEditor(
|
|
|
94
95
|
return {
|
|
95
96
|
visibleBlockCount: getGlobalBlockCount() - draggedBlockCount,
|
|
96
97
|
shouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',
|
|
98
|
+
parentId:
|
|
99
|
+
blocks.length > 0
|
|
100
|
+
? getBlockRootClientId( blocks[ 0 ].clientId )
|
|
101
|
+
: undefined,
|
|
97
102
|
};
|
|
98
103
|
},
|
|
99
|
-
[ draggedClientIds ]
|
|
104
|
+
[ draggedClientIds, blocks ]
|
|
100
105
|
);
|
|
101
106
|
|
|
102
107
|
const { updateBlockSelection } = useBlockSelection();
|
|
@@ -227,6 +232,7 @@ function OffCanvasEditor(
|
|
|
227
232
|
>
|
|
228
233
|
<ListViewContext.Provider value={ contextValue }>
|
|
229
234
|
<ListViewBranch
|
|
235
|
+
parentId={ parentId }
|
|
230
236
|
blocks={ clientIdsTree }
|
|
231
237
|
selectBlock={ selectEditorBlock }
|
|
232
238
|
showBlockMovers={ showBlockMovers }
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
addSubmenu,
|
|
7
|
+
chevronUp,
|
|
8
|
+
chevronDown,
|
|
9
|
+
moreVertical,
|
|
10
|
+
} from '@wordpress/icons';
|
|
6
11
|
import { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';
|
|
7
|
-
import { useDispatch } from '@wordpress/data';
|
|
12
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
13
|
import { __, sprintf } from '@wordpress/i18n';
|
|
9
14
|
|
|
10
15
|
/**
|
|
@@ -12,6 +17,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
12
17
|
*/
|
|
13
18
|
import { store as blockEditorStore } from '../../store';
|
|
14
19
|
import BlockTitle from '../block-title';
|
|
20
|
+
import { useListViewContext } from './context';
|
|
15
21
|
|
|
16
22
|
const POPOVER_PROPS = {
|
|
17
23
|
className: 'block-editor-block-settings-menu__popover',
|
|
@@ -25,6 +31,7 @@ const BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU = [
|
|
|
25
31
|
];
|
|
26
32
|
|
|
27
33
|
function AddSubmenuItem( { block, onClose } ) {
|
|
34
|
+
const { expandedState, expand } = useListViewContext();
|
|
28
35
|
const { insertBlock, replaceBlock, replaceInnerBlocks } =
|
|
29
36
|
useDispatch( blockEditorStore );
|
|
30
37
|
|
|
@@ -69,6 +76,9 @@ function AddSubmenuItem( { block, onClose } ) {
|
|
|
69
76
|
updateSelectionOnInsert
|
|
70
77
|
);
|
|
71
78
|
}
|
|
79
|
+
if ( ! expandedState[ block.clientId ] ) {
|
|
80
|
+
expand( block.clientId );
|
|
81
|
+
}
|
|
72
82
|
onClose();
|
|
73
83
|
} }
|
|
74
84
|
>
|
|
@@ -80,14 +90,24 @@ function AddSubmenuItem( { block, onClose } ) {
|
|
|
80
90
|
export default function LeafMoreMenu( props ) {
|
|
81
91
|
const { clientId, block } = props;
|
|
82
92
|
|
|
83
|
-
const { removeBlocks } =
|
|
93
|
+
const { moveBlocksDown, moveBlocksUp, removeBlocks } =
|
|
94
|
+
useDispatch( blockEditorStore );
|
|
84
95
|
|
|
85
|
-
const
|
|
96
|
+
const removeLabel = sprintf(
|
|
86
97
|
/* translators: %s: block name */
|
|
87
98
|
__( 'Remove %s' ),
|
|
88
99
|
BlockTitle( { clientId, maximumLength: 25 } )
|
|
89
100
|
);
|
|
90
101
|
|
|
102
|
+
const rootClientId = useSelect(
|
|
103
|
+
( select ) => {
|
|
104
|
+
const { getBlockRootClientId } = select( blockEditorStore );
|
|
105
|
+
|
|
106
|
+
return getBlockRootClientId( clientId );
|
|
107
|
+
},
|
|
108
|
+
[ clientId ]
|
|
109
|
+
);
|
|
110
|
+
|
|
91
111
|
return (
|
|
92
112
|
<DropdownMenu
|
|
93
113
|
icon={ moreVertical }
|
|
@@ -98,17 +118,39 @@ export default function LeafMoreMenu( props ) {
|
|
|
98
118
|
{ ...props }
|
|
99
119
|
>
|
|
100
120
|
{ ( { onClose } ) => (
|
|
101
|
-
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
<>
|
|
122
|
+
<MenuGroup>
|
|
123
|
+
<MenuItem
|
|
124
|
+
icon={ chevronUp }
|
|
125
|
+
onClick={ () => {
|
|
126
|
+
moveBlocksUp( [ clientId ], rootClientId );
|
|
127
|
+
onClose();
|
|
128
|
+
} }
|
|
129
|
+
>
|
|
130
|
+
{ __( 'Move up' ) }
|
|
131
|
+
</MenuItem>
|
|
132
|
+
<MenuItem
|
|
133
|
+
icon={ chevronDown }
|
|
134
|
+
onClick={ () => {
|
|
135
|
+
moveBlocksDown( [ clientId ], rootClientId );
|
|
136
|
+
onClose();
|
|
137
|
+
} }
|
|
138
|
+
>
|
|
139
|
+
{ __( 'Move down' ) }
|
|
140
|
+
</MenuItem>
|
|
141
|
+
<AddSubmenuItem block={ block } onClose={ onClose } />
|
|
142
|
+
</MenuGroup>
|
|
143
|
+
<MenuGroup>
|
|
144
|
+
<MenuItem
|
|
145
|
+
onClick={ () => {
|
|
146
|
+
removeBlocks( [ clientId ], false );
|
|
147
|
+
onClose();
|
|
148
|
+
} }
|
|
149
|
+
>
|
|
150
|
+
{ removeLabel }
|
|
151
|
+
</MenuItem>
|
|
152
|
+
</MenuGroup>
|
|
153
|
+
</>
|
|
112
154
|
) }
|
|
113
155
|
</DropdownMenu>
|
|
114
156
|
);
|
|
@@ -92,6 +92,7 @@ function ResponsiveBlockControl( props ) {
|
|
|
92
92
|
|
|
93
93
|
<div className="block-editor-responsive-block-control__inner">
|
|
94
94
|
<ToggleControl
|
|
95
|
+
__nextHasNoMarginBottom
|
|
95
96
|
className="block-editor-responsive-block-control__toggle"
|
|
96
97
|
label={ toggleControlLabel }
|
|
97
98
|
checked={ ! isResponsive }
|
|
@@ -19,12 +19,9 @@ import { useInstanceId, useMergeRefs } from '@wordpress/compose';
|
|
|
19
19
|
import {
|
|
20
20
|
__unstableUseRichText as useRichText,
|
|
21
21
|
__unstableCreateElement,
|
|
22
|
-
isEmpty,
|
|
23
|
-
isCollapsed,
|
|
24
22
|
removeFormat,
|
|
25
23
|
} from '@wordpress/rich-text';
|
|
26
24
|
import deprecated from '@wordpress/deprecated';
|
|
27
|
-
import { BACKSPACE, DELETE } from '@wordpress/keycodes';
|
|
28
25
|
import { Popover } from '@wordpress/components';
|
|
29
26
|
|
|
30
27
|
/**
|
|
@@ -39,6 +36,7 @@ import { useMarkPersistent } from './use-mark-persistent';
|
|
|
39
36
|
import { usePasteHandler } from './use-paste-handler';
|
|
40
37
|
import { useBeforeInputRules } from './use-before-input-rules';
|
|
41
38
|
import { useInputRules } from './use-input-rules';
|
|
39
|
+
import { useDelete } from './use-delete';
|
|
42
40
|
import { useEnter } from './use-enter';
|
|
43
41
|
import { useFormatTypes } from './use-format-types';
|
|
44
42
|
import { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';
|
|
@@ -280,6 +278,7 @@ function RichTextWrapper(
|
|
|
280
278
|
|
|
281
279
|
const {
|
|
282
280
|
value,
|
|
281
|
+
getValue,
|
|
283
282
|
onChange,
|
|
284
283
|
ref: richTextRef,
|
|
285
284
|
} = useRichText( {
|
|
@@ -315,45 +314,6 @@ function RichTextWrapper(
|
|
|
315
314
|
const keyboardShortcuts = useRef( new Set() );
|
|
316
315
|
const inputEvents = useRef( new Set() );
|
|
317
316
|
|
|
318
|
-
function onKeyDown( event ) {
|
|
319
|
-
const { keyCode } = event;
|
|
320
|
-
|
|
321
|
-
if ( event.defaultPrevented ) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if ( keyCode === DELETE || keyCode === BACKSPACE ) {
|
|
326
|
-
const { start, end, text } = value;
|
|
327
|
-
const isReverse = keyCode === BACKSPACE;
|
|
328
|
-
const hasActiveFormats =
|
|
329
|
-
value.activeFormats && !! value.activeFormats.length;
|
|
330
|
-
|
|
331
|
-
// Only process delete if the key press occurs at an uncollapsed edge.
|
|
332
|
-
if (
|
|
333
|
-
! isCollapsed( value ) ||
|
|
334
|
-
hasActiveFormats ||
|
|
335
|
-
( isReverse && start !== 0 ) ||
|
|
336
|
-
( ! isReverse && end !== text.length )
|
|
337
|
-
) {
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
if ( onMerge ) {
|
|
342
|
-
onMerge( ! isReverse );
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Only handle remove on Backspace. This serves dual-purpose of being
|
|
346
|
-
// an intentional user interaction distinguishing between Backspace and
|
|
347
|
-
// Delete to remove the empty field, but also to avoid merge & remove
|
|
348
|
-
// causing destruction of two fields (merge, then removed merged).
|
|
349
|
-
if ( onRemove && isEmpty( value ) && isReverse ) {
|
|
350
|
-
onRemove( ! isReverse );
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
event.preventDefault();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
317
|
function onFocus() {
|
|
358
318
|
anchorRef.current?.focus();
|
|
359
319
|
}
|
|
@@ -400,7 +360,7 @@ function RichTextWrapper(
|
|
|
400
360
|
richTextRef,
|
|
401
361
|
useBeforeInputRules( { value, onChange } ),
|
|
402
362
|
useInputRules( {
|
|
403
|
-
|
|
363
|
+
getValue,
|
|
404
364
|
onChange,
|
|
405
365
|
__unstableAllowPrefixTransformations,
|
|
406
366
|
formatTypes,
|
|
@@ -427,6 +387,11 @@ function RichTextWrapper(
|
|
|
427
387
|
preserveWhiteSpace,
|
|
428
388
|
pastePlainText,
|
|
429
389
|
} ),
|
|
390
|
+
useDelete( {
|
|
391
|
+
value,
|
|
392
|
+
onMerge,
|
|
393
|
+
onRemove,
|
|
394
|
+
} ),
|
|
430
395
|
useEnter( {
|
|
431
396
|
removeEditorOnlyFormats,
|
|
432
397
|
value,
|
|
@@ -448,7 +413,6 @@ function RichTextWrapper(
|
|
|
448
413
|
props.className,
|
|
449
414
|
'rich-text'
|
|
450
415
|
) }
|
|
451
|
-
onKeyDown={ onKeyDown }
|
|
452
416
|
/>
|
|
453
417
|
</>
|
|
454
418
|
);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef } from '@wordpress/element';
|
|
5
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
+
import { DELETE, BACKSPACE } from '@wordpress/keycodes';
|
|
7
|
+
import { isCollapsed, isEmpty } from '@wordpress/rich-text';
|
|
8
|
+
|
|
9
|
+
export function useDelete( props ) {
|
|
10
|
+
const propsRef = useRef( props );
|
|
11
|
+
propsRef.current = props;
|
|
12
|
+
return useRefEffect( ( element ) => {
|
|
13
|
+
function onKeyDown( event ) {
|
|
14
|
+
const { keyCode } = event;
|
|
15
|
+
|
|
16
|
+
if ( event.defaultPrevented ) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { value, onMerge, onRemove } = propsRef.current;
|
|
21
|
+
|
|
22
|
+
if ( keyCode === DELETE || keyCode === BACKSPACE ) {
|
|
23
|
+
const { start, end, text } = value;
|
|
24
|
+
const isReverse = keyCode === BACKSPACE;
|
|
25
|
+
const hasActiveFormats =
|
|
26
|
+
value.activeFormats && !! value.activeFormats.length;
|
|
27
|
+
|
|
28
|
+
// Only process delete if the key press occurs at an uncollapsed edge.
|
|
29
|
+
if (
|
|
30
|
+
! isCollapsed( value ) ||
|
|
31
|
+
hasActiveFormats ||
|
|
32
|
+
( isReverse && start !== 0 ) ||
|
|
33
|
+
( ! isReverse && end !== text.length )
|
|
34
|
+
) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if ( onMerge ) {
|
|
39
|
+
onMerge( ! isReverse );
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Only handle remove on Backspace. This serves dual-purpose of being
|
|
43
|
+
// an intentional user interaction distinguishing between Backspace and
|
|
44
|
+
// Delete to remove the empty field, but also to avoid merge & remove
|
|
45
|
+
// causing destruction of two fields (merge, then removed merged).
|
|
46
|
+
if ( onRemove && isEmpty( value ) && isReverse ) {
|
|
47
|
+
onRemove( ! isReverse );
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
element.addEventListener( 'keydown', onKeyDown );
|
|
55
|
+
return () => {
|
|
56
|
+
element.removeEventListener( 'keydown', onKeyDown );
|
|
57
|
+
};
|
|
58
|
+
}, [] );
|
|
59
|
+
}
|
|
@@ -29,7 +29,7 @@ function findSelection( blocks ) {
|
|
|
29
29
|
blocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[
|
|
30
30
|
attributeKey
|
|
31
31
|
].replace( START_OF_SELECTED_AREA, '' );
|
|
32
|
-
return blocks[ i ].clientId;
|
|
32
|
+
return [ blocks[ i ].clientId, attributeKey, 0, 0 ];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const nestedSelection = findSelection( blocks[ i ].innerBlocks );
|
|
@@ -38,6 +38,8 @@ function findSelection( blocks ) {
|
|
|
38
38
|
return nestedSelection;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
return [];
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export function useInputRules( props ) {
|
|
@@ -49,12 +51,15 @@ export function useInputRules( props ) {
|
|
|
49
51
|
propsRef.current = props;
|
|
50
52
|
return useRefEffect( ( element ) => {
|
|
51
53
|
function inputRule() {
|
|
52
|
-
const {
|
|
54
|
+
const { getValue, onReplace, selectionChange } = propsRef.current;
|
|
53
55
|
|
|
54
56
|
if ( ! onReplace ) {
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
// We must use getValue() here because value may be update
|
|
61
|
+
// asynchronously.
|
|
62
|
+
const value = getValue();
|
|
58
63
|
const { start, text } = value;
|
|
59
64
|
const characterBefore = text.slice( start - 1, start );
|
|
60
65
|
|
|
@@ -83,15 +88,17 @@ export function useInputRules( props ) {
|
|
|
83
88
|
} );
|
|
84
89
|
const block = transformation.transform( content );
|
|
85
90
|
|
|
86
|
-
selectionChange( findSelection( [ block ] ) );
|
|
91
|
+
selectionChange( ...findSelection( [ block ] ) );
|
|
87
92
|
onReplace( [ block ] );
|
|
88
93
|
__unstableMarkAutomaticChange();
|
|
94
|
+
|
|
95
|
+
return true;
|
|
89
96
|
}
|
|
90
97
|
|
|
91
98
|
function onInput( event ) {
|
|
92
99
|
const { inputType, type } = event;
|
|
93
100
|
const {
|
|
94
|
-
|
|
101
|
+
getValue,
|
|
95
102
|
onChange,
|
|
96
103
|
__unstableAllowPrefixTransformations,
|
|
97
104
|
formatTypes,
|
|
@@ -103,9 +110,10 @@ export function useInputRules( props ) {
|
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
if ( __unstableAllowPrefixTransformations && inputRule ) {
|
|
106
|
-
inputRule();
|
|
113
|
+
if ( inputRule() ) return;
|
|
107
114
|
}
|
|
108
115
|
|
|
116
|
+
const value = getValue();
|
|
109
117
|
const transformed = formatTypes.reduce(
|
|
110
118
|
( accumlator, { __unstableInputRule } ) => {
|
|
111
119
|
if ( __unstableInputRule ) {
|
|
@@ -72,7 +72,11 @@ function findDepth( a, b ) {
|
|
|
72
72
|
* @param {boolean} value `contentEditable` value (true or false)
|
|
73
73
|
*/
|
|
74
74
|
function setContentEditableWrapper( node, value ) {
|
|
75
|
-
|
|
75
|
+
// Since we are calling this on every selection change, check if the value
|
|
76
|
+
// needs to be updated first because it trigger the browser to recalculate
|
|
77
|
+
// style.
|
|
78
|
+
if ( node.contentEditable !== String( value ) )
|
|
79
|
+
node.contentEditable = value;
|
|
76
80
|
// Firefox doesn't automatically move focus.
|
|
77
81
|
if ( value ) node.focus();
|
|
78
82
|
}
|
package/src/hooks/align.js
CHANGED
|
@@ -119,7 +119,7 @@ export function addAttribute( settings ) {
|
|
|
119
119
|
*/
|
|
120
120
|
export const withToolbarControls = createHigherOrderComponent(
|
|
121
121
|
( BlockEdit ) => ( props ) => {
|
|
122
|
-
const blockEdit = <BlockEdit { ...props } />;
|
|
122
|
+
const blockEdit = <BlockEdit key="edit" { ...props } />;
|
|
123
123
|
const { name: blockName } = props;
|
|
124
124
|
// Compute the block valid alignments by taking into account,
|
|
125
125
|
// if the theme supports wide alignments or not and the layout's
|