Skip to content

Commit 2b2ed70

Browse files
fix: resolve WP 7.0 / Gutenberg editor deprecations
Editor console deprecations surfaced under WP 7.0 / Gutenberg, fixed across lite and pro: - captcha: Block API v2 -> v3 (6.9) - options sidebar: import PluginSidebar/PluginSidebarMoreMenuItem from @wordpress/editor (6.6) - otter-store: registerGenericStore -> createReduxStore + register (5.9) - preferences: read/write hiddenBlockTypes under the 'core' scope (6.5) - device type: core/editor getDeviceType/setDeviceType instead of core/edit-post __experimentalGetPreviewDeviceType (6.5) - toolbar controls: use ToolbarButton; mark the Design Library header button as a toolbar item (5.6) - interface scope: enableComplementaryArea( 'core', ... ) not 'core/edit-post' (6.6) - date: getSettings instead of __experimentalGetSettings (6.1) - icon-list item: RichText onSplit -> block.json supports.splitting (6.4) - FormFileUpload: opt into __next40pxDefaultSize (6.8 / removal 7.1) - countdown: fix malformed timezone offset (+0:0) fed into moment(), which forced a fallback to the JS Date constructor Deferred, documented: advanced-heading onSplit (core splitting would convert the styled heading tail to a plain paragraph) and the broad TextControl 40px migration (tracked separately, removal in 7.1). Tests: - unit: getTimezone returns a valid ISO 8601 offset (red->green) - e2e: icon-list splits into same-type items on Enter (guards the onSplit -> supports.splitting migration) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent fd2b617 commit 2b2ed70

34 files changed

Lines changed: 296 additions & 156 deletions

File tree

src/blocks/blocks/advanced-heading/controls.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import { __ } from '@wordpress/i18n';
55

66
import {
7-
Button,
87
Dropdown,
98
DropdownMenu,
109
RangeControl,
10+
ToolbarButton,
1111
ToolbarGroup
1212
} from '@wordpress/components';
1313

