@wordpress/block-library 8.17.1 → 8.18.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/cover/edit/index.js +3 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/shared.js +26 -21
- package/build/cover/shared.js.map +1 -1
- package/build/embed/embed-link-settings.native.js +0 -1
- package/build/embed/embed-link-settings.native.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/query/edit/inspector-controls/index.js +28 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -1
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/index.js +9 -2
- package/build/query/index.js.map +1 -1
- package/build/query/view.js +75 -0
- package/build/query/view.js.map +1 -0
- package/build/query-pagination-next/index.js +1 -1
- package/build/query-pagination-numbers/edit.js +50 -5
- package/build/query-pagination-numbers/edit.js.map +1 -1
- package/build/query-pagination-numbers/index.js +7 -1
- package/build/query-pagination-numbers/index.js.map +1 -1
- package/build/query-pagination-previous/index.js +1 -1
- package/build/search/edit.js +3 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/utils.js +2 -4
- package/build/search/utils.js.map +1 -1
- package/build/social-link/edit.native.js +1 -3
- package/build/social-link/edit.native.js.map +1 -1
- package/build-module/cover/edit/index.js +3 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/shared.js +26 -21
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/embed/embed-link-settings.native.js +0 -1
- package/build-module/embed/embed-link-settings.native.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/query/edit/inspector-controls/index.js +29 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -1
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/index.js +9 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/view.js +72 -0
- package/build-module/query/view.js.map +1 -0
- package/build-module/query-pagination-next/index.js +1 -1
- package/build-module/query-pagination-numbers/edit.js +51 -6
- package/build-module/query-pagination-numbers/edit.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +7 -1
- package/build-module/query-pagination-numbers/index.js.map +1 -1
- package/build-module/query-pagination-previous/index.js +1 -1
- package/build-module/search/edit.js +4 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/utils.js +0 -1
- package/build-module/search/utils.js.map +1 -1
- package/build-module/social-link/edit.native.js +1 -3
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-style/query/style-rtl.css +140 -0
- package/build-style/query/style.css +140 -0
- package/build-style/site-logo/style-rtl.css +1 -0
- package/build-style/site-logo/style.css +1 -0
- package/build-style/style-rtl.css +1 -0
- package/build-style/style.css +1 -0
- package/package.json +32 -32
- package/src/audio/test/__snapshots__/edit.native.js.snap +106 -78
- package/src/cover/edit/index.js +3 -1
- package/src/cover/shared.js +25 -20
- package/src/cover/test/edit.native.js +1 -5
- package/src/embed/embed-link-settings.native.js +0 -1
- package/src/embed/test/index.native.js +9 -9
- package/src/file/test/__snapshots__/edit.native.js.snap +218 -162
- package/src/image/index.php +5 -0
- package/src/post-content/edit.js +2 -2
- package/src/post-content/index.php +0 -6
- package/src/post-featured-image/index.php +0 -6
- package/src/post-template/block.json +2 -1
- package/src/post-template/index.php +19 -4
- package/src/query/block.json +9 -2
- package/src/query/edit/inspector-controls/index.js +46 -3
- package/src/query/edit/query-content.js +1 -0
- package/src/query/index.php +94 -1
- package/src/query/style.scss +63 -0
- package/src/query/view.js +82 -0
- package/src/query-no-results/index.php +1 -5
- package/src/query-pagination-next/block.json +7 -1
- package/src/query-pagination-next/index.php +20 -3
- package/src/query-pagination-numbers/block.json +7 -1
- package/src/query-pagination-numbers/edit.js +64 -16
- package/src/query-pagination-numbers/index.php +27 -4
- package/src/query-pagination-previous/block.json +7 -1
- package/src/query-pagination-previous/index.php +19 -2
- package/src/search/edit.js +8 -2
- package/src/search/test/__snapshots__/edit.native.js.snap +363 -265
- package/src/search/utils.js +0 -1
- package/src/site-logo/style.scss +1 -0
- package/src/social-link/edit.native.js +1 -1
- package/src/social-link/editor.native.scss +0 -4
- package/src/social-links/test/edit.native.js +30 -0
- package/src/social-link/test/index.native.js +0 -132
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_reactNative","_blockEditor","_components","_compose","_i18n","_icons","_data","_socialList","_editor","_interopRequireDefault","DEFAULT_ACTIVE_ICON_STYLES","backgroundColor","color","DEFAULT_INACTIVE_ICON_STYLES","ANIMATION_DELAY","ANIMATION_DURATION","linkSettingsOptions","url","label","__","placeholder","autoFocus","linkLabel","footer","SocialLinkEdit","attributes","setAttributes","isSelected","onFocus","name","service","isLinkSheetVisible","setIsLinkSheetVisible","useState","hasUrl","setHasUrl","activeIcon","styles","inactiveIcon","usePreferredColorSchemeStyle","inactiveIconDark","animatedValue","useRef","Animated","Value","current","IconComponent","getIconBySite","socialLinkName","getNameBySite","useEffect","setValue","animateColors","interpolationColors","interpolate","inputRange","outputRange","stroke","sequence","delay","timing","toValue","duration","easing","Easing","circle","useNativeDriver","start","onCloseSettingsSheet","useCallback","onOpenSettingsSheet","onEmptyURL","onIconPress","accessibilityHint","sprintf","createElement","View","style","container","Fragment","BlockControls","ToolbarGroup","ToolbarButton","title","icon","link","onClick","isActive","LinkSettingsNavigation","isVisible","rel","onClose","options","withBottomSheet","TouchableWithoutFeedback","onPress","accessibilityRole","accessibilityLabel","iconContainer","Icon","animated","_default","compose","withSelect","select","clientId","getBlock","blockEditorStore","block","substring","exports","default"],"sources":["@wordpress/block-library/src/social-link/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Animated, Easing, TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect, useState, useRef, useCallback } from '@wordpress/element';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n} from '@wordpress/components';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { link, Icon } from '@wordpress/icons';\nimport { withSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { getIconBySite, getNameBySite } from './social-list';\nimport styles from './editor.scss';\n\nconst DEFAULT_ACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#f0f0f0',\n\tcolor: '#444',\n};\nconst DEFAULT_INACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#0000003f',\n\tcolor: '#fff',\n};\nconst ANIMATION_DELAY = 300;\nconst ANIMATION_DURATION = 400;\n\nconst linkSettingsOptions = {\n\turl: {\n\t\tlabel: __( 'URL' ),\n\t\tplaceholder: __( 'Add URL' ),\n\t\tautoFocus: true,\n\t},\n\tlinkLabel: {\n\t\tlabel: __( 'Link label' ),\n\t\tplaceholder: __( 'None' ),\n\t},\n\tfooter: {\n\t\tlabel: __( 'Briefly describe the link to help screen reader user' ),\n\t},\n};\n\nconst SocialLinkEdit = ( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tonFocus,\n\tname,\n} ) => {\n\tconst { url, service = name } = attributes;\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ hasUrl, setHasUrl ] = useState( !! url );\n\tconst activeIcon =\n\t\tstyles[ `wp-social-link-${ service }` ] ||\n\t\tstyles[ `wp-social-link` ] ||\n\t\tDEFAULT_ACTIVE_ICON_STYLES;\n\tconst inactiveIcon =\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.inactiveIcon,\n\t\t\tstyles.inactiveIconDark\n\t\t) || DEFAULT_INACTIVE_ICON_STYLES;\n\n\tconst animatedValue = useRef( new Animated.Value( 0 ) ).current;\n\n\tconst IconComponent = getIconBySite( service )();\n\tconst socialLinkName = getNameBySite( service );\n\n\t// When new social icon is added link sheet is opened automatically.\n\tuseEffect( () => {\n\t\tif ( isSelected && ! url ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! url ) {\n\t\t\tsetHasUrl( false );\n\t\t\tanimatedValue.setValue( 0 );\n\t\t} else if ( url ) {\n\t\t\tanimateColors();\n\t\t}\n\t}, [ url ] );\n\n\tconst interpolationColors = {\n\t\tbackgroundColor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [\n\t\t\t\tinactiveIcon.backgroundColor,\n\t\t\t\tactiveIcon.backgroundColor,\n\t\t\t],\n\t\t} ),\n\t\tcolor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [ inactiveIcon.color, activeIcon.color ],\n\t\t} ),\n\t\tstroke: '',\n\t};\n\n\tconst { backgroundColor, color, stroke } = hasUrl\n\t\t? activeIcon\n\t\t: interpolationColors;\n\n\tfunction animateColors() {\n\t\tAnimated.sequence( [\n\t\t\tAnimated.delay( ANIMATION_DELAY ),\n\t\t\tAnimated.timing( animatedValue, {\n\t\t\t\ttoValue: 1,\n\t\t\t\tduration: ANIMATION_DURATION,\n\t\t\t\teasing: Easing.circle,\n\t\t\t\tuseNativeDriver: false,\n\t\t\t} ),\n\t\t] ).start( () => setHasUrl( true ) );\n\t}\n\n\tconst onCloseSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( false );\n\t}, [] );\n\n\tconst onOpenSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( true );\n\t}, [] );\n\n\tconst onEmptyURL = useCallback( () => {\n\t\tanimatedValue.setValue( 0 );\n\t\tsetHasUrl( false );\n\t}, [ animatedValue ] );\n\n\tfunction onIconPress() {\n\t\tif ( isSelected ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t}\n\n\tconst accessibilityHint = url\n\t\t? sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has URL set' ),\n\t\t\t\tsocialLinkName\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has no URL set' ),\n\t\t\t\tsocialLinkName\n\t\t );\n\n\treturn (\n\t\t<View style={ styles.container }>\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t\t\t\t\t__( 'Add link to %s' ),\n\t\t\t\t\t\t\t\t\tsocialLinkName\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onOpenSettingsSheet }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<LinkSettingsNavigation\n\t\t\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\t\t\turl={ attributes.url }\n\t\t\t\t\t\tlabel={ attributes.label }\n\t\t\t\t\t\trel={ attributes.rel }\n\t\t\t\t\t\tonEmptyURL={ onEmptyURL }\n\t\t\t\t\t\tonClose={ onCloseSettingsSheet }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\toptions={ linkSettingsOptions }\n\t\t\t\t\t\twithBottomSheet\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tonPress={ onIconPress }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t__( '%s social icon' ),\n\t\t\t\t\tsocialLinkName\n\t\t\t\t) }\n\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t>\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={ [ styles.iconContainer, { backgroundColor } ] }\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tanimated\n\t\t\t\t\t\ticon={ IconComponent }\n\t\t\t\t\t\tstyle={ { stroke, color } }\n\t\t\t\t\t/>\n\t\t\t\t</Animated.View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t</View>\n\t);\n};\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\n\t\tconst block = getBlock( clientId );\n\t\tconst name = block?.name.substring( 17 );\n\n\t\treturn {\n\t\t\tname,\n\t\t};\n\t} ),\n] )( SocialLinkEdit );\n"],"mappings":";;;;;;;AAYA,IAAAA,QAAA,GAAAC,OAAA;AATA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,YAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAIA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAC,sBAAA,CAAAV,OAAA;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAIA,MAAMW,0BAA0B,GAAG;EAClCC,eAAe,EAAE,SAAS;EAC1BC,KAAK,EAAE;AACR,CAAC;AACD,MAAMC,4BAA4B,GAAG;EACpCF,eAAe,EAAE,WAAW;EAC5BC,KAAK,EAAE;AACR,CAAC;AACD,MAAME,eAAe,GAAG,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rB,CAAC;AAET,CAAC;AAAC,IAAAyF,QAAA,GAEa,IAAAC,gBAAO,EAAE,CACvB,IAAAC,gBAAU,EAAE,CAAEC,MAAM,EAAE;EAAEC;AAAS,CAAC,KAAM;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAGF,MAAM,CAAEG,kBAAiB,CAAC;EAE/C,MAAMC,KAAK,GAAGF,QAAQ,CAAED,QAAS,CAAC;EAClC,MAAM5E,IAAI,GAAG+E,KAAK,EAAE/E,IAAI,CAACgF,SAAS,CAAE,EAAG,CAAC;EAExC,OAAO;IACNhF;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAEL,cAAe,CAAC;AAAAsF,OAAA,CAAAC,OAAA,GAAAV,QAAA"}
|
|
1
|
+
{"version":3,"names":["_element","require","_reactNative","_blockEditor","_components","_compose","_i18n","_icons","_data","_socialList","_editor","_interopRequireDefault","DEFAULT_ACTIVE_ICON_STYLES","backgroundColor","color","DEFAULT_INACTIVE_ICON_STYLES","ANIMATION_DELAY","ANIMATION_DURATION","linkSettingsOptions","url","label","__","placeholder","autoFocus","linkLabel","footer","SocialLinkEdit","attributes","setAttributes","isSelected","onFocus","name","service","isLinkSheetVisible","setIsLinkSheetVisible","useState","hasUrl","setHasUrl","activeIcon","styles","inactiveIcon","usePreferredColorSchemeStyle","inactiveIconDark","animatedValue","useRef","Animated","Value","current","IconComponent","getIconBySite","socialLinkName","getNameBySite","useEffect","setValue","animateColors","interpolationColors","interpolate","inputRange","outputRange","stroke","sequence","delay","timing","toValue","duration","easing","Easing","circle","useNativeDriver","start","onCloseSettingsSheet","useCallback","onOpenSettingsSheet","onEmptyURL","onIconPress","accessibilityHint","sprintf","createElement","View","Fragment","BlockControls","ToolbarGroup","ToolbarButton","title","icon","link","onClick","isActive","LinkSettingsNavigation","isVisible","rel","onClose","options","withBottomSheet","TouchableWithoutFeedback","onPress","accessibilityRole","accessibilityLabel","style","iconContainer","Icon","animated","_default","compose","withSelect","select","clientId","getBlock","blockEditorStore","block","substring","exports","default"],"sources":["@wordpress/block-library/src/social-link/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Animated, Easing, TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect, useState, useRef, useCallback } from '@wordpress/element';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n} from '@wordpress/components';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { link, Icon } from '@wordpress/icons';\nimport { withSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { getIconBySite, getNameBySite } from './social-list';\nimport styles from './editor.scss';\n\nconst DEFAULT_ACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#f0f0f0',\n\tcolor: '#444',\n};\nconst DEFAULT_INACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#0000003f',\n\tcolor: '#fff',\n};\nconst ANIMATION_DELAY = 300;\nconst ANIMATION_DURATION = 400;\n\nconst linkSettingsOptions = {\n\turl: {\n\t\tlabel: __( 'URL' ),\n\t\tplaceholder: __( 'Add URL' ),\n\t\tautoFocus: true,\n\t},\n\tlinkLabel: {\n\t\tlabel: __( 'Link label' ),\n\t\tplaceholder: __( 'None' ),\n\t},\n\tfooter: {\n\t\tlabel: __( 'Briefly describe the link to help screen reader user' ),\n\t},\n};\n\nconst SocialLinkEdit = ( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tonFocus,\n\tname,\n} ) => {\n\tconst { url, service = name } = attributes;\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ hasUrl, setHasUrl ] = useState( !! url );\n\tconst activeIcon =\n\t\tstyles[ `wp-social-link-${ service }` ] ||\n\t\tstyles[ `wp-social-link` ] ||\n\t\tDEFAULT_ACTIVE_ICON_STYLES;\n\tconst inactiveIcon =\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.inactiveIcon,\n\t\t\tstyles.inactiveIconDark\n\t\t) || DEFAULT_INACTIVE_ICON_STYLES;\n\n\tconst animatedValue = useRef( new Animated.Value( 0 ) ).current;\n\n\tconst IconComponent = getIconBySite( service )();\n\tconst socialLinkName = getNameBySite( service );\n\n\t// When new social icon is added link sheet is opened automatically.\n\tuseEffect( () => {\n\t\tif ( isSelected && ! url ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! url ) {\n\t\t\tsetHasUrl( false );\n\t\t\tanimatedValue.setValue( 0 );\n\t\t} else if ( url ) {\n\t\t\tanimateColors();\n\t\t}\n\t}, [ url ] );\n\n\tconst interpolationColors = {\n\t\tbackgroundColor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [\n\t\t\t\tinactiveIcon.backgroundColor,\n\t\t\t\tactiveIcon.backgroundColor,\n\t\t\t],\n\t\t} ),\n\t\tcolor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [ inactiveIcon.color, activeIcon.color ],\n\t\t} ),\n\t\tstroke: '',\n\t};\n\n\tconst { backgroundColor, color, stroke } = hasUrl\n\t\t? activeIcon\n\t\t: interpolationColors;\n\n\tfunction animateColors() {\n\t\tAnimated.sequence( [\n\t\t\tAnimated.delay( ANIMATION_DELAY ),\n\t\t\tAnimated.timing( animatedValue, {\n\t\t\t\ttoValue: 1,\n\t\t\t\tduration: ANIMATION_DURATION,\n\t\t\t\teasing: Easing.circle,\n\t\t\t\tuseNativeDriver: false,\n\t\t\t} ),\n\t\t] ).start( () => setHasUrl( true ) );\n\t}\n\n\tconst onCloseSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( false );\n\t}, [] );\n\n\tconst onOpenSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( true );\n\t}, [] );\n\n\tconst onEmptyURL = useCallback( () => {\n\t\tanimatedValue.setValue( 0 );\n\t\tsetHasUrl( false );\n\t}, [ animatedValue ] );\n\n\tfunction onIconPress() {\n\t\tif ( isSelected ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t}\n\n\tconst accessibilityHint = url\n\t\t? sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has URL set' ),\n\t\t\t\tsocialLinkName\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has no URL set' ),\n\t\t\t\tsocialLinkName\n\t\t );\n\n\treturn (\n\t\t<View>\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t\t\t\t\t__( 'Add link to %s' ),\n\t\t\t\t\t\t\t\t\tsocialLinkName\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onOpenSettingsSheet }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<LinkSettingsNavigation\n\t\t\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\t\t\turl={ attributes.url }\n\t\t\t\t\t\tlabel={ attributes.label }\n\t\t\t\t\t\trel={ attributes.rel }\n\t\t\t\t\t\tonEmptyURL={ onEmptyURL }\n\t\t\t\t\t\tonClose={ onCloseSettingsSheet }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\toptions={ linkSettingsOptions }\n\t\t\t\t\t\twithBottomSheet\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tonPress={ onIconPress }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t__( '%s social icon' ),\n\t\t\t\t\tsocialLinkName\n\t\t\t\t) }\n\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t>\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={ [ styles.iconContainer, { backgroundColor } ] }\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tanimated\n\t\t\t\t\t\ticon={ IconComponent }\n\t\t\t\t\t\tstyle={ { stroke, color } }\n\t\t\t\t\t/>\n\t\t\t\t</Animated.View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t</View>\n\t);\n};\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\n\t\tconst block = getBlock( clientId );\n\t\tconst name = block?.name.substring( 17 );\n\n\t\treturn {\n\t\t\tname,\n\t\t};\n\t} ),\n] )( SocialLinkEdit );\n"],"mappings":";;;;;;;AAYA,IAAAA,QAAA,GAAAC,OAAA;AATA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,YAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAIA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAC,sBAAA,CAAAV,OAAA;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAIA,MAAMW,0BAA0B,GAAG;EAClCC,eAAe,EAAE,SAAS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IAAI,EAAGpC,aAAe;IACtBkD,KAAK,EAAG;MAAEvC,MAAM;MAAE7C;IAAM;EAAG,CAC3B,CACa,CACU,CACrB,CAAC;AAET,CAAC;AAAC,IAAAwF,QAAA,GAEa,IAAAC,gBAAO,EAAE,CACvB,IAAAC,gBAAU,EAAE,CAAEC,MAAM,EAAE;EAAEC;AAAS,CAAC,KAAM;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAGF,MAAM,CAAEG,kBAAiB,CAAC;EAE/C,MAAMC,KAAK,GAAGF,QAAQ,CAAED,QAAS,CAAC;EAClC,MAAM3E,IAAI,GAAG8E,KAAK,EAAE9E,IAAI,CAAC+E,SAAS,CAAE,EAAG,CAAC;EAExC,OAAO;IACN/E;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAEL,cAAe,CAAC;AAAAqF,OAAA,CAAAC,OAAA,GAAAV,QAAA"}
|
|
@@ -116,7 +116,9 @@ function CoverEdit({
|
|
|
116
116
|
} = __experimentalUseGradient();
|
|
117
117
|
const setMedia = attributesFromMedia(setAttributes, dimRatio);
|
|
118
118
|
const onSelectMedia = async newMedia => {
|
|
119
|
-
|
|
119
|
+
// Only pass the url to getCoverIsDark if the media is an image as video is not handled.
|
|
120
|
+
const newUrl = newMedia?.type === 'image' ? newMedia.url : undefined;
|
|
121
|
+
const isDarkSetting = await getCoverIsDark(newUrl, dimRatio, overlayColor.color);
|
|
120
122
|
setMedia(newMedia, isDarkSetting);
|
|
121
123
|
};
|
|
122
124
|
const onClearMedia = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","extend","namesPlugin","useEntityProp","store","coreStore","useEffect","useMemo","useRef","Placeholder","Spinner","compose","useResizeObserver","withColors","ColorPalette","useBlockProps","useSetting","useInnerBlocksProps","__experimentalUseGradient","blockEditorStore","__","useSelect","useDispatch","isBlobURL","noticesStore","attributesFromMedia","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","dimRatioToClass","isContentPositionCenter","getPositionClassName","mediaPosition","getCoverIsDark","CoverInspectorControls","CoverBlockControls","CoverPlaceholder","ResizableCoverPopover","getInnerBlocksTemplate","attributes","align","placeholder","isTemporaryMedia","id","url","CoverEdit","clientId","isSelected","overlayColor","setAttributes","setOverlayColor","toggleSelection","context","postId","postType","contentPosition","useFeaturedImage","dimRatio","focalPoint","hasParallax","isDark","isRepeated","minHeight","minHeightUnit","alt","allowedBlocks","templateLock","tagName","TagName","featuredImage","__unstableMarkNextChangeAsNotPersistent","media","select","getMedia","mediaUrl","source_url","setIsDark","isDarkSetting","color","replaceAll","backgroundType","createErrorNotice","gradientClass","gradientValue","setMedia","onSelectMedia","newMedia","onClearMedia","undefined","onSetOverlayColor","colorValue","onUpdateDimRatio","newDimRatio","isUploadingMedia","onUploadError","message","type","isImageBackground","isVideoBackground","resizeListener","height","width","resizableBoxDimensions","minHeightWithUnit","isImgElement","style","backgroundImage","backgroundPosition","bgStyle","backgroundColor","mediaStyle","objectPosition","hasBackground","hasInnerBlocks","getBlock","innerBlocks","length","ref","blockProps","hasFontSizes","innerBlocksTemplate","fontSize","innerBlocksProps","className","template","templateInsertUpdatesSelection","mediaElement","currentSettings","toggleUseFeaturedImage","blockControls","createElement","inspectorControls","coverRef","updateDimRatio","resizableCoverProps","onResizeStart","onResize","value","onResizeStop","newMinHeight","showHandle","size","Fragment","onError","disableCustomColors","onChange","clearable","classes","class","withIllustration","src","role","autoPlay","muted","loop","disableMediaButtons"],"sources":["@wordpress/block-library/src/cover/edit/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\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\tuseSetting,\n\tuseInnerBlocksProps,\n\t__experimentalUseGradient,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport {\n\tattributesFromMedia,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n\tgetCoverIsDark,\n} from '../shared';\nimport CoverInspectorControls from './inspector-controls';\nimport CoverBlockControls from './block-controls';\nimport CoverPlaceholder from './cover-placeholder';\nimport ResizableCoverPopover from './resizable-cover-popover';\n\nextend( [ namesPlugin ] );\n\nfunction getInnerBlocksTemplate( attributes ) {\n\treturn [\n\t\t[\n\t\t\t'core/paragraph',\n\t\t\t{\n\t\t\t\talign: 'center',\n\t\t\t\tplaceholder: __( 'Write title…' ),\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\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} = attributes;\n\n\tconst [ featuredImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst media = useSelect(\n\t\t( select ) =>\n\t\t\tfeaturedImage &&\n\t\t\tselect( coreStore ).getMedia( featuredImage, { context: 'view' } ),\n\t\t[ featuredImage ]\n\t);\n\tconst mediaUrl = media?.source_url;\n\n\tuseEffect( () => {\n\t\tasync function setIsDark() {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tconst isDarkSetting = await getCoverIsDark(\n\t\t\t\tmediaUrl,\n\t\t\t\tdimRatio,\n\t\t\t\toverlayColor.color\n\t\t\t);\n\t\t\tsetAttributes( {\n\t\t\t\tisDark: isDarkSetting,\n\t\t\t} );\n\t\t}\n\t\tif ( useFeaturedImage ) {\n\t\t\tsetIsDark();\n\t\t}\n\t\t// We only ever want to run this effect if the mediaUrl changes.\n\t\t// All other changes to the isDark state are handled in the appropriate event handlers.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\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 attributes.url?.replaceAll( '&', '&' );\n\tconst backgroundType = useFeaturedImage\n\t\t? IMAGE_BACKGROUND_TYPE\n\t\t: attributes.backgroundType;\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { gradientClass, gradientValue } = __experimentalUseGradient();\n\tconst setMedia = attributesFromMedia( setAttributes, dimRatio );\n\n\tconst onSelectMedia = async ( newMedia ) => {\n\t\tconst isDarkSetting = await getCoverIsDark(\n\t\t\tnewMedia.url,\n\t\t\tdimRatio,\n\t\t\toverlayColor.color\n\t\t);\n\t\tsetMedia( newMedia, isDarkSetting );\n\t};\n\n\tconst onClearMedia = async () => {\n\t\tconst isDarkSetting = await getCoverIsDark(\n\t\t\tundefined,\n\t\t\tdimRatio,\n\t\t\toverlayColor.color\n\t\t);\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: false,\n\t\t\tisDark: isDarkSetting,\n\t\t} );\n\t};\n\n\tconst onSetOverlayColor = async ( colorValue ) => {\n\t\tconst isDarkSetting = await getCoverIsDark( url, dimRatio, colorValue );\n\t\tsetOverlayColor( colorValue );\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( {\n\t\t\tisDark: isDarkSetting,\n\t\t} );\n\t};\n\n\tconst onUpdateDimRatio = async ( newDimRatio ) => {\n\t\tconst isDarkSetting = await getCoverIsDark(\n\t\t\turl,\n\t\t\tnewDimRatio,\n\t\t\toverlayColor.color\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\tdimRatio: newDimRatio,\n\t\t\tisDark: isDarkSetting,\n\t\t} );\n\t};\n\n\tconst isUploadingMedia = isTemporaryMedia( id, url );\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst [ resizeListener, { height, width } ] = useResizeObserver();\n\tconst resizableBoxDimensions = useMemo( () => {\n\t\treturn {\n\t\t\theight: minHeightUnit === 'px' ? 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 hasFontSizes = !! useSetting( 'typography.fontSizes' )?.length;\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}\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 isDarkSetting = await ( useFeaturedImage\n\t\t\t? getCoverIsDark( undefined, dimRatio, overlayColor.color )\n\t\t\t: getCoverIsDark( mediaUrl, dimRatio, overlayColor.color ) );\n\t\tsetAttributes( {\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tuseFeaturedImage: ! useFeaturedImage,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\tbackgroundType: useFeaturedImage\n\t\t\t\t? IMAGE_BACKGROUND_TYPE\n\t\t\t\t: undefined,\n\t\t\tisDark: isDarkSetting,\n\t\t} );\n\t};\n\n\tconst blockControls = (\n\t\t<CoverBlockControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t/>\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/>\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\tshowHandle: true,\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{ 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={ classnames(\n\t\t\t\t\t\t'is-placeholder',\n\t\t\t\t\t\tblockProps.className\n\t\t\t\t\t) }\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={ true }\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/>\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 = classnames(\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\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={ classnames( 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\t\t\t\t{ ( ! useFeaturedImage || url ) && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName={ classnames(\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{ ! 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={ true }\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=\"img\"\n\t\t\t\t\t\t\tclassName={ classnames(\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\tstyle={ mediaStyle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isUploadingMedia && <Spinner /> }\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{ 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"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,OAAOC,WAAW,MAAM,sBAAsB;;AAE9C;AACA;AACA;AACA,SAASC,aAAa,EAAEC,KAAK,IAAIC,SA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H,SAAS,EAAC,kCAAkC;IAC5C3D,GAAG,EAAGA,GAAK;IACXsF,GAAG,EAAG1G,GAAK;IACX6D,KAAK,EAAGK;EAAY,CACpB,CAAC,GAEFoB,aAAA;IACCb,GAAG,EAAGS,YAAc;IACpByB,IAAI,EAAC,KAAK;IACV5B,SAAS,EAAG1H,UAAU,CACrBkJ,OAAO,EACP,kCACD,CAAG;IACH1C,KAAK,EAAG;MAAEC,eAAe;MAAEC;IAAmB;EAAG,CACjD,CACD,CAAE,EACF/D,GAAG,IAAIsD,iBAAiB,IACzBgC,aAAA;IACCb,GAAG,EAAGS,YAAc;IACpBH,SAAS,EAAC,kCAAkC;IAC5C6B,QAAQ;IACRC,KAAK;IACLC,IAAI;IACJJ,GAAG,EAAG1G,GAAK;IACX6D,KAAK,EAAGK;EAAY,CACpB,CACD,EACCjB,gBAAgB,IAAIqC,aAAA,CAACvH,OAAO,MAAE,CAAC,EACjCuH,aAAA,CAAC9F,gBAAgB;IAChBuH,mBAAmB;IACnBtE,aAAa,EAAGA,aAAe;IAC/B0D,OAAO,EAAGjD,aAAe;IACzBkC,sBAAsB,EAAGA;EAAwB,CACjD,CAAC,EACFE,aAAA;IAAA,GAAUR;EAAgB,CAAI,CACtB,CAAC,EACR3E,UAAU,IACXmF,aAAA,CAAC7F,qBAAqB;IAAA,GAAMiG;EAAmB,CAAI,CAEnD,CAAC;AAEL;AAEA,eAAe1H,OAAO,CAAE,CACvBE,UAAU,CAAE;EAAEkC,YAAY,EAAE;AAAmB,CAAE,CAAC,CACjD,CAAC,CAAEH,SAAU,CAAC"}
|
|
1
|
+
{"version":3,"names":["classnames","extend","namesPlugin","useEntityProp","store","coreStore","useEffect","useMemo","useRef","Placeholder","Spinner","compose","useResizeObserver","withColors","ColorPalette","useBlockProps","useSetting","useInnerBlocksProps","__experimentalUseGradient","blockEditorStore","__","useSelect","useDispatch","isBlobURL","noticesStore","attributesFromMedia","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","dimRatioToClass","isContentPositionCenter","getPositionClassName","mediaPosition","getCoverIsDark","CoverInspectorControls","CoverBlockControls","CoverPlaceholder","ResizableCoverPopover","getInnerBlocksTemplate","attributes","align","placeholder","isTemporaryMedia","id","url","CoverEdit","clientId","isSelected","overlayColor","setAttributes","setOverlayColor","toggleSelection","context","postId","postType","contentPosition","useFeaturedImage","dimRatio","focalPoint","hasParallax","isDark","isRepeated","minHeight","minHeightUnit","alt","allowedBlocks","templateLock","tagName","TagName","featuredImage","__unstableMarkNextChangeAsNotPersistent","media","select","getMedia","mediaUrl","source_url","setIsDark","isDarkSetting","color","replaceAll","backgroundType","createErrorNotice","gradientClass","gradientValue","setMedia","onSelectMedia","newMedia","newUrl","type","undefined","onClearMedia","onSetOverlayColor","colorValue","onUpdateDimRatio","newDimRatio","isUploadingMedia","onUploadError","message","isImageBackground","isVideoBackground","resizeListener","height","width","resizableBoxDimensions","minHeightWithUnit","isImgElement","style","backgroundImage","backgroundPosition","bgStyle","backgroundColor","mediaStyle","objectPosition","hasBackground","hasInnerBlocks","getBlock","innerBlocks","length","ref","blockProps","hasFontSizes","innerBlocksTemplate","fontSize","innerBlocksProps","className","template","templateInsertUpdatesSelection","mediaElement","currentSettings","toggleUseFeaturedImage","blockControls","createElement","inspectorControls","coverRef","updateDimRatio","resizableCoverProps","onResizeStart","onResize","value","onResizeStop","newMinHeight","showHandle","size","Fragment","onError","disableCustomColors","onChange","clearable","classes","class","withIllustration","src","role","autoPlay","muted","loop","disableMediaButtons"],"sources":["@wordpress/block-library/src/cover/edit/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\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\tuseSetting,\n\tuseInnerBlocksProps,\n\t__experimentalUseGradient,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport {\n\tattributesFromMedia,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n\tgetCoverIsDark,\n} from '../shared';\nimport CoverInspectorControls from './inspector-controls';\nimport CoverBlockControls from './block-controls';\nimport CoverPlaceholder from './cover-placeholder';\nimport ResizableCoverPopover from './resizable-cover-popover';\n\nextend( [ namesPlugin ] );\n\nfunction getInnerBlocksTemplate( attributes ) {\n\treturn [\n\t\t[\n\t\t\t'core/paragraph',\n\t\t\t{\n\t\t\t\talign: 'center',\n\t\t\t\tplaceholder: __( 'Write title…' ),\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\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} = attributes;\n\n\tconst [ featuredImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst media = useSelect(\n\t\t( select ) =>\n\t\t\tfeaturedImage &&\n\t\t\tselect( coreStore ).getMedia( featuredImage, { context: 'view' } ),\n\t\t[ featuredImage ]\n\t);\n\tconst mediaUrl = media?.source_url;\n\n\tuseEffect( () => {\n\t\tasync function setIsDark() {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tconst isDarkSetting = await getCoverIsDark(\n\t\t\t\tmediaUrl,\n\t\t\t\tdimRatio,\n\t\t\t\toverlayColor.color\n\t\t\t);\n\t\t\tsetAttributes( {\n\t\t\t\tisDark: isDarkSetting,\n\t\t\t} );\n\t\t}\n\t\tif ( useFeaturedImage ) {\n\t\t\tsetIsDark();\n\t\t}\n\t\t// We only ever want to run this effect if the mediaUrl changes.\n\t\t// All other changes to the isDark state are handled in the appropriate event handlers.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\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 attributes.url?.replaceAll( '&', '&' );\n\tconst backgroundType = useFeaturedImage\n\t\t? IMAGE_BACKGROUND_TYPE\n\t\t: attributes.backgroundType;\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { gradientClass, gradientValue } = __experimentalUseGradient();\n\tconst setMedia = attributesFromMedia( setAttributes, dimRatio );\n\n\tconst onSelectMedia = async ( newMedia ) => {\n\t\t// Only pass the url to getCoverIsDark if the media is an image as video is not handled.\n\t\tconst newUrl = newMedia?.type === 'image' ? newMedia.url : undefined;\n\t\tconst isDarkSetting = await getCoverIsDark(\n\t\t\tnewUrl,\n\t\t\tdimRatio,\n\t\t\toverlayColor.color\n\t\t);\n\t\tsetMedia( newMedia, isDarkSetting );\n\t};\n\n\tconst onClearMedia = async () => {\n\t\tconst isDarkSetting = await getCoverIsDark(\n\t\t\tundefined,\n\t\t\tdimRatio,\n\t\t\toverlayColor.color\n\t\t);\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: false,\n\t\t\tisDark: isDarkSetting,\n\t\t} );\n\t};\n\n\tconst onSetOverlayColor = async ( colorValue ) => {\n\t\tconst isDarkSetting = await getCoverIsDark( url, dimRatio, colorValue );\n\t\tsetOverlayColor( colorValue );\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( {\n\t\t\tisDark: isDarkSetting,\n\t\t} );\n\t};\n\n\tconst onUpdateDimRatio = async ( newDimRatio ) => {\n\t\tconst isDarkSetting = await getCoverIsDark(\n\t\t\turl,\n\t\t\tnewDimRatio,\n\t\t\toverlayColor.color\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\tdimRatio: newDimRatio,\n\t\t\tisDark: isDarkSetting,\n\t\t} );\n\t};\n\n\tconst isUploadingMedia = isTemporaryMedia( id, url );\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst [ resizeListener, { height, width } ] = useResizeObserver();\n\tconst resizableBoxDimensions = useMemo( () => {\n\t\treturn {\n\t\t\theight: minHeightUnit === 'px' ? 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 hasFontSizes = !! useSetting( 'typography.fontSizes' )?.length;\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}\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 isDarkSetting = await ( useFeaturedImage\n\t\t\t? getCoverIsDark( undefined, dimRatio, overlayColor.color )\n\t\t\t: getCoverIsDark( mediaUrl, dimRatio, overlayColor.color ) );\n\t\tsetAttributes( {\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tuseFeaturedImage: ! useFeaturedImage,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\tbackgroundType: useFeaturedImage\n\t\t\t\t? IMAGE_BACKGROUND_TYPE\n\t\t\t\t: undefined,\n\t\t\tisDark: isDarkSetting,\n\t\t} );\n\t};\n\n\tconst blockControls = (\n\t\t<CoverBlockControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t/>\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/>\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\tshowHandle: true,\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{ 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={ classnames(\n\t\t\t\t\t\t'is-placeholder',\n\t\t\t\t\t\tblockProps.className\n\t\t\t\t\t) }\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={ true }\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/>\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 = classnames(\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\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={ classnames( 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\t\t\t\t{ ( ! useFeaturedImage || url ) && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName={ classnames(\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{ ! 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={ true }\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=\"img\"\n\t\t\t\t\t\t\tclassName={ classnames(\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\tstyle={ mediaStyle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isUploadingMedia && <Spinner /> }\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{ 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"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,MAAM,QA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
export async function getCoverIsDark(url, dimRatio = 50, overlayColor) {
|
|
156
156
|
const overlay = colord(overlayColor).alpha(dimRatio / 100).toRgb();
|
|
157
157
|
if (url) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
158
|
+
try {
|
|
159
|
+
const imgCrossOrigin = applyFilters('media.crossOrigin', undefined, url);
|
|
160
|
+
const {
|
|
161
|
+
value: [r, g, b, a]
|
|
162
|
+
} = await retrieveFastAverageColor().getColorAsync(url, {
|
|
163
|
+
// Previously the default color was white, but that changed
|
|
164
|
+
// in v6.0.0 so it has to be manually set now.
|
|
165
|
+
defaultColor: [255, 255, 255, 255],
|
|
166
|
+
// Errors that come up don't reject the promise, so error
|
|
167
|
+
// logging has to be silenced with this option.
|
|
168
|
+
silent: process.env.NODE_ENV === 'production',
|
|
169
|
+
crossOrigin: imgCrossOrigin
|
|
170
|
+
});
|
|
171
|
+
// FAC uses 0-255 for alpha, but colord expects 0-1.
|
|
172
|
+
const media = {
|
|
173
|
+
r,
|
|
174
|
+
g,
|
|
175
|
+
b,
|
|
176
|
+
a: a / 255
|
|
177
|
+
};
|
|
178
|
+
const composite = compositeSourceOver(overlay, media);
|
|
179
|
+
return colord(composite).isDark();
|
|
180
|
+
} catch (error) {
|
|
181
|
+
// If there's an error, just assume the image is dark.
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
179
184
|
}
|
|
180
185
|
|
|
181
186
|
// Assume a white background because it isn't easy to get the actual
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FastAverageColor","colord","getBlobTypeByURL","isBlobURL","applyFilters","POSITION_CLASSNAMES","center","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","COVER_MIN_HEIGHT","COVER_MAX_HEIGHT","COVER_DEFAULT_HEIGHT","DEFAULT_FOCAL_POINT","x","y","ALLOWED_MEDIA_TYPES","mediaPosition","Math","round","dimRatioToClass","ratio","undefined","attributesFromMedia","setAttributes","dimRatio","media","isDark","url","id","type","mediaType","media_type","alt","backgroundType","focalPoint","hasParallax","isContentPositionCenter","contentPosition","getPositionClassName","compositeSourceOver","source","dest","r","a","g","b","retrieveFastAverageColor","fastAverageColor","getCoverIsDark","overlayColor","overlay","alpha","toRgb","imgCrossOrigin","value","getColorAsync","defaultColor","silent","process","env","NODE_ENV","crossOrigin","composite","background"],"sources":["@wordpress/block-library/src/cover/shared.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { FastAverageColor } from 'fast-average-color';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobTypeByURL, isBlobURL } from '@wordpress/blob';\nimport { applyFilters } from '@wordpress/hooks';\n\nconst POSITION_CLASSNAMES = {\n\t'top left': 'is-position-top-left',\n\t'top center': 'is-position-top-center',\n\t'top right': 'is-position-top-right',\n\t'center left': 'is-position-center-left',\n\t'center center': 'is-position-center-center',\n\tcenter: 'is-position-center-center',\n\t'center right': 'is-position-center-right',\n\t'bottom left': 'is-position-bottom-left',\n\t'bottom center': 'is-position-bottom-center',\n\t'bottom right': 'is-position-bottom-right',\n};\n\nexport const IMAGE_BACKGROUND_TYPE = 'image';\nexport const VIDEO_BACKGROUND_TYPE = 'video';\nexport const COVER_MIN_HEIGHT = 50;\nexport const COVER_MAX_HEIGHT = 1000;\nexport const COVER_DEFAULT_HEIGHT = 300;\nexport const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\nexport const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\n\nexport function mediaPosition( { x, y } = DEFAULT_FOCAL_POINT ) {\n\treturn `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;\n}\n\nexport function dimRatioToClass( ratio ) {\n\treturn ratio === 50 || ! ratio === undefined\n\t\t? null\n\t\t: 'has-background-dim-' + 10 * Math.round( ratio / 10 );\n}\n\nexport function attributesFromMedia( setAttributes, dimRatio ) {\n\treturn ( media, isDark ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( { url: undefined, id: undefined, isDark } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tmedia.type = getBlobTypeByURL( media.url );\n\t\t}\n\n\t\tlet mediaType;\n\t\t// For media selections originated from a file upload.\n\t\tif ( media.media_type ) {\n\t\t\tif ( media.media_type === IMAGE_BACKGROUND_TYPE ) {\n\t\t\t\tmediaType = IMAGE_BACKGROUND_TYPE;\n\t\t\t} else {\n\t\t\t\t// only images and videos are accepted so if the media_type is not an image we can assume it is a video.\n\t\t\t\t// Videos contain the media type of 'file' in the object returned from the rest api.\n\t\t\t\tmediaType = VIDEO_BACKGROUND_TYPE;\n\t\t\t}\n\t\t} else {\n\t\t\t// For media selections originated from existing files in the media library.\n\t\t\tif (\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE &&\n\t\t\t\tmedia.type !== VIDEO_BACKGROUND_TYPE\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmediaType = media.type;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tisDark,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\turl: media.url,\n\t\t\tid: media.id,\n\t\t\talt: media?.alt,\n\t\t\tbackgroundType: mediaType,\n\t\t\tfocalPoint: undefined,\n\t\t\t...( mediaType === VIDEO_BACKGROUND_TYPE\n\t\t\t\t? { hasParallax: undefined }\n\t\t\t\t: {} ),\n\t\t} );\n\t};\n}\n\n/**\n * Checks of the contentPosition is the center (default) position.\n *\n * @param {string} contentPosition The current content position.\n * @return {boolean} Whether the contentPosition is center.\n */\nexport function isContentPositionCenter( contentPosition ) {\n\treturn (\n\t\t! contentPosition ||\n\t\tcontentPosition === 'center center' ||\n\t\tcontentPosition === 'center'\n\t);\n}\n\n/**\n * Retrieves the className for the current contentPosition.\n * The default position (center) will not have a className.\n *\n * @param {string} contentPosition The current content position.\n * @return {string} The className assigned to the contentPosition.\n */\nexport function getPositionClassName( contentPosition ) {\n\t/*\n\t * Only render a className if the contentPosition is not center (the default).\n\t */\n\tif ( isContentPositionCenter( contentPosition ) ) return '';\n\n\treturn POSITION_CLASSNAMES[ contentPosition ];\n}\n\n/**\n * Performs a Porter Duff composite source over operation on two rgba colors.\n *\n * @see https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators_srcover\n *\n * @param {import('colord').RgbaColor} source Source color.\n * @param {import('colord').RgbaColor} dest Destination color.\n * @return {import('colord').RgbaColor} Composite color.\n */\nfunction 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\nfunction retrieveFastAverageColor() {\n\tif ( ! retrieveFastAverageColor.fastAverageColor ) {\n\t\tretrieveFastAverageColor.fastAverageColor = new FastAverageColor();\n\t}\n\treturn retrieveFastAverageColor.fastAverageColor;\n}\n\n/**\n * This method evaluates if the cover block's background is dark or not and this boolean\n * can then be applied to the relevant attribute to help ensure that text is visible by default.\n * This needs to be recalculated in all of the following Cover block scenarios:\n * - When an overlay image is added, changed or removed\n * - When the featured image is selected as the overlay image, or removed from the overlay\n * - When the overlay color is changed\n * - When the overlay color is removed\n * - When the dimRatio is changed\n *\n * See the comments below for more details about which aspects take priority when\n * calculating the relative darkness of the Cover.\n *\n * @param {string} url\n * @param {number} dimRatio\n * @param {string} overlayColor\n * @return {Promise<boolean>} True if cover should be considered to be dark.\n */\nexport async function getCoverIsDark( url, dimRatio = 50, overlayColor ) {\n\tconst overlay = colord( overlayColor )\n\t\t.alpha( dimRatio / 100 )\n\t\t.toRgb();\n\n\tif ( url ) {\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 {\n\t\t\tvalue: [ r, g, b, a ],\n\t\t} = await retrieveFastAverageColor().getColorAsync( url, {\n\t\t\t// Previously the default color was white, but that changed\n\t\t\t// in v6.0.0 so it has to be manually set now.\n\t\t\tdefaultColor: [ 255, 255, 255, 255 ],\n\t\t\t// Errors that come up don't reject the promise, so error\n\t\t\t// logging has to be silenced with this option.\n\t\t\tsilent: process.env.NODE_ENV === 'production',\n\t\t\tcrossOrigin: imgCrossOrigin,\n\t\t} );\n\t\t// FAC uses 0-255 for alpha, but colord expects 0-1.\n\t\tconst media = { r, g, b, a: a / 255 };\n\t\tconst composite = compositeSourceOver( overlay, media );\n\t\treturn colord( composite ).isDark();\n\t}\n\n\t// Assume a white background because it isn't easy to get the actual\n\t// parent background color.\n\tconst background = { r: 255, g: 255, b: 255, a: 1 };\n\tconst composite = compositeSourceOver( overlay, background );\n\treturn colord( composite ).isDark();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,iBAAiB;AAC7D,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,MAAMC,mBAAmB,GAAG;EAC3B,UAAU,EAAE,sBAAsB;EAClC,YAAY,EAAE,wBAAwB;EACtC,WAAW,EAAE,uBAAuB;EACpC,aAAa,EAAE,yBAAyB;EACxC,eAAe,EAAE,2BAA2B;EAC5CC,MAAM,EAAE,2BAA2B;EACnC,cAAc,EAAE,0BAA0B;EAC1C,aAAa,EAAE,yBAAyB;EACxC,eAAe,EAAE,2BAA2B;EAC5C,cAAc,EAAE;AACjB,CAAC;AA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CAAEZ,CAAC,EAAEE,CAAC,EAAEC,CAAC,EAAEF,CAAC;IACpB,CAAC,GAAG,MAAMG,wBAAwB,CAAC,CAAC,CAACS,aAAa,CAAE5B,GAAG,EAAE;MACxD;MACA;MACA6B,YAAY,EAAE,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;MACpC;MACA;MACAC,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;MAC7CC,WAAW,EAAER;IACd,CAAE,CAAC;IACH;IACA,MAAM5B,KAAK,GAAG;MAAEiB,CAAC;MAAEE,CAAC;MAAEC,CAAC;MAAEF,CAAC,EAAEA,CAAC,GAAG;IAAI,CAAC;IACrC,MAAMmB,SAAS,GAAGvB,mBAAmB,CAAEW,OAAO,EAAEzB,KAAM,CAAC;IACvD,OAAOxB,MAAM,CAAE6D,SAAU,CAAC,CAACpC,MAAM,CAAC,CAAC;EACpC;;EAEA;EACA;EACA,MAAMqC,UAAU,GAAG;IAAErB,CAAC,EAAE,GAAG;IAAEE,CAAC,EAAE,GAAG;IAAEC,CAAC,EAAE,GAAG;IAAEF,CAAC,EAAE;EAAE,CAAC;EACnD,MAAMmB,SAAS,GAAGvB,mBAAmB,CAAEW,OAAO,EAAEa,UAAW,CAAC;EAC5D,OAAO9D,MAAM,CAAE6D,SAAU,CAAC,CAACpC,MAAM,CAAC,CAAC;AACpC"}
|
|
1
|
+
{"version":3,"names":["FastAverageColor","colord","getBlobTypeByURL","isBlobURL","applyFilters","POSITION_CLASSNAMES","center","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","COVER_MIN_HEIGHT","COVER_MAX_HEIGHT","COVER_DEFAULT_HEIGHT","DEFAULT_FOCAL_POINT","x","y","ALLOWED_MEDIA_TYPES","mediaPosition","Math","round","dimRatioToClass","ratio","undefined","attributesFromMedia","setAttributes","dimRatio","media","isDark","url","id","type","mediaType","media_type","alt","backgroundType","focalPoint","hasParallax","isContentPositionCenter","contentPosition","getPositionClassName","compositeSourceOver","source","dest","r","a","g","b","retrieveFastAverageColor","fastAverageColor","getCoverIsDark","overlayColor","overlay","alpha","toRgb","imgCrossOrigin","value","getColorAsync","defaultColor","silent","process","env","NODE_ENV","crossOrigin","composite","error","background"],"sources":["@wordpress/block-library/src/cover/shared.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { FastAverageColor } from 'fast-average-color';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobTypeByURL, isBlobURL } from '@wordpress/blob';\nimport { applyFilters } from '@wordpress/hooks';\n\nconst POSITION_CLASSNAMES = {\n\t'top left': 'is-position-top-left',\n\t'top center': 'is-position-top-center',\n\t'top right': 'is-position-top-right',\n\t'center left': 'is-position-center-left',\n\t'center center': 'is-position-center-center',\n\tcenter: 'is-position-center-center',\n\t'center right': 'is-position-center-right',\n\t'bottom left': 'is-position-bottom-left',\n\t'bottom center': 'is-position-bottom-center',\n\t'bottom right': 'is-position-bottom-right',\n};\n\nexport const IMAGE_BACKGROUND_TYPE = 'image';\nexport const VIDEO_BACKGROUND_TYPE = 'video';\nexport const COVER_MIN_HEIGHT = 50;\nexport const COVER_MAX_HEIGHT = 1000;\nexport const COVER_DEFAULT_HEIGHT = 300;\nexport const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\nexport const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\n\nexport function mediaPosition( { x, y } = DEFAULT_FOCAL_POINT ) {\n\treturn `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;\n}\n\nexport function dimRatioToClass( ratio ) {\n\treturn ratio === 50 || ! ratio === undefined\n\t\t? null\n\t\t: 'has-background-dim-' + 10 * Math.round( ratio / 10 );\n}\n\nexport function attributesFromMedia( setAttributes, dimRatio ) {\n\treturn ( media, isDark ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( { url: undefined, id: undefined, isDark } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tmedia.type = getBlobTypeByURL( media.url );\n\t\t}\n\n\t\tlet mediaType;\n\t\t// For media selections originated from a file upload.\n\t\tif ( media.media_type ) {\n\t\t\tif ( media.media_type === IMAGE_BACKGROUND_TYPE ) {\n\t\t\t\tmediaType = IMAGE_BACKGROUND_TYPE;\n\t\t\t} else {\n\t\t\t\t// only images and videos are accepted so if the media_type is not an image we can assume it is a video.\n\t\t\t\t// Videos contain the media type of 'file' in the object returned from the rest api.\n\t\t\t\tmediaType = VIDEO_BACKGROUND_TYPE;\n\t\t\t}\n\t\t} else {\n\t\t\t// For media selections originated from existing files in the media library.\n\t\t\tif (\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE &&\n\t\t\t\tmedia.type !== VIDEO_BACKGROUND_TYPE\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmediaType = media.type;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tisDark,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\turl: media.url,\n\t\t\tid: media.id,\n\t\t\talt: media?.alt,\n\t\t\tbackgroundType: mediaType,\n\t\t\tfocalPoint: undefined,\n\t\t\t...( mediaType === VIDEO_BACKGROUND_TYPE\n\t\t\t\t? { hasParallax: undefined }\n\t\t\t\t: {} ),\n\t\t} );\n\t};\n}\n\n/**\n * Checks of the contentPosition is the center (default) position.\n *\n * @param {string} contentPosition The current content position.\n * @return {boolean} Whether the contentPosition is center.\n */\nexport function isContentPositionCenter( contentPosition ) {\n\treturn (\n\t\t! contentPosition ||\n\t\tcontentPosition === 'center center' ||\n\t\tcontentPosition === 'center'\n\t);\n}\n\n/**\n * Retrieves the className for the current contentPosition.\n * The default position (center) will not have a className.\n *\n * @param {string} contentPosition The current content position.\n * @return {string} The className assigned to the contentPosition.\n */\nexport function getPositionClassName( contentPosition ) {\n\t/*\n\t * Only render a className if the contentPosition is not center (the default).\n\t */\n\tif ( isContentPositionCenter( contentPosition ) ) return '';\n\n\treturn POSITION_CLASSNAMES[ contentPosition ];\n}\n\n/**\n * Performs a Porter Duff composite source over operation on two rgba colors.\n *\n * @see https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators_srcover\n *\n * @param {import('colord').RgbaColor} source Source color.\n * @param {import('colord').RgbaColor} dest Destination color.\n * @return {import('colord').RgbaColor} Composite color.\n */\nfunction 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\nfunction retrieveFastAverageColor() {\n\tif ( ! retrieveFastAverageColor.fastAverageColor ) {\n\t\tretrieveFastAverageColor.fastAverageColor = new FastAverageColor();\n\t}\n\treturn retrieveFastAverageColor.fastAverageColor;\n}\n\n/**\n * This method evaluates if the cover block's background is dark or not and this boolean\n * can then be applied to the relevant attribute to help ensure that text is visible by default.\n * This needs to be recalculated in all of the following Cover block scenarios:\n * - When an overlay image is added, changed or removed\n * - When the featured image is selected as the overlay image, or removed from the overlay\n * - When the overlay color is changed\n * - When the overlay color is removed\n * - When the dimRatio is changed\n *\n * See the comments below for more details about which aspects take priority when\n * calculating the relative darkness of the Cover.\n *\n * @param {string} url\n * @param {number} dimRatio\n * @param {string} overlayColor\n * @return {Promise<boolean>} True if cover should be considered to be dark.\n */\nexport async function getCoverIsDark( url, dimRatio = 50, overlayColor ) {\n\tconst overlay = colord( overlayColor )\n\t\t.alpha( dimRatio / 100 )\n\t\t.toRgb();\n\n\tif ( url ) {\n\t\ttry {\n\t\t\tconst imgCrossOrigin = applyFilters(\n\t\t\t\t'media.crossOrigin',\n\t\t\t\tundefined,\n\t\t\t\turl\n\t\t\t);\n\t\t\tconst {\n\t\t\t\tvalue: [ r, g, b, a ],\n\t\t\t} = await retrieveFastAverageColor().getColorAsync( url, {\n\t\t\t\t// Previously the default color was white, but that changed\n\t\t\t\t// in v6.0.0 so it has to be manually set now.\n\t\t\t\tdefaultColor: [ 255, 255, 255, 255 ],\n\t\t\t\t// Errors that come up don't reject the promise, so error\n\t\t\t\t// logging has to be silenced with this option.\n\t\t\t\tsilent: process.env.NODE_ENV === 'production',\n\t\t\t\tcrossOrigin: imgCrossOrigin,\n\t\t\t} );\n\t\t\t// FAC uses 0-255 for alpha, but colord expects 0-1.\n\t\t\tconst media = { r, g, b, a: a / 255 };\n\t\t\tconst composite = compositeSourceOver( overlay, media );\n\t\t\treturn colord( composite ).isDark();\n\t\t} catch ( error ) {\n\t\t\t// If there's an error, just assume the image is dark.\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Assume a white background because it isn't easy to get the actual\n\t// parent background color.\n\tconst background = { r: 255, g: 255, b: 255, a: 1 };\n\tconst composite = compositeSourceOver( overlay, background );\n\treturn colord( composite ).isDark();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,iBAAiB;AAC7D,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,MAAMC,mBAAmB,GAAG;EAC3B,UAAU,EAAE,sBAAsB;EAClC,YAAY,EAAE,wBAAwB;EACtC,WAAW,EAAE,uBAAuB;EACpC,aAAa,EAAE,yBAAyB;EACxC,eAAe,EAAE,2BAA2B;EAC5CC,MAAM,EAAE,2BAA2B;EACnC,cAAc,EAAE,0BAA0B;EAC1C,aAAa,EAAE,yBAAyB;EACxC,eAAe,EAAE,2BAA2B;EAC5C,cAAc,EAAE;AACjB,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAG,OAAO;AAC5C,OAAO,MAAMC,qBAAqB,GAAG,OAAO;AAC5C,OAAO,MAAMC,gBAAgB,GAAG,EAAE;AAClC,OAAO,M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GAAG,EAAE;QACxD;QACA;QACA6B,YAAY,EAAE,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;QACpC;QACA;QACAC,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;QAC7CC,WAAW,EAAER;MACd,CAAE,CAAC;MACH;MACA,MAAM5B,KAAK,GAAG;QAAEiB,CAAC;QAAEE,CAAC;QAAEC,CAAC;QAAEF,CAAC,EAAEA,CAAC,GAAG;MAAI,CAAC;MACrC,MAAMmB,SAAS,GAAGvB,mBAAmB,CAAEW,OAAO,EAAEzB,KAAM,CAAC;MACvD,OAAOxB,MAAM,CAAE6D,SAAU,CAAC,CAACpC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,OAAQqC,KAAK,EAAG;MACjB;MACA,OAAO,IAAI;IACZ;EACD;;EAEA;EACA;EACA,MAAMC,UAAU,GAAG;IAAEtB,CAAC,EAAE,GAAG;IAAEE,CAAC,EAAE,GAAG;IAAEC,CAAC,EAAE,GAAG;IAAEF,CAAC,EAAE;EAAE,CAAC;EACnD,MAAMmB,SAAS,GAAGvB,mBAAmB,CAAEW,OAAO,EAAEc,UAAW,CAAC;EAC5D,OAAO/D,MAAM,CAAE6D,SAAU,CAAC,CAACpC,MAAM,CAAC,CAAC;AACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","LinkSettingsNavigation","FooterMessageLink","isURL","useDispatch","store","noticesStore","useCallback","useEffect","useRef","useState","EmbedLinkSettings","autoFocus","value","label","isVisible","onClose","onSubmit","withBottomSheet","url","inputURL","setInputURL","createErrorNotice","linkSettingsOptions","placeholder","autoFill","footer","createElement","href","separatorType","onDismiss","current","performOnCloseOperations","onSetAttributes","attributes","setAttributes","options","
|
|
1
|
+
{"version":3,"names":["__","sprintf","LinkSettingsNavigation","FooterMessageLink","isURL","useDispatch","store","noticesStore","useCallback","useEffect","useRef","useState","EmbedLinkSettings","autoFocus","value","label","isVisible","onClose","onSubmit","withBottomSheet","url","inputURL","setInputURL","createErrorNotice","linkSettingsOptions","placeholder","autoFill","footer","createElement","href","separatorType","onDismiss","current","performOnCloseOperations","onSetAttributes","attributes","setAttributes","options","showIcon"],"sources":["@wordpress/block-library/src/embed/embed-link-settings.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tLinkSettingsNavigation,\n\tFooterMessageLink,\n} from '@wordpress/components';\nimport { isURL } from '@wordpress/url';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\nconst EmbedLinkSettings = ( {\n\tautoFocus,\n\tvalue,\n\tlabel,\n\tisVisible,\n\tonClose,\n\tonSubmit,\n\twithBottomSheet,\n} ) => {\n\tconst url = useRef( value );\n\tconst [ inputURL, setInputURL ] = useState( value );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tconst linkSettingsOptions = {\n\t\turl: {\n\t\t\tlabel: sprintf(\n\t\t\t\t// translators: %s: embed block variant's label e.g: \"Twitter\".\n\t\t\t\t__( '%s link' ),\n\t\t\t\tlabel\n\t\t\t),\n\t\t\tplaceholder: __( 'Add link' ),\n\t\t\tautoFocus,\n\t\t\tautoFill: true,\n\t\t},\n\t\tfooter: {\n\t\t\tlabel: (\n\t\t\t\t<FooterMessageLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/documentation/article/embeds/'\n\t\t\t\t\t) }\n\t\t\t\t\tvalue={ __( 'Learn more about embeds' ) }\n\t\t\t\t/>\n\t\t\t),\n\t\t\tseparatorType: 'topFullWidth',\n\t\t},\n\t};\n\n\tconst onDismiss = useCallback( () => {\n\t\tif ( ! isURL( url.current ) && url.current !== '' ) {\n\t\t\tcreateErrorNotice( __( 'Invalid URL. Please enter a valid URL.' ) );\n\t\t\t// If the URL was already defined, we submit it to stop showing the embed placeholder.\n\t\t\tonSubmit( value );\n\t\t\treturn;\n\t\t}\n\t\tonSubmit( url.current );\n\t}, [ onSubmit, value ] );\n\n\tuseEffect( () => {\n\t\turl.current = value;\n\t\tsetInputURL( value );\n\t}, [ value ] );\n\n\t/**\n\t * If the Embed Bottom Sheet component does not utilize a bottom sheet then the onDismiss action is not\n\t * called. Here we are wiring the onDismiss to the onClose callback that gets triggered when input is submitted.\n\t */\n\tconst performOnCloseOperations = useCallback( () => {\n\t\tif ( onClose ) {\n\t\t\tonClose();\n\t\t}\n\n\t\tif ( ! withBottomSheet ) {\n\t\t\tonDismiss();\n\t\t}\n\t}, [ onClose ] );\n\n\tconst onSetAttributes = useCallback( ( attributes ) => {\n\t\turl.current = attributes.url;\n\t\tsetInputURL( attributes.url );\n\t}, [] );\n\n\treturn (\n\t\t<LinkSettingsNavigation\n\t\t\tisVisible={ isVisible }\n\t\t\turl={ inputURL }\n\t\t\tonClose={ performOnCloseOperations }\n\t\t\tonDismiss={ onDismiss }\n\t\t\tsetAttributes={ onSetAttributes }\n\t\t\toptions={ linkSettingsOptions }\n\t\t\twithBottomSheet={ withBottomSheet }\n\t\t\tshowIcon\n\t\t/>\n\t);\n};\n\nexport default EmbedLinkSettings;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,sBAAsB,EACtBC,iBAAiB,QACX,uBAAuB;AAC9B,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAE7E,MAAMC,iBAAiB,GAAGA,CAAE;EAC3BC,SAAS;EACTC,KAAK;EACLC,KAAK;EACLC,SAAS;EACTC,OAAO;EACPC,QAAQ;EACRC;AACD,CAAC,KAAM;EACN,MAAMC,GAAG,GAAGV,MA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AAe,EAAG;MACxBY,SAAS,CAAC,CAAC;IACZ;EACD,CAAC,EAAE,CAAEd,OAAO,CAAG,CAAC;EAEhB,MAAMiB,eAAe,GAAG1B,WAAW,CAAI2B,UAAU,IAAM;IACtDf,GAAG,CAACY,OAAO,GAAGG,UAAU,CAACf,GAAG;IAC5BE,WAAW,CAAEa,UAAU,CAACf,GAAI,CAAC;EAC9B,CAAC,EAAE,EAAG,CAAC;EAEP,OACCQ,aAAA,CAAC1B,sBAAsB;IACtBc,SAAS,EAAGA,SAAW;IACvBI,GAAG,EAAGC,QAAU;IAChBJ,OAAO,EAAGgB,wBAA0B;IACpCF,SAAS,EAAGA,SAAW;IACvBK,aAAa,EAAGF,eAAiB;IACjCG,OAAO,EAAGb,mBAAqB;IAC/BL,eAAe,EAAGA,eAAiB;IACnCmB,QAAQ;EAAA,CACR,CAAC;AAEJ,CAAC;AAED,eAAe1B,iBAAiB"}
|
|
@@ -83,7 +83,7 @@ function Placeholder({
|
|
|
83
83
|
});
|
|
84
84
|
return createElement("div", {
|
|
85
85
|
...blockProps
|
|
86
|
-
}, createElement("p", null, __('This is the
|
|
86
|
+
}, createElement("p", null, __('This is the Content block, it will display all the blocks in any single post or page.')), createElement("p", null, __('That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.')), createElement("p", null, __('If there are any Custom Post Types registered at your site, the Content block can display the contents of those entries as well.')));
|
|
87
87
|
}
|
|
88
88
|
function RecursionError() {
|
|
89
89
|
const blockProps = useBlockProps();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useBlockProps","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","Warning","useEntityProp","useEntityBlockEditor","store","coreStore","useSelect","useCanEditEntity","ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","createElement","dangerouslySetInnerHTML","__html","rendered","EditableContent","context","blocks","onInput","onChange","id","entityRecord","select","getEntityRecord","hasInnerBlocks","raw","length","initialInnerBlocks","props","className","value","template","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","layoutClassNames","RecursionError","PostContentEdit","attributes","__unstableLayoutClassNames","contextPostId","contextPostType","layout","hasAlreadyRendered","uniqueId"],"sources":["@wordpress/block-library/src/post-content/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tWarning,\n} from '@wordpress/block-editor';\nimport {\n\tuseEntityProp,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { context = {} } ) {\n\tconst { postType, postId } = context;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst entityRecord = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst hasInnerBlocks = !! entityRecord?.content?.raw || blocks?.length;\n\n\tconst initialInnerBlocks = [ [ 'core/paragraph' ] ];\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplate: ! hasInnerBlocks ? initialInnerBlocks : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tif ( userCanEdit === undefined ) {\n\t\treturn null;\n\t}\n\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder( { layoutClassNames } ) {\n\tconst blockProps = useBlockProps( { className: layoutClassNames } );\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the
|
|
1
|
+
{"version":3,"names":["__","useBlockProps","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","Warning","useEntityProp","useEntityBlockEditor","store","coreStore","useSelect","useCanEditEntity","ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","createElement","dangerouslySetInnerHTML","__html","rendered","EditableContent","context","blocks","onInput","onChange","id","entityRecord","select","getEntityRecord","hasInnerBlocks","raw","length","initialInnerBlocks","props","className","value","template","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","layoutClassNames","RecursionError","PostContentEdit","attributes","__unstableLayoutClassNames","contextPostId","contextPostType","layout","hasAlreadyRendered","uniqueId"],"sources":["@wordpress/block-library/src/post-content/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tWarning,\n} from '@wordpress/block-editor';\nimport {\n\tuseEntityProp,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { context = {} } ) {\n\tconst { postType, postId } = context;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst entityRecord = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst hasInnerBlocks = !! entityRecord?.content?.raw || blocks?.length;\n\n\tconst initialInnerBlocks = [ [ 'core/paragraph' ] ];\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplate: ! hasInnerBlocks ? initialInnerBlocks : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tif ( userCanEdit === undefined ) {\n\t\treturn null;\n\t}\n\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder( { layoutClassNames } ) {\n\tconst blockProps = useBlockProps( { className: layoutClassNames } );\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the Content block, it will display all the blocks in any single post or page.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'If there are any Custom Post Types registered at your site, the Content block can display the contents of those entries as well.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n\nfunction RecursionError() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t</div>\n\t);\n}\n\nexport default function PostContentEdit( {\n\tcontext,\n\tattributes,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst { postId: contextPostId, postType: contextPostType } = context;\n\tconst { layout = {} } = attributes;\n\tconst hasAlreadyRendered = useHasRecursion( contextPostId );\n\n\tif ( contextPostId && contextPostType && hasAlreadyRendered ) {\n\t\treturn <RecursionError />;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ contextPostId }>\n\t\t\t{ contextPostId && contextPostType ? (\n\t\t\t\t<Content context={ context } layout={ layout } />\n\t\t\t) : (\n\t\t\t\t<Placeholder layoutClassNames={ layoutClassNames } />\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,aAAa,EACbC,mBAAmB,EACnBC,+BAA+B,IAAIC,iBAAiB,EACpDC,6BAA6B,IAAIC,eAAe,EAChDC,OAAO,QACD,yBAAyB;AAChC,SACCC,aAAa,EACbC,oBAAoB,EACpBC,KAAK,IAAIC,SAAS,QACZ,sBAAsB;AAC7B,SAASC,SAAS,QAAQ,iBAAiB;AAC3C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,gBAAgB;AAEjD,SAASC,eAAeA,CAAE;EAAEC,WAAW;EAAEC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAC7D,MAAM,IAAMC,OAAO,CAAE,GAAGV,aAAa,CACpC,UAAU,EACVQ,QAAQ,EACR,SAAS,EACTC,MACD,CAAC;EACD,MAAME,UAAU,GAAGlB,aAAa,CAAC,CAAC;EAClC,OAAOiB,OAAO,EAAEE,SAAS,IAAI,CAAEL,WAAW,GACzCM,aAAA;IAAA,GAAUF;EAAU,GACnBE,aAAA,CAACd,OAAO,QAAGP,EAAE,CAAE,qCAAsC,CAAY,CAC7D,CAAC,GAENqB,aAAA;IAAA,GACMF,UAAU;IACfG,uBAAuB,EAAG;MAAEC,MAAM,EAAEL,OAAO,EAAEM;IAAS;EAAG,CACpD,CACN;AACF;AAEA,SAASC,eAAeA,CAAE;EAAEC,OAAO,GAAG,CAAC;AAAE,CAAC,EAAG;EAC5C,MAAM;IAAEV,QAAQ;IAAEC;EAAO,CAAC,GAAGS,OAAO;EAEpC,MAAM,CAAEC,MAAM,EAAEC,OAA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O,EAAGA,OAAS;IAAC+B,MAAM,EAAGA;EAAQ,CAAE,CAAC,GAEjDpC,aAAA,CAAC4B,WAAW;IAACC,gBAAgB,EAAGA;EAAkB,CAAE,CAEnC,CAAC;AAEtB"}
|
|
@@ -16,7 +16,7 @@ const metadata = {
|
|
|
16
16
|
parent: ["core/query"],
|
|
17
17
|
description: "Contains the block elements used to render a post, like the title, date, featured image, content or excerpt, and more.",
|
|
18
18
|
textdomain: "default",
|
|
19
|
-
usesContext: ["queryId", "query", "queryContext", "displayLayout", "templateSlug", "previewPostType"],
|
|
19
|
+
usesContext: ["queryId", "query", "queryContext", "displayLayout", "templateSlug", "previewPostType", "enhancedPagination"],
|
|
20
20
|
supports: {
|
|
21
21
|
reusable: false,
|
|
22
22
|
html: false,
|
|
@@ -6,7 +6,8 @@ import { PanelBody, TextControl, SelectControl, RangeControl, ToggleControl, Not
|
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { InspectorControls, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
8
8
|
import { debounce } from '@wordpress/compose';
|
|
9
|
-
import { useEffect, useState, useCallback } from '@wordpress/element';
|
|
9
|
+
import { useEffect, useState, useCallback, useRef } from '@wordpress/element';
|
|
10
|
+
import { speak } from '@wordpress/a11y';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
@@ -26,11 +27,13 @@ export default function QueryInspectorControls(props) {
|
|
|
26
27
|
const {
|
|
27
28
|
attributes,
|
|
28
29
|
setQuery,
|
|
29
|
-
setDisplayLayout
|
|
30
|
+
setDisplayLayout,
|
|
31
|
+
setAttributes
|
|
30
32
|
} = props;
|
|
31
33
|
const {
|
|
32
34
|
query,
|
|
33
|
-
displayLayout
|
|
35
|
+
displayLayout,
|
|
36
|
+
enhancedPagination
|
|
34
37
|
} = attributes;
|
|
35
38
|
const {
|
|
36
39
|
order,
|
|
@@ -96,6 +99,14 @@ export default function QueryInspectorControls(props) {
|
|
|
96
99
|
const showAuthorControl = isControlAllowed(allowedControls, 'author');
|
|
97
100
|
const showSearchControl = isControlAllowed(allowedControls, 'search');
|
|
98
101
|
const showParentControl = isControlAllowed(allowedControls, 'parents') && isPostTypeHierarchical;
|
|
102
|
+
const enhancedPaginationNotice = __('Enhanced Pagination might cause interactive blocks within the Post Template to stop working. Disable it if you experience any issues.');
|
|
103
|
+
const isFirstRender = useRef(true); // Don't speak on first render.
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!isFirstRender.current && enhancedPagination) {
|
|
106
|
+
speak(enhancedPaginationNotice);
|
|
107
|
+
}
|
|
108
|
+
isFirstRender.current = false;
|
|
109
|
+
}, [enhancedPagination, enhancedPaginationNotice]);
|
|
99
110
|
const showFiltersPanel = showTaxControl || showAuthorControl || showSearchControl || showParentControl;
|
|
100
111
|
return createElement(Fragment, null, createElement(BlockInfo, null, createElement(CreateNewPostLink, {
|
|
101
112
|
...props
|
|
@@ -186,6 +197,20 @@ export default function QueryInspectorControls(props) {
|
|
|
186
197
|
parents: parents,
|
|
187
198
|
postType: postType,
|
|
188
199
|
onChange: setQuery
|
|
189
|
-
}))))
|
|
200
|
+
})))), createElement(InspectorControls, null, createElement(PanelBody, {
|
|
201
|
+
title: __('User Experience'),
|
|
202
|
+
initialOpen: false
|
|
203
|
+
}, createElement(ToggleControl, {
|
|
204
|
+
label: __('Enhanced pagination'),
|
|
205
|
+
help: __("Don't refresh the page when paginating to another page."),
|
|
206
|
+
checked: !!enhancedPagination,
|
|
207
|
+
onChange: value => setAttributes({
|
|
208
|
+
enhancedPagination: !!value
|
|
209
|
+
})
|
|
210
|
+
}), enhancedPagination && createElement("div", null, createElement(Notice, {
|
|
211
|
+
spokenMessage: null,
|
|
212
|
+
status: "warning",
|
|
213
|
+
isDismissible: false
|
|
214
|
+
}, enhancedPaginationNotice)))));
|
|
190
215
|
}
|
|
191
216
|
//# sourceMappingURL=index.js.map
|