@wordpress/block-library 9.35.1-next.dc3f6d3c1.0 → 9.36.1-next.6deb34194.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/accordion/view.js +46 -4
- package/build/accordion/view.js.map +2 -2
- package/build/accordion-heading/block.json +1 -1
- package/build/accordion-heading/deprecated.js +1 -1
- package/build/accordion-heading/deprecated.js.map +2 -2
- package/build/accordion-panel/block.json +1 -1
- package/build/audio/index.js +13 -10
- package/build/audio/index.js.map +3 -3
- package/build/avatar/edit.js +13 -38
- package/build/avatar/edit.js.map +2 -2
- package/build/breadcrumbs/block.json +3 -2
- package/build/breadcrumbs/edit.js +18 -18
- package/build/breadcrumbs/edit.js.map +2 -2
- package/build/button/index.js +14 -11
- package/build/button/index.js.map +3 -3
- package/build/code/index.js +10 -7
- package/build/code/index.js.map +3 -3
- package/build/comments-pagination-numbers/block.json +7 -0
- package/build/cover/edit/block-controls.js +37 -3
- package/build/cover/edit/block-controls.js.map +3 -3
- package/build/cover/edit/cover-placeholder.js +0 -1
- package/build/cover/edit/cover-placeholder.js.map +2 -2
- package/build/cover/edit/embed-video-url-input.js +83 -0
- package/build/cover/edit/embed-video-url-input.js.map +7 -0
- package/build/cover/edit/index.js +60 -0
- package/build/cover/edit/index.js.map +2 -2
- package/build/cover/embed-video-utils.js +151 -0
- package/build/cover/embed-video-utils.js.map +7 -0
- package/build/cover/index.js +11 -5
- package/build/cover/index.js.map +3 -3
- package/build/cover/save.js +12 -0
- package/build/cover/save.js.map +2 -2
- package/build/cover/shared.js +3 -0
- package/build/cover/shared.js.map +2 -2
- package/build/details/index.js +10 -7
- package/build/details/index.js.map +3 -3
- package/build/file/index.js +15 -15
- package/build/file/index.js.map +3 -3
- package/build/freeform/block.json +1 -1
- package/build/gallery/edit.js +1 -3
- package/build/gallery/edit.js.map +2 -2
- package/build/gallery/transforms.js +7 -3
- package/build/gallery/transforms.js.map +2 -2
- package/build/heading/index.js +10 -7
- package/build/heading/index.js.map +3 -3
- package/build/html/modal.js +141 -121
- package/build/html/modal.js.map +3 -3
- package/build/image/edit.js +0 -1
- package/build/image/edit.js.map +2 -2
- package/build/image/image.js +0 -1
- package/build/image/image.js.map +2 -2
- package/build/image/index.js +19 -19
- package/build/image/index.js.map +3 -3
- package/build/index.js +9 -3
- package/build/index.js.map +2 -2
- package/build/list-item/index.js +9 -7
- package/build/list-item/index.js.map +3 -3
- package/build/math/block.json +28 -1
- package/build/math/edit.js +17 -2
- package/build/math/edit.js.map +2 -2
- package/build/media-text/index.js +16 -9
- package/build/media-text/index.js.map +3 -3
- package/build/media-text/media-container.js +0 -2
- package/build/media-text/media-container.js.map +2 -2
- package/build/missing/block.json +1 -1
- package/build/missing/edit.js +2 -2
- package/build/missing/edit.js.map +1 -1
- package/build/more/index.js +10 -7
- package/build/more/index.js.map +3 -3
- package/build/navigation-link/edit.js +36 -11
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/index.js +12 -9
- package/build/navigation-link/index.js.map +3 -3
- package/build/navigation-submenu/index.js +12 -9
- package/build/navigation-submenu/index.js.map +3 -3
- package/build/page-list-item/edit.js +4 -3
- package/build/page-list-item/edit.js.map +2 -2
- package/build/paragraph/deprecated-attributes.js +68 -0
- package/build/paragraph/deprecated-attributes.js.map +7 -0
- package/build/paragraph/edit.js +2 -0
- package/build/paragraph/edit.js.map +3 -3
- package/build/paragraph/index.js +10 -7
- package/build/paragraph/index.js.map +3 -3
- package/build/pattern/block.json +1 -1
- package/build/post-title/edit.js +6 -4
- package/build/post-title/edit.js.map +2 -2
- package/build/preformatted/index.js +10 -7
- package/build/preformatted/index.js.map +3 -3
- package/build/pullquote/index.js +12 -12
- package/build/pullquote/index.js.map +3 -3
- package/build/search/index.js +15 -17
- package/build/search/index.js.map +3 -3
- package/build/social-link/index.js +12 -9
- package/build/social-link/index.js.map +3 -3
- package/build/template-part/edit/index.js +37 -7
- package/build/template-part/edit/index.js.map +2 -2
- package/build/template-part/edit/utils/get-template-part-icon.js +9 -4
- package/build/template-part/edit/utils/get-template-part-icon.js.map +3 -3
- package/build/template-part/edit/utils/hooks.js +2 -3
- package/build/template-part/edit/utils/hooks.js.map +2 -2
- package/build/term-count/index.js +1 -0
- package/build/term-count/index.js.map +2 -2
- package/build/term-name/index.js +1 -0
- package/build/term-name/index.js.map +2 -2
- package/build/verse/index.js +10 -7
- package/build/verse/index.js.map +3 -3
- package/build/video/index.js +13 -10
- package/build/video/index.js.map +3 -3
- package/build-module/accordion/view.js +46 -4
- package/build-module/accordion/view.js.map +2 -2
- package/build-module/accordion-heading/block.json +1 -1
- package/build-module/accordion-heading/deprecated.js +1 -1
- package/build-module/accordion-heading/deprecated.js.map +2 -2
- package/build-module/accordion-panel/block.json +1 -1
- package/build-module/audio/index.js +13 -10
- package/build-module/audio/index.js.map +2 -2
- package/build-module/avatar/edit.js +13 -38
- package/build-module/avatar/edit.js.map +2 -2
- package/build-module/breadcrumbs/block.json +3 -2
- package/build-module/breadcrumbs/edit.js +18 -18
- package/build-module/breadcrumbs/edit.js.map +2 -2
- package/build-module/button/index.js +14 -11
- package/build-module/button/index.js.map +2 -2
- package/build-module/code/index.js +10 -7
- package/build-module/code/index.js.map +2 -2
- package/build-module/comments-pagination-numbers/block.json +7 -0
- package/build-module/cover/edit/block-controls.js +27 -3
- package/build-module/cover/edit/block-controls.js.map +2 -2
- package/build-module/cover/edit/cover-placeholder.js +0 -1
- package/build-module/cover/edit/cover-placeholder.js.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.js +67 -0
- package/build-module/cover/edit/embed-video-url-input.js.map +7 -0
- package/build-module/cover/edit/index.js +61 -0
- package/build-module/cover/edit/index.js.map +2 -2
- package/build-module/cover/embed-video-utils.js +122 -0
- package/build-module/cover/embed-video-utils.js.map +7 -0
- package/build-module/cover/index.js +11 -5
- package/build-module/cover/index.js.map +2 -2
- package/build-module/cover/save.js +13 -0
- package/build-module/cover/save.js.map +2 -2
- package/build-module/cover/shared.js +2 -0
- package/build-module/cover/shared.js.map +2 -2
- package/build-module/details/index.js +10 -7
- package/build-module/details/index.js.map +2 -2
- package/build-module/file/index.js +15 -15
- package/build-module/file/index.js.map +2 -2
- package/build-module/freeform/block.json +1 -1
- package/build-module/gallery/edit.js +1 -3
- package/build-module/gallery/edit.js.map +2 -2
- package/build-module/gallery/transforms.js +7 -3
- package/build-module/gallery/transforms.js.map +2 -2
- package/build-module/heading/index.js +10 -7
- package/build-module/heading/index.js.map +2 -2
- package/build-module/html/modal.js +143 -122
- package/build-module/html/modal.js.map +2 -2
- package/build-module/image/edit.js +0 -1
- package/build-module/image/edit.js.map +2 -2
- package/build-module/image/image.js +0 -1
- package/build-module/image/image.js.map +2 -2
- package/build-module/image/index.js +19 -19
- package/build-module/image/index.js.map +2 -2
- package/build-module/index.js +9 -3
- package/build-module/index.js.map +2 -2
- package/build-module/list-item/index.js +9 -7
- package/build-module/list-item/index.js.map +2 -2
- package/build-module/math/block.json +28 -1
- package/build-module/math/edit.js +18 -3
- package/build-module/math/edit.js.map +2 -2
- package/build-module/media-text/index.js +16 -9
- package/build-module/media-text/index.js.map +2 -2
- package/build-module/media-text/media-container.js +0 -2
- package/build-module/media-text/media-container.js.map +2 -2
- package/build-module/missing/block.json +1 -1
- package/build-module/missing/edit.js +2 -2
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/more/index.js +10 -7
- package/build-module/more/index.js.map +2 -2
- package/build-module/navigation-link/edit.js +37 -12
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/index.js +12 -9
- package/build-module/navigation-link/index.js.map +2 -2
- package/build-module/navigation-submenu/index.js +12 -9
- package/build-module/navigation-submenu/index.js.map +2 -2
- package/build-module/page-list-item/edit.js +4 -3
- package/build-module/page-list-item/edit.js.map +2 -2
- package/build-module/paragraph/deprecated-attributes.js +37 -0
- package/build-module/paragraph/deprecated-attributes.js.map +7 -0
- package/build-module/paragraph/edit.js +2 -0
- package/build-module/paragraph/edit.js.map +2 -2
- package/build-module/paragraph/index.js +10 -7
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/pattern/block.json +1 -1
- package/build-module/post-title/edit.js +6 -4
- package/build-module/post-title/edit.js.map +2 -2
- package/build-module/preformatted/index.js +10 -7
- package/build-module/preformatted/index.js.map +2 -2
- package/build-module/pullquote/index.js +12 -12
- package/build-module/pullquote/index.js.map +2 -2
- package/build-module/search/index.js +15 -17
- package/build-module/search/index.js.map +2 -2
- package/build-module/social-link/index.js +12 -9
- package/build-module/social-link/index.js.map +2 -2
- package/build-module/template-part/edit/index.js +37 -7
- package/build-module/template-part/edit/index.js.map +2 -2
- package/build-module/template-part/edit/utils/get-template-part-icon.js +10 -4
- package/build-module/template-part/edit/utils/get-template-part-icon.js.map +2 -2
- package/build-module/template-part/edit/utils/hooks.js +2 -3
- package/build-module/template-part/edit/utils/hooks.js.map +2 -2
- package/build-module/term-count/index.js +1 -0
- package/build-module/term-count/index.js.map +2 -2
- package/build-module/term-name/index.js +1 -0
- package/build-module/term-name/index.js.map +2 -2
- package/build-module/verse/index.js +10 -7
- package/build-module/verse/index.js.map +2 -2
- package/build-module/video/index.js +13 -10
- package/build-module/video/index.js.map +2 -2
- package/build-style/accordion/style-rtl.css +3 -0
- package/build-style/accordion/style.css +3 -0
- package/build-style/accordion-heading/style-rtl.css +2 -19
- package/build-style/accordion-heading/style.css +2 -19
- package/build-style/accordion-item/style-rtl.css +0 -7
- package/build-style/accordion-item/style.css +0 -7
- package/build-style/accordion-panel/style-rtl.css +1 -4
- package/build-style/accordion-panel/style.css +1 -4
- package/build-style/classic-rtl.css +24 -0
- package/build-style/classic.css +24 -0
- package/build-style/common-rtl.css +4 -4
- package/build-style/common.css +4 -0
- package/build-style/cover/style-rtl.css +47 -0
- package/build-style/cover/style.css +47 -0
- package/build-style/editor-rtl.css +11 -13
- package/build-style/editor.css +11 -13
- package/build-style/html/editor-rtl.css +11 -13
- package/build-style/html/editor.css +11 -13
- package/build-style/style-rtl.css +59 -33
- package/build-style/style.css +59 -29
- package/build-style/verse/style-rtl.css +2 -0
- package/build-style/verse/style.css +2 -0
- package/package.json +40 -38
- package/src/accordion/style.scss +4 -0
- package/src/accordion/view.js +60 -3
- package/src/accordion-heading/block.json +1 -1
- package/src/accordion-heading/deprecated.js +1 -1
- package/src/accordion-heading/style.scss +2 -38
- package/src/accordion-item/index.php +1 -0
- package/src/accordion-item/style.scss +2 -9
- package/src/accordion-panel/block.json +1 -1
- package/src/accordion-panel/style.scss +1 -5
- package/src/audio/index.js +14 -10
- package/src/avatar/edit.js +68 -83
- package/src/breadcrumbs/block.json +3 -2
- package/src/breadcrumbs/edit.js +18 -18
- package/src/breadcrumbs/index.php +103 -93
- package/src/button/index.js +15 -11
- package/src/classic.scss +38 -0
- package/src/code/index.js +11 -7
- package/src/comments-pagination-numbers/block.json +7 -0
- package/src/common.scss +4 -0
- package/src/cover/edit/block-controls.js +26 -2
- package/src/cover/edit/cover-placeholder.js +0 -1
- package/src/cover/edit/embed-video-url-input.js +74 -0
- package/src/cover/edit/index.js +81 -0
- package/src/cover/embed-video-utils.js +196 -0
- package/src/cover/index.js +12 -5
- package/src/cover/index.php +106 -0
- package/src/cover/save.js +14 -0
- package/src/cover/shared.js +1 -0
- package/src/cover/style.scss +47 -0
- package/src/details/index.js +11 -7
- package/src/file/index.js +16 -15
- package/src/freeform/block.json +1 -1
- package/src/gallery/edit.js +4 -3
- package/src/gallery/transforms.js +6 -2
- package/src/heading/index.js +11 -7
- package/src/html/editor.scss +10 -15
- package/src/html/modal.js +54 -30
- package/src/image/edit.js +0 -1
- package/src/image/image.js +0 -1
- package/src/image/index.js +20 -19
- package/src/image/index.php +1 -0
- package/src/index.js +9 -3
- package/src/list-item/index.js +10 -7
- package/src/math/block.json +28 -1
- package/src/math/edit.js +18 -3
- package/src/media-text/index.js +17 -9
- package/src/media-text/media-container.js +0 -2
- package/src/missing/block.json +1 -1
- package/src/missing/edit.js +2 -2
- package/src/more/index.js +11 -7
- package/src/navigation-link/edit.js +72 -26
- package/src/navigation-link/index.js +13 -9
- package/src/navigation-submenu/index.js +13 -9
- package/src/page-list/index.php +3 -4
- package/src/page-list-item/edit.js +4 -3
- package/src/paragraph/deprecated-attributes.js +45 -0
- package/src/paragraph/edit.js +2 -0
- package/src/paragraph/index.js +11 -7
- package/src/pattern/block.json +1 -1
- package/src/post-title/edit.js +8 -4
- package/src/post-title/index.php +1 -1
- package/src/preformatted/index.js +11 -7
- package/src/pullquote/index.js +13 -12
- package/src/search/index.js +15 -16
- package/src/social-link/index.js +13 -9
- package/src/style.scss +1 -0
- package/src/template-part/edit/index.js +44 -6
- package/src/template-part/edit/utils/get-template-part-icon.js +23 -4
- package/src/template-part/edit/utils/hooks.js +2 -4
- package/src/term-count/index.js +1 -0
- package/src/term-name/index.js +1 -0
- package/src/verse/index.js +11 -7
- package/src/verse/style.scss +4 -0
- package/src/video/index.js +14 -10
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
attributesFromMedia,
|
|
23
23
|
IMAGE_BACKGROUND_TYPE,
|
|
24
24
|
VIDEO_BACKGROUND_TYPE,
|
|
25
|
+
EMBED_VIDEO_BACKGROUND_TYPE,
|
|
25
26
|
dimRatioToClass,
|
|
26
27
|
isContentPositionCenter,
|
|
27
28
|
getPositionClassName,
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
DEFAULT_OVERLAY_COLOR
|
|
39
40
|
} from "./color-utils";
|
|
40
41
|
import { DEFAULT_MEDIA_SIZE_SLUG } from "../constants";
|
|
42
|
+
import { getIframeSrc, getBackgroundVideoSrc } from "../embed-video-utils";
|
|
41
43
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
42
44
|
function getInnerBlocksTemplate(attributes) {
|
|
43
45
|
return [
|
|
@@ -231,9 +233,49 @@ function CoverEdit({
|
|
|
231
233
|
const onUploadError = (message) => {
|
|
232
234
|
createErrorNotice(message, { type: "snackbar" });
|
|
233
235
|
};
|
|
236
|
+
const onSelectEmbedUrl = (embedUrl) => {
|
|
237
|
+
const newDimRatio = originalUrl === void 0 && dimRatio === 100 ? 50 : dimRatio;
|
|
238
|
+
setAttributes({
|
|
239
|
+
url: embedUrl,
|
|
240
|
+
backgroundType: EMBED_VIDEO_BACKGROUND_TYPE,
|
|
241
|
+
dimRatio: newDimRatio,
|
|
242
|
+
id: void 0,
|
|
243
|
+
focalPoint: void 0,
|
|
244
|
+
hasParallax: void 0,
|
|
245
|
+
isRepeated: void 0,
|
|
246
|
+
useFeaturedImage: void 0
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
const { embedPreview, isFetchingEmbed } = useSelect(
|
|
250
|
+
(select) => {
|
|
251
|
+
if (backgroundType !== EMBED_VIDEO_BACKGROUND_TYPE || !url) {
|
|
252
|
+
return {
|
|
253
|
+
embedPreview: void 0,
|
|
254
|
+
isFetchingEmbed: false
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
const { getEmbedPreview, isRequestingEmbedPreview } = select(coreStore);
|
|
258
|
+
return {
|
|
259
|
+
embedPreview: getEmbedPreview(url),
|
|
260
|
+
isFetchingEmbed: isRequestingEmbedPreview(url)
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
[url, backgroundType]
|
|
264
|
+
);
|
|
265
|
+
const embedSrc = useMemo(() => {
|
|
266
|
+
if (backgroundType !== EMBED_VIDEO_BACKGROUND_TYPE || !embedPreview?.html) {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
const iframeSrc = getIframeSrc(embedPreview.html);
|
|
270
|
+
if (!iframeSrc) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
return getBackgroundVideoSrc(iframeSrc);
|
|
274
|
+
}, [embedPreview, backgroundType]);
|
|
234
275
|
const isUploadingMedia = isTemporaryMedia(id, url);
|
|
235
276
|
const isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;
|
|
236
277
|
const isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;
|
|
278
|
+
const isEmbedVideoBackground = EMBED_VIDEO_BACKGROUND_TYPE === backgroundType;
|
|
237
279
|
const blockEditingMode = useBlockEditingMode();
|
|
238
280
|
const hasNonContentControls = blockEditingMode === "default";
|
|
239
281
|
const [resizeListener, { height, width }] = useResizeObserver();
|
|
@@ -323,6 +365,7 @@ function CoverEdit({
|
|
|
323
365
|
attributes,
|
|
324
366
|
setAttributes,
|
|
325
367
|
onSelectMedia,
|
|
368
|
+
onSelectEmbedUrl,
|
|
326
369
|
currentSettings,
|
|
327
370
|
toggleUseFeaturedImage,
|
|
328
371
|
onClearMedia,
|
|
@@ -471,6 +514,24 @@ function CoverEdit({
|
|
|
471
514
|
style: mediaStyle
|
|
472
515
|
}
|
|
473
516
|
),
|
|
517
|
+
isEmbedVideoBackground && embedSrc && /* @__PURE__ */ jsx(
|
|
518
|
+
"div",
|
|
519
|
+
{
|
|
520
|
+
ref: mediaElement,
|
|
521
|
+
className: "wp-block-cover__video-background wp-block-cover__embed-background",
|
|
522
|
+
style: mediaStyle,
|
|
523
|
+
children: /* @__PURE__ */ jsx(
|
|
524
|
+
"iframe",
|
|
525
|
+
{
|
|
526
|
+
src: embedSrc,
|
|
527
|
+
title: "Background video",
|
|
528
|
+
frameBorder: "0",
|
|
529
|
+
allow: "autoplay; fullscreen"
|
|
530
|
+
}
|
|
531
|
+
)
|
|
532
|
+
}
|
|
533
|
+
),
|
|
534
|
+
isEmbedVideoBackground && !embedSrc && isFetchingEmbed && /* @__PURE__ */ jsx(Spinner, {}),
|
|
474
535
|
showOverlay && /* @__PURE__ */ jsx(
|
|
475
536
|
"span",
|
|
476
537
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cover/edit/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\nimport { Placeholder, Spinner } from '@wordpress/components';\nimport { compose, useResizeObserver } from '@wordpress/compose';\nimport {\n\twithColors,\n\tColorPalette,\n\tuseBlockProps,\n\tuseSettings,\n\tuseInnerBlocksProps,\n\t__experimentalUseGradient,\n\tstore as blockEditorStore,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport {\n\tattributesFromMedia,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n} from '../shared';\nimport CoverInspectorControls from './inspector-controls';\nimport CoverBlockControls from './block-controls';\nimport CoverPlaceholder from './cover-placeholder';\nimport ResizableCoverPopover from './resizable-cover-popover';\nimport {\n\tgetMediaColor,\n\tcompositeIsDark,\n\tDEFAULT_BACKGROUND_COLOR,\n\tDEFAULT_OVERLAY_COLOR,\n} from './color-utils';\nimport { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';\n\nfunction getInnerBlocksTemplate( attributes ) {\n\treturn [\n\t\t[\n\t\t\t'core/paragraph',\n\t\t\t{\n\t\t\t\talign: 'center',\n\t\t\t\tplaceholder: __( 'Write title\u2026' ),\n\t\t\t\t...attributes,\n\t\t\t},\n\t\t],\n\t];\n}\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily while\n * the media (image or video) is being uploaded and will not have an id allocated yet.\n *\n * @param {number} id The id of the media.\n * @param {string} url The url of the media.\n *\n * @return {boolean} Is the URL a Blob URL.\n */\nconst isTemporaryMedia = ( id, url ) => ! id && isBlobURL( url );\n\nfunction CoverEdit( {\n\tattributes,\n\tclientId,\n\tisSelected,\n\toverlayColor,\n\tsetAttributes,\n\tsetOverlayColor,\n\ttoggleSelection,\n\tcontext: { postId, postType },\n} ) {\n\tconst {\n\t\tcontentPosition,\n\t\tid,\n\t\turl: originalUrl,\n\t\tbackgroundType: originalBackgroundType,\n\t\tuseFeaturedImage,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\thasParallax,\n\t\tisDark,\n\t\tisRepeated,\n\t\tminHeight,\n\t\tminHeightUnit,\n\t\talt,\n\t\tallowedBlocks,\n\t\ttemplateLock,\n\t\ttagName: TagName = 'div',\n\t\tisUserOverlayColor,\n\t\tsizeSlug,\n\t\tposter,\n\t} = attributes;\n\n\tconst [ featuredImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\tconst { getSettings } = useSelect( blockEditorStore );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { media } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage && useFeaturedImage\n\t\t\t\t\t\t? select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\tfeaturedImage,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, useFeaturedImage ]\n\t);\n\tconst mediaUrl =\n\t\tmedia?.media_details?.sizes?.[ sizeSlug ]?.source_url ??\n\t\tmedia?.source_url;\n\n\t// User can change the featured image outside of the block, but we still\n\t// need to update the block when that happens. This effect should only\n\t// run when the featured image changes in that case. All other cases are\n\t// handled in their respective callbacks.\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tif ( ! useFeaturedImage ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst averageBackgroundColor = await getMediaColor( mediaUrl );\n\n\t\t\tlet newOverlayColor = overlayColor.color;\n\t\t\tif ( ! isUserOverlayColor ) {\n\t\t\t\tnewOverlayColor = averageBackgroundColor;\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetOverlayColor( newOverlayColor );\n\t\t\t}\n\n\t\t\tconst newIsDark = compositeIsDark(\n\t\t\t\tdimRatio,\n\t\t\t\tnewOverlayColor,\n\t\t\t\taverageBackgroundColor\n\t\t\t);\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tisDark: newIsDark,\n\t\t\t\tisUserOverlayColor: isUserOverlayColor || false,\n\t\t\t} );\n\t\t} )();\n\t\t// Update the block only when the featured image changes.\n\t}, [ mediaUrl ] );\n\n\t// instead of destructuring the attributes\n\t// we define the url and background type\n\t// depending on the value of the useFeaturedImage flag\n\t// to preview in edit the dynamic featured image\n\tconst url = useFeaturedImage\n\t\t? mediaUrl\n\t\t: // Ensure the url is not malformed due to sanitization through `wp_kses`.\n\t\t originalUrl?.replaceAll( '&', '&' );\n\tconst backgroundType = useFeaturedImage\n\t\t? IMAGE_BACKGROUND_TYPE\n\t\t: originalBackgroundType;\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { gradientClass, gradientValue } = __experimentalUseGradient();\n\n\tconst onSelectMedia = async ( newMedia ) => {\n\t\tconst mediaAttributes = attributesFromMedia( newMedia );\n\t\tconst isImage = [ newMedia?.type, newMedia?.media_type ].includes(\n\t\t\tIMAGE_BACKGROUND_TYPE\n\t\t);\n\n\t\tconst averageBackgroundColor = await getMediaColor(\n\t\t\tisImage ? newMedia?.url : undefined\n\t\t);\n\n\t\tlet newOverlayColor = overlayColor.color;\n\t\tif ( ! isUserOverlayColor ) {\n\t\t\tnewOverlayColor = averageBackgroundColor;\n\t\t\tsetOverlayColor( newOverlayColor );\n\n\t\t\t// Make undo revert the next setAttributes and the previous setOverlayColor.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\t// Only set a new dimRatio if there was no previous media selected\n\t\t// to avoid resetting to 50 if it has been explicitly set to 100.\n\t\t// See issue #52835 for context.\n\t\tconst newDimRatio =\n\t\t\toriginalUrl === undefined && dimRatio === 100 ? 50 : dimRatio;\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tif ( backgroundType === IMAGE_BACKGROUND_TYPE && mediaAttributes?.id ) {\n\t\t\tconst { imageDefaultSize } = getSettings();\n\n\t\t\t// Try to use the previous selected image size if it's available\n\t\t\t// otherwise try the default image size or fallback to full size.\n\t\t\tif (\n\t\t\t\tsizeSlug &&\n\t\t\t\t( newMedia?.sizes?.[ sizeSlug ] ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ sizeSlug ] )\n\t\t\t) {\n\t\t\t\tmediaAttributes.sizeSlug = sizeSlug;\n\t\t\t\tmediaAttributes.url =\n\t\t\t\t\tnewMedia?.sizes?.[ sizeSlug ]?.url ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ sizeSlug ]?.source_url;\n\t\t\t} else if (\n\t\t\t\tnewMedia?.sizes?.[ imageDefaultSize ] ||\n\t\t\t\tnewMedia?.media_details?.sizes?.[ imageDefaultSize ]\n\t\t\t) {\n\t\t\t\tmediaAttributes.sizeSlug = imageDefaultSize;\n\t\t\t\tmediaAttributes.url =\n\t\t\t\t\tnewMedia?.sizes?.[ imageDefaultSize ]?.url ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ imageDefaultSize ]\n\t\t\t\t\t\t?.source_url;\n\t\t\t} else {\n\t\t\t\tmediaAttributes.sizeSlug = DEFAULT_MEDIA_SIZE_SLUG;\n\t\t\t}\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\t...mediaAttributes,\n\t\t\tfocalPoint: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t\tdimRatio: newDimRatio,\n\t\t\tisDark: newIsDark,\n\t\t\tisUserOverlayColor: isUserOverlayColor || false,\n\t\t} );\n\t};\n\n\tconst onClearMedia = () => {\n\t\tlet newOverlayColor = overlayColor.color;\n\t\tif ( ! isUserOverlayColor ) {\n\t\t\tnewOverlayColor = DEFAULT_OVERLAY_COLOR;\n\t\t\tsetOverlayColor( undefined );\n\n\t\t\t// Make undo revert the next setAttributes and the previous setOverlayColor.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tdimRatio,\n\t\t\tnewOverlayColor,\n\t\t\tDEFAULT_BACKGROUND_COLOR\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tid: undefined,\n\t\t\tbackgroundType: undefined,\n\t\t\tfocalPoint: undefined,\n\t\t\thasParallax: undefined,\n\t\t\tisRepeated: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst onSetOverlayColor = async ( newOverlayColor ) => {\n\t\tconst averageBackgroundColor = await getMediaColor( url );\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tdimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tsetOverlayColor( newOverlayColor );\n\n\t\t// Make undo revert the next setAttributes and the previous setOverlayColor.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\n\t\tsetAttributes( {\n\t\t\tisUserOverlayColor: true,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst onUpdateDimRatio = async ( newDimRatio ) => {\n\t\tconst averageBackgroundColor = await getMediaColor( url );\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\toverlayColor.color,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\tdimRatio: newDimRatio,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst isUploadingMedia = isTemporaryMedia( id, url );\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\n\tconst [ resizeListener, { height, width } ] = useResizeObserver();\n\tconst resizableBoxDimensions = useMemo( () => {\n\t\treturn {\n\t\t\theight: minHeightUnit === 'px' && minHeight ? minHeight : 'auto',\n\t\t\twidth: 'auto',\n\t\t};\n\t}, [ minHeight, minHeightUnit ] );\n\n\tconst minHeightWithUnit =\n\t\tminHeight && minHeightUnit\n\t\t\t? `${ minHeight }${ minHeightUnit }`\n\t\t\t: minHeight;\n\n\tconst isImgElement = ! ( hasParallax || isRepeated );\n\n\tconst style = {\n\t\tminHeight: minHeightWithUnit || undefined,\n\t};\n\n\tconst backgroundImage = url ? `url(${ url })` : undefined;\n\n\tconst backgroundPosition = mediaPosition( focalPoint );\n\n\tconst bgStyle = { backgroundColor: overlayColor.color };\n\tconst mediaStyle = {\n\t\tobjectPosition:\n\t\t\tfocalPoint && isImgElement\n\t\t\t\t? mediaPosition( focalPoint )\n\t\t\t\t: undefined,\n\t};\n\n\tconst hasBackground = !! ( url || overlayColor.color || gradientValue );\n\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlock( clientId ).innerBlocks.length >\n\t\t\t0,\n\t\t[ clientId ]\n\t);\n\n\tconst ref = useRef();\n\tconst blockProps = useBlockProps( { ref } );\n\n\t// Check for fontSize support before we pass a fontSize attribute to the innerBlocks.\n\tconst [ fontSizes ] = useSettings( 'typography.fontSizes' );\n\tconst hasFontSizes = fontSizes?.length > 0;\n\tconst innerBlocksTemplate = getInnerBlocksTemplate( {\n\t\tfontSize: hasFontSizes ? 'large' : undefined,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'wp-block-cover__inner-container',\n\t\t},\n\t\t{\n\t\t\t// Avoid template sync when the `templateLock` value is `all` or `contentOnly`.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/45632\n\t\t\ttemplate: ! hasInnerBlocks ? innerBlocksTemplate : undefined,\n\t\t\ttemplateInsertUpdatesSelection: true,\n\t\t\tallowedBlocks,\n\t\t\ttemplateLock,\n\t\t\tdropZoneElement: ref.current,\n\t\t}\n\t);\n\n\tconst mediaElement = useRef();\n\tconst currentSettings = {\n\t\tisVideoBackground,\n\t\tisImageBackground,\n\t\tmediaElement,\n\t\thasInnerBlocks,\n\t\turl,\n\t\tisImgElement,\n\t\toverlayColor,\n\t};\n\n\tconst toggleUseFeaturedImage = async () => {\n\t\tconst newUseFeaturedImage = ! useFeaturedImage;\n\n\t\tconst averageBackgroundColor = newUseFeaturedImage\n\t\t\t? await getMediaColor( mediaUrl )\n\t\t\t: DEFAULT_BACKGROUND_COLOR;\n\n\t\tconst newOverlayColor = ! isUserOverlayColor\n\t\t\t? averageBackgroundColor\n\t\t\t: overlayColor.color;\n\n\t\tif ( ! isUserOverlayColor ) {\n\t\t\tif ( newUseFeaturedImage ) {\n\t\t\t\tsetOverlayColor( newOverlayColor );\n\t\t\t} else {\n\t\t\t\tsetOverlayColor( undefined );\n\t\t\t}\n\n\t\t\t// Make undo revert the next setAttributes and the previous setOverlayColor.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\tconst newDimRatio = dimRatio === 100 ? 50 : dimRatio;\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tuseFeaturedImage: newUseFeaturedImage,\n\t\t\tdimRatio: newDimRatio,\n\t\t\tbackgroundType: useFeaturedImage\n\t\t\t\t? IMAGE_BACKGROUND_TYPE\n\t\t\t\t: undefined,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst blockControls = (\n\t\t<CoverBlockControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\tonClearMedia={ onClearMedia }\n\t\t\tblockEditingMode={ blockEditingMode }\n\t\t/>\n\t);\n\n\tconst inspectorControls = (\n\t\t<CoverInspectorControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tclientId={ clientId }\n\t\t\tsetOverlayColor={ onSetOverlayColor }\n\t\t\tcoverRef={ ref }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\tupdateDimRatio={ onUpdateDimRatio }\n\t\t\tonClearMedia={ onClearMedia }\n\t\t\tfeaturedImage={ media }\n\t\t/>\n\t);\n\n\tconst resizableCoverProps = {\n\t\tclassName: 'block-library-cover__resize-container',\n\t\tclientId,\n\t\theight,\n\t\tminHeight: minHeightWithUnit,\n\t\tonResizeStart: () => {\n\t\t\tsetAttributes( { minHeightUnit: 'px' } );\n\t\t\ttoggleSelection( false );\n\t\t},\n\t\tonResize: ( value ) => {\n\t\t\tsetAttributes( { minHeight: value } );\n\t\t},\n\t\tonResizeStop: ( newMinHeight ) => {\n\t\t\ttoggleSelection( true );\n\t\t\tsetAttributes( { minHeight: newMinHeight } );\n\t\t},\n\t\t// Hide the resize handle if an aspect ratio is set, as the aspect ratio takes precedence.\n\t\tshowHandle: ! attributes.style?.dimensions?.aspectRatio,\n\t\tsize: resizableBoxDimensions,\n\t\twidth,\n\t};\n\n\tif ( ! useFeaturedImage && ! hasInnerBlocks && ! hasBackground ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ blockControls }\n\t\t\t\t{ inspectorControls }\n\t\t\t\t{ hasNonContentControls && isSelected && (\n\t\t\t\t\t<ResizableCoverPopover { ...resizableCoverProps } />\n\t\t\t\t) }\n\t\t\t\t<TagName\n\t\t\t\t\t{ ...blockProps }\n\t\t\t\t\tclassName={ clsx( 'is-placeholder', blockProps.className ) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...blockProps.style,\n\t\t\t\t\t\tminHeight: minHeightWithUnit || undefined,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ resizeListener }\n\t\t\t\t\t<CoverPlaceholder\n\t\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"wp-block-cover__placeholder-background-options\">\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tdisableCustomColors\n\t\t\t\t\t\t\t\tvalue={ overlayColor.color }\n\t\t\t\t\t\t\t\tonChange={ onSetOverlayColor }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tasButtons\n\t\t\t\t\t\t\t\taria-label={ __( 'Overlay color' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</CoverPlaceholder>\n\t\t\t\t</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst classes = clsx(\n\t\t{\n\t\t\t'is-dark-theme': isDark,\n\t\t\t'is-light': ! isDark,\n\t\t\t'is-transient': isUploadingMedia,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t\t'has-custom-content-position':\n\t\t\t\t! isContentPositionCenter( contentPosition ),\n\t\t},\n\t\tgetPositionClassName( contentPosition )\n\t);\n\n\tconst showOverlay =\n\t\turl || ! useFeaturedImage || ( useFeaturedImage && ! url );\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ clsx( classes, blockProps.className ) }\n\t\t\t\tstyle={ { ...style, ...blockProps.style } }\n\t\t\t\tdata-url={ url }\n\t\t\t>\n\t\t\t\t{ resizeListener }\n\n\t\t\t\t{ ! url && useFeaturedImage && (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\tclassName=\"wp-block-cover__image--placeholder-image\"\n\t\t\t\t\t\twithIllustration\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ url &&\n\t\t\t\t\tisImageBackground &&\n\t\t\t\t\t( isImgElement ? (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\tclassName=\"wp-block-cover__image-background\"\n\t\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\trole={ alt ? 'img' : undefined }\n\t\t\t\t\t\t\taria-label={ alt ? alt : undefined }\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\tclasses,\n\t\t\t\t\t\t\t\t'wp-block-cover__image-background'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ { backgroundImage, backgroundPosition } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ url && isVideoBackground && (\n\t\t\t\t\t<video\n\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\tclassName=\"wp-block-cover__video-background\"\n\t\t\t\t\t\tautoPlay\n\t\t\t\t\t\tmuted\n\t\t\t\t\t\tloop\n\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showOverlay && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'wp-block-cover__background',\n\t\t\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t\t\t// For backwards compatibility. Former versions of the Cover Block applied\n\t\t\t\t\t\t\t\t// `.wp-block-cover__gradient-background` in the presence of\n\t\t\t\t\t\t\t\t// media, a gradient and a dim.\n\t\t\t\t\t\t\t\t'wp-block-cover__gradient-background':\n\t\t\t\t\t\t\t\t\turl && gradientValue && dimRatio !== 0,\n\t\t\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ { backgroundImage: gradientValue, ...bgStyle } }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ isUploadingMedia && <Spinner /> }\n\n\t\t\t\t<CoverPlaceholder\n\t\t\t\t\tdisableMediaButtons\n\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t/>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</TagName>\n\t\t\t{ hasNonContentControls && isSelected && (\n\t\t\t\t<ResizableCoverPopover { ...resizableCoverProps } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( CoverEdit );\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,eAAe,SAAS,iBAAiB;AAClD,SAAS,WAAW,SAAS,cAAc;AAC3C,SAAS,aAAa,eAAe;AACrC,SAAS,SAAS,yBAAyB;AAC3C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,WAAW,mBAAmB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,oBAAoB;AAKtC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,4BAA4B;AACnC,OAAO,wBAAwB;AAC/B,OAAO,sBAAsB;AAC7B,OAAO,2BAA2B;AAClC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,+BAA+B;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\nimport { Placeholder, Spinner } from '@wordpress/components';\nimport { compose, useResizeObserver } from '@wordpress/compose';\nimport {\n\twithColors,\n\tColorPalette,\n\tuseBlockProps,\n\tuseSettings,\n\tuseInnerBlocksProps,\n\t__experimentalUseGradient,\n\tstore as blockEditorStore,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport {\n\tattributesFromMedia,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tEMBED_VIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n} from '../shared';\nimport CoverInspectorControls from './inspector-controls';\nimport CoverBlockControls from './block-controls';\nimport CoverPlaceholder from './cover-placeholder';\nimport ResizableCoverPopover from './resizable-cover-popover';\nimport {\n\tgetMediaColor,\n\tcompositeIsDark,\n\tDEFAULT_BACKGROUND_COLOR,\n\tDEFAULT_OVERLAY_COLOR,\n} from './color-utils';\nimport { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';\nimport { getIframeSrc, getBackgroundVideoSrc } from '../embed-video-utils';\n\nfunction getInnerBlocksTemplate( attributes ) {\n\treturn [\n\t\t[\n\t\t\t'core/paragraph',\n\t\t\t{\n\t\t\t\talign: 'center',\n\t\t\t\tplaceholder: __( 'Write title\u2026' ),\n\t\t\t\t...attributes,\n\t\t\t},\n\t\t],\n\t];\n}\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily while\n * the media (image or video) is being uploaded and will not have an id allocated yet.\n *\n * @param {number} id The id of the media.\n * @param {string} url The url of the media.\n *\n * @return {boolean} Is the URL a Blob URL.\n */\nconst isTemporaryMedia = ( id, url ) => ! id && isBlobURL( url );\n\nfunction CoverEdit( {\n\tattributes,\n\tclientId,\n\tisSelected,\n\toverlayColor,\n\tsetAttributes,\n\tsetOverlayColor,\n\ttoggleSelection,\n\tcontext: { postId, postType },\n} ) {\n\tconst {\n\t\tcontentPosition,\n\t\tid,\n\t\turl: originalUrl,\n\t\tbackgroundType: originalBackgroundType,\n\t\tuseFeaturedImage,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\thasParallax,\n\t\tisDark,\n\t\tisRepeated,\n\t\tminHeight,\n\t\tminHeightUnit,\n\t\talt,\n\t\tallowedBlocks,\n\t\ttemplateLock,\n\t\ttagName: TagName = 'div',\n\t\tisUserOverlayColor,\n\t\tsizeSlug,\n\t\tposter,\n\t} = attributes;\n\n\tconst [ featuredImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\tconst { getSettings } = useSelect( blockEditorStore );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { media } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage && useFeaturedImage\n\t\t\t\t\t\t? select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\tfeaturedImage,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, useFeaturedImage ]\n\t);\n\tconst mediaUrl =\n\t\tmedia?.media_details?.sizes?.[ sizeSlug ]?.source_url ??\n\t\tmedia?.source_url;\n\n\t// User can change the featured image outside of the block, but we still\n\t// need to update the block when that happens. This effect should only\n\t// run when the featured image changes in that case. All other cases are\n\t// handled in their respective callbacks.\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tif ( ! useFeaturedImage ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst averageBackgroundColor = await getMediaColor( mediaUrl );\n\n\t\t\tlet newOverlayColor = overlayColor.color;\n\t\t\tif ( ! isUserOverlayColor ) {\n\t\t\t\tnewOverlayColor = averageBackgroundColor;\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetOverlayColor( newOverlayColor );\n\t\t\t}\n\n\t\t\tconst newIsDark = compositeIsDark(\n\t\t\t\tdimRatio,\n\t\t\t\tnewOverlayColor,\n\t\t\t\taverageBackgroundColor\n\t\t\t);\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tisDark: newIsDark,\n\t\t\t\tisUserOverlayColor: isUserOverlayColor || false,\n\t\t\t} );\n\t\t} )();\n\t\t// Update the block only when the featured image changes.\n\t}, [ mediaUrl ] );\n\n\t// instead of destructuring the attributes\n\t// we define the url and background type\n\t// depending on the value of the useFeaturedImage flag\n\t// to preview in edit the dynamic featured image\n\tconst url = useFeaturedImage\n\t\t? mediaUrl\n\t\t: // Ensure the url is not malformed due to sanitization through `wp_kses`.\n\t\t originalUrl?.replaceAll( '&', '&' );\n\tconst backgroundType = useFeaturedImage\n\t\t? IMAGE_BACKGROUND_TYPE\n\t\t: originalBackgroundType;\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { gradientClass, gradientValue } = __experimentalUseGradient();\n\n\tconst onSelectMedia = async ( newMedia ) => {\n\t\tconst mediaAttributes = attributesFromMedia( newMedia );\n\t\tconst isImage = [ newMedia?.type, newMedia?.media_type ].includes(\n\t\t\tIMAGE_BACKGROUND_TYPE\n\t\t);\n\n\t\tconst averageBackgroundColor = await getMediaColor(\n\t\t\tisImage ? newMedia?.url : undefined\n\t\t);\n\n\t\tlet newOverlayColor = overlayColor.color;\n\t\tif ( ! isUserOverlayColor ) {\n\t\t\tnewOverlayColor = averageBackgroundColor;\n\t\t\tsetOverlayColor( newOverlayColor );\n\n\t\t\t// Make undo revert the next setAttributes and the previous setOverlayColor.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\t// Only set a new dimRatio if there was no previous media selected\n\t\t// to avoid resetting to 50 if it has been explicitly set to 100.\n\t\t// See issue #52835 for context.\n\t\tconst newDimRatio =\n\t\t\toriginalUrl === undefined && dimRatio === 100 ? 50 : dimRatio;\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tif ( backgroundType === IMAGE_BACKGROUND_TYPE && mediaAttributes?.id ) {\n\t\t\tconst { imageDefaultSize } = getSettings();\n\n\t\t\t// Try to use the previous selected image size if it's available\n\t\t\t// otherwise try the default image size or fallback to full size.\n\t\t\tif (\n\t\t\t\tsizeSlug &&\n\t\t\t\t( newMedia?.sizes?.[ sizeSlug ] ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ sizeSlug ] )\n\t\t\t) {\n\t\t\t\tmediaAttributes.sizeSlug = sizeSlug;\n\t\t\t\tmediaAttributes.url =\n\t\t\t\t\tnewMedia?.sizes?.[ sizeSlug ]?.url ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ sizeSlug ]?.source_url;\n\t\t\t} else if (\n\t\t\t\tnewMedia?.sizes?.[ imageDefaultSize ] ||\n\t\t\t\tnewMedia?.media_details?.sizes?.[ imageDefaultSize ]\n\t\t\t) {\n\t\t\t\tmediaAttributes.sizeSlug = imageDefaultSize;\n\t\t\t\tmediaAttributes.url =\n\t\t\t\t\tnewMedia?.sizes?.[ imageDefaultSize ]?.url ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ imageDefaultSize ]\n\t\t\t\t\t\t?.source_url;\n\t\t\t} else {\n\t\t\t\tmediaAttributes.sizeSlug = DEFAULT_MEDIA_SIZE_SLUG;\n\t\t\t}\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\t...mediaAttributes,\n\t\t\tfocalPoint: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t\tdimRatio: newDimRatio,\n\t\t\tisDark: newIsDark,\n\t\t\tisUserOverlayColor: isUserOverlayColor || false,\n\t\t} );\n\t};\n\n\tconst onClearMedia = () => {\n\t\tlet newOverlayColor = overlayColor.color;\n\t\tif ( ! isUserOverlayColor ) {\n\t\t\tnewOverlayColor = DEFAULT_OVERLAY_COLOR;\n\t\t\tsetOverlayColor( undefined );\n\n\t\t\t// Make undo revert the next setAttributes and the previous setOverlayColor.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tdimRatio,\n\t\t\tnewOverlayColor,\n\t\t\tDEFAULT_BACKGROUND_COLOR\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tid: undefined,\n\t\t\tbackgroundType: undefined,\n\t\t\tfocalPoint: undefined,\n\t\t\thasParallax: undefined,\n\t\t\tisRepeated: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst onSetOverlayColor = async ( newOverlayColor ) => {\n\t\tconst averageBackgroundColor = await getMediaColor( url );\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tdimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tsetOverlayColor( newOverlayColor );\n\n\t\t// Make undo revert the next setAttributes and the previous setOverlayColor.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\n\t\tsetAttributes( {\n\t\t\tisUserOverlayColor: true,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst onUpdateDimRatio = async ( newDimRatio ) => {\n\t\tconst averageBackgroundColor = await getMediaColor( url );\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\toverlayColor.color,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\tdimRatio: newDimRatio,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectEmbedUrl = ( embedUrl ) => {\n\t\t// Only set a new dimRatio if there was no previous media selected\n\t\t// to avoid resetting to 50 if it has been explicitly set to 100.\n\t\tconst newDimRatio =\n\t\t\toriginalUrl === undefined && dimRatio === 100 ? 50 : dimRatio;\n\n\t\t// Set initial attributes with URL\n\t\tsetAttributes( {\n\t\t\turl: embedUrl,\n\t\t\tbackgroundType: EMBED_VIDEO_BACKGROUND_TYPE,\n\t\t\tdimRatio: newDimRatio,\n\t\t\tid: undefined,\n\t\t\tfocalPoint: undefined,\n\t\t\thasParallax: undefined,\n\t\t\tisRepeated: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t} );\n\t};\n\n\t// Fetch embed preview for embed videos\n\tconst { embedPreview, isFetchingEmbed } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( backgroundType !== EMBED_VIDEO_BACKGROUND_TYPE || ! url ) {\n\t\t\t\treturn {\n\t\t\t\t\tembedPreview: undefined,\n\t\t\t\t\tisFetchingEmbed: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getEmbedPreview, isRequestingEmbedPreview } =\n\t\t\t\tselect( coreStore );\n\n\t\t\treturn {\n\t\t\t\tembedPreview: getEmbedPreview( url ),\n\t\t\t\tisFetchingEmbed: isRequestingEmbedPreview( url ),\n\t\t\t};\n\t\t},\n\t\t[ url, backgroundType ]\n\t);\n\n\t// Compute embedSrc on-the-fly from embed preview for editor display\n\tconst embedSrc = useMemo( () => {\n\t\tif (\n\t\t\tbackgroundType !== EMBED_VIDEO_BACKGROUND_TYPE ||\n\t\t\t! embedPreview?.html\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Extract iframe src from embed HTML\n\t\tconst iframeSrc = getIframeSrc( embedPreview.html );\n\t\tif ( ! iframeSrc ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Modify the src to add background video parameters (provider auto-detected)\n\t\treturn getBackgroundVideoSrc( iframeSrc );\n\t}, [ embedPreview, backgroundType ] );\n\n\tconst isUploadingMedia = isTemporaryMedia( id, url );\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\tconst isEmbedVideoBackground =\n\t\tEMBED_VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\n\tconst [ resizeListener, { height, width } ] = useResizeObserver();\n\tconst resizableBoxDimensions = useMemo( () => {\n\t\treturn {\n\t\t\theight: minHeightUnit === 'px' && minHeight ? minHeight : 'auto',\n\t\t\twidth: 'auto',\n\t\t};\n\t}, [ minHeight, minHeightUnit ] );\n\n\tconst minHeightWithUnit =\n\t\tminHeight && minHeightUnit\n\t\t\t? `${ minHeight }${ minHeightUnit }`\n\t\t\t: minHeight;\n\n\tconst isImgElement = ! ( hasParallax || isRepeated );\n\n\tconst style = {\n\t\tminHeight: minHeightWithUnit || undefined,\n\t};\n\n\tconst backgroundImage = url ? `url(${ url })` : undefined;\n\n\tconst backgroundPosition = mediaPosition( focalPoint );\n\n\tconst bgStyle = { backgroundColor: overlayColor.color };\n\tconst mediaStyle = {\n\t\tobjectPosition:\n\t\t\tfocalPoint && isImgElement\n\t\t\t\t? mediaPosition( focalPoint )\n\t\t\t\t: undefined,\n\t};\n\n\tconst hasBackground = !! ( url || overlayColor.color || gradientValue );\n\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlock( clientId ).innerBlocks.length >\n\t\t\t0,\n\t\t[ clientId ]\n\t);\n\n\tconst ref = useRef();\n\tconst blockProps = useBlockProps( { ref } );\n\n\t// Check for fontSize support before we pass a fontSize attribute to the innerBlocks.\n\tconst [ fontSizes ] = useSettings( 'typography.fontSizes' );\n\tconst hasFontSizes = fontSizes?.length > 0;\n\tconst innerBlocksTemplate = getInnerBlocksTemplate( {\n\t\tfontSize: hasFontSizes ? 'large' : undefined,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'wp-block-cover__inner-container',\n\t\t},\n\t\t{\n\t\t\t// Avoid template sync when the `templateLock` value is `all` or `contentOnly`.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/45632\n\t\t\ttemplate: ! hasInnerBlocks ? innerBlocksTemplate : undefined,\n\t\t\ttemplateInsertUpdatesSelection: true,\n\t\t\tallowedBlocks,\n\t\t\ttemplateLock,\n\t\t\tdropZoneElement: ref.current,\n\t\t}\n\t);\n\n\tconst mediaElement = useRef();\n\tconst currentSettings = {\n\t\tisVideoBackground,\n\t\tisImageBackground,\n\t\tmediaElement,\n\t\thasInnerBlocks,\n\t\turl,\n\t\tisImgElement,\n\t\toverlayColor,\n\t};\n\n\tconst toggleUseFeaturedImage = async () => {\n\t\tconst newUseFeaturedImage = ! useFeaturedImage;\n\n\t\tconst averageBackgroundColor = newUseFeaturedImage\n\t\t\t? await getMediaColor( mediaUrl )\n\t\t\t: DEFAULT_BACKGROUND_COLOR;\n\n\t\tconst newOverlayColor = ! isUserOverlayColor\n\t\t\t? averageBackgroundColor\n\t\t\t: overlayColor.color;\n\n\t\tif ( ! isUserOverlayColor ) {\n\t\t\tif ( newUseFeaturedImage ) {\n\t\t\t\tsetOverlayColor( newOverlayColor );\n\t\t\t} else {\n\t\t\t\tsetOverlayColor( undefined );\n\t\t\t}\n\n\t\t\t// Make undo revert the next setAttributes and the previous setOverlayColor.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\tconst newDimRatio = dimRatio === 100 ? 50 : dimRatio;\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tuseFeaturedImage: newUseFeaturedImage,\n\t\t\tdimRatio: newDimRatio,\n\t\t\tbackgroundType: useFeaturedImage\n\t\t\t\t? IMAGE_BACKGROUND_TYPE\n\t\t\t\t: undefined,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst blockControls = (\n\t\t<CoverBlockControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\tonSelectEmbedUrl={ onSelectEmbedUrl }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\tonClearMedia={ onClearMedia }\n\t\t\tblockEditingMode={ blockEditingMode }\n\t\t/>\n\t);\n\n\tconst inspectorControls = (\n\t\t<CoverInspectorControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tclientId={ clientId }\n\t\t\tsetOverlayColor={ onSetOverlayColor }\n\t\t\tcoverRef={ ref }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\tupdateDimRatio={ onUpdateDimRatio }\n\t\t\tonClearMedia={ onClearMedia }\n\t\t\tfeaturedImage={ media }\n\t\t/>\n\t);\n\n\tconst resizableCoverProps = {\n\t\tclassName: 'block-library-cover__resize-container',\n\t\tclientId,\n\t\theight,\n\t\tminHeight: minHeightWithUnit,\n\t\tonResizeStart: () => {\n\t\t\tsetAttributes( { minHeightUnit: 'px' } );\n\t\t\ttoggleSelection( false );\n\t\t},\n\t\tonResize: ( value ) => {\n\t\t\tsetAttributes( { minHeight: value } );\n\t\t},\n\t\tonResizeStop: ( newMinHeight ) => {\n\t\t\ttoggleSelection( true );\n\t\t\tsetAttributes( { minHeight: newMinHeight } );\n\t\t},\n\t\t// Hide the resize handle if an aspect ratio is set, as the aspect ratio takes precedence.\n\t\tshowHandle: ! attributes.style?.dimensions?.aspectRatio,\n\t\tsize: resizableBoxDimensions,\n\t\twidth,\n\t};\n\n\tif ( ! useFeaturedImage && ! hasInnerBlocks && ! hasBackground ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ blockControls }\n\t\t\t\t{ inspectorControls }\n\t\t\t\t{ hasNonContentControls && isSelected && (\n\t\t\t\t\t<ResizableCoverPopover { ...resizableCoverProps } />\n\t\t\t\t) }\n\t\t\t\t<TagName\n\t\t\t\t\t{ ...blockProps }\n\t\t\t\t\tclassName={ clsx( 'is-placeholder', blockProps.className ) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...blockProps.style,\n\t\t\t\t\t\tminHeight: minHeightWithUnit || undefined,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ resizeListener }\n\t\t\t\t\t<CoverPlaceholder\n\t\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"wp-block-cover__placeholder-background-options\">\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tdisableCustomColors\n\t\t\t\t\t\t\t\tvalue={ overlayColor.color }\n\t\t\t\t\t\t\t\tonChange={ onSetOverlayColor }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tasButtons\n\t\t\t\t\t\t\t\taria-label={ __( 'Overlay color' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</CoverPlaceholder>\n\t\t\t\t</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst classes = clsx(\n\t\t{\n\t\t\t'is-dark-theme': isDark,\n\t\t\t'is-light': ! isDark,\n\t\t\t'is-transient': isUploadingMedia,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t\t'has-custom-content-position':\n\t\t\t\t! isContentPositionCenter( contentPosition ),\n\t\t},\n\t\tgetPositionClassName( contentPosition )\n\t);\n\n\tconst showOverlay =\n\t\turl || ! useFeaturedImage || ( useFeaturedImage && ! url );\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ clsx( classes, blockProps.className ) }\n\t\t\t\tstyle={ { ...style, ...blockProps.style } }\n\t\t\t\tdata-url={ url }\n\t\t\t>\n\t\t\t\t{ resizeListener }\n\n\t\t\t\t{ ! url && useFeaturedImage && (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\tclassName=\"wp-block-cover__image--placeholder-image\"\n\t\t\t\t\t\twithIllustration\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ url &&\n\t\t\t\t\tisImageBackground &&\n\t\t\t\t\t( isImgElement ? (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\tclassName=\"wp-block-cover__image-background\"\n\t\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\trole={ alt ? 'img' : undefined }\n\t\t\t\t\t\t\taria-label={ alt ? alt : undefined }\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\tclasses,\n\t\t\t\t\t\t\t\t'wp-block-cover__image-background'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ { backgroundImage, backgroundPosition } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ url && isVideoBackground && (\n\t\t\t\t\t<video\n\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\tclassName=\"wp-block-cover__video-background\"\n\t\t\t\t\t\tautoPlay\n\t\t\t\t\t\tmuted\n\t\t\t\t\t\tloop\n\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isEmbedVideoBackground && embedSrc && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\tclassName=\"wp-block-cover__video-background wp-block-cover__embed-background\"\n\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t>\n\t\t\t\t\t\t<iframe\n\t\t\t\t\t\t\tsrc={ embedSrc }\n\t\t\t\t\t\t\ttitle=\"Background video\"\n\t\t\t\t\t\t\tframeBorder=\"0\"\n\t\t\t\t\t\t\tallow=\"autoplay; fullscreen\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t{ isEmbedVideoBackground && ! embedSrc && isFetchingEmbed && (\n\t\t\t\t\t<Spinner />\n\t\t\t\t) }\n\n\t\t\t\t{ showOverlay && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'wp-block-cover__background',\n\t\t\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t\t\t// For backwards compatibility. Former versions of the Cover Block applied\n\t\t\t\t\t\t\t\t// `.wp-block-cover__gradient-background` in the presence of\n\t\t\t\t\t\t\t\t// media, a gradient and a dim.\n\t\t\t\t\t\t\t\t'wp-block-cover__gradient-background':\n\t\t\t\t\t\t\t\t\turl && gradientValue && dimRatio !== 0,\n\t\t\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ { backgroundImage: gradientValue, ...bgStyle } }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ isUploadingMedia && <Spinner /> }\n\n\t\t\t\t<CoverPlaceholder\n\t\t\t\t\tdisableMediaButtons\n\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t/>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</TagName>\n\t\t\t{ hasNonContentControls && isSelected && (\n\t\t\t\t<ResizableCoverPopover { ...resizableCoverProps } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( CoverEdit );\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,eAAe,SAAS,iBAAiB;AAClD,SAAS,WAAW,SAAS,cAAc;AAC3C,SAAS,aAAa,eAAe;AACrC,SAAS,SAAS,yBAAyB;AAC3C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,WAAW,mBAAmB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,oBAAoB;AAKtC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,4BAA4B;AACnC,OAAO,wBAAwB;AAC/B,OAAO,sBAAsB;AAC7B,OAAO,2BAA2B;AAClC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,+BAA+B;AACxC,SAAS,cAAc,6BAA6B;AA2clD,SAmDC,UAnDD,KAyDE,YAzDF;AAzcF,SAAS,uBAAwB,YAAa;AAC7C,SAAO;AAAA,IACN;AAAA,MACC;AAAA,MACA;AAAA,QACC,OAAO;AAAA,QACP,aAAa,GAAI,mBAAe;AAAA,QAChC,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACD;AACD;AAWA,IAAM,mBAAmB,CAAE,IAAI,QAAS,CAAE,MAAM,UAAW,GAAI;AAE/D,SAAS,UAAW;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,EAAE,QAAQ,SAAS;AAC7B,GAAI;AACH,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB;AAA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BAAyB,cAC1B,oBAAC,yBAAwB,GAAG,qBAAsB;AAAA,KAEpD;AAEF;AAEA,IAAO,eAAQ,QAAS;AAAA,EACvB,WAAY,EAAE,cAAc,mBAAmB,CAAE;AAClD,CAAE,EAAG,SAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// packages/block-library/src/cover/embed-video-utils.js
|
|
2
|
+
import { getBlockVariations } from "@wordpress/blocks";
|
|
3
|
+
import { matchesPatterns } from "../embed/util";
|
|
4
|
+
var DEFAULT_EMBED_BLOCK = "core/embed";
|
|
5
|
+
var VIDEO_PROVIDERS = [
|
|
6
|
+
"youtube",
|
|
7
|
+
"vimeo",
|
|
8
|
+
"videopress",
|
|
9
|
+
"animoto",
|
|
10
|
+
"tiktok",
|
|
11
|
+
"wordpress-tv"
|
|
12
|
+
];
|
|
13
|
+
function isValidVideoEmbedUrl(url) {
|
|
14
|
+
if (!url) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const embedBlock = findVideoEmbedProvider(url);
|
|
18
|
+
return embedBlock !== null;
|
|
19
|
+
}
|
|
20
|
+
function getVideoEmbedProvider(url) {
|
|
21
|
+
const embedBlock = findVideoEmbedProvider(url);
|
|
22
|
+
return embedBlock ? embedBlock.name : null;
|
|
23
|
+
}
|
|
24
|
+
function findVideoEmbedProvider(url) {
|
|
25
|
+
const embedVariations = getBlockVariations(DEFAULT_EMBED_BLOCK);
|
|
26
|
+
if (!embedVariations) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const matchingVariation = embedVariations.find(
|
|
30
|
+
({ patterns }) => matchesPatterns(url, patterns)
|
|
31
|
+
);
|
|
32
|
+
if (!matchingVariation || !VIDEO_PROVIDERS.includes(matchingVariation.name)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return matchingVariation;
|
|
36
|
+
}
|
|
37
|
+
function getIframeSrc(html) {
|
|
38
|
+
if (!html) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const srcMatch = html.match(/src=["']([^"']+)["']/);
|
|
42
|
+
return srcMatch ? srcMatch[1] : null;
|
|
43
|
+
}
|
|
44
|
+
function detectProviderFromSrc(src) {
|
|
45
|
+
if (!src) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const lowerSrc = src.toLowerCase();
|
|
49
|
+
if (lowerSrc.includes("youtube.com") || lowerSrc.includes("youtu.be")) {
|
|
50
|
+
return "youtube";
|
|
51
|
+
}
|
|
52
|
+
if (lowerSrc.includes("vimeo.com")) {
|
|
53
|
+
return "vimeo";
|
|
54
|
+
}
|
|
55
|
+
if (lowerSrc.includes("videopress.com")) {
|
|
56
|
+
return "videopress";
|
|
57
|
+
}
|
|
58
|
+
if (lowerSrc.includes("animoto.com")) {
|
|
59
|
+
return "animoto";
|
|
60
|
+
}
|
|
61
|
+
if (lowerSrc.includes("tiktok.com")) {
|
|
62
|
+
return "tiktok";
|
|
63
|
+
}
|
|
64
|
+
if (lowerSrc.includes("wordpress.tv")) {
|
|
65
|
+
return "wordpress-tv";
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function getBackgroundVideoSrc(src) {
|
|
70
|
+
if (!src) {
|
|
71
|
+
return src;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const url = new URL(src);
|
|
75
|
+
const provider = detectProviderFromSrc(src);
|
|
76
|
+
switch (provider) {
|
|
77
|
+
case "youtube":
|
|
78
|
+
url.searchParams.set("autoplay", "1");
|
|
79
|
+
url.searchParams.set("mute", "1");
|
|
80
|
+
url.searchParams.set("loop", "1");
|
|
81
|
+
url.searchParams.set("controls", "0");
|
|
82
|
+
url.searchParams.set("showinfo", "0");
|
|
83
|
+
url.searchParams.set("modestbranding", "1");
|
|
84
|
+
url.searchParams.set("playsinline", "1");
|
|
85
|
+
url.searchParams.set("rel", "0");
|
|
86
|
+
const videoId = url.pathname.split("/").pop();
|
|
87
|
+
if (videoId) {
|
|
88
|
+
url.searchParams.set("playlist", videoId);
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case "vimeo":
|
|
92
|
+
url.searchParams.set("autoplay", "1");
|
|
93
|
+
url.searchParams.set("muted", "1");
|
|
94
|
+
url.searchParams.set("loop", "1");
|
|
95
|
+
url.searchParams.set("background", "1");
|
|
96
|
+
url.searchParams.set("controls", "0");
|
|
97
|
+
break;
|
|
98
|
+
case "videopress":
|
|
99
|
+
case "wordpress-tv":
|
|
100
|
+
url.searchParams.set("autoplay", "1");
|
|
101
|
+
url.searchParams.set("loop", "1");
|
|
102
|
+
url.searchParams.set("muted", "1");
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
url.searchParams.set("autoplay", "1");
|
|
106
|
+
url.searchParams.set("muted", "1");
|
|
107
|
+
url.searchParams.set("loop", "1");
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
return url.toString();
|
|
111
|
+
} catch (error) {
|
|
112
|
+
return src;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
detectProviderFromSrc,
|
|
117
|
+
getBackgroundVideoSrc,
|
|
118
|
+
getIframeSrc,
|
|
119
|
+
getVideoEmbedProvider,
|
|
120
|
+
isValidVideoEmbedUrl
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=embed-video-utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cover/embed-video-utils.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockVariations } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { matchesPatterns } from '../embed/util';\n\nconst DEFAULT_EMBED_BLOCK = 'core/embed';\n\n// List of supported video providers for cover block backgrounds\nconst VIDEO_PROVIDERS = [\n\t'youtube',\n\t'vimeo',\n\t'videopress',\n\t'animoto',\n\t'tiktok',\n\t'wordpress-tv',\n];\n\n/**\n * Checks if a URL is a valid video embed URL from supported providers.\n *\n * @param {string} url The URL to validate.\n * @return {boolean} True if the URL matches a supported video provider pattern.\n */\nexport function isValidVideoEmbedUrl( url ) {\n\tif ( ! url ) {\n\t\treturn false;\n\t}\n\n\tconst embedBlock = findVideoEmbedProvider( url );\n\treturn embedBlock !== null;\n}\n\n/**\n * Finds the embed provider for a given URL if it's a supported video provider.\n *\n * @param {string} url The URL to check.\n * @return {string|null} The provider name slug (e.g., 'youtube') or null if not found.\n */\nexport function getVideoEmbedProvider( url ) {\n\tconst embedBlock = findVideoEmbedProvider( url );\n\treturn embedBlock ? embedBlock.name : null;\n}\n\n/**\n * Finds a matching video embed block variation for the given URL.\n *\n * @param {string} url The URL to match against provider patterns.\n * @return {Object|null} The matching block variation or null if not found.\n */\nfunction findVideoEmbedProvider( url ) {\n\tconst embedVariations = getBlockVariations( DEFAULT_EMBED_BLOCK );\n\n\tif ( ! embedVariations ) {\n\t\treturn null;\n\t}\n\n\tconst matchingVariation = embedVariations.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\n\tif (\n\t\t! matchingVariation ||\n\t\t! VIDEO_PROVIDERS.includes( matchingVariation.name )\n\t) {\n\t\treturn null;\n\t}\n\n\treturn matchingVariation;\n}\n\n/**\n * Extracts iframe src from embed HTML.\n *\n * @param {string} html The embed HTML.\n * @return {string|null} The iframe src URL or null if not found.\n */\nexport function getIframeSrc( html ) {\n\tif ( ! html ) {\n\t\treturn null;\n\t}\n\n\tconst srcMatch = html.match( /src=[\"']([^\"']+)[\"']/ );\n\treturn srcMatch ? srcMatch[ 1 ] : null;\n}\n\n/**\n * Detects the video provider from an iframe src URL.\n *\n * @param {string} src The iframe src URL.\n * @return {string|null} The provider name slug or null if not recognized.\n */\nexport function detectProviderFromSrc( src ) {\n\tif ( ! src ) {\n\t\treturn null;\n\t}\n\n\tconst lowerSrc = src.toLowerCase();\n\n\tif (\n\t\tlowerSrc.includes( 'youtube.com' ) ||\n\t\tlowerSrc.includes( 'youtu.be' )\n\t) {\n\t\treturn 'youtube';\n\t}\n\tif ( lowerSrc.includes( 'vimeo.com' ) ) {\n\t\treturn 'vimeo';\n\t}\n\tif ( lowerSrc.includes( 'videopress.com' ) ) {\n\t\treturn 'videopress';\n\t}\n\tif ( lowerSrc.includes( 'animoto.com' ) ) {\n\t\treturn 'animoto';\n\t}\n\tif ( lowerSrc.includes( 'tiktok.com' ) ) {\n\t\treturn 'tiktok';\n\t}\n\tif ( lowerSrc.includes( 'wordpress.tv' ) ) {\n\t\treturn 'wordpress-tv';\n\t}\n\n\treturn null;\n}\n\n/**\n * Modifies an iframe src URL to add background video parameters.\n * Automatically detects the provider from the URL.\n *\n * @param {string} src The iframe src URL.\n * @return {string} The modified URL.\n */\nexport function getBackgroundVideoSrc( src ) {\n\tif ( ! src ) {\n\t\treturn src;\n\t}\n\n\ttry {\n\t\tconst url = new URL( src );\n\n\t\t// Detect provider from the iframe src URL\n\t\tconst provider = detectProviderFromSrc( src );\n\n\t\t// Add provider-specific parameters for background video behavior\n\t\tswitch ( provider ) {\n\t\t\tcase 'youtube':\n\t\t\t\t// YouTube parameters for background video\n\t\t\t\turl.searchParams.set( 'autoplay', '1' );\n\t\t\t\turl.searchParams.set( 'mute', '1' );\n\t\t\t\turl.searchParams.set( 'loop', '1' );\n\t\t\t\turl.searchParams.set( 'controls', '0' );\n\t\t\t\turl.searchParams.set( 'showinfo', '0' );\n\t\t\t\turl.searchParams.set( 'modestbranding', '1' );\n\t\t\t\turl.searchParams.set( 'playsinline', '1' );\n\t\t\t\turl.searchParams.set( 'rel', '0' );\n\t\t\t\t// For loop to work, we need the playlist parameter\n\t\t\t\tconst videoId = url.pathname.split( '/' ).pop();\n\t\t\t\tif ( videoId ) {\n\t\t\t\t\turl.searchParams.set( 'playlist', videoId );\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'vimeo':\n\t\t\t\t// Vimeo parameters for background video\n\t\t\t\turl.searchParams.set( 'autoplay', '1' );\n\t\t\t\turl.searchParams.set( 'muted', '1' );\n\t\t\t\turl.searchParams.set( 'loop', '1' );\n\t\t\t\turl.searchParams.set( 'background', '1' );\n\t\t\t\turl.searchParams.set( 'controls', '0' );\n\t\t\t\tbreak;\n\n\t\t\tcase 'videopress':\n\t\t\tcase 'wordpress-tv':\n\t\t\t\t// VideoPress parameters\n\t\t\t\turl.searchParams.set( 'autoplay', '1' );\n\t\t\t\turl.searchParams.set( 'loop', '1' );\n\t\t\t\turl.searchParams.set( 'muted', '1' );\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// Generic parameters that might work for other providers\n\t\t\t\turl.searchParams.set( 'autoplay', '1' );\n\t\t\t\turl.searchParams.set( 'muted', '1' );\n\t\t\t\turl.searchParams.set( 'loop', '1' );\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn url.toString();\n\t} catch ( error ) {\n\t\t// If URL parsing fails, return original src\n\t\treturn src;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,0BAA0B;AAKnC,SAAS,uBAAuB;AAEhC,IAAM,sBAAsB;AAG5B,IAAM,kBAAkB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAQO,SAAS,qBAAsB,KAAM;AAC3C,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAEA,QAAM,aAAa,uBAAwB,GAAI;AAC/C,SAAO,eAAe;AACvB;AAQO,SAAS,sBAAuB,KAAM;AAC5C,QAAM,aAAa,uBAAwB,GAAI;AAC/C,SAAO,aAAa,WAAW,OAAO;AACvC;AAQA,SAAS,uBAAwB,KAAM;AACtC,QAAM,kBAAkB,mBAAoB,mBAAoB;AAEhE,MAAK,CAAE,iBAAkB;AACxB,WAAO;AAAA,EACR;AAEA,QAAM,oBAAoB,gBAAgB;AAAA,IAAM,CAAE,EAAE,SAAS,MA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,GAAI;AACzC,YAAI,aAAa,IAAK,OAAO,GAAI;AAEjC,cAAM,UAAU,IAAI,SAAS,MAAO,GAAI,EAAE,IAAI;AAC9C,YAAK,SAAU;AACd,cAAI,aAAa,IAAK,YAAY,OAAQ;AAAA,QAC3C;AACA;AAAA,MAED,KAAK;AAEJ,YAAI,aAAa,IAAK,YAAY,GAAI;AACtC,YAAI,aAAa,IAAK,SAAS,GAAI;AACnC,YAAI,aAAa,IAAK,QAAQ,GAAI;AAClC,YAAI,aAAa,IAAK,cAAc,GAAI;AACxC,YAAI,aAAa,IAAK,YAAY,GAAI;AACtC;AAAA,MAED,KAAK;AAAA,MACL,KAAK;AAEJ,YAAI,aAAa,IAAK,YAAY,GAAI;AACtC,YAAI,aAAa,IAAK,QAAQ,GAAI;AAClC,YAAI,aAAa,IAAK,SAAS,GAAI;AACnC;AAAA,MAED;AAEC,YAAI,aAAa,IAAK,YAAY,GAAI;AACtC,YAAI,aAAa,IAAK,SAAS,GAAI;AACnC,YAAI,aAAa,IAAK,QAAQ,GAAI;AAClC;AAAA,IACF;AAEA,WAAO,IAAI,SAAS;AAAA,EACrB,SAAU,OAAQ;AAEjB,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// packages/block-library/src/cover/index.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { cover as icon } from "@wordpress/icons";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block";
|
|
5
6
|
import deprecated from "./deprecated";
|
|
6
7
|
import edit from "./edit";
|
|
@@ -8,6 +9,8 @@ import metadata from "./block.json";
|
|
|
8
9
|
import save from "./save";
|
|
9
10
|
import transforms from "./transforms";
|
|
10
11
|
import variations from "./variations";
|
|
12
|
+
import { unlock } from "../lock-unlock";
|
|
13
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
11
14
|
var { name } = metadata;
|
|
12
15
|
var settings = {
|
|
13
16
|
icon,
|
|
@@ -41,16 +44,16 @@ var settings = {
|
|
|
41
44
|
deprecated,
|
|
42
45
|
variations
|
|
43
46
|
};
|
|
44
|
-
if (window.
|
|
45
|
-
settings
|
|
47
|
+
if (window.__experimentalContentOnlyInspectorFields) {
|
|
48
|
+
settings[fieldsKey] = [
|
|
46
49
|
{
|
|
50
|
+
id: "background",
|
|
47
51
|
label: __("Background"),
|
|
48
|
-
type: "
|
|
49
|
-
shownByDefault: true,
|
|
52
|
+
type: "media",
|
|
50
53
|
mapping: {
|
|
51
54
|
type: "backgroundType",
|
|
52
55
|
id: "id",
|
|
53
|
-
|
|
56
|
+
url: "url",
|
|
54
57
|
alt: "alt",
|
|
55
58
|
featuredImage: "useFeaturedImage"
|
|
56
59
|
},
|
|
@@ -62,6 +65,9 @@ if (window.__experimentalContentOnlyPatternInsertion) {
|
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
];
|
|
68
|
+
settings[formKey] = {
|
|
69
|
+
fields: ["background"]
|
|
70
|
+
};
|
|
65
71
|
}
|
|
66
72
|
var init = () => initBlock({ name, metadata, settings });
|
|
67
73
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cover/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cover as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcustomOverlayColor: '#065174',\n\t\t\tdimRatio: 40,\n\t\t\turl: 'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\tstyle: {\n\t\t\t\ttypography: {\n\t\t\t\t\tfontSize: 48,\n\t\t\t\t},\n\t\t\t\tcolor: {\n\t\t\t\t\ttext: 'white',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: `<strong>${ __( 'Snow Patrol' ) }</strong>`,\n\t\t\t\t\talign: 'center',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tsave,\n\tedit,\n\tdeprecated,\n\tvariations,\n};\n\nif ( window.
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,SAAS,YAAY;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cover as icon } from '@wordpress/icons';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcustomOverlayColor: '#065174',\n\t\t\tdimRatio: 40,\n\t\t\turl: 'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\tstyle: {\n\t\t\t\ttypography: {\n\t\t\t\t\tfontSize: 48,\n\t\t\t\t},\n\t\t\t\tcolor: {\n\t\t\t\t\ttext: 'white',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: `<strong>${ __( 'Snow Patrol' ) }</strong>`,\n\t\t\t\t\talign: 'center',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tsave,\n\tedit,\n\tdeprecated,\n\tvariations,\n};\n\nif ( window.__experimentalContentOnlyInspectorFields ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'background',\n\t\t\tlabel: __( 'Background' ),\n\t\t\ttype: 'media',\n\t\t\tmapping: {\n\t\t\t\ttype: 'backgroundType',\n\t\t\t\tid: 'id',\n\t\t\t\turl: 'url',\n\t\t\t\talt: 'alt',\n\t\t\t\tfeaturedImage: 'useFeaturedImage',\n\t\t\t},\n\t\t\targs: {\n\t\t\t\t// TODO - How to support custom gradient?\n\t\t\t\t// Build it into Media, or use a custom control?\n\t\t\t\tallowedTypes: [ 'image', 'video' ],\n\t\t\t\tmultiple: false,\n\t\t\t},\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'background' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,SAAS,YAAY;AAC9B,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,oBAAoB;AAAA,MACpB,UAAU;AAAA,MACV,KAAK;AAAA,MACL,OAAO;AAAA,QACN,YAAY;AAAA,UACX,UAAU;AAAA,QACX;AAAA,QACA,OAAO;AAAA,UACN,MAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IACA,aAAa;AAAA,MACZ;AAAA,QACC,MAAM;AAAA,QACN,YAAY;AAAA,UACX,SAAS,WAAY,GAAI,aAAc,CAAE;AAAA,UACzC,OAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAK,OAAO,0CAA2C;AACtD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,YAAa;AAAA,MACxB,MAAM;AAAA,MACN,SAAS;AAAA,QACR,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,KAAK;AAAA,QACL,KAAK;AAAA,QACL,eAAe;AAAA,MAChB;AAAA,MACA,MAAM;AAAA;AAAA;AAAA,QAGL,cAAc,CAAE,SAAS,OAAQ;AAAA,QACjC,UAAU;AAAA,MACX;AAAA,IACD;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,YAAa;AAAA,EACxB;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
IMAGE_BACKGROUND_TYPE,
|
|
11
11
|
VIDEO_BACKGROUND_TYPE,
|
|
12
|
+
EMBED_VIDEO_BACKGROUND_TYPE,
|
|
12
13
|
dimRatioToClass,
|
|
13
14
|
isContentPositionCenter,
|
|
14
15
|
getPositionClassName,
|
|
@@ -46,6 +47,7 @@ function save({ attributes }) {
|
|
|
46
47
|
const minHeight = minHeightProp && minHeightUnit ? `${minHeightProp}${minHeightUnit}` : minHeightProp;
|
|
47
48
|
const isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;
|
|
48
49
|
const isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;
|
|
50
|
+
const isEmbedVideoBackground = EMBED_VIDEO_BACKGROUND_TYPE === backgroundType;
|
|
49
51
|
const isImgElement = !(hasParallax || isRepeated);
|
|
50
52
|
const style = {
|
|
51
53
|
minHeight: minHeight || void 0
|
|
@@ -117,6 +119,17 @@ function save({ attributes }) {
|
|
|
117
119
|
"data-object-position": objectPosition
|
|
118
120
|
}
|
|
119
121
|
),
|
|
122
|
+
isEmbedVideoBackground && url && /* @__PURE__ */ jsx(
|
|
123
|
+
"figure",
|
|
124
|
+
{
|
|
125
|
+
className: clsx(
|
|
126
|
+
"wp-block-cover__video-background",
|
|
127
|
+
"wp-block-cover__embed-background",
|
|
128
|
+
"wp-block-embed"
|
|
129
|
+
),
|
|
130
|
+
children: /* @__PURE__ */ jsx("div", { className: "wp-block-embed__wrapper", children: url })
|
|
131
|
+
}
|
|
132
|
+
),
|
|
120
133
|
/* @__PURE__ */ jsx(
|
|
121
134
|
"span",
|
|
122
135
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cover/save.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseInnerBlocksProps,\n\tgetColorClassName,\n\t__experimentalGetGradientClass,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n} from './shared';\n\nexport default function save( { attributes } ) {\n\tconst {\n\t\tbackgroundType,\n\t\tgradient,\n\t\tcontentPosition,\n\t\tcustomGradient,\n\t\tcustomOverlayColor,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\tuseFeaturedImage,\n\t\thasParallax,\n\t\tisDark,\n\t\tisRepeated,\n\t\toverlayColor,\n\t\turl,\n\t\talt,\n\t\tid,\n\t\tminHeight: minHeightProp,\n\t\tminHeightUnit,\n\t\ttagName: Tag,\n\t\tsizeSlug,\n\t\tposter,\n\t} = attributes;\n\tconst overlayColorClass = getColorClassName(\n\t\t'background-color',\n\t\toverlayColor\n\t);\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst minHeight =\n\t\tminHeightProp && minHeightUnit\n\t\t\t? `${ minHeightProp }${ minHeightUnit }`\n\t\t\t: minHeightProp;\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst isImgElement = ! ( hasParallax || isRepeated );\n\n\tconst style = {\n\t\tminHeight: minHeight || undefined,\n\t};\n\n\tconst bgStyle = {\n\t\tbackgroundColor: ! overlayColorClass ? customOverlayColor : undefined,\n\t\tbackground: customGradient ? customGradient : undefined,\n\t};\n\n\tconst objectPosition =\n\t\t// prettier-ignore\n\t\tfocalPoint && isImgElement\n\t\t\t ? mediaPosition(focalPoint)\n\t\t\t : undefined;\n\n\tconst backgroundImage = url ? `url(${ url })` : undefined;\n\n\tconst backgroundPosition = mediaPosition( focalPoint );\n\n\tconst classes = clsx(\n\t\t{\n\t\t\t'is-light': ! isDark,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t\t'has-custom-content-position':\n\t\t\t\t! isContentPositionCenter( contentPosition ),\n\t\t},\n\t\tgetPositionClassName( contentPosition )\n\t);\n\n\tconst imgClasses = clsx(\n\t\t'wp-block-cover__image-background',\n\t\tid ? `wp-image-${ id }` : null,\n\t\t{\n\t\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t}\n\t);\n\n\tconst gradientValue = gradient || customGradient;\n\n\treturn (\n\t\t<Tag { ...useBlockProps.save( { className: classes, style } ) }>\n\t\t\t{ ! useFeaturedImage &&\n\t\t\t\tisImageBackground &&\n\t\t\t\turl &&\n\t\t\t\t( isImgElement ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName={ imgClasses }\n\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\tstyle={ { objectPosition } }\n\t\t\t\t\t\tdata-object-fit=\"cover\"\n\t\t\t\t\t\tdata-object-position={ objectPosition }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<div\n\t\t\t\t\t\trole={ alt ? 'img' : undefined }\n\t\t\t\t\t\taria-label={ alt ? alt : undefined }\n\t\t\t\t\t\tclassName={ imgClasses }\n\t\t\t\t\t\tstyle={ { backgroundPosition, backgroundImage } }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ isVideoBackground && url && (\n\t\t\t\t<video\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'wp-block-cover__video-background',\n\t\t\t\t\t\t'intrinsic-ignore'\n\t\t\t\t\t) }\n\t\t\t\t\tautoPlay\n\t\t\t\t\tmuted\n\t\t\t\t\tloop\n\t\t\t\t\tplaysInline\n\t\t\t\t\tsrc={ url }\n\t\t\t\t\tposter={ poster }\n\t\t\t\t\tstyle={ { objectPosition } }\n\t\t\t\t\tdata-object-fit=\"cover\"\n\t\t\t\t\tdata-object-position={ objectPosition }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ /* The `wp-block-cover__background` needs to be immediately before\n\t\t\tthe `wp-block-cover__inner-container`, so the exclusion CSS selector\n\t\t\t`.wp-block-cover__background + .wp-block-cover__inner-container`\n\t\t\tworks properly. If it needs to be changed in the future, the\n\t\t\tselector for the backward compatibility for v14 deprecation also\n\t\t\tneeds change. */ }\n\t\t\t<span\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-block-cover__background',\n\t\t\t\t\toverlayColorClass,\n\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t{\n\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t// For backwards compatibility. Former versions of the Cover Block applied\n\t\t\t\t\t\t// `.wp-block-cover__gradient-background` in the presence of\n\t\t\t\t\t\t// media, a gradient and a dim.\n\t\t\t\t\t\t'wp-block-cover__gradient-background':\n\t\t\t\t\t\t\turl && gradientValue && dimRatio !== 0,\n\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tstyle={ bgStyle }\n\t\t\t/>\n\n\t\t\t<div\n\t\t\t\t{ ...useInnerBlocksProps.save( {\n\t\t\t\t\tclassName: 'wp-block-cover__inner-container',\n\t\t\t\t} ) }\n\t\t\t/>\n\t\t</Tag>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseInnerBlocksProps,\n\tgetColorClassName,\n\t__experimentalGetGradientClass,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tEMBED_VIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n} from './shared';\n\nexport default function save( { attributes } ) {\n\tconst {\n\t\tbackgroundType,\n\t\tgradient,\n\t\tcontentPosition,\n\t\tcustomGradient,\n\t\tcustomOverlayColor,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\tuseFeaturedImage,\n\t\thasParallax,\n\t\tisDark,\n\t\tisRepeated,\n\t\toverlayColor,\n\t\turl,\n\t\talt,\n\t\tid,\n\t\tminHeight: minHeightProp,\n\t\tminHeightUnit,\n\t\ttagName: Tag,\n\t\tsizeSlug,\n\t\tposter,\n\t} = attributes;\n\tconst overlayColorClass = getColorClassName(\n\t\t'background-color',\n\t\toverlayColor\n\t);\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst minHeight =\n\t\tminHeightProp && minHeightUnit\n\t\t\t? `${ minHeightProp }${ minHeightUnit }`\n\t\t\t: minHeightProp;\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\tconst isEmbedVideoBackground =\n\t\tEMBED_VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst isImgElement = ! ( hasParallax || isRepeated );\n\n\tconst style = {\n\t\tminHeight: minHeight || undefined,\n\t};\n\n\tconst bgStyle = {\n\t\tbackgroundColor: ! overlayColorClass ? customOverlayColor : undefined,\n\t\tbackground: customGradient ? customGradient : undefined,\n\t};\n\n\tconst objectPosition =\n\t\t// prettier-ignore\n\t\tfocalPoint && isImgElement\n\t\t\t ? mediaPosition(focalPoint)\n\t\t\t : undefined;\n\n\tconst backgroundImage = url ? `url(${ url })` : undefined;\n\n\tconst backgroundPosition = mediaPosition( focalPoint );\n\n\tconst classes = clsx(\n\t\t{\n\t\t\t'is-light': ! isDark,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t\t'has-custom-content-position':\n\t\t\t\t! isContentPositionCenter( contentPosition ),\n\t\t},\n\t\tgetPositionClassName( contentPosition )\n\t);\n\n\tconst imgClasses = clsx(\n\t\t'wp-block-cover__image-background',\n\t\tid ? `wp-image-${ id }` : null,\n\t\t{\n\t\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t}\n\t);\n\n\tconst gradientValue = gradient || customGradient;\n\n\treturn (\n\t\t<Tag { ...useBlockProps.save( { className: classes, style } ) }>\n\t\t\t{ ! useFeaturedImage &&\n\t\t\t\tisImageBackground &&\n\t\t\t\turl &&\n\t\t\t\t( isImgElement ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName={ imgClasses }\n\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\tstyle={ { objectPosition } }\n\t\t\t\t\t\tdata-object-fit=\"cover\"\n\t\t\t\t\t\tdata-object-position={ objectPosition }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<div\n\t\t\t\t\t\trole={ alt ? 'img' : undefined }\n\t\t\t\t\t\taria-label={ alt ? alt : undefined }\n\t\t\t\t\t\tclassName={ imgClasses }\n\t\t\t\t\t\tstyle={ { backgroundPosition, backgroundImage } }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ isVideoBackground && url && (\n\t\t\t\t<video\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'wp-block-cover__video-background',\n\t\t\t\t\t\t'intrinsic-ignore'\n\t\t\t\t\t) }\n\t\t\t\t\tautoPlay\n\t\t\t\t\tmuted\n\t\t\t\t\tloop\n\t\t\t\t\tplaysInline\n\t\t\t\t\tsrc={ url }\n\t\t\t\t\tposter={ poster }\n\t\t\t\t\tstyle={ { objectPosition } }\n\t\t\t\t\tdata-object-fit=\"cover\"\n\t\t\t\t\tdata-object-position={ objectPosition }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isEmbedVideoBackground && url && (\n\t\t\t\t<figure\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'wp-block-cover__video-background',\n\t\t\t\t\t\t'wp-block-cover__embed-background',\n\t\t\t\t\t\t'wp-block-embed'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"wp-block-embed__wrapper\">{ url }</div>\n\t\t\t\t</figure>\n\t\t\t) }\n\n\t\t\t{ /* The `wp-block-cover__background` needs to be immediately before\n\t\t\tthe `wp-block-cover__inner-container`, so the exclusion CSS selector\n\t\t\t`.wp-block-cover__background + .wp-block-cover__inner-container`\n\t\t\tworks properly. If it needs to be changed in the future, the\n\t\t\tselector for the backward compatibility for v14 deprecation also\n\t\t\tneeds change. */ }\n\t\t\t<span\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-block-cover__background',\n\t\t\t\t\toverlayColorClass,\n\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t{\n\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t// For backwards compatibility. Former versions of the Cover Block applied\n\t\t\t\t\t\t// `.wp-block-cover__gradient-background` in the presence of\n\t\t\t\t\t\t// media, a gradient and a dim.\n\t\t\t\t\t\t'wp-block-cover__gradient-background':\n\t\t\t\t\t\t\turl && gradientValue && dimRatio !== 0,\n\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tstyle={ bgStyle }\n\t\t\t/>\n\n\t\t\t<div\n\t\t\t\t{ ...useInnerBlocksProps.save( {\n\t\t\t\t\tclassName: 'wp-block-cover__inner-container',\n\t\t\t\t} ) }\n\t\t\t/>\n\t\t</Tag>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAqFL,SAKG,KALH;AAnFa,SAAR,KAAuB,EAAE,WAAW,GAAI;AAC9C,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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
}
|
|
@@ -14,6 +14,7 @@ var POSITION_CLASSNAMES = {
|
|
|
14
14
|
};
|
|
15
15
|
var IMAGE_BACKGROUND_TYPE = "image";
|
|
16
16
|
var VIDEO_BACKGROUND_TYPE = "video";
|
|
17
|
+
var EMBED_VIDEO_BACKGROUND_TYPE = "embed-video";
|
|
17
18
|
var COVER_MIN_HEIGHT = 50;
|
|
18
19
|
var COVER_MAX_HEIGHT = 1e3;
|
|
19
20
|
var COVER_DEFAULT_HEIGHT = 300;
|
|
@@ -70,6 +71,7 @@ export {
|
|
|
70
71
|
COVER_MAX_HEIGHT,
|
|
71
72
|
COVER_MIN_HEIGHT,
|
|
72
73
|
DEFAULT_FOCAL_POINT,
|
|
74
|
+
EMBED_VIDEO_BACKGROUND_TYPE,
|
|
73
75
|
IMAGE_BACKGROUND_TYPE,
|
|
74
76
|
VIDEO_BACKGROUND_TYPE,
|
|
75
77
|
attributesFromMedia,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cover/shared.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlobTypeByURL, isBlobURL } from '@wordpress/blob';\n\nconst POSITION_CLASSNAMES = {\n\t'top left': 'is-position-top-left',\n\t'top center': 'is-position-top-center',\n\t'top right': 'is-position-top-right',\n\t'center left': 'is-position-center-left',\n\t'center center': 'is-position-center-center',\n\tcenter: 'is-position-center-center',\n\t'center right': 'is-position-center-right',\n\t'bottom left': 'is-position-bottom-left',\n\t'bottom center': 'is-position-bottom-center',\n\t'bottom right': 'is-position-bottom-right',\n};\n\nexport const IMAGE_BACKGROUND_TYPE = 'image';\nexport const VIDEO_BACKGROUND_TYPE = 'video';\nexport const COVER_MIN_HEIGHT = 50;\nexport const COVER_MAX_HEIGHT = 1000;\nexport const COVER_DEFAULT_HEIGHT = 300;\nexport const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\nexport const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\n\nexport function mediaPosition( { x, y } = DEFAULT_FOCAL_POINT ) {\n\treturn `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;\n}\n\nexport function dimRatioToClass( ratio ) {\n\treturn ratio === 50 || ratio === undefined\n\t\t? null\n\t\t: 'has-background-dim-' + 10 * Math.round( ratio / 10 );\n}\n\nexport function attributesFromMedia( media ) {\n\tif ( ! media || ( ! media.url && ! media.src ) ) {\n\t\treturn {\n\t\t\turl: undefined,\n\t\t\tid: undefined,\n\t\t};\n\t}\n\n\tif ( isBlobURL( media.url ) ) {\n\t\tmedia.type = getBlobTypeByURL( media.url );\n\t}\n\n\tlet mediaType;\n\t// For media selections originated from a file upload.\n\tif ( media.media_type ) {\n\t\tif ( media.media_type === IMAGE_BACKGROUND_TYPE ) {\n\t\t\tmediaType = IMAGE_BACKGROUND_TYPE;\n\t\t} else {\n\t\t\t// Only images and videos are accepted so if the media_type is not an image we can assume it is a video.\n\t\t\t// Videos contain the media type of 'file' in the object returned from the rest api.\n\t\t\tmediaType = VIDEO_BACKGROUND_TYPE;\n\t\t}\n\t\t// For media selections originated from existing files in the media library.\n\t} else if (\n\t\tmedia.type &&\n\t\t( media.type === IMAGE_BACKGROUND_TYPE ||\n\t\t\tmedia.type === VIDEO_BACKGROUND_TYPE )\n\t) {\n\t\tmediaType = media.type;\n\t} else {\n\t\treturn;\n\t}\n\n\treturn {\n\t\turl: media.url || media.src,\n\t\tid: media.id,\n\t\talt: media?.alt,\n\t\tbackgroundType: mediaType,\n\t\t...( mediaType === VIDEO_BACKGROUND_TYPE\n\t\t\t? { hasParallax: undefined }\n\t\t\t: {} ),\n\t};\n}\n\n/**\n * Checks of the contentPosition is the center (default) position.\n *\n * @param {string} contentPosition The current content position.\n * @return {boolean} Whether the contentPosition is center.\n */\nexport function isContentPositionCenter( contentPosition ) {\n\treturn (\n\t\t! contentPosition ||\n\t\tcontentPosition === 'center center' ||\n\t\tcontentPosition === 'center'\n\t);\n}\n\n/**\n * Retrieves the className for the current contentPosition.\n * The default position (center) will not have a className.\n *\n * @param {string} contentPosition The current content position.\n * @return {string} The className assigned to the contentPosition.\n */\nexport function getPositionClassName( contentPosition ) {\n\t/*\n\t * Only render a className if the contentPosition is not center (the default).\n\t */\n\tif ( isContentPositionCenter( contentPosition ) ) {\n\t\treturn '';\n\t}\n\n\treturn POSITION_CLASSNAMES[ contentPosition ];\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,kBAAkB,iBAAiB;AAE5C,IAAM,sBAAsB;AAAA,EAC3B,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EACb,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AACjB;AAEO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAC9B,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAC7B,IAAM,sBAAsB,EAAE,GAAG,KAAK,GAAG,IAAI;AAC7C,IAAM,sBAAsB,CAAE,SAAS,OAAQ;AAE/C,SAAS,cAAe,EAAE,GAAG,EAAE,IAAI,qBAAsB;AAC/D,SAAO,GAAI,KAAK,MAAO,IAAI,GAAI,CAAE,KAAM,KAAK,MAAO,IAAI,GAAI,CAAE;AAC9D;AAEO,SAAS,gBAAiB,OAAQ;AACxC,SAAO,UAAU,MAAM,UAAU,SAC9B,OACA,wBAAwB,KAAK,KAAK,MAAO,QAAQ,EAAG;AACxD;AAEO,SAAS,oBAAqB,OAAQ;AAC5C,MAAK,CAAE,SAAW,CAAE,MAAM,OAAO,CAAE,MAAM,KAAQ;AAChD,WAAO;AAAA,MACN,KAAK;AAAA,MACL,IAAI;AAAA,IACL;AAAA,EACD;AAEA,MAAK,UAAW,MAAM,GAAI,GAAI;AAC7B,UAAM,OAAO,iBAAkB,MAAM,GAAI;AAAA,EAC1C;AAEA,MAAI;AAEJ,MAAK,MAAM,YAAa;AACvB,QAAK,MAAM,eAAe,uBAAwB;AACjD,kBAAY;AAAA,IACb,OAAO;AAGN,kBAAY;AAAA,IACb;AAAA,EAED,WACC,MAAM,SACJ,MAAM,SAAS,yBAChB,MAAM,SAAS,wBACf;AACD,gBAAY,MAAM;AAAA,EACnB,OAAO;AACN;AAAA,EACD;AAEA,SAAO;AAAA,IACN,KAAK,MAAM,OAAO,MAAM;AAAA,IACxB,IAAI,MAAM;AAAA,IACV,KAAK,OAAO;AAAA,IACZ,gBAAgB;AAAA,IAChB,GAAK,cAAc,wBAChB,EAAE,aAAa,OAAU,IACzB,CAAC;AAAA,EACL;AACD;AAQO,SAAS,wBAAyB,iBAAkB;AAC1D,SACC,CAAE,mBACF,oBAAoB,mBACpB,oBAAoB;AAEtB;AASO,SAAS,qBAAsB,iBAAkB;AAIvD,MAAK,wBAAyB,eAAgB,GAAI;AACjD,WAAO;AAAA,EACR;AAEA,SAAO,oBAAqB,eAAgB;AAC7C;",
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlobTypeByURL, isBlobURL } from '@wordpress/blob';\n\nconst POSITION_CLASSNAMES = {\n\t'top left': 'is-position-top-left',\n\t'top center': 'is-position-top-center',\n\t'top right': 'is-position-top-right',\n\t'center left': 'is-position-center-left',\n\t'center center': 'is-position-center-center',\n\tcenter: 'is-position-center-center',\n\t'center right': 'is-position-center-right',\n\t'bottom left': 'is-position-bottom-left',\n\t'bottom center': 'is-position-bottom-center',\n\t'bottom right': 'is-position-bottom-right',\n};\n\nexport const IMAGE_BACKGROUND_TYPE = 'image';\nexport const VIDEO_BACKGROUND_TYPE = 'video';\nexport const EMBED_VIDEO_BACKGROUND_TYPE = 'embed-video';\nexport const COVER_MIN_HEIGHT = 50;\nexport const COVER_MAX_HEIGHT = 1000;\nexport const COVER_DEFAULT_HEIGHT = 300;\nexport const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\nexport const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\n\nexport function mediaPosition( { x, y } = DEFAULT_FOCAL_POINT ) {\n\treturn `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;\n}\n\nexport function dimRatioToClass( ratio ) {\n\treturn ratio === 50 || ratio === undefined\n\t\t? null\n\t\t: 'has-background-dim-' + 10 * Math.round( ratio / 10 );\n}\n\nexport function attributesFromMedia( media ) {\n\tif ( ! media || ( ! media.url && ! media.src ) ) {\n\t\treturn {\n\t\t\turl: undefined,\n\t\t\tid: undefined,\n\t\t};\n\t}\n\n\tif ( isBlobURL( media.url ) ) {\n\t\tmedia.type = getBlobTypeByURL( media.url );\n\t}\n\n\tlet mediaType;\n\t// For media selections originated from a file upload.\n\tif ( media.media_type ) {\n\t\tif ( media.media_type === IMAGE_BACKGROUND_TYPE ) {\n\t\t\tmediaType = IMAGE_BACKGROUND_TYPE;\n\t\t} else {\n\t\t\t// Only images and videos are accepted so if the media_type is not an image we can assume it is a video.\n\t\t\t// Videos contain the media type of 'file' in the object returned from the rest api.\n\t\t\tmediaType = VIDEO_BACKGROUND_TYPE;\n\t\t}\n\t\t// For media selections originated from existing files in the media library.\n\t} else if (\n\t\tmedia.type &&\n\t\t( media.type === IMAGE_BACKGROUND_TYPE ||\n\t\t\tmedia.type === VIDEO_BACKGROUND_TYPE )\n\t) {\n\t\tmediaType = media.type;\n\t} else {\n\t\treturn;\n\t}\n\n\treturn {\n\t\turl: media.url || media.src,\n\t\tid: media.id,\n\t\talt: media?.alt,\n\t\tbackgroundType: mediaType,\n\t\t...( mediaType === VIDEO_BACKGROUND_TYPE\n\t\t\t? { hasParallax: undefined }\n\t\t\t: {} ),\n\t};\n}\n\n/**\n * Checks of the contentPosition is the center (default) position.\n *\n * @param {string} contentPosition The current content position.\n * @return {boolean} Whether the contentPosition is center.\n */\nexport function isContentPositionCenter( contentPosition ) {\n\treturn (\n\t\t! contentPosition ||\n\t\tcontentPosition === 'center center' ||\n\t\tcontentPosition === 'center'\n\t);\n}\n\n/**\n * Retrieves the className for the current contentPosition.\n * The default position (center) will not have a className.\n *\n * @param {string} contentPosition The current content position.\n * @return {string} The className assigned to the contentPosition.\n */\nexport function getPositionClassName( contentPosition ) {\n\t/*\n\t * Only render a className if the contentPosition is not center (the default).\n\t */\n\tif ( isContentPositionCenter( contentPosition ) ) {\n\t\treturn '';\n\t}\n\n\treturn POSITION_CLASSNAMES[ contentPosition ];\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,kBAAkB,iBAAiB;AAE5C,IAAM,sBAAsB;AAAA,EAC3B,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EACb,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AACjB;AAEO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAC9B,IAAM,8BAA8B;AACpC,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAC7B,IAAM,sBAAsB,EAAE,GAAG,KAAK,GAAG,IAAI;AAC7C,IAAM,sBAAsB,CAAE,SAAS,OAAQ;AAE/C,SAAS,cAAe,EAAE,GAAG,EAAE,IAAI,qBAAsB;AAC/D,SAAO,GAAI,KAAK,MAAO,IAAI,GAAI,CAAE,KAAM,KAAK,MAAO,IAAI,GAAI,CAAE;AAC9D;AAEO,SAAS,gBAAiB,OAAQ;AACxC,SAAO,UAAU,MAAM,UAAU,SAC9B,OACA,wBAAwB,KAAK,KAAK,MAAO,QAAQ,EAAG;AACxD;AAEO,SAAS,oBAAqB,OAAQ;AAC5C,MAAK,CAAE,SAAW,CAAE,MAAM,OAAO,CAAE,MAAM,KAAQ;AAChD,WAAO;AAAA,MACN,KAAK;AAAA,MACL,IAAI;AAAA,IACL;AAAA,EACD;AAEA,MAAK,UAAW,MAAM,GAAI,GAAI;AAC7B,UAAM,OAAO,iBAAkB,MAAM,GAAI;AAAA,EAC1C;AAEA,MAAI;AAEJ,MAAK,MAAM,YAAa;AACvB,QAAK,MAAM,eAAe,uBAAwB;AACjD,kBAAY;AAAA,IACb,OAAO;AAGN,kBAAY;AAAA,IACb;AAAA,EAED,WACC,MAAM,SACJ,MAAM,SAAS,yBAChB,MAAM,SAAS,wBACf;AACD,gBAAY,MAAM;AAAA,EACnB,OAAO;AACN;AAAA,EACD;AAEA,SAAO;AAAA,IACN,KAAK,MAAM,OAAO,MAAM;AAAA,IACxB,IAAI,MAAM;AAAA,IACV,KAAK,OAAO;AAAA,IACZ,gBAAgB;AAAA,IAChB,GAAK,cAAc,wBAChB,EAAE,aAAa,OAAU,IACzB,CAAC;AAAA,EACL;AACD;AAQO,SAAS,wBAAyB,iBAAkB;AAC1D,SACC,CAAE,mBACF,oBAAoB,mBACpB,oBAAoB;AAEtB;AASO,SAAS,qBAAsB,iBAAkB;AAIvD,MAAK,wBAAyB,eAAgB,GAAI;AACjD,WAAO;AAAA,EACR;AAEA,SAAO,oBAAqB,eAAgB;AAC7C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// packages/block-library/src/details/index.js
|
|
2
2
|
import { details as icon } from "@wordpress/icons";
|
|
3
3
|
import { __, sprintf } from "@wordpress/i18n";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block";
|
|
5
6
|
import metadata from "./block.json";
|
|
6
7
|
import edit from "./edit";
|
|
7
8
|
import save from "./save";
|
|
8
9
|
import transforms from "./transforms";
|
|
10
|
+
import { unlock } from "../lock-unlock";
|
|
11
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
9
12
|
var { name } = metadata;
|
|
10
13
|
var settings = {
|
|
11
14
|
icon,
|
|
@@ -44,17 +47,17 @@ var settings = {
|
|
|
44
47
|
edit,
|
|
45
48
|
transforms
|
|
46
49
|
};
|
|
47
|
-
if (window.
|
|
48
|
-
settings
|
|
50
|
+
if (window.__experimentalContentOnlyInspectorFields) {
|
|
51
|
+
settings[fieldsKey] = [
|
|
49
52
|
{
|
|
53
|
+
id: "summary",
|
|
50
54
|
label: __("Summary"),
|
|
51
|
-
type: "
|
|
52
|
-
shownByDefault: true,
|
|
53
|
-
mapping: {
|
|
54
|
-
value: "summary"
|
|
55
|
-
}
|
|
55
|
+
type: "richtext"
|
|
56
56
|
}
|
|
57
57
|
];
|
|
58
|
+
settings[formKey] = {
|
|
59
|
+
fields: ["summary"]
|
|
60
|
+
};
|
|
58
61
|
}
|
|
59
62
|
var init = () => initBlock({ name, metadata, settings });
|
|
60
63
|
export {
|