@wordpress/block-library 6.0.11 → 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 +1 -0
- 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 +10 -12
- 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/navigation/edit/index.js +1 -0
- 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-submenu/edit.js +4 -0
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/query-pagination/index.js +1 -1
- package/build/query-pagination-next/index.js +1 -1
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/query-pagination-previous/index.js +1 -1
- package/build/separator/separator-settings.js +1 -0
- package/build/separator/separator-settings.js.map +1 -1
- package/build/social-links/edit.js +1 -0
- package/build/social-links/edit.js.map +1 -1
- package/build-module/cover/edit.js +1 -0
- 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 +10 -12
- 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/navigation/edit/index.js +1 -0
- 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-submenu/edit.js +4 -0
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/query-pagination/index.js +1 -1
- package/build-module/query-pagination-next/index.js +1 -1
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/query-pagination-previous/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/social-links/edit.js +1 -0
- package/build-module/social-links/edit.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 +1 -1
- package/build-style/editor.css +1 -1
- package/build-style/navigation/style-rtl.css +4 -1
- package/build-style/navigation/style.css +4 -1
- package/build-style/style-rtl.css +4 -1
- package/build-style/style.css +4 -1
- package/package.json +8 -8
- package/src/columns/editor.scss +3 -2
- package/src/cover/edit.js +1 -0
- package/src/gallery/deprecated.js +831 -559
- package/src/gallery/edit-wrapper.js +7 -27
- package/src/gallery/edit.js +10 -12
- 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/navigation/edit/index.js +1 -0
- package/src/navigation/edit/inner-blocks.js +0 -5
- package/src/navigation/index.php +149 -18
- package/src/navigation/style.scss +4 -1
- package/src/navigation-submenu/edit.js +6 -0
- package/src/navigation-submenu/index.php +30 -45
- package/src/page-list/index.php +5 -9
- package/src/query-pagination/block.json +1 -1
- package/src/query-pagination-next/block.json +1 -1
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/query-pagination-previous/block.json +1 -1
- package/src/separator/separator-settings.js +1 -0
- package/src/social-links/edit.js +1 -0
- package/src/template-part/index.php +36 -0
- package/build/gallery/v1/update-gallery-modal.js +0 -114
- package/build/gallery/v1/update-gallery-modal.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/src/gallery/v1/update-gallery-modal.js +0 -97
package/src/page-list/index.php
CHANGED
|
@@ -173,24 +173,20 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
$title = wp_kses( $page['title'], wp_kses_allowed_html( 'post' ) );
|
|
177
|
+
|
|
176
178
|
$markup .= '<li class="wp-block-pages-list__item' . $css_class . '"' . $style_attribute . '>';
|
|
177
179
|
|
|
178
180
|
if ( isset( $page['children'] ) && $is_navigation_child && $open_submenus_on_click ) {
|
|
179
|
-
$markup .= '<button class="' . $navigation_child_content_class . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' .
|
|
180
|
-
$page['title'],
|
|
181
|
-
wp_kses_allowed_html( 'post' )
|
|
182
|
-
) . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>' .
|
|
181
|
+
$markup .= '<button aria-label="' . $title . ' ' . __( 'submenu', 'gutenberg' ) . '" class="' . $navigation_child_content_class . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' . $title . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>' .
|
|
183
182
|
'</button>';
|
|
184
183
|
} else {
|
|
185
|
-
$markup .= '<a class="wp-block-pages-list__item__link' . $navigation_child_content_class . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' .
|
|
186
|
-
$page['title'],
|
|
187
|
-
wp_kses_allowed_html( 'post' )
|
|
188
|
-
) . '</a>';
|
|
184
|
+
$markup .= '<a class="wp-block-pages-list__item__link' . $navigation_child_content_class . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . $title . '</a>';
|
|
189
185
|
}
|
|
190
186
|
|
|
191
187
|
if ( isset( $page['children'] ) ) {
|
|
192
188
|
if ( $is_navigation_child && $show_submenu_icons && ! $open_submenus_on_click ) {
|
|
193
|
-
$markup .= '<button class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">';
|
|
189
|
+
$markup .= '<button aria-label="' . $title . ' ' . __( 'submenu', 'gutenberg' ) . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">';
|
|
194
190
|
$markup .= '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>';
|
|
195
191
|
$markup .= '</button>';
|
|
196
192
|
}
|
package/src/social-links/edit.js
CHANGED
|
@@ -50,6 +50,17 @@ function render_block_core_template_part( $attributes ) {
|
|
|
50
50
|
if ( ! is_wp_error( $area_terms ) && false !== $area_terms ) {
|
|
51
51
|
$area = $area_terms[0]->name;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Fires when a block template part is loaded from a template post stored in the database.
|
|
55
|
+
*
|
|
56
|
+
* @since 5.9.0
|
|
57
|
+
*
|
|
58
|
+
* @param string $template_part_id The requested template part namespaced to the theme.
|
|
59
|
+
* @param array $attributes The block attributes.
|
|
60
|
+
* @param WP_Post $template_part_post The template part post object.
|
|
61
|
+
* @param string $content The template part content.
|
|
62
|
+
*/
|
|
63
|
+
do_action( 'render_block_core_template_part_post', $template_part_id, $attributes, $template_part_post, $content );
|
|
53
64
|
} else {
|
|
54
65
|
// Else, if the template part was provided by the active theme,
|
|
55
66
|
// render the corresponding file content.
|
|
@@ -61,6 +72,31 @@ function render_block_core_template_part( $attributes ) {
|
|
|
61
72
|
? _inject_theme_attribute_in_block_template_content( $content )
|
|
62
73
|
: '';
|
|
63
74
|
}
|
|
75
|
+
|
|
76
|
+
if ( '' !== $content && null !== $content ) {
|
|
77
|
+
/**
|
|
78
|
+
* Fires when a block template part is loaded from a template part in the theme.
|
|
79
|
+
*
|
|
80
|
+
* @since 5.9.0
|
|
81
|
+
*
|
|
82
|
+
* @param string $template_part_id The requested template part namespaced to the theme.
|
|
83
|
+
* @param array $attributes The block attributes.
|
|
84
|
+
* @param string $template_part_file_path Absolute path to the template path.
|
|
85
|
+
* @param string $content The template part content.
|
|
86
|
+
*/
|
|
87
|
+
do_action( 'render_block_core_template_part_file', $template_part_id, $attributes, $template_part_file_path, $content );
|
|
88
|
+
} else {
|
|
89
|
+
/**
|
|
90
|
+
* Fires when a requested block template part does not exist in the database nor in the theme.
|
|
91
|
+
*
|
|
92
|
+
* @since 5.9.0
|
|
93
|
+
*
|
|
94
|
+
* @param string $template_part_id The requested template part namespaced to the theme.
|
|
95
|
+
* @param array $attributes The block attributes.
|
|
96
|
+
* @param string $template_part_file_path Absolute path to the not found template path.
|
|
97
|
+
*/
|
|
98
|
+
do_action( 'render_block_core_template_part_none', $template_part_id, $attributes, $template_part_file_path );
|
|
99
|
+
}
|
|
64
100
|
}
|
|
65
101
|
}
|
|
66
102
|
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = UpdateGalleryModal;
|
|
7
|
-
exports.updateGallery = void 0;
|
|
8
|
-
|
|
9
|
-
var _element = require("@wordpress/element");
|
|
10
|
-
|
|
11
|
-
var _components = require("@wordpress/components");
|
|
12
|
-
|
|
13
|
-
var _i18n = require("@wordpress/i18n");
|
|
14
|
-
|
|
15
|
-
var _data = require("@wordpress/data");
|
|
16
|
-
|
|
17
|
-
var _blocks = require("@wordpress/blocks");
|
|
18
|
-
|
|
19
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
20
|
-
|
|
21
|
-
var _constants = require("./constants");
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* WordPress dependencies
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Internal dependencies
|
|
29
|
-
*/
|
|
30
|
-
const updateGallery = _ref => {
|
|
31
|
-
let {
|
|
32
|
-
clientId,
|
|
33
|
-
getBlock,
|
|
34
|
-
replaceBlocks
|
|
35
|
-
} = _ref;
|
|
36
|
-
return () => {
|
|
37
|
-
let link;
|
|
38
|
-
const {
|
|
39
|
-
attributes: {
|
|
40
|
-
sizeSlug,
|
|
41
|
-
linkTo,
|
|
42
|
-
images,
|
|
43
|
-
caption
|
|
44
|
-
}
|
|
45
|
-
} = getBlock(clientId);
|
|
46
|
-
|
|
47
|
-
switch (linkTo) {
|
|
48
|
-
case 'post':
|
|
49
|
-
link = _constants.LINK_DESTINATION_ATTACHMENT;
|
|
50
|
-
break;
|
|
51
|
-
|
|
52
|
-
case 'file':
|
|
53
|
-
link = _constants.LINK_DESTINATION_MEDIA;
|
|
54
|
-
break;
|
|
55
|
-
|
|
56
|
-
default:
|
|
57
|
-
link = _constants.LINK_DESTINATION_NONE;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const innerBlocks = images.map(image => (0, _blocks.createBlock)('core/image', {
|
|
62
|
-
id: image.id ? parseInt(image.id, 10) : null,
|
|
63
|
-
url: image.url,
|
|
64
|
-
alt: image.alt,
|
|
65
|
-
caption: image.caption,
|
|
66
|
-
linkDestination: link
|
|
67
|
-
}));
|
|
68
|
-
replaceBlocks(clientId, (0, _blocks.createBlock)('core/gallery', {
|
|
69
|
-
sizeSlug,
|
|
70
|
-
linkTo: link,
|
|
71
|
-
caption
|
|
72
|
-
}, innerBlocks));
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
exports.updateGallery = updateGallery;
|
|
77
|
-
|
|
78
|
-
function UpdateGalleryModal(_ref2) {
|
|
79
|
-
let {
|
|
80
|
-
onClose,
|
|
81
|
-
clientId
|
|
82
|
-
} = _ref2;
|
|
83
|
-
const {
|
|
84
|
-
getBlock
|
|
85
|
-
} = (0, _data.useSelect)(_blockEditor.store);
|
|
86
|
-
const {
|
|
87
|
-
replaceBlocks
|
|
88
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
89
|
-
return (0, _element.createElement)(_components.Modal, {
|
|
90
|
-
closeLabel: (0, _i18n.__)('Close'),
|
|
91
|
-
onRequestClose: onClose,
|
|
92
|
-
title: (0, _i18n.__)('Update gallery'),
|
|
93
|
-
className: 'wp-block-update-gallery-modal',
|
|
94
|
-
aria: {
|
|
95
|
-
describedby: 'wp-block-update-gallery-modal__description'
|
|
96
|
-
}
|
|
97
|
-
}, (0, _element.createElement)("p", {
|
|
98
|
-
id: 'wp-block-update-gallery-modal__description'
|
|
99
|
-
}, (0, _i18n.__)('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.')), (0, _element.createElement)("div", {
|
|
100
|
-
className: "wp-block-update-gallery-modal-buttons"
|
|
101
|
-
}, (0, _element.createElement)(_components.Button, {
|
|
102
|
-
isTertiary: true,
|
|
103
|
-
onClick: onClose
|
|
104
|
-
}, (0, _i18n.__)('Cancel')), (0, _element.createElement)(_components.Button, {
|
|
105
|
-
isPrimary: true,
|
|
106
|
-
onClick: updateGallery({
|
|
107
|
-
replaceBlocks,
|
|
108
|
-
getBlock,
|
|
109
|
-
clientId,
|
|
110
|
-
createBlock: _blocks.createBlock
|
|
111
|
-
})
|
|
112
|
-
}, (0, _i18n.__)('Update'))));
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=update-gallery-modal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/v1/update-gallery-modal.js"],"names":["updateGallery","clientId","getBlock","replaceBlocks","link","attributes","sizeSlug","linkTo","images","caption","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","innerBlocks","map","image","id","parseInt","url","alt","linkDestination","UpdateGalleryModal","onClose","blockEditorStore","describedby","createBlock"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAOO,MAAMA,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,GAAGM,sCAAP;AACA;;AACD,WAAK,MAAL;AACCN,QAAAA,IAAI,GAAGO,iCAAP;AACA;;AACD;AACCP,QAAAA,IAAI,GAAGQ,gCAAP;AACA;AATF;;AAWA,UAAMC,WAAW,GAAGL,MAAM,CAACM,GAAP,CAAcC,KAAF,IAC/B,yBAAa,YAAb,EAA2B;AAC1BC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AAE;AACxBG,MAAAA,aADwB;AAExBD,MAAAA,QAFwB;AAGxBD,MAAAA,QAHwB;AAIxBwB,MAAAA,WAAW,EAAXA;AAJwB,KAAF;AAFxB,KASG,cAAI,QAAJ,CATH,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: image.id ? parseInt( image.id, 10 ) : null,\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,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: image.id ? parseInt(image.id, 10) : null,
|
|
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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AAF;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: image.id ? parseInt( image.id, 10 ) : null,\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,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: image.id ? parseInt( image.id, 10 ) : null,
|
|
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
|
-
}
|