@wordpress/block-library 6.0.8 → 6.0.12
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/cover/edit.js +9 -3
- package/build/cover/edit.js.map +1 -1
- package/build/gallery/deprecated.js +314 -26
- package/build/gallery/deprecated.js.map +1 -1
- package/build/gallery/edit-wrapper.js +10 -27
- package/build/gallery/edit-wrapper.js.map +1 -1
- package/build/gallery/edit.js +11 -13
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/save.js +3 -3
- package/build/gallery/save.js.map +1 -1
- package/build/gallery/shared.js +24 -0
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/transforms.js +8 -22
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/use-mobile-warning.js +1 -1
- package/build/gallery/use-mobile-warning.js.map +1 -1
- package/build/gallery/v1/edit.js +2 -21
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/index.js +4 -3
- package/build/index.js.map +1 -1
- package/build/navigation/deprecated.js +127 -19
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +46 -31
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +0 -4
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +2 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +16 -48
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -35
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +50 -0
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -0
- package/build/navigation/edit/use-generate-default-navigation-title.js +73 -0
- package/build/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
- package/build/navigation/index.js +1 -1
- package/build/navigation/save.js +2 -2
- package/build/navigation/save.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +19 -8
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-area/edit.js +5 -0
- package/build/navigation-area/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +4 -0
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/pattern/index.js +1 -1
- package/build/post-featured-image/edit.js +2 -3
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-terms/index.js +1 -1
- package/build/post-title/edit.js +2 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/query-pagination/index.js +1 -1
- package/build/query-pagination-next/index.js +2 -2
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/query-pagination-previous/index.js +2 -2
- package/build/query-title/index.js +1 -1
- package/build/separator/separator-settings.js +1 -0
- package/build/separator/separator-settings.js.map +1 -1
- package/build/site-logo/index.js +1 -1
- package/build/site-tagline/index.js +1 -1
- package/build/site-title/index.js +1 -1
- package/build/social-links/edit.js +1 -0
- package/build/social-links/edit.js.map +1 -1
- package/build/template-part/edit/placeholder/index.js +1 -1
- package/build/template-part/edit/placeholder/index.js.map +1 -1
- package/build/template-part/index.js +2 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/cover/edit.js +9 -3
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/gallery/deprecated.js +309 -27
- package/build-module/gallery/deprecated.js.map +1 -1
- package/build-module/gallery/edit-wrapper.js +7 -27
- package/build-module/gallery/edit-wrapper.js.map +1 -1
- package/build-module/gallery/edit.js +11 -13
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/save.js +2 -3
- package/build-module/gallery/save.js.map +1 -1
- package/build-module/gallery/shared.js +22 -0
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/transforms.js +9 -21
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/use-mobile-warning.js +1 -1
- package/build-module/gallery/use-mobile-warning.js.map +1 -1
- package/build-module/gallery/v1/edit.js +4 -22
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/index.js +4 -3
- package/build-module/index.js.map +1 -1
- package/build-module/navigation/deprecated.js +127 -19
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +47 -31
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +0 -4
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +2 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +15 -45
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +6 -35
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +36 -0
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -0
- package/build-module/navigation/edit/use-generate-default-navigation-title.js +57 -0
- package/build-module/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
- package/build-module/navigation/index.js +1 -1
- package/build-module/navigation/save.js +2 -2
- package/build-module/navigation/save.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +19 -8
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-area/edit.js +4 -0
- package/build-module/navigation-area/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +4 -0
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/pattern/index.js +1 -1
- package/build-module/post-featured-image/edit.js +2 -3
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-terms/index.js +1 -1
- package/build-module/post-title/edit.js +2 -2
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/query-pagination/index.js +1 -1
- package/build-module/query-pagination-next/index.js +2 -2
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/query-pagination-previous/index.js +2 -2
- package/build-module/query-title/index.js +1 -1
- package/build-module/separator/separator-settings.js +1 -0
- package/build-module/separator/separator-settings.js.map +1 -1
- package/build-module/site-logo/index.js +1 -1
- package/build-module/site-tagline/index.js +1 -1
- package/build-module/site-title/index.js +1 -1
- package/build-module/social-links/edit.js +1 -0
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/template-part/edit/placeholder/index.js +2 -2
- package/build-module/template-part/edit/placeholder/index.js.map +1 -1
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/columns/editor-rtl.css +1 -1
- package/build-style/columns/editor.css +1 -1
- package/build-style/editor-rtl.css +6 -5
- package/build-style/editor.css +6 -5
- package/build-style/gallery/editor-rtl.css +1 -0
- package/build-style/gallery/editor.css +1 -0
- package/build-style/navigation/style-rtl.css +12 -3
- package/build-style/navigation/style.css +12 -3
- package/build-style/post-featured-image/editor-rtl.css +2 -2
- package/build-style/post-featured-image/editor.css +2 -2
- package/build-style/site-logo/editor-rtl.css +2 -2
- package/build-style/site-logo/editor.css +2 -2
- package/build-style/style-rtl.css +12 -3
- package/build-style/style.css +12 -3
- package/package.json +9 -9
- package/src/calendar/index.php +2 -2
- package/src/columns/editor.scss +3 -2
- package/src/cover/edit.js +9 -1
- package/src/gallery/deprecated.js +831 -559
- package/src/gallery/edit-wrapper.js +7 -27
- package/src/gallery/edit.js +11 -13
- package/src/gallery/editor.scss +1 -0
- package/src/gallery/save.js +2 -1
- package/src/gallery/shared.js +24 -0
- package/src/gallery/transforms.js +9 -27
- package/src/gallery/use-mobile-warning.js +1 -1
- package/src/gallery/v1/edit.js +1 -28
- package/src/index.js +28 -26
- package/src/navigation/block.json +1 -1
- package/src/navigation/deprecated.js +115 -13
- package/src/navigation/edit/index.js +44 -36
- package/src/navigation/edit/inner-blocks.js +0 -5
- package/src/navigation/edit/navigation-menu-selector.js +2 -2
- package/src/navigation/edit/placeholder/index.js +16 -62
- package/src/navigation/edit/unsaved-inner-blocks.js +6 -57
- package/src/navigation/edit/use-create-navigation-menu.js +39 -0
- package/src/navigation/edit/use-generate-default-navigation-title.js +79 -0
- package/src/navigation/index.php +263 -26
- package/src/navigation/save.js +2 -2
- package/src/navigation/style.scss +15 -4
- package/src/navigation/use-navigation-menu.js +20 -9
- package/src/navigation-area/edit.js +5 -0
- package/src/navigation-area/index.php +1 -0
- package/src/navigation-submenu/edit.js +6 -0
- package/src/navigation-submenu/index.php +30 -45
- package/src/page-list/index.php +14 -13
- package/src/pattern/block.json +1 -1
- package/src/post-featured-image/edit.js +2 -5
- package/src/post-featured-image/editor.scss +2 -2
- package/src/post-terms/block.json +1 -1
- package/src/post-title/edit.js +2 -2
- package/src/query-pagination/block.json +1 -1
- package/src/query-pagination-next/block.json +2 -2
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/query-pagination-previous/block.json +2 -2
- package/src/query-title/block.json +1 -1
- package/src/separator/separator-settings.js +1 -0
- package/src/site-logo/block.json +1 -1
- package/src/site-logo/editor.scss +2 -2
- package/src/site-tagline/block.json +1 -1
- package/src/site-title/block.json +1 -1
- package/src/social-links/edit.js +1 -0
- package/src/template-part/block.json +2 -1
- package/src/template-part/edit/placeholder/index.js +2 -2
- package/src/template-part/index.php +38 -1
- package/build/gallery/v1/update-gallery-modal.js +0 -114
- package/build/gallery/v1/update-gallery-modal.js.map +0 -1
- package/build/navigation/edit/navigation-menu-name-modal.js +0 -55
- package/build/navigation/edit/navigation-menu-name-modal.js.map +0 -1
- package/build/navigation/edit/navigation-menu-publish-button.js +0 -53
- package/build/navigation/edit/navigation-menu-publish-button.js.map +0 -1
- package/build-module/gallery/v1/update-gallery-modal.js +0 -97
- package/build-module/gallery/v1/update-gallery-modal.js.map +0 -1
- package/build-module/navigation/edit/navigation-menu-name-modal.js +0 -47
- package/build-module/navigation/edit/navigation-menu-name-modal.js.map +0 -1
- package/build-module/navigation/edit/navigation-menu-publish-button.js +0 -40
- package/build-module/navigation/edit/navigation-menu-publish-button.js.map +0 -1
- package/src/gallery/v1/update-gallery-modal.js +0 -97
- package/src/navigation/edit/navigation-menu-name-modal.js +0 -69
- package/src/navigation/edit/navigation-menu-publish-button.js +0 -57
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { Button, Modal } from '@wordpress/components';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
9
|
-
import { createBlock } from '@wordpress/blocks';
|
|
10
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { LINK_DESTINATION_ATTACHMENT, LINK_DESTINATION_NONE, LINK_DESTINATION_MEDIA } from './constants';
|
|
16
|
-
export const updateGallery = _ref => {
|
|
17
|
-
let {
|
|
18
|
-
clientId,
|
|
19
|
-
getBlock,
|
|
20
|
-
replaceBlocks
|
|
21
|
-
} = _ref;
|
|
22
|
-
return () => {
|
|
23
|
-
let link;
|
|
24
|
-
const {
|
|
25
|
-
attributes: {
|
|
26
|
-
sizeSlug,
|
|
27
|
-
linkTo,
|
|
28
|
-
images,
|
|
29
|
-
caption
|
|
30
|
-
}
|
|
31
|
-
} = getBlock(clientId);
|
|
32
|
-
|
|
33
|
-
switch (linkTo) {
|
|
34
|
-
case 'post':
|
|
35
|
-
link = LINK_DESTINATION_ATTACHMENT;
|
|
36
|
-
break;
|
|
37
|
-
|
|
38
|
-
case 'file':
|
|
39
|
-
link = LINK_DESTINATION_MEDIA;
|
|
40
|
-
break;
|
|
41
|
-
|
|
42
|
-
default:
|
|
43
|
-
link = LINK_DESTINATION_NONE;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const innerBlocks = images.map(image => createBlock('core/image', {
|
|
48
|
-
id: parseInt(image.id, 10),
|
|
49
|
-
url: image.url,
|
|
50
|
-
alt: image.alt,
|
|
51
|
-
caption: image.caption,
|
|
52
|
-
linkDestination: link
|
|
53
|
-
}));
|
|
54
|
-
replaceBlocks(clientId, createBlock('core/gallery', {
|
|
55
|
-
sizeSlug,
|
|
56
|
-
linkTo: link,
|
|
57
|
-
caption
|
|
58
|
-
}, innerBlocks));
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
export default function UpdateGalleryModal(_ref2) {
|
|
62
|
-
let {
|
|
63
|
-
onClose,
|
|
64
|
-
clientId
|
|
65
|
-
} = _ref2;
|
|
66
|
-
const {
|
|
67
|
-
getBlock
|
|
68
|
-
} = useSelect(blockEditorStore);
|
|
69
|
-
const {
|
|
70
|
-
replaceBlocks
|
|
71
|
-
} = useDispatch(blockEditorStore);
|
|
72
|
-
return createElement(Modal, {
|
|
73
|
-
closeLabel: __('Close'),
|
|
74
|
-
onRequestClose: onClose,
|
|
75
|
-
title: __('Update gallery'),
|
|
76
|
-
className: 'wp-block-update-gallery-modal',
|
|
77
|
-
aria: {
|
|
78
|
-
describedby: 'wp-block-update-gallery-modal__description'
|
|
79
|
-
}
|
|
80
|
-
}, createElement("p", {
|
|
81
|
-
id: 'wp-block-update-gallery-modal__description'
|
|
82
|
-
}, __('Updating to the new format adds the ability to use custom links or styles on individual images in the gallery, and makes it easier to add or move them around.')), createElement("div", {
|
|
83
|
-
className: "wp-block-update-gallery-modal-buttons"
|
|
84
|
-
}, createElement(Button, {
|
|
85
|
-
isTertiary: true,
|
|
86
|
-
onClick: onClose
|
|
87
|
-
}, __('Cancel')), createElement(Button, {
|
|
88
|
-
isPrimary: true,
|
|
89
|
-
onClick: updateGallery({
|
|
90
|
-
replaceBlocks,
|
|
91
|
-
getBlock,
|
|
92
|
-
clientId,
|
|
93
|
-
createBlock
|
|
94
|
-
})
|
|
95
|
-
}, __('Update'))));
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=update-gallery-modal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/v1/update-gallery-modal.js"],"names":["Button","Modal","__","useDispatch","useSelect","createBlock","store","blockEditorStore","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_NONE","LINK_DESTINATION_MEDIA","updateGallery","clientId","getBlock","replaceBlocks","link","attributes","sizeSlug","linkTo","images","caption","innerBlocks","map","image","id","parseInt","url","alt","linkDestination","UpdateGalleryModal","onClose","describedby"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,KAAjB,QAA8B,uBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SACCC,2BADD,EAECC,qBAFD,EAGCC,sBAHD,QAIO,aAJP;AAMA,OAAO,MAAMC,aAAa,GAAG;AAAA,MAAE;AAC9BC,IAAAA,QAD8B;AAE9BC,IAAAA,QAF8B;AAG9BC,IAAAA;AAH8B,GAAF;AAAA,SAItB,MAAM;AACZ,QAAIC,IAAJ;AACA,UAAM;AACLC,MAAAA,UAAU,EAAE;AAAEC,QAAAA,QAAF;AAAYC,QAAAA,MAAZ;AAAoBC,QAAAA,MAApB;AAA4BC,QAAAA;AAA5B;AADP,QAEFP,QAAQ,CAAED,QAAF,CAFZ;;AAIA,YAASM,MAAT;AACC,WAAK,MAAL;AACCH,QAAAA,IAAI,GAAGP,2BAAP;AACA;;AACD,WAAK,MAAL;AACCO,QAAAA,IAAI,GAAGL,sBAAP;AACA;;AACD;AACCK,QAAAA,IAAI,GAAGN,qBAAP;AACA;AATF;;AAWA,UAAMY,WAAW,GAAGF,MAAM,CAACG,GAAP,CAAcC,KAAF,IAC/BlB,WAAW,CAAE,YAAF,EAAgB;AAC1BmB,MAAAA,EAAE,EAAEC,QAAQ,CAAEF,KAAK,CAACC,EAAR,EAAY,EAAZ,CADc;AAE1BE,MAAAA,GAAG,EAAEH,KAAK,CAACG,GAFe;AAG1BC,MAAAA,GAAG,EAAEJ,KAAK,CAACI,GAHe;AAI1BP,MAAAA,OAAO,EAAEG,KAAK,CAACH,OAJW;AAK1BQ,MAAAA,eAAe,EAAEb;AALS,KAAhB,CADQ,CAApB;AAUAD,IAAAA,aAAa,CACZF,QADY,EAEZP,WAAW,CACV,cADU,EAEV;AAAEY,MAAAA,QAAF;AAAYC,MAAAA,MAAM,EAAEH,IAApB;AAA0BK,MAAAA;AAA1B,KAFU,EAGVC,WAHU,CAFC,CAAb;AAQA,GAvC4B;AAAA,CAAtB;AAyCP,eAAe,SAASQ,kBAAT,QAAqD;AAAA,MAAxB;AAAEC,IAAAA,OAAF;AAAWlB,IAAAA;AAAX,GAAwB;AACnE,QAAM;AAAEC,IAAAA;AAAF,MAAeT,SAAS,CAAEG,gBAAF,CAA9B;AACA,QAAM;AAAEO,IAAAA;AAAF,MAAoBX,WAAW,CAAEI,gBAAF,CAArC;AACA,SACC,cAAC,KAAD;AACC,IAAA,UAAU,EAAGL,EAAE,CAAE,OAAF,CADhB;AAEC,IAAA,cAAc,EAAG4B,OAFlB;AAGC,IAAA,KAAK,EAAG5B,EAAE,CAAE,gBAAF,CAHX;AAIC,IAAA,SAAS,EAAG,+BAJb;AAKC,IAAA,IAAI,EAAG;AACN6B,MAAAA,WAAW,EAAE;AADP;AALR,KASC;AAAG,IAAA,EAAE,EAAG;AAAR,KACG7B,EAAE,CACH,gKADG,CADL,CATD,EAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AAAQ,IAAA,UAAU,MAAlB;AAAmB,IAAA,OAAO,EAAG4B;AAA7B,KACG5B,EAAE,CAAE,QAAF,CADL,CADD,EAIC,cAAC,MAAD;AACC,IAAA,SAAS,MADV;AAEC,IAAA,OAAO,EAAGS,aAAa,CAAE;AACxBG,MAAAA,aADwB;AAExBD,MAAAA,QAFwB;AAGxBD,MAAAA,QAHwB;AAIxBP,MAAAA;AAJwB,KAAF;AAFxB,KASGH,EAAE,CAAE,QAAF,CATL,CAJD,CAfD,CADD;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_NONE,\n\tLINK_DESTINATION_MEDIA,\n} from './constants';\n\nexport const updateGallery = ( {\n\tclientId,\n\tgetBlock,\n\treplaceBlocks,\n} ) => () => {\n\tlet link;\n\tconst {\n\t\tattributes: { sizeSlug, linkTo, images, caption },\n\t} = getBlock( clientId );\n\n\tswitch ( linkTo ) {\n\t\tcase 'post':\n\t\t\tlink = LINK_DESTINATION_ATTACHMENT;\n\t\t\tbreak;\n\t\tcase 'file':\n\t\t\tlink = LINK_DESTINATION_MEDIA;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tlink = LINK_DESTINATION_NONE;\n\t\t\tbreak;\n\t}\n\tconst innerBlocks = images.map( ( image ) =>\n\t\tcreateBlock( 'core/image', {\n\t\t\tid: parseInt( image.id, 10 ),\n\t\t\turl: image.url,\n\t\t\talt: image.alt,\n\t\t\tcaption: image.caption,\n\t\t\tlinkDestination: link,\n\t\t} )\n\t);\n\n\treplaceBlocks(\n\t\tclientId,\n\t\tcreateBlock(\n\t\t\t'core/gallery',\n\t\t\t{ sizeSlug, linkTo: link, caption },\n\t\t\tinnerBlocks\n\t\t)\n\t);\n};\n\nexport default function UpdateGalleryModal( { onClose, clientId } ) {\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\treturn (\n\t\t<Modal\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\ttitle={ __( 'Update gallery' ) }\n\t\t\tclassName={ 'wp-block-update-gallery-modal' }\n\t\t\taria={ {\n\t\t\t\tdescribedby: 'wp-block-update-gallery-modal__description',\n\t\t\t} }\n\t\t>\n\t\t\t<p id={ 'wp-block-update-gallery-modal__description' }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Updating to the new format adds the ability to use custom links or styles on individual images in the gallery, and makes it easier to add or move them around.'\n\t\t\t\t) }\n\t\t\t</p>\n\n\t\t\t<div className=\"wp-block-update-gallery-modal-buttons\">\n\t\t\t\t<Button isTertiary onClick={ onClose }>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tisPrimary\n\t\t\t\t\tonClick={ updateGallery( {\n\t\t\t\t\t\treplaceBlocks,\n\t\t\t\t\t\tgetBlock,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tcreateBlock,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Update' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { Button, Flex, FlexItem, Modal, TextControl } from '@wordpress/components';
|
|
7
|
-
import { useState } from '@wordpress/element';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
export default function NavigationMenuNameModal(_ref) {
|
|
10
|
-
let {
|
|
11
|
-
title,
|
|
12
|
-
finishButtonText = __('Create'),
|
|
13
|
-
onFinish,
|
|
14
|
-
onRequestClose,
|
|
15
|
-
value = ''
|
|
16
|
-
} = _ref;
|
|
17
|
-
const [name, setName] = useState(value);
|
|
18
|
-
return createElement(Modal, {
|
|
19
|
-
title: title,
|
|
20
|
-
closeLabel: __('Cancel'),
|
|
21
|
-
onRequestClose: onRequestClose,
|
|
22
|
-
overlayClassName: "wp-block-template-part__placeholder-create-new__title-form"
|
|
23
|
-
}, createElement("form", {
|
|
24
|
-
onSubmit: event => {
|
|
25
|
-
event.preventDefault();
|
|
26
|
-
onFinish(name);
|
|
27
|
-
}
|
|
28
|
-
}, createElement(TextControl, {
|
|
29
|
-
label: __('Name'),
|
|
30
|
-
value: name,
|
|
31
|
-
onChange: setName
|
|
32
|
-
}), createElement(Flex, {
|
|
33
|
-
className: "wp-block-template-part__placeholder-create-new__title-form-actions",
|
|
34
|
-
justify: "flex-end"
|
|
35
|
-
}, createElement(FlexItem, null, createElement(Button, {
|
|
36
|
-
variant: "secondary",
|
|
37
|
-
onClick: () => {
|
|
38
|
-
onRequestClose();
|
|
39
|
-
}
|
|
40
|
-
}, __('Cancel'))), createElement(FlexItem, null, createElement(Button, {
|
|
41
|
-
variant: "primary",
|
|
42
|
-
type: "submit",
|
|
43
|
-
disabled: !name.length,
|
|
44
|
-
"aria-disabled": !name.length
|
|
45
|
-
}, finishButtonText)))));
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=navigation-menu-name-modal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/navigation-menu-name-modal.js"],"names":["Button","Flex","FlexItem","Modal","TextControl","useState","__","NavigationMenuNameModal","title","finishButtonText","onFinish","onRequestClose","value","name","setName","event","preventDefault","length"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,IAFD,EAGCC,QAHD,EAICC,KAJD,EAKCC,WALD,QAMO,uBANP;AAOA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,eAAe,SAASC,uBAAT,OAMX;AAAA,MAN6C;AAChDC,IAAAA,KADgD;AAEhDC,IAAAA,gBAAgB,GAAGH,EAAE,CAAE,QAAF,CAF2B;AAGhDI,IAAAA,QAHgD;AAIhDC,IAAAA,cAJgD;AAKhDC,IAAAA,KAAK,GAAG;AALwC,GAM7C;AACH,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoBT,QAAQ,CAAEO,KAAF,CAAlC;AAEA,SACC,cAAC,KAAD;AACC,IAAA,KAAK,EAAGJ,KADT;AAEC,IAAA,UAAU,EAAGF,EAAE,CAAE,QAAF,CAFhB;AAGC,IAAA,cAAc,EAAGK,cAHlB;AAIC,IAAA,gBAAgB,EAAC;AAJlB,KAMC;AACC,IAAA,QAAQ,EAAKI,KAAF,IAAa;AACvBA,MAAAA,KAAK,CAACC,cAAN;AACAN,MAAAA,QAAQ,CAAEG,IAAF,CAAR;AACA;AAJF,KAMC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGP,EAAE,CAAE,MAAF,CADX;AAEC,IAAA,KAAK,EAAGO,IAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IAND,EAWC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,oEADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfH,MAAAA,cAAc;AACd;AAJF,KAMGL,EAAE,CAAE,QAAF,CANL,CADD,CAJD,EAcC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,QAAQ,EAAG,CAAEO,IAAI,CAACI,MAHnB;AAIC,qBAAgB,CAAEJ,IAAI,CAACI;AAJxB,KAMGR,gBANH,CADD,CAdD,CAXD,CAND,CADD;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tModal,\n\tTextControl,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nexport default function NavigationMenuNameModal( {\n\ttitle,\n\tfinishButtonText = __( 'Create' ),\n\tonFinish,\n\tonRequestClose,\n\tvalue = '',\n} ) {\n\tconst [ name, setName ] = useState( value );\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ title }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tonRequestClose={ onRequestClose }\n\t\t\toverlayClassName=\"wp-block-template-part__placeholder-create-new__title-form\"\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonFinish( name );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ name }\n\t\t\t\t\tonChange={ setName }\n\t\t\t\t/>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"wp-block-template-part__placeholder-create-new__title-form-actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonRequestClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tdisabled={ ! name.length }\n\t\t\t\t\t\t\taria-disabled={ ! name.length }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ finishButtonText }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { ToolbarButton } from '@wordpress/components';
|
|
7
|
-
import { useEntityId, useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
8
|
-
import { useDispatch } from '@wordpress/data';
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import NavigationMenuNameModal from './navigation-menu-name-modal';
|
|
16
|
-
export default function NavigationMenuPublishButton() {
|
|
17
|
-
const [isNameModalVisible, setIsNameModalVisible] = useState(false);
|
|
18
|
-
const id = useEntityId('postType', 'wp_navigation');
|
|
19
|
-
const [navigationMenuTitle] = useEntityProp('postType', 'wp_navigation', 'title');
|
|
20
|
-
const {
|
|
21
|
-
editEntityRecord,
|
|
22
|
-
saveEditedEntityRecord
|
|
23
|
-
} = useDispatch(coreStore);
|
|
24
|
-
return createElement(Fragment, null, createElement(ToolbarButton, {
|
|
25
|
-
onClick: () => setIsNameModalVisible(true)
|
|
26
|
-
}, __('Save as')), isNameModalVisible && createElement(NavigationMenuNameModal, {
|
|
27
|
-
title: __('Save your new navigation menu'),
|
|
28
|
-
value: navigationMenuTitle,
|
|
29
|
-
onRequestClose: () => setIsNameModalVisible(false),
|
|
30
|
-
finishButtonText: __('Save'),
|
|
31
|
-
onFinish: updatedTitle => {
|
|
32
|
-
editEntityRecord('postType', 'wp_navigation', id, {
|
|
33
|
-
title: updatedTitle,
|
|
34
|
-
status: 'publish'
|
|
35
|
-
});
|
|
36
|
-
saveEditedEntityRecord('postType', 'wp_navigation', id);
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=navigation-menu-publish-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/navigation-menu-publish-button.js"],"names":["ToolbarButton","useEntityId","useEntityProp","store","coreStore","useDispatch","useState","__","NavigationMenuNameModal","NavigationMenuPublishButton","isNameModalVisible","setIsNameModalVisible","id","navigationMenuTitle","editEntityRecord","saveEditedEntityRecord","updatedTitle","title","status"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,uBAA9B;AACA,SACCC,WADD,EAECC,aAFD,EAGCC,KAAK,IAAIC,SAHV,QAIO,sBAJP;AAKA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AAEA,eAAe,SAASC,2BAAT,GAAuC;AACrD,QAAM,CAAEC,kBAAF,EAAsBC,qBAAtB,IAAgDL,QAAQ,CAAE,KAAF,CAA9D;AACA,QAAMM,EAAE,GAAGX,WAAW,CAAE,UAAF,EAAc,eAAd,CAAtB;AACA,QAAM,CAAEY,mBAAF,IAA0BX,aAAa,CAC5C,UAD4C,EAE5C,eAF4C,EAG5C,OAH4C,CAA7C;AAKA,QAAM;AAAEY,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAA+CV,WAAW,CAC/DD,SAD+D,CAAhE;AAIA,SACC,8BACC,cAAC,aAAD;AAAe,IAAA,OAAO,EAAG,MAAMO,qBAAqB,CAAE,IAAF;AAApD,KACGJ,EAAE,CAAE,SAAF,CADL,CADD,EAIGG,kBAAkB,IACnB,cAAC,uBAAD;AACC,IAAA,KAAK,EAAGH,EAAE,CAAE,+BAAF,CADX;AAEC,IAAA,KAAK,EAAGM,mBAFT;AAGC,IAAA,cAAc,EAAG,MAAMF,qBAAqB,CAAE,KAAF,CAH7C;AAIC,IAAA,gBAAgB,EAAGJ,EAAE,CAAE,MAAF,CAJtB;AAKC,IAAA,QAAQ,EAAKS,YAAF,IAAoB;AAC9BF,MAAAA,gBAAgB,CAAE,UAAF,EAAc,eAAd,EAA+BF,EAA/B,EAAmC;AAClDK,QAAAA,KAAK,EAAED,YAD2C;AAElDE,QAAAA,MAAM,EAAE;AAF0C,OAAnC,CAAhB;AAIAH,MAAAA,sBAAsB,CACrB,UADqB,EAErB,eAFqB,EAGrBH,EAHqB,CAAtB;AAKA;AAfF,IALF,CADD;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarButton } from '@wordpress/components';\nimport {\n\tuseEntityId,\n\tuseEntityProp,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuNameModal from './navigation-menu-name-modal';\n\nexport default function NavigationMenuPublishButton() {\n\tconst [ isNameModalVisible, setIsNameModalVisible ] = useState( false );\n\tconst id = useEntityId( 'postType', 'wp_navigation' );\n\tconst [ navigationMenuTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t'title'\n\t);\n\tconst { editEntityRecord, saveEditedEntityRecord } = useDispatch(\n\t\tcoreStore\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton onClick={ () => setIsNameModalVisible( true ) }>\n\t\t\t\t{ __( 'Save as' ) }\n\t\t\t</ToolbarButton>\n\t\t\t{ isNameModalVisible && (\n\t\t\t\t<NavigationMenuNameModal\n\t\t\t\t\ttitle={ __( 'Save your new navigation menu' ) }\n\t\t\t\t\tvalue={ navigationMenuTitle }\n\t\t\t\t\tonRequestClose={ () => setIsNameModalVisible( false ) }\n\t\t\t\t\tfinishButtonText={ __( 'Save' ) }\n\t\t\t\t\tonFinish={ ( updatedTitle ) => {\n\t\t\t\t\t\teditEntityRecord( 'postType', 'wp_navigation', id, {\n\t\t\t\t\t\t\ttitle: updatedTitle,\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tsaveEditedEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t'wp_navigation',\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Button, Modal } from '@wordpress/components';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
|
-
import { createBlock } from '@wordpress/blocks';
|
|
8
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import {
|
|
14
|
-
LINK_DESTINATION_ATTACHMENT,
|
|
15
|
-
LINK_DESTINATION_NONE,
|
|
16
|
-
LINK_DESTINATION_MEDIA,
|
|
17
|
-
} from './constants';
|
|
18
|
-
|
|
19
|
-
export const updateGallery = ( {
|
|
20
|
-
clientId,
|
|
21
|
-
getBlock,
|
|
22
|
-
replaceBlocks,
|
|
23
|
-
} ) => () => {
|
|
24
|
-
let link;
|
|
25
|
-
const {
|
|
26
|
-
attributes: { sizeSlug, linkTo, images, caption },
|
|
27
|
-
} = getBlock( clientId );
|
|
28
|
-
|
|
29
|
-
switch ( linkTo ) {
|
|
30
|
-
case 'post':
|
|
31
|
-
link = LINK_DESTINATION_ATTACHMENT;
|
|
32
|
-
break;
|
|
33
|
-
case 'file':
|
|
34
|
-
link = LINK_DESTINATION_MEDIA;
|
|
35
|
-
break;
|
|
36
|
-
default:
|
|
37
|
-
link = LINK_DESTINATION_NONE;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
const innerBlocks = images.map( ( image ) =>
|
|
41
|
-
createBlock( 'core/image', {
|
|
42
|
-
id: parseInt( image.id, 10 ),
|
|
43
|
-
url: image.url,
|
|
44
|
-
alt: image.alt,
|
|
45
|
-
caption: image.caption,
|
|
46
|
-
linkDestination: link,
|
|
47
|
-
} )
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
replaceBlocks(
|
|
51
|
-
clientId,
|
|
52
|
-
createBlock(
|
|
53
|
-
'core/gallery',
|
|
54
|
-
{ sizeSlug, linkTo: link, caption },
|
|
55
|
-
innerBlocks
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default function UpdateGalleryModal( { onClose, clientId } ) {
|
|
61
|
-
const { getBlock } = useSelect( blockEditorStore );
|
|
62
|
-
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
63
|
-
return (
|
|
64
|
-
<Modal
|
|
65
|
-
closeLabel={ __( 'Close' ) }
|
|
66
|
-
onRequestClose={ onClose }
|
|
67
|
-
title={ __( 'Update gallery' ) }
|
|
68
|
-
className={ 'wp-block-update-gallery-modal' }
|
|
69
|
-
aria={ {
|
|
70
|
-
describedby: 'wp-block-update-gallery-modal__description',
|
|
71
|
-
} }
|
|
72
|
-
>
|
|
73
|
-
<p id={ 'wp-block-update-gallery-modal__description' }>
|
|
74
|
-
{ __(
|
|
75
|
-
'Updating to the new format adds the ability to use custom links or styles on individual images in the gallery, and makes it easier to add or move them around.'
|
|
76
|
-
) }
|
|
77
|
-
</p>
|
|
78
|
-
|
|
79
|
-
<div className="wp-block-update-gallery-modal-buttons">
|
|
80
|
-
<Button isTertiary onClick={ onClose }>
|
|
81
|
-
{ __( 'Cancel' ) }
|
|
82
|
-
</Button>
|
|
83
|
-
<Button
|
|
84
|
-
isPrimary
|
|
85
|
-
onClick={ updateGallery( {
|
|
86
|
-
replaceBlocks,
|
|
87
|
-
getBlock,
|
|
88
|
-
clientId,
|
|
89
|
-
createBlock,
|
|
90
|
-
} ) }
|
|
91
|
-
>
|
|
92
|
-
{ __( 'Update' ) }
|
|
93
|
-
</Button>
|
|
94
|
-
</div>
|
|
95
|
-
</Modal>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
Flex,
|
|
7
|
-
FlexItem,
|
|
8
|
-
Modal,
|
|
9
|
-
TextControl,
|
|
10
|
-
} from '@wordpress/components';
|
|
11
|
-
import { useState } from '@wordpress/element';
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
13
|
-
|
|
14
|
-
export default function NavigationMenuNameModal( {
|
|
15
|
-
title,
|
|
16
|
-
finishButtonText = __( 'Create' ),
|
|
17
|
-
onFinish,
|
|
18
|
-
onRequestClose,
|
|
19
|
-
value = '',
|
|
20
|
-
} ) {
|
|
21
|
-
const [ name, setName ] = useState( value );
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Modal
|
|
25
|
-
title={ title }
|
|
26
|
-
closeLabel={ __( 'Cancel' ) }
|
|
27
|
-
onRequestClose={ onRequestClose }
|
|
28
|
-
overlayClassName="wp-block-template-part__placeholder-create-new__title-form"
|
|
29
|
-
>
|
|
30
|
-
<form
|
|
31
|
-
onSubmit={ ( event ) => {
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
onFinish( name );
|
|
34
|
-
} }
|
|
35
|
-
>
|
|
36
|
-
<TextControl
|
|
37
|
-
label={ __( 'Name' ) }
|
|
38
|
-
value={ name }
|
|
39
|
-
onChange={ setName }
|
|
40
|
-
/>
|
|
41
|
-
<Flex
|
|
42
|
-
className="wp-block-template-part__placeholder-create-new__title-form-actions"
|
|
43
|
-
justify="flex-end"
|
|
44
|
-
>
|
|
45
|
-
<FlexItem>
|
|
46
|
-
<Button
|
|
47
|
-
variant="secondary"
|
|
48
|
-
onClick={ () => {
|
|
49
|
-
onRequestClose();
|
|
50
|
-
} }
|
|
51
|
-
>
|
|
52
|
-
{ __( 'Cancel' ) }
|
|
53
|
-
</Button>
|
|
54
|
-
</FlexItem>
|
|
55
|
-
<FlexItem>
|
|
56
|
-
<Button
|
|
57
|
-
variant="primary"
|
|
58
|
-
type="submit"
|
|
59
|
-
disabled={ ! name.length }
|
|
60
|
-
aria-disabled={ ! name.length }
|
|
61
|
-
>
|
|
62
|
-
{ finishButtonText }
|
|
63
|
-
</Button>
|
|
64
|
-
</FlexItem>
|
|
65
|
-
</Flex>
|
|
66
|
-
</form>
|
|
67
|
-
</Modal>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { ToolbarButton } from '@wordpress/components';
|
|
5
|
-
import {
|
|
6
|
-
useEntityId,
|
|
7
|
-
useEntityProp,
|
|
8
|
-
store as coreStore,
|
|
9
|
-
} from '@wordpress/core-data';
|
|
10
|
-
import { useDispatch } from '@wordpress/data';
|
|
11
|
-
import { useState } from '@wordpress/element';
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
import NavigationMenuNameModal from './navigation-menu-name-modal';
|
|
18
|
-
|
|
19
|
-
export default function NavigationMenuPublishButton() {
|
|
20
|
-
const [ isNameModalVisible, setIsNameModalVisible ] = useState( false );
|
|
21
|
-
const id = useEntityId( 'postType', 'wp_navigation' );
|
|
22
|
-
const [ navigationMenuTitle ] = useEntityProp(
|
|
23
|
-
'postType',
|
|
24
|
-
'wp_navigation',
|
|
25
|
-
'title'
|
|
26
|
-
);
|
|
27
|
-
const { editEntityRecord, saveEditedEntityRecord } = useDispatch(
|
|
28
|
-
coreStore
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<>
|
|
33
|
-
<ToolbarButton onClick={ () => setIsNameModalVisible( true ) }>
|
|
34
|
-
{ __( 'Save as' ) }
|
|
35
|
-
</ToolbarButton>
|
|
36
|
-
{ isNameModalVisible && (
|
|
37
|
-
<NavigationMenuNameModal
|
|
38
|
-
title={ __( 'Save your new navigation menu' ) }
|
|
39
|
-
value={ navigationMenuTitle }
|
|
40
|
-
onRequestClose={ () => setIsNameModalVisible( false ) }
|
|
41
|
-
finishButtonText={ __( 'Save' ) }
|
|
42
|
-
onFinish={ ( updatedTitle ) => {
|
|
43
|
-
editEntityRecord( 'postType', 'wp_navigation', id, {
|
|
44
|
-
title: updatedTitle,
|
|
45
|
-
status: 'publish',
|
|
46
|
-
} );
|
|
47
|
-
saveEditedEntityRecord(
|
|
48
|
-
'postType',
|
|
49
|
-
'wp_navigation',
|
|
50
|
-
id
|
|
51
|
-
);
|
|
52
|
-
} }
|
|
53
|
-
/>
|
|
54
|
-
) }
|
|
55
|
-
</>
|
|
56
|
-
);
|
|
57
|
-
}
|