@wordpress/block-editor 12.14.0 → 12.15.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 -1
- package/build/components/block-list/block.native.js +2 -0
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +1 -1
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +25 -16
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +4 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-list/index.js +36 -19
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-rename/index.js +28 -0
- package/build/components/block-rename/index.js.map +1 -0
- package/build/components/block-rename/is-empty-string.js +10 -0
- package/build/components/block-rename/is-empty-string.js.map +1 -0
- package/build/components/block-rename/modal.js +87 -0
- package/build/components/block-rename/modal.js.map +1 -0
- package/build/components/block-rename/rename-control.js +74 -0
- package/build/components/block-rename/rename-control.js.map +1 -0
- package/build/components/block-rename/use-block-rename.js +17 -0
- package/build/components/block-rename/use-block-rename.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js +33 -20
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +7 -0
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-types-list/index.js +6 -2
- package/build/components/block-types-list/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +8 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +1 -1
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/image-size-control/index.js +0 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/warning-max-depth-exceeded.native.js +29 -31
- package/build/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +3 -4
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +2 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter-listbox/index.js +11 -6
- package/build/components/inserter-listbox/index.js.map +1 -1
- package/build/components/inserter-listbox/item.js +24 -23
- package/build/components/inserter-listbox/item.js.map +1 -1
- package/build/components/inserter-listbox/row.js +5 -5
- package/build/components/inserter-listbox/row.js.map +1 -1
- package/build/components/list-view/use-list-view-expand-selected-item.js +2 -3
- package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
- package/build/components/preview-options/index.js +4 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +1 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +34 -3
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +30 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +4 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +2 -1
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-settings/index.js +2 -2
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/block-renaming.js +42 -0
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/custom-fields.js +53 -48
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +13 -7
- package/build/hooks/layout.js.map +1 -1
- package/build/layouts/constrained.js +4 -3
- package/build/layouts/constrained.js.map +1 -1
- package/build/store/selectors.js +2 -0
- package/build/store/selectors.js.map +1 -1
- package/build/utils/transform-styles/index.js +26 -6
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -0
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +1 -1
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +24 -15
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +4 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +36 -19
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-rename/index.js +4 -0
- package/build-module/components/block-rename/index.js.map +1 -0
- package/build-module/components/block-rename/is-empty-string.js +4 -0
- package/build-module/components/block-rename/is-empty-string.js.map +1 -0
- package/build-module/components/block-rename/modal.js +79 -0
- package/build-module/components/block-rename/modal.js.map +1 -0
- package/build-module/components/block-rename/rename-control.js +66 -0
- package/build-module/components/block-rename/rename-control.js.map +1 -0
- package/build-module/components/block-rename/use-block-rename.js +10 -0
- package/build-module/components/block-rename/use-block-rename.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +34 -21
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +7 -0
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-types-list/index.js +6 -2
- package/build-module/components/block-types-list/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +8 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +1 -1
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/image-size-control/index.js +0 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +30 -32
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +2 -2
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +3 -4
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +2 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter-listbox/index.js +13 -8
- package/build-module/components/inserter-listbox/index.js.map +1 -1
- package/build-module/components/inserter-listbox/item.js +25 -23
- package/build-module/components/inserter-listbox/item.js.map +1 -1
- package/build-module/components/inserter-listbox/row.js +6 -5
- package/build-module/components/inserter-listbox/row.js.map +1 -1
- package/build-module/components/list-view/use-list-view-expand-selected-item.js +2 -3
- package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
- package/build-module/components/preview-options/index.js +4 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +1 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +34 -3
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +31 -2
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +4 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +2 -1
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +2 -2
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/block-renaming.js +40 -0
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/custom-fields.js +53 -48
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/index.js +0 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +13 -7
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/layouts/constrained.js +4 -3
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/store/selectors.js +2 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +24 -7
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +6 -6
- package/build-style/content.css +6 -6
- package/build-style/style-rtl.css +10 -5
- package/build-style/style.css +10 -5
- package/package.json +31 -31
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-parent-selector/index.js +1 -1
- package/src/components/block-pattern-setup/index.js +38 -22
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -0
- package/src/components/block-pattern-setup/style.scss +4 -1
- package/src/components/block-patterns-list/README.md +4 -4
- package/src/components/block-patterns-list/index.js +60 -34
- package/src/components/block-patterns-list/style.scss +7 -0
- package/src/components/block-rename/index.js +3 -0
- package/src/components/block-rename/is-empty-string.js +3 -0
- package/src/components/block-rename/modal.js +115 -0
- package/src/components/block-rename/rename-control.js +80 -0
- package/src/components/block-rename/use-block-rename.js +10 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +38 -34
- package/src/components/block-settings-menu-controls/index.js +9 -0
- package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -4
- package/src/components/block-types-list/index.js +5 -4
- package/src/components/button-block-appender/content.scss +2 -2
- package/src/components/date-format-picker/index.js +7 -0
- package/src/components/editable-text/README.md +0 -36
- package/src/components/global-styles/advanced-panel.js +1 -1
- package/src/components/image-size-control/index.js +0 -6
- package/src/components/inner-blocks/index.js +6 -2
- package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +57 -33
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +5 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -3
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +6 -1
- package/src/components/inserter/block-patterns-tab/utils.js +6 -4
- package/src/components/inserter/hooks/use-patterns-state.js +3 -1
- package/src/components/inserter-listbox/index.js +11 -7
- package/src/components/inserter-listbox/item.js +11 -12
- package/src/components/inserter-listbox/row.js +6 -12
- package/src/components/list-view/use-list-view-expand-selected-item.js +7 -8
- package/src/components/plain-text/README.md +0 -28
- package/src/components/preview-options/index.js +2 -0
- package/src/components/rich-text/README.md +0 -58
- package/src/components/rich-text/index.native.js +1 -1
- package/src/components/rich-text/native/index.native.js +45 -2
- package/src/components/rich-text/use-input-rules.js +30 -2
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/src/components/url-input/README.md +1 -74
- package/src/components/use-block-drop-zone/index.js +4 -1
- package/src/components/use-moving-animation/index.js +1 -1
- package/src/components/use-settings/index.js +2 -2
- package/src/components/use-settings/test/index.js +1 -1
- package/src/hooks/block-renaming.js +47 -0
- package/src/hooks/custom-fields.js +68 -65
- package/src/hooks/index.js +0 -1
- package/src/hooks/layout.js +12 -8
- package/src/hooks/test/__snapshots__/align.native.js.snap +5 -5
- package/src/layouts/constrained.js +57 -50
- package/src/store/selectors.js +2 -0
- package/src/style.scss +1 -1
- package/src/utils/test/transform-styles.js +49 -0
- package/src/utils/transform-styles/index.js +39 -13
- package/build/hooks/block-rename-ui.js +0 -167
- package/build/hooks/block-rename-ui.js.map +0 -1
- package/build-module/hooks/block-rename-ui.js +0 -159
- package/build-module/hooks/block-rename-ui.js.map +0 -1
- package/src/hooks/block-rename-ui.js +0 -228
- /package/src/{hooks/block-rename-ui.scss → components/block-rename/style.scss} +0 -0
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
__experimentalNumberControl as NumberControl,
|
|
9
9
|
__experimentalHStack as HStack,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
|
-
import deprecated from '@wordpress/deprecated';
|
|
12
11
|
import { __ } from '@wordpress/i18n';
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -31,11 +30,6 @@ export default function ImageSizeControl( {
|
|
|
31
30
|
onChange,
|
|
32
31
|
onChangeImage = noop,
|
|
33
32
|
} ) {
|
|
34
|
-
deprecated( 'wp.blockEditor.__experimentalImageSizeControl', {
|
|
35
|
-
since: '6.3',
|
|
36
|
-
alternative:
|
|
37
|
-
'wp.blockEditor.privateApis.DimensionsTool and wp.blockEditor.privateApis.ResolutionTool',
|
|
38
|
-
} );
|
|
39
33
|
const { currentHeight, currentWidth, updateDimension, updateDimensions } =
|
|
40
34
|
useDimensionHandler( height, width, imageHeight, imageWidth, onChange );
|
|
41
35
|
|
|
@@ -169,8 +169,11 @@ const ForwardedInnerBlocks = forwardRef( ( props, ref ) => {
|
|
|
169
169
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
|
|
170
170
|
*/
|
|
171
171
|
export function useInnerBlocksProps( props = {}, options = {} ) {
|
|
172
|
-
const {
|
|
173
|
-
|
|
172
|
+
const {
|
|
173
|
+
__unstableDisableLayoutClassNames,
|
|
174
|
+
__unstableDisableDropZone,
|
|
175
|
+
dropZoneElement,
|
|
176
|
+
} = options;
|
|
174
177
|
const {
|
|
175
178
|
clientId,
|
|
176
179
|
layout = null,
|
|
@@ -211,6 +214,7 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
|
|
|
211
214
|
);
|
|
212
215
|
|
|
213
216
|
const blockDropZoneRef = useBlockDropZone( {
|
|
217
|
+
dropZoneElement,
|
|
214
218
|
rootClientId: clientId,
|
|
215
219
|
} );
|
|
216
220
|
|
|
@@ -8,7 +8,7 @@ import { TouchableWithoutFeedback, View } from 'react-native';
|
|
|
8
8
|
*/
|
|
9
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
10
|
import { useState } from '@wordpress/element';
|
|
11
|
-
import {
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
@@ -18,54 +18,71 @@ import UnsupportedBlockDetails from '../unsupported-block-details';
|
|
|
18
18
|
import { store as blockEditorStore } from '../../store';
|
|
19
19
|
import { MAX_NESTING_DEPTH } from './constants';
|
|
20
20
|
import useUnsupportedBlockEditor from '../use-unsupported-block-editor';
|
|
21
|
+
import {
|
|
22
|
+
useConvertToGroupButtons,
|
|
23
|
+
useConvertToGroupButtonProps,
|
|
24
|
+
} from '../convert-to-group-buttons';
|
|
25
|
+
|
|
26
|
+
const EMPTY_ARRAY = [];
|
|
21
27
|
|
|
22
28
|
const WarningMaxDepthExceeded = ( { clientId } ) => {
|
|
23
29
|
const [ showDetails, setShowDetails ] = useState( false );
|
|
24
30
|
|
|
25
|
-
const
|
|
26
|
-
( select ) =>
|
|
27
|
-
const { getBlock, isBlockSelected } = select( blockEditorStore );
|
|
28
|
-
return {
|
|
29
|
-
innerBlocks: getBlock( clientId )?.innerBlocks || [],
|
|
30
|
-
isSelected: isBlockSelected( clientId ),
|
|
31
|
-
};
|
|
32
|
-
},
|
|
31
|
+
const isSelected = useSelect(
|
|
32
|
+
( select ) => select( blockEditorStore ).isBlockSelected( clientId ),
|
|
33
33
|
[ clientId ]
|
|
34
34
|
);
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
// We rely on the logic related to the Group/Ungroup buttons used in the block options to
|
|
37
|
+
// determine whether to use the Ungroup action.
|
|
38
|
+
const convertToGroupButtonProps = useConvertToGroupButtonProps( [
|
|
39
|
+
clientId,
|
|
40
|
+
] );
|
|
41
|
+
const { isUngroupable } = convertToGroupButtonProps;
|
|
42
|
+
const convertToGroupButtons = useConvertToGroupButtons( {
|
|
43
|
+
...convertToGroupButtonProps,
|
|
44
|
+
} );
|
|
45
|
+
const onUngroup = convertToGroupButtons.ungroup.onSelect;
|
|
36
46
|
|
|
37
47
|
const {
|
|
38
48
|
isUnsupportedBlockEditorSupported,
|
|
39
49
|
canEnableUnsupportedBlockEditor,
|
|
40
50
|
} = useUnsupportedBlockEditor( clientId );
|
|
41
51
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
replaceBlocks( clientId, innerBlocks );
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
let description;
|
|
51
|
-
// When UBE can't be used, the description mentions using the web browser to edit the block.
|
|
52
|
+
/* translators: Warning related to having blocks deeply nested. %d: The deepest nesting level. */
|
|
53
|
+
const descriptionFormat = __(
|
|
54
|
+
'Blocks nested deeper than %d levels may not render properly in the mobile editor.'
|
|
55
|
+
);
|
|
56
|
+
let description = sprintf( descriptionFormat, MAX_NESTING_DEPTH );
|
|
52
57
|
if (
|
|
53
58
|
! isUnsupportedBlockEditorSupported &&
|
|
54
59
|
! canEnableUnsupportedBlockEditor
|
|
55
60
|
) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
// When UBE can't be used, the description mentions using the web browser to edit the block.
|
|
62
|
+
description +=
|
|
63
|
+
' ' +
|
|
64
|
+
/* translators: Recommendation included in a warning related to having blocks deeply nested. */
|
|
65
|
+
__(
|
|
66
|
+
'For this reason, we recommend editing the block using your web browser.'
|
|
67
|
+
);
|
|
61
68
|
}
|
|
62
69
|
// Otherwise, the description mentions using the web editor (i.e. UBE).
|
|
63
70
|
else {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
description +=
|
|
72
|
+
' ' +
|
|
73
|
+
/* translators: Recommendation included in a warning related to having blocks deeply nested. */
|
|
74
|
+
__(
|
|
75
|
+
'For this reason, we recommend editing the block using the web editor.'
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
// If the block can be flattened, we also suggest to ungroup the block.
|
|
79
|
+
if ( isUngroupable ) {
|
|
80
|
+
description +=
|
|
81
|
+
' ' +
|
|
82
|
+
/* translators: Alternative option included in a warning related to having blocks deeply nested. */
|
|
83
|
+
__(
|
|
84
|
+
'Alternatively, you can flatten the content by ungrouping the block.'
|
|
85
|
+
);
|
|
69
86
|
}
|
|
70
87
|
|
|
71
88
|
return (
|
|
@@ -88,9 +105,16 @@ const WarningMaxDepthExceeded = ( { clientId } ) => {
|
|
|
88
105
|
onCloseSheet={ () => setShowDetails( false ) }
|
|
89
106
|
title={ __( 'Deeply nested block' ) }
|
|
90
107
|
description={ description }
|
|
91
|
-
customActions={
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
customActions={
|
|
109
|
+
isUngroupable
|
|
110
|
+
? [
|
|
111
|
+
{
|
|
112
|
+
label: __( 'Ungroup block' ),
|
|
113
|
+
onPress: onUngroup,
|
|
114
|
+
},
|
|
115
|
+
]
|
|
116
|
+
: EMPTY_ARRAY
|
|
117
|
+
}
|
|
94
118
|
/>
|
|
95
119
|
</View>
|
|
96
120
|
</TouchableWithoutFeedback>
|
|
@@ -18,6 +18,7 @@ import { searchItems } from '../search-items';
|
|
|
18
18
|
import BlockPatternsPaging from '../../block-patterns-paging';
|
|
19
19
|
import usePatternsPaging from '../hooks/use-patterns-paging';
|
|
20
20
|
import {
|
|
21
|
+
PATTERN_TYPES,
|
|
21
22
|
allPatternsCategory,
|
|
22
23
|
myPatternsCategory,
|
|
23
24
|
} from '../block-patterns-tab/utils';
|
|
@@ -70,7 +71,10 @@ function PatternList( { searchValue, selectedCategory, patternCategories } ) {
|
|
|
70
71
|
if ( selectedCategory === allPatternsCategory.name ) {
|
|
71
72
|
return true;
|
|
72
73
|
}
|
|
73
|
-
if (
|
|
74
|
+
if (
|
|
75
|
+
selectedCategory === myPatternsCategory.name &&
|
|
76
|
+
pattern.type === PATTERN_TYPES.user
|
|
77
|
+
) {
|
|
74
78
|
return true;
|
|
75
79
|
}
|
|
76
80
|
if ( selectedCategory === 'uncategorized' ) {
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
* Internal dependencies
|
|
23
23
|
*/
|
|
24
24
|
import usePatternsState from '../hooks/use-patterns-state';
|
|
25
|
-
import
|
|
25
|
+
import BlockPatternsList from '../../block-patterns-list';
|
|
26
26
|
import usePatternsPaging from '../hooks/use-patterns-paging';
|
|
27
27
|
import { PatternsFilter } from './patterns-filter';
|
|
28
28
|
import { usePatternCategories } from './use-pattern-categories';
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
isPatternFiltered,
|
|
31
31
|
allPatternsCategory,
|
|
32
32
|
myPatternsCategory,
|
|
33
|
+
PATTERN_TYPES,
|
|
33
34
|
} from './utils';
|
|
34
35
|
|
|
35
36
|
const noop = () => {};
|
|
@@ -69,7 +70,10 @@ export function PatternCategoryPreviews( {
|
|
|
69
70
|
if ( category.name === allPatternsCategory.name ) {
|
|
70
71
|
return true;
|
|
71
72
|
}
|
|
72
|
-
if (
|
|
73
|
+
if (
|
|
74
|
+
category.name === myPatternsCategory.name &&
|
|
75
|
+
pattern.type === PATTERN_TYPES.user
|
|
76
|
+
) {
|
|
73
77
|
return true;
|
|
74
78
|
}
|
|
75
79
|
if ( category.name !== 'uncategorized' ) {
|
|
@@ -155,7 +159,7 @@ export function PatternCategoryPreviews( {
|
|
|
155
159
|
</VStack>
|
|
156
160
|
|
|
157
161
|
{ currentCategoryPatterns.length > 0 && (
|
|
158
|
-
<
|
|
162
|
+
<BlockPatternsList
|
|
159
163
|
ref={ scrollContainerRef }
|
|
160
164
|
shownPatterns={ pagingProps.categoryPatternsAsyncList }
|
|
161
165
|
blockPatterns={ pagingProps.categoryPatterns }
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isPatternFiltered,
|
|
15
15
|
allPatternsCategory,
|
|
16
16
|
myPatternsCategory,
|
|
17
|
+
PATTERN_TYPES,
|
|
17
18
|
} from './utils';
|
|
18
19
|
|
|
19
20
|
export function usePatternCategories( rootClientId, sourceFilter = 'all' ) {
|
|
@@ -69,7 +70,11 @@ export function usePatternCategories( rootClientId, sourceFilter = 'all' ) {
|
|
|
69
70
|
label: _x( 'Uncategorized' ),
|
|
70
71
|
} );
|
|
71
72
|
}
|
|
72
|
-
if (
|
|
73
|
+
if (
|
|
74
|
+
filteredPatterns.some(
|
|
75
|
+
( pattern ) => pattern.type === PATTERN_TYPES.user
|
|
76
|
+
)
|
|
77
|
+
) {
|
|
73
78
|
categories.unshift( myPatternsCategory );
|
|
74
79
|
}
|
|
75
80
|
if ( filteredPatterns.length > 0 ) {
|
|
@@ -21,7 +21,7 @@ export const SYNC_TYPES = {
|
|
|
21
21
|
|
|
22
22
|
export const allPatternsCategory = {
|
|
23
23
|
name: 'allPatterns',
|
|
24
|
-
label: __( 'All
|
|
24
|
+
label: __( 'All' ),
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export const myPatternsCategory = {
|
|
@@ -53,9 +53,11 @@ export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
|
|
|
53
53
|
return true;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// If user source selected, filter out theme patterns.
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
// If user source selected, filter out theme patterns.
|
|
57
|
+
if (
|
|
58
|
+
sourceFilter === PATTERN_TYPES.user &&
|
|
59
|
+
pattern.type !== PATTERN_TYPES.user
|
|
60
|
+
) {
|
|
59
61
|
return true;
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -11,6 +11,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../../store';
|
|
14
|
+
import { PATTERN_TYPES } from '../block-patterns-tab/utils';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Retrieves the block patterns inserter state.
|
|
@@ -57,7 +58,8 @@ const usePatternsState = ( onInsert, rootClientId ) => {
|
|
|
57
58
|
const onClickPattern = useCallback(
|
|
58
59
|
( pattern, blocks ) => {
|
|
59
60
|
const patternBlocks =
|
|
60
|
-
pattern.
|
|
61
|
+
pattern.type === PATTERN_TYPES.user &&
|
|
62
|
+
pattern.syncStatus !== 'unsynced'
|
|
61
63
|
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
|
|
62
64
|
: blocks;
|
|
63
65
|
onInsert(
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import { unlock } from '../../lock-unlock';
|
|
10
10
|
|
|
11
11
|
export { default as InserterListboxGroup } from './group';
|
|
12
12
|
export { default as InserterListboxRow } from './row';
|
|
13
13
|
export { default as InserterListboxItem } from './item';
|
|
14
14
|
|
|
15
|
+
const { CompositeV2: Composite, useCompositeStoreV2: useCompositeStore } =
|
|
16
|
+
unlock( componentsPrivateApis );
|
|
17
|
+
|
|
15
18
|
function InserterListbox( { children } ) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const store = useCompositeStore( {
|
|
20
|
+
focusShift: true,
|
|
21
|
+
focusWrap: 'horizontal',
|
|
19
22
|
} );
|
|
23
|
+
|
|
20
24
|
return (
|
|
21
|
-
<
|
|
25
|
+
<Composite store={ store } render={ <></> }>
|
|
22
26
|
{ children }
|
|
23
|
-
</
|
|
27
|
+
</Composite>
|
|
24
28
|
);
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -3,32 +3,31 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
Button,
|
|
6
|
-
|
|
6
|
+
privateApis as componentsPrivateApis,
|
|
7
7
|
} from '@wordpress/components';
|
|
8
|
-
import { forwardRef
|
|
8
|
+
import { forwardRef } from '@wordpress/element';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
-
import
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
|
|
15
|
+
const { CompositeItemV2: CompositeItem } = unlock( componentsPrivateApis );
|
|
14
16
|
|
|
15
17
|
function InserterListboxItem(
|
|
16
18
|
{ isFirst, as: Component, children, ...props },
|
|
17
19
|
ref
|
|
18
20
|
) {
|
|
19
|
-
const state = useContext( InserterListboxContext );
|
|
20
21
|
return (
|
|
21
22
|
<CompositeItem
|
|
22
23
|
ref={ ref }
|
|
23
|
-
state={ state }
|
|
24
24
|
role="option"
|
|
25
|
-
// Use the CompositeItem `
|
|
26
|
-
// isFocusable
|
|
27
|
-
// with tab order in the inserter list.
|
|
28
|
-
|
|
25
|
+
// Use the CompositeItem `accessibleWhenDisabled` prop
|
|
26
|
+
// over Button's `isFocusable`. The latter was shown to
|
|
27
|
+
// cause an issue with tab order in the inserter list.
|
|
28
|
+
accessibleWhenDisabled
|
|
29
29
|
{ ...props }
|
|
30
|
-
|
|
31
|
-
{ ( htmlProps ) => {
|
|
30
|
+
render={ ( htmlProps ) => {
|
|
32
31
|
const propsWithTabIndex = {
|
|
33
32
|
...htmlProps,
|
|
34
33
|
tabIndex: isFirst ? 0 : htmlProps.tabIndex,
|
|
@@ -45,7 +44,7 @@ function InserterListboxItem(
|
|
|
45
44
|
}
|
|
46
45
|
return <Button { ...propsWithTabIndex }>{ children }</Button>;
|
|
47
46
|
} }
|
|
48
|
-
|
|
47
|
+
/>
|
|
49
48
|
);
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { forwardRef
|
|
5
|
-
import {
|
|
4
|
+
import { forwardRef } from '@wordpress/element';
|
|
5
|
+
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import { unlock } from '../../lock-unlock';
|
|
11
|
+
|
|
12
|
+
const { CompositeGroupV2: CompositeGroup } = unlock( componentsPrivateApis );
|
|
11
13
|
|
|
12
14
|
function InserterListboxRow( props, ref ) {
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<CompositeGroup
|
|
16
|
-
state={ state }
|
|
17
|
-
role="presentation"
|
|
18
|
-
ref={ ref }
|
|
19
|
-
{ ...props }
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
15
|
+
return <CompositeGroup role="presentation" ref={ ref } { ...props } />;
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
export default forwardRef( InserterListboxRow );
|
|
@@ -27,12 +27,6 @@ export default function useListViewExpandSelectedItem( {
|
|
|
27
27
|
[ firstSelectedBlockClientId ]
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
const parentClientIds =
|
|
31
|
-
Array.isArray( selectedBlockParentClientIds ) &&
|
|
32
|
-
selectedBlockParentClientIds.length
|
|
33
|
-
? selectedBlockParentClientIds
|
|
34
|
-
: null;
|
|
35
|
-
|
|
36
30
|
// Expand tree when a block is selected.
|
|
37
31
|
useEffect( () => {
|
|
38
32
|
// If the selectedTreeId is the same as the selected block,
|
|
@@ -42,7 +36,7 @@ export default function useListViewExpandSelectedItem( {
|
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
// If the selected block has parents, get the top-level parent.
|
|
45
|
-
if (
|
|
39
|
+
if ( selectedBlockParentClientIds?.length ) {
|
|
46
40
|
// If the selected block has parents,
|
|
47
41
|
// expand the tree branch.
|
|
48
42
|
setExpandedState( {
|
|
@@ -50,7 +44,12 @@ export default function useListViewExpandSelectedItem( {
|
|
|
50
44
|
clientIds: selectedBlockParentClientIds,
|
|
51
45
|
} );
|
|
52
46
|
}
|
|
53
|
-
}, [
|
|
47
|
+
}, [
|
|
48
|
+
firstSelectedBlockClientId,
|
|
49
|
+
selectedBlockParentClientIds,
|
|
50
|
+
selectedTreeId,
|
|
51
|
+
setExpandedState,
|
|
52
|
+
] );
|
|
54
53
|
|
|
55
54
|
return {
|
|
56
55
|
setSelectedTreeId,
|
|
@@ -20,33 +20,6 @@ _Optional._ The component forwards the `ref` property to the `TextareaAutosize`
|
|
|
20
20
|
|
|
21
21
|
## Example
|
|
22
22
|
|
|
23
|
-
{% codetabs %}
|
|
24
|
-
{% ES5 %}
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
wp.blocks.registerBlockType( /* ... */, {
|
|
28
|
-
// ...
|
|
29
|
-
|
|
30
|
-
attributes: {
|
|
31
|
-
content: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
edit: function( props ) {
|
|
37
|
-
return React.createElement( wp.blockEditor.PlainText, {
|
|
38
|
-
className: props.className,
|
|
39
|
-
value: props.attributes.content,
|
|
40
|
-
onChange: function( content ) {
|
|
41
|
-
props.setAttributes( { content: content } );
|
|
42
|
-
},
|
|
43
|
-
} );
|
|
44
|
-
},
|
|
45
|
-
} );
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
{% ESNext %}
|
|
49
|
-
|
|
50
23
|
```js
|
|
51
24
|
import { registerBlockType } from '@wordpress/blocks';
|
|
52
25
|
import { PlainText } from '@wordpress/block-editor';
|
|
@@ -72,4 +45,3 @@ registerBlockType( /* ... */, {
|
|
|
72
45
|
} );
|
|
73
46
|
```
|
|
74
47
|
|
|
75
|
-
{% end %}
|
|
@@ -19,6 +19,7 @@ export default function PreviewOptions( {
|
|
|
19
19
|
deviceType,
|
|
20
20
|
setDeviceType,
|
|
21
21
|
label,
|
|
22
|
+
showIconLabels,
|
|
22
23
|
} ) {
|
|
23
24
|
const isMobile = useViewportMatch( 'small', '<' );
|
|
24
25
|
if ( isMobile ) return null;
|
|
@@ -35,6 +36,7 @@ export default function PreviewOptions( {
|
|
|
35
36
|
disabled: ! isEnabled,
|
|
36
37
|
__experimentalIsFocusable: ! isEnabled,
|
|
37
38
|
children: viewLabel,
|
|
39
|
+
showTooltip: ! showIconLabels,
|
|
38
40
|
};
|
|
39
41
|
const menuProps = {
|
|
40
42
|
'aria-label': __( 'View options' ),
|
|
@@ -80,41 +80,6 @@ trimmed.
|
|
|
80
80
|
|
|
81
81
|
## Example
|
|
82
82
|
|
|
83
|
-
{% codetabs %}
|
|
84
|
-
{% ES5 %}
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
wp.blocks.registerBlockType( /* ... */, {
|
|
88
|
-
// ...
|
|
89
|
-
|
|
90
|
-
attributes: {
|
|
91
|
-
content: {
|
|
92
|
-
source: 'html',
|
|
93
|
-
selector: 'h2',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
edit: function( props ) {
|
|
98
|
-
return React.createElement( wp.blockEditor.RichText, {
|
|
99
|
-
tagName: 'h2',
|
|
100
|
-
className: props.className,
|
|
101
|
-
value: props.attributes.content,
|
|
102
|
-
onChange: function( content ) {
|
|
103
|
-
props.setAttributes( { content: content } );
|
|
104
|
-
}
|
|
105
|
-
} );
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
save: function( props ) {
|
|
109
|
-
return React.createElement( wp.blockEditor.RichText.Content, {
|
|
110
|
-
tagName: 'h2', value: props.attributes.content
|
|
111
|
-
} );
|
|
112
|
-
}
|
|
113
|
-
} );
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
{% ESNext %}
|
|
117
|
-
|
|
118
83
|
```js
|
|
119
84
|
import { registerBlockType } from '@wordpress/blocks';
|
|
120
85
|
import { RichText } from '@wordpress/block-editor';
|
|
@@ -146,7 +111,6 @@ registerBlockType( /* ... */, {
|
|
|
146
111
|
} );
|
|
147
112
|
```
|
|
148
113
|
|
|
149
|
-
{% end %}
|
|
150
114
|
|
|
151
115
|
## RichTextToolbarButton
|
|
152
116
|
|
|
@@ -154,26 +118,6 @@ Slot to extend the format toolbar. Use it in the edit function of a `registerFor
|
|
|
154
118
|
|
|
155
119
|
### Example
|
|
156
120
|
|
|
157
|
-
{% codetabs %}
|
|
158
|
-
{% ES5 %}
|
|
159
|
-
|
|
160
|
-
```js
|
|
161
|
-
wp.richText.registerFormatType( /* ... */, {
|
|
162
|
-
/* ... */
|
|
163
|
-
edit: function( props ) {
|
|
164
|
-
return React.createElement(
|
|
165
|
-
wp.blockEditor.RichTextToolbarButton, {
|
|
166
|
-
icon: 'editor-code',
|
|
167
|
-
title: 'My formatting button',
|
|
168
|
-
onClick: function() { /* ... */ }
|
|
169
|
-
isActive: props.isActive,
|
|
170
|
-
} );
|
|
171
|
-
},
|
|
172
|
-
/* ... */
|
|
173
|
-
} );
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
{% ESNext %}
|
|
177
121
|
|
|
178
122
|
```js
|
|
179
123
|
import { registerFormatType } from '@wordpress/rich-text';
|
|
@@ -194,5 +138,3 @@ registerFormatType( /* ... */, {
|
|
|
194
138
|
/* ... */
|
|
195
139
|
} );
|
|
196
140
|
```
|
|
197
|
-
|
|
198
|
-
{% end %}
|
|
@@ -223,7 +223,7 @@ function RichTextWrapper(
|
|
|
223
223
|
// an intentional user interaction distinguishing between Backspace and
|
|
224
224
|
// Delete to remove the empty field, but also to avoid merge & remove
|
|
225
225
|
// causing destruction of two fields (merge, then removed merged).
|
|
226
|
-
if ( onRemove && isEmpty( value ) && isReverse ) {
|
|
226
|
+
else if ( onRemove && isEmpty( value ) && isReverse ) {
|
|
227
227
|
onRemove( ! isReverse );
|
|
228
228
|
}
|
|
229
229
|
},
|
|
@@ -650,6 +650,40 @@ export class RichText extends Component {
|
|
|
650
650
|
return shouldDrop;
|
|
651
651
|
}
|
|
652
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Determines whether the text input should receive focus after an update.
|
|
655
|
+
* For cases where a RichText with a value is merged with an empty one.
|
|
656
|
+
*
|
|
657
|
+
* @param {Object} prevProps - The previous props of the component.
|
|
658
|
+
* @return {boolean} True if the text input should receive focus, false otherwise.
|
|
659
|
+
*/
|
|
660
|
+
shouldFocusTextInputAfterMerge( prevProps ) {
|
|
661
|
+
const {
|
|
662
|
+
__unstableIsSelected: isSelected,
|
|
663
|
+
blockIsSelected,
|
|
664
|
+
selectionStart,
|
|
665
|
+
selectionEnd,
|
|
666
|
+
__unstableMobileNoFocusOnMount,
|
|
667
|
+
} = this.props;
|
|
668
|
+
|
|
669
|
+
const {
|
|
670
|
+
__unstableIsSelected: prevIsSelected,
|
|
671
|
+
blockIsSelected: prevBlockIsSelected,
|
|
672
|
+
} = prevProps;
|
|
673
|
+
|
|
674
|
+
const noSelectionValues =
|
|
675
|
+
selectionStart === undefined && selectionEnd === undefined;
|
|
676
|
+
const textInputWasNotFocused = ! prevIsSelected && ! isSelected;
|
|
677
|
+
|
|
678
|
+
return (
|
|
679
|
+
! __unstableMobileNoFocusOnMount &&
|
|
680
|
+
noSelectionValues &&
|
|
681
|
+
textInputWasNotFocused &&
|
|
682
|
+
! prevBlockIsSelected &&
|
|
683
|
+
blockIsSelected
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
|
|
653
687
|
onSelectionChangeFromAztec( start, end, text, event ) {
|
|
654
688
|
if ( this.shouldDropEventFromAztec( event, 'onSelectionChange' ) ) {
|
|
655
689
|
return;
|
|
@@ -843,9 +877,8 @@ export class RichText extends Component {
|
|
|
843
877
|
if ( this.props.value !== this.value ) {
|
|
844
878
|
this.value = this.props.value;
|
|
845
879
|
}
|
|
846
|
-
const { __unstableIsSelected: isSelected } = this.props;
|
|
847
|
-
|
|
848
880
|
const { __unstableIsSelected: prevIsSelected } = prevProps;
|
|
881
|
+
const { __unstableIsSelected: isSelected } = this.props;
|
|
849
882
|
|
|
850
883
|
if ( isSelected && ! prevIsSelected ) {
|
|
851
884
|
this._editor.focus();
|
|
@@ -855,6 +888,16 @@ export class RichText extends Component {
|
|
|
855
888
|
this.props.selectionStart || 0,
|
|
856
889
|
this.props.selectionEnd || 0
|
|
857
890
|
);
|
|
891
|
+
} else if ( this.shouldFocusTextInputAfterMerge( prevProps ) ) {
|
|
892
|
+
// Since this is happening when merging blocks, the selection should be at the last character position.
|
|
893
|
+
// As a fallback the internal selectionEnd value is used.
|
|
894
|
+
const lastCharacterPosition =
|
|
895
|
+
this.value?.length ?? this.selectionEnd;
|
|
896
|
+
this._editor.focus();
|
|
897
|
+
this.props.onSelectionChange(
|
|
898
|
+
lastCharacterPosition,
|
|
899
|
+
lastCharacterPosition
|
|
900
|
+
);
|
|
858
901
|
} else if ( ! isSelected && prevIsSelected ) {
|
|
859
902
|
this._editor.blur();
|
|
860
903
|
}
|