@wordpress/block-library 8.29.0 → 8.30.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 +2 -0
- package/build/audio/edit.js +7 -17
- package/build/audio/edit.js.map +1 -1
- package/build/audio/edit.native.js.map +1 -1
- package/build/avatar/edit.js.map +1 -1
- package/build/block/deprecated.js +71 -11
- package/build/block/deprecated.js.map +1 -1
- package/build/block/edit.js +49 -24
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +2 -2
- package/build/button/edit.js.map +1 -1
- package/build/buttons/edit.native.js.map +1 -1
- package/build/buttons/transforms.js +16 -2
- package/build/buttons/transforms.js.map +1 -1
- package/build/code/transforms.js +17 -6
- package/build/code/transforms.js.map +1 -1
- package/build/columns/edit.js +3 -2
- package/build/columns/edit.js.map +1 -1
- package/build/comment-author-avatar/edit.js +1 -1
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/cover/edit/block-controls.js +14 -3
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit/resizable-cover-popover.js +0 -6
- package/build/cover/edit/resizable-cover-popover.js.map +1 -1
- package/build/cover/edit.native.js.map +1 -1
- package/build/file/deprecated.js.map +1 -1
- package/build/file/edit.js +6 -13
- package/build/file/edit.js.map +1 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/save.js.map +1 -1
- package/build/form-input/edit.js +1 -1
- package/build/form-input/edit.js.map +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.native.js.map +1 -1
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery.native.js.map +1 -1
- package/build/heading/transforms.js +17 -4
- package/build/heading/transforms.js.map +1 -1
- package/build/image/edit.js +8 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +22 -8
- package/build/image/image.js.map +1 -1
- package/build/latest-posts/edit.native.js.map +1 -1
- package/build/list/ordered-list-settings.js +1 -1
- package/build/list/ordered-list-settings.js.map +1 -1
- package/build/list-item/edit.js +1 -3
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js.map +1 -1
- package/build/list-item/hooks/index.js +0 -7
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/hooks/use-indent-list-item.js +1 -0
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +1 -0
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +16 -7
- package/build/list-item/hooks/use-space.js.map +1 -1
- package/build/list-item/index.js +4 -1
- package/build/list-item/index.js.map +1 -1
- package/build/media-text/media-container.native.js +1 -1
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/paragraph/edit.native.js.map +1 -1
- package/build/pattern/edit.js +11 -0
- package/build/pattern/edit.js.map +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -11
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-title/edit.js +2 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/query/edit/pattern-selection-modal.js.map +1 -1
- package/build/query/utils.js +7 -5
- package/build/query/utils.js.map +1 -1
- package/build/query-pagination-next/edit.js.map +1 -1
- package/build/query-pagination-previous/edit.js.map +1 -1
- package/build/quote/deprecated.js +111 -12
- package/build/quote/deprecated.js.map +1 -1
- package/build/quote/edit.js +5 -5
- package/build/quote/edit.js.map +1 -1
- package/build/quote/index.js +1 -1
- package/build/quote/index.js.map +1 -1
- package/build/quote/save.js +2 -2
- package/build/quote/save.js.map +1 -1
- package/build/read-more/edit.js.map +1 -1
- package/build/search/edit.js +1 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/edit.native.js.map +1 -1
- package/build/site-logo/edit.js +7 -2
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-title/{edit/index.js → edit.js} +1 -1
- package/build/site-title/edit.js.map +1 -0
- package/build/social-link/edit.js.map +1 -1
- package/build/social-links/edit.native.js.map +1 -1
- package/build/spacer/edit.js.map +1 -1
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/template-part/edit/index.js +53 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +2 -8
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/template-part/edit/utils/map-template-part-to-block-pattern.js +30 -0
- package/build/template-part/edit/utils/map-template-part-to-block-pattern.js.map +1 -0
- package/build/utils/caption.js +15 -5
- package/build/utils/caption.js.map +1 -1
- package/build/utils/get-transformed-metadata.js +57 -0
- package/build/utils/get-transformed-metadata.js.map +1 -0
- package/build/utils/hooks.js +55 -4
- package/build/utils/hooks.js.map +1 -1
- package/build/video/edit-common-settings.js.map +1 -1
- package/build/video/edit.js +7 -16
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +2 -7
- package/build/video/edit.native.js.map +1 -1
- package/build-module/audio/edit.js +10 -20
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/deprecated.js +71 -11
- package/build-module/block/deprecated.js.map +1 -1
- package/build-module/block/edit.js +49 -24
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +3 -3
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/edit.native.js.map +1 -1
- package/build-module/buttons/transforms.js +16 -2
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/code/transforms.js +17 -6
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/columns/edit.js +3 -2
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +1 -1
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +15 -4
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit/resizable-cover-popover.js +1 -7
- package/build-module/cover/edit/resizable-cover-popover.js.map +1 -1
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/file/deprecated.js.map +1 -1
- package/build-module/file/edit.js +7 -14
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/save.js.map +1 -1
- package/build-module/form-input/edit.js +1 -1
- package/build-module/form-input/edit.js.map +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.native.js.map +1 -1
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery.native.js.map +1 -1
- package/build-module/heading/transforms.js +17 -4
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/edit.js +9 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +23 -9
- package/build-module/image/image.js.map +1 -1
- package/build-module/latest-posts/edit.native.js.map +1 -1
- package/build-module/list/ordered-list-settings.js +1 -1
- package/build-module/list/ordered-list-settings.js.map +1 -1
- package/build-module/list-item/edit.js +2 -4
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js.map +1 -1
- package/build-module/list-item/hooks/index.js +0 -1
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/hooks/use-indent-list-item.js +1 -0
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +1 -0
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +17 -8
- package/build-module/list-item/hooks/use-space.js.map +1 -1
- package/build-module/list-item/index.js +4 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/media-text/media-container.native.js +1 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/paragraph/edit.native.js.map +1 -1
- package/build-module/pattern/edit.js +11 -0
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +9 -12
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-title/edit.js +2 -2
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
- package/build-module/query/utils.js +7 -5
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-pagination-next/edit.js.map +1 -1
- package/build-module/query-pagination-previous/edit.js.map +1 -1
- package/build-module/quote/deprecated.js +112 -13
- package/build-module/quote/deprecated.js.map +1 -1
- package/build-module/quote/edit.js +5 -5
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/quote/index.js +1 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/save.js +2 -2
- package/build-module/quote/save.js.map +1 -1
- package/build-module/read-more/edit.js.map +1 -1
- package/build-module/search/edit.js +1 -1
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/edit.native.js.map +1 -1
- package/build-module/site-logo/edit.js +7 -2
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-title/{edit/index.js → edit.js} +1 -1
- package/build-module/site-title/edit.js.map +1 -0
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-links/edit.native.js.map +1 -1
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +57 -5
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +2 -8
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/template-part/edit/utils/map-template-part-to-block-pattern.js +24 -0
- package/build-module/template-part/edit/utils/map-template-part-to-block-pattern.js.map +1 -0
- package/build-module/utils/caption.js +13 -3
- package/build-module/utils/caption.js.map +1 -1
- package/build-module/utils/get-transformed-metadata.js +51 -0
- package/build-module/utils/get-transformed-metadata.js.map +1 -0
- package/build-module/utils/hooks.js +54 -3
- package/build-module/utils/hooks.js.map +1 -1
- package/build-module/video/edit-common-settings.js.map +1 -1
- package/build-module/video/edit.js +10 -19
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +2 -7
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/common-rtl.css +1 -0
- package/build-style/common.css +1 -0
- package/build-style/cover/style-rtl.css +2 -1
- package/build-style/cover/style.css +2 -1
- package/build-style/editor-rtl.css +4 -1
- package/build-style/editor.css +4 -1
- package/build-style/group/editor-rtl.css +1 -1
- package/build-style/group/editor.css +1 -1
- package/build-style/image/editor-rtl.css +3 -0
- package/build-style/image/editor.css +3 -0
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/style-rtl.css +4 -1
- package/build-style/style.css +4 -1
- package/package.json +34 -34
- package/src/audio/edit.js +9 -19
- package/src/audio/edit.native.js +3 -3
- package/src/avatar/edit.js +1 -1
- package/src/block/deprecated.js +76 -11
- package/src/block/edit.js +64 -19
- package/src/block/index.php +23 -12
- package/src/button/edit.js +4 -3
- package/src/buttons/edit.native.js +1 -1
- package/src/buttons/transforms.js +14 -4
- package/src/calendar/index.php +5 -0
- package/src/code/transforms.js +20 -5
- package/src/columns/edit.js +3 -2
- package/src/comment-author-avatar/edit.js +1 -1
- package/src/comments/index.php +2 -0
- package/src/cover/edit/block-controls.js +16 -2
- package/src/cover/edit/index.js +2 -2
- package/src/cover/edit/inspector-controls.js +1 -1
- package/src/cover/edit/resizable-cover-popover.js +1 -6
- package/src/cover/edit.native.js +1 -1
- package/src/cover/style.scss +3 -2
- package/src/file/deprecated.js +3 -3
- package/src/file/edit.js +8 -15
- package/src/file/edit.native.js +4 -4
- package/src/file/save.js +1 -1
- package/src/footnotes/index.php +1 -1
- package/src/form-input/edit.js +1 -1
- package/src/gallery/edit.js +3 -3
- package/src/gallery/gallery.native.js +1 -1
- package/src/gallery/test/index.native.js +1 -1
- package/src/gallery/v1/edit.js +2 -2
- package/src/gallery/v1/gallery.native.js +1 -1
- package/src/group/editor.scss +1 -1
- package/src/heading/transforms.js +27 -8
- package/src/image/edit.js +13 -5
- package/src/image/edit.native.js +1 -1
- package/src/image/editor.scss +6 -0
- package/src/image/image.js +34 -22
- package/src/latest-posts/edit.native.js +1 -1
- package/src/list/ordered-list-settings.js +1 -1
- package/src/list-item/edit.js +1 -2
- package/src/list-item/edit.native.js +1 -1
- package/src/list-item/hooks/index.js +0 -1
- package/src/list-item/hooks/use-indent-list-item.js +2 -0
- package/src/list-item/hooks/use-outdent-list-item.js +2 -0
- package/src/list-item/hooks/use-space.js +16 -9
- package/src/list-item/index.js +3 -0
- package/src/media-text/media-container.native.js +5 -3
- package/src/media-text/test/edit.native.js +58 -0
- package/src/missing/test/edit-integration.native.js +2 -1
- package/src/navigation/edit/index.js +1 -1
- package/src/navigation/edit/test/navigation-menu-selector.js +3 -3
- package/src/navigation/index.php +26 -17
- package/src/navigation-link/link-ui.js +2 -2
- package/src/paragraph/edit.native.js +1 -1
- package/src/paragraph/test/edit.native.js +36 -0
- package/src/pattern/edit.js +14 -0
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-featured-image/dimension-controls.js +4 -4
- package/src/post-featured-image/edit.js +10 -12
- package/src/post-navigation-link/edit.js +1 -1
- package/src/post-template/index.php +2 -0
- package/src/post-title/edit.js +49 -43
- package/src/query/edit/pattern-selection-modal.js +1 -1
- package/src/query/utils.js +6 -4
- package/src/query-pagination-next/edit.js +1 -1
- package/src/query-pagination-previous/edit.js +1 -1
- package/src/quote/block.json +1 -1
- package/src/quote/deprecated.js +110 -15
- package/src/quote/edit.js +5 -5
- package/src/quote/save.js +2 -2
- package/src/quote/test/__snapshots__/transforms.native.js.snap +2 -2
- package/src/read-more/edit.js +1 -1
- package/src/search/edit.js +1 -1
- package/src/search/edit.native.js +4 -4
- package/src/search/index.php +1 -1
- package/src/search/style.scss +2 -0
- package/src/site-logo/edit.js +11 -6
- package/src/social-link/edit.js +1 -1
- package/src/social-links/edit.native.js +1 -1
- package/src/spacer/edit.js +1 -1
- package/src/table-of-contents/edit.js +1 -1
- package/src/template-part/edit/index.js +91 -4
- package/src/template-part/edit/selection-modal.js +4 -8
- package/src/template-part/edit/utils/map-template-part-to-block-pattern.js +23 -0
- package/src/utils/caption.js +10 -1
- package/src/utils/get-transformed-metadata.js +65 -0
- package/src/utils/hooks.js +53 -3
- package/src/video/edit-common-settings.js +1 -1
- package/src/video/edit.js +10 -18
- package/src/video/edit.native.js +5 -8
- package/src/video/test/edit.native.js +0 -14
- package/build/list-item/hooks/use-copy.js +0 -39
- package/build/list-item/hooks/use-copy.js.map +0 -1
- package/build/site-title/edit/index.js.map +0 -1
- package/build-module/list-item/hooks/use-copy.js +0 -32
- package/build-module/list-item/hooks/use-copy.js.map +0 -1
- package/build-module/site-title/edit/index.js.map +0 -1
- package/src/list-item/hooks/use-copy.js +0 -38
- /package/src/site-title/{edit/index.js → edit.js} +0 -0
package/src/block/edit.js
CHANGED
|
@@ -42,6 +42,25 @@ const { PARTIAL_SYNCING_SUPPORTED_BLOCKS } = unlock( patternsPrivateApis );
|
|
|
42
42
|
|
|
43
43
|
const fullAlignments = [ 'full', 'wide', 'left', 'right' ];
|
|
44
44
|
|
|
45
|
+
function getLegacyIdMap( blocks, content, nameCount = {} ) {
|
|
46
|
+
let idToClientIdMap = {};
|
|
47
|
+
for ( const block of blocks ) {
|
|
48
|
+
if ( block?.innerBlocks?.length ) {
|
|
49
|
+
idToClientIdMap = {
|
|
50
|
+
...idToClientIdMap,
|
|
51
|
+
...getLegacyIdMap( block.innerBlocks, content, nameCount ),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const id = block.attributes.metadata?.id;
|
|
56
|
+
const clientId = block.clientId;
|
|
57
|
+
if ( id && content?.[ id ] ) {
|
|
58
|
+
idToClientIdMap[ clientId ] = id;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return idToClientIdMap;
|
|
62
|
+
}
|
|
63
|
+
|
|
45
64
|
const useInferredLayout = ( blocks, parentLayout ) => {
|
|
46
65
|
const initialInferredAlignmentRef = useRef();
|
|
47
66
|
|
|
@@ -101,25 +120,31 @@ function getOverridableAttributes( block ) {
|
|
|
101
120
|
function applyInitialContentValuesToInnerBlocks(
|
|
102
121
|
blocks,
|
|
103
122
|
content = {},
|
|
104
|
-
defaultValues
|
|
123
|
+
defaultValues,
|
|
124
|
+
legacyIdMap
|
|
105
125
|
) {
|
|
106
126
|
return blocks.map( ( block ) => {
|
|
107
127
|
const innerBlocks = applyInitialContentValuesToInnerBlocks(
|
|
108
128
|
block.innerBlocks,
|
|
109
129
|
content,
|
|
110
|
-
defaultValues
|
|
130
|
+
defaultValues,
|
|
131
|
+
legacyIdMap
|
|
111
132
|
);
|
|
112
|
-
const
|
|
113
|
-
|
|
133
|
+
const metadataName =
|
|
134
|
+
legacyIdMap?.[ block.clientId ] ?? block.attributes.metadata?.name;
|
|
135
|
+
|
|
136
|
+
if ( ! metadataName || ! hasOverridableAttributes( block ) ) {
|
|
114
137
|
return { ...block, innerBlocks };
|
|
138
|
+
}
|
|
139
|
+
|
|
115
140
|
const attributes = getOverridableAttributes( block );
|
|
116
141
|
const newAttributes = { ...block.attributes };
|
|
117
142
|
for ( const attributeKey of attributes ) {
|
|
118
|
-
defaultValues[
|
|
119
|
-
defaultValues[
|
|
143
|
+
defaultValues[ metadataName ] ??= {};
|
|
144
|
+
defaultValues[ metadataName ][ attributeKey ] =
|
|
120
145
|
block.attributes[ attributeKey ];
|
|
121
146
|
|
|
122
|
-
const contentValues = content[
|
|
147
|
+
const contentValues = content[ metadataName ];
|
|
123
148
|
if ( contentValues?.[ attributeKey ] !== undefined ) {
|
|
124
149
|
newAttributes[ attributeKey ] = contentValues[ attributeKey ];
|
|
125
150
|
}
|
|
@@ -142,29 +167,40 @@ function isAttributeEqual( attribute1, attribute2 ) {
|
|
|
142
167
|
return attribute1 === attribute2;
|
|
143
168
|
}
|
|
144
169
|
|
|
145
|
-
function getContentValuesFromInnerBlocks( blocks, defaultValues ) {
|
|
170
|
+
function getContentValuesFromInnerBlocks( blocks, defaultValues, legacyIdMap ) {
|
|
146
171
|
/** @type {Record<string, { values: Record<string, unknown>}>} */
|
|
147
172
|
const content = {};
|
|
148
173
|
for ( const block of blocks ) {
|
|
149
174
|
if ( block.name === patternBlockName ) continue;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
175
|
+
if ( block.innerBlocks.length ) {
|
|
176
|
+
Object.assign(
|
|
177
|
+
content,
|
|
178
|
+
getContentValuesFromInnerBlocks(
|
|
179
|
+
block.innerBlocks,
|
|
180
|
+
defaultValues,
|
|
181
|
+
legacyIdMap
|
|
182
|
+
)
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
const metadataName =
|
|
186
|
+
legacyIdMap?.[ block.clientId ] ?? block.attributes.metadata?.name;
|
|
187
|
+
if ( ! metadataName || ! hasOverridableAttributes( block ) ) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
|
|
156
191
|
const attributes = getOverridableAttributes( block );
|
|
192
|
+
|
|
157
193
|
for ( const attributeKey of attributes ) {
|
|
158
194
|
if (
|
|
159
195
|
! isAttributeEqual(
|
|
160
196
|
block.attributes[ attributeKey ],
|
|
161
|
-
defaultValues[
|
|
197
|
+
defaultValues?.[ metadataName ]?.[ attributeKey ]
|
|
162
198
|
)
|
|
163
199
|
) {
|
|
164
|
-
content[
|
|
200
|
+
content[ metadataName ] ??= {};
|
|
165
201
|
// TODO: We need a way to represent `undefined` in the serialized overrides.
|
|
166
202
|
// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
|
|
167
|
-
content[
|
|
203
|
+
content[ metadataName ][ attributeKey ] =
|
|
168
204
|
block.attributes[ attributeKey ] === undefined
|
|
169
205
|
? // TODO: We use an empty string to represent undefined for now until
|
|
170
206
|
// we support a richer format for overrides and the block binding API.
|
|
@@ -278,8 +314,15 @@ export default function ReusableBlockEdit( {
|
|
|
278
314
|
[ editedRecord.blocks, editedRecord.content ]
|
|
279
315
|
);
|
|
280
316
|
|
|
317
|
+
const legacyIdMap = useRef( {} );
|
|
318
|
+
|
|
281
319
|
// Apply the initial overrides from the pattern block to the inner blocks.
|
|
282
320
|
useEffect( () => {
|
|
321
|
+
// Build a map of clientIds to the old nano id system to provide back compat.
|
|
322
|
+
legacyIdMap.current = getLegacyIdMap(
|
|
323
|
+
initialBlocks,
|
|
324
|
+
initialContent.current
|
|
325
|
+
);
|
|
283
326
|
defaultContent.current = {};
|
|
284
327
|
const originalEditingMode = getBlockEditingMode( patternClientId );
|
|
285
328
|
// Replace the contents of the blocks with the overrides.
|
|
@@ -291,7 +334,8 @@ export default function ReusableBlockEdit( {
|
|
|
291
334
|
applyInitialContentValuesToInnerBlocks(
|
|
292
335
|
initialBlocks,
|
|
293
336
|
initialContent.current,
|
|
294
|
-
defaultContent.current
|
|
337
|
+
defaultContent.current,
|
|
338
|
+
legacyIdMap.current
|
|
295
339
|
)
|
|
296
340
|
);
|
|
297
341
|
} );
|
|
@@ -343,7 +387,8 @@ export default function ReusableBlockEdit( {
|
|
|
343
387
|
setAttributes( {
|
|
344
388
|
content: getContentValuesFromInnerBlocks(
|
|
345
389
|
blocks,
|
|
346
|
-
defaultContent.current
|
|
390
|
+
defaultContent.current,
|
|
391
|
+
legacyIdMap.current
|
|
347
392
|
),
|
|
348
393
|
} );
|
|
349
394
|
} );
|
package/src/block/index.php
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/block` block on server.
|
|
10
10
|
*
|
|
11
|
+
* @global WP_Embed $wp_embed
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes The block attributes.
|
|
12
14
|
*
|
|
13
15
|
* @return string Rendered HTML of the referenced block.
|
|
@@ -46,26 +48,35 @@ function render_block_core_block( $attributes ) {
|
|
|
46
48
|
$content = $wp_embed->run_shortcode( $reusable_block->post_content );
|
|
47
49
|
$content = $wp_embed->autoembed( $content );
|
|
48
50
|
|
|
49
|
-
// Back compat
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
// Back compat.
|
|
52
|
+
// For blocks that have not been migrated in the editor, add some back compat
|
|
53
|
+
// so that front-end rendering continues to work.
|
|
54
|
+
|
|
55
|
+
// This matches the `v2` deprecation. Removes the inner `values` property
|
|
56
|
+
// from every item.
|
|
57
|
+
if ( isset( $attributes['content'] ) ) {
|
|
58
|
+
foreach ( $attributes['content'] as &$content_data ) {
|
|
59
|
+
if ( isset( $content_data['values'] ) ) {
|
|
60
|
+
$is_assoc_array = is_array( $content_data['values'] ) && ! wp_is_numeric_array( $content_data['values'] );
|
|
61
|
+
|
|
62
|
+
if ( $is_assoc_array ) {
|
|
63
|
+
$content_data = $content_data['values'];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
59
66
|
}
|
|
60
|
-
$attributes['content'] = $migrated_content;
|
|
61
67
|
}
|
|
62
|
-
|
|
68
|
+
|
|
69
|
+
// This matches the `v1` deprecation. Rename `overrides` to `content`.
|
|
70
|
+
if ( isset( $attributes['overrides'] ) && ! isset( $attributes['content'] ) ) {
|
|
71
|
+
$attributes['content'] = $attributes['overrides'];
|
|
72
|
+
}
|
|
63
73
|
|
|
64
74
|
/**
|
|
65
75
|
* We set the `pattern/overrides` context through the `render_block_context`
|
|
66
76
|
* filter so that it is available when a pattern's inner blocks are
|
|
67
77
|
* rendering via do_blocks given it only receives the inner content.
|
|
68
78
|
*/
|
|
79
|
+
$has_pattern_overrides = isset( $attributes['content'] );
|
|
69
80
|
if ( $has_pattern_overrides ) {
|
|
70
81
|
$filter_block_context = static function ( $context ) use ( $attributes ) {
|
|
71
82
|
$context['pattern/overrides'] = $attributes['content'];
|
package/src/button/edit.js
CHANGED
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
createBlock,
|
|
46
46
|
cloneBlock,
|
|
47
47
|
getDefaultBlockName,
|
|
48
|
+
store as blocksStore,
|
|
48
49
|
} from '@wordpress/blocks';
|
|
49
50
|
import { useMergeRefs, useRefEffect } from '@wordpress/compose';
|
|
50
51
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -123,7 +124,7 @@ function WidthPanel( { selectedWidth, setAttributes } ) {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
return (
|
|
126
|
-
<PanelBody title={ __( '
|
|
127
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
127
128
|
<ButtonGroup aria-label={ __( 'Button width' ) }>
|
|
128
129
|
{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {
|
|
129
130
|
return (
|
|
@@ -239,7 +240,7 @@ function ButtonEdit( props ) {
|
|
|
239
240
|
}
|
|
240
241
|
|
|
241
242
|
const blockBindingsSource = unlock(
|
|
242
|
-
select(
|
|
243
|
+
select( blocksStore )
|
|
243
244
|
).getBlockBindingsSource( metadata?.bindings?.url?.source );
|
|
244
245
|
|
|
245
246
|
return {
|
|
@@ -328,7 +329,7 @@ function ButtonEdit( props ) {
|
|
|
328
329
|
title={ __( 'Unlink' ) }
|
|
329
330
|
shortcut={ displayShortcut.primaryShift( 'k' ) }
|
|
330
331
|
onClick={ unlink }
|
|
331
|
-
isActive
|
|
332
|
+
isActive
|
|
332
333
|
/>
|
|
333
334
|
) }
|
|
334
335
|
</BlockControls>
|
|
@@ -106,7 +106,7 @@ export default function ButtonsEdit( {
|
|
|
106
106
|
const renderFooterAppender = useRef( () => (
|
|
107
107
|
<View style={ styles.appenderContainer }>
|
|
108
108
|
<InnerBlocks.ButtonBlockAppender
|
|
109
|
-
isFloating
|
|
109
|
+
isFloating
|
|
110
110
|
onAddBlock={ onAddNextButton }
|
|
111
111
|
/>
|
|
112
112
|
</View>
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
5
|
import { __unstableCreateElement as createElement } from '@wordpress/rich-text';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getTransformedMetadata } from '../utils/get-transformed-metadata';
|
|
11
|
+
|
|
7
12
|
const transforms = {
|
|
8
13
|
from: [
|
|
9
14
|
{
|
|
@@ -33,10 +38,8 @@ const transforms = {
|
|
|
33
38
|
{},
|
|
34
39
|
// Loop the selected buttons.
|
|
35
40
|
buttons.map( ( attributes ) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
attributes.content
|
|
39
|
-
);
|
|
41
|
+
const { content, metadata } = attributes;
|
|
42
|
+
const element = createElement( document, content );
|
|
40
43
|
// Remove any HTML tags.
|
|
41
44
|
const text = element.innerText || '';
|
|
42
45
|
// Get first url.
|
|
@@ -46,6 +49,13 @@ const transforms = {
|
|
|
46
49
|
return createBlock( 'core/button', {
|
|
47
50
|
text,
|
|
48
51
|
url,
|
|
52
|
+
metadata: getTransformedMetadata(
|
|
53
|
+
metadata,
|
|
54
|
+
'core/button',
|
|
55
|
+
( { content: contentBinding } ) => ( {
|
|
56
|
+
text: contentBinding,
|
|
57
|
+
} )
|
|
58
|
+
),
|
|
49
59
|
} );
|
|
50
60
|
} )
|
|
51
61
|
),
|
package/src/calendar/index.php
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/calendar` block on server.
|
|
10
10
|
*
|
|
11
|
+
* @global int $monthnum.
|
|
12
|
+
* @global int $year.
|
|
13
|
+
*
|
|
11
14
|
* @param array $attributes The block attributes.
|
|
12
15
|
*
|
|
13
16
|
* @return string Returns the block content.
|
|
@@ -117,6 +120,8 @@ function block_core_calendar_has_published_posts() {
|
|
|
117
120
|
* Queries the database for any published post and saves
|
|
118
121
|
* a flag whether any published post exists or not.
|
|
119
122
|
*
|
|
123
|
+
* @global wpdb $wpdb WordPress database abstraction object.
|
|
124
|
+
*
|
|
120
125
|
* @return bool Has any published posts or not.
|
|
121
126
|
*/
|
|
122
127
|
function block_core_calendar_update_has_published_posts() {
|
package/src/code/transforms.js
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
5
|
import { create, toHTMLString } from '@wordpress/rich-text';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getTransformedMetadata } from '../utils/get-transformed-metadata';
|
|
11
|
+
|
|
7
12
|
const transforms = {
|
|
8
13
|
from: [
|
|
9
14
|
{
|
|
@@ -14,17 +19,21 @@ const transforms = {
|
|
|
14
19
|
{
|
|
15
20
|
type: 'block',
|
|
16
21
|
blocks: [ 'core/paragraph' ],
|
|
17
|
-
transform: ( { content } ) =>
|
|
18
|
-
createBlock( 'core/code', {
|
|
22
|
+
transform: ( { content, metadata } ) =>
|
|
23
|
+
createBlock( 'core/code', {
|
|
24
|
+
content,
|
|
25
|
+
metadata: getTransformedMetadata( metadata, 'core/code' ),
|
|
26
|
+
} ),
|
|
19
27
|
},
|
|
20
28
|
{
|
|
21
29
|
type: 'block',
|
|
22
30
|
blocks: [ 'core/html' ],
|
|
23
|
-
transform: ( { content: text } ) => {
|
|
31
|
+
transform: ( { content: text, metadata } ) => {
|
|
24
32
|
return createBlock( 'core/code', {
|
|
25
33
|
// The HTML is plain text (with plain line breaks), so
|
|
26
34
|
// convert it to rich text.
|
|
27
35
|
content: toHTMLString( { value: create( { text } ) } ),
|
|
36
|
+
metadata: getTransformedMetadata( metadata, 'core/code' ),
|
|
28
37
|
} );
|
|
29
38
|
},
|
|
30
39
|
},
|
|
@@ -51,8 +60,14 @@ const transforms = {
|
|
|
51
60
|
{
|
|
52
61
|
type: 'block',
|
|
53
62
|
blocks: [ 'core/paragraph' ],
|
|
54
|
-
transform: ( { content } ) =>
|
|
55
|
-
createBlock( 'core/paragraph', {
|
|
63
|
+
transform: ( { content, metadata } ) =>
|
|
64
|
+
createBlock( 'core/paragraph', {
|
|
65
|
+
content,
|
|
66
|
+
metadata: getTransformedMetadata(
|
|
67
|
+
metadata,
|
|
68
|
+
'core/paragraph'
|
|
69
|
+
),
|
|
70
|
+
} ),
|
|
56
71
|
},
|
|
57
72
|
],
|
|
58
73
|
};
|
package/src/columns/edit.js
CHANGED
|
@@ -139,18 +139,19 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
|
|
|
139
139
|
// If adding a new column, assign width to the new column equal to
|
|
140
140
|
// as if it were `1 / columns` of the total available space.
|
|
141
141
|
const newColumnWidth = toWidthPrecision( 100 / newColumns );
|
|
142
|
+
const newlyAddedColumns = newColumns - previousColumns;
|
|
142
143
|
|
|
143
144
|
// Redistribute in consideration of pending block insertion as
|
|
144
145
|
// constraining the available working width.
|
|
145
146
|
const widths = getRedistributedColumnWidths(
|
|
146
147
|
innerBlocks,
|
|
147
|
-
100 - newColumnWidth
|
|
148
|
+
100 - newColumnWidth * newlyAddedColumns
|
|
148
149
|
);
|
|
149
150
|
|
|
150
151
|
innerBlocks = [
|
|
151
152
|
...getMappedColumnWidths( innerBlocks, widths ),
|
|
152
153
|
...Array.from( {
|
|
153
|
-
length:
|
|
154
|
+
length: newlyAddedColumns,
|
|
154
155
|
} ).map( () => {
|
|
155
156
|
return createBlock( 'core/column', {
|
|
156
157
|
width: `${ newColumnWidth }%`,
|
package/src/comments/index.php
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* the block is in legacy mode. If not, the HTML generated in the editor is
|
|
17
17
|
* returned instead.
|
|
18
18
|
*
|
|
19
|
+
* @global WP_Post $post Global post object.
|
|
20
|
+
*
|
|
19
21
|
* @param array $attributes Block attributes.
|
|
20
22
|
* @param string $content Block default content.
|
|
21
23
|
* @param WP_Block $block Block instance.
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
MediaReplaceFlow,
|
|
9
9
|
__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,
|
|
10
10
|
__experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl,
|
|
11
|
+
privateApis as blockEditorPrivateApis,
|
|
11
12
|
} from '@wordpress/block-editor';
|
|
12
13
|
import { __ } from '@wordpress/i18n';
|
|
13
14
|
|
|
@@ -15,6 +16,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
17
18
|
import { ALLOWED_MEDIA_TYPES } from '../shared';
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
20
|
+
|
|
21
|
+
const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
|
|
18
22
|
|
|
19
23
|
export default function CoverBlockControls( {
|
|
20
24
|
attributes,
|
|
@@ -30,7 +34,10 @@ export default function CoverBlockControls( {
|
|
|
30
34
|
const [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );
|
|
31
35
|
const [ prevMinHeightUnit, setPrevMinHeightUnit ] =
|
|
32
36
|
useState( minHeightUnit );
|
|
33
|
-
const isMinFullHeight =
|
|
37
|
+
const isMinFullHeight =
|
|
38
|
+
minHeightUnit === 'vh' &&
|
|
39
|
+
minHeight === 100 &&
|
|
40
|
+
! attributes?.style?.dimensions?.aspectRatio;
|
|
34
41
|
const toggleMinFullHeight = () => {
|
|
35
42
|
if ( isMinFullHeight ) {
|
|
36
43
|
// If there aren't previous values, take the default ones.
|
|
@@ -51,10 +58,17 @@ export default function CoverBlockControls( {
|
|
|
51
58
|
setPrevMinHeightValue( minHeight );
|
|
52
59
|
setPrevMinHeightUnit( minHeightUnit );
|
|
53
60
|
|
|
54
|
-
// Set full height.
|
|
61
|
+
// Set full height, and clear any aspect ratio value.
|
|
55
62
|
return setAttributes( {
|
|
56
63
|
minHeight: 100,
|
|
57
64
|
minHeightUnit: 'vh',
|
|
65
|
+
style: cleanEmptyObject( {
|
|
66
|
+
...attributes?.style,
|
|
67
|
+
dimensions: {
|
|
68
|
+
...attributes?.style?.dimensions,
|
|
69
|
+
aspectRatio: undefined, // Reset aspect ratio when minHeight is set.
|
|
70
|
+
},
|
|
71
|
+
} ),
|
|
58
72
|
} );
|
|
59
73
|
};
|
|
60
74
|
|
package/src/cover/edit/index.js
CHANGED
|
@@ -464,7 +464,7 @@ function CoverEdit( {
|
|
|
464
464
|
>
|
|
465
465
|
<div className="wp-block-cover__placeholder-background-options">
|
|
466
466
|
<ColorPalette
|
|
467
|
-
disableCustomColors
|
|
467
|
+
disableCustomColors
|
|
468
468
|
value={ overlayColor.color }
|
|
469
469
|
onChange={ onSetOverlayColor }
|
|
470
470
|
clearable={ false }
|
|
@@ -525,7 +525,7 @@ function CoverEdit( {
|
|
|
525
525
|
{ ! url && useFeaturedImage && (
|
|
526
526
|
<Placeholder
|
|
527
527
|
className="wp-block-cover__image--placeholder-image"
|
|
528
|
-
withIllustration
|
|
528
|
+
withIllustration
|
|
529
529
|
/>
|
|
530
530
|
) }
|
|
531
531
|
|
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
10
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -40,10 +40,6 @@ export default function ResizableCoverPopover( {
|
|
|
40
40
|
...props
|
|
41
41
|
} ) {
|
|
42
42
|
const [ isResizing, setIsResizing ] = useState( false );
|
|
43
|
-
const dimensions = useMemo(
|
|
44
|
-
() => ( { height, minHeight, width } ),
|
|
45
|
-
[ minHeight, height, width ]
|
|
46
|
-
);
|
|
47
43
|
|
|
48
44
|
const resizableBoxProps = {
|
|
49
45
|
className: classnames( className, { 'is-resizing': isResizing } ),
|
|
@@ -75,7 +71,6 @@ export default function ResizableCoverPopover( {
|
|
|
75
71
|
return (
|
|
76
72
|
<ResizableBoxPopover
|
|
77
73
|
className="block-library-cover__resizable-box-popover"
|
|
78
|
-
__unstableRefreshSize={ dimensions }
|
|
79
74
|
resizableBoxProps={ resizableBoxProps }
|
|
80
75
|
{ ...props }
|
|
81
76
|
/>
|
package/src/cover/edit.native.js
CHANGED
package/src/cover/style.scss
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
align-items: center;
|
|
9
9
|
padding: 1em;
|
|
10
10
|
// Prevent the `wp-block-cover__background` span from overflowing the container when border-radius is applied.
|
|
11
|
+
// `overflow: hidden` is provided as a fallback for browsers that don't support `overflow: clip`.
|
|
12
|
+
overflow: hidden;
|
|
11
13
|
// Use clip instead of overflow: hidden so that sticky position works on child elements.
|
|
12
|
-
|
|
13
|
-
overflow-x: clip;
|
|
14
|
+
overflow: clip;
|
|
14
15
|
// This block has customizable padding, border-box makes that more predictable.
|
|
15
16
|
box-sizing: border-box;
|
|
16
17
|
// Keep the flex layout direction to the physical direction (LTR) in RTL languages.
|
package/src/file/deprecated.js
CHANGED
|
@@ -131,7 +131,7 @@ const v3 = {
|
|
|
131
131
|
'wp-block-file__button',
|
|
132
132
|
__experimentalGetElementClassName( 'button' )
|
|
133
133
|
) }
|
|
134
|
-
download
|
|
134
|
+
download
|
|
135
135
|
aria-describedby={ describedById }
|
|
136
136
|
>
|
|
137
137
|
<RichText.Content value={ downloadButtonText } />
|
|
@@ -259,7 +259,7 @@ const v2 = {
|
|
|
259
259
|
<a
|
|
260
260
|
href={ href }
|
|
261
261
|
className="wp-block-file__button"
|
|
262
|
-
download
|
|
262
|
+
download
|
|
263
263
|
aria-describedby={ describedById }
|
|
264
264
|
>
|
|
265
265
|
<RichText.Content value={ downloadButtonText } />
|
|
@@ -372,7 +372,7 @@ const v1 = {
|
|
|
372
372
|
<a
|
|
373
373
|
href={ href }
|
|
374
374
|
className="wp-block-file__button"
|
|
375
|
-
download
|
|
375
|
+
download
|
|
376
376
|
>
|
|
377
377
|
<RichText.Content value={ downloadButtonText } />
|
|
378
378
|
</a>
|
package/src/file/edit.js
CHANGED
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { isBlobURL } from '@wordpress/blob';
|
|
10
10
|
import {
|
|
11
11
|
__unstableGetAnimateClassName as getAnimateClassName,
|
|
12
12
|
ResizableBox,
|
|
@@ -36,6 +36,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
36
36
|
import FileBlockInspector from './inspector';
|
|
37
37
|
import { browserSupportsPdfs } from './utils';
|
|
38
38
|
import removeAnchorTag from '../utils/remove-anchor-tag';
|
|
39
|
+
import { useUploadMediaFromBlobURL } from '../utils/hooks';
|
|
39
40
|
|
|
40
41
|
export const MIN_PREVIEW_HEIGHT = 200;
|
|
41
42
|
export const MAX_PREVIEW_HEIGHT = 2000;
|
|
@@ -72,7 +73,6 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
72
73
|
displayPreview,
|
|
73
74
|
previewHeight,
|
|
74
75
|
} = attributes;
|
|
75
|
-
const { getSettings } = useSelect( blockEditorStore );
|
|
76
76
|
const { media } = useSelect(
|
|
77
77
|
( select ) => ( {
|
|
78
78
|
media:
|
|
@@ -86,20 +86,13 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
86
86
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
87
87
|
const { toggleSelection } = useDispatch( blockEditorStore );
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
getSettings().mediaUpload( {
|
|
95
|
-
filesList: [ file ],
|
|
96
|
-
onFileChange: ( [ newMedia ] ) => onSelectFile( newMedia ),
|
|
97
|
-
onError: onUploadError,
|
|
98
|
-
} );
|
|
99
|
-
|
|
100
|
-
revokeBlobURL( href );
|
|
101
|
-
}
|
|
89
|
+
useUploadMediaFromBlobURL( {
|
|
90
|
+
url: href,
|
|
91
|
+
onChange: onSelectFile,
|
|
92
|
+
onError: onUploadError,
|
|
93
|
+
} );
|
|
102
94
|
|
|
95
|
+
useEffect( () => {
|
|
103
96
|
if ( RichText.isEmpty( downloadButtonText ) ) {
|
|
104
97
|
setAttributes( {
|
|
105
98
|
downloadButtonText: _x( 'Download', 'button label' ),
|
package/src/file/edit.native.js
CHANGED
|
@@ -282,7 +282,7 @@ export class FileEdit extends Component {
|
|
|
282
282
|
value={ textLinkHref }
|
|
283
283
|
onChange={ this.onChangeLinkDestinationOption }
|
|
284
284
|
options={ linkDestinationOptions }
|
|
285
|
-
hideCancelButton
|
|
285
|
+
hideCancelButton
|
|
286
286
|
/>
|
|
287
287
|
<ToggleControl
|
|
288
288
|
icon={ external }
|
|
@@ -469,7 +469,7 @@ export class FileEdit extends Component {
|
|
|
469
469
|
tagName="p"
|
|
470
470
|
underlineColorAndroid="transparent"
|
|
471
471
|
value={ fileName }
|
|
472
|
-
deleteEnter
|
|
472
|
+
deleteEnter
|
|
473
473
|
textAlign={ this.getTextAlignmentForAlignment(
|
|
474
474
|
align
|
|
475
475
|
) }
|
|
@@ -505,7 +505,7 @@ export class FileEdit extends Component {
|
|
|
505
505
|
textAlign="center"
|
|
506
506
|
minWidth={ minWidth }
|
|
507
507
|
maxWidth={ this.state.maxWidth }
|
|
508
|
-
deleteEnter
|
|
508
|
+
deleteEnter
|
|
509
509
|
style={ styles.buttonText }
|
|
510
510
|
value={ downloadButtonText }
|
|
511
511
|
placeholder={ placeholderText }
|
|
@@ -565,7 +565,7 @@ export class FileEdit extends Component {
|
|
|
565
565
|
return (
|
|
566
566
|
<MediaUpload
|
|
567
567
|
allowedTypes={ [ MEDIA_TYPE_ANY ] }
|
|
568
|
-
isReplacingMedia
|
|
568
|
+
isReplacingMedia
|
|
569
569
|
onSelect={ this.onSelectFile }
|
|
570
570
|
render={ ( { open, getMediaOptions } ) => {
|
|
571
571
|
return this.getFileComponent( open, getMediaOptions );
|
package/src/file/save.js
CHANGED
|
@@ -73,7 +73,7 @@ export default function save( { attributes } ) {
|
|
|
73
73
|
'wp-block-file__button',
|
|
74
74
|
__experimentalGetElementClassName( 'button' )
|
|
75
75
|
) }
|
|
76
|
-
download
|
|
76
|
+
download
|
|
77
77
|
aria-describedby={ describedById }
|
|
78
78
|
>
|
|
79
79
|
<RichText.Content value={ downloadButtonText } />
|