@wordpress/block-library 9.43.0 → 9.44.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/code/edit.cjs +2 -1
- package/build/code/edit.cjs.map +2 -2
- package/build/cover/edit/color-utils.cjs +1 -1
- package/build/cover/edit/color-utils.cjs.map +2 -2
- package/build/cover/edit/index.cjs +39 -26
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/embed-video-utils.cjs +9 -7
- package/build/cover/embed-video-utils.cjs.map +2 -2
- package/build/embed/embed-preview.cjs +2 -1
- package/build/embed/embed-preview.cjs.map +2 -2
- package/build/file/utils/index.cjs +1 -1
- package/build/file/utils/index.cjs.map +2 -2
- package/build/form/view.cjs +1 -1
- package/build/form/view.cjs.map +2 -2
- package/build/icon/edit.cjs +1 -3
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/image.cjs +32 -9
- package/build/image/image.cjs.map +2 -2
- package/build/navigation-link/link-ui/index.cjs +12 -1
- package/build/navigation-link/link-ui/index.cjs.map +2 -2
- package/build/navigation-link/link-ui/page-creator.cjs +1 -1
- package/build/navigation-link/link-ui/page-creator.cjs.map +2 -2
- package/build/navigation-link/shared/update-attributes.cjs +1 -1
- package/build/navigation-link/shared/update-attributes.cjs.map +2 -2
- package/build/navigation-link/shared/use-link-preview.cjs +1 -1
- package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
- package/build/paragraph/use-enter.cjs +4 -5
- package/build/paragraph/use-enter.cjs.map +2 -2
- package/build/pattern/edit.cjs +1 -1
- package/build/pattern/edit.cjs.map +2 -2
- package/build/search/block.json +5 -5
- package/build/search/edit.cjs +8 -33
- package/build/search/edit.cjs.map +2 -2
- package/build/separator/transforms.cjs +12 -4
- package/build/separator/transforms.cjs.map +2 -2
- package/build/tab/add-tab-toolbar-control.cjs +5 -17
- package/build/tab/add-tab-toolbar-control.cjs.map +2 -2
- package/build/tab/block.json +2 -1
- package/build/tab/remove-tab-toolbar-control.cjs +1 -4
- package/build/tab/remove-tab-toolbar-control.cjs.map +2 -2
- package/build/tabs/edit.cjs +45 -45
- package/build/tabs/edit.cjs.map +2 -2
- package/build/tabs-menu/block.json +1 -2
- package/build/tabs-menu-item/block.json +0 -6
- package/build/tabs-menu-item/edit.cjs +2 -8
- package/build/tabs-menu-item/edit.cjs.map +2 -2
- package/build-module/code/edit.mjs +2 -1
- package/build-module/code/edit.mjs.map +2 -2
- package/build-module/cover/edit/color-utils.mjs +1 -1
- package/build-module/cover/edit/color-utils.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +47 -29
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/embed-video-utils.mjs +8 -6
- package/build-module/cover/embed-video-utils.mjs.map +2 -2
- package/build-module/embed/embed-preview.mjs +2 -1
- package/build-module/embed/embed-preview.mjs.map +2 -2
- package/build-module/file/utils/index.mjs +1 -1
- package/build-module/file/utils/index.mjs.map +2 -2
- package/build-module/form/view.mjs +1 -1
- package/build-module/form/view.mjs.map +2 -2
- package/build-module/icon/edit.mjs +1 -3
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +32 -9
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/index.mjs +12 -1
- package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/page-creator.mjs +1 -1
- package/build-module/navigation-link/link-ui/page-creator.mjs.map +2 -2
- package/build-module/navigation-link/shared/update-attributes.mjs +1 -1
- package/build-module/navigation-link/shared/update-attributes.mjs.map +2 -2
- package/build-module/navigation-link/shared/use-link-preview.mjs +1 -1
- package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
- package/build-module/paragraph/use-enter.mjs +4 -5
- package/build-module/paragraph/use-enter.mjs.map +2 -2
- package/build-module/pattern/edit.mjs +1 -1
- package/build-module/pattern/edit.mjs.map +2 -2
- package/build-module/search/block.json +5 -5
- package/build-module/search/edit.mjs +8 -33
- package/build-module/search/edit.mjs.map +2 -2
- package/build-module/separator/transforms.mjs +17 -5
- package/build-module/separator/transforms.mjs.map +2 -2
- package/build-module/tab/add-tab-toolbar-control.mjs +6 -18
- package/build-module/tab/add-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tab/block.json +2 -1
- package/build-module/tab/remove-tab-toolbar-control.mjs +1 -4
- package/build-module/tab/remove-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tabs/edit.mjs +45 -45
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs-menu/block.json +1 -2
- package/build-module/tabs-menu-item/block.json +0 -6
- package/build-module/tabs-menu-item/edit.mjs +3 -9
- package/build-module/tabs-menu-item/edit.mjs.map +2 -2
- package/build-style/code/style-rtl.css +1 -1
- package/build-style/code/style.css +1 -1
- package/build-style/post-author-biography/style-rtl.css +1 -0
- package/build-style/post-author-biography/style.css +1 -0
- package/build-style/style-rtl.css +11 -16
- package/build-style/style.css +11 -16
- package/build-style/tabs-menu-item/style-rtl.css +9 -6
- package/build-style/tabs-menu-item/style.css +9 -6
- package/package.json +38 -38
- package/src/code/edit.js +1 -0
- package/src/code/style.scss +1 -1
- package/src/cover/edit/color-utils.js +1 -1
- package/src/cover/edit/index.js +72 -35
- package/src/cover/embed-video-utils.js +10 -8
- package/src/embed/embed-preview.js +6 -5
- package/src/embed/test/index.native.js +3 -2
- package/src/file/utils/index.js +1 -1
- package/src/form/view.js +1 -1
- package/src/icon/edit.js +1 -3
- package/src/image/image.js +56 -9
- package/src/image/index.php +4 -4
- package/src/navigation-link/link-ui/index.js +12 -1
- package/src/navigation-link/link-ui/page-creator.js +1 -1
- package/src/navigation-link/shared/update-attributes.js +1 -1
- package/src/navigation-link/shared/use-link-preview.js +1 -1
- package/src/paragraph/use-enter.js +5 -5
- package/src/pattern/edit.js +1 -1
- package/src/post-author-biography/style.scss +1 -0
- package/src/search/block.json +5 -5
- package/src/search/edit.js +4 -35
- package/src/search/index.php +23 -3
- package/src/separator/transforms.js +19 -5
- package/src/style.scss +0 -1
- package/src/tab/add-tab-toolbar-control.js +24 -42
- package/src/tab/block.json +2 -1
- package/src/tab/index.php +21 -4
- package/src/tab/remove-tab-toolbar-control.js +1 -9
- package/src/tabs/edit.js +59 -66
- package/src/tabs/index.php +14 -15
- package/src/tabs-menu/block.json +1 -2
- package/src/tabs-menu/index.php +6 -17
- package/src/tabs-menu-item/block.json +0 -6
- package/src/tabs-menu-item/edit.js +3 -15
- package/src/tabs-menu-item/style.scss +10 -8
- package/build-style/tabs-menu/style-rtl.css +0 -8
- package/build-style/tabs-menu/style.css +0 -8
- package/src/tabs-menu/style.scss +0 -8
package/CHANGELOG.md
CHANGED
package/build/code/edit.cjs
CHANGED
|
@@ -48,7 +48,8 @@ function CodeEdit({
|
|
|
48
48
|
"aria-label": (0, import_i18n.__)("Code"),
|
|
49
49
|
preserveWhiteSpace: true,
|
|
50
50
|
__unstablePastePlainText: true,
|
|
51
|
-
__unstableOnSplitAtDoubleLineEnd: () => insertBlocksAfter((0, import_blocks.createBlock)((0, import_blocks.getDefaultBlockName)()))
|
|
51
|
+
__unstableOnSplitAtDoubleLineEnd: () => insertBlocksAfter((0, import_blocks.createBlock)((0, import_blocks.getDefaultBlockName)())),
|
|
52
|
+
style: { whiteSpace: "break-spaces" }
|
|
52
53
|
}
|
|
53
54
|
) });
|
|
54
55
|
}
|
package/build/code/edit.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\nexport default function CodeEdit( {\n\tattributes,\n\tsetAttributes,\n\tonRemove,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n} ) {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<pre { ...blockProps }>\n\t\t\t<RichText\n\t\t\t\ttagName=\"code\"\n\t\t\t\tidentifier=\"content\"\n\t\t\t\tvalue={ attributes.content }\n\t\t\t\tonChange={ ( content ) => setAttributes( { content } ) }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tplaceholder={ __( 'Write code\u2026' ) }\n\t\t\t\taria-label={ __( 'Code' ) }\n\t\t\t\tpreserveWhiteSpace\n\t\t\t\t__unstablePastePlainText\n\t\t\t\t__unstableOnSplitAtDoubleLineEnd={ () =>\n\t\t\t\t\tinsertBlocksAfter( createBlock( getDefaultBlockName() ) )\n\t\t\t\t}\n\t\t\t/>\n\t\t</pre>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,0BAAwC;AACxC,oBAAiD;AAY9C;AAVY,SAAR,SAA2B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,iBAAa,mCAAc;AACjC,SACC,4CAAC,SAAM,GAAG,YACT;AAAA,IAAC;AAAA;AAAA,MACA,SAAQ;AAAA,MACR,YAAW;AAAA,MACX,OAAQ,WAAW;AAAA,MACnB,UAAW,CAAE,YAAa,cAAe,EAAE,QAAQ,CAAE;AAAA,MACrD;AAAA,MACA,SAAU;AAAA,MACV,iBAAc,gBAAI,kBAAc;AAAA,MAChC,kBAAa,gBAAI,MAAO;AAAA,MACxB,oBAAkB;AAAA,MAClB,0BAAwB;AAAA,MACxB,kCAAmC,MAClC,sBAAmB,+BAAa,mCAAoB,CAAE,CAAE;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\nexport default function CodeEdit( {\n\tattributes,\n\tsetAttributes,\n\tonRemove,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n} ) {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<pre { ...blockProps }>\n\t\t\t<RichText\n\t\t\t\ttagName=\"code\"\n\t\t\t\tidentifier=\"content\"\n\t\t\t\tvalue={ attributes.content }\n\t\t\t\tonChange={ ( content ) => setAttributes( { content } ) }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tplaceholder={ __( 'Write code\u2026' ) }\n\t\t\t\taria-label={ __( 'Code' ) }\n\t\t\t\tpreserveWhiteSpace\n\t\t\t\t__unstablePastePlainText\n\t\t\t\t__unstableOnSplitAtDoubleLineEnd={ () =>\n\t\t\t\t\tinsertBlocksAfter( createBlock( getDefaultBlockName() ) )\n\t\t\t\t}\n\t\t\t\tstyle={ { whiteSpace: 'break-spaces' } }\n\t\t\t/>\n\t\t</pre>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,0BAAwC;AACxC,oBAAiD;AAY9C;AAVY,SAAR,SAA2B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,iBAAa,mCAAc;AACjC,SACC,4CAAC,SAAM,GAAG,YACT;AAAA,IAAC;AAAA;AAAA,MACA,SAAQ;AAAA,MACR,YAAW;AAAA,MACX,OAAQ,WAAW;AAAA,MACnB,UAAW,CAAE,YAAa,cAAe,EAAE,QAAQ,CAAE;AAAA,MACrD;AAAA,MACA,SAAU;AAAA,MACV,iBAAc,gBAAI,kBAAc;AAAA,MAChC,kBAAa,gBAAI,MAAO;AAAA,MACxB,oBAAkB;AAAA,MAClB,0BAAwB;AAAA,MACxB,kCAAmC,MAClC,sBAAmB,+BAAa,mCAAoB,CAAE,CAAE;AAAA,MAEzD,OAAQ,EAAE,YAAY,eAAe;AAAA;AAAA,EACtC,GACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cover/edit/color-utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport { FastAverageColor } from 'fast-average-color';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * @typedef {import('colord').RgbaColor} RgbaColor\n */\n\nextend( [ namesPlugin ] );\n\n/**\n * Fallback color when the average color can't be computed. The image may be\n * rendering as transparent, and most sites have a light color background.\n */\nexport const DEFAULT_BACKGROUND_COLOR = '#FFF';\n\n/**\n * Default dim color specified in style.css.\n */\nexport const DEFAULT_OVERLAY_COLOR = '#000';\n\n/**\n * Performs a Porter Duff composite source over operation on two rgba colors.\n *\n * @see {@link https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators_srcover}\n *\n * @param {RgbaColor} source Source color.\n * @param {RgbaColor} dest Destination color.\n *\n * @return {RgbaColor} Composite color.\n */\nexport function compositeSourceOver( source, dest ) {\n\treturn {\n\t\tr: source.r * source.a + dest.r * dest.a * ( 1 - source.a ),\n\t\tg: source.g * source.a + dest.g * dest.a * ( 1 - source.a ),\n\t\tb: source.b * source.a + dest.b * dest.a * ( 1 - source.a ),\n\t\ta: source.a + dest.a * ( 1 - source.a ),\n\t};\n}\n\n/**\n * Retrieves the FastAverageColor singleton.\n *\n * @return {FastAverageColor} The FastAverageColor singleton.\n */\nexport function retrieveFastAverageColor() {\n\tif ( ! retrieveFastAverageColor.fastAverageColor ) {\n\t\tretrieveFastAverageColor.fastAverageColor = new FastAverageColor();\n\t}\n\treturn retrieveFastAverageColor.fastAverageColor;\n}\n\n/**\n * Computes the average color of an image.\n *\n * @param {string} url The url of the image.\n *\n * @return {Promise<string>} Promise of an average color as a hex string.\n */\nexport const getMediaColor = memoize( async ( url ) => {\n\tif ( ! url ) {\n\t\treturn DEFAULT_BACKGROUND_COLOR;\n\t}\n\n\t// making the default color rgb for compat with FAC\n\tconst { r, g, b, a } = colord( DEFAULT_BACKGROUND_COLOR ).toRgb();\n\n\ttry {\n\t\tconst imgCrossOrigin = applyFilters(\n\t\t\t'media.crossOrigin',\n\t\t\tundefined,\n\t\t\turl\n\t\t);\n\t\tconst color = await retrieveFastAverageColor().getColorAsync( url, {\n\t\t\t// The default color is white, which is the color\n\t\t\t// that is returned if there's an error.\n\t\t\t// colord returns alpga 0-1, FAC needs 0-255\n\t\t\tdefaultColor: [ r, g, b, a * 255 ],\n\t\t\t// Errors that come up don't reject the promise,\n\t\t\t// so error logging has to be silenced\n\t\t\t// with this option.\n\t\t\tsilent: process.env.NODE_ENV === 'production',\n\t\t\tcrossOrigin: imgCrossOrigin,\n\t\t} );\n\t\treturn color.hex;\n\t} catch
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA+B;AAC/B,mBAAwB;AACxB,gCAAiC;AACjC,oBAAoB;AAKpB,mBAA6B;AAAA,IAM7B,sBAAQ,CAAE,aAAAA,OAAY,CAAE;AAMjB,IAAM,2BAA2B;AAKjC,IAAM,wBAAwB;AAY9B,SAAS,oBAAqB,QAAQ,MAAO;AACnD,SAAO;AAAA,IACN,GAAG,OAAO,IAAI,OAAO,IAAI,KAAK,IAAI,KAAK,KAAM,IAAI,OAAO;AAAA,IACxD,GAAG,OAAO,IAAI,OAAO,IAAI,KAAK,IAAI,KAAK,KAAM,IAAI,OAAO;AAAA,IACxD,GAAG,OAAO,IAAI,OAAO,IAAI,KAAK,IAAI,KAAK,KAAM,IAAI,OAAO;AAAA,IACxD,GAAG,OAAO,IAAI,KAAK,KAAM,IAAI,OAAO;AAAA,EACrC;AACD;AAOO,SAAS,2BAA2B;AAC1C,MAAK,CAAE,yBAAyB,kBAAmB;AAClD,6BAAyB,mBAAmB,IAAI,2CAAiB;AAAA,EAClE;AACA,SAAO,yBAAyB;AACjC;AASO,IAAM,oBAAgB,cAAAC,SAAS,OAAQ,QAAS;AACtD,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,QAAM,EAAE,GAAG,GAAG,GAAG,EAAE,QAAI,sBAAQ,wBAAyB,EAAE,MAAM;AAEhE,MAAI;AACH,UAAM,qBAAiB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,IACD;AACA,UAAM,QAAQ,MAAM,yBAAyB,EAAE,cAAe,KAAK;AAAA;AAAA;AAAA;AAAA,MAIlE,cAAc,CAAE,GAAG,GAAG,GAAG,IAAI,GAAI;AAAA;AAAA;AAAA;AAAA,MAIjC,QAAQ,QAAQ,IAAI,aAAa;AAAA,MACjC,aAAa;AAAA,IACd,CAAE;AACF,WAAO,MAAM;AAAA,EACd,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport { FastAverageColor } from 'fast-average-color';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * @typedef {import('colord').RgbaColor} RgbaColor\n */\n\nextend( [ namesPlugin ] );\n\n/**\n * Fallback color when the average color can't be computed. The image may be\n * rendering as transparent, and most sites have a light color background.\n */\nexport const DEFAULT_BACKGROUND_COLOR = '#FFF';\n\n/**\n * Default dim color specified in style.css.\n */\nexport const DEFAULT_OVERLAY_COLOR = '#000';\n\n/**\n * Performs a Porter Duff composite source over operation on two rgba colors.\n *\n * @see {@link https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators_srcover}\n *\n * @param {RgbaColor} source Source color.\n * @param {RgbaColor} dest Destination color.\n *\n * @return {RgbaColor} Composite color.\n */\nexport function compositeSourceOver( source, dest ) {\n\treturn {\n\t\tr: source.r * source.a + dest.r * dest.a * ( 1 - source.a ),\n\t\tg: source.g * source.a + dest.g * dest.a * ( 1 - source.a ),\n\t\tb: source.b * source.a + dest.b * dest.a * ( 1 - source.a ),\n\t\ta: source.a + dest.a * ( 1 - source.a ),\n\t};\n}\n\n/**\n * Retrieves the FastAverageColor singleton.\n *\n * @return {FastAverageColor} The FastAverageColor singleton.\n */\nexport function retrieveFastAverageColor() {\n\tif ( ! retrieveFastAverageColor.fastAverageColor ) {\n\t\tretrieveFastAverageColor.fastAverageColor = new FastAverageColor();\n\t}\n\treturn retrieveFastAverageColor.fastAverageColor;\n}\n\n/**\n * Computes the average color of an image.\n *\n * @param {string} url The url of the image.\n *\n * @return {Promise<string>} Promise of an average color as a hex string.\n */\nexport const getMediaColor = memoize( async ( url ) => {\n\tif ( ! url ) {\n\t\treturn DEFAULT_BACKGROUND_COLOR;\n\t}\n\n\t// making the default color rgb for compat with FAC\n\tconst { r, g, b, a } = colord( DEFAULT_BACKGROUND_COLOR ).toRgb();\n\n\ttry {\n\t\tconst imgCrossOrigin = applyFilters(\n\t\t\t'media.crossOrigin',\n\t\t\tundefined,\n\t\t\turl\n\t\t);\n\t\tconst color = await retrieveFastAverageColor().getColorAsync( url, {\n\t\t\t// The default color is white, which is the color\n\t\t\t// that is returned if there's an error.\n\t\t\t// colord returns alpga 0-1, FAC needs 0-255\n\t\t\tdefaultColor: [ r, g, b, a * 255 ],\n\t\t\t// Errors that come up don't reject the promise,\n\t\t\t// so error logging has to be silenced\n\t\t\t// with this option.\n\t\t\tsilent: process.env.NODE_ENV === 'production',\n\t\t\tcrossOrigin: imgCrossOrigin,\n\t\t} );\n\t\treturn color.hex;\n\t} catch {\n\t\t// If there's an error return the fallback color.\n\t\treturn DEFAULT_BACKGROUND_COLOR;\n\t}\n} );\n\n/**\n * Computes if the color combination of the overlay and background color is dark.\n *\n * @param {number} dimRatio Opacity of the overlay between 0 and 100.\n * @param {string} overlayColor CSS color string for the overlay.\n * @param {string} backgroundColor CSS color string for the background.\n *\n * @return {boolean} true if the color combination composite result is dark.\n */\nexport function compositeIsDark( dimRatio, overlayColor, backgroundColor ) {\n\t// Opacity doesn't matter if you're overlaying the same color on top of itself.\n\t// And background doesn't matter when overlay is fully opaque.\n\tif ( overlayColor === backgroundColor || dimRatio === 100 ) {\n\t\treturn colord( overlayColor ).isDark();\n\t}\n\tconst overlay = colord( overlayColor )\n\t\t.alpha( dimRatio / 100 )\n\t\t.toRgb();\n\tconst background = colord( backgroundColor ).toRgb();\n\tconst composite = compositeSourceOver( overlay, background );\n\treturn colord( composite ).isDark();\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA+B;AAC/B,mBAAwB;AACxB,gCAAiC;AACjC,oBAAoB;AAKpB,mBAA6B;AAAA,IAM7B,sBAAQ,CAAE,aAAAA,OAAY,CAAE;AAMjB,IAAM,2BAA2B;AAKjC,IAAM,wBAAwB;AAY9B,SAAS,oBAAqB,QAAQ,MAAO;AACnD,SAAO;AAAA,IACN,GAAG,OAAO,IAAI,OAAO,IAAI,KAAK,IAAI,KAAK,KAAM,IAAI,OAAO;AAAA,IACxD,GAAG,OAAO,IAAI,OAAO,IAAI,KAAK,IAAI,KAAK,KAAM,IAAI,OAAO;AAAA,IACxD,GAAG,OAAO,IAAI,OAAO,IAAI,KAAK,IAAI,KAAK,KAAM,IAAI,OAAO;AAAA,IACxD,GAAG,OAAO,IAAI,KAAK,KAAM,IAAI,OAAO;AAAA,EACrC;AACD;AAOO,SAAS,2BAA2B;AAC1C,MAAK,CAAE,yBAAyB,kBAAmB;AAClD,6BAAyB,mBAAmB,IAAI,2CAAiB;AAAA,EAClE;AACA,SAAO,yBAAyB;AACjC;AASO,IAAM,oBAAgB,cAAAC,SAAS,OAAQ,QAAS;AACtD,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,QAAM,EAAE,GAAG,GAAG,GAAG,EAAE,QAAI,sBAAQ,wBAAyB,EAAE,MAAM;AAEhE,MAAI;AACH,UAAM,qBAAiB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,IACD;AACA,UAAM,QAAQ,MAAM,yBAAyB,EAAE,cAAe,KAAK;AAAA;AAAA;AAAA;AAAA,MAIlE,cAAc,CAAE,GAAG,GAAG,GAAG,IAAI,GAAI;AAAA;AAAA;AAAA;AAAA,MAIjC,QAAQ,QAAQ,IAAI,aAAa;AAAA,MACjC,aAAa;AAAA,IACd,CAAE;AACF,WAAO,MAAM;AAAA,EACd,QAAQ;AAEP,WAAO;AAAA,EACR;AACD,CAAE;AAWK,SAAS,gBAAiB,UAAU,cAAc,iBAAkB;AAG1E,MAAK,iBAAiB,mBAAmB,aAAa,KAAM;AAC3D,eAAO,sBAAQ,YAAa,EAAE,OAAO;AAAA,EACtC;AACA,QAAM,cAAU,sBAAQ,YAAa,EACnC,MAAO,WAAW,GAAI,EACtB,MAAM;AACR,QAAM,iBAAa,sBAAQ,eAAgB,EAAE,MAAM;AACnD,QAAM,YAAY,oBAAqB,SAAS,UAAW;AAC3D,aAAO,sBAAQ,SAAU,EAAE,OAAO;AACnC;",
|
|
6
6
|
"names": ["namesPlugin", "memoize"]
|
|
7
7
|
}
|
|
@@ -108,6 +108,10 @@ function CoverEdit({
|
|
|
108
108
|
);
|
|
109
109
|
const { getSettings } = (0, import_data.useSelect)(import_block_editor.store);
|
|
110
110
|
const { __unstableMarkNextChangeAsNotPersistent } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
111
|
+
const propsRef = (0, import_element.useRef)({ attributes, overlayColor });
|
|
112
|
+
(0, import_element.useLayoutEffect)(() => {
|
|
113
|
+
propsRef.current = { attributes, overlayColor };
|
|
114
|
+
});
|
|
111
115
|
const { media } = (0, import_data.useSelect)(
|
|
112
116
|
(select) => {
|
|
113
117
|
return {
|
|
@@ -130,24 +134,31 @@ function CoverEdit({
|
|
|
130
134
|
return;
|
|
131
135
|
}
|
|
132
136
|
const averageBackgroundColor = await (0, import_color_utils.getMediaColor)(mediaUrl);
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
const { attributes: currentAttrs, overlayColor: currentOverlay } = propsRef.current;
|
|
138
|
+
let newOverlayColor = currentOverlay.color;
|
|
139
|
+
if (!currentAttrs.isUserOverlayColor) {
|
|
135
140
|
newOverlayColor = averageBackgroundColor;
|
|
136
141
|
__unstableMarkNextChangeAsNotPersistent();
|
|
137
142
|
setOverlayColor(newOverlayColor);
|
|
138
143
|
}
|
|
139
144
|
const newIsDark = (0, import_color_utils.compositeIsDark)(
|
|
140
|
-
dimRatio,
|
|
145
|
+
currentAttrs.dimRatio,
|
|
141
146
|
newOverlayColor,
|
|
142
147
|
averageBackgroundColor
|
|
143
148
|
);
|
|
144
149
|
__unstableMarkNextChangeAsNotPersistent();
|
|
145
150
|
setAttributes({
|
|
146
151
|
isDark: newIsDark,
|
|
147
|
-
isUserOverlayColor: isUserOverlayColor || false
|
|
152
|
+
isUserOverlayColor: currentAttrs.isUserOverlayColor || false
|
|
148
153
|
});
|
|
149
154
|
})();
|
|
150
|
-
}, [
|
|
155
|
+
}, [
|
|
156
|
+
mediaUrl,
|
|
157
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
158
|
+
setAttributes,
|
|
159
|
+
setOverlayColor,
|
|
160
|
+
useFeaturedImage
|
|
161
|
+
]);
|
|
151
162
|
const url = useFeaturedImage ? mediaUrl : (
|
|
152
163
|
// Ensure the url is not malformed due to sanitization through `wp_kses`.
|
|
153
164
|
originalUrl?.replaceAll("&", "&")
|
|
@@ -163,13 +174,14 @@ function CoverEdit({
|
|
|
163
174
|
const averageBackgroundColor = await (0, import_color_utils.getMediaColor)(
|
|
164
175
|
isImage ? newMedia?.url : void 0
|
|
165
176
|
);
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
const { attributes: currentAttrs, overlayColor: currentOverlay } = propsRef.current;
|
|
178
|
+
let newOverlayColor = currentOverlay.color;
|
|
179
|
+
if (!currentAttrs.isUserOverlayColor) {
|
|
168
180
|
newOverlayColor = averageBackgroundColor;
|
|
169
181
|
setOverlayColor(newOverlayColor);
|
|
170
182
|
__unstableMarkNextChangeAsNotPersistent();
|
|
171
183
|
}
|
|
172
|
-
const newDimRatio =
|
|
184
|
+
const newDimRatio = currentAttrs.url === void 0 && currentAttrs.dimRatio === 100 ? 50 : currentAttrs.dimRatio;
|
|
173
185
|
const newIsDark = (0, import_color_utils.compositeIsDark)(
|
|
174
186
|
newDimRatio,
|
|
175
187
|
newOverlayColor,
|
|
@@ -193,7 +205,7 @@ function CoverEdit({
|
|
|
193
205
|
useFeaturedImage: void 0,
|
|
194
206
|
dimRatio: newDimRatio,
|
|
195
207
|
isDark: newIsDark,
|
|
196
|
-
isUserOverlayColor: isUserOverlayColor || false
|
|
208
|
+
isUserOverlayColor: currentAttrs.isUserOverlayColor || false
|
|
197
209
|
});
|
|
198
210
|
};
|
|
199
211
|
const onClearMedia = () => {
|
|
@@ -221,8 +233,9 @@ function CoverEdit({
|
|
|
221
233
|
};
|
|
222
234
|
const onSetOverlayColor = async (newOverlayColor) => {
|
|
223
235
|
const averageBackgroundColor = await (0, import_color_utils.getMediaColor)(url);
|
|
236
|
+
const { attributes: currentAttrs } = propsRef.current;
|
|
224
237
|
const newIsDark = (0, import_color_utils.compositeIsDark)(
|
|
225
|
-
dimRatio,
|
|
238
|
+
currentAttrs.dimRatio,
|
|
226
239
|
newOverlayColor,
|
|
227
240
|
averageBackgroundColor
|
|
228
241
|
);
|
|
@@ -235,9 +248,10 @@ function CoverEdit({
|
|
|
235
248
|
};
|
|
236
249
|
const onUpdateDimRatio = async (newDimRatio) => {
|
|
237
250
|
const averageBackgroundColor = await (0, import_color_utils.getMediaColor)(url);
|
|
251
|
+
const { overlayColor: currentOverlay } = propsRef.current;
|
|
238
252
|
const newIsDark = (0, import_color_utils.compositeIsDark)(
|
|
239
253
|
newDimRatio,
|
|
240
|
-
|
|
254
|
+
currentOverlay.color,
|
|
241
255
|
averageBackgroundColor
|
|
242
256
|
);
|
|
243
257
|
setAttributes({
|
|
@@ -277,15 +291,11 @@ function CoverEdit({
|
|
|
277
291
|
},
|
|
278
292
|
[url, backgroundType]
|
|
279
293
|
);
|
|
280
|
-
const
|
|
294
|
+
const embedHtml = (0, import_element.useMemo)(() => {
|
|
281
295
|
if (backgroundType !== import_shared.EMBED_VIDEO_BACKGROUND_TYPE || !embedPreview?.html) {
|
|
282
296
|
return null;
|
|
283
297
|
}
|
|
284
|
-
|
|
285
|
-
if (!iframeSrc) {
|
|
286
|
-
return null;
|
|
287
|
-
}
|
|
288
|
-
return (0, import_embed_video_utils.getBackgroundVideoSrc)(iframeSrc);
|
|
298
|
+
return (0, import_embed_video_utils.getBackgroundEmbedHtml)(embedPreview.html);
|
|
289
299
|
}, [embedPreview, backgroundType]);
|
|
290
300
|
const isUploadingMedia = isTemporaryMedia(id, url);
|
|
291
301
|
const isImageBackground = import_shared.IMAGE_BACKGROUND_TYPE === backgroundType;
|
|
@@ -350,8 +360,9 @@ function CoverEdit({
|
|
|
350
360
|
const toggleUseFeaturedImage = async () => {
|
|
351
361
|
const newUseFeaturedImage = !useFeaturedImage;
|
|
352
362
|
const averageBackgroundColor = newUseFeaturedImage ? await (0, import_color_utils.getMediaColor)(mediaUrl) : import_color_utils.DEFAULT_BACKGROUND_COLOR;
|
|
353
|
-
const
|
|
354
|
-
|
|
363
|
+
const { attributes: currentAttrs, overlayColor: currentOverlay } = propsRef.current;
|
|
364
|
+
const newOverlayColor = !currentAttrs.isUserOverlayColor ? averageBackgroundColor : currentOverlay.color;
|
|
365
|
+
if (!currentAttrs.isUserOverlayColor) {
|
|
355
366
|
if (newUseFeaturedImage) {
|
|
356
367
|
setOverlayColor(newOverlayColor);
|
|
357
368
|
} else {
|
|
@@ -359,7 +370,7 @@ function CoverEdit({
|
|
|
359
370
|
}
|
|
360
371
|
__unstableMarkNextChangeAsNotPersistent();
|
|
361
372
|
}
|
|
362
|
-
const newDimRatio = dimRatio === 100 ? 50 : dimRatio;
|
|
373
|
+
const newDimRatio = currentAttrs.dimRatio === 100 ? 50 : currentAttrs.dimRatio;
|
|
363
374
|
const newIsDark = (0, import_color_utils.compositeIsDark)(
|
|
364
375
|
newDimRatio,
|
|
365
376
|
newOverlayColor,
|
|
@@ -529,24 +540,26 @@ function CoverEdit({
|
|
|
529
540
|
style: mediaStyle
|
|
530
541
|
}
|
|
531
542
|
),
|
|
532
|
-
isEmbedVideoBackground &&
|
|
543
|
+
isEmbedVideoBackground && embedHtml && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
533
544
|
"div",
|
|
534
545
|
{
|
|
535
546
|
ref: mediaElement,
|
|
536
547
|
className: "wp-block-cover__video-background wp-block-cover__embed-background",
|
|
537
548
|
style: mediaStyle,
|
|
538
549
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
539
|
-
|
|
550
|
+
import_components.SandBox,
|
|
540
551
|
{
|
|
541
|
-
|
|
552
|
+
allowSameOrigin: true,
|
|
553
|
+
html: embedHtml,
|
|
542
554
|
title: "Background video",
|
|
543
|
-
|
|
544
|
-
|
|
555
|
+
styles: [
|
|
556
|
+
"iframe{position:fixed;top:0;left:0;width:100%;height:100%;}"
|
|
557
|
+
]
|
|
545
558
|
}
|
|
546
559
|
)
|
|
547
560
|
}
|
|
548
561
|
),
|
|
549
|
-
isEmbedVideoBackground && !
|
|
562
|
+
isEmbedVideoBackground && !embedHtml && isFetchingEmbed && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}),
|
|
550
563
|
showOverlay && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
551
564
|
"span",
|
|
552
565
|
{
|
|
@@ -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\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\tstyle: {\n\t\t\t\t\ttypography: {\n\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t},\n\t\t\t\t},\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,uBAAkD;AAClD,
|
|
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 {\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { Placeholder, SandBox, 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 { getBackgroundEmbedHtml } 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\tstyle: {\n\t\t\t\t\ttypography: {\n\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t},\n\t\t\t\t},\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\n\t// Ref to access latest values after async operations (e.g. getMediaColor),\n\t// avoiding stale values that could overwrite concurrent remote changes.\n\tconst propsRef = useRef( { attributes, overlayColor } );\n\tuseLayoutEffect( () => {\n\t\tpropsRef.current = { attributes, overlayColor };\n\t} );\n\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\t// Read latest values after await to avoid stale closures.\n\t\t\tconst { attributes: currentAttrs, overlayColor: currentOverlay } =\n\t\t\t\tpropsRef.current;\n\n\t\t\tlet newOverlayColor = currentOverlay.color;\n\t\t\tif ( ! currentAttrs.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\tcurrentAttrs.dimRatio,\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: currentAttrs.isUserOverlayColor || false,\n\t\t\t} );\n\t\t} )();\n\t\t// Update the block only when the featured image changes.\n\t\t// The other dependencies are stable references (dispatch actions / setters).\n\t}, [\n\t\tmediaUrl,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetAttributes,\n\t\tsetOverlayColor,\n\t\tuseFeaturedImage,\n\t] );\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\t// Read latest values to avoid stale closures.\n\t\tconst { attributes: currentAttrs, overlayColor: currentOverlay } =\n\t\t\tpropsRef.current;\n\n\t\tlet newOverlayColor = currentOverlay.color;\n\t\tif ( ! currentAttrs.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\tcurrentAttrs.url === undefined && currentAttrs.dimRatio === 100\n\t\t\t\t? 50\n\t\t\t\t: currentAttrs.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: currentAttrs.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\n\t\t// Read latest dimRatio after await to avoid stale closure.\n\t\tconst { attributes: currentAttrs } = propsRef.current;\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tcurrentAttrs.dimRatio,\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\n\t\t// Read latest overlayColor after await to avoid stale closure.\n\t\tconst { overlayColor: currentOverlay } = propsRef.current;\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\tcurrentOverlay.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 embed HTML for editor display via SandBox\n\tconst embedHtml = 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\t\treturn getBackgroundEmbedHtml( embedPreview.html );\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\t// Read latest values after await to avoid stale closures.\n\t\tconst { attributes: currentAttrs, overlayColor: currentOverlay } =\n\t\t\tpropsRef.current;\n\n\t\tconst newOverlayColor = ! currentAttrs.isUserOverlayColor\n\t\t\t? averageBackgroundColor\n\t\t\t: currentOverlay.color;\n\n\t\tif ( ! currentAttrs.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 =\n\t\t\tcurrentAttrs.dimRatio === 100 ? 50 : currentAttrs.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 && embedHtml && (\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<SandBox\n\t\t\t\t\t\t\tallowSameOrigin\n\t\t\t\t\t\t\thtml={ embedHtml }\n\t\t\t\t\t\t\ttitle=\"Background video\"\n\t\t\t\t\t\t\tstyles={ [\n\t\t\t\t\t\t\t\t'iframe{position:fixed;top:0;left:0;width:100%;height:100%;}',\n\t\t\t\t\t\t\t] }\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 && ! embedHtml && 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,uBAAkD;AAClD,qBAKO;AACP,wBAA8C;AAC9C,qBAA2C;AAC3C,0BASO;AACP,kBAAmB;AACnB,kBAAuC;AACvC,kBAA0B;AAC1B,qBAAsC;AAKtC,oBASO;AACP,gCAAmC;AACnC,4BAA+B;AAC/B,+BAA6B;AAC7B,qCAAkC;AAClC,yBAKO;AACP,uBAAwC;AACxC,+BAAuC;AA6erC;AA3eF,SAAS,uBAAwB,YAAa;AAC7C,SAAO;AAAA,IACN;AAAA,MACC;AAAA,MACA;AAAA,QACC,OAAO;AAAA,UACN,YAAY;AAAA,YACX,WAAW;AAAA,UACZ;AAAA,QACD;AAAA,QACA,iBAAa,gBAAI,mBAAe;AAAA,QAChC,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACD;AACD;AAWA,IAAM,mBAAmB,CAAE,IAAI,QAAS,CAAE,UAAM,uBAAW,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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,UAAU;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,QAAM,CAAE,aAAc,QAAI;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,EAAE,YA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3B,CAAE,aAAc,GAAG;AAAA,gBACpB;AAAA,cACD;AAAA,cACA,OAAQ,EAAE,iBAAiB,eAAe,GAAG,QAAQ;AAAA;AAAA,UACtD;AAAA,UAGC,oBAAoB,4CAAC,6BAAQ;AAAA,UAE/B;AAAA,YAAC,yBAAAC;AAAA,YAAA;AAAA,cACA,qBAAmB;AAAA,cACnB;AAAA,cACA,SAAU;AAAA,cACV;AAAA;AAAA,UACD;AAAA,UACA,4CAAC,SAAM,GAAG,kBAAmB;AAAA;AAAA;AAAA,IAC9B;AAAA,IACE,yBAAyB,cAC1B,4CAAC,+BAAAF,SAAA,EAAwB,GAAG,qBAAsB;AAAA,KAEpD;AAEF;AAEA,IAAO,mBAAQ,wBAAS;AAAA,MACvB,gCAAY,EAAE,cAAc,mBAAmB,CAAE;AAClD,CAAE,EAAG,SAAU;",
|
|
6
6
|
"names": ["blockEditorStore", "coreStore", "noticesStore", "CoverBlockControls", "CoverInspectorControls", "ResizableCoverPopover", "clsx", "CoverPlaceholder"]
|
|
7
7
|
}
|
|
@@ -21,8 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var embed_video_utils_exports = {};
|
|
22
22
|
__export(embed_video_utils_exports, {
|
|
23
23
|
detectProviderFromSrc: () => detectProviderFromSrc,
|
|
24
|
+
getBackgroundEmbedHtml: () => getBackgroundEmbedHtml,
|
|
24
25
|
getBackgroundVideoSrc: () => getBackgroundVideoSrc,
|
|
25
|
-
getIframeSrc: () => getIframeSrc,
|
|
26
26
|
getVideoEmbedProvider: () => getVideoEmbedProvider,
|
|
27
27
|
isValidVideoEmbedUrl: () => isValidVideoEmbedUrl
|
|
28
28
|
});
|
|
@@ -62,12 +62,14 @@ function findVideoEmbedProvider(url) {
|
|
|
62
62
|
}
|
|
63
63
|
return matchingVariation;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
65
|
+
function getBackgroundEmbedHtml(html) {
|
|
66
|
+
const srcMatch = html?.match(/src=["']([^"']+)["']/);
|
|
67
|
+
if (!srcMatch) {
|
|
67
68
|
return null;
|
|
68
69
|
}
|
|
69
|
-
const
|
|
70
|
-
|
|
70
|
+
const iframeSrc = srcMatch[1];
|
|
71
|
+
const backgroundSrc = getBackgroundVideoSrc(iframeSrc);
|
|
72
|
+
return html.replace(iframeSrc, backgroundSrc);
|
|
71
73
|
}
|
|
72
74
|
function detectProviderFromSrc(src) {
|
|
73
75
|
if (!src) {
|
|
@@ -136,15 +138,15 @@ function getBackgroundVideoSrc(src) {
|
|
|
136
138
|
break;
|
|
137
139
|
}
|
|
138
140
|
return url.toString();
|
|
139
|
-
} catch
|
|
141
|
+
} catch {
|
|
140
142
|
return src;
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
// Annotate the CommonJS export names for ESM import in node:
|
|
144
146
|
0 && (module.exports = {
|
|
145
147
|
detectProviderFromSrc,
|
|
148
|
+
getBackgroundEmbedHtml,
|
|
146
149
|
getBackgroundVideoSrc,
|
|
147
|
-
getIframeSrc,
|
|
148
150
|
getVideoEmbedProvider,
|
|
149
151
|
isValidVideoEmbedUrl
|
|
150
152
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 *
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAmC;AAKnC,kBAAgC;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,sBAAkB,kCAAoB,mBAAoB;AAEhE,MAAK,CAAE,iBAAkB;AACxB,WAAO;AAAA,EACR;AAEA,QAAM,oBAAoB,gBAAgB;AAAA,IAAM,CAAE,EAAE,SAAS,UAC5D,6BAAiB,KAAK,QAAS;AAAA,EAChC;AAEA,MACC,CAAE,qBACF,CAAE,gBAAgB,SAAU,kBAAkB,IAAK,GAClD;AACD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAQO,SAAS,
|
|
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 * Modifies embed HTML to use background video parameters.\n *\n * @param {string} html The original embed HTML.\n * @return {string|null} The modified embed HTML, or null if not possible.\n */\nexport function getBackgroundEmbedHtml( html ) {\n\tconst srcMatch = html?.match( /src=[\"']([^\"']+)[\"']/ );\n\tif ( ! srcMatch ) {\n\t\treturn null;\n\t}\n\n\tconst iframeSrc = srcMatch[ 1 ];\n\tconst backgroundSrc = getBackgroundVideoSrc( iframeSrc );\n\treturn html.replace( iframeSrc, backgroundSrc );\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 {\n\t\t// If URL parsing fails, return original src\n\t\treturn src;\n\t}\n}\n"],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AAS,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,QAAQ;AAEP,WAAO;AAAA,EACR;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -33,13 +33,13 @@ __export(embed_preview_exports, {
|
|
|
33
33
|
default: () => EmbedPreview
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(embed_preview_exports);
|
|
36
|
-
var import_util = require("./util.cjs");
|
|
37
36
|
var import_clsx = __toESM(require("clsx"));
|
|
38
37
|
var import_i18n = require("@wordpress/i18n");
|
|
39
38
|
var import_components = require("@wordpress/components");
|
|
40
39
|
var import_block_editor = require("@wordpress/block-editor");
|
|
41
40
|
var import_element = require("@wordpress/element");
|
|
42
41
|
var import_url = require("@wordpress/url");
|
|
42
|
+
var import_util = require("./util.cjs");
|
|
43
43
|
var import_wp_embed_preview = __toESM(require("./wp-embed-preview.cjs"));
|
|
44
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
45
|
function EmbedPreview({
|
|
@@ -76,6 +76,7 @@ function EmbedPreview({
|
|
|
76
76
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
77
|
import_components.SandBox,
|
|
78
78
|
{
|
|
79
|
+
allowSameOrigin: true,
|
|
79
80
|
html,
|
|
80
81
|
scripts,
|
|
81
82
|
title: iframeTitle,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/embed/embed-preview.js"],
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, SandBox } from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { useState } from '@wordpress/element';\nimport { getAuthority } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { getPhotoHtml } from './util';\n\n/**\n * Internal dependencies\n */\nimport WpEmbedPreview from './wp-embed-preview';\n\nexport default function EmbedPreview( {\n\tpreview,\n\tpreviewable,\n\turl,\n\ttype,\n\tisSelected,\n\tclassName,\n\ticon,\n\tlabel,\n} ) {\n\tconst [ interactive, setInteractive ] = useState( false );\n\n\tif ( ! isSelected && interactive ) {\n\t\t// We only want to change this when the block is not selected, because changing it when\n\t\t// the block becomes selected makes the overlap disappear too early. Hiding the overlay\n\t\t// happens on mouseup when the overlay is clicked.\n\t\tsetInteractive( false );\n\t}\n\n\tconst hideOverlay = () => {\n\t\t// This is called onMouseUp on the overlay. We can't respond to the `isSelected` prop\n\t\t// changing, because that happens on mouse down, and the overlay immediately disappears,\n\t\t// and the mouse event can end up in the preview content. We can't use onClick on\n\t\t// the overlay to hide it either, because then the editor misses the mouseup event, and\n\t\t// thinks we're multi-selecting blocks.\n\t\tsetInteractive( true );\n\t};\n\n\tconst { scripts } = preview;\n\n\tconst html = 'photo' === type ? getPhotoHtml( preview ) : preview.html;\n\tconst embedSourceUrl = getAuthority( url );\n\tconst iframeTitle = sprintf(\n\t\t// translators: %s: host providing embed content e.g: www.youtube.com\n\t\t__( 'Embedded content from %s' ),\n\t\tembedSourceUrl\n\t);\n\tconst sandboxClassnames = clsx(\n\t\ttype,\n\t\tclassName,\n\t\t'wp-block-embed__wrapper'\n\t);\n\n\t// Disabled because the overlay div doesn't actually have a role or functionality\n\t// as far as the user is concerned. We're just catching the first click so that\n\t// the block can be selected without interacting with the embed preview that the overlay covers.\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\tconst embedWrapper =\n\t\t'wp-embed' === type ? (\n\t\t\t<WpEmbedPreview html={ html } />\n\t\t) : (\n\t\t\t<div className=\"wp-block-embed__wrapper\">\n\t\t\t\t<SandBox\n\t\t\t\t\tallowSameOrigin\n\t\t\t\t\thtml={ html }\n\t\t\t\t\tscripts={ scripts }\n\t\t\t\t\ttitle={ iframeTitle }\n\t\t\t\t\ttype={ sandboxClassnames }\n\t\t\t\t\tonFocus={ hideOverlay }\n\t\t\t\t/>\n\t\t\t\t{ ! interactive && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"block-library-embed__interactive-overlay\"\n\t\t\t\t\t\tonMouseUp={ hideOverlay }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n\n\treturn (\n\t\t<>\n\t\t\t{ previewable ? (\n\t\t\t\tembedWrapper\n\t\t\t) : (\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t>\n\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t<a href={ url }>{ url }</a>\n\t\t\t\t\t</p>\n\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: host providing embed content e.g: www.youtube.com */\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\"Embedded content from %s can't be previewed in the editor.\"\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tembedSourceUrl\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA4B;AAC5B,wBAAqC;AACrC,0BAA0B;AAC1B,qBAAyB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D,GACD;AAAA;AAAA;AAAA,EACD,GAEF;AAEF;",
|
|
6
6
|
"names": ["clsx", "WpEmbedPreview"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/file/utils/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Uses a combination of user agent matching and feature detection to determine whether\n * the current browser supports rendering PDFs inline.\n *\n * @return {boolean} Whether or not the browser supports inline PDFs.\n */\nexport const browserSupportsPdfs = () => {\n\t// Use native feature detection if available.\n\tif ( window.navigator.pdfViewerEnabled ) {\n\t\treturn true;\n\t}\n\n\t// Most mobile devices include \"Mobi\" in their UA.\n\tif ( window.navigator.userAgent.indexOf( 'Mobi' ) > -1 ) {\n\t\treturn false;\n\t}\n\n\t// Android tablets are the notable exception.\n\tif ( window.navigator.userAgent.indexOf( 'Android' ) > -1 ) {\n\t\treturn false;\n\t}\n\n\t// iPad pretends to be a Mac.\n\tif (\n\t\twindow.navigator.userAgent.indexOf( 'Macintosh' ) > -1 &&\n\t\twindow.navigator.maxTouchPoints &&\n\t\twindow.navigator.maxTouchPoints > 2\n\t) {\n\t\treturn false;\n\t}\n\n\t// IE only supports PDFs when there's an ActiveX object available for it.\n\tif (\n\t\t!! ( window.ActiveXObject || 'ActiveXObject' in window ) &&\n\t\t! (\n\t\t\tcreateActiveXObject( 'AcroPDF.PDF' ) ||\n\t\t\tcreateActiveXObject( 'PDF.PdfCtrl' )\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n};\n\n/**\n * Helper function for creating ActiveX objects, catching any errors that are thrown\n * when it's generated.\n *\n * @param {string} type The name of the ActiveX object to create.\n * @return {window.ActiveXObject|undefined} The generated ActiveXObject, or null if it failed.\n */\nconst createActiveXObject = ( type ) => {\n\tlet ax;\n\ttry {\n\t\tax = new window.ActiveXObject( type );\n\t} catch
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,sBAAsB,MAAM;AAExC,MAAK,OAAO,UAAU,kBAAmB;AACxC,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,UAAU,UAAU,QAAS,MAAO,IAAI,IAAK;AACxD,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,UAAU,UAAU,QAAS,SAAU,IAAI,IAAK;AAC3D,WAAO;AAAA,EACR;AAGA,MACC,OAAO,UAAU,UAAU,QAAS,WAAY,IAAI,MACpD,OAAO,UAAU,kBACjB,OAAO,UAAU,iBAAiB,GACjC;AACD,WAAO;AAAA,EACR;AAGA,MACC,CAAC,EAAI,OAAO,iBAAiB,mBAAmB,WAChD,EACC,oBAAqB,aAAc,KACnC,oBAAqB,aAAc,IAEnC;AACD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AASA,IAAM,sBAAsB,CAAE,SAAU;AACvC,MAAI;AACJ,MAAI;AACH,SAAK,IAAI,OAAO,cAAe,IAAK;AAAA,EACrC,
|
|
4
|
+
"sourcesContent": ["/**\n * Uses a combination of user agent matching and feature detection to determine whether\n * the current browser supports rendering PDFs inline.\n *\n * @return {boolean} Whether or not the browser supports inline PDFs.\n */\nexport const browserSupportsPdfs = () => {\n\t// Use native feature detection if available.\n\tif ( window.navigator.pdfViewerEnabled ) {\n\t\treturn true;\n\t}\n\n\t// Most mobile devices include \"Mobi\" in their UA.\n\tif ( window.navigator.userAgent.indexOf( 'Mobi' ) > -1 ) {\n\t\treturn false;\n\t}\n\n\t// Android tablets are the notable exception.\n\tif ( window.navigator.userAgent.indexOf( 'Android' ) > -1 ) {\n\t\treturn false;\n\t}\n\n\t// iPad pretends to be a Mac.\n\tif (\n\t\twindow.navigator.userAgent.indexOf( 'Macintosh' ) > -1 &&\n\t\twindow.navigator.maxTouchPoints &&\n\t\twindow.navigator.maxTouchPoints > 2\n\t) {\n\t\treturn false;\n\t}\n\n\t// IE only supports PDFs when there's an ActiveX object available for it.\n\tif (\n\t\t!! ( window.ActiveXObject || 'ActiveXObject' in window ) &&\n\t\t! (\n\t\t\tcreateActiveXObject( 'AcroPDF.PDF' ) ||\n\t\t\tcreateActiveXObject( 'PDF.PdfCtrl' )\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n};\n\n/**\n * Helper function for creating ActiveX objects, catching any errors that are thrown\n * when it's generated.\n *\n * @param {string} type The name of the ActiveX object to create.\n * @return {window.ActiveXObject|undefined} The generated ActiveXObject, or null if it failed.\n */\nconst createActiveXObject = ( type ) => {\n\tlet ax;\n\ttry {\n\t\tax = new window.ActiveXObject( type );\n\t} catch {\n\t\tax = undefined;\n\t}\n\treturn ax;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,sBAAsB,MAAM;AAExC,MAAK,OAAO,UAAU,kBAAmB;AACxC,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,UAAU,UAAU,QAAS,MAAO,IAAI,IAAK;AACxD,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,UAAU,UAAU,QAAS,SAAU,IAAI,IAAK;AAC3D,WAAO;AAAA,EACR;AAGA,MACC,OAAO,UAAU,UAAU,QAAS,WAAY,IAAI,MACpD,OAAO,UAAU,kBACjB,OAAO,UAAU,iBAAiB,GACjC;AACD,WAAO;AAAA,EACR;AAGA,MACC,CAAC,EAAI,OAAO,iBAAiB,mBAAmB,WAChD,EACC,oBAAqB,aAAc,KACnC,oBAAqB,aAAc,IAEnC;AACD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AASA,IAAM,sBAAsB,CAAE,SAAU;AACvC,MAAI;AACJ,MAAI;AACH,SAAK,IAAI,OAAO,cAAe,IAAK;AAAA,EACrC,QAAQ;AACP,SAAK;AAAA,EACN;AACA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|