@@ -111,7 +111,7 @@ const Controls = ({
111111
contentClassName="wp-themeisle-blocks-advanced-heading-popover-content"
112112
position="bottom center"
113113
renderToggle={ ({ isOpen, onToggle }) => (
114-
<Button
114+
<ToolbarButton
115115
className="components-dropdown-menu__toggle"
116116
icon={ 'editor-textcolor' }
117117
onClick={ onToggle }
@@ -121,7 +121,7 @@ const Controls = ({
121121
showTooltip={ true }
122122
>
123123
<span className="components-dropdown-menu__indicator" />
124-
</Button>
124+
</ToolbarButton>
125125
) }
126126
renderContent={ () => (
127127
<Fragment>

src/blocks/blocks/countdown/inspector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525

2626
import {
2727
format,
28-
__experimentalGetSettings
28+
getSettings
2929
} from '@wordpress/date';
3030

3131
import {
@@ -168,7 +168,7 @@ const Inspector = ({
168168

169169
const [ tab, setTab ] = useTabSwitch( attributes.id, 'settings' );
170170

171-
const settings = __experimentalGetSettings();
171+
const settings = getSettings();
172172

173173
return (
174174
<InspectorControls>

src/blocks/blocks/form/captcha/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://schemas.wp.org/trunk/block.json",
3-
"apiVersion": 2,
3+
"apiVersion": 3,
44
"name": "themeisle-blocks/form-captcha",
55
"title": "Captcha",
66
"category": "themeisle-blocks",

src/blocks/blocks/form/edit.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {
4747
Icon
4848
} from '@wordpress/icons';
4949

50-
import { Button, Notice, ToolbarGroup } from '@wordpress/components';
50+
import { Button, Notice, ToolbarButton, ToolbarGroup } from '@wordpress/components';
5151

5252
/**
5353
* Internal dependencies
@@ -983,7 +983,7 @@ const Edit = ({
983983

984984
<BlockControls>
985985
<ToolbarGroup>
986-
<Button
986+
<ToolbarButton
987987
onClick={()=> {
988988
const generator = createBlock( 'themeisle-blocks/content-generator', {
989989
promptID: 'form'
@@ -994,7 +994,7 @@ const Edit = ({
994994
>
995995
{ __( 'Create Form With AI', 'otter-blocks' ) }
996996
<Icon width={22} icon={aiGeneration} style={{ marginLeft: '8px' }} />
997-
</Button>
997+
</ToolbarButton>
998998
</ToolbarGroup>
999999
</BlockControls>
10001000

src/blocks/blocks/icon-list/item/block.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@
3636
"iconAlt": {
3737
"type": "string"
3838
}
39+
},
40+
"supports": {
41+
"splitting": true
3942
}
4043
}

src/blocks/blocks/icon-list/item/edit.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import {
1313
useBlockProps
1414
} from '@wordpress/block-editor';
1515

16-
import { createBlock } from '@wordpress/blocks';
17-
1816
import { select, useSelect } from '@wordpress/data';
1917

2018
import {
@@ -41,7 +39,6 @@ const { attributes: defaultAttributes } = metadata;
4139
const Edit = ({
4240
attributes,
4341
setAttributes,
44-
name,
4542
clientId,
4643
onReplace,
4744
onRemove,
@@ -159,16 +156,6 @@ const Edit = ({
159156
) }
160157
value={ attributes.content }
161158
onChange={ ( content ) => setAttributes({ content }) }
162-
onSplit={ ( value ) => {
163-
if ( ! value ) {
164-
return createBlock( name );
165-
}
166-
167-
return createBlock( name, {
168-
...attributes,
169-
content: value
170-
});
171-
} }
172159
onMerge={ mergeBlocks }
173160
onReplace={ onReplace }
174161
onRemove={ onRemove }

src/blocks/blocks/lottie/controls.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { __ } from '@wordpress/i18n';
55

66
import {
77
Dashicon,
8-
Button,
9-
ToolbarGroup,
10-
Tooltip
8+
ToolbarButton,
9+
ToolbarGroup
1110
} from '@wordpress/components';
1211

1312
import { BlockControls } from '@wordpress/block-editor';
@@ -19,13 +18,13 @@ const Controls = ({
1918
return (
2019
<BlockControls>
2120
<ToolbarGroup>
22-
<Tooltip text={ isEditing ? __( 'Save', 'otter-blocks' ) : __( 'Edit', 'otter-blocks' ) }>
23-
<Button
24-
onClick={ () => setEditing( ! isEditing ) }
25-
>
26-
<Dashicon icon={ isEditing ? 'yes' : 'edit' } />
27-
</Button>
28-
</Tooltip>
21+
<ToolbarButton
22+
label={ isEditing ? __( 'Save', 'otter-blocks' ) : __( 'Edit', 'otter-blocks' ) }
23+
showTooltip={ true }
24+
onClick={ () => setEditing( ! isEditing ) }
25+
>
26+
<Dashicon icon={ isEditing ? 'yes' : 'edit' } />
27+
</ToolbarButton>
2928
</ToolbarGroup>
3029
</BlockControls>
3130
);

src/blocks/blocks/section/column/edit.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ const Edit = ({
7171
getBlock,
7272
getBlockRootClientId
7373
} = select( 'core/block-editor' );
74-
const { __experimentalGetPreviewDeviceType } = select( 'core/edit-post' ) ? select( 'core/edit-post' ) : false;
74+
const editor = select( 'core/editor' );
75+
const deviceType = editor?.getDeviceType ? editor.getDeviceType() : false;
7576
const block = getBlock( clientId );
7677
const adjacentBlockClientId = getAdjacentBlockClientId( clientId );
7778
const adjacentBlock = getBlock( adjacentBlockClientId );
@@ -84,10 +85,10 @@ const Edit = ({
8485
adjacentBlock,
8586
parentBlock,
8687
hasInnerBlocks,
87-
isViewportAvailable: __experimentalGetPreviewDeviceType ? true : false,
88-
isPreviewDesktop: __experimentalGetPreviewDeviceType ? 'Desktop' === __experimentalGetPreviewDeviceType() : false,
89-
isPreviewTablet: __experimentalGetPreviewDeviceType ? 'Tablet' === __experimentalGetPreviewDeviceType() : false,
90-
isPreviewMobile: __experimentalGetPreviewDeviceType ? 'Mobile' === __experimentalGetPreviewDeviceType() : false
88+
isViewportAvailable: deviceType ? true : false,
89+
isPreviewDesktop: deviceType ? 'Desktop' === deviceType : false,
90+
isPreviewTablet: deviceType ? 'Tablet' === deviceType : false,
91+
isPreviewMobile: deviceType ? 'Mobile' === deviceType : false
9192
};
9293
}, []);
9394

src/blocks/blocks/section/column/inspector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ const Inspector = ({
6969
}) => {
7070
const getView = useSelect( select => {
7171
const { getView } = select( 'themeisle-gutenberg/data' );
72-
const { __experimentalGetPreviewDeviceType } = select( 'core/edit-post' ) ? select( 'core/edit-post' ) : false;
72+
const editor = select( 'core/editor' );
7373

74-
return __experimentalGetPreviewDeviceType ? __experimentalGetPreviewDeviceType() : getView();
74+
return editor?.getDeviceType ? editor.getDeviceType() : getView();
7575
}, []);
7676

7777
const [ tab, setTab ] = useTabSwitch( attributes.id, 'layout' );

src/blocks/blocks/section/columns/edit.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,16 @@ const Edit = ({
9999
getDefaultBlockVariation
100100
} = select( 'core/blocks' );
101101

102-
const { __experimentalGetPreviewDeviceType } = select( 'core/edit-post' ) ? select( 'core/edit-post' ) : false;
102+
const editor = select( 'core/editor' );
103+
const deviceType = editor?.getDeviceType ? editor.getDeviceType() : false;
103104

104105
return {
105106
sectionBlock: getBlock( clientId ),
106107
children: getBlock( clientId )?.innerBlocks || [],
107-
isViewportAvailable: __experimentalGetPreviewDeviceType ? true : false,
108-
isPreviewDesktop: __experimentalGetPreviewDeviceType ? 'Desktop' === __experimentalGetPreviewDeviceType() : false,
109-
isPreviewTablet: __experimentalGetPreviewDeviceType ? 'Tablet' === __experimentalGetPreviewDeviceType() : false,
110-
isPreviewMobile: __experimentalGetPreviewDeviceType ? 'Mobile' === __experimentalGetPreviewDeviceType() : false,
108+
isViewportAvailable: deviceType ? true : false,
109+
isPreviewDesktop: deviceType ? 'Desktop' === deviceType : false,
110+
isPreviewTablet: deviceType ? 'Tablet' === deviceType : false,
111+
isPreviewMobile: deviceType ? 'Mobile' === deviceType : false,
111112
blockType: getBlockType( name ),
112113
defaultVariation: getDefaultBlockVariation( name, 'block' ),
113114
variations: getBlockVariations( name, 'block' ).filter( ({ isDefault }) => ! isDefault )

0 commit comments

Comments
 (0)