@@ -12,6 +12,11 @@ import {
1212 useBlockProps ,
1313} from '@wordpress/block-editor' ;
1414
15+ /**
16+ * Internal dependencies
17+ */
18+ import migrateTextAlignAttributeToBlockSupport from '../utils/migrate-text-align' ;
19+
1520const blockSupports = {
1621 className : false ,
1722 anchor : true ,
@@ -75,7 +80,9 @@ const v1 = {
7580 } ,
7681 } ,
7782 migrate : ( attributes ) =>
78- migrateCustomColors ( migrateTextAlign ( attributes ) ) ,
83+ migrateTextAlignAttributeToBlockSupport (
84+ migrateCustomColors ( migrateTextAlign ( attributes ) )
85+ ) ,
7986 save ( { attributes } ) {
8087 const { align, level, content, textColor, customTextColor } =
8188 attributes ;
@@ -111,7 +118,9 @@ const v2 = {
111118 } ,
112119 } ,
113120 migrate : ( attributes ) =>
114- migrateCustomColors ( migrateTextAlign ( attributes ) ) ,
121+ migrateTextAlignAttributeToBlockSupport (
122+ migrateCustomColors ( migrateTextAlign ( attributes ) )
123+ ) ,
115124 save ( { attributes } ) {
116125 const { align, content, customTextColor, level, textColor } =
117126 attributes ;
@@ -149,7 +158,9 @@ const v3 = {
149158 } ,
150159 } ,
151160 migrate : ( attributes ) =>
152- migrateCustomColors ( migrateTextAlign ( attributes ) ) ,
161+ migrateTextAlignAttributeToBlockSupport (
162+ migrateCustomColors ( migrateTextAlign ( attributes ) )
163+ ) ,
153164 save ( { attributes } ) {
154165 const { align, content, customTextColor, level, textColor } =
155166 attributes ;
@@ -195,7 +206,10 @@ const v4 = {
195206 } ,
196207 attributes : blockAttributes ,
197208 isEligible : ( { align } ) => TEXT_ALIGN_OPTIONS . includes ( align ) ,
198- migrate : migrateTextAlign ,
209+ migrate : ( attributes ) =>
210+ migrateTextAlignAttributeToBlockSupport (
211+ migrateCustomColors ( migrateTextAlign ( attributes ) )
212+ ) ,
199213 save ( { attributes } ) {
200214 const { align, content, level } = attributes ;
201215 const TagName = 'h' + level ;
@@ -283,8 +297,107 @@ const v5 = {
283297 </ TagName >
284298 ) ;
285299 } ,
300+ migrate : ( attributes ) =>
301+ migrateTextAlignAttributeToBlockSupport (
302+ migrateCustomColors ( migrateTextAlign ( attributes ) )
303+ ) ,
304+ } ;
305+
306+ const v6 = {
307+ supports : {
308+ align : [ 'wide' , 'full' ] ,
309+ anchor : true ,
310+ className : true ,
311+ splitting : true ,
312+ __experimentalBorder : {
313+ color : true ,
314+ radius : true ,
315+ style : true ,
316+ width : true ,
317+ } ,
318+ color : {
319+ gradients : true ,
320+ link : true ,
321+ __experimentalDefaultControls : {
322+ background : true ,
323+ text : true ,
324+ } ,
325+ } ,
326+ spacing : {
327+ margin : true ,
328+ padding : true ,
329+ } ,
330+ typography : {
331+ fontSize : true ,
332+ lineHeight : true ,
333+ __experimentalFontFamily : true ,
334+ __experimentalFontStyle : true ,
335+ __experimentalFontWeight : true ,
336+ __experimentalLetterSpacing : true ,
337+ __experimentalTextTransform : true ,
338+ __experimentalTextDecoration : true ,
339+ __experimentalWritingMode : true ,
340+ fitText : true ,
341+ __experimentalDefaultControls : {
342+ fontSize : true ,
343+ } ,
344+ } ,
345+ __unstablePasteTextInline : true ,
346+ __experimentalSlashInserter : true ,
347+ interactivity : {
348+ clientNavigation : true ,
349+ } ,
350+ } ,
351+ attributes : {
352+ textAlign : {
353+ type : 'string' ,
354+ } ,
355+ content : {
356+ type : 'string' ,
357+ source : 'html' ,
358+ selector : 'h1,h2,h3,h4,h5,h6' ,
359+ default : '' ,
360+ role : 'content' ,
361+ } ,
362+ level : {
363+ type : 'number' ,
364+ default : 2 ,
365+ } ,
366+ levelOptions : {
367+ type : 'array' ,
368+ } ,
369+ placeholder : {
370+ type : 'string' ,
371+ } ,
372+ } ,
373+ save ( { attributes } ) {
374+ const { textAlign, content, level } = attributes ;
375+ const TagName = 'h' + level ;
376+
377+ const className = clsx ( {
378+ [ `has-text-align-${ textAlign } ` ] : textAlign ,
379+ } ) ;
380+
381+ return (
382+ < TagName { ...useBlockProps . save ( { className } ) } >
383+ < RichText . Content value = { content } />
384+ </ TagName >
385+ ) ;
386+ } ,
387+ migrate : ( attributes ) =>
388+ migrateTextAlignAttributeToBlockSupport (
389+ migrateCustomColors ( migrateTextAlign ( attributes ) )
390+ ) ,
391+ isEligible ( attributes ) {
392+ return (
393+ ! ! attributes . textAlign ||
394+ ! ! attributes . className ?. match (
395+ / \b h a s - t e x t - a l i g n - ( l e f t | c e n t e r | r i g h t ) \b /
396+ )
397+ ) ;
398+ } ,
286399} ;
287400
288- const deprecated = [ v5 , v4 , v3 , v2 , v1 ] ;
401+ const deprecated = [ v6 , v5 , v4 , v3 , v2 , v1 ] ;
289402
290403export default deprecated ;
0 commit comments