@wordpress/block-library 10.1.1-next.v.202607070741.0 → 10.2.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 +9 -0
- package/build/accordion/block.json +1 -0
- package/build/button/edit.cjs +18 -8
- package/build/button/edit.cjs.map +2 -2
- package/build/cover/block.json +11 -0
- package/build/cover/edit/block-controls.cjs +11 -4
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/embed-video-url-input.cjs +5 -3
- package/build/cover/edit/embed-video-url-input.cjs.map +3 -3
- package/build/cover/edit/index.cjs +1 -1
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/embed-video-utils.cjs +17 -7
- package/build/cover/embed-video-utils.cjs.map +2 -2
- package/build/details/transforms.cjs +1 -3
- package/build/details/transforms.cjs.map +2 -2
- package/build/embed/embed-placeholder.cjs +0 -1
- package/build/embed/embed-placeholder.cjs.map +2 -2
- package/build/file/edit.cjs +4 -3
- package/build/file/edit.cjs.map +2 -2
- package/build/file/transforms.cjs +25 -60
- package/build/file/transforms.cjs.map +2 -2
- package/build/gallery/block.json +4 -2
- package/build/gallery/edit.cjs +1 -1
- package/build/gallery/edit.cjs.map +3 -3
- package/build/gallery/gap-styles.cjs +49 -13
- package/build/gallery/gap-styles.cjs.map +3 -3
- package/build/group/transforms.cjs +1 -1
- package/build/group/transforms.cjs.map +2 -2
- package/build/icon/components/custom-inserter/icon-grid.cjs +25 -12
- package/build/icon/components/custom-inserter/icon-grid.cjs.map +2 -2
- package/build/icon/components/custom-inserter/index.cjs +100 -31
- package/build/icon/components/custom-inserter/index.cjs.map +3 -3
- package/build/icon/edit.cjs +11 -12
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/block.json +1 -1
- package/build/image/edit.cjs +0 -34
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs +4 -23
- package/build/image/image.cjs.map +3 -3
- package/build/image/transforms.cjs +78 -0
- package/build/image/transforms.cjs.map +3 -3
- package/build/index.cjs +18 -8
- package/build/index.cjs.map +2 -2
- package/build/latest-posts/edit.cjs +5 -8
- package/build/latest-posts/edit.cjs.map +2 -2
- package/build/list-item/edit.cjs +1 -1
- package/build/list-item/edit.cjs.map +2 -2
- package/build/list-item/hooks/use-enter.cjs +14 -17
- package/build/list-item/hooks/use-enter.cjs.map +3 -3
- package/build/list-item/hooks/use-space.cjs +3 -2
- package/build/list-item/hooks/use-space.cjs.map +3 -3
- package/build/paragraph/block.json +1 -0
- package/build/paragraph/use-enter.cjs +3 -7
- package/build/paragraph/use-enter.cjs.map +3 -3
- package/build/playlist/block.json +29 -10
- package/build/playlist/edit.cjs +216 -14
- package/build/playlist/edit.cjs.map +3 -3
- package/build/playlist/index.cjs +1 -1
- package/build/playlist/index.cjs.map +2 -2
- package/build/playlist/utils.cjs +19 -5
- package/build/playlist/utils.cjs.map +2 -2
- package/build/playlist/view.cjs +83 -13
- package/build/playlist/view.cjs.map +2 -2
- package/build/playlist-track/block.json +4 -2
- package/build/playlist-track/edit.cjs +94 -64
- package/build/playlist-track/edit.cjs.map +2 -2
- package/build/post-content/block.json +1 -0
- package/build/post-template/block.json +2 -1
- package/build/post-template/edit.cjs +10 -1
- package/build/post-template/edit.cjs.map +2 -2
- package/build/pullquote/block.json +3 -1
- package/build/query/block.json +3 -2
- package/build/query/edit/inspector-controls/index.cjs +38 -4
- package/build/query/edit/inspector-controls/index.cjs.map +2 -2
- package/build/query/edit/inspector-controls/offset-controls.cjs +0 -1
- package/build/query/edit/inspector-controls/offset-controls.cjs.map +2 -2
- package/build/query/edit/inspector-controls/pages-control.cjs +0 -1
- package/build/query/edit/inspector-controls/pages-control.cjs.map +2 -2
- package/build/query/edit/query-content.cjs +10 -3
- package/build/query/edit/query-content.cjs.map +2 -2
- package/build/query/index.cjs +2 -1
- package/build/query/index.cjs.map +2 -2
- package/build/quote/block.json +3 -1
- package/build/quote/transforms.cjs +1 -3
- package/build/quote/transforms.cjs.map +2 -2
- package/build/rss/edit.cjs +0 -1
- package/build/rss/edit.cjs.map +2 -2
- package/build/tab-list/block.json +2 -2
- package/build/tab-list/edit.cjs +65 -11
- package/build/tab-list/edit.cjs.map +3 -3
- package/build/tab-panel/block.json +1 -6
- package/build/tab-panel/edit.cjs +15 -15
- package/build/tab-panel/edit.cjs.map +2 -2
- package/build/tab-panels/block.json +0 -1
- package/build/tabs/block.json +0 -5
- package/build/tabs/edit.cjs +4 -39
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/use-tab-list-items-sync.cjs +19 -1
- package/build/tabs/use-tab-list-items-sync.cjs.map +2 -2
- package/build/term-name/block.json +1 -3
- package/build/term-name/deprecated.cjs +105 -0
- package/build/term-name/deprecated.cjs.map +7 -0
- package/build/term-name/edit.cjs +11 -37
- package/build/term-name/edit.cjs.map +3 -3
- package/build/term-name/index.cjs +3 -1
- package/build/term-name/index.cjs.map +3 -3
- package/build/utils/waveform-player.cjs +138 -22
- package/build/utils/waveform-player.cjs.map +2 -2
- package/build/utils/waveform-utils.cjs +315 -17
- package/build/utils/waveform-utils.cjs.map +2 -2
- package/build/video/edit.cjs +2 -11
- package/build/video/edit.cjs.map +3 -3
- package/build-module/accordion/block.json +1 -0
- package/build-module/button/edit.mjs +19 -14
- package/build-module/button/edit.mjs.map +2 -2
- package/build-module/cover/block.json +11 -0
- package/build-module/cover/edit/block-controls.mjs +11 -4
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.mjs +5 -4
- package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +1 -1
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/embed-video-utils.mjs +16 -7
- package/build-module/cover/embed-video-utils.mjs.map +2 -2
- package/build-module/details/transforms.mjs +2 -7
- package/build-module/details/transforms.mjs.map +2 -2
- package/build-module/embed/embed-placeholder.mjs +0 -1
- package/build-module/embed/embed-placeholder.mjs.map +2 -2
- package/build-module/file/edit.mjs +4 -3
- package/build-module/file/edit.mjs.map +2 -2
- package/build-module/file/transforms.mjs +25 -60
- package/build-module/file/transforms.mjs.map +2 -2
- package/build-module/gallery/block.json +4 -2
- package/build-module/gallery/edit.mjs +3 -3
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/gallery/gap-styles.mjs +53 -14
- package/build-module/gallery/gap-styles.mjs.map +2 -2
- package/build-module/group/transforms.mjs +2 -5
- package/build-module/group/transforms.mjs.map +2 -2
- package/build-module/icon/components/custom-inserter/icon-grid.mjs +25 -12
- package/build-module/icon/components/custom-inserter/icon-grid.mjs.map +2 -2
- package/build-module/icon/components/custom-inserter/index.mjs +102 -33
- package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
- package/build-module/icon/edit.mjs +11 -12
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/block.json +1 -1
- package/build-module/image/edit.mjs +0 -34
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +4 -13
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/image/transforms.mjs +78 -0
- package/build-module/image/transforms.mjs.map +2 -2
- package/build-module/index.mjs +18 -8
- package/build-module/index.mjs.map +2 -2
- package/build-module/latest-posts/edit.mjs +5 -8
- package/build-module/latest-posts/edit.mjs.map +2 -2
- package/build-module/list-item/edit.mjs +1 -1
- package/build-module/list-item/edit.mjs.map +2 -2
- package/build-module/list-item/hooks/use-enter.mjs +15 -21
- package/build-module/list-item/hooks/use-enter.mjs.map +2 -2
- package/build-module/list-item/hooks/use-space.mjs +4 -6
- package/build-module/list-item/hooks/use-space.mjs.map +2 -2
- package/build-module/paragraph/block.json +1 -0
- package/build-module/paragraph/use-enter.mjs +4 -11
- package/build-module/paragraph/use-enter.mjs.map +2 -2
- package/build-module/playlist/block.json +29 -10
- package/build-module/playlist/edit.mjs +220 -16
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/playlist/index.mjs +1 -1
- package/build-module/playlist/index.mjs.map +2 -2
- package/build-module/playlist/utils.mjs +17 -4
- package/build-module/playlist/utils.mjs.map +2 -2
- package/build-module/playlist/view.mjs +89 -14
- package/build-module/playlist/view.mjs.map +2 -2
- package/build-module/playlist-track/block.json +4 -2
- package/build-module/playlist-track/edit.mjs +96 -65
- package/build-module/playlist-track/edit.mjs.map +2 -2
- package/build-module/post-content/block.json +1 -0
- package/build-module/post-template/block.json +2 -1
- package/build-module/post-template/edit.mjs +10 -1
- package/build-module/post-template/edit.mjs.map +2 -2
- package/build-module/pullquote/block.json +3 -1
- package/build-module/query/block.json +3 -2
- package/build-module/query/edit/inspector-controls/index.mjs +40 -5
- package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/offset-controls.mjs +0 -1
- package/build-module/query/edit/inspector-controls/offset-controls.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/pages-control.mjs +0 -1
- package/build-module/query/edit/inspector-controls/pages-control.mjs.map +2 -2
- package/build-module/query/edit/query-content.mjs +10 -3
- package/build-module/query/edit/query-content.mjs.map +2 -2
- package/build-module/query/index.mjs +2 -1
- package/build-module/query/index.mjs.map +2 -2
- package/build-module/quote/block.json +3 -1
- package/build-module/quote/transforms.mjs +2 -4
- package/build-module/quote/transforms.mjs.map +2 -2
- package/build-module/rss/edit.mjs +0 -1
- package/build-module/rss/edit.mjs.map +2 -2
- package/build-module/tab-list/block.json +2 -2
- package/build-module/tab-list/edit.mjs +72 -13
- package/build-module/tab-list/edit.mjs.map +2 -2
- package/build-module/tab-panel/block.json +1 -6
- package/build-module/tab-panel/edit.mjs +16 -16
- package/build-module/tab-panel/edit.mjs.map +2 -2
- package/build-module/tab-panels/block.json +0 -1
- package/build-module/tabs/block.json +0 -5
- package/build-module/tabs/edit.mjs +5 -45
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/use-tab-list-items-sync.mjs +19 -1
- package/build-module/tabs/use-tab-list-items-sync.mjs.map +2 -2
- package/build-module/term-name/block.json +1 -3
- package/build-module/term-name/deprecated.mjs +74 -0
- package/build-module/term-name/deprecated.mjs.map +7 -0
- package/build-module/term-name/edit.mjs +11 -28
- package/build-module/term-name/edit.mjs.map +2 -2
- package/build-module/term-name/index.mjs +3 -1
- package/build-module/term-name/index.mjs.map +2 -2
- package/build-module/utils/waveform-player.mjs +144 -23
- package/build-module/utils/waveform-player.mjs.map +2 -2
- package/build-module/utils/waveform-utils.mjs +310 -16
- package/build-module/utils/waveform-utils.mjs.map +2 -2
- package/build-module/video/edit.mjs +2 -11
- package/build-module/video/edit.mjs.map +2 -2
- package/build-style/editor-rtl.css +46 -21
- package/build-style/editor.css +46 -21
- package/build-style/icon/editor-rtl.css +80 -7
- package/build-style/icon/editor.css +80 -7
- package/build-style/more/editor-rtl.css +2 -2
- package/build-style/more/editor.css +2 -2
- package/build-style/navigation/editor-rtl.css +3 -4
- package/build-style/navigation/editor.css +3 -4
- package/build-style/navigation-link/editor-rtl.css +1 -1
- package/build-style/navigation-link/editor.css +1 -1
- package/build-style/nextpage/editor-rtl.css +2 -2
- package/build-style/nextpage/editor.css +2 -2
- package/build-style/playlist/editor-rtl.css +6 -0
- package/build-style/playlist/editor.css +6 -0
- package/build-style/playlist/style-rtl.css +37 -1
- package/build-style/playlist/style.css +37 -1
- package/build-style/playlist-track/style-rtl.css +10 -0
- package/build-style/playlist-track/style.css +10 -0
- package/build-style/style-rtl.css +47 -1
- package/build-style/style.css +47 -1
- package/build-style/video/editor-rtl.css +1 -1
- package/build-style/video/editor.css +1 -1
- package/build-types/table-of-contents/list.d.ts +1 -1
- package/build-types/table-of-contents/list.d.ts.map +1 -1
- package/package.json +46 -44
- package/src/accordion/README.md +1 -0
- package/src/accordion/block.json +1 -0
- package/src/button/edit.js +21 -15
- package/src/cover/README.md +60 -0
- package/src/cover/block.json +11 -0
- package/src/cover/edit/block-controls.js +21 -11
- package/src/cover/edit/embed-video-url-input.js +5 -4
- package/src/cover/edit/index.js +9 -11
- package/src/cover/embed-video-utils.js +38 -13
- package/src/details/transforms.js +2 -7
- package/src/embed/embed-placeholder.js +0 -1
- package/src/file/edit.js +8 -8
- package/src/file/transforms.js +28 -60
- package/src/gallery/README.md +1 -1
- package/src/gallery/block.json +4 -2
- package/src/gallery/edit.js +3 -3
- package/src/gallery/gap-styles.js +79 -20
- package/src/gallery/index.php +103 -43
- package/src/group/transforms.js +2 -5
- package/src/icon/components/custom-inserter/icon-grid.js +40 -11
- package/src/icon/components/custom-inserter/index.js +98 -25
- package/src/icon/edit.js +11 -17
- package/src/icon/editor.scss +33 -8
- package/src/image/README.md +1 -1
- package/src/image/block.json +1 -1
- package/src/image/edit.js +0 -52
- package/src/image/editor.scss +2 -0
- package/src/image/image.js +19 -24
- package/src/image/transforms.js +128 -0
- package/src/index.js +19 -7
- package/src/latest-posts/edit.js +5 -8
- package/src/latest-posts/index.php +46 -16
- package/src/list-item/edit.js +1 -1
- package/src/list-item/hooks/use-enter.js +15 -22
- package/src/list-item/hooks/use-space.js +4 -6
- package/src/media-text/editor.scss +1 -0
- package/src/more/editor.scss +1 -1
- package/src/navigation/editor.scss +1 -2
- package/src/navigation-link/editor.scss +1 -1
- package/src/navigation-link/index.php +6 -3
- package/src/navigation-submenu/index.php +6 -3
- package/src/nextpage/editor.scss +1 -1
- package/src/paragraph/README.md +1 -0
- package/src/paragraph/block.json +1 -0
- package/src/paragraph/use-enter.js +4 -11
- package/src/playlist/README.md +17 -18
- package/src/playlist/block.json +29 -10
- package/src/playlist/edit.js +247 -15
- package/src/playlist/editor.scss +6 -0
- package/src/playlist/index.js +1 -1
- package/src/playlist/index.php +58 -14
- package/src/playlist/style.scss +51 -1
- package/src/playlist/test/edit.js +13 -2
- package/src/playlist/utils.js +25 -7
- package/src/playlist/view.js +97 -16
- package/src/playlist-track/README.md +3 -3
- package/src/playlist-track/block.json +4 -2
- package/src/playlist-track/edit.js +94 -70
- package/src/playlist-track/index.php +20 -6
- package/src/playlist-track/style.scss +10 -0
- package/src/playlist-track/test/edit.js +169 -0
- package/src/post-content/README.md +1 -0
- package/src/post-content/block.json +1 -0
- package/src/post-template/README.md +1 -0
- package/src/post-template/block.json +2 -1
- package/src/post-template/edit.js +9 -0
- package/src/pullquote/README.md +1 -0
- package/src/pullquote/block.json +3 -1
- package/src/query/README.md +2 -1
- package/src/query/block.json +3 -2
- package/src/query/edit/inspector-controls/index.js +43 -3
- package/src/query/edit/inspector-controls/offset-controls.js +0 -1
- package/src/query/edit/inspector-controls/pages-control.js +0 -1
- package/src/query/edit/query-content.js +19 -3
- package/src/query/index.js +1 -0
- package/src/quote/README.md +1 -0
- package/src/quote/block.json +3 -1
- package/src/quote/transforms.js +2 -4
- package/src/rss/edit.js +0 -1
- package/src/rss/index.php +1 -1
- package/src/tab-list/README.md +4 -5
- package/src/tab-list/block.json +2 -2
- package/src/tab-list/edit.js +90 -28
- package/src/tab-list/index.php +9 -4
- package/src/tab-panel/README.md +4 -6
- package/src/tab-panel/block.json +1 -6
- package/src/tab-panel/edit.js +19 -24
- package/src/tab-panels/README.md +5 -3
- package/src/tab-panels/block.json +0 -1
- package/src/tabs/README.md +18 -9
- package/src/tabs/block.json +0 -5
- package/src/tabs/edit.js +7 -64
- package/src/tabs/use-tab-list-items-sync.js +24 -4
- package/src/template-part/index.php +1 -16
- package/src/term-name/README.md +1 -1
- package/src/term-name/block.json +1 -3
- package/src/term-name/deprecated.js +74 -0
- package/src/term-name/edit.js +2 -18
- package/src/term-name/index.js +2 -0
- package/src/utils/media-control.scss +1 -5
- package/src/utils/test/waveform-player.js +297 -34
- package/src/utils/test/waveform-utils.js +410 -5
- package/src/utils/waveform-player.js +189 -59
- package/src/utils/waveform-utils.js +443 -40
- package/src/video/edit.js +0 -8
- package/src/video/editor.scss +1 -1
- package/build/image/animated-gif-convert-control.cjs +0 -105
- package/build/image/animated-gif-convert-control.cjs.map +0 -7
- package/build/utils/gif-conversion-attributes.cjs +0 -40
- package/build/utils/gif-conversion-attributes.cjs.map +0 -7
- package/build/video/gif-restore-control.cjs +0 -73
- package/build/video/gif-restore-control.cjs.map +0 -7
- package/build-module/image/animated-gif-convert-control.mjs +0 -87
- package/build-module/image/animated-gif-convert-control.mjs.map +0 -7
- package/build-module/utils/gif-conversion-attributes.mjs +0 -15
- package/build-module/utils/gif-conversion-attributes.mjs.map +0 -7
- package/build-module/video/gif-restore-control.mjs +0 -55
- package/build-module/video/gif-restore-control.mjs.map +0 -7
- package/src/image/animated-gif-convert-control.js +0 -135
- package/src/image/test/animated-gif-convert-control.js +0 -276
- package/src/utils/gif-conversion-attributes.js +0 -30
- package/src/utils/test/gif-conversion-attributes.js +0 -60
- package/src/video/gif-restore-control.js +0 -92
package/build/playlist/view.cjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
var import_interactivity = require("@wordpress/interactivity");
|
|
5
5
|
var import_waveform_utils = require("../utils/waveform-utils.cjs");
|
|
6
6
|
var playerState = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
var playlistPlayerState = /* @__PURE__ */ new Map();
|
|
7
8
|
var { state } = (0, import_interactivity.store)(
|
|
8
9
|
"core/playlist",
|
|
9
10
|
{
|
|
@@ -12,11 +13,32 @@ var { state } = (0, import_interactivity.store)(
|
|
|
12
13
|
get isCurrentTrack() {
|
|
13
14
|
const { currentId, trackId } = (0, import_interactivity.getContext)();
|
|
14
15
|
return currentId === trackId;
|
|
16
|
+
},
|
|
17
|
+
get isCurrentTrackPlaying() {
|
|
18
|
+
const { currentId, isPlaying, trackId } = (0, import_interactivity.getContext)();
|
|
19
|
+
return currentId === trackId && !!isPlaying;
|
|
20
|
+
},
|
|
21
|
+
get trackButtonActionLabel() {
|
|
22
|
+
const { labelPauseTrack, labelSelectTrack } = (0, import_interactivity.getContext)();
|
|
23
|
+
return state.isCurrentTrackPlaying ? labelPauseTrack : labelSelectTrack;
|
|
15
24
|
}
|
|
16
25
|
},
|
|
17
26
|
actions: {
|
|
18
27
|
changeTrack() {
|
|
19
28
|
const context = (0, import_interactivity.getContext)();
|
|
29
|
+
if (context.currentId === context.trackId) {
|
|
30
|
+
const player = playlistPlayerState.get(
|
|
31
|
+
context.playlistId
|
|
32
|
+
)?.instance;
|
|
33
|
+
if (player?.isPlaying) {
|
|
34
|
+
context.isPlaying = false;
|
|
35
|
+
player.pause();
|
|
36
|
+
} else {
|
|
37
|
+
player?.play()?.catch(import_waveform_utils.logPlayError);
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
context.isPlaying = false;
|
|
20
42
|
context.currentId = context.trackId;
|
|
21
43
|
}
|
|
22
44
|
},
|
|
@@ -44,29 +66,60 @@ var { state } = (0, import_interactivity.store)(
|
|
|
44
66
|
);
|
|
45
67
|
function initPlayer(ref, track, shouldAutoPlay, context) {
|
|
46
68
|
const existing = playerState.get(ref);
|
|
69
|
+
const showPlayButtonArtwork = context.showPlayButtonArtwork === true;
|
|
70
|
+
const playerArtwork = showPlayButtonArtwork ? "" : track.image;
|
|
47
71
|
if (existing?.instance) {
|
|
48
|
-
existing.instance.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
const shouldRecreatePlayer = !!existing.instance.artworkEl !== !!playerArtwork;
|
|
73
|
+
if (shouldRecreatePlayer) {
|
|
74
|
+
existing.destroy?.();
|
|
75
|
+
playerState.delete(ref);
|
|
76
|
+
} else {
|
|
77
|
+
playlistPlayerState.set(context.playlistId, existing);
|
|
78
|
+
existing.instance.loadTrack(track.url, track.title, track.artist, {
|
|
79
|
+
artwork: playerArtwork,
|
|
80
|
+
artworkAlt: playerArtwork ? track.imageAlt : ""
|
|
81
|
+
}).then(() => {
|
|
82
|
+
existing.url = track.url;
|
|
83
|
+
if (existing.instance.artworkEl) {
|
|
84
|
+
existing.instance.artworkEl.alt = track.imageAlt || "";
|
|
85
|
+
}
|
|
86
|
+
(0, import_waveform_utils.updateSeekControlLabel)(
|
|
87
|
+
existing.instance,
|
|
88
|
+
track.title || ref.dataset.labelSeek
|
|
89
|
+
);
|
|
90
|
+
if (showPlayButtonArtwork) {
|
|
91
|
+
(0, import_waveform_utils.setupPlayButtonArtwork)(
|
|
92
|
+
existing.container,
|
|
93
|
+
track.image
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (shouldAutoPlay) {
|
|
97
|
+
existing.instance.play()?.catch(import_waveform_utils.logPlayError);
|
|
98
|
+
}
|
|
99
|
+
}).catch(import_waveform_utils.logPlayError);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
57
102
|
}
|
|
58
103
|
const labels = {
|
|
59
104
|
play: ref.dataset.labelPlay,
|
|
60
|
-
pause: ref.dataset.labelPause
|
|
105
|
+
pause: ref.dataset.labelPause,
|
|
106
|
+
seek: ref.dataset.labelSeek,
|
|
107
|
+
seekValueText: ref.dataset.labelSeekValue
|
|
61
108
|
};
|
|
62
109
|
const player = (0, import_waveform_utils.initWaveformPlayer)(ref, {
|
|
63
110
|
src: track.url,
|
|
64
111
|
title: track.title,
|
|
65
112
|
artist: track.artist,
|
|
66
113
|
image: track.image,
|
|
114
|
+
imageAlt: track.imageAlt,
|
|
115
|
+
waveformColor: ref.dataset.waveformPlayerColor,
|
|
116
|
+
waveformGradient: ref.dataset.waveformPlayerGradient,
|
|
117
|
+
backgroundColor: ref.dataset.waveformPlayerBackgroundColor,
|
|
118
|
+
backgroundGradient: ref.dataset.waveformPlayerBackgroundGradient,
|
|
67
119
|
autoPlay: shouldAutoPlay,
|
|
68
120
|
labels,
|
|
69
121
|
waveformStyle: context.waveformStyle,
|
|
122
|
+
showPlayButtonArtwork,
|
|
70
123
|
onEnded: () => {
|
|
71
124
|
const currentIndex = context.tracks.findIndex(
|
|
72
125
|
(trackId) => trackId === context.currentId
|
|
@@ -77,10 +130,27 @@ function initPlayer(ref, track, shouldAutoPlay, context) {
|
|
|
77
130
|
}
|
|
78
131
|
}
|
|
79
132
|
});
|
|
80
|
-
|
|
133
|
+
const setIsPlaying = (isPlaying) => {
|
|
134
|
+
context.isPlaying = isPlaying;
|
|
135
|
+
};
|
|
136
|
+
const onPlay = () => setIsPlaying(true);
|
|
137
|
+
const onPause = () => setIsPlaying(false);
|
|
138
|
+
player.container.addEventListener("waveformplayer:play", onPlay);
|
|
139
|
+
player.container.addEventListener("waveformplayer:pause", onPause);
|
|
140
|
+
player.container.addEventListener("waveformplayer:ended", onPause);
|
|
141
|
+
const destroy = () => {
|
|
142
|
+
player.container.removeEventListener("waveformplayer:play", onPlay);
|
|
143
|
+
player.container.removeEventListener("waveformplayer:pause", onPause);
|
|
144
|
+
player.container.removeEventListener("waveformplayer:ended", onPause);
|
|
145
|
+
player.destroy();
|
|
146
|
+
};
|
|
147
|
+
const nextState = {
|
|
81
148
|
url: track.url,
|
|
82
149
|
instance: player.instance,
|
|
83
|
-
|
|
84
|
-
|
|
150
|
+
container: player.container,
|
|
151
|
+
destroy
|
|
152
|
+
};
|
|
153
|
+
playerState.set(ref, nextState);
|
|
154
|
+
playlistPlayerState.set(context.playlistId, nextState);
|
|
85
155
|
}
|
|
86
156
|
//# sourceMappingURL=view.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/playlist/view.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;AAGA,2BAA8C;AAK9C,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\n/**\n * Internal dependencies\n */\nimport {\n\tinitWaveformPlayer,\n\tlogPlayError,\n\tsetupPlayButtonArtwork,\n\tupdateSeekControlLabel,\n} from '../utils/waveform-utils';\n\n/**\n * Store player state for each element.\n */\nconst playerState = new WeakMap();\nconst playlistPlayerState = new Map();\n\nconst { state } = store(\n\t'core/playlist',\n\t{\n\t\tstate: {\n\t\t\tplaylists: {},\n\t\t\tget isCurrentTrack() {\n\t\t\t\tconst { currentId, trackId } = getContext();\n\t\t\t\treturn currentId === trackId;\n\t\t\t},\n\t\t\tget isCurrentTrackPlaying() {\n\t\t\t\tconst { currentId, isPlaying, trackId } = getContext();\n\t\t\t\treturn currentId === trackId && !! isPlaying;\n\t\t\t},\n\t\t\tget trackButtonActionLabel() {\n\t\t\t\tconst { labelPauseTrack, labelSelectTrack } = getContext();\n\t\t\t\treturn state.isCurrentTrackPlaying\n\t\t\t\t\t? labelPauseTrack\n\t\t\t\t\t: labelSelectTrack;\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tchangeTrack() {\n\t\t\t\tconst context = getContext();\n\t\t\t\tif ( context.currentId === context.trackId ) {\n\t\t\t\t\tconst player = playlistPlayerState.get(\n\t\t\t\t\t\tcontext.playlistId\n\t\t\t\t\t)?.instance;\n\t\t\t\t\tif ( player?.isPlaying ) {\n\t\t\t\t\t\tcontext.isPlaying = false;\n\t\t\t\t\t\tplayer.pause();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tplayer?.play()?.catch( logPlayError );\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontext.isPlaying = false;\n\t\t\t\tcontext.currentId = context.trackId;\n\t\t\t},\n\t\t},\n\t\tcallbacks: {\n\t\t\tinitWaveformPlayer() {\n\t\t\t\tconst context = getContext();\n\t\t\t\tconst { ref } = getElement();\n\n\t\t\t\tif ( ! context.currentId || ! ref ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst track =\n\t\t\t\t\tstate.playlists[ context.playlistId ]?.tracks[\n\t\t\t\t\t\tcontext.currentId\n\t\t\t\t\t];\n\t\t\t\tif ( ! track?.url ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst existing = playerState.get( ref );\n\n\t\t\t\t// Skip if we already initialized with this exact URL.\n\t\t\t\tif ( existing?.url === track.url ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Autoplay if we're switching from a different track (user action),\n\t\t\t\t// but not on initial page load (when existing has no URL).\n\t\t\t\tconst shouldAutoPlay = !! existing?.url;\n\n\t\t\t\tinitPlayer( ref, track, shouldAutoPlay, context );\n\t\t\t},\n\t\t},\n\t},\n\t{ lock: true }\n);\n\n/**\n * Initialize the waveform player for a given element.\n *\n * @param {Element} ref - The container element.\n * @param {Object} track - The track data.\n * @param {boolean} shouldAutoPlay - Whether to auto-play after initialization.\n * @param {Object} context - The Interactivity API context.\n */\nfunction initPlayer( ref, track, shouldAutoPlay, context ) {\n\tconst existing = playerState.get( ref );\n\tconst showPlayButtonArtwork = context.showPlayButtonArtwork === true;\n\tconst playerArtwork = showPlayButtonArtwork ? '' : track.image;\n\n\t// If a player already exists, load the new track without recreating.\n\tif ( existing?.instance ) {\n\t\tconst shouldRecreatePlayer =\n\t\t\t!! existing.instance.artworkEl !== !! playerArtwork;\n\n\t\tif ( shouldRecreatePlayer ) {\n\t\t\texisting.destroy?.();\n\t\t\tplayerState.delete( ref );\n\t\t} else {\n\t\t\tplaylistPlayerState.set( context.playlistId, existing );\n\t\t\texisting.instance\n\t\t\t\t.loadTrack( track.url, track.title, track.artist, {\n\t\t\t\t\tartwork: playerArtwork,\n\t\t\t\t\tartworkAlt: playerArtwork ? track.imageAlt : '',\n\t\t\t\t} )\n\t\t\t\t.then( () => {\n\t\t\t\t\texisting.url = track.url;\n\t\t\t\t\tif ( existing.instance.artworkEl ) {\n\t\t\t\t\t\texisting.instance.artworkEl.alt = track.imageAlt || '';\n\t\t\t\t\t}\n\t\t\t\t\t// loadTrack() preserves the previous explicit seekLabel option.\n\t\t\t\t\tupdateSeekControlLabel(\n\t\t\t\t\t\texisting.instance,\n\t\t\t\t\t\ttrack.title || ref.dataset.labelSeek\n\t\t\t\t\t);\n\t\t\t\t\tif ( showPlayButtonArtwork ) {\n\t\t\t\t\t\tsetupPlayButtonArtwork(\n\t\t\t\t\t\t\texisting.container,\n\t\t\t\t\t\t\ttrack.image\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif ( shouldAutoPlay ) {\n\t\t\t\t\t\texisting.instance.play()?.catch( logPlayError );\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t\t.catch( logPlayError );\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// Read translated labels from server-rendered data attributes.\n\tconst labels = {\n\t\tplay: ref.dataset.labelPlay,\n\t\tpause: ref.dataset.labelPause,\n\t\tseek: ref.dataset.labelSeek,\n\t\tseekValueText: ref.dataset.labelSeekValue,\n\t};\n\n\t// Initialize using the shared core.\n\tconst player = initWaveformPlayer( ref, {\n\t\tsrc: track.url,\n\t\ttitle: track.title,\n\t\tartist: track.artist,\n\t\timage: track.image,\n\t\timageAlt: track.imageAlt,\n\t\twaveformColor: ref.dataset.waveformPlayerColor,\n\t\twaveformGradient: ref.dataset.waveformPlayerGradient,\n\t\tbackgroundColor: ref.dataset.waveformPlayerBackgroundColor,\n\t\tbackgroundGradient: ref.dataset.waveformPlayerBackgroundGradient,\n\t\tautoPlay: shouldAutoPlay,\n\t\tlabels,\n\t\twaveformStyle: context.waveformStyle,\n\t\tshowPlayButtonArtwork,\n\t\tonEnded: () => {\n\t\t\t// Advance to next track (autoPlay handles playback).\n\t\t\tconst currentIndex = context.tracks.findIndex(\n\t\t\t\t( trackId ) => trackId === context.currentId\n\t\t\t);\n\t\t\tconst nextTrack = context.tracks[ currentIndex + 1 ];\n\t\t\tif ( nextTrack ) {\n\t\t\t\tcontext.currentId = nextTrack;\n\t\t\t}\n\t\t},\n\t} );\n\tconst setIsPlaying = ( isPlaying ) => {\n\t\tcontext.isPlaying = isPlaying;\n\t};\n\tconst onPlay = () => setIsPlaying( true );\n\tconst onPause = () => setIsPlaying( false );\n\tplayer.container.addEventListener( 'waveformplayer:play', onPlay );\n\tplayer.container.addEventListener( 'waveformplayer:pause', onPause );\n\tplayer.container.addEventListener( 'waveformplayer:ended', onPause );\n\tconst destroy = () => {\n\t\tplayer.container.removeEventListener( 'waveformplayer:play', onPlay );\n\t\tplayer.container.removeEventListener( 'waveformplayer:pause', onPause );\n\t\tplayer.container.removeEventListener( 'waveformplayer:ended', onPause );\n\t\tplayer.destroy();\n\t};\n\n\t// Store state for cleanup, including instance for loadTrack reuse.\n\tconst nextState = {\n\t\turl: track.url,\n\t\tinstance: player.instance,\n\t\tcontainer: player.container,\n\t\tdestroy,\n\t};\n\tplayerState.set( ref, nextState );\n\tplaylistPlayerState.set( context.playlistId, nextState );\n}\n"],
|
|
5
|
+
"mappings": ";;;AAGA,2BAA8C;AAK9C,4BAKO;AAKP,IAAM,cAAc,oBAAI,QAAQ;AAChC,IAAM,sBAAsB,oBAAI,IAAI;AAEpC,IAAM,EAAE,MAAM,QAAI;AAAA,EACjB;AAAA,EACA;AAAA,IACC,OAAO;AAAA,MACN,WAAW,CAAC;AAAA,MACZ,IAAI,iBAAiB;AACpB,cAAM,EAAE,WAAW,QAAQ,QAAI,iCAAW;AAC1C,eAAO,cAAc;AAAA,MACtB;AAAA,MACA,IAAI,wBAAwB;AAC3B,cAAM,EAAE,WAAW,WAAW,QAAQ,QAAI,iCAAW;AACrD,eAAO,cAAc,WAAW,CAAC,CAAE;AAAA,MACpC;AAAA,MACA,IAAI,yBAAyB;AAC5B,cAAM,EAAE,iBAAiB,iBAAiB,QAAI,iCAAW;AACzD,eAAO,MAAM,wBACV,kBACA;AAAA,MACJ;AAAA,IACD;AAAA,IACA,SAAS;AAAA,MACR,cAAc;AACb,cAAM,cAAU,iCAAW;AAC3B,YAAK,QAAQ,cAAc,QAAQ,SAAU;AAC5C,gBAAM,SAAS,oBAAoB;AAAA,YAClC,QAAQ;AAAA,UACT,GAAG;AACH,cAAK,QAAQ,WAAY;AACxB,oBAAQ,YAAY;AACpB,mBAAO,MAAM;AAAA,UACd,OAAO;AACN,oBAAQ,KAAK,GAAG,MAAO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U,iBAAkB,wBAAwB,OAAQ;AACnE,SAAO,UAAU,iBAAkB,wBAAwB,OAAQ;AACnE,QAAM,UAAU,MAAM;AACrB,WAAO,UAAU,oBAAqB,uBAAuB,MAAO;AACpE,WAAO,UAAU,oBAAqB,wBAAwB,OAAQ;AACtE,WAAO,UAAU,oBAAqB,wBAAwB,OAAQ;AACtE,WAAO,QAAQ;AAAA,EAChB;AAGA,QAAM,YAAY;AAAA,IACjB,KAAK,MAAM;AAAA,IACX,UAAU,OAAO;AAAA,IACjB,WAAW,OAAO;AAAA,IAClB;AAAA,EACD;AACA,cAAY,IAAK,KAAK,SAAU;AAChC,sBAAoB,IAAK,QAAQ,YAAY,SAAU;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
3
|
"apiVersion": 3,
|
|
4
|
-
"__experimental": true,
|
|
5
4
|
"name": "core/playlist-track",
|
|
6
5
|
"title": "Playlist track",
|
|
7
6
|
"category": "media",
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
"description": "Playlist track.",
|
|
10
9
|
"keywords": [ "music", "sound" ],
|
|
11
10
|
"textdomain": "default",
|
|
12
|
-
"usesContext": [ "showArtists" ],
|
|
11
|
+
"usesContext": [ "showArtists", "showImages" ],
|
|
13
12
|
"attributes": {
|
|
14
13
|
"blob": {
|
|
15
14
|
"type": "string",
|
|
@@ -34,6 +33,9 @@
|
|
|
34
33
|
"image": {
|
|
35
34
|
"type": "string"
|
|
36
35
|
},
|
|
36
|
+
"imageAlt": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
37
39
|
"length": {
|
|
38
40
|
"type": "string"
|
|
39
41
|
},
|
|
@@ -27,16 +27,18 @@ var import_blob = require("@wordpress/blob");
|
|
|
27
27
|
var import_element = require("@wordpress/element");
|
|
28
28
|
var import_block_editor = require("@wordpress/block-editor");
|
|
29
29
|
var import_components = require("@wordpress/components");
|
|
30
|
+
var import_ui = require("@wordpress/ui");
|
|
30
31
|
var import_data = require("@wordpress/data");
|
|
31
32
|
var import_notices = require("@wordpress/notices");
|
|
32
33
|
var import_i18n = require("@wordpress/i18n");
|
|
33
34
|
var import_icons = require("@wordpress/icons");
|
|
34
35
|
var import_dom = require("@wordpress/dom");
|
|
35
36
|
var import_context = require("../playlist/context.cjs");
|
|
37
|
+
var import_utils = require("../playlist/utils.cjs");
|
|
36
38
|
var import_hooks = require("../utils/hooks.cjs");
|
|
37
39
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
40
|
var ALLOWED_MEDIA_TYPES = ["audio"];
|
|
39
|
-
var
|
|
41
|
+
var TRACK_IMAGE_ALLOWED_MEDIA_TYPES = ["image"];
|
|
40
42
|
var PlaylistTrackEdit = ({
|
|
41
43
|
attributes,
|
|
42
44
|
setAttributes,
|
|
@@ -44,9 +46,10 @@ var PlaylistTrackEdit = ({
|
|
|
44
46
|
clientId,
|
|
45
47
|
isSelected
|
|
46
48
|
}) => {
|
|
47
|
-
const { id, src, album, artist, image, length, title } = attributes;
|
|
49
|
+
const { id, src, album, artist, image, imageAlt, length, title } = attributes;
|
|
48
50
|
const [temporaryURL, setTemporaryURL] = (0, import_element.useState)(attributes.blob);
|
|
49
51
|
const showArtists = context?.showArtists;
|
|
52
|
+
const showImages = context?.showImages ?? true;
|
|
50
53
|
const imageButton = (0, import_element.useRef)();
|
|
51
54
|
const blockProps = (0, import_block_editor.useBlockProps)();
|
|
52
55
|
const { currentTrackClientId, setCurrentTrackClientId } = (0, import_element.useContext)(import_context.PlaylistContext);
|
|
@@ -54,12 +57,14 @@ var PlaylistTrackEdit = ({
|
|
|
54
57
|
function onUploadError(message) {
|
|
55
58
|
createErrorNotice(message, { type: "snackbar" });
|
|
56
59
|
}
|
|
60
|
+
const hasTrackSource = !!src || !!temporaryURL;
|
|
57
61
|
(0, import_element.useEffect)(() => {
|
|
58
|
-
if (isSelected && currentTrackClientId !== clientId) {
|
|
62
|
+
if (isSelected && hasTrackSource && currentTrackClientId !== clientId) {
|
|
59
63
|
setCurrentTrackClientId(clientId);
|
|
60
64
|
}
|
|
61
65
|
}, [
|
|
62
66
|
isSelected,
|
|
67
|
+
hasTrackSource,
|
|
63
68
|
clientId,
|
|
64
69
|
currentTrackClientId,
|
|
65
70
|
setCurrentTrackClientId
|
|
@@ -78,6 +83,7 @@ var PlaylistTrackEdit = ({
|
|
|
78
83
|
artist: void 0,
|
|
79
84
|
album: void 0,
|
|
80
85
|
image: void 0,
|
|
86
|
+
imageAlt: void 0,
|
|
81
87
|
length: void 0,
|
|
82
88
|
title: void 0,
|
|
83
89
|
url: void 0
|
|
@@ -91,25 +97,18 @@ var PlaylistTrackEdit = ({
|
|
|
91
97
|
}
|
|
92
98
|
setAttributes({
|
|
93
99
|
blob: void 0,
|
|
94
|
-
|
|
95
|
-
src: media.url,
|
|
96
|
-
artist: media.artist || media?.meta?.artist || media?.media_details?.artist || (0, import_i18n.__)("Unknown artist"),
|
|
97
|
-
album: media.album || media?.meta?.album || media?.media_details?.album || (0, import_i18n.__)("Unknown album"),
|
|
98
|
-
// Prevent using the default media attachment icon as the track image.
|
|
99
|
-
image: media?.image?.src && media?.image?.src.endsWith("/images/media/audio.svg") ? "" : media?.image?.src,
|
|
100
|
-
length: media?.fileLength || media?.media_details?.length_formatted,
|
|
101
|
-
title: media.title
|
|
100
|
+
...(0, import_utils.getTrackAttributes)(media)
|
|
102
101
|
});
|
|
103
102
|
setTemporaryURL();
|
|
104
103
|
}
|
|
105
|
-
function
|
|
106
|
-
setAttributes(
|
|
104
|
+
function onSelectTrackImage(trackImage) {
|
|
105
|
+
setAttributes((0, import_utils.getTrackImageAttributes)(trackImage));
|
|
107
106
|
}
|
|
108
|
-
function
|
|
109
|
-
setAttributes({ image: void 0 });
|
|
107
|
+
function onRemoveTrackImage() {
|
|
108
|
+
setAttributes({ image: void 0, imageAlt: void 0 });
|
|
110
109
|
imageButton.current.focus();
|
|
111
110
|
}
|
|
112
|
-
if (!
|
|
111
|
+
if (!hasTrackSource) {
|
|
113
112
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
114
113
|
import_block_editor.MediaPlaceholder,
|
|
115
114
|
{
|
|
@@ -172,45 +171,70 @@ var PlaylistTrackEdit = ({
|
|
|
172
171
|
}
|
|
173
172
|
}
|
|
174
173
|
),
|
|
175
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.MediaUploadCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
176
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.BaseControl.VisualLabel, { children: (0, import_i18n.__)("
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.MediaUploadCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.BaseControl, { children: [
|
|
175
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.BaseControl.VisualLabel, { children: (0, import_i18n.__)("Track image") }),
|
|
176
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "editor-video-poster-control", children: [
|
|
177
|
+
!!image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
|
+
"img",
|
|
179
|
+
{
|
|
180
|
+
src: image,
|
|
181
|
+
alt: (0, import_i18n.__)(
|
|
182
|
+
"Preview of the track image"
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
187
|
+
import_block_editor.MediaUpload,
|
|
188
|
+
{
|
|
189
|
+
title: (0, import_i18n.__)("Select image"),
|
|
190
|
+
onSelect: onSelectTrackImage,
|
|
191
|
+
allowedTypes: TRACK_IMAGE_ALLOWED_MEDIA_TYPES,
|
|
192
|
+
render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
193
|
+
import_components.Button,
|
|
194
|
+
{
|
|
195
|
+
__next40pxDefaultSize: true,
|
|
196
|
+
variant: "primary",
|
|
197
|
+
onClick: open,
|
|
198
|
+
ref: imageButton,
|
|
199
|
+
children: !image ? (0, import_i18n.__)("Select") : (0, import_i18n.__)("Replace")
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
),
|
|
204
|
+
!!image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
205
|
+
import_components.Button,
|
|
206
|
+
{
|
|
207
|
+
__next40pxDefaultSize: true,
|
|
208
|
+
onClick: onRemoveTrackImage,
|
|
209
|
+
variant: "tertiary",
|
|
210
|
+
children: (0, import_i18n.__)("Remove")
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
] })
|
|
214
|
+
] }) }),
|
|
215
|
+
!!image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
216
|
+
import_components.TextareaControl,
|
|
217
|
+
{
|
|
218
|
+
label: (0, import_i18n.__)("Alternative text"),
|
|
219
|
+
value: imageAlt || "",
|
|
220
|
+
onChange: (value) => setAttributes({ imageAlt: value }),
|
|
221
|
+
help: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
222
|
+
import_ui.Link,
|
|
223
|
+
{
|
|
224
|
+
openInNewTab: true,
|
|
225
|
+
href: (
|
|
226
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
227
|
+
(0, import_i18n.__)(
|
|
228
|
+
"https://www.w3.org/WAI/tutorials/images/decision-tree/"
|
|
229
|
+
)
|
|
230
|
+
),
|
|
231
|
+
children: (0, import_i18n.__)(
|
|
232
|
+
"Describe the purpose of the image."
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
)
|
|
214
238
|
] }) }),
|
|
215
239
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { ...blockProps, children: [
|
|
216
240
|
!!temporaryURL && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}),
|
|
@@ -221,9 +245,17 @@ var PlaylistTrackEdit = ({
|
|
|
221
245
|
onClick: () => setCurrentTrackClientId(clientId),
|
|
222
246
|
"aria-current": currentTrackClientId === clientId ? "true" : "false",
|
|
223
247
|
children: [
|
|
248
|
+
showImages && !!image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
249
|
+
"img",
|
|
250
|
+
{
|
|
251
|
+
className: "wp-block-playlist-track__image",
|
|
252
|
+
src: image,
|
|
253
|
+
alt: imageAlt || ""
|
|
254
|
+
}
|
|
255
|
+
),
|
|
224
256
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "wp-block-playlist-track__content", children: [
|
|
225
257
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
226
|
-
import_block_editor.
|
|
258
|
+
import_block_editor.PlainText,
|
|
227
259
|
{
|
|
228
260
|
tagName: "span",
|
|
229
261
|
className: "wp-block-playlist-track__title",
|
|
@@ -232,32 +264,30 @@ var PlaylistTrackEdit = ({
|
|
|
232
264
|
onChange: (value) => {
|
|
233
265
|
setAttributes({ title: value });
|
|
234
266
|
},
|
|
235
|
-
|
|
236
|
-
withoutInteractiveFormatting: true
|
|
267
|
+
__experimentalVersion: 2
|
|
237
268
|
}
|
|
238
269
|
),
|
|
239
270
|
showArtists && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
240
|
-
import_block_editor.
|
|
271
|
+
import_block_editor.PlainText,
|
|
241
272
|
{
|
|
242
273
|
tagName: "span",
|
|
243
274
|
className: "wp-block-playlist-track__artist",
|
|
244
275
|
value: artist,
|
|
245
276
|
placeholder: (0, import_i18n.__)("Add artist"),
|
|
246
277
|
onChange: (value) => setAttributes({ artist: value }),
|
|
247
|
-
|
|
248
|
-
withoutInteractiveFormatting: true
|
|
278
|
+
__experimentalVersion: 2
|
|
249
279
|
}
|
|
250
280
|
)
|
|
251
281
|
] }),
|
|
252
282
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "wp-block-playlist-track__length", children: [
|
|
253
283
|
length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
254
284
|
className: "screen-reader-text",
|
|
255
|
-
/* translators:
|
|
256
|
-
children: (0, import_i18n.__)("
|
|
285
|
+
/* translators: Visually hidden label for the track duration (screen reader text). */
|
|
286
|
+
children: (0, import_i18n.__)("Duration:")
|
|
257
287
|
}),
|
|
258
288
|
length
|
|
259
289
|
] }),
|
|
260
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "screen-reader-text", children: (0, import_i18n.__)("
|
|
290
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "screen-reader-text", children: (0, import_i18n.__)("Play") })
|
|
261
291
|
]
|
|
262
292
|
}
|
|
263
293
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/playlist-track/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { useContext, useEffect, useRef, useState } from '@wordpress/element';\nimport {\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tBlockIcon,\n\tuseBlockProps,\n\tBlockControls,\n\tInspectorControls,\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAAwD;AACxD,0BAUO;AACP,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { useContext, useEffect, useRef, useState } from '@wordpress/element';\nimport {\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tBlockIcon,\n\tuseBlockProps,\n\tBlockControls,\n\tInspectorControls,\n\tPlainText,\n} from '@wordpress/block-editor';\nimport {\n\tButton,\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tBaseControl,\n\tSpinner,\n} from '@wordpress/components';\nimport { Link } from '@wordpress/ui';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __ } from '@wordpress/i18n';\nimport { audio as icon } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { PlaylistContext } from '../playlist/context';\nimport { getTrackAttributes, getTrackImageAttributes } from '../playlist/utils';\nimport { useUploadMediaFromBlobURL } from '../utils/hooks';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\nconst TRACK_IMAGE_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nconst PlaylistTrackEdit = ( {\n\tattributes,\n\tsetAttributes,\n\tcontext,\n\tclientId,\n\tisSelected,\n} ) => {\n\tconst { id, src, album, artist, image, imageAlt, length, title } =\n\t\tattributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst showArtists = context?.showArtists;\n\tconst showImages = context?.showImages ?? true;\n\tconst imageButton = useRef();\n\tconst blockProps = useBlockProps();\n\tconst { currentTrackClientId, setCurrentTrackClientId } =\n\t\tuseContext( PlaylistContext );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\tconst hasTrackSource = !! src || !! temporaryURL;\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tisSelected &&\n\t\t\thasTrackSource &&\n\t\t\tcurrentTrackClientId !== clientId\n\t\t) {\n\t\t\tsetCurrentTrackClientId( clientId );\n\t\t}\n\t}, [\n\t\tisSelected,\n\t\thasTrackSource,\n\t\tclientId,\n\t\tcurrentTrackClientId,\n\t\tsetCurrentTrackClientId,\n\t] );\n\n\tuseUploadMediaFromBlobURL( {\n\t\tsrc: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectTrack,\n\t\tonError: onUploadError,\n\t} );\n\n\tfunction onSelectTrack( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tartist: undefined,\n\t\t\t\talbum: undefined,\n\t\t\t\timage: undefined,\n\t\t\t\timageAlt: undefined,\n\t\t\t\tlength: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\turl: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\t...getTrackAttributes( media ),\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectTrackImage( trackImage ) {\n\t\tsetAttributes( getTrackImageAttributes( trackImage ) );\n\t}\n\n\tfunction onRemoveTrackImage() {\n\t\tsetAttributes( { image: undefined, imageAlt: undefined } );\n\n\t\t// Move focus back to the Media Upload button.\n\t\timageButton.current.focus();\n\t}\n\n\tif ( ! hasTrackSource ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'Track' ),\n\t\t\t\t\t\tinstructions: __(\n\t\t\t\t\t\t\t'Upload an audio file or pick one from your media library.'\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectTrack }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tname={ __( 'Replace' ) }\n\t\t\t\t\tonSelect={ onSelectTrack }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Artist' ) }\n\t\t\t\t\t\tvalue={ artist ? stripHTML( artist ) : '' }\n\t\t\t\t\t\tonChange={ ( artistValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { artist: artistValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Album' ) }\n\t\t\t\t\t\tvalue={ album ? stripHTML( album ) : '' }\n\t\t\t\t\t\tonChange={ ( albumValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { album: albumValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\tvalue={ title ? stripHTML( title ) : '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t{ __( 'Track image' ) }\n\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t<div className=\"editor-video-poster-control\">\n\t\t\t\t\t\t\t\t{ !! image && (\n\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\tsrc={ image }\n\t\t\t\t\t\t\t\t\t\talt={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Preview of the track image'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\t\ttitle={ __( 'Select image' ) }\n\t\t\t\t\t\t\t\t\tonSelect={ onSelectTrackImage }\n\t\t\t\t\t\t\t\t\tallowedTypes={\n\t\t\t\t\t\t\t\t\t\tTRACK_IMAGE_ALLOWED_MEDIA_TYPES\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t\tref={ imageButton }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ ! image\n\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Select' )\n\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ !! image && (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\tonClick={ onRemoveTrackImage }\n\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t\t{ !! image && (\n\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tvalue={ imageAlt || '' }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { imageAlt: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<li { ...blockProps }>\n\t\t\t\t{ !! temporaryURL && <Spinner /> }\n\t\t\t\t<button\n\t\t\t\t\tclassName=\"wp-block-playlist-track__button\"\n\t\t\t\t\tonClick={ () => setCurrentTrackClientId( clientId ) }\n\t\t\t\t\taria-current={\n\t\t\t\t\t\tcurrentTrackClientId === clientId ? 'true' : 'false'\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ showImages && !! image && (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tclassName=\"wp-block-playlist-track__image\"\n\t\t\t\t\t\t\tsrc={ image }\n\t\t\t\t\t\t\talt={ imageAlt || '' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<span className=\"wp-block-playlist-track__content\">\n\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\tclassName=\"wp-block-playlist-track__title\"\n\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\tplaceholder={ __( 'Add title' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { title: value } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ showArtists && (\n\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\t\tclassName=\"wp-block-playlist-track__artist\"\n\t\t\t\t\t\t\t\tvalue={ artist }\n\t\t\t\t\t\t\t\tplaceholder={ __( 'Add artist' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { artist: value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"wp-block-playlist-track__length\">\n\t\t\t\t\t\t{ length && (\n\t\t\t\t\t\t\t<span className=\"screen-reader-text\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t/* translators: Visually hidden label for the track duration (screen reader text). */\n\t\t\t\t\t\t\t\t\t__( 'Duration:' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ length }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"screen-reader-text\">{ __( 'Play' ) }</span>\n\t\t\t\t</button>\n\t\t\t</li>\n\t\t</>\n\t);\n};\n\nexport default PlaylistTrackEdit;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAAwD;AACxD,0BAUO;AACP,wBAOO;AACP,gBAAqB;AACrB,kBAA4B;AAC5B,qBAAsC;AACtC,kBAAmB;AACnB,mBAA8B;AAC9B,iBAAiD;AAKjD,qBAAgC;AAChC,mBAA4D;AAC5D,mBAA0C;AAgG9B;AA9FZ,IAAM,sBAAsB,CAAE,OAAQ;AACtC,IAAM,kCAAkC,CAAE,OAAQ;AAElD,IAAM,oBAAoB,CAAE;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAO;AACN,QAAM,EAAE,IAAI,KAAK,OAAO,QAAQ,OAAO,UAAU,QAAQ,MAAM,IAC9D;AACD,QAAM,CAAE,cAAc,eAAgB,QAAI,yBAAU,WAAW,IAAK;AACpE,QAAM,cAAc,SAAS;AAC7B,QAAM,aAAa,SAAS,cAAc;AAC1C,QAAM,kBA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AAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU,MAAM,wBAAyB,QAAS;AAAA,UAClD,gBACC,yBAAyB,WAAW,SAAS;AAAA,UAG5C;AAAA,0BAAc,CAAC,CAAE,SAClB;AAAA,cAAC;AAAA;AAAA,gBACA,WAAU;AAAA,gBACV,KAAM;AAAA,gBACN,KAAM,YAAY;AAAA;AAAA,YACnB;AAAA,YAED,6CAAC,UAAK,WAAU,oCACf;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,SAAQ;AAAA,kBACR,WAAU;AAAA,kBACV,OAAQ;AAAA,kBACR,iBAAc,gBAAI,WAAY;AAAA,kBAC9B,UAAW,CAAE,UAAW;AACvB,kCAAe,EAAE,OAAO,MAAM,CAAE;AAAA,kBACjC;AAAA,kBACA,uBAAwB;AAAA;AAAA,cACzB;AAAA,cACE,eACD;AAAA,gBAAC;AAAA;AAAA,kBACA,SAAQ;AAAA,kBACR,WAAU;AAAA,kBACV,OAAQ;AAAA,kBACR,iBAAc,gBAAI,YAAa;AAAA,kBAC/B,UAAW,CAAE,UACZ,cAAe,EAAE,QAAQ,MAAM,CAAE;AAAA,kBAElC,uBAAwB;AAAA;AAAA,cACzB;AAAA,eAEF;AAAA,YACA,6CAAC,UAAK,WAAU,mCACb;AAAA,wBACD,4CAAC;AAAA,gBAAK,WAAU;AAAA;AAAA,gBAGd,8BAAI,WAAY;AAAA,eAElB;AAAA,cAEC;AAAA,eACH;AAAA,YACA,4CAAC,UAAK,WAAU,sBAAuB,8BAAI,MAAO,GAAG;AAAA;AAAA;AAAA,MACtD;AAAA,OACD;AAAA,KACD;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": ["noticesStore", "icon", "stripHTML"]
|
|
7
7
|
}
|
|
@@ -117,6 +117,7 @@ function PostTemplateEdit({
|
|
|
117
117
|
parents,
|
|
118
118
|
pages,
|
|
119
119
|
format,
|
|
120
|
+
excludeCurrent,
|
|
120
121
|
// We gather extra query args to pass to the REST API call.
|
|
121
122
|
// This way extenders of Query Loop can add their own query args,
|
|
122
123
|
// and have accurate previews in the editor.
|
|
@@ -125,7 +126,8 @@ function PostTemplateEdit({
|
|
|
125
126
|
...restQueryArgs
|
|
126
127
|
} = {},
|
|
127
128
|
templateSlug,
|
|
128
|
-
previewPostType
|
|
129
|
+
previewPostType,
|
|
130
|
+
postId
|
|
129
131
|
},
|
|
130
132
|
attributes: { layout },
|
|
131
133
|
__unstableLayoutClassNames
|
|
@@ -206,6 +208,13 @@ function PostTemplateEdit({
|
|
|
206
208
|
if (format?.length) {
|
|
207
209
|
query.format = format;
|
|
208
210
|
}
|
|
211
|
+
if (excludeCurrent && postId) {
|
|
212
|
+
if (query.exclude) {
|
|
213
|
+
query.exclude = [...query.exclude, postId];
|
|
214
|
+
} else {
|
|
215
|
+
query.exclude = [postId];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
209
218
|
if (["exclude", "only"].includes(sticky)) {
|
|
210
219
|
query.sticky = sticky === "only";
|
|
211
220
|
}
|