@wordpress/block-library 9.10.0 → 9.12.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/README.md +10 -5
- package/build/archives/index.js +6 -0
- package/build/archives/index.js.map +1 -1
- package/build/avatar/hooks.js +2 -3
- package/build/avatar/hooks.js.map +1 -1
- package/build/button/get-updated-link-attributes.js +1 -1
- package/build/button/get-updated-link-attributes.js.map +1 -1
- package/build/button/index.js +1 -1
- package/build/button/index.js.map +1 -1
- package/build/comments/index.js +12 -0
- package/build/comments/index.js.map +1 -1
- package/build/cover/constants.js +8 -0
- package/build/cover/constants.js.map +1 -0
- package/build/cover/deprecated.js +140 -4
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/block-controls.js +1 -1
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/cover-placeholder.js +1 -2
- package/build/cover/edit/cover-placeholder.js.map +1 -1
- package/build/cover/edit/index.js +42 -21
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +40 -2
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +3 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +16 -14
- package/build/cover/save.js.map +1 -1
- package/build/details/index.js +1 -0
- package/build/details/index.js.map +1 -1
- package/build/file/edit.js +2 -3
- package/build/file/edit.js.map +1 -1
- package/build/gallery/constants.js +2 -1
- package/build/gallery/constants.js.map +1 -1
- package/build/gallery/edit.js +12 -3
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/utils.js +26 -5
- package/build/gallery/utils.js.map +1 -1
- package/build/html/edit.js +5 -1
- package/build/html/edit.js.map +1 -1
- package/build/html/preview.js +2 -2
- package/build/html/preview.js.map +1 -1
- package/build/image/edit.js +1 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +144 -78
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +1 -1
- package/build/latest-posts/edit.js +3 -9
- package/build/latest-posts/edit.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +1 -1
- package/build/navigation/edit/menu-inspector-controls.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/paragraph/edit.js +2 -2
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-content/index.js +13 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-featured-image/edit.js +1 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +11 -0
- package/build/post-template/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/post-time-to-read/edit.js +2 -2
- package/build/post-time-to-read/edit.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +2 -2
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/order-control.js +2 -2
- package/build/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build/query/edit/pattern-selection-modal.js +0 -3
- package/build/query/edit/pattern-selection-modal.js.map +1 -1
- package/build/query/edit/query-content.js +10 -12
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/index.js +1 -1
- package/build/query/utils.js +32 -1
- package/build/query/utils.js.map +1 -1
- package/build/query-title/edit.js +1 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/search/edit.js +19 -14
- package/build/search/edit.js.map +1 -1
- package/build/separator/transforms.js +12 -0
- package/build/separator/transforms.js.map +1 -1
- package/build/social-links/edit.js +0 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/spacer/index.js +2 -0
- package/build/spacer/index.js.map +1 -1
- package/build/spacer/transforms.js +27 -0
- package/build/spacer/transforms.js.map +1 -0
- package/build/table/edit.js +0 -1
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +2 -7
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/template-part/edit/index.js +2 -5
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +0 -3
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/video/edit.js +1 -1
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +1 -3
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/archives/index.js +6 -0
- package/build-module/archives/index.js.map +1 -1
- package/build-module/avatar/hooks.js +2 -3
- package/build-module/avatar/hooks.js.map +1 -1
- package/build-module/button/get-updated-link-attributes.js +1 -1
- package/build-module/button/get-updated-link-attributes.js.map +1 -1
- package/build-module/button/index.js +1 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/comments/index.js +12 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/cover/constants.js +2 -0
- package/build-module/cover/constants.js.map +1 -0
- package/build-module/cover/deprecated.js +140 -4
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +1 -1
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/cover-placeholder.js +1 -2
- package/build-module/cover/edit/cover-placeholder.js.map +1 -1
- package/build-module/cover/edit/index.js +42 -21
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +41 -3
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +3 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +16 -14
- package/build-module/cover/save.js.map +1 -1
- package/build-module/details/index.js +1 -0
- package/build-module/details/index.js.map +1 -1
- package/build-module/file/edit.js +2 -3
- package/build-module/file/edit.js.map +1 -1
- package/build-module/gallery/constants.js +1 -0
- package/build-module/gallery/constants.js.map +1 -1
- package/build-module/gallery/edit.js +15 -6
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/utils.js +27 -6
- package/build-module/gallery/utils.js.map +1 -1
- package/build-module/html/edit.js +6 -2
- package/build-module/html/edit.js.map +1 -1
- package/build-module/html/preview.js +2 -2
- package/build-module/html/preview.js.map +1 -1
- package/build-module/image/edit.js +1 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +149 -83
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +1 -1
- package/build-module/latest-posts/edit.js +3 -9
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +1 -3
- package/build-module/navigation/edit/menu-inspector-controls.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/paragraph/edit.js +2 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-content/index.js +13 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +1 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +11 -0
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/post-time-to-read/edit.js +2 -2
- package/build-module/post-time-to-read/edit.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +2 -2
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/order-control.js +2 -2
- package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build-module/query/edit/pattern-selection-modal.js +0 -3
- package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
- package/build-module/query/edit/query-content.js +10 -12
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/index.js +1 -1
- package/build-module/query/utils.js +29 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-title/edit.js +2 -2
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/search/edit.js +20 -15
- package/build-module/search/edit.js.map +1 -1
- package/build-module/separator/transforms.js +12 -0
- package/build-module/separator/transforms.js.map +1 -1
- package/build-module/social-links/edit.js +0 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/spacer/index.js +2 -0
- package/build-module/spacer/index.js.map +1 -1
- package/build-module/spacer/transforms.js +20 -0
- package/build-module/spacer/transforms.js.map +1 -0
- package/build-module/table/edit.js +0 -1
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +2 -7
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +2 -5
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +0 -3
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/video/edit.js +1 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +2 -4
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/archives/editor-rtl.css +5 -0
- package/build-style/archives/editor.css +5 -0
- package/build-style/button/style-rtl.css +3 -0
- package/build-style/button/style.css +3 -0
- package/build-style/comments/editor-rtl.css +4 -0
- package/build-style/comments/editor.css +4 -0
- package/build-style/comments/style-rtl.css +4 -0
- package/build-style/comments/style.css +4 -0
- package/build-style/cover/editor-rtl.css +3 -5
- package/build-style/cover/editor.css +3 -5
- package/build-style/cover/style-rtl.css +19 -10
- package/build-style/cover/style.css +19 -10
- package/build-style/editor-rtl.css +17 -12
- package/build-style/editor.css +17 -12
- package/build-style/image/editor-rtl.css +4 -0
- package/build-style/image/editor.css +4 -0
- package/build-style/latest-posts/editor-rtl.css +0 -7
- package/build-style/latest-posts/editor.css +0 -7
- package/build-style/media-text/style-rtl.css +1 -1
- package/build-style/media-text/style.css +1 -1
- package/build-style/navigation/editor-rtl.css +1 -0
- package/build-style/navigation/editor.css +1 -0
- package/build-style/style-rtl.css +27 -11
- package/build-style/style.css +27 -11
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/package.json +41 -40
- package/src/archives/block.json +6 -0
- package/src/archives/editor.scss +8 -0
- package/src/avatar/hooks.js +2 -3
- package/src/avatar/index.php +4 -5
- package/src/button/get-updated-link-attributes.js +1 -1
- package/src/button/index.js +1 -1
- package/src/button/style.scss +3 -0
- package/src/button/test/get-updated-link-attributes.js +15 -0
- package/src/comment-author-avatar/index.php +1 -1
- package/src/comments/block.json +12 -0
- package/src/comments/style.scss +4 -1
- package/src/cover/block.json +3 -0
- package/src/cover/constants.js +1 -0
- package/src/cover/deprecated.js +182 -4
- package/src/cover/edit/block-controls.js +1 -1
- package/src/cover/edit/cover-placeholder.js +0 -3
- package/src/cover/edit/index.js +57 -24
- package/src/cover/edit/inspector-controls.js +46 -1
- package/src/cover/editor.scss +4 -5
- package/src/cover/save.js +29 -20
- package/src/cover/style.scss +40 -10
- package/src/cover/test/__snapshots__/edit.native.js.snap +9 -9
- package/src/cover/test/__snapshots__/transforms.native.js.snap +4 -4
- package/src/cover/test/edit.js +1 -3
- package/src/cover/test/edit.native.js +4 -4
- package/src/cover/test/transforms.native.js +4 -4
- package/src/details/block.json +1 -0
- package/src/file/edit.js +2 -3
- package/src/gallery/constants.js +1 -0
- package/src/gallery/edit.js +26 -3
- package/src/gallery/utils.js +23 -2
- package/src/html/edit.js +7 -1
- package/src/html/preview.js +3 -2
- package/src/image/block.json +1 -1
- package/src/image/edit.js +1 -1
- package/src/image/editor.scss +4 -0
- package/src/image/image.js +200 -109
- package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/latest-posts/edit.js +3 -8
- package/src/latest-posts/editor.scss +0 -11
- package/src/latest-posts/index.php +1 -1
- package/src/media-text/style.scss +1 -1
- package/src/media-text/test/__snapshots__/transforms.native.js.snap +2 -2
- package/src/navigation/edit/menu-inspector-controls.js +2 -2
- package/src/navigation/edit/navigation-menu-selector.js +2 -2
- package/src/navigation/editor.scss +1 -0
- package/src/navigation/index.php +1 -1
- package/src/paragraph/edit.js +2 -2
- package/src/post-content/block.json +14 -1
- package/src/post-featured-image/edit.js +1 -1
- package/src/post-template/block.json +2 -1
- package/src/post-template/edit.js +19 -0
- package/src/post-time-to-read/edit.js +2 -2
- package/src/post-time-to-read/index.php +1 -1
- package/src/query/block.json +1 -1
- package/src/query/edit/inspector-controls/index.js +2 -2
- package/src/query/edit/inspector-controls/order-control.js +2 -2
- package/src/query/edit/pattern-selection-modal.js +0 -3
- package/src/query/edit/query-content.js +9 -17
- package/src/query/test/utils.js +59 -1
- package/src/query/utils.js +29 -0
- package/src/query-title/edit.js +2 -2
- package/src/rss/index.php +1 -1
- package/src/search/edit.js +28 -25
- package/src/search/index.php +2 -2
- package/src/separator/test/__snapshots__/transforms.native.js.snap +6 -0
- package/src/separator/test/transforms.native.js +1 -1
- package/src/separator/transforms.js +11 -0
- package/src/social-links/edit.js +0 -1
- package/src/spacer/index.js +2 -0
- package/src/spacer/test/__snapshots__/transforms.native.js.snap +6 -0
- package/src/spacer/test/transforms.native.js +1 -1
- package/src/spacer/transforms.js +20 -0
- package/src/table/edit.js +0 -1
- package/src/table-of-contents/edit.js +2 -6
- package/src/template-part/edit/index.js +2 -5
- package/src/template-part/edit/selection-modal.js +0 -3
- package/src/video/edit.js +1 -1
- package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/video/tracks-editor.js +2 -4
- package/tsconfig.tsbuildinfo +1 -1
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
|
@@ -45,7 +45,7 @@ import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks';
|
|
|
45
45
|
const { BlockInfo } = unlock( blockEditorPrivateApis );
|
|
46
46
|
|
|
47
47
|
export default function QueryInspectorControls( props ) {
|
|
48
|
-
const { attributes, setQuery, setDisplayLayout,
|
|
48
|
+
const { attributes, setQuery, setDisplayLayout, isSingular } = props;
|
|
49
49
|
const { query, displayLayout } = attributes;
|
|
50
50
|
const {
|
|
51
51
|
order,
|
|
@@ -118,7 +118,7 @@ export default function QueryInspectorControls( props ) {
|
|
|
118
118
|
}, [ querySearch, onChangeDebounced ] );
|
|
119
119
|
|
|
120
120
|
const showInheritControl =
|
|
121
|
-
|
|
121
|
+
! isSingular && isControlAllowed( allowedControls, 'inherit' );
|
|
122
122
|
const showPostTypeControl =
|
|
123
123
|
! inherit && isControlAllowed( allowedControls, 'postType' );
|
|
124
124
|
const postTypeControlLabel = __( 'Post type' );
|
|
@@ -14,12 +14,12 @@ const orderOptions = [
|
|
|
14
14
|
value: 'date/asc',
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
/* translators:
|
|
17
|
+
/* translators: Label for ordering posts by title in ascending order. */
|
|
18
18
|
label: __( 'A → Z' ),
|
|
19
19
|
value: 'title/asc',
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
|
-
/* translators:
|
|
22
|
+
/* translators: Label for ordering posts by title in descending order. */
|
|
23
23
|
label: __( 'Z → A' ),
|
|
24
24
|
value: 'title/desc',
|
|
25
25
|
},
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { useState, useMemo } from '@wordpress/element';
|
|
5
5
|
import { useDispatch } from '@wordpress/data';
|
|
6
6
|
import { Modal, SearchControl } from '@wordpress/components';
|
|
7
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
8
7
|
import {
|
|
9
8
|
BlockContextProvider,
|
|
10
9
|
store as blockEditorStore,
|
|
@@ -55,7 +54,6 @@ export default function PatternSelectionModal( {
|
|
|
55
54
|
const filteredBlockPatterns = useMemo( () => {
|
|
56
55
|
return searchPatterns( blockPatterns, searchValue );
|
|
57
56
|
}, [ blockPatterns, searchValue ] );
|
|
58
|
-
const shownBlockPatterns = useAsyncList( filteredBlockPatterns );
|
|
59
57
|
|
|
60
58
|
return (
|
|
61
59
|
<Modal
|
|
@@ -77,7 +75,6 @@ export default function PatternSelectionModal( {
|
|
|
77
75
|
<BlockContextProvider value={ blockPreviewContext }>
|
|
78
76
|
<BlockPatternsList
|
|
79
77
|
blockPatterns={ filteredBlockPatterns }
|
|
80
|
-
shownPatterns={ shownBlockPatterns }
|
|
81
78
|
onClickPattern={ onBlockPatternSelect }
|
|
82
79
|
/>
|
|
83
80
|
</BlockContextProvider>
|
|
@@ -22,6 +22,7 @@ import EnhancedPaginationControl from './inspector-controls/enhanced-pagination-
|
|
|
22
22
|
import QueryToolbar from './query-toolbar';
|
|
23
23
|
import QueryInspectorControls from './inspector-controls';
|
|
24
24
|
import EnhancedPaginationModal from './enhanced-pagination-modal';
|
|
25
|
+
import { getQueryContextFromTemplate } from '../utils';
|
|
25
26
|
|
|
26
27
|
const DEFAULTS_POSTS_PER_PAGE = 3;
|
|
27
28
|
|
|
@@ -42,7 +43,8 @@ export default function QueryContent( {
|
|
|
42
43
|
tagName: TagName = 'div',
|
|
43
44
|
query: { inherit } = {},
|
|
44
45
|
} = attributes;
|
|
45
|
-
const {
|
|
46
|
+
const { templateSlug } = context;
|
|
47
|
+
const { isSingular } = getQueryContextFromTemplate( templateSlug );
|
|
46
48
|
const { __unstableMarkNextChangeAsNotPersistent } =
|
|
47
49
|
useDispatch( blockEditorStore );
|
|
48
50
|
const instanceId = useInstanceId( QueryContent );
|
|
@@ -50,16 +52,6 @@ export default function QueryContent( {
|
|
|
50
52
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
51
53
|
template: TEMPLATE,
|
|
52
54
|
} );
|
|
53
|
-
const isTemplate = useSelect(
|
|
54
|
-
( select ) => {
|
|
55
|
-
const currentTemplate =
|
|
56
|
-
select( coreStore ).__experimentalGetTemplateForLink()?.type;
|
|
57
|
-
const isInTemplate = 'wp_template' === currentTemplate;
|
|
58
|
-
const isInSingularContent = postType !== undefined;
|
|
59
|
-
return isInTemplate && ! isInSingularContent;
|
|
60
|
-
},
|
|
61
|
-
[ postType ]
|
|
62
|
-
);
|
|
63
55
|
const { postsPerPage } = useSelect( ( select ) => {
|
|
64
56
|
const { getSettings } = select( blockEditorStore );
|
|
65
57
|
const { getEntityRecord, getEntityRecordEdits, canUser } =
|
|
@@ -106,9 +98,9 @@ export default function QueryContent( {
|
|
|
106
98
|
} else if ( ! query.perPage && postsPerPage ) {
|
|
107
99
|
newQuery.perPage = postsPerPage;
|
|
108
100
|
}
|
|
109
|
-
// We need to reset the `inherit` value if
|
|
110
|
-
// are not inherited when
|
|
111
|
-
if (
|
|
101
|
+
// We need to reset the `inherit` value if in a singular template, as queries
|
|
102
|
+
// are not inherited when in singular content (e.g. post, page, 404, blank).
|
|
103
|
+
if ( isSingular && query.inherit ) {
|
|
112
104
|
newQuery.inherit = false;
|
|
113
105
|
}
|
|
114
106
|
if ( !! Object.keys( newQuery ).length ) {
|
|
@@ -117,10 +109,10 @@ export default function QueryContent( {
|
|
|
117
109
|
}
|
|
118
110
|
}, [
|
|
119
111
|
query.perPage,
|
|
112
|
+
query.inherit,
|
|
120
113
|
postsPerPage,
|
|
121
114
|
inherit,
|
|
122
|
-
|
|
123
|
-
query.inherit,
|
|
115
|
+
isSingular,
|
|
124
116
|
__unstableMarkNextChangeAsNotPersistent,
|
|
125
117
|
updateQuery,
|
|
126
118
|
] );
|
|
@@ -167,7 +159,7 @@ export default function QueryContent( {
|
|
|
167
159
|
setDisplayLayout={ updateDisplayLayout }
|
|
168
160
|
setAttributes={ setAttributes }
|
|
169
161
|
clientId={ clientId }
|
|
170
|
-
|
|
162
|
+
isSingular={ isSingular }
|
|
171
163
|
/>
|
|
172
164
|
</InspectorControls>
|
|
173
165
|
<BlockControls>
|
package/src/query/test/utils.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { terms } from './fixtures';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getEntitiesInfo,
|
|
7
|
+
getValueFromObjectPath,
|
|
8
|
+
getQueryContextFromTemplate,
|
|
9
|
+
} from '../utils';
|
|
6
10
|
|
|
7
11
|
describe( 'Query block utils', () => {
|
|
8
12
|
describe( 'getEntitiesInfo', () => {
|
|
@@ -61,4 +65,58 @@ describe( 'Query block utils', () => {
|
|
|
61
65
|
expect( result ).toBe( 'test' );
|
|
62
66
|
} );
|
|
63
67
|
} );
|
|
68
|
+
|
|
69
|
+
describe( 'getQueryContextFromTemplate', () => {
|
|
70
|
+
it( 'should return the correct query context based on template slug', () => {
|
|
71
|
+
expect( getQueryContextFromTemplate() ).toStrictEqual( {
|
|
72
|
+
isSingular: true,
|
|
73
|
+
} );
|
|
74
|
+
expect( getQueryContextFromTemplate( '404' ) ).toStrictEqual( {
|
|
75
|
+
isSingular: true,
|
|
76
|
+
templateType: '404',
|
|
77
|
+
} );
|
|
78
|
+
expect( getQueryContextFromTemplate( 'blank' ) ).toStrictEqual( {
|
|
79
|
+
isSingular: true,
|
|
80
|
+
templateType: 'blank',
|
|
81
|
+
} );
|
|
82
|
+
expect( getQueryContextFromTemplate( 'single' ) ).toStrictEqual( {
|
|
83
|
+
isSingular: true,
|
|
84
|
+
templateType: 'single',
|
|
85
|
+
} );
|
|
86
|
+
expect(
|
|
87
|
+
getQueryContextFromTemplate( 'single-film' )
|
|
88
|
+
).toStrictEqual( {
|
|
89
|
+
isSingular: true,
|
|
90
|
+
templateType: 'single',
|
|
91
|
+
} );
|
|
92
|
+
expect( getQueryContextFromTemplate( 'page' ) ).toStrictEqual( {
|
|
93
|
+
isSingular: true,
|
|
94
|
+
templateType: 'page',
|
|
95
|
+
} );
|
|
96
|
+
expect( getQueryContextFromTemplate( 'wp' ) ).toStrictEqual( {
|
|
97
|
+
isSingular: true,
|
|
98
|
+
templateType: 'custom',
|
|
99
|
+
} );
|
|
100
|
+
expect( getQueryContextFromTemplate( 'category' ) ).toStrictEqual( {
|
|
101
|
+
isSingular: false,
|
|
102
|
+
templateType: 'category',
|
|
103
|
+
} );
|
|
104
|
+
expect(
|
|
105
|
+
getQueryContextFromTemplate( 'category-dog' )
|
|
106
|
+
).toStrictEqual( {
|
|
107
|
+
isSingular: false,
|
|
108
|
+
templateType: 'category',
|
|
109
|
+
} );
|
|
110
|
+
expect( getQueryContextFromTemplate( 'archive' ) ).toStrictEqual( {
|
|
111
|
+
isSingular: false,
|
|
112
|
+
templateType: 'archive',
|
|
113
|
+
} );
|
|
114
|
+
expect(
|
|
115
|
+
getQueryContextFromTemplate( 'archive-film' )
|
|
116
|
+
).toStrictEqual( {
|
|
117
|
+
isSingular: false,
|
|
118
|
+
templateType: 'archive',
|
|
119
|
+
} );
|
|
120
|
+
} );
|
|
121
|
+
} );
|
|
64
122
|
} );
|
package/src/query/utils.js
CHANGED
|
@@ -435,3 +435,32 @@ export const useUnsupportedBlocks = ( clientId ) => {
|
|
|
435
435
|
[ clientId ]
|
|
436
436
|
);
|
|
437
437
|
};
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Helper function that returns the query context from the editor based on the
|
|
441
|
+
* available template slug.
|
|
442
|
+
*
|
|
443
|
+
* @param {string} templateSlug Current template slug based on context.
|
|
444
|
+
* @return {Object} An object with isSingular and templateType properties.
|
|
445
|
+
*/
|
|
446
|
+
export function getQueryContextFromTemplate( templateSlug ) {
|
|
447
|
+
// In the Post Editor, the template slug is not available.
|
|
448
|
+
if ( ! templateSlug ) {
|
|
449
|
+
return { isSingular: true };
|
|
450
|
+
}
|
|
451
|
+
let isSingular = false;
|
|
452
|
+
let templateType = templateSlug === 'wp' ? 'custom' : templateSlug;
|
|
453
|
+
const singularTemplates = [ '404', 'blank', 'single', 'page', 'custom' ];
|
|
454
|
+
const templateTypeFromSlug = templateSlug.includes( '-' )
|
|
455
|
+
? templateSlug.split( '-', 1 )[ 0 ]
|
|
456
|
+
: templateSlug;
|
|
457
|
+
const queryFromTemplateSlug = templateSlug.includes( '-' )
|
|
458
|
+
? templateSlug.split( '-' ).slice( 1 ).join( '-' )
|
|
459
|
+
: '';
|
|
460
|
+
if ( queryFromTemplateSlug ) {
|
|
461
|
+
templateType = templateTypeFromSlug;
|
|
462
|
+
}
|
|
463
|
+
isSingular = singularTemplates.includes( templateType );
|
|
464
|
+
|
|
465
|
+
return { isSingular, templateType };
|
|
466
|
+
}
|
package/src/query-title/edit.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
HeadingLevelDropdown,
|
|
16
16
|
} from '@wordpress/block-editor';
|
|
17
17
|
import { ToggleControl, PanelBody } from '@wordpress/components';
|
|
18
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
18
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Internal dependencies
|
|
@@ -60,7 +60,7 @@ export default function QueryTitleEdit( {
|
|
|
60
60
|
if ( archiveNameLabel ) {
|
|
61
61
|
title = sprintf(
|
|
62
62
|
/* translators: 1: Archive type title e.g: "Category", 2: Label of the archive e.g: "Shoes" */
|
|
63
|
-
|
|
63
|
+
_x( '%1$s: %2$s', 'archive label' ),
|
|
64
64
|
archiveTypeLabel,
|
|
65
65
|
archiveNameLabel
|
|
66
66
|
);
|
package/src/rss/index.php
CHANGED
|
@@ -62,7 +62,7 @@ function render_block_core_rss( $attributes ) {
|
|
|
62
62
|
if ( is_object( $author ) ) {
|
|
63
63
|
$author = $author->get_name();
|
|
64
64
|
$author = '<span class="wp-block-rss__item-author">' . sprintf(
|
|
65
|
-
/* translators: %s:
|
|
65
|
+
/* translators: byline. %s: author. */
|
|
66
66
|
__( 'by %s' ),
|
|
67
67
|
esc_html( strip_tags( $author ) )
|
|
68
68
|
) . '</span>';
|
package/src/search/edit.js
CHANGED
|
@@ -23,14 +23,14 @@ import { useEffect, useRef } from '@wordpress/element';
|
|
|
23
23
|
import {
|
|
24
24
|
ToolbarDropdownMenu,
|
|
25
25
|
ToolbarGroup,
|
|
26
|
-
Button,
|
|
27
|
-
ButtonGroup,
|
|
28
26
|
ToolbarButton,
|
|
29
27
|
ResizableBox,
|
|
30
28
|
PanelBody,
|
|
31
29
|
__experimentalVStack as VStack,
|
|
32
30
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
33
31
|
__experimentalUnitControl as UnitControl,
|
|
32
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
33
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
34
34
|
} from '@wordpress/components';
|
|
35
35
|
import { useInstanceId } from '@wordpress/compose';
|
|
36
36
|
import { Icon, search } from '@wordpress/icons';
|
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
// Used to calculate border radius adjustment to avoid "fat" corners when
|
|
59
59
|
// button is placed inside wrapper.
|
|
60
60
|
const DEFAULT_INNER_PADDING = '4px';
|
|
61
|
+
const PERCENTAGE_WIDTHS = [ 25, 50, 75, 100 ];
|
|
61
62
|
|
|
62
63
|
export default function SearchEdit( {
|
|
63
64
|
className,
|
|
@@ -375,7 +376,7 @@ export default function SearchEdit( {
|
|
|
375
376
|
<BlockControls>
|
|
376
377
|
<ToolbarGroup>
|
|
377
378
|
<ToolbarButton
|
|
378
|
-
title={ __( '
|
|
379
|
+
title={ __( 'Show search label' ) }
|
|
379
380
|
icon={ toggleLabel }
|
|
380
381
|
onClick={ () => {
|
|
381
382
|
setAttributes( {
|
|
@@ -445,33 +446,35 @@ export default function SearchEdit( {
|
|
|
445
446
|
value={ `${ width }${ widthUnit }` }
|
|
446
447
|
units={ units }
|
|
447
448
|
/>
|
|
448
|
-
<
|
|
449
|
-
|
|
450
|
-
|
|
449
|
+
<ToggleGroupControl
|
|
450
|
+
label={ __( 'Percentage Width' ) }
|
|
451
|
+
value={
|
|
452
|
+
PERCENTAGE_WIDTHS.includes( width ) &&
|
|
453
|
+
widthUnit === '%'
|
|
454
|
+
? width
|
|
455
|
+
: undefined
|
|
456
|
+
}
|
|
457
|
+
hideLabelFromVision
|
|
458
|
+
onChange={ ( newWidth ) => {
|
|
459
|
+
setAttributes( {
|
|
460
|
+
width: newWidth,
|
|
461
|
+
widthUnit: '%',
|
|
462
|
+
} );
|
|
463
|
+
} }
|
|
464
|
+
isBlock
|
|
465
|
+
__next40pxDefaultSize
|
|
466
|
+
__nextHasNoMarginBottom
|
|
451
467
|
>
|
|
452
|
-
{
|
|
468
|
+
{ PERCENTAGE_WIDTHS.map( ( widthValue ) => {
|
|
453
469
|
return (
|
|
454
|
-
<
|
|
470
|
+
<ToggleGroupControlOption
|
|
455
471
|
key={ widthValue }
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
widthUnit === '%'
|
|
460
|
-
? 'primary'
|
|
461
|
-
: undefined
|
|
462
|
-
}
|
|
463
|
-
onClick={ () =>
|
|
464
|
-
setAttributes( {
|
|
465
|
-
width: widthValue,
|
|
466
|
-
widthUnit: '%',
|
|
467
|
-
} )
|
|
468
|
-
}
|
|
469
|
-
>
|
|
470
|
-
{ widthValue }%
|
|
471
|
-
</Button>
|
|
472
|
+
value={ widthValue }
|
|
473
|
+
label={ `${ widthValue }%` }
|
|
474
|
+
/>
|
|
472
475
|
);
|
|
473
476
|
} ) }
|
|
474
|
-
</
|
|
477
|
+
</ToggleGroupControl>
|
|
475
478
|
</VStack>
|
|
476
479
|
</PanelBody>
|
|
477
480
|
</InspectorControls>
|
package/src/search/index.php
CHANGED
|
@@ -31,8 +31,8 @@ function render_block_core_search( $attributes ) {
|
|
|
31
31
|
|
|
32
32
|
$input_id = wp_unique_id( 'wp-block-search__input-' );
|
|
33
33
|
$classnames = classnames_for_block_core_search( $attributes );
|
|
34
|
-
$show_label =
|
|
35
|
-
$use_icon_button =
|
|
34
|
+
$show_label = ! empty( $attributes['showLabel'] );
|
|
35
|
+
$use_icon_button = ! empty( $attributes['buttonUseIcon'] );
|
|
36
36
|
$show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
|
|
37
37
|
$button_position = $show_button ? $attributes['buttonPosition'] : null;
|
|
38
38
|
$query_params = ( ! empty( $attributes['query'] ) ) ? $attributes['query'] : array();
|
|
@@ -17,3 +17,9 @@ exports[`Separator block transforms to Group block 1`] = `
|
|
|
17
17
|
<!-- /wp:separator --></div>
|
|
18
18
|
<!-- /wp:group -->"
|
|
19
19
|
`;
|
|
20
|
+
|
|
21
|
+
exports[`Separator block transforms to Spacer block 1`] = `
|
|
22
|
+
"<!-- wp:spacer -->
|
|
23
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
24
|
+
<!-- /wp:spacer -->"
|
|
25
|
+
`;
|
|
@@ -16,7 +16,7 @@ const initialHtml = `
|
|
|
16
16
|
<!-- /wp:separator -->`;
|
|
17
17
|
|
|
18
18
|
const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
|
|
19
|
-
const blockTransforms = [ ...transformsWithInnerBlocks ];
|
|
19
|
+
const blockTransforms = [ 'Spacer', ...transformsWithInnerBlocks ];
|
|
20
20
|
|
|
21
21
|
setupCoreBlocks();
|
|
22
22
|
|
|
@@ -18,6 +18,17 @@ const transforms = {
|
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
],
|
|
21
|
+
to: [
|
|
22
|
+
{
|
|
23
|
+
type: 'block',
|
|
24
|
+
blocks: [ 'core/spacer' ], // Transform to Spacer.
|
|
25
|
+
transform: ( { anchor } ) => {
|
|
26
|
+
return createBlock( 'core/spacer', {
|
|
27
|
+
anchor: anchor || '',
|
|
28
|
+
} );
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
21
32
|
};
|
|
22
33
|
|
|
23
34
|
export default transforms;
|
package/src/social-links/edit.js
CHANGED
package/src/spacer/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import initBlock from '../utils/init-block';
|
|
|
10
10
|
import deprecated from './deprecated';
|
|
11
11
|
import edit from './edit';
|
|
12
12
|
import metadata from './block.json';
|
|
13
|
+
import transforms from './transforms';
|
|
13
14
|
import save from './save';
|
|
14
15
|
|
|
15
16
|
const { name } = metadata;
|
|
@@ -18,6 +19,7 @@ export { metadata, name };
|
|
|
18
19
|
|
|
19
20
|
export const settings = {
|
|
20
21
|
icon,
|
|
22
|
+
transforms,
|
|
21
23
|
edit,
|
|
22
24
|
save,
|
|
23
25
|
deprecated,
|
|
@@ -17,3 +17,9 @@ exports[`Spacer block transforms to Group block 1`] = `
|
|
|
17
17
|
<!-- /wp:spacer --></div>
|
|
18
18
|
<!-- /wp:group -->"
|
|
19
19
|
`;
|
|
20
|
+
|
|
21
|
+
exports[`Spacer block transforms to Separator block 1`] = `
|
|
22
|
+
"<!-- wp:separator -->
|
|
23
|
+
<hr class="wp-block-separator has-alpha-channel-opacity"/>
|
|
24
|
+
<!-- /wp:separator -->"
|
|
25
|
+
`;
|
|
@@ -16,7 +16,7 @@ const initialHtml = `
|
|
|
16
16
|
<!-- /wp:spacer -->`;
|
|
17
17
|
|
|
18
18
|
const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
|
|
19
|
-
const blockTransforms = [ ...transformsWithInnerBlocks ];
|
|
19
|
+
const blockTransforms = [ 'Separator', ...transformsWithInnerBlocks ];
|
|
20
20
|
|
|
21
21
|
setupCoreBlocks();
|
|
22
22
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createBlock } from '@wordpress/blocks';
|
|
5
|
+
|
|
6
|
+
const transforms = {
|
|
7
|
+
to: [
|
|
8
|
+
{
|
|
9
|
+
type: 'block',
|
|
10
|
+
blocks: [ 'core/separator' ], // Transform to Separator.
|
|
11
|
+
transform: ( { anchor } ) => {
|
|
12
|
+
return createBlock( 'core/separator', {
|
|
13
|
+
anchor: anchor || '',
|
|
14
|
+
} );
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default transforms;
|
package/src/table/edit.js
CHANGED
|
@@ -58,15 +58,11 @@ export default function TableOfContentsEdit( {
|
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
// If a user clicks to a link prevent redirection and show a warning.
|
|
61
|
-
const { createWarningNotice
|
|
62
|
-
let noticeId;
|
|
61
|
+
const { createWarningNotice } = useDispatch( noticeStore );
|
|
63
62
|
const showRedirectionPreventedNotice = ( event ) => {
|
|
64
63
|
event.preventDefault();
|
|
65
|
-
// Remove previous warning if any, to show one at a time per block.
|
|
66
|
-
removeNotice( noticeId );
|
|
67
|
-
noticeId = `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`;
|
|
68
64
|
createWarningNotice( __( 'Links are disabled in the editor.' ), {
|
|
69
|
-
id:
|
|
65
|
+
id: `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`,
|
|
70
66
|
type: 'snackbar',
|
|
71
67
|
} );
|
|
72
68
|
};
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
MenuItem,
|
|
22
22
|
ToolbarButton,
|
|
23
23
|
} from '@wordpress/components';
|
|
24
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
25
24
|
import { __, sprintf } from '@wordpress/i18n';
|
|
26
25
|
import { store as coreStore } from '@wordpress/core-data';
|
|
27
26
|
import { useState } from '@wordpress/element';
|
|
@@ -85,7 +84,6 @@ function TemplatesList( { area, clientId, isEntityAvailable, onSelect } ) {
|
|
|
85
84
|
isEntityAvailable &&
|
|
86
85
|
!! blockPatterns.length &&
|
|
87
86
|
( area === 'header' || area === 'footer' );
|
|
88
|
-
const shownTemplates = useAsyncList( blockPatterns );
|
|
89
87
|
|
|
90
88
|
if ( ! canReplace ) {
|
|
91
89
|
return null;
|
|
@@ -96,9 +94,8 @@ function TemplatesList( { area, clientId, isEntityAvailable, onSelect } ) {
|
|
|
96
94
|
<BlockPatternsList
|
|
97
95
|
label={ __( 'Templates' ) }
|
|
98
96
|
blockPatterns={ blockPatterns }
|
|
99
|
-
shownPatterns={ shownTemplates }
|
|
100
97
|
onClickPattern={ onSelect }
|
|
101
|
-
|
|
98
|
+
showTitlesAsTooltip
|
|
102
99
|
/>
|
|
103
100
|
</PanelBody>
|
|
104
101
|
);
|
|
@@ -214,7 +211,7 @@ export default function TemplatePartEdit( {
|
|
|
214
211
|
<TagName { ...blockProps }>
|
|
215
212
|
<Warning>
|
|
216
213
|
{ sprintf(
|
|
217
|
-
/* translators: %s: Template part slug */
|
|
214
|
+
/* translators: %s: Template part slug. */
|
|
218
215
|
__(
|
|
219
216
|
'Template part has been deleted or is unavailable: %s'
|
|
220
217
|
),
|
|
@@ -5,7 +5,6 @@ import { useMemo, useState } from '@wordpress/element';
|
|
|
5
5
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { store as noticesStore } from '@wordpress/notices';
|
|
7
7
|
import { useDispatch } from '@wordpress/data';
|
|
8
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
9
8
|
import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
10
9
|
import {
|
|
11
10
|
SearchControl,
|
|
@@ -43,7 +42,6 @@ export default function TemplatePartSelectionModal( {
|
|
|
43
42
|
|
|
44
43
|
return searchPatterns( partsAsPatterns, searchValue );
|
|
45
44
|
}, [ templateParts, searchValue ] );
|
|
46
|
-
const shownTemplateParts = useAsyncList( filteredTemplateParts );
|
|
47
45
|
const blockPatterns = useAlternativeBlockPatterns( area, clientId );
|
|
48
46
|
const filteredBlockPatterns = useMemo( () => {
|
|
49
47
|
return searchPatterns( blockPatterns, searchValue );
|
|
@@ -89,7 +87,6 @@ export default function TemplatePartSelectionModal( {
|
|
|
89
87
|
<h2>{ __( 'Existing template parts' ) }</h2>
|
|
90
88
|
<BlockPatternsList
|
|
91
89
|
blockPatterns={ filteredTemplateParts }
|
|
92
|
-
shownPatterns={ shownTemplateParts }
|
|
93
90
|
onClickPattern={ ( pattern ) => {
|
|
94
91
|
onTemplatePartSelect( pattern.templatePart );
|
|
95
92
|
} }
|
package/src/video/edit.js
CHANGED
|
@@ -141,7 +141,7 @@ function VideoEdit( {
|
|
|
141
141
|
icon={ icon }
|
|
142
142
|
label={ __( 'Video' ) }
|
|
143
143
|
instructions={ __(
|
|
144
|
-
'
|
|
144
|
+
'Drag and drop a video, upload, or choose from your library.'
|
|
145
145
|
) }
|
|
146
146
|
>
|
|
147
147
|
{ content }
|
|
@@ -12,7 +12,7 @@ exports[`Video block transforms to Columns block 1`] = `
|
|
|
12
12
|
|
|
13
13
|
exports[`Video block transforms to Cover block 1`] = `
|
|
14
14
|
"<!-- wp:cover {"url":"https://i.cloudup.com/YtZFJbuQCE.mov","dimRatio":50,"backgroundType":"video"} -->
|
|
15
|
-
<div class="wp-block-cover"><
|
|
15
|
+
<div class="wp-block-cover"><video class="wp-block-cover__video-background intrinsic-ignore" autoplay muted loop playsinline src="https://i.cloudup.com/YtZFJbuQCE.mov" data-object-fit="cover"></video><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","fontSize":"large"} -->
|
|
16
16
|
<p class="has-text-align-center has-large-font-size">Cloudup video</p>
|
|
17
17
|
<!-- /wp:paragraph --></div></div>
|
|
18
18
|
<!-- /wp:cover -->"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
4
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import {
|
|
6
6
|
NavigableMenu,
|
|
7
7
|
MenuItem,
|
|
@@ -63,7 +63,7 @@ function TrackList( { tracks, onEditPress } ) {
|
|
|
63
63
|
onClick={ () => onEditPress( index ) }
|
|
64
64
|
aria-label={ sprintf(
|
|
65
65
|
/* translators: %s: Label of the video text track e.g: "French subtitles" */
|
|
66
|
-
|
|
66
|
+
_x( 'Edit %s', 'text tracks' ),
|
|
67
67
|
track.label
|
|
68
68
|
) }
|
|
69
69
|
>
|
|
@@ -204,8 +204,6 @@ export default function TracksEditor( { tracks = [], onChange } ) {
|
|
|
204
204
|
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
205
205
|
<ToolbarGroup>
|
|
206
206
|
<ToolbarButton
|
|
207
|
-
label={ __( 'Text tracks' ) }
|
|
208
|
-
showTooltip
|
|
209
207
|
aria-expanded={ isOpen }
|
|
210
208
|
aria-haspopup="true"
|
|
211
209
|
onClick={ onToggle }
|