@wordpress/block-library 6.0.19 → 6.0.25
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/build/gallery/edit.js +0 -7
- package/build/gallery/edit.js.map +1 -1
- package/build/navigation/edit/index.js +8 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +42 -4
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +6 -41
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-convert-classic-menu.js +59 -0
- package/build/navigation/use-convert-classic-menu.js.map +1 -0
- package/build/navigation/view.js +1 -1
- package/build/navigation/view.js.map +1 -1
- package/build/template-part/index.js +0 -8
- package/build/template-part/index.js.map +1 -1
- package/build-module/gallery/edit.js +0 -6
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +7 -2
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +39 -4
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +5 -41
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-convert-classic-menu.js +47 -0
- package/build-module/navigation/use-convert-classic-menu.js.map +1 -0
- package/build-module/navigation/view.js +1 -1
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/template-part/index.js +0 -8
- package/build-module/template-part/index.js.map +1 -1
- package/package.json +7 -8
- package/src/gallery/edit.js +0 -7
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +9 -1
- package/src/navigation/edit/navigation-menu-selector.js +65 -15
- package/src/navigation/edit/placeholder/index.js +9 -44
- package/src/navigation/use-convert-classic-menu.js +58 -0
- package/src/navigation/view.js +1 -1
- package/src/template-part/block.json +0 -8
- package/build/gallery/use-mobile-warning.js +0 -43
- package/build/gallery/use-mobile-warning.js.map +0 -1
- package/build-module/gallery/use-mobile-warning.js +0 -32
- package/build-module/gallery/use-mobile-warning.js.map +0 -1
- package/src/gallery/use-mobile-warning.js +0 -28
|
@@ -38,14 +38,6 @@ const metadata = {
|
|
|
38
38
|
supports: {
|
|
39
39
|
align: true,
|
|
40
40
|
html: false,
|
|
41
|
-
color: {
|
|
42
|
-
gradients: true,
|
|
43
|
-
link: true
|
|
44
|
-
},
|
|
45
|
-
spacing: {
|
|
46
|
-
padding: true
|
|
47
|
-
},
|
|
48
|
-
__experimentalLayout: true,
|
|
49
41
|
reusable: false
|
|
50
42
|
},
|
|
51
43
|
editorStyle: "wp-block-template-part-editor"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["startCase","store","coreDataStore","select","symbolFilled","addFilter","edit","enhanceTemplatePartVariations","name","metadata","settings","icon","__experimentalLabel","slug","theme","entity","getEntityRecord","title","rendered","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["startCase","store","coreDataStore","select","symbolFilled","addFilter","edit","enhanceTemplatePartVariations","name","metadata","settings","icon","__experimentalLabel","slug","theme","entity","getEntityRecord","title","rendered","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,SAASC,6BAAT,QAA8C,cAA9C;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAEP,YADiB;AAEvBQ,EAAAA,mBAAmB,EAAE,QAAuB;AAAA;;AAAA,QAArB;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAqB;;AAC3C;AACA;AACA,QAAK,CAAED,IAAP,EAAc;AACb;AACA;;AAED,UAAME,MAAM,GAAGZ,MAAM,CAAED,aAAF,CAAN,CAAwBc,eAAxB,CACd,UADc,EAEd,kBAFc,EAGdF,KAAK,GAAG,IAAR,GAAeD,IAHD,CAAf;;AAKA,QAAK,CAAEE,MAAP,EAAgB;AACf;AACA;;AAED,WAAOf,SAAS,CAAE,kBAAAe,MAAM,CAACE,KAAP,gEAAcC,QAAd,KAA0BH,MAAM,CAACF,IAAnC,CAAhB;AACA,GAnBsB;AAoBvBP,EAAAA;AApBuB,CAAjB,C,CAuBP;;AACAD,SAAS,CACR,0BADQ,EAER,oBAFQ,EAGRE,6BAHQ,CAAT,C,CAMA;;AACA,MAAMY,kBAAkB,GAAG,CAAE,oBAAF,EAAwB,mBAAxB,CAA3B;AACAd,SAAS,CACR,0CADQ,EAER,sCAFQ,EAGR,CACCe,GADD,EAECC,SAFD,EAGCC,YAHD,YAKK;AAAA,MADJ;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GACI;;AACJ,MAAKH,SAAS,CAACb,IAAV,KAAmB,oBAAxB,EAA+C;AAC9C,WAAOY,GAAP;AACA;;AAED,OAAM,MAAMK,oBAAZ,IAAoCN,kBAApC,EAAyD;AAAA;;AACxD,UAAMO,mBAAmB,GACxB,cAAAH,QAAQ,CAAED,YAAF,CAAR,wDAA0Bd,IAA1B,MAAmCiB,oBAAnC,IACAD,0BAA0B,CAAEF,YAAF,EAAgBG,oBAAhB,CAA1B,CACEE,MAHH;;AAIA,QAAKD,mBAAL,EAA2B;AAC1B,aAAO,KAAP;AACA;AACD;;AACD,SAAO,IAAP;AACA,CAvBO,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport { startCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst entity = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\ttheme + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn startCase( entity.title?.rendered || entity.slug );\n\t},\n\tedit,\n};\n\n// Importing this file includes side effects. This is whitelisted in block-library/package.json under sideEffects\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/template-part',\n\tenhanceTemplatePartVariations\n);\n\n// Prevent adding template parts inside post templates.\nconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\naddFilter(\n\t'blockEditor.__unstableCanInsertBlockType',\n\t'removeTemplatePartsFromPostTemplates',\n\t(\n\t\tcan,\n\t\tblockType,\n\t\trootClientId,\n\t\t{ getBlock, getBlockParentsByBlockName }\n\t) => {\n\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\treturn can;\n\t\t}\n\n\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\tconst hasDisallowedParent =\n\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\tgetBlockParentsByBlockName( rootClientId, disallowedParentType )\n\t\t\t\t\t.length;\n\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.25",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@wordpress/api-fetch": "^5.2.6",
|
|
38
38
|
"@wordpress/autop": "^3.2.3",
|
|
39
39
|
"@wordpress/blob": "^3.2.2",
|
|
40
|
-
"@wordpress/block-editor": "^8.0.
|
|
40
|
+
"@wordpress/block-editor": "^8.0.16",
|
|
41
41
|
"@wordpress/blocks": "^11.1.5",
|
|
42
|
-
"@wordpress/components": "^19.2.
|
|
42
|
+
"@wordpress/components": "^19.2.2",
|
|
43
43
|
"@wordpress/compose": "^5.0.7",
|
|
44
44
|
"@wordpress/core-data": "^4.0.9",
|
|
45
45
|
"@wordpress/data": "^6.1.5",
|
|
@@ -52,14 +52,13 @@
|
|
|
52
52
|
"@wordpress/html-entities": "^3.2.3",
|
|
53
53
|
"@wordpress/i18n": "^4.2.4",
|
|
54
54
|
"@wordpress/icons": "^6.1.1",
|
|
55
|
-
"@wordpress/interface": "^4.1.16",
|
|
56
55
|
"@wordpress/is-shallow-equal": "^4.2.1",
|
|
57
56
|
"@wordpress/keycodes": "^3.2.4",
|
|
58
57
|
"@wordpress/notices": "^3.2.8",
|
|
59
58
|
"@wordpress/primitives": "^3.0.4",
|
|
60
|
-
"@wordpress/reusable-blocks": "^3.0.
|
|
59
|
+
"@wordpress/reusable-blocks": "^3.0.22",
|
|
61
60
|
"@wordpress/rich-text": "^5.0.8",
|
|
62
|
-
"@wordpress/server-side-render": "^3.0.
|
|
61
|
+
"@wordpress/server-side-render": "^3.0.19",
|
|
63
62
|
"@wordpress/url": "^3.3.1",
|
|
64
63
|
"@wordpress/viewport": "^4.0.7",
|
|
65
64
|
"classnames": "^2.3.1",
|
|
@@ -67,11 +66,11 @@
|
|
|
67
66
|
"fast-average-color": "4.3.0",
|
|
68
67
|
"lodash": "^4.17.21",
|
|
69
68
|
"memize": "^1.1.0",
|
|
70
|
-
"micromodal": "^0.4.
|
|
69
|
+
"micromodal": "^0.4.10",
|
|
71
70
|
"moment": "^2.22.1"
|
|
72
71
|
},
|
|
73
72
|
"publishConfig": {
|
|
74
73
|
"access": "public"
|
|
75
74
|
},
|
|
76
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "cac1a1f3c854fc282d67b91a74936c3fe42d7d0a"
|
|
77
76
|
}
|
package/src/gallery/edit.js
CHANGED
|
@@ -53,11 +53,6 @@ import useShortCodeTransform from './use-short-code-transform';
|
|
|
53
53
|
import useGetNewImages from './use-get-new-images';
|
|
54
54
|
import useGetMedia from './use-get-media';
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* Internal dependencies
|
|
58
|
-
*/
|
|
59
|
-
import useMobileWarning from './use-mobile-warning';
|
|
60
|
-
|
|
61
56
|
const MAX_COLUMNS = 8;
|
|
62
57
|
const linkOptions = [
|
|
63
58
|
{ value: LINK_DESTINATION_ATTACHMENT, label: __( 'Attachment Page' ) },
|
|
@@ -139,8 +134,6 @@ function GalleryEdit( props ) {
|
|
|
139
134
|
|
|
140
135
|
const newImages = useGetNewImages( images, imageData );
|
|
141
136
|
|
|
142
|
-
useMobileWarning( newImages );
|
|
143
|
-
|
|
144
137
|
useEffect( () => {
|
|
145
138
|
newImages?.forEach( ( newImage ) => {
|
|
146
139
|
updateBlockAttributes( newImage.clientId, {
|
|
@@ -45,6 +45,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
45
45
|
*/
|
|
46
46
|
import useListViewModal from './use-list-view-modal';
|
|
47
47
|
import useNavigationMenu from '../use-navigation-menu';
|
|
48
|
+
import useNavigationEntities from '../use-navigation-entities';
|
|
48
49
|
import Placeholder from './placeholder';
|
|
49
50
|
import PlaceholderPreview from './placeholder/placeholder-preview';
|
|
50
51
|
import ResponsiveWrapper from './responsive-wrapper';
|
|
@@ -151,6 +152,10 @@ function Navigation( {
|
|
|
151
152
|
`navigationMenu/${ ref }`
|
|
152
153
|
);
|
|
153
154
|
|
|
155
|
+
// Preload classic menus, so that they don't suddenly pop-in when viewing
|
|
156
|
+
// the Select Menu dropdown.
|
|
157
|
+
useNavigationEntities();
|
|
158
|
+
|
|
154
159
|
const {
|
|
155
160
|
hasUncontrolledInnerBlocks,
|
|
156
161
|
uncontrolledInnerBlocks,
|
|
@@ -474,12 +479,15 @@ function Navigation( {
|
|
|
474
479
|
>
|
|
475
480
|
{ ( { onClose } ) => (
|
|
476
481
|
<NavigationMenuSelector
|
|
482
|
+
clientId={ clientId }
|
|
477
483
|
onSelect={ ( { id } ) => {
|
|
478
484
|
setRef( id );
|
|
479
485
|
onClose();
|
|
480
486
|
} }
|
|
481
487
|
onCreateNew={ startWithEmptyMenu }
|
|
482
|
-
|
|
488
|
+
canUserCreateNavigation={
|
|
489
|
+
canUserCreateNavigation
|
|
490
|
+
}
|
|
483
491
|
/>
|
|
484
492
|
) }
|
|
485
493
|
</ToolbarDropdownMenu>
|
|
@@ -11,18 +11,47 @@ import { addQueryArgs } from '@wordpress/url';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import useNavigationMenu from '../use-navigation-menu';
|
|
14
|
+
import useNavigationEntities from '../use-navigation-entities';
|
|
15
|
+
import useConvertClassicMenu from '../use-convert-classic-menu';
|
|
16
|
+
import useCreateNavigationMenu from './use-create-navigation-menu';
|
|
14
17
|
|
|
15
18
|
export default function NavigationMenuSelector( {
|
|
19
|
+
clientId,
|
|
16
20
|
onSelect,
|
|
17
21
|
onCreateNew,
|
|
18
|
-
|
|
22
|
+
canUserCreateNavigation = false,
|
|
19
23
|
} ) {
|
|
24
|
+
const {
|
|
25
|
+
menus: classicMenus,
|
|
26
|
+
hasMenus: hasClassicMenus,
|
|
27
|
+
} = useNavigationEntities();
|
|
20
28
|
const { navigationMenus } = useNavigationMenu();
|
|
21
29
|
const ref = useEntityId( 'postType', 'wp_navigation' );
|
|
22
30
|
|
|
31
|
+
const createNavigationMenu = useCreateNavigationMenu( clientId );
|
|
32
|
+
|
|
33
|
+
const onFinishMenuCreation = async (
|
|
34
|
+
blocks,
|
|
35
|
+
navigationMenuTitle = null
|
|
36
|
+
) => {
|
|
37
|
+
if ( ! canUserCreateNavigation ) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const navigationMenu = await createNavigationMenu(
|
|
42
|
+
navigationMenuTitle,
|
|
43
|
+
blocks
|
|
44
|
+
);
|
|
45
|
+
onSelect( navigationMenu );
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const convertClassicMenuToBlocks = useConvertClassicMenu(
|
|
49
|
+
onFinishMenuCreation
|
|
50
|
+
);
|
|
51
|
+
|
|
23
52
|
return (
|
|
24
53
|
<>
|
|
25
|
-
<MenuGroup>
|
|
54
|
+
<MenuGroup label={ __( 'Menus' ) }>
|
|
26
55
|
<MenuItemsChoice
|
|
27
56
|
value={ ref }
|
|
28
57
|
onSelect={ ( selectedId ) =>
|
|
@@ -46,19 +75,40 @@ export default function NavigationMenuSelector( {
|
|
|
46
75
|
} ) }
|
|
47
76
|
/>
|
|
48
77
|
</MenuGroup>
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
{ __( '
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
{ canUserCreateNavigation && (
|
|
79
|
+
<>
|
|
80
|
+
{ hasClassicMenus && (
|
|
81
|
+
<MenuGroup label={ __( 'Classic Menus' ) }>
|
|
82
|
+
{ classicMenus.map( ( menu ) => {
|
|
83
|
+
return (
|
|
84
|
+
<MenuItem
|
|
85
|
+
onClick={ () => {
|
|
86
|
+
convertClassicMenuToBlocks(
|
|
87
|
+
menu.id,
|
|
88
|
+
menu.name
|
|
89
|
+
);
|
|
90
|
+
} }
|
|
91
|
+
key={ menu.id }
|
|
92
|
+
>
|
|
93
|
+
{ decodeEntities( menu.name ) }
|
|
94
|
+
</MenuItem>
|
|
95
|
+
);
|
|
96
|
+
} ) }
|
|
97
|
+
</MenuGroup>
|
|
98
|
+
) }
|
|
99
|
+
<MenuGroup label={ __( 'Tools' ) }>
|
|
100
|
+
<MenuItem onClick={ onCreateNew }>
|
|
101
|
+
{ __( 'Create new menu' ) }
|
|
102
|
+
</MenuItem>
|
|
103
|
+
<MenuItem
|
|
104
|
+
href={ addQueryArgs( 'edit.php', {
|
|
105
|
+
post_type: 'wp_navigation',
|
|
106
|
+
} ) }
|
|
107
|
+
>
|
|
108
|
+
{ __( 'Manage menus' ) }
|
|
109
|
+
</MenuItem>
|
|
110
|
+
</MenuGroup>
|
|
111
|
+
</>
|
|
62
112
|
) }
|
|
63
113
|
</>
|
|
64
114
|
);
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
MenuGroup,
|
|
10
10
|
MenuItem,
|
|
11
11
|
} from '@wordpress/components';
|
|
12
|
-
import { useCallback, useState, useEffect } from '@wordpress/element';
|
|
13
12
|
import { __ } from '@wordpress/i18n';
|
|
14
13
|
import { navigation, Icon } from '@wordpress/icons';
|
|
15
14
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
@@ -20,14 +19,13 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
20
19
|
|
|
21
20
|
import useNavigationEntities from '../../use-navigation-entities';
|
|
22
21
|
import PlaceholderPreview from './placeholder-preview';
|
|
23
|
-
import menuItemsToBlocks from '../../menu-items-to-blocks';
|
|
24
22
|
import useNavigationMenu from '../../use-navigation-menu';
|
|
25
23
|
import useCreateNavigationMenu from '../use-create-navigation-menu';
|
|
24
|
+
import useConvertClassicMenu from '../../use-convert-classic-menu';
|
|
26
25
|
|
|
27
26
|
const ExistingMenusDropdown = ( {
|
|
28
27
|
canSwitchNavigationMenu,
|
|
29
28
|
navigationMenus,
|
|
30
|
-
setSelectedMenu,
|
|
31
29
|
onFinish,
|
|
32
30
|
menus,
|
|
33
31
|
onCreateFromMenu,
|
|
@@ -53,7 +51,6 @@ const ExistingMenusDropdown = ( {
|
|
|
53
51
|
return (
|
|
54
52
|
<MenuItem
|
|
55
53
|
onClick={ () => {
|
|
56
|
-
setSelectedMenu( menu.id );
|
|
57
54
|
onFinish( menu );
|
|
58
55
|
} }
|
|
59
56
|
onClose={ onClose }
|
|
@@ -72,8 +69,10 @@ const ExistingMenusDropdown = ( {
|
|
|
72
69
|
return (
|
|
73
70
|
<MenuItem
|
|
74
71
|
onClick={ () => {
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
onCreateFromMenu(
|
|
73
|
+
menu.id,
|
|
74
|
+
menu.name
|
|
75
|
+
);
|
|
77
76
|
} }
|
|
78
77
|
onClose={ onClose }
|
|
79
78
|
key={ menu.id }
|
|
@@ -97,9 +96,6 @@ export default function NavigationPlaceholder( {
|
|
|
97
96
|
hasResolvedNavigationMenus,
|
|
98
97
|
canUserCreateNavigation = false,
|
|
99
98
|
} ) {
|
|
100
|
-
const [ selectedMenu, setSelectedMenu ] = useState();
|
|
101
|
-
const [ isCreatingFromMenu, setIsCreatingFromMenu ] = useState( false );
|
|
102
|
-
const [ menuName, setMenuName ] = useState( '' );
|
|
103
99
|
const createNavigationMenu = useCreateNavigationMenu( clientId );
|
|
104
100
|
|
|
105
101
|
const onFinishMenuCreation = async (
|
|
@@ -117,39 +113,18 @@ export default function NavigationPlaceholder( {
|
|
|
117
113
|
onFinish( navigationMenu, blocks );
|
|
118
114
|
};
|
|
119
115
|
|
|
116
|
+
const convertClassicMenu = useConvertClassicMenu( onFinishMenuCreation );
|
|
117
|
+
|
|
120
118
|
const {
|
|
121
119
|
isResolvingPages,
|
|
122
120
|
menus,
|
|
123
121
|
isResolvingMenus,
|
|
124
|
-
menuItems,
|
|
125
|
-
hasResolvedMenuItems,
|
|
126
122
|
hasPages,
|
|
127
123
|
hasMenus,
|
|
128
|
-
} = useNavigationEntities(
|
|
124
|
+
} = useNavigationEntities();
|
|
129
125
|
|
|
130
126
|
const isStillLoading = isResolvingPages || isResolvingMenus;
|
|
131
127
|
|
|
132
|
-
const createFromMenu = useCallback(
|
|
133
|
-
( name ) => {
|
|
134
|
-
const { innerBlocks: blocks } = menuItemsToBlocks( menuItems );
|
|
135
|
-
onFinishMenuCreation( blocks, name );
|
|
136
|
-
},
|
|
137
|
-
[ menuItems, menuItemsToBlocks, onFinish ]
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
const onCreateFromMenu = ( name ) => {
|
|
141
|
-
// If we have menu items, create the block right away.
|
|
142
|
-
if ( hasResolvedMenuItems ) {
|
|
143
|
-
createFromMenu( name );
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Otherwise, create the block when resolution finishes.
|
|
148
|
-
setIsCreatingFromMenu( true );
|
|
149
|
-
// Store the name to use later.
|
|
150
|
-
setMenuName( name );
|
|
151
|
-
};
|
|
152
|
-
|
|
153
128
|
const onCreateEmptyMenu = () => {
|
|
154
129
|
onFinishMenuCreation( [] );
|
|
155
130
|
};
|
|
@@ -159,15 +134,6 @@ export default function NavigationPlaceholder( {
|
|
|
159
134
|
onFinishMenuCreation( block );
|
|
160
135
|
};
|
|
161
136
|
|
|
162
|
-
useEffect( () => {
|
|
163
|
-
// If the user selected a menu but we had to wait for menu items to
|
|
164
|
-
// finish resolving, then create the block once resolution finishes.
|
|
165
|
-
if ( isCreatingFromMenu && hasResolvedMenuItems ) {
|
|
166
|
-
createFromMenu( menuName );
|
|
167
|
-
setIsCreatingFromMenu( false );
|
|
168
|
-
}
|
|
169
|
-
}, [ isCreatingFromMenu, hasResolvedMenuItems, menuName ] );
|
|
170
|
-
|
|
171
137
|
const { navigationMenus } = useNavigationMenu();
|
|
172
138
|
|
|
173
139
|
return (
|
|
@@ -194,10 +160,9 @@ export default function NavigationPlaceholder( {
|
|
|
194
160
|
canSwitchNavigationMenu
|
|
195
161
|
}
|
|
196
162
|
navigationMenus={ navigationMenus }
|
|
197
|
-
setSelectedMenu={ setSelectedMenu }
|
|
198
163
|
onFinish={ onFinish }
|
|
199
164
|
menus={ menus }
|
|
200
|
-
onCreateFromMenu={
|
|
165
|
+
onCreateFromMenu={ convertClassicMenu }
|
|
201
166
|
showClassicMenus={
|
|
202
167
|
canUserCreateNavigation
|
|
203
168
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback, useState, useEffect } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import useNavigationEntities from './use-navigation-entities';
|
|
10
|
+
import menuItemsToBlocks from './menu-items-to-blocks';
|
|
11
|
+
|
|
12
|
+
export default function useConvertClassicMenu( onFinish ) {
|
|
13
|
+
const [ selectedMenu, setSelectedMenu ] = useState();
|
|
14
|
+
const [
|
|
15
|
+
isAwaitingMenuItemResolution,
|
|
16
|
+
setIsAwaitingMenuItemResolution,
|
|
17
|
+
] = useState( false );
|
|
18
|
+
const [ menuName, setMenuName ] = useState( '' );
|
|
19
|
+
|
|
20
|
+
const { menuItems, hasResolvedMenuItems } = useNavigationEntities(
|
|
21
|
+
selectedMenu
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const createFromMenu = useCallback(
|
|
25
|
+
( name ) => {
|
|
26
|
+
const { innerBlocks: blocks } = menuItemsToBlocks( menuItems );
|
|
27
|
+
onFinish( blocks, name );
|
|
28
|
+
},
|
|
29
|
+
[ menuItems, menuItemsToBlocks, onFinish ]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
useEffect( () => {
|
|
33
|
+
// If the user selected a menu but we had to wait for menu items to
|
|
34
|
+
// finish resolving, then create the block once resolution finishes.
|
|
35
|
+
if ( isAwaitingMenuItemResolution && hasResolvedMenuItems ) {
|
|
36
|
+
createFromMenu( menuName );
|
|
37
|
+
setIsAwaitingMenuItemResolution( false );
|
|
38
|
+
}
|
|
39
|
+
}, [ isAwaitingMenuItemResolution, hasResolvedMenuItems, menuName ] );
|
|
40
|
+
|
|
41
|
+
return useCallback(
|
|
42
|
+
( id, name ) => {
|
|
43
|
+
setSelectedMenu( id );
|
|
44
|
+
|
|
45
|
+
// If we have menu items, create the block right away.
|
|
46
|
+
if ( hasResolvedMenuItems ) {
|
|
47
|
+
createFromMenu( name );
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Otherwise, create the block when resolution finishes.
|
|
52
|
+
setIsAwaitingMenuItemResolution( true );
|
|
53
|
+
// Store the name to use later.
|
|
54
|
+
setMenuName( name );
|
|
55
|
+
},
|
|
56
|
+
[ hasResolvedMenuItems, createFromMenu ]
|
|
57
|
+
);
|
|
58
|
+
}
|
package/src/navigation/view.js
CHANGED
|
@@ -5,7 +5,7 @@ import MicroModal from 'micromodal';
|
|
|
5
5
|
|
|
6
6
|
// Responsive navigation toggle.
|
|
7
7
|
function navigationToggleModal( modal ) {
|
|
8
|
-
const dialogContainer =
|
|
8
|
+
const dialogContainer = modal.querySelector(
|
|
9
9
|
`.wp-block-navigation__responsive-dialog`
|
|
10
10
|
);
|
|
11
11
|
|
|
@@ -22,14 +22,6 @@
|
|
|
22
22
|
"supports": {
|
|
23
23
|
"align": true,
|
|
24
24
|
"html": false,
|
|
25
|
-
"color": {
|
|
26
|
-
"gradients": true,
|
|
27
|
-
"link": true
|
|
28
|
-
},
|
|
29
|
-
"spacing": {
|
|
30
|
-
"padding": true
|
|
31
|
-
},
|
|
32
|
-
"__experimentalLayout": true,
|
|
33
25
|
"reusable": false
|
|
34
26
|
},
|
|
35
27
|
"editorStyle": "wp-block-template-part-editor"
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useMobileWarning;
|
|
7
|
-
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
|
|
10
|
-
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
|
-
var _interface = require("@wordpress/interface");
|
|
13
|
-
|
|
14
|
-
var _notices = require("@wordpress/notices");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
function useMobileWarning(newImages) {
|
|
20
|
-
const {
|
|
21
|
-
createWarningNotice
|
|
22
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
23
|
-
const {
|
|
24
|
-
toggleFeature
|
|
25
|
-
} = (0, _data.useDispatch)(_interface.store);
|
|
26
|
-
const isMobileWarningActive = (0, _data.useSelect)(select => {
|
|
27
|
-
const {
|
|
28
|
-
isFeatureActive
|
|
29
|
-
} = select(_interface.store);
|
|
30
|
-
return isFeatureActive('core/edit-post', 'mobileGalleryWarning');
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
if (!isMobileWarningActive || !newImages) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
createWarningNotice((0, _i18n.__)('If you want to edit the gallery you just added in the mobile app, to avoid losing any data please make sure you use version 18.2 of the app or above.'), {
|
|
38
|
-
type: 'snackbar',
|
|
39
|
-
explicitDismiss: true
|
|
40
|
-
});
|
|
41
|
-
toggleFeature('core/edit-post', 'mobileGalleryWarning');
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=use-mobile-warning.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/use-mobile-warning.js"],"names":["useMobileWarning","newImages","createWarningNotice","noticesStore","toggleFeature","interfaceStore","isMobileWarningActive","select","isFeatureActive","type","explicitDismiss"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMe,SAASA,gBAAT,CAA2BC,SAA3B,EAAuC;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAA0B,uBAAaC,cAAb,CAAhC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,gBAAb,CAA1B;AACA,QAAMC,qBAAqB,GAAG,qBAAaC,MAAF,IAAc;AACtD,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAEF,gBAAF,CAAlC;AACA,WAAOG,eAAe,CAAE,gBAAF,EAAoB,sBAApB,CAAtB;AACA,GAH6B,EAG3B,EAH2B,CAA9B;;AAKA,MAAK,CAAEF,qBAAF,IAA2B,CAAEL,SAAlC,EAA8C;AAC7C;AACA;;AAEDC,EAAAA,mBAAmB,CAClB,cACC,uJADD,CADkB,EAIlB;AAAEO,IAAAA,IAAI,EAAE,UAAR;AAAoBC,IAAAA,eAAe,EAAE;AAArC,GAJkB,CAAnB;AAMAN,EAAAA,aAAa,CAAE,gBAAF,EAAoB,sBAApB,CAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function useMobileWarning( newImages ) {\n\tconst { createWarningNotice } = useDispatch( noticesStore );\n\tconst { toggleFeature } = useDispatch( interfaceStore );\n\tconst isMobileWarningActive = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( interfaceStore );\n\t\treturn isFeatureActive( 'core/edit-post', 'mobileGalleryWarning' );\n\t}, [] );\n\n\tif ( ! isMobileWarningActive || ! newImages ) {\n\t\treturn;\n\t}\n\n\tcreateWarningNotice(\n\t\t__(\n\t\t\t'If you want to edit the gallery you just added in the mobile app, to avoid losing any data please make sure you use version 18.2 of the app or above.'\n\t\t),\n\t\t{ type: 'snackbar', explicitDismiss: true }\n\t);\n\ttoggleFeature( 'core/edit-post', 'mobileGalleryWarning' );\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
-
import { store as interfaceStore } from '@wordpress/interface';
|
|
7
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
-
export default function useMobileWarning(newImages) {
|
|
9
|
-
const {
|
|
10
|
-
createWarningNotice
|
|
11
|
-
} = useDispatch(noticesStore);
|
|
12
|
-
const {
|
|
13
|
-
toggleFeature
|
|
14
|
-
} = useDispatch(interfaceStore);
|
|
15
|
-
const isMobileWarningActive = useSelect(select => {
|
|
16
|
-
const {
|
|
17
|
-
isFeatureActive
|
|
18
|
-
} = select(interfaceStore);
|
|
19
|
-
return isFeatureActive('core/edit-post', 'mobileGalleryWarning');
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
|
-
if (!isMobileWarningActive || !newImages) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
createWarningNotice(__('If you want to edit the gallery you just added in the mobile app, to avoid losing any data please make sure you use version 18.2 of the app or above.'), {
|
|
27
|
-
type: 'snackbar',
|
|
28
|
-
explicitDismiss: true
|
|
29
|
-
});
|
|
30
|
-
toggleFeature('core/edit-post', 'mobileGalleryWarning');
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=use-mobile-warning.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/use-mobile-warning.js"],"names":["__","useDispatch","useSelect","store","interfaceStore","noticesStore","useMobileWarning","newImages","createWarningNotice","toggleFeature","isMobileWarningActive","select","isFeatureActive","type","explicitDismiss"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,YAAlB,QAAsC,oBAAtC;AAEA,eAAe,SAASC,gBAAT,CAA2BC,SAA3B,EAAuC;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAA0BP,WAAW,CAAEI,YAAF,CAA3C;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAoBR,WAAW,CAAEG,cAAF,CAArC;AACA,QAAMM,qBAAqB,GAAGR,SAAS,CAAIS,MAAF,IAAc;AACtD,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAEP,cAAF,CAAlC;AACA,WAAOQ,eAAe,CAAE,gBAAF,EAAoB,sBAApB,CAAtB;AACA,GAHsC,EAGpC,EAHoC,CAAvC;;AAKA,MAAK,CAAEF,qBAAF,IAA2B,CAAEH,SAAlC,EAA8C;AAC7C;AACA;;AAEDC,EAAAA,mBAAmB,CAClBR,EAAE,CACD,uJADC,CADgB,EAIlB;AAAEa,IAAAA,IAAI,EAAE,UAAR;AAAoBC,IAAAA,eAAe,EAAE;AAArC,GAJkB,CAAnB;AAMAL,EAAAA,aAAa,CAAE,gBAAF,EAAoB,sBAApB,CAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function useMobileWarning( newImages ) {\n\tconst { createWarningNotice } = useDispatch( noticesStore );\n\tconst { toggleFeature } = useDispatch( interfaceStore );\n\tconst isMobileWarningActive = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( interfaceStore );\n\t\treturn isFeatureActive( 'core/edit-post', 'mobileGalleryWarning' );\n\t}, [] );\n\n\tif ( ! isMobileWarningActive || ! newImages ) {\n\t\treturn;\n\t}\n\n\tcreateWarningNotice(\n\t\t__(\n\t\t\t'If you want to edit the gallery you just added in the mobile app, to avoid losing any data please make sure you use version 18.2 of the app or above.'\n\t\t),\n\t\t{ type: 'snackbar', explicitDismiss: true }\n\t);\n\ttoggleFeature( 'core/edit-post', 'mobileGalleryWarning' );\n}\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
-
import { store as interfaceStore } from '@wordpress/interface';
|
|
7
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
-
|
|
9
|
-
export default function useMobileWarning( newImages ) {
|
|
10
|
-
const { createWarningNotice } = useDispatch( noticesStore );
|
|
11
|
-
const { toggleFeature } = useDispatch( interfaceStore );
|
|
12
|
-
const isMobileWarningActive = useSelect( ( select ) => {
|
|
13
|
-
const { isFeatureActive } = select( interfaceStore );
|
|
14
|
-
return isFeatureActive( 'core/edit-post', 'mobileGalleryWarning' );
|
|
15
|
-
}, [] );
|
|
16
|
-
|
|
17
|
-
if ( ! isMobileWarningActive || ! newImages ) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
createWarningNotice(
|
|
22
|
-
__(
|
|
23
|
-
'If you want to edit the gallery you just added in the mobile app, to avoid losing any data please make sure you use version 18.2 of the app or above.'
|
|
24
|
-
),
|
|
25
|
-
{ type: 'snackbar', explicitDismiss: true }
|
|
26
|
-
);
|
|
27
|
-
toggleFeature( 'core/edit-post', 'mobileGalleryWarning' );
|
|
28
|
-
}
|