@wordpress/block-library 9.14.0 → 9.15.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/LICENSE.md +1 -1
- package/build/archives/edit.js +83 -36
- package/build/archives/edit.js.map +1 -1
- package/build/button/deprecated.js +182 -1
- package/build/button/deprecated.js.map +1 -1
- package/build/button/edit.js +47 -25
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +8 -2
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +8 -5
- package/build/button/save.js.map +1 -1
- package/build/column/edit.js +33 -13
- package/build/column/edit.js.map +1 -1
- package/build/columns/edit.js +50 -27
- package/build/columns/edit.js.map +1 -1
- package/build/comments/index.js +1 -0
- package/build/comments/index.js.map +1 -1
- package/build/cover/edit/index.js +9 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit.native.js +1 -1
- package/build/cover/edit.native.js.map +1 -1
- package/build/details/edit.js +29 -7
- package/build/details/edit.js.map +1 -1
- package/build/image/transforms.js +1 -0
- package/build/image/transforms.js.map +1 -1
- package/build/latest-posts/deprecated.js +12 -0
- package/build/latest-posts/deprecated.js.map +1 -1
- package/build/latest-posts/index.js +12 -0
- package/build/latest-posts/index.js.map +1 -1
- package/build/loginout/edit.js +42 -13
- package/build/loginout/edit.js.map +1 -1
- package/build/media-text/edit.js +59 -31
- package/build/media-text/edit.js.map +1 -1
- package/build/more/edit.js +28 -7
- package/build/more/edit.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +5 -3
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation-link/edit.js +95 -55
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +105 -53
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +44 -25
- package/build/page-list/edit.js.map +1 -1
- package/build/paragraph/edit.js +14 -4
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-author/edit.js +15 -3
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author/index.js +4 -2
- package/build/post-author/index.js.map +1 -1
- package/build/post-author-name/edit.js +11 -5
- package/build/post-author-name/edit.js.map +1 -1
- package/build/post-author-name/index.js +4 -2
- package/build/post-author-name/index.js.map +1 -1
- package/build/post-comments-form/index.js +6 -1
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-comments-link/index.js +8 -1
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-date/edit.js +58 -18
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/index.js +2 -1
- package/build/post-date/index.js.map +1 -1
- package/build/post-excerpt/edit.js +42 -18
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +17 -19
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +45 -11
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +6 -3
- package/build/post-featured-image/index.js.map +1 -1
- package/build/post-navigation-link/index.js +11 -7
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-navigation-link/variations.js +2 -2
- package/build/post-navigation-link/variations.js.map +1 -1
- package/build/post-template/index.js +11 -1
- package/build/post-template/index.js.map +1 -1
- package/build/post-title/index.js +6 -3
- package/build/post-title/index.js.map +1 -1
- package/build/query-no-results/index.js +10 -9
- package/build/query-no-results/index.js.map +1 -1
- package/build/query-pagination/edit.js +47 -17
- package/build/query-pagination/edit.js.map +1 -1
- package/build/query-pagination/query-pagination-label-control.js +1 -1
- package/build/query-pagination/query-pagination-label-control.js.map +1 -1
- package/build/query-pagination-numbers/edit.js +33 -15
- package/build/query-pagination-numbers/edit.js.map +1 -1
- package/build/query-total/edit.js +8 -10
- package/build/query-total/edit.js.map +1 -1
- package/build/query-total/index.js +8 -1
- package/build/query-total/index.js.map +1 -1
- package/build/read-more/index.js +7 -1
- package/build/read-more/index.js.map +1 -1
- package/build/site-logo/index.js +4 -2
- package/build/site-logo/index.js.map +1 -1
- package/build/site-title/edit.js +41 -12
- package/build/site-title/edit.js.map +1 -1
- package/build/site-title/index.js +4 -2
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/edit.js +19 -3
- package/build/social-link/edit.js.map +1 -1
- package/build/social-links/edit.js +41 -12
- package/build/social-links/edit.js.map +1 -1
- package/build/spacer/controls.js +34 -12
- package/build/spacer/controls.js.map +1 -1
- package/build/table/edit.js +48 -15
- package/build/table/edit.js.map +1 -1
- package/build/table/index.js +4 -1
- package/build/table/index.js.map +1 -1
- package/build/table-of-contents/edit.js +1 -1
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/index.js +24 -23
- package/build/table-of-contents/index.js.map +1 -1
- package/build/tag-cloud/edit.js +56 -11
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/video/edit-common-settings.js +90 -30
- package/build/video/edit-common-settings.js.map +1 -1
- package/build/video/edit.js +20 -49
- package/build/video/edit.js.map +1 -1
- package/build/video/poster-image.js +81 -0
- package/build/video/poster-image.js.map +1 -0
- package/build/video/tracks-editor.js +1 -1
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/archives/edit.js +84 -37
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/button/deprecated.js +183 -2
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/edit.js +50 -28
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +8 -2
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +9 -6
- package/build-module/button/save.js.map +1 -1
- package/build-module/column/edit.js +34 -14
- package/build-module/column/edit.js.map +1 -1
- package/build-module/columns/edit.js +52 -29
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/comments/index.js +1 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/cover/edit/index.js +9 -3
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit.native.js +2 -2
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/details/edit.js +30 -8
- package/build-module/details/edit.js.map +1 -1
- package/build-module/image/transforms.js +1 -0
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/latest-posts/deprecated.js +12 -0
- package/build-module/latest-posts/deprecated.js.map +1 -1
- package/build-module/latest-posts/index.js +12 -0
- package/build-module/latest-posts/index.js.map +1 -1
- package/build-module/loginout/edit.js +42 -14
- package/build-module/loginout/edit.js.map +1 -1
- package/build-module/media-text/edit.js +59 -31
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/more/edit.js +28 -8
- package/build-module/more/edit.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +5 -3
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation-link/edit.js +96 -56
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +106 -54
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +45 -26
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +15 -6
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-author/edit.js +16 -4
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author/index.js +4 -2
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-author-name/edit.js +12 -6
- package/build-module/post-author-name/edit.js.map +1 -1
- package/build-module/post-author-name/index.js +4 -2
- package/build-module/post-author-name/index.js.map +1 -1
- package/build-module/post-comments-form/index.js +6 -1
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +8 -1
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-date/edit.js +59 -19
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/index.js +2 -1
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-excerpt/edit.js +44 -20
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +18 -20
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +47 -13
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +6 -3
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/post-navigation-link/index.js +12 -7
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-navigation-link/variations.js +2 -2
- package/build-module/post-navigation-link/variations.js.map +1 -1
- package/build-module/post-template/index.js +11 -1
- package/build-module/post-template/index.js.map +1 -1
- package/build-module/post-title/index.js +6 -3
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/query-no-results/index.js +10 -9
- package/build-module/query-no-results/index.js.map +1 -1
- package/build-module/query-pagination/edit.js +49 -19
- package/build-module/query-pagination/edit.js.map +1 -1
- package/build-module/query-pagination/query-pagination-label-control.js +1 -1
- package/build-module/query-pagination/query-pagination-label-control.js.map +1 -1
- package/build-module/query-pagination-numbers/edit.js +34 -16
- package/build-module/query-pagination-numbers/edit.js.map +1 -1
- package/build-module/query-total/edit.js +8 -10
- package/build-module/query-total/edit.js.map +1 -1
- package/build-module/query-total/index.js +8 -1
- package/build-module/query-total/index.js.map +1 -1
- package/build-module/read-more/index.js +7 -1
- package/build-module/read-more/index.js.map +1 -1
- package/build-module/site-logo/index.js +4 -2
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-title/edit.js +42 -13
- package/build-module/site-title/edit.js.map +1 -1
- package/build-module/site-title/index.js +4 -2
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/edit.js +20 -4
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-links/edit.js +42 -13
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/spacer/controls.js +35 -13
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/table/edit.js +49 -16
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table/index.js +4 -1
- package/build-module/table/index.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -1
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/index.js +26 -25
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/tag-cloud/edit.js +57 -12
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/video/edit-common-settings.js +91 -31
- package/build-module/video/edit-common-settings.js.map +1 -1
- package/build-module/video/edit.js +24 -53
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/poster-image.js +74 -0
- package/build-module/video/poster-image.js.map +1 -0
- package/build-module/video/tracks-editor.js +1 -1
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/comment-template/style-rtl.css +0 -1
- package/build-style/comment-template/style.css +0 -1
- package/build-style/editor-rtl.css +4 -19
- package/build-style/editor.css +4 -19
- package/build-style/form-input/style-rtl.css +0 -2
- package/build-style/form-input/style.css +0 -2
- package/build-style/freeform/editor-rtl.css +4 -8
- package/build-style/freeform/editor.css +4 -8
- package/build-style/{post-template/editor.css → post-comments-link/style-rtl.css} +2 -4
- package/build-style/{post-template/editor-rtl.css → post-comments-link/style.css} +2 -4
- package/build-style/post-template/style-rtl.css +1 -0
- package/build-style/post-template/style.css +1 -0
- package/build-style/query-total/style-rtl.css +103 -0
- package/build-style/query-total/style.css +103 -0
- package/build-style/read-more/style-rtl.css +0 -1
- package/build-style/read-more/style.css +0 -1
- package/build-style/style-rtl.css +9 -4
- package/build-style/style.css +9 -4
- package/build-style/tag-cloud/editor-rtl.css +0 -5
- package/build-style/tag-cloud/editor.css +0 -5
- package/package.json +35 -35
- package/src/archives/edit.js +94 -36
- package/src/audio/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/block/index.php +20 -0
- package/src/button/block.json +17 -2
- package/src/button/deprecated.js +189 -0
- package/src/button/edit.js +60 -31
- package/src/button/save.js +6 -1
- package/src/column/edit.js +34 -13
- package/src/columns/edit.js +71 -40
- package/src/comments/index.js +1 -0
- package/src/cover/edit/index.js +12 -5
- package/src/cover/edit.native.js +5 -2
- package/src/cover/test/edit.js +5 -7
- package/src/details/edit.js +40 -11
- package/src/editor.scss +0 -1
- package/src/file/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/image/transforms.js +1 -0
- package/src/latest-posts/block.json +12 -0
- package/src/loginout/edit.js +56 -20
- package/src/media-text/edit.js +57 -28
- package/src/more/edit.js +39 -12
- package/src/navigation/edit/navigation-menu-selector.js +9 -2
- package/src/navigation/index.php +2 -2
- package/src/navigation-link/edit.js +101 -61
- package/src/navigation-link/index.php +16 -1
- package/src/navigation-submenu/edit.js +113 -57
- package/src/page-list/edit.js +52 -31
- package/src/paragraph/edit.js +18 -4
- package/src/post-author/block.json +4 -2
- package/src/post-author/edit.js +17 -3
- package/src/post-author/index.php +4 -0
- package/src/post-author-name/block.json +4 -2
- package/src/post-author-name/edit.js +17 -4
- package/src/post-author-name/index.php +4 -0
- package/src/post-comments-form/block.json +6 -1
- package/src/post-comments-link/block.json +8 -1
- package/src/post-comments-link/style.scss +4 -0
- package/src/post-content/index.php +23 -0
- package/src/post-date/block.json +2 -1
- package/src/post-date/edit.js +79 -25
- package/src/post-excerpt/edit.js +59 -22
- package/src/post-featured-image/block.json +6 -3
- package/src/post-featured-image/dimension-controls.js +18 -21
- package/src/post-featured-image/edit.js +67 -10
- package/src/post-navigation-link/block.json +0 -6
- package/src/post-navigation-link/index.js +11 -0
- package/src/post-navigation-link/variations.js +2 -2
- package/src/post-template/block.json +11 -1
- package/src/post-template/style.scss +2 -0
- package/src/post-title/block.json +6 -3
- package/src/query-no-results/block.json +0 -10
- package/src/query-no-results/index.js +11 -0
- package/src/query-pagination/edit.js +57 -15
- package/src/query-pagination/query-pagination-label-control.js +1 -3
- package/src/query-pagination-numbers/edit.js +41 -19
- package/src/query-pagination-previous/index.php +21 -14
- package/src/query-total/block.json +8 -1
- package/src/query-total/edit.js +11 -13
- package/src/query-total/index.php +9 -13
- package/src/query-total/style.scss +4 -0
- package/src/read-more/index.js +6 -0
- package/src/site-logo/block.json +4 -2
- package/src/site-title/block.json +4 -2
- package/src/site-title/edit.js +52 -15
- package/src/social-link/edit.js +21 -6
- package/src/social-links/edit.js +52 -15
- package/src/spacer/controls.js +42 -15
- package/src/style.scss +2 -0
- package/src/table/block.json +4 -1
- package/src/table/edit.js +58 -20
- package/src/table-of-contents/block.json +0 -52
- package/src/table-of-contents/edit.js +1 -1
- package/src/table-of-contents/index.js +53 -0
- package/src/tag-cloud/edit.js +60 -8
- package/src/tag-cloud/editor.scss +0 -8
- package/src/video/edit-common-settings.js +97 -39
- package/src/video/edit.js +29 -75
- package/src/video/poster-image.js +86 -0
- package/src/video/tracks-editor.js +1 -1
- package/tsconfig.json +0 -2
- package/src/post-template/editor.scss +0 -7
package/src/tag-cloud/edit.js
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
import {
|
|
5
5
|
Flex,
|
|
6
6
|
FlexItem,
|
|
7
|
-
PanelBody,
|
|
8
7
|
ToggleControl,
|
|
9
8
|
SelectControl,
|
|
10
9
|
RangeControl,
|
|
11
10
|
__experimentalUnitControl as UnitControl,
|
|
12
11
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
13
12
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
14
|
-
|
|
13
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
14
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
15
15
|
Disabled,
|
|
16
16
|
} from '@wordpress/components';
|
|
17
17
|
import { useSelect } from '@wordpress/data';
|
|
@@ -24,6 +24,11 @@ import {
|
|
|
24
24
|
import ServerSideRender from '@wordpress/server-side-render';
|
|
25
25
|
import { store as coreStore } from '@wordpress/core-data';
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Internal dependencies
|
|
29
|
+
*/
|
|
30
|
+
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
31
|
+
|
|
27
32
|
/**
|
|
28
33
|
* Minimum number of tags a user can show using this block.
|
|
29
34
|
*
|
|
@@ -51,6 +56,7 @@ function TagCloudEdit( { attributes, setAttributes } ) {
|
|
|
51
56
|
} = attributes;
|
|
52
57
|
|
|
53
58
|
const [ availableUnits ] = useSettings( 'spacing.units' );
|
|
59
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
54
60
|
|
|
55
61
|
// The `pt` unit is used as the default value and is therefore
|
|
56
62
|
// always considered an available unit.
|
|
@@ -118,10 +124,26 @@ function TagCloudEdit( { attributes, setAttributes } ) {
|
|
|
118
124
|
|
|
119
125
|
const inspectorControls = (
|
|
120
126
|
<InspectorControls>
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
<ToolsPanel
|
|
128
|
+
label={ __( 'Settings' ) }
|
|
129
|
+
resetAll={ () => {
|
|
130
|
+
setAttributes( {
|
|
131
|
+
taxonomy: 'post_tag',
|
|
132
|
+
showTagCounts: false,
|
|
133
|
+
numberOfTags: 45,
|
|
134
|
+
smallestFontSize: '8pt',
|
|
135
|
+
largestFontSize: '22pt',
|
|
136
|
+
} );
|
|
137
|
+
} }
|
|
138
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
139
|
+
>
|
|
140
|
+
<ToolsPanelItem
|
|
141
|
+
hasValue={ () => taxonomy !== 'post_tag' }
|
|
142
|
+
label={ __( 'Taxonomy' ) }
|
|
143
|
+
onDeselect={ () =>
|
|
144
|
+
setAttributes( { taxonomy: 'post_tag' } )
|
|
145
|
+
}
|
|
146
|
+
isShownByDefault
|
|
125
147
|
>
|
|
126
148
|
<SelectControl
|
|
127
149
|
__nextHasNoMarginBottom
|
|
@@ -133,6 +155,20 @@ function TagCloudEdit( { attributes, setAttributes } ) {
|
|
|
133
155
|
setAttributes( { taxonomy: selectedTaxonomy } )
|
|
134
156
|
}
|
|
135
157
|
/>
|
|
158
|
+
</ToolsPanelItem>
|
|
159
|
+
<ToolsPanelItem
|
|
160
|
+
hasValue={ () =>
|
|
161
|
+
smallestFontSize !== '8pt' || largestFontSize !== '22pt'
|
|
162
|
+
}
|
|
163
|
+
label={ __( 'Font size' ) }
|
|
164
|
+
onDeselect={ () =>
|
|
165
|
+
setAttributes( {
|
|
166
|
+
smallestFontSize: '8pt',
|
|
167
|
+
largestFontSize: '22pt',
|
|
168
|
+
} )
|
|
169
|
+
}
|
|
170
|
+
isShownByDefault
|
|
171
|
+
>
|
|
136
172
|
<Flex gap={ 4 }>
|
|
137
173
|
<FlexItem isBlock>
|
|
138
174
|
<UnitControl
|
|
@@ -167,6 +203,13 @@ function TagCloudEdit( { attributes, setAttributes } ) {
|
|
|
167
203
|
/>
|
|
168
204
|
</FlexItem>
|
|
169
205
|
</Flex>
|
|
206
|
+
</ToolsPanelItem>
|
|
207
|
+
<ToolsPanelItem
|
|
208
|
+
hasValue={ () => numberOfTags !== 45 }
|
|
209
|
+
label={ __( 'Number of tags' ) }
|
|
210
|
+
onDeselect={ () => setAttributes( { numberOfTags: 45 } ) }
|
|
211
|
+
isShownByDefault
|
|
212
|
+
>
|
|
170
213
|
<RangeControl
|
|
171
214
|
__nextHasNoMarginBottom
|
|
172
215
|
__next40pxDefaultSize
|
|
@@ -179,6 +222,15 @@ function TagCloudEdit( { attributes, setAttributes } ) {
|
|
|
179
222
|
max={ MAX_TAGS }
|
|
180
223
|
required
|
|
181
224
|
/>
|
|
225
|
+
</ToolsPanelItem>
|
|
226
|
+
<ToolsPanelItem
|
|
227
|
+
hasValue={ () => showTagCounts !== false }
|
|
228
|
+
label={ __( 'Show tag counts' ) }
|
|
229
|
+
onDeselect={ () =>
|
|
230
|
+
setAttributes( { showTagCounts: false } )
|
|
231
|
+
}
|
|
232
|
+
isShownByDefault
|
|
233
|
+
>
|
|
182
234
|
<ToggleControl
|
|
183
235
|
__nextHasNoMarginBottom
|
|
184
236
|
label={ __( 'Show tag counts' ) }
|
|
@@ -187,8 +239,8 @@ function TagCloudEdit( { attributes, setAttributes } ) {
|
|
|
187
239
|
setAttributes( { showTagCounts: ! showTagCounts } )
|
|
188
240
|
}
|
|
189
241
|
/>
|
|
190
|
-
</
|
|
191
|
-
</
|
|
242
|
+
</ToolsPanelItem>
|
|
243
|
+
</ToolsPanel>
|
|
192
244
|
</InspectorControls>
|
|
193
245
|
);
|
|
194
246
|
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, _x } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ToggleControl,
|
|
7
|
+
SelectControl,
|
|
8
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
9
|
+
} from '@wordpress/components';
|
|
6
10
|
import { useMemo, useCallback, Platform } from '@wordpress/element';
|
|
7
11
|
|
|
8
12
|
const options = [
|
|
@@ -47,50 +51,104 @@ const VideoSettings = ( { setAttributes, attributes } ) => {
|
|
|
47
51
|
|
|
48
52
|
return (
|
|
49
53
|
<>
|
|
50
|
-
<
|
|
51
|
-
__nextHasNoMarginBottom
|
|
54
|
+
<ToolsPanelItem
|
|
52
55
|
label={ __( 'Autoplay' ) }
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
isShownByDefault
|
|
57
|
+
hasValue={ () => !! autoplay }
|
|
58
|
+
onDeselect={ () => {
|
|
59
|
+
setAttributes( { autoplay: false } );
|
|
60
|
+
} }
|
|
61
|
+
>
|
|
62
|
+
<ToggleControl
|
|
63
|
+
__nextHasNoMarginBottom
|
|
64
|
+
label={ __( 'Autoplay' ) }
|
|
65
|
+
onChange={ toggleFactory.autoplay }
|
|
66
|
+
checked={ !! autoplay }
|
|
67
|
+
help={ getAutoplayHelp }
|
|
68
|
+
/>
|
|
69
|
+
</ToolsPanelItem>
|
|
70
|
+
<ToolsPanelItem
|
|
59
71
|
label={ __( 'Loop' ) }
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
isShownByDefault
|
|
73
|
+
hasValue={ () => !! loop }
|
|
74
|
+
onDeselect={ () => {
|
|
75
|
+
setAttributes( { loop: false } );
|
|
76
|
+
} }
|
|
77
|
+
>
|
|
78
|
+
<ToggleControl
|
|
79
|
+
__nextHasNoMarginBottom
|
|
80
|
+
label={ __( 'Loop' ) }
|
|
81
|
+
onChange={ toggleFactory.loop }
|
|
82
|
+
checked={ !! loop }
|
|
83
|
+
/>
|
|
84
|
+
</ToolsPanelItem>
|
|
85
|
+
<ToolsPanelItem
|
|
65
86
|
label={ __( 'Muted' ) }
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
87
|
+
isShownByDefault
|
|
88
|
+
hasValue={ () => !! muted }
|
|
89
|
+
onDeselect={ () => {
|
|
90
|
+
setAttributes( { muted: false } );
|
|
91
|
+
} }
|
|
92
|
+
>
|
|
93
|
+
<ToggleControl
|
|
94
|
+
__nextHasNoMarginBottom
|
|
95
|
+
label={ __( 'Muted' ) }
|
|
96
|
+
onChange={ toggleFactory.muted }
|
|
97
|
+
checked={ !! muted }
|
|
98
|
+
/>
|
|
99
|
+
</ToolsPanelItem>
|
|
100
|
+
<ToolsPanelItem
|
|
71
101
|
label={ __( 'Playback controls' ) }
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
102
|
+
isShownByDefault
|
|
103
|
+
hasValue={ () => ! controls }
|
|
104
|
+
onDeselect={ () => {
|
|
105
|
+
setAttributes( { controls: true } );
|
|
106
|
+
} }
|
|
107
|
+
>
|
|
108
|
+
<ToggleControl
|
|
109
|
+
__nextHasNoMarginBottom
|
|
110
|
+
label={ __( 'Playback controls' ) }
|
|
111
|
+
onChange={ toggleFactory.controls }
|
|
112
|
+
checked={ !! controls }
|
|
113
|
+
/>
|
|
114
|
+
</ToolsPanelItem>
|
|
115
|
+
<ToolsPanelItem
|
|
78
116
|
label={ __( 'Play inline' ) }
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
117
|
+
isShownByDefault
|
|
118
|
+
hasValue={ () => !! playsInline }
|
|
119
|
+
onDeselect={ () => {
|
|
120
|
+
setAttributes( { playsInline: false } );
|
|
121
|
+
} }
|
|
122
|
+
>
|
|
123
|
+
<ToggleControl
|
|
124
|
+
__nextHasNoMarginBottom
|
|
125
|
+
/* translators: Setting to play videos within the webpage on mobile browsers rather than opening in a fullscreen player. */
|
|
126
|
+
label={ __( 'Play inline' ) }
|
|
127
|
+
onChange={ toggleFactory.playsInline }
|
|
128
|
+
checked={ playsInline }
|
|
129
|
+
help={ __(
|
|
130
|
+
'When enabled, videos will play directly within the webpage on mobile browsers, instead of opening in a fullscreen player.'
|
|
131
|
+
) }
|
|
132
|
+
/>
|
|
133
|
+
</ToolsPanelItem>
|
|
134
|
+
<ToolsPanelItem
|
|
88
135
|
label={ __( 'Preload' ) }
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
136
|
+
isShownByDefault
|
|
137
|
+
hasValue={ () => preload !== 'metadata' }
|
|
138
|
+
onDeselect={ () => {
|
|
139
|
+
setAttributes( { preload: 'metadata' } );
|
|
140
|
+
} }
|
|
141
|
+
>
|
|
142
|
+
<SelectControl
|
|
143
|
+
__next40pxDefaultSize
|
|
144
|
+
__nextHasNoMarginBottom
|
|
145
|
+
label={ __( 'Preload' ) }
|
|
146
|
+
value={ preload }
|
|
147
|
+
onChange={ onChangePreload }
|
|
148
|
+
options={ options }
|
|
149
|
+
hideCancelButton
|
|
150
|
+
/>
|
|
151
|
+
</ToolsPanelItem>
|
|
94
152
|
</>
|
|
95
153
|
);
|
|
96
154
|
};
|
package/src/video/edit.js
CHANGED
|
@@ -8,25 +8,21 @@ import clsx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
import { isBlobURL } from '@wordpress/blob';
|
|
10
10
|
import {
|
|
11
|
-
BaseControl,
|
|
12
|
-
Button,
|
|
13
11
|
Disabled,
|
|
14
|
-
PanelBody,
|
|
15
12
|
Spinner,
|
|
16
13
|
Placeholder,
|
|
14
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
17
15
|
} from '@wordpress/components';
|
|
18
16
|
import {
|
|
19
17
|
BlockControls,
|
|
20
18
|
BlockIcon,
|
|
21
19
|
InspectorControls,
|
|
22
20
|
MediaPlaceholder,
|
|
23
|
-
MediaUpload,
|
|
24
|
-
MediaUploadCheck,
|
|
25
21
|
MediaReplaceFlow,
|
|
26
22
|
useBlockProps,
|
|
27
23
|
} from '@wordpress/block-editor';
|
|
28
24
|
import { useRef, useEffect, useState } from '@wordpress/element';
|
|
29
|
-
import { __
|
|
25
|
+
import { __ } from '@wordpress/i18n';
|
|
30
26
|
import { useInstanceId } from '@wordpress/compose';
|
|
31
27
|
import { useDispatch } from '@wordpress/data';
|
|
32
28
|
import { video as icon } from '@wordpress/icons';
|
|
@@ -35,15 +31,18 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
35
31
|
/**
|
|
36
32
|
* Internal dependencies
|
|
37
33
|
*/
|
|
34
|
+
import PosterImage from './poster-image';
|
|
38
35
|
import { createUpgradedEmbedBlock } from '../embed/util';
|
|
39
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
useUploadMediaFromBlobURL,
|
|
38
|
+
useToolsPanelDropdownMenuProps,
|
|
39
|
+
} from '../utils/hooks';
|
|
40
40
|
import VideoCommonSettings from './edit-common-settings';
|
|
41
41
|
import TracksEditor from './tracks-editor';
|
|
42
42
|
import Tracks from './tracks';
|
|
43
43
|
import { Caption } from '../utils/caption';
|
|
44
44
|
|
|
45
45
|
const ALLOWED_MEDIA_TYPES = [ 'video' ];
|
|
46
|
-
const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
47
46
|
|
|
48
47
|
function VideoEdit( {
|
|
49
48
|
isSelected: isSingleSelected,
|
|
@@ -55,9 +54,9 @@ function VideoEdit( {
|
|
|
55
54
|
} ) {
|
|
56
55
|
const instanceId = useInstanceId( VideoEdit );
|
|
57
56
|
const videoPlayer = useRef();
|
|
58
|
-
const posterImageButton = useRef();
|
|
59
57
|
const { id, controls, poster, src, tracks } = attributes;
|
|
60
58
|
const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
|
|
59
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
61
60
|
|
|
62
61
|
useUploadMediaFromBlobURL( {
|
|
63
62
|
url: temporaryURL,
|
|
@@ -174,19 +173,6 @@ function VideoEdit( {
|
|
|
174
173
|
);
|
|
175
174
|
}
|
|
176
175
|
|
|
177
|
-
function onSelectPoster( image ) {
|
|
178
|
-
setAttributes( { poster: image.url } );
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function onRemovePoster() {
|
|
182
|
-
setAttributes( { poster: undefined } );
|
|
183
|
-
|
|
184
|
-
// Move focus back to the Media Upload button.
|
|
185
|
-
posterImageButton.current.focus();
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;
|
|
189
|
-
|
|
190
176
|
return (
|
|
191
177
|
<>
|
|
192
178
|
{ isSingleSelected && (
|
|
@@ -214,63 +200,31 @@ function VideoEdit( {
|
|
|
214
200
|
</>
|
|
215
201
|
) }
|
|
216
202
|
<InspectorControls>
|
|
217
|
-
<
|
|
203
|
+
<ToolsPanel
|
|
204
|
+
label={ __( 'Settings' ) }
|
|
205
|
+
resetAll={ () => {
|
|
206
|
+
setAttributes( {
|
|
207
|
+
autoplay: false,
|
|
208
|
+
controls: true,
|
|
209
|
+
loop: false,
|
|
210
|
+
muted: false,
|
|
211
|
+
playsInline: false,
|
|
212
|
+
preload: 'metadata',
|
|
213
|
+
poster: '',
|
|
214
|
+
} );
|
|
215
|
+
} }
|
|
216
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
217
|
+
>
|
|
218
218
|
<VideoCommonSettings
|
|
219
219
|
setAttributes={ setAttributes }
|
|
220
220
|
attributes={ attributes }
|
|
221
221
|
/>
|
|
222
|
-
<
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
title={ __( 'Select poster image' ) }
|
|
229
|
-
onSelect={ onSelectPoster }
|
|
230
|
-
allowedTypes={
|
|
231
|
-
VIDEO_POSTER_ALLOWED_MEDIA_TYPES
|
|
232
|
-
}
|
|
233
|
-
render={ ( { open } ) => (
|
|
234
|
-
<Button
|
|
235
|
-
__next40pxDefaultSize
|
|
236
|
-
variant="primary"
|
|
237
|
-
onClick={ open }
|
|
238
|
-
ref={ posterImageButton }
|
|
239
|
-
aria-describedby={
|
|
240
|
-
videoPosterDescription
|
|
241
|
-
}
|
|
242
|
-
>
|
|
243
|
-
{ ! poster
|
|
244
|
-
? __( 'Select' )
|
|
245
|
-
: __( 'Replace' ) }
|
|
246
|
-
</Button>
|
|
247
|
-
) }
|
|
248
|
-
/>
|
|
249
|
-
<p id={ videoPosterDescription } hidden>
|
|
250
|
-
{ poster
|
|
251
|
-
? sprintf(
|
|
252
|
-
/* translators: %s: poster image URL. */
|
|
253
|
-
__(
|
|
254
|
-
'The current poster image url is %s'
|
|
255
|
-
),
|
|
256
|
-
poster
|
|
257
|
-
)
|
|
258
|
-
: __(
|
|
259
|
-
'There is no poster image currently selected'
|
|
260
|
-
) }
|
|
261
|
-
</p>
|
|
262
|
-
{ !! poster && (
|
|
263
|
-
<Button
|
|
264
|
-
__next40pxDefaultSize
|
|
265
|
-
onClick={ onRemovePoster }
|
|
266
|
-
variant="tertiary"
|
|
267
|
-
>
|
|
268
|
-
{ __( 'Remove' ) }
|
|
269
|
-
</Button>
|
|
270
|
-
) }
|
|
271
|
-
</div>
|
|
272
|
-
</MediaUploadCheck>
|
|
273
|
-
</PanelBody>
|
|
222
|
+
<PosterImage
|
|
223
|
+
poster={ poster }
|
|
224
|
+
setAttributes={ setAttributes }
|
|
225
|
+
instanceId={ instanceId }
|
|
226
|
+
/>
|
|
227
|
+
</ToolsPanel>
|
|
274
228
|
</InspectorControls>
|
|
275
229
|
<figure { ...blockProps }>
|
|
276
230
|
{ /*
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
BaseControl,
|
|
8
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
11
|
+
import { useRef } from '@wordpress/element';
|
|
12
|
+
|
|
13
|
+
function PosterImage( { poster, setAttributes, instanceId } ) {
|
|
14
|
+
const posterImageButton = useRef();
|
|
15
|
+
const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
16
|
+
|
|
17
|
+
const videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;
|
|
18
|
+
|
|
19
|
+
function onSelectPoster( image ) {
|
|
20
|
+
setAttributes( { poster: image.url } );
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function onRemovePoster() {
|
|
24
|
+
setAttributes( { poster: undefined } );
|
|
25
|
+
|
|
26
|
+
// Move focus back to the Media Upload button.
|
|
27
|
+
posterImageButton.current.focus();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<ToolsPanelItem
|
|
32
|
+
label={ __( 'Poster image' ) }
|
|
33
|
+
isShownByDefault
|
|
34
|
+
hasValue={ () => !! poster }
|
|
35
|
+
onDeselect={ () => {
|
|
36
|
+
setAttributes( { poster: '' } );
|
|
37
|
+
} }
|
|
38
|
+
>
|
|
39
|
+
<MediaUploadCheck>
|
|
40
|
+
<div className="editor-video-poster-control">
|
|
41
|
+
<BaseControl.VisualLabel>
|
|
42
|
+
{ __( 'Poster image' ) }
|
|
43
|
+
</BaseControl.VisualLabel>
|
|
44
|
+
<MediaUpload
|
|
45
|
+
title={ __( 'Select poster image' ) }
|
|
46
|
+
onSelect={ onSelectPoster }
|
|
47
|
+
allowedTypes={ VIDEO_POSTER_ALLOWED_MEDIA_TYPES }
|
|
48
|
+
render={ ( { open } ) => (
|
|
49
|
+
<Button
|
|
50
|
+
__next40pxDefaultSize
|
|
51
|
+
variant="primary"
|
|
52
|
+
onClick={ open }
|
|
53
|
+
ref={ posterImageButton }
|
|
54
|
+
aria-describedby={ videoPosterDescription }
|
|
55
|
+
>
|
|
56
|
+
{ ! poster ? __( 'Select' ) : __( 'Replace' ) }
|
|
57
|
+
</Button>
|
|
58
|
+
) }
|
|
59
|
+
/>
|
|
60
|
+
<p id={ videoPosterDescription } hidden>
|
|
61
|
+
{ poster
|
|
62
|
+
? sprintf(
|
|
63
|
+
/* translators: %s: poster image URL. */
|
|
64
|
+
__( 'The current poster image url is %s' ),
|
|
65
|
+
poster
|
|
66
|
+
)
|
|
67
|
+
: __(
|
|
68
|
+
'There is no poster image currently selected'
|
|
69
|
+
) }
|
|
70
|
+
</p>
|
|
71
|
+
{ !! poster && (
|
|
72
|
+
<Button
|
|
73
|
+
__next40pxDefaultSize
|
|
74
|
+
onClick={ onRemovePoster }
|
|
75
|
+
variant="tertiary"
|
|
76
|
+
>
|
|
77
|
+
{ __( 'Remove' ) }
|
|
78
|
+
</Button>
|
|
79
|
+
) }
|
|
80
|
+
</div>
|
|
81
|
+
</MediaUploadCheck>
|
|
82
|
+
</ToolsPanelItem>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default PosterImage;
|
package/tsconfig.json
CHANGED