@wordpress/block-library 8.22.0 → 8.24.0
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/CHANGELOG.md +4 -0
- package/build/block/edit.js +11 -13
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +3 -4
- package/build/block/edit.native.js.map +1 -1
- package/build/button/edit.js +61 -9
- package/build/button/edit.js.map +1 -1
- package/build/code/transforms.js +20 -7
- package/build/code/transforms.js.map +1 -1
- package/build/column/edit.js +1 -1
- package/build/column/edit.js.map +1 -1
- package/build/column/edit.native.js +1 -1
- package/build/column/edit.native.js.map +1 -1
- package/build/comments/edit/comments-inspector-controls.js +1 -0
- package/build/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -0
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/edit.js +1 -2
- package/build/details/edit.js.map +1 -1
- package/build/file/edit.js +8 -9
- package/build/file/edit.js.map +1 -1
- package/build/file/view.js +4 -6
- package/build/file/view.js.map +1 -1
- package/build/form/index.js +1 -1
- package/build/form/index.js.map +1 -1
- package/build/form-submit-button/edit.js +2 -1
- package/build/form-submit-button/edit.js.map +1 -1
- package/build/gallery/gap-styles.js +12 -7
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/group/edit.js +4 -7
- package/build/group/edit.js.map +1 -1
- package/build/html/transforms.js +7 -2
- package/build/html/transforms.js.map +1 -1
- package/build/image/deprecated.js +8 -0
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +17 -18
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +22 -15
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +35 -27
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +2 -3
- package/build/image/index.js.map +1 -1
- package/build/image/view.js +234 -266
- package/build/image/view.js.map +1 -1
- package/build/missing/index.js +1 -1
- package/build/navigation/edit/overlay-menu-preview.js +1 -1
- package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build/navigation/use-template-part-area-label.js +2 -1
- package/build/navigation/use-template-part-area-label.js.map +1 -1
- package/build/navigation/view.js +153 -176
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +1 -1
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +2 -1
- package/build/navigation-link/index.js.map +1 -1
- package/build/pattern/edit.js +2 -4
- package/build/pattern/edit.js.map +1 -1
- package/build/post-author/edit.js +0 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +21 -6
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +2 -8
- package/build/post-template/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/post-terms/edit.js +0 -2
- package/build/post-terms/edit.js.map +1 -1
- package/build/preformatted/transforms.js +1 -4
- package/build/preformatted/transforms.js.map +1 -1
- package/build/query/edit/query-content.js +1 -0
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/view.js +52 -60
- package/build/query/view.js.map +1 -1
- package/build/quote/index.js +6 -0
- package/build/quote/index.js.map +1 -1
- package/build/search/view.js +66 -74
- package/build/search/view.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -0
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +3 -7
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/index.js +6 -2
- package/build/template-part/index.js.map +1 -1
- package/build/template-part/variations.js +5 -1
- package/build/template-part/variations.js.map +1 -1
- package/build/utils/remove-anchor-tag.js +17 -0
- package/build/utils/remove-anchor-tag.js.map +1 -0
- package/build-module/block/edit.js +11 -13
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +3 -4
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/button/edit.js +65 -13
- package/build-module/button/edit.js.map +1 -1
- package/build-module/code/transforms.js +20 -7
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/column/edit.js +1 -1
- package/build-module/column/edit.js.map +1 -1
- package/build-module/column/edit.native.js +1 -1
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/comments/edit/comments-inspector-controls.js +1 -0
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/edit.js +1 -2
- package/build-module/details/edit.js.map +1 -1
- package/build-module/file/edit.js +8 -9
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/view.js +5 -7
- package/build-module/file/view.js.map +1 -1
- package/build-module/form/index.js +1 -1
- package/build-module/form/index.js.map +1 -1
- package/build-module/form-submit-button/edit.js +2 -1
- package/build-module/form-submit-button/edit.js.map +1 -1
- package/build-module/gallery/gap-styles.js +13 -8
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/group/edit.js +4 -7
- package/build-module/group/edit.js.map +1 -1
- package/build-module/html/transforms.js +7 -2
- package/build-module/html/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +8 -0
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +18 -19
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +23 -16
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +36 -28
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +2 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/view.js +235 -267
- package/build-module/image/view.js.map +1 -1
- package/build-module/missing/index.js +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build-module/navigation/use-template-part-area-label.js +2 -1
- package/build-module/navigation/use-template-part-area-label.js.map +1 -1
- package/build-module/navigation/view.js +154 -177
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +2 -2
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +2 -1
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/pattern/edit.js +2 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-author/edit.js +0 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +21 -6
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +2 -8
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/post-terms/edit.js +0 -2
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/preformatted/transforms.js +1 -4
- package/build-module/preformatted/transforms.js.map +1 -1
- package/build-module/query/edit/query-content.js +1 -0
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/view.js +53 -61
- package/build-module/query/view.js.map +1 -1
- package/build-module/quote/index.js +6 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/search/view.js +67 -75
- package/build-module/search/view.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -0
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +5 -9
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/index.js +6 -2
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/template-part/variations.js +5 -1
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/utils/remove-anchor-tag.js +11 -0
- package/build-module/utils/remove-anchor-tag.js.map +1 -0
- package/build-style/cover/style-rtl.css +14 -14
- package/build-style/cover/style.css +14 -14
- package/build-style/editor-rtl.css +15 -6
- package/build-style/editor.css +15 -6
- package/build-style/gallery/style-rtl.css +28 -0
- package/build-style/gallery/style.css +28 -0
- package/build-style/image/style-rtl.css +19 -13
- package/build-style/image/style.css +19 -13
- package/build-style/post-featured-image/editor-rtl.css +9 -0
- package/build-style/post-featured-image/editor.css +9 -0
- package/build-style/quote/style-rtl.css +3 -0
- package/build-style/quote/style.css +3 -0
- package/build-style/read-more/style-rtl.css +2 -2
- package/build-style/read-more/style.css +2 -2
- package/build-style/style-rtl.css +66 -29
- package/build-style/style.css +66 -29
- package/package.json +32 -32
- package/src/block/edit.js +20 -20
- package/src/block/edit.native.js +5 -13
- package/src/button/edit.js +76 -10
- package/src/buttons/test/__snapshots__/edit.native.js.snap +0 -6
- package/src/buttons/test/edit.native.js +0 -27
- package/src/code/transforms.js +14 -8
- package/src/column/edit.js +1 -1
- package/src/column/edit.native.js +1 -1
- package/src/comments/edit/comments-inspector-controls.js +1 -0
- package/src/cover/edit/index.js +1 -0
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/cover/style.scss +1 -1
- package/src/cover/test/edit.js +1 -1
- package/src/details/edit.js +0 -1
- package/src/editor.scss +6 -6
- package/src/file/edit.js +11 -10
- package/src/file/index.php +30 -11
- package/src/file/view.js +5 -7
- package/src/form/index.js +1 -1
- package/src/form-submit-button/edit.js +1 -0
- package/src/gallery/gap-styles.js +10 -9
- package/src/gallery/style.scss +1 -0
- package/src/group/edit.js +4 -11
- package/src/heading/test/__snapshots__/index.native.js.snap +6 -0
- package/src/heading/test/index.native.js +40 -0
- package/src/html/transforms.js +5 -2
- package/src/image/block.json +2 -3
- package/src/image/deprecated.js +8 -0
- package/src/image/edit.js +16 -21
- package/src/image/edit.native.js +17 -18
- package/src/image/image.js +48 -51
- package/src/image/index.php +57 -49
- package/src/image/style.scss +18 -13
- package/src/image/view.js +281 -324
- package/src/missing/block.json +1 -1
- package/src/navigation/edit/overlay-menu-preview.js +1 -1
- package/src/navigation/index.php +46 -402
- package/src/navigation/use-template-part-area-label.js +4 -2
- package/src/navigation/view.js +159 -192
- package/src/navigation-link/block.json +2 -1
- package/src/navigation-link/edit.js +2 -2
- package/src/navigation-link/index.php +57 -0
- package/src/paragraph/test/__snapshots__/transforms.native.js.snap +6 -0
- package/src/paragraph/test/edit.native.js +37 -1
- package/src/paragraph/test/transforms.native.js +1 -0
- package/src/pattern/edit.js +7 -4
- package/src/pattern/index.php +6 -1
- package/src/post-author/edit.js +0 -1
- package/src/post-featured-image/edit.js +38 -5
- package/src/post-featured-image/editor.scss +19 -0
- package/src/post-template/block.json +0 -1
- package/src/post-template/edit.js +1 -5
- package/src/post-terms/edit.js +0 -2
- package/src/preformatted/transforms.js +1 -4
- package/src/query/edit/query-content.js +1 -0
- package/src/query/index.php +42 -24
- package/src/query/view.js +58 -65
- package/src/query-pagination-next/index.php +3 -3
- package/src/query-pagination-numbers/index.php +1 -1
- package/src/query-pagination-previous/index.php +3 -3
- package/src/quote/block.json +6 -0
- package/src/quote/style.scss +4 -0
- package/src/read-more/style.scss +1 -1
- package/src/search/index.php +40 -40
- package/src/search/view.js +58 -63
- package/src/template-part/edit/advanced-controls.js +1 -0
- package/src/template-part/edit/index.js +7 -14
- package/src/template-part/index.js +4 -3
- package/src/template-part/index.php +4 -4
- package/src/template-part/variations.js +4 -2
- package/src/utils/remove-anchor-tag.js +10 -0
- package/tsconfig.json +1 -0
package/src/editor.scss
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
|
|
66
66
|
// This CSS Custom Properties aren't used anymore as defaults,
|
|
67
67
|
// but we still need to keep them for backward compatibility.
|
|
68
|
-
.editor-styles-wrapper {
|
|
68
|
+
:where(.editor-styles-wrapper) {
|
|
69
69
|
--wp--preset--font-size--normal: 16px;
|
|
70
70
|
--wp--preset--font-size--huge: 42px;
|
|
71
71
|
}
|
|
@@ -74,19 +74,19 @@
|
|
|
74
74
|
//
|
|
75
75
|
// The reason we add the editor class wrapper here is
|
|
76
76
|
// to avoid enqueing the classes twice: here and in ./editor.scss
|
|
77
|
-
.editor-styles-wrapper .has-regular-font-size {
|
|
77
|
+
:where(.editor-styles-wrapper) .has-regular-font-size {
|
|
78
78
|
font-size: 16px;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
.editor-styles-wrapper .has-larger-font-size {
|
|
81
|
+
:where(.editor-styles-wrapper) .has-larger-font-size {
|
|
82
82
|
font-size: 42px;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
.editor-styles-wrapper .has-normal-font-size {
|
|
85
|
+
:where(.editor-styles-wrapper) .has-normal-font-size {
|
|
86
86
|
font-size: var(--wp--preset--font-size--normal);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
.editor-styles-wrapper .has-huge-font-size {
|
|
89
|
+
:where(.editor-styles-wrapper) .has-huge-font-size {
|
|
90
90
|
font-size: var(--wp--preset--font-size--huge);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -98,6 +98,6 @@
|
|
|
98
98
|
*/
|
|
99
99
|
|
|
100
100
|
// Remove the browser default border for iframe in Custom HTML block, Embed block, etc.
|
|
101
|
-
.editor-styles-wrapper iframe:not([frameborder]) {
|
|
101
|
+
:where(.editor-styles-wrapper) iframe:not([frameborder]) {
|
|
102
102
|
border: 0;
|
|
103
103
|
}
|
package/src/file/edit.js
CHANGED
|
@@ -35,6 +35,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
35
35
|
*/
|
|
36
36
|
import FileBlockInspector from './inspector';
|
|
37
37
|
import { browserSupportsPdfs } from './utils';
|
|
38
|
+
import removeAnchorTag from '../utils/remove-anchor-tag';
|
|
38
39
|
|
|
39
40
|
export const MIN_PREVIEW_HEIGHT = 200;
|
|
40
41
|
export const MAX_PREVIEW_HEIGHT = 2000;
|
|
@@ -102,7 +103,9 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
if ( downloadButtonText === undefined ) {
|
|
105
|
-
|
|
106
|
+
setAttributes( {
|
|
107
|
+
downloadButtonText: _x( 'Download', 'button label' ),
|
|
108
|
+
} );
|
|
106
109
|
}
|
|
107
110
|
}, [] );
|
|
108
111
|
|
|
@@ -148,13 +151,6 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
148
151
|
setAttributes( { showDownloadButton: newValue } );
|
|
149
152
|
}
|
|
150
153
|
|
|
151
|
-
function changeDownloadButtonText( newValue ) {
|
|
152
|
-
// Remove anchor tags from button text content.
|
|
153
|
-
setAttributes( {
|
|
154
|
-
downloadButtonText: newValue.replace( /<\/?a[^>]*>/g, '' ),
|
|
155
|
-
} );
|
|
156
|
-
}
|
|
157
|
-
|
|
158
154
|
function changeDisplayPreview( newValue ) {
|
|
159
155
|
setAttributes( { displayPreview: newValue } );
|
|
160
156
|
}
|
|
@@ -277,7 +273,9 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
277
273
|
placeholder={ __( 'Write file name…' ) }
|
|
278
274
|
withoutInteractiveFormatting
|
|
279
275
|
onChange={ ( text ) =>
|
|
280
|
-
setAttributes( {
|
|
276
|
+
setAttributes( {
|
|
277
|
+
fileName: removeAnchorTag( text ),
|
|
278
|
+
} )
|
|
281
279
|
}
|
|
282
280
|
href={ textLinkHref }
|
|
283
281
|
/>
|
|
@@ -301,7 +299,10 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
301
299
|
withoutInteractiveFormatting
|
|
302
300
|
placeholder={ __( 'Add text…' ) }
|
|
303
301
|
onChange={ ( text ) =>
|
|
304
|
-
|
|
302
|
+
setAttributes( {
|
|
303
|
+
downloadButtonText:
|
|
304
|
+
removeAnchorTag( text ),
|
|
305
|
+
} )
|
|
305
306
|
}
|
|
306
307
|
/>
|
|
307
308
|
</div>
|
package/src/file/index.php
CHANGED
|
@@ -15,19 +15,29 @@
|
|
|
15
15
|
* @return string Returns the block content.
|
|
16
16
|
*/
|
|
17
17
|
function render_block_core_file( $attributes, $content, $block ) {
|
|
18
|
+
$is_gutenberg_plugin = defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN;
|
|
18
19
|
$should_load_view_script = ! empty( $attributes['displayPreview'] );
|
|
19
20
|
$view_js_file = 'wp-block-file-view';
|
|
20
|
-
|
|
21
|
-
if ( ! wp_script_is( $view_js_file ) ) {
|
|
22
|
-
$script_handles = $block->block_type->view_script_handles;
|
|
21
|
+
$script_handles = $block->block_type->view_script_handles;
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
23
|
+
if ( $is_gutenberg_plugin ) {
|
|
24
|
+
if ( $should_load_view_script ) {
|
|
25
|
+
gutenberg_enqueue_module( '@wordpress/block-library/file-block' );
|
|
27
26
|
}
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
// Remove the view script because we are using the module.
|
|
28
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
|
29
|
+
} else {
|
|
30
|
+
// If the script already exists, there is no point in removing it from viewScript.
|
|
31
|
+
if ( ! wp_script_is( $view_js_file ) ) {
|
|
32
|
+
|
|
33
|
+
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
|
34
|
+
if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
|
|
35
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
|
36
|
+
}
|
|
37
|
+
// If the script is needed, but it was previously removed, add it again.
|
|
38
|
+
if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
|
|
39
|
+
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
|
|
40
|
+
}
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -57,9 +67,9 @@ function render_block_core_file( $attributes, $content, $block ) {
|
|
|
57
67
|
if ( $should_load_view_script ) {
|
|
58
68
|
$processor = new WP_HTML_Tag_Processor( $content );
|
|
59
69
|
$processor->next_tag();
|
|
60
|
-
$processor->set_attribute( 'data-wp-interactive', '' );
|
|
70
|
+
$processor->set_attribute( 'data-wp-interactive', '{"namespace":"core/file"}' );
|
|
61
71
|
$processor->next_tag( 'object' );
|
|
62
|
-
$processor->set_attribute( 'data-wp-bind--hidden', '!
|
|
72
|
+
$processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
|
|
63
73
|
$processor->set_attribute( 'hidden', true );
|
|
64
74
|
return $processor->get_updated_html();
|
|
65
75
|
}
|
|
@@ -96,5 +106,14 @@ function register_block_core_file() {
|
|
|
96
106
|
'render_callback' => 'render_block_core_file',
|
|
97
107
|
)
|
|
98
108
|
);
|
|
109
|
+
|
|
110
|
+
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
111
|
+
gutenberg_register_module(
|
|
112
|
+
'@wordpress/block-library/file-block',
|
|
113
|
+
gutenberg_url( '/build/interactivity/file.min.js' ),
|
|
114
|
+
array( '@wordpress/interactivity' ),
|
|
115
|
+
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
|
|
116
|
+
);
|
|
117
|
+
}
|
|
99
118
|
}
|
|
100
119
|
add_action( 'init', 'register_block_core_file' );
|
package/src/file/view.js
CHANGED
|
@@ -5,14 +5,12 @@ import { store } from '@wordpress/interactivity';
|
|
|
5
5
|
/**
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
|
-
import { browserSupportsPdfs
|
|
8
|
+
import { browserSupportsPdfs } from './utils';
|
|
9
9
|
|
|
10
|
-
store( {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
hasPdfPreview,
|
|
15
|
-
},
|
|
10
|
+
store( 'core/file', {
|
|
11
|
+
state: {
|
|
12
|
+
get hasPdfPreview() {
|
|
13
|
+
return browserSupportsPdfs();
|
|
16
14
|
},
|
|
17
15
|
},
|
|
18
16
|
} );
|
package/src/form/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export const init = () => {
|
|
|
27
27
|
const DISALLOWED_PARENTS = [ 'core/form' ];
|
|
28
28
|
addFilter(
|
|
29
29
|
'blockEditor.__unstableCanInsertBlockType',
|
|
30
|
-
'
|
|
30
|
+
'core/block-library/preventInsertingFormIntoAnotherForm',
|
|
31
31
|
(
|
|
32
32
|
canInsert,
|
|
33
33
|
blockType,
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
BlockList,
|
|
6
5
|
__experimentalGetGapCSSValue as getGapCSSValue,
|
|
6
|
+
privateApis as blockEditorPrivateApis,
|
|
7
7
|
} from '@wordpress/block-editor';
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { unlock } from '../lock-unlock';
|
|
13
|
+
|
|
14
|
+
const { useStyleOverride } = unlock( blockEditorPrivateApis );
|
|
9
15
|
|
|
10
16
|
export default function GapStyles( { blockGap, clientId } ) {
|
|
11
|
-
const styleElement = useContext( BlockList.__unstableElementContext );
|
|
12
17
|
// --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
|
|
13
18
|
// gap on the gallery.
|
|
14
19
|
const fallbackValue = `var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )`;
|
|
@@ -35,11 +40,7 @@ export default function GapStyles( { blockGap, clientId } ) {
|
|
|
35
40
|
gap: ${ gapValue }
|
|
36
41
|
}`;
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
return <style>{ gap }</style>;
|
|
40
|
-
};
|
|
43
|
+
useStyleOverride( { css: gap } );
|
|
41
44
|
|
|
42
|
-
return
|
|
43
|
-
? createPortal( <GapStyle />, styleElement )
|
|
44
|
-
: null;
|
|
45
|
+
return null;
|
|
45
46
|
}
|
package/src/gallery/style.scss
CHANGED
package/src/group/edit.js
CHANGED
|
@@ -52,6 +52,7 @@ function GroupEditControls( { tagName, onSelectTagName } ) {
|
|
|
52
52
|
<InspectorControls group="advanced">
|
|
53
53
|
<SelectControl
|
|
54
54
|
__nextHasNoMarginBottom
|
|
55
|
+
__next40pxDefaultSize
|
|
55
56
|
label={ __( 'HTML element' ) }
|
|
56
57
|
options={ [
|
|
57
58
|
{ label: __( 'Default (<div>)' ), value: 'div' },
|
|
@@ -70,13 +71,7 @@ function GroupEditControls( { tagName, onSelectTagName } ) {
|
|
|
70
71
|
);
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
function GroupEdit( {
|
|
74
|
-
attributes,
|
|
75
|
-
name,
|
|
76
|
-
setAttributes,
|
|
77
|
-
clientId,
|
|
78
|
-
__unstableLayoutClassNames: layoutClassNames,
|
|
79
|
-
} ) {
|
|
74
|
+
function GroupEdit( { attributes, name, setAttributes, clientId } ) {
|
|
80
75
|
const { hasInnerBlocks, themeSupportsLayout } = useSelect(
|
|
81
76
|
( select ) => {
|
|
82
77
|
const { getBlock, getSettings } = select( blockEditorStore );
|
|
@@ -102,9 +97,8 @@ function GroupEdit( {
|
|
|
102
97
|
themeSupportsLayout || type === 'flex' || type === 'grid';
|
|
103
98
|
|
|
104
99
|
// Hooks.
|
|
105
|
-
const blockProps = useBlockProps(
|
|
106
|
-
|
|
107
|
-
} );
|
|
100
|
+
const blockProps = useBlockProps();
|
|
101
|
+
|
|
108
102
|
const [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {
|
|
109
103
|
attributes,
|
|
110
104
|
usedLayoutType: type,
|
|
@@ -133,7 +127,6 @@ function GroupEdit( {
|
|
|
133
127
|
templateLock,
|
|
134
128
|
allowedBlocks,
|
|
135
129
|
renderAppender,
|
|
136
|
-
__unstableDisableLayoutClassNames: ! layoutSupportEnabled,
|
|
137
130
|
}
|
|
138
131
|
);
|
|
139
132
|
|
|
@@ -6,6 +6,12 @@ exports[`Heading block inserts block 1`] = `
|
|
|
6
6
|
<!-- /wp:heading -->"
|
|
7
7
|
`;
|
|
8
8
|
|
|
9
|
+
exports[`Heading block should merge with an empty Paragraph block and keep being the Heading block 1`] = `
|
|
10
|
+
"<!-- wp:heading -->
|
|
11
|
+
<h2 class="wp-block-heading">A quick brown fox jumps over the lazy dog.</h2>
|
|
12
|
+
<!-- /wp:heading -->"
|
|
13
|
+
`;
|
|
14
|
+
|
|
9
15
|
exports[`Heading block should set a background color 1`] = `
|
|
10
16
|
"<!-- wp:heading {"backgroundColor":"luminous-vivid-orange"} -->
|
|
11
17
|
<h2 class="wp-block-heading has-luminous-vivid-orange-background-color has-background">A quick brown fox jumps over the lazy dog.</h2>
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
*/
|
|
18
18
|
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
19
19
|
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
20
|
+
import { BACKSPACE, ENTER } from '@wordpress/keycodes';
|
|
20
21
|
|
|
21
22
|
beforeAll( () => {
|
|
22
23
|
// Register all core blocks
|
|
@@ -134,4 +135,43 @@ describe( 'Heading block', () => {
|
|
|
134
135
|
)
|
|
135
136
|
).toBeVisible();
|
|
136
137
|
} );
|
|
138
|
+
|
|
139
|
+
it( 'should merge with an empty Paragraph block and keep being the Heading block', async () => {
|
|
140
|
+
// Arrange
|
|
141
|
+
const screen = await initializeEditor();
|
|
142
|
+
await addBlock( screen, 'Paragraph' );
|
|
143
|
+
|
|
144
|
+
// Act
|
|
145
|
+
const paragraphBlock = getBlock( screen, 'Paragraph' );
|
|
146
|
+
fireEvent.press( paragraphBlock );
|
|
147
|
+
|
|
148
|
+
const paragraphTextInput =
|
|
149
|
+
within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
|
|
150
|
+
fireEvent( paragraphTextInput, 'onKeyDown', {
|
|
151
|
+
nativeEvent: {},
|
|
152
|
+
preventDefault() {},
|
|
153
|
+
keyCode: ENTER,
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
await addBlock( screen, 'Heading' );
|
|
157
|
+
const headingBlock = getBlock( screen, 'Heading', { rowIndex: 2 } );
|
|
158
|
+
fireEvent.press( headingBlock );
|
|
159
|
+
|
|
160
|
+
const headingTextInput =
|
|
161
|
+
within( headingBlock ).getByPlaceholderText( 'Heading' );
|
|
162
|
+
typeInRichText(
|
|
163
|
+
headingTextInput,
|
|
164
|
+
'A quick brown fox jumps over the lazy dog.',
|
|
165
|
+
{ finalSelectionStart: 0, finalSelectionEnd: 0 }
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
fireEvent( headingTextInput, 'onKeyDown', {
|
|
169
|
+
nativeEvent: {},
|
|
170
|
+
preventDefault() {},
|
|
171
|
+
keyCode: BACKSPACE,
|
|
172
|
+
} );
|
|
173
|
+
|
|
174
|
+
// Assert
|
|
175
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
176
|
+
} );
|
|
137
177
|
} );
|
package/src/html/transforms.js
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
|
+
import { create } from '@wordpress/rich-text';
|
|
5
6
|
|
|
6
7
|
const transforms = {
|
|
7
8
|
from: [
|
|
8
9
|
{
|
|
9
10
|
type: 'block',
|
|
10
11
|
blocks: [ 'core/code' ],
|
|
11
|
-
transform: ( { content } ) => {
|
|
12
|
+
transform: ( { content: html } ) => {
|
|
12
13
|
return createBlock( 'core/html', {
|
|
13
|
-
|
|
14
|
+
// The code block may output HTML formatting, so convert it
|
|
15
|
+
// to plain text.
|
|
16
|
+
content: create( { html } ).text,
|
|
14
17
|
} );
|
|
15
18
|
},
|
|
16
19
|
},
|
package/src/image/block.json
CHANGED
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
"keywords": [ "img", "photo", "picture" ],
|
|
10
10
|
"textdomain": "default",
|
|
11
11
|
"attributes": {
|
|
12
|
-
"align": {
|
|
13
|
-
"type": "string"
|
|
14
|
-
},
|
|
15
12
|
"url": {
|
|
16
13
|
"type": "string",
|
|
17
14
|
"source": "attribute",
|
|
@@ -95,6 +92,8 @@
|
|
|
95
92
|
}
|
|
96
93
|
},
|
|
97
94
|
"supports": {
|
|
95
|
+
"interactivity": true,
|
|
96
|
+
"align": [ "left", "center", "right", "wide", "full" ],
|
|
98
97
|
"anchor": true,
|
|
99
98
|
"color": {
|
|
100
99
|
"text": false,
|
package/src/image/deprecated.js
CHANGED
|
@@ -1047,6 +1047,14 @@ const v8 = {
|
|
|
1047
1047
|
},
|
|
1048
1048
|
},
|
|
1049
1049
|
migrate( { width, height, ...attributes } ) {
|
|
1050
|
+
// We need to perform a check here because in cases
|
|
1051
|
+
// where attributes are added dynamically to blocks,
|
|
1052
|
+
// block invalidation overrides the isEligible() method
|
|
1053
|
+
// and forces the migration to run, so it's not guaranteed
|
|
1054
|
+
// that `behaviors` or `behaviors.lightbox` will be defined.
|
|
1055
|
+
if ( ! attributes.behaviors?.lightbox ) {
|
|
1056
|
+
return attributes;
|
|
1057
|
+
}
|
|
1050
1058
|
const {
|
|
1051
1059
|
behaviors: {
|
|
1052
1060
|
lightbox: { enabled },
|
package/src/image/edit.js
CHANGED
|
@@ -10,8 +10,6 @@ import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
|
|
|
10
10
|
import { Placeholder } from '@wordpress/components';
|
|
11
11
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import {
|
|
13
|
-
BlockAlignmentControl,
|
|
14
|
-
BlockControls,
|
|
15
13
|
BlockIcon,
|
|
16
14
|
MediaPlaceholder,
|
|
17
15
|
useBlockProps,
|
|
@@ -106,13 +104,13 @@ export function ImageEdit( {
|
|
|
106
104
|
url = '',
|
|
107
105
|
alt,
|
|
108
106
|
caption,
|
|
109
|
-
align,
|
|
110
107
|
id,
|
|
111
108
|
width,
|
|
112
109
|
height,
|
|
113
110
|
sizeSlug,
|
|
114
111
|
aspectRatio,
|
|
115
112
|
scale,
|
|
113
|
+
align,
|
|
116
114
|
} = attributes;
|
|
117
115
|
const [ temporaryURL, setTemporaryURL ] = useState();
|
|
118
116
|
|
|
@@ -126,6 +124,21 @@ export function ImageEdit( {
|
|
|
126
124
|
captionRef.current = caption;
|
|
127
125
|
}, [ caption ] );
|
|
128
126
|
|
|
127
|
+
const { __unstableMarkNextChangeAsNotPersistent } =
|
|
128
|
+
useDispatch( blockEditorStore );
|
|
129
|
+
|
|
130
|
+
useEffect( () => {
|
|
131
|
+
if ( [ 'wide', 'full' ].includes( align ) ) {
|
|
132
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
133
|
+
setAttributes( {
|
|
134
|
+
width: undefined,
|
|
135
|
+
height: undefined,
|
|
136
|
+
aspectRatio: undefined,
|
|
137
|
+
scale: undefined,
|
|
138
|
+
} );
|
|
139
|
+
}
|
|
140
|
+
}, [ align ] );
|
|
141
|
+
|
|
129
142
|
const ref = useRef();
|
|
130
143
|
const { imageDefaultSize, mediaUpload } = useSelect( ( select ) => {
|
|
131
144
|
const { getSettings } = select( blockEditorStore );
|
|
@@ -255,16 +268,6 @@ export function ImageEdit( {
|
|
|
255
268
|
}
|
|
256
269
|
}
|
|
257
270
|
|
|
258
|
-
function updateAlignment( nextAlign ) {
|
|
259
|
-
const extraUpdatedAttributes = [ 'wide', 'full' ].includes( nextAlign )
|
|
260
|
-
? { width: undefined, height: undefined }
|
|
261
|
-
: {};
|
|
262
|
-
setAttributes( {
|
|
263
|
-
...extraUpdatedAttributes,
|
|
264
|
-
align: nextAlign,
|
|
265
|
-
} );
|
|
266
|
-
}
|
|
267
|
-
|
|
268
271
|
let isTemp = isTemporaryImage( id, url );
|
|
269
272
|
|
|
270
273
|
// Upload a temporary image on mount.
|
|
@@ -375,14 +378,6 @@ export function ImageEdit( {
|
|
|
375
378
|
clientId={ clientId }
|
|
376
379
|
blockEditingMode={ blockEditingMode }
|
|
377
380
|
/>
|
|
378
|
-
{ ! url && blockEditingMode === 'default' && (
|
|
379
|
-
<BlockControls group="block">
|
|
380
|
-
<BlockAlignmentControl
|
|
381
|
-
value={ align }
|
|
382
|
-
onChange={ updateAlignment }
|
|
383
|
-
/>
|
|
384
|
-
</BlockControls>
|
|
385
|
-
) }
|
|
386
381
|
<MediaPlaceholder
|
|
387
382
|
icon={ <BlockIcon icon={ icon } /> }
|
|
388
383
|
onSelect={ onSelectImage }
|
package/src/image/edit.native.js
CHANGED
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
MEDIA_TYPE_IMAGE,
|
|
45
45
|
BlockControls,
|
|
46
46
|
InspectorControls,
|
|
47
|
-
BlockAlignmentToolbar,
|
|
48
47
|
BlockStyles,
|
|
49
48
|
store as blockEditorStore,
|
|
50
49
|
blockSettingsScreens,
|
|
@@ -212,7 +211,6 @@ export class ImageEdit extends Component {
|
|
|
212
211
|
this.onSetFeatured = this.onSetFeatured.bind( this );
|
|
213
212
|
this.onFocusCaption = this.onFocusCaption.bind( this );
|
|
214
213
|
this.onSelectURL = this.onSelectURL.bind( this );
|
|
215
|
-
this.updateAlignment = this.updateAlignment.bind( this );
|
|
216
214
|
this.accessibilityLabelCreator =
|
|
217
215
|
this.accessibilityLabelCreator.bind( this );
|
|
218
216
|
this.setMappedAttributes = this.setMappedAttributes.bind( this );
|
|
@@ -305,6 +303,20 @@ export class ImageEdit extends Component {
|
|
|
305
303
|
this.replacedFeaturedImage = false;
|
|
306
304
|
setFeaturedImage( id );
|
|
307
305
|
}
|
|
306
|
+
|
|
307
|
+
const { align } = attributes;
|
|
308
|
+
const { __unstableMarkNextChangeAsNotPersistent } = this.props;
|
|
309
|
+
|
|
310
|
+
// Update the attributes if the align is wide or full
|
|
311
|
+
if ( [ 'wide', 'full' ].includes( align ) ) {
|
|
312
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
313
|
+
setAttributes( {
|
|
314
|
+
width: undefined,
|
|
315
|
+
height: undefined,
|
|
316
|
+
aspectRatio: undefined,
|
|
317
|
+
scale: undefined,
|
|
318
|
+
} );
|
|
319
|
+
}
|
|
308
320
|
}
|
|
309
321
|
|
|
310
322
|
static getDerivedStateFromProps( props, state ) {
|
|
@@ -391,18 +403,6 @@ export class ImageEdit extends Component {
|
|
|
391
403
|
} );
|
|
392
404
|
}
|
|
393
405
|
|
|
394
|
-
updateAlignment( nextAlign ) {
|
|
395
|
-
const extraUpdatedAttributes = Object.values(
|
|
396
|
-
WIDE_ALIGNMENTS.alignments
|
|
397
|
-
).includes( nextAlign )
|
|
398
|
-
? { width: undefined, height: undefined }
|
|
399
|
-
: {};
|
|
400
|
-
this.props.setAttributes( {
|
|
401
|
-
...extraUpdatedAttributes,
|
|
402
|
-
align: nextAlign,
|
|
403
|
-
} );
|
|
404
|
-
}
|
|
405
|
-
|
|
406
406
|
onSetNewTab( value ) {
|
|
407
407
|
const updatedLinkTarget = getUpdatedLinkTargetSettings(
|
|
408
408
|
value,
|
|
@@ -711,10 +711,6 @@ export class ImageEdit extends Component {
|
|
|
711
711
|
onClick={ open }
|
|
712
712
|
/>
|
|
713
713
|
</ToolbarGroup>
|
|
714
|
-
<BlockAlignmentToolbar
|
|
715
|
-
value={ align }
|
|
716
|
-
onChange={ this.updateAlignment }
|
|
717
|
-
/>
|
|
718
714
|
</BlockControls>
|
|
719
715
|
);
|
|
720
716
|
|
|
@@ -941,8 +937,11 @@ export default compose( [
|
|
|
941
937
|
} ),
|
|
942
938
|
withDispatch( ( dispatch ) => {
|
|
943
939
|
const { createErrorNotice } = dispatch( noticesStore );
|
|
940
|
+
const { __unstableMarkNextChangeAsNotPersistent } =
|
|
941
|
+
dispatch( blockEditorStore );
|
|
944
942
|
|
|
945
943
|
return {
|
|
944
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
946
945
|
createErrorNotice,
|
|
947
946
|
closeSettingsBottomSheet() {
|
|
948
947
|
dispatch( editPostStore ).closeGeneralSidebar();
|