@wordpress/block-library 8.25.0 → 8.25.1-next.79a6196f.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/LICENSE.md +1 -1
- package/build/audio/edit.js +10 -12
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +81 -34
- package/build/block/edit.js.map +1 -1
- package/build/comments-title/deprecated.js +1 -1
- package/build/comments-title/index.js +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit.native.js +1 -0
- package/build/cover/edit.native.js.map +1 -1
- package/build/embed/util.js +4 -4
- package/build/embed/util.js.map +1 -1
- package/build/file/edit.js +19 -27
- package/build/file/edit.js.map +1 -1
- package/build/gallery/edit.js +36 -17
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +3 -2
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/index.js +4 -0
- package/build/gallery/index.js.map +1 -1
- package/build/gallery/transforms.js +4 -68
- package/build/gallery/transforms.js.map +1 -1
- package/build/group/index.js +5 -1
- package/build/group/index.js.map +1 -1
- package/build/image/deprecated.js +11 -0
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.native.js +3 -0
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +22 -21
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +7 -1
- package/build/image/view.js.map +1 -1
- package/build/list/edit.js +10 -15
- package/build/list/edit.js.map +1 -1
- package/build/list-item/edit.js +17 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/use-enter.js +5 -3
- package/build/list-item/hooks/use-enter.js.map +1 -1
- package/build/list-item/hooks/use-enter.native.js +4 -3
- package/build/list-item/hooks/use-enter.native.js.map +1 -1
- package/build/list-item/hooks/use-indent-list-item.js +2 -3
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +1 -1
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +3 -17
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +8 -4
- package/build/list-item/hooks/use-space.js.map +1 -1
- package/build/media-text/media-container.native.js +3 -0
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/constants.js +3 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +4 -0
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/view.js +25 -1
- package/build/navigation/view.js.map +1 -1
- package/build/paragraph/index.js +0 -1
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +0 -1
- package/build/paragraph/transforms.js.map +1 -1
- package/build/pattern/edit.js +24 -2
- package/build/pattern/edit.js.map +1 -1
- package/build/pattern/recursion-detector.js +147 -0
- package/build/pattern/recursion-detector.js.map +1 -0
- package/build/post-featured-image/edit.js +19 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +4 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -1
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/search/edit.js +3 -5
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +0 -4
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +7 -6
- package/build/site-logo/edit.js.map +1 -1
- package/build/spacer/edit.native.js +2 -2
- package/build/spacer/edit.native.js.map +1 -1
- package/build/tag-cloud/edit.js +5 -9
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/utils/constants.js +16 -0
- package/build/utils/constants.js.map +1 -0
- package/build/video/edit.js +11 -8
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +10 -12
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +85 -38
- package/build-module/block/edit.js.map +1 -1
- package/build-module/comments-title/deprecated.js +1 -1
- package/build-module/comments-title/index.js +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit.native.js +1 -0
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/embed/util.js +4 -4
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/edit.js +19 -27
- package/build-module/file/edit.js.map +1 -1
- package/build-module/gallery/edit.js +36 -17
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +3 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/index.js +4 -0
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/gallery/transforms.js +4 -68
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/group/index.js +5 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/deprecated.js +11 -0
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.native.js +3 -0
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +17 -16
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +7 -1
- package/build-module/image/view.js.map +1 -1
- package/build-module/list/edit.js +10 -15
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list-item/edit.js +18 -3
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-enter.js +5 -3
- package/build-module/list-item/hooks/use-enter.js.map +1 -1
- package/build-module/list-item/hooks/use-enter.native.js +4 -3
- package/build-module/list-item/hooks/use-enter.native.js.map +1 -1
- package/build-module/list-item/hooks/use-indent-list-item.js +2 -3
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +1 -1
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +3 -17
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +8 -4
- package/build-module/list-item/hooks/use-space.js.map +1 -1
- package/build-module/media-text/media-container.native.js +3 -0
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/constants.js +1 -0
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +5 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/view.js +25 -1
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/paragraph/index.js +0 -1
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +0 -1
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/pattern/edit.js +26 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/pattern/recursion-detector.js +139 -0
- package/build-module/pattern/recursion-detector.js.map +1 -0
- package/build-module/post-featured-image/edit.js +19 -2
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +4 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +3 -1
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/search/edit.js +3 -5
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +0 -4
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +7 -6
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/spacer/edit.native.js +2 -2
- package/build-module/spacer/edit.native.js.map +1 -1
- package/build-module/tag-cloud/edit.js +6 -10
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/utils/constants.js +9 -0
- package/build-module/utils/constants.js.map +1 -0
- package/build-module/video/edit.js +11 -8
- package/build-module/video/edit.js.map +1 -1
- package/build-style/button/editor-rtl.css +0 -37
- package/build-style/button/editor.css +0 -37
- package/build-style/button/style-rtl.css +6 -6
- package/build-style/button/style.css +6 -6
- package/build-style/editor-rtl.css +2 -44
- package/build-style/editor.css +2 -44
- package/build-style/navigation/editor-rtl.css +2 -4
- package/build-style/navigation/editor.css +2 -4
- package/build-style/navigation/style-rtl.css +14 -18
- package/build-style/navigation/style.css +14 -18
- package/build-style/search/style-rtl.css +26 -27
- package/build-style/search/style.css +26 -27
- package/build-style/style-rtl.css +46 -51
- package/build-style/style.css +46 -51
- package/build-style/table/editor-rtl.css +0 -3
- package/build-style/table/editor.css +0 -3
- package/package.json +32 -32
- package/src/audio/edit.js +19 -19
- package/src/audio/test/__snapshots__/edit.native.js.snap +12 -0
- package/src/audio/test/edit.native.js +29 -0
- package/src/block/edit.js +120 -66
- package/src/button/editor.scss +0 -43
- package/src/button/style.scss +6 -6
- package/src/buttons/test/__snapshots__/edit.native.js.snap +6 -0
- package/src/buttons/test/edit.native.js +49 -0
- package/src/comments-title/block.json +1 -1
- package/src/cover/edit/inspector-controls.js +1 -1
- package/src/cover/edit.native.js +1 -0
- package/src/embed/util.js +2 -2
- package/src/file/edit.js +17 -24
- package/src/gallery/block.json +4 -0
- package/src/gallery/edit.js +69 -42
- package/src/gallery/gallery.js +4 -1
- package/src/gallery/index.php +15 -0
- package/src/gallery/transforms.js +2 -55
- package/src/group/block.json +5 -1
- package/src/image/deprecated.js +8 -0
- package/src/image/edit.native.js +3 -0
- package/src/image/image.js +54 -35
- package/src/image/index.php +1 -6
- package/src/image/view.js +5 -2
- package/src/list/edit.js +27 -35
- package/src/list-item/edit.js +18 -2
- package/src/list-item/hooks/use-enter.js +63 -62
- package/src/list-item/hooks/use-enter.native.js +9 -5
- package/src/list-item/hooks/use-indent-list-item.js +43 -53
- package/src/list-item/hooks/use-merge.js +1 -1
- package/src/list-item/hooks/use-outdent-list-item.js +50 -69
- package/src/list-item/hooks/use-space.js +7 -4
- package/src/media-text/media-container.native.js +3 -1
- package/src/navigation/constants.js +2 -0
- package/src/navigation/edit/index.js +11 -1
- package/src/navigation/editor.scss +1 -1
- package/src/navigation/style.scss +18 -16
- package/src/navigation/view.js +29 -3
- package/src/paragraph/block.json +0 -1
- package/src/paragraph/test/__snapshots__/edit.native.js.snap +12 -0
- package/src/paragraph/test/edit.native.js +114 -0
- package/src/pattern/edit.js +35 -3
- package/src/pattern/index.php +16 -0
- package/src/pattern/recursion-detector.js +145 -0
- package/src/pattern/test/index.js +74 -0
- package/src/post-featured-image/block.json +4 -0
- package/src/post-featured-image/edit.js +32 -1
- package/src/post-featured-image/index.php +31 -0
- package/src/query/edit/inspector-controls/index.js +2 -0
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/search/block.json +0 -4
- package/src/search/edit.js +2 -8
- package/src/search/index.php +3 -7
- package/src/search/style.scss +27 -29
- package/src/site-logo/edit.js +3 -4
- package/src/social-link/index.php +1 -1
- package/src/spacer/edit.native.js +4 -2
- package/src/table/editor.scss +0 -3
- package/src/tag-cloud/edit.js +7 -7
- package/src/template-part/index.php +6 -0
- package/src/utils/constants.js +8 -0
- package/src/video/edit.js +29 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_reactNativeVideo","_interopRequireDefault","_dedupe","_reactNativeBridge","_i18n","_components","_blockEditor","_compose","_data","_element","_icons","_url","_editPost","_style","_shared","_controls","_useCoverIsDark","INNER_BLOCKS_TEMPLATE","align","placeholder","__","useIsScreenReaderEnabled","isScreenReaderEnabled","setIsScreenReaderEnabled","useState","useEffect","mounted","changeListener","AccessibilityInfo","addEventListener","enabled","then","screenReaderEnabled","remove","Cover","attributes","getStylesFromColorScheme","isParentSelected","onFocus","setAttributes","openGeneralSidebar","closeSettingsBottomSheet","isSelected","selectBlock","blockWidth","hasInnerBlocks","backgroundType","dimRatio","focalPoint","minHeight","url","id","style","customOverlayColor","minHeightUnit","allowedBlocks","templateLock","customGradient","gradient","overlayColor","isDark","mediaUploadSync","convertedMinHeight","useConvertUnitToMobile","COVER_DEFAULT_HEIGHT","isImage","MEDIA_TYPE_IMAGE","THEME_COLORS_COUNT","colorsDefault","useMobileGlobalStylesColors","coverDefaultPalette","useMemo","colors","slice","gradients","gradientValue","getGradientValueBySlug","overlayColorValue","getColorObjectByAttributeValues","hasBackground","color","background","hasOnlyColorBackground","isCustomColorPickerShowing","setCustomColorPickerShowing","openMediaOptionsRef","useRef","isUploadInProgress","setIsUploadInProgress","didUploadFail","setDidUploadFail","getProtocol","shouldShowFailure","onSelectMedia","media","mediaAttributes","attributesFromMedia","undefined","useFeaturedImage","onMediaPressed","requestImageUploadCancelDialog","requestImageFailedRetryDialog","requestImageFullscreenPreview","isVideoLoading","setIsVideoLoading","onVideoLoadStart","onVideoLoad","onClearMedia","useCallback","hasParallax","setColor","_colorValue$slug","_ref","colorValue","getColorObjectByColorValue","slug","openColorPicker","__unstableMarkNextChangeAsNotPersistent","useDispatch","blockEditorStore","isCoverDark","useCoverIsDark","childrenStyles","styles","defaultColor","defaultColorLightMode","className","includes","classnames","backgroundColor","backgroundSolid","backgroundSolidDark","overlayStyles","overlay","opacity","overlaySelected","placeholderIconStyle","icon","iconDark","placeholderIcon","_react","createElement","Icon","toolbarControls","open","BlockControls","group","ToolbarButton","title","replace","onClick","accessibilityHint","Platform","OS","addMediaButton","TouchableWithoutFeedback","accessibilityLabel","accessibilityRole","onPress","current","View","selectImageContainer","selectImage","size","image","selectImageIcon","onBottomSheetClosed","InteractionManager","runAfterInteractions","selectedColorText","selectedColorTextDark","bottomLabelText","Text","toUpperCase","colorPickerControls","InspectorControls","BottomSheetConsumer","shouldEnableBottomSheetScroll","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","onHandleHardwareButtonPress","isBottomSheetContentScrolling","ColorPicker","onNavigationBack","renderContent","getMediaOptions","Fragment","renderBackground","accessible","disabled","VIDEO_BACKGROUND_TYPE","MediaUploadProgress","mediaId","onUpdateMediaProgress","onFinishMediaUploadWithSuccess","mediaServerId","mediaUrl","onFinishMediaUploadWithFailure","onMediaUploadStateReset","IMAGE_BACKGROUND_TYPE","imageContainer","Image","editButton","IMAGE_DEFAULT_FOCAL_POINT","isUploadFailed","onSelectMediaUploadOption","openMediaOptions","width","default","muted","disableFocus","repeat","resizeMode","source","uri","onLoad","onLoadStart","MediaPlaceholder","height","mediaPlaceholderEmptyStateContainer","hideContent","labels","onSelect","allowedTypes","ALLOWED_MEDIA_TYPES","colorPaletteWrapper","pointerEvents","ColorPalette","customColorIndicatorStyles","paletteColorIndicator","customIndicatorWrapperStyles","paletteCustomIndicatorWrapper","onCustomPress","defaultSettings","shouldShowCustomLabel","shouldShowCustomVerticalSeparator","backgroundContainer","content","InnerBlocks","template","templateInsertUpdatesSelection","overlayContainer","Gradient","MediaUpload","isReplacingMedia","render","imageEditButton","ImageEditingButton","pickerOptions","destructiveButton","label","separated","value","uploadFailedContainer","uploadFailed","warning","uploadFailedIcon","_default","compose","withSelect","select","clientId","getSelectedBlockClientId","getBlock","selectedBlockClientId","innerBlocks","length","withDispatch","dispatch","editPostStore","closeGeneralSidebar","withPreferredColorScheme","exports"],"sources":["@wordpress/block-library/src/cover/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tTouchableWithoutFeedback,\n\tInteractionManager,\n\tAccessibilityInfo,\n\tText,\n\tPlatform,\n} from 'react-native';\nimport Video from 'react-native-video';\nimport classnames from 'classnames/dedupe';\n\n/**\n * WordPress dependencies\n */\nimport {\n\trequestImageFailedRetryDialog,\n\trequestImageUploadCancelDialog,\n\trequestImageFullscreenPreview,\n\tmediaUploadSync,\n} from '@wordpress/react-native-bridge';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tIcon,\n\tImage,\n\tImageEditingButton,\n\tIMAGE_DEFAULT_FOCAL_POINT,\n\tToolbarButton,\n\tGradient,\n\tColorPalette,\n\tColorPicker,\n\tBottomSheetConsumer,\n\tuseConvertUnitToMobile,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tInspectorControls,\n\tMEDIA_TYPE_IMAGE,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tgetGradientValueBySlug,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { useDispatch, withSelect, withDispatch } from '@wordpress/data';\nimport {\n\tuseEffect,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { cover as icon, replace, image, warning } from '@wordpress/icons';\nimport { getProtocol } from '@wordpress/url';\n// eslint-disable-next-line no-restricted-imports\nimport { store as editPostStore } from '@wordpress/edit-post';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport {\n\tattributesFromMedia,\n\tALLOWED_MEDIA_TYPES,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tCOVER_DEFAULT_HEIGHT,\n} from './shared';\nimport Controls from './controls';\nimport useCoverIsDark from './use-cover-is-dark';\n\n/**\n * Constants\n */\nconst INNER_BLOCKS_TEMPLATE = [\n\t[\n\t\t'core/paragraph',\n\t\t{\n\t\t\talign: 'center',\n\t\t\tplaceholder: __( 'Write title…' ),\n\t\t},\n\t],\n];\n\nfunction useIsScreenReaderEnabled() {\n\tconst [ isScreenReaderEnabled, setIsScreenReaderEnabled ] =\n\t\tuseState( false );\n\n\tuseEffect( () => {\n\t\tlet mounted = true;\n\n\t\tconst changeListener = AccessibilityInfo.addEventListener(\n\t\t\t'screenReaderChanged',\n\t\t\t( enabled ) => setIsScreenReaderEnabled( enabled )\n\t\t);\n\n\t\tAccessibilityInfo.isScreenReaderEnabled().then(\n\t\t\t( screenReaderEnabled ) => {\n\t\t\t\tif ( mounted && screenReaderEnabled ) {\n\t\t\t\t\tsetIsScreenReaderEnabled( screenReaderEnabled );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\n\t\t\tchangeListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn isScreenReaderEnabled;\n}\n\nconst Cover = ( {\n\tattributes,\n\tgetStylesFromColorScheme,\n\tisParentSelected,\n\tonFocus,\n\tsetAttributes,\n\topenGeneralSidebar,\n\tcloseSettingsBottomSheet,\n\tisSelected,\n\tselectBlock,\n\tblockWidth,\n\thasInnerBlocks,\n} ) => {\n\tconst {\n\t\tbackgroundType,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\tminHeight,\n\t\turl,\n\t\tid,\n\t\tstyle,\n\t\tcustomOverlayColor,\n\t\tminHeightUnit = 'px',\n\t\tallowedBlocks,\n\t\ttemplateLock,\n\t\tcustomGradient,\n\t\tgradient,\n\t\toverlayColor,\n\t\tisDark,\n\t} = attributes;\n\tconst isScreenReaderEnabled = useIsScreenReaderEnabled();\n\n\tuseEffect( () => {\n\t\t// Sync with local media store.\n\t\tmediaUploadSync();\n\t}, [] );\n\n\tconst convertedMinHeight = useConvertUnitToMobile(\n\t\tminHeight || COVER_DEFAULT_HEIGHT,\n\t\tminHeightUnit\n\t);\n\n\tconst isImage = backgroundType === MEDIA_TYPE_IMAGE;\n\n\tconst THEME_COLORS_COUNT = 4;\n\tconst colorsDefault = useMobileGlobalStylesColors();\n\tconst coverDefaultPalette = useMemo( () => {\n\t\treturn {\n\t\t\tcolors: colorsDefault.slice( 0, THEME_COLORS_COUNT ),\n\t\t};\n\t}, [ colorsDefault ] );\n\tconst gradients = useMobileGlobalStylesColors( 'gradients' );\n\tconst gradientValue =\n\t\tcustomGradient || getGradientValueBySlug( gradients, gradient );\n\tconst overlayColorValue = getColorObjectByAttributeValues(\n\t\tcolorsDefault,\n\t\toverlayColor\n\t);\n\n\tconst hasBackground = !! (\n\t\turl ||\n\t\t( style && style.color && style.color.background ) ||\n\t\tattributes.overlayColor ||\n\t\toverlayColorValue.color ||\n\t\tcustomOverlayColor ||\n\t\tgradientValue\n\t);\n\n\tconst hasOnlyColorBackground = ! url && ( hasBackground || hasInnerBlocks );\n\n\tconst [ isCustomColorPickerShowing, setCustomColorPickerShowing ] =\n\t\tuseState( false );\n\n\tconst openMediaOptionsRef = useRef();\n\n\t// Initialize uploading flag to false, awaiting sync.\n\tconst [ isUploadInProgress, setIsUploadInProgress ] = useState( false );\n\n\t// Initialize upload failure flag to true if url is local.\n\tconst [ didUploadFail, setDidUploadFail ] = useState(\n\t\tid && getProtocol( url ) === 'file:'\n\t);\n\n\t// Don't show failure if upload is in progress.\n\tconst shouldShowFailure = didUploadFail && ! isUploadInProgress;\n\n\tconst onSelectMedia = ( media ) => {\n\t\tsetDidUploadFail( false );\n\n\t\tconst mediaAttributes = attributesFromMedia( media );\n\t\tsetAttributes( {\n\t\t\t...mediaAttributes,\n\t\t\tfocalPoint: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\tisDark: undefined,\n\t\t} );\n\t};\n\n\tconst onMediaPressed = () => {\n\t\tif ( isUploadInProgress ) {\n\t\t\trequestImageUploadCancelDialog( id );\n\t\t} else if ( shouldShowFailure ) {\n\t\t\trequestImageFailedRetryDialog( id );\n\t\t} else if ( isImage && url ) {\n\t\t\trequestImageFullscreenPreview( url );\n\t\t}\n\t};\n\n\tconst [ isVideoLoading, setIsVideoLoading ] = useState( true );\n\n\tconst onVideoLoadStart = () => {\n\t\tsetIsVideoLoading( true );\n\t};\n\n\tconst onVideoLoad = () => {\n\t\tsetIsVideoLoading( false );\n\t};\n\n\tconst onClearMedia = useCallback( () => {\n\t\tsetAttributes( {\n\t\t\tfocalPoint: undefined,\n\t\t\thasParallax: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t} );\n\t\tcloseSettingsBottomSheet();\n\t}, [ closeSettingsBottomSheet ] );\n\n\tfunction setColor( color ) {\n\t\tconst colorValue = getColorObjectByColorValue( colorsDefault, color );\n\n\t\tsetAttributes( {\n\t\t\t// Clear all related attributes (only one should be set).\n\t\t\toverlayColor: colorValue?.slug ?? undefined,\n\t\t\tcustomOverlayColor: ( ! colorValue?.slug && color ) ?? undefined,\n\t\t\tgradient: undefined,\n\t\t\tcustomGradient: undefined,\n\t\t} );\n\t}\n\n\tfunction openColorPicker() {\n\t\tselectBlock();\n\t\tsetCustomColorPickerShowing( true );\n\t\topenGeneralSidebar();\n\t}\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst isCoverDark = useCoverIsDark(\n\t\tisDark,\n\t\turl,\n\t\tdimRatio,\n\t\toverlayColorValue?.color\n\t);\n\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t// Used to set a default color for its InnerBlocks\n\t\t// since there's no system to inherit styles yet\n\t\t// the RichText component will check if there are\n\t\t// parent styles for the current block. If there are,\n\t\t// it will use that color instead.\n\t\tsetAttributes( {\n\t\t\tisDark: isCoverDark,\n\t\t\tchildrenStyles: isCoverDark\n\t\t\t\t? styles.defaultColor\n\t\t\t\t: styles.defaultColorLightMode,\n\t\t} );\n\n\t\t// Ensure that \"is-light\" is removed from \"className\" attribute if cover background is dark.\n\t\tif ( isCoverDark && attributes.className?.includes( 'is-light' ) ) {\n\t\t\tconst className = classnames( attributes.className, {\n\t\t\t\t'is-light': false,\n\t\t\t} );\n\t\t\tsetAttributes( {\n\t\t\t\tclassName: className !== '' ? className : undefined,\n\t\t\t} );\n\t\t}\n\t}, [ isCoverDark ] );\n\n\tconst backgroundColor = getStylesFromColorScheme(\n\t\tstyles.backgroundSolid,\n\t\tstyles.backgroundSolidDark\n\t);\n\n\tconst overlayStyles = [\n\t\tstyles.overlay,\n\t\turl && { opacity: dimRatio / 100 },\n\t\t! gradientValue && {\n\t\t\tbackgroundColor:\n\t\t\t\tcustomOverlayColor ||\n\t\t\t\toverlayColorValue?.color ||\n\t\t\t\tstyle?.color?.background ||\n\t\t\t\tstyles.overlay?.color,\n\t\t},\n\t\t// While we don't support theme colors we add a default bg color.\n\t\t! overlayColorValue.color && ! url ? backgroundColor : {},\n\t\tisImage &&\n\t\t\tisParentSelected &&\n\t\t\t! isUploadInProgress &&\n\t\t\t! didUploadFail &&\n\t\t\tstyles.overlaySelected,\n\t];\n\n\tconst placeholderIconStyle = getStylesFromColorScheme(\n\t\tstyles.icon,\n\t\tstyles.iconDark\n\t);\n\n\tconst placeholderIcon = <Icon icon={ icon } { ...placeholderIconStyle } />;\n\n\tconst toolbarControls = ( open ) => (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarButton\n\t\t\t\ttitle={ __( 'Edit cover media' ) }\n\t\t\t\ticon={ replace }\n\t\t\t\tonClick={ open }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst accessibilityHint =\n\t\tPlatform.OS === 'ios'\n\t\t\t? __( 'Double tap to open Action Sheet to add image or video' )\n\t\t\t: __( 'Double tap to open Bottom Sheet to add image or video' );\n\n\tconst addMediaButton = () => (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\taccessibilityLabel={ __( 'Add image or video' ) }\n\t\t\taccessibilityRole=\"button\"\n\t\t\tonPress={ openMediaOptionsRef.current }\n\t\t>\n\t\t\t<View style={ styles.selectImageContainer }>\n\t\t\t\t<View style={ styles.selectImage }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tsize={ 16 }\n\t\t\t\t\t\ticon={ image }\n\t\t\t\t\t\t{ ...styles.selectImageIcon }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n\n\tconst onBottomSheetClosed = useCallback( () => {\n\t\tInteractionManager.runAfterInteractions( () => {\n\t\t\tsetCustomColorPickerShowing( false );\n\t\t} );\n\t}, [] );\n\n\tconst selectedColorText = getStylesFromColorScheme(\n\t\tstyles.selectedColorText,\n\t\tstyles.selectedColorTextDark\n\t);\n\n\tconst bottomLabelText = customOverlayColor ? (\n\t\t<Text style={ selectedColorText }>\n\t\t\t{ customOverlayColor.toUpperCase() }\n\t\t</Text>\n\t) : (\n\t\t__( 'Select a color' )\n\t);\n\n\tconst colorPickerControls = (\n\t\t<InspectorControls>\n\t\t\t<BottomSheetConsumer>\n\t\t\t\t{ ( {\n\t\t\t\t\tshouldEnableBottomSheetScroll,\n\t\t\t\t\tshouldEnableBottomSheetMaxHeight,\n\t\t\t\t\tonHandleClosingBottomSheet,\n\t\t\t\t\tonHandleHardwareButtonPress,\n\t\t\t\t\tisBottomSheetContentScrolling,\n\t\t\t\t} ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tshouldEnableBottomSheetScroll={\n\t\t\t\t\t\t\tshouldEnableBottomSheetScroll\n\t\t\t\t\t\t}\n\t\t\t\t\t\tshouldEnableBottomSheetMaxHeight={\n\t\t\t\t\t\t\tshouldEnableBottomSheetMaxHeight\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetColor={ setColor }\n\t\t\t\t\t\tonNavigationBack={ closeSettingsBottomSheet }\n\t\t\t\t\t\tonHandleClosingBottomSheet={\n\t\t\t\t\t\t\tonHandleClosingBottomSheet\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonHandleHardwareButtonPress={\n\t\t\t\t\t\t\tonHandleHardwareButtonPress\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonBottomSheetClosed={ onBottomSheetClosed }\n\t\t\t\t\t\tisBottomSheetContentScrolling={\n\t\t\t\t\t\t\tisBottomSheetContentScrolling\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbottomLabelText={ bottomLabelText }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BottomSheetConsumer>\n\t\t</InspectorControls>\n\t);\n\n\tconst renderContent = ( getMediaOptions ) => (\n\t\t<>\n\t\t\t{ renderBackground( getMediaOptions ) }\n\t\t\t{ isParentSelected && hasOnlyColorBackground && addMediaButton() }\n\t\t</>\n\t);\n\n\tconst renderBackground = ( getMediaOptions ) => (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessible={ ! isParentSelected }\n\t\t\tonPress={ onMediaPressed }\n\t\t\tdisabled={ ! isParentSelected }\n\t\t>\n\t\t\t<View style={ [ styles.background, backgroundColor ] }>\n\t\t\t\t{ getMediaOptions() }\n\t\t\t\t{ isParentSelected &&\n\t\t\t\t\tbackgroundType === VIDEO_BACKGROUND_TYPE &&\n\t\t\t\t\ttoolbarControls( openMediaOptionsRef.current ) }\n\t\t\t\t<MediaUploadProgress\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tonUpdateMediaProgress={ () => {\n\t\t\t\t\t\tsetIsUploadInProgress( true );\n\t\t\t\t\t} }\n\t\t\t\t\tonFinishMediaUploadWithSuccess={ ( {\n\t\t\t\t\t\tmediaServerId,\n\t\t\t\t\t\tmediaUrl,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\tsetIsUploadInProgress( false );\n\t\t\t\t\t\tsetDidUploadFail( false );\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tid: mediaServerId,\n\t\t\t\t\t\t\turl: mediaUrl,\n\t\t\t\t\t\t\tbackgroundType,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tonFinishMediaUploadWithFailure={ () => {\n\t\t\t\t\t\tsetIsUploadInProgress( false );\n\t\t\t\t\t\tsetDidUploadFail( true );\n\t\t\t\t\t} }\n\t\t\t\t\tonMediaUploadStateReset={ () => {\n\t\t\t\t\t\tsetIsUploadInProgress( false );\n\t\t\t\t\t\tsetDidUploadFail( false );\n\t\t\t\t\t\tsetAttributes( { id: undefined, url: undefined } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\n\t\t\t\t{ IMAGE_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t<View style={ styles.imageContainer }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\teditButton={ false }\n\t\t\t\t\t\t\tfocalPoint={\n\t\t\t\t\t\t\t\tfocalPoint || IMAGE_DEFAULT_FOCAL_POINT\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisSelected={ isParentSelected }\n\t\t\t\t\t\t\tisUploadFailed={ didUploadFail }\n\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\tonSelectMediaUploadOption={ onSelectMedia }\n\t\t\t\t\t\t\topenMediaOptions={ openMediaOptionsRef.current }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\twidth={ styles.image?.width }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\n\t\t\t\t{ VIDEO_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t<Video\n\t\t\t\t\t\tmuted\n\t\t\t\t\t\tdisableFocus\n\t\t\t\t\t\trepeat\n\t\t\t\t\t\tresizeMode={ 'cover' }\n\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t\tonLoad={ onVideoLoad }\n\t\t\t\t\t\tonLoadStart={ onVideoLoadStart }\n\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\tstyles.background,\n\t\t\t\t\t\t\t// Hide Video component since it has black background while loading the source.\n\t\t\t\t\t\t\t{ opacity: isVideoLoading ? 0 : 1 },\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n\n\tif (\n\t\t( ! hasBackground && ! hasInnerBlocks ) ||\n\t\tisCustomColorPickerShowing\n\t) {\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t{ isCustomColorPickerShowing && colorPickerControls }\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\theight={\n\t\t\t\t\t\tstyles.mediaPlaceholderEmptyStateContainer?.height\n\t\t\t\t\t}\n\t\t\t\t\tbackgroundColor={ customOverlayColor }\n\t\t\t\t\thideContent={\n\t\t\t\t\t\tcustomOverlayColor !== '' &&\n\t\t\t\t\t\tcustomOverlayColor !== undefined\n\t\t\t\t\t}\n\t\t\t\t\ticon={ placeholderIcon }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'Cover' ),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t>\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ styles.colorPaletteWrapper }\n\t\t\t\t\t\tpointerEvents={\n\t\t\t\t\t\t\tisScreenReaderEnabled ? 'none' : 'auto'\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BottomSheetConsumer>\n\t\t\t\t\t\t\t{ ( { shouldEnableBottomSheetScroll } ) => (\n\t\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles={\n\t\t\t\t\t\t\t\t\t\tstyles.paletteColorIndicator\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcustomIndicatorWrapperStyles={\n\t\t\t\t\t\t\t\t\t\tstyles.paletteCustomIndicatorWrapper\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetColor={ setColor }\n\t\t\t\t\t\t\t\t\tonCustomPress={ openColorPicker }\n\t\t\t\t\t\t\t\t\tdefaultSettings={ coverDefaultPalette }\n\t\t\t\t\t\t\t\t\tshouldShowCustomLabel={ false }\n\t\t\t\t\t\t\t\t\tshouldShowCustomVerticalSeparator={ false }\n\t\t\t\t\t\t\t\t\tshouldEnableBottomSheetScroll={\n\t\t\t\t\t\t\t\t\t\tshouldEnableBottomSheetScroll\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BottomSheetConsumer>\n\t\t\t\t\t</View>\n\t\t\t\t</MediaPlaceholder>\n\t\t\t</View>\n\t\t);\n\t}\n\n\treturn (\n\t\t<View style={ styles.backgroundContainer }>\n\t\t\t{ isSelected && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<Controls\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tdidUploadFail={ didUploadFail }\n\t\t\t\t\t\thasOnlyColorBackground={ hasOnlyColorBackground }\n\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\tonClearMedia={ onClearMedia }\n\t\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t/>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\n\t\t\t<View\n\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\tstyle={ [ styles.content, { minHeight: convertedMinHeight } ] }\n\t\t\t>\n\t\t\t\t<InnerBlocks\n\t\t\t\t\tallowedBlocks={ allowedBlocks }\n\t\t\t\t\ttemplate={ INNER_BLOCKS_TEMPLATE }\n\t\t\t\t\ttemplateLock={ templateLock }\n\t\t\t\t\ttemplateInsertUpdatesSelection\n\t\t\t\t\tblockWidth={ blockWidth }\n\t\t\t\t/>\n\t\t\t</View>\n\n\t\t\t<View pointerEvents=\"none\" style={ styles.overlayContainer }>\n\t\t\t\t<View style={ overlayStyles }>\n\t\t\t\t\t{ gradientValue && (\n\t\t\t\t\t\t<Gradient\n\t\t\t\t\t\t\tgradientValue={ gradientValue }\n\t\t\t\t\t\t\tstyle={ styles.background }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</View>\n\t\t\t</View>\n\n\t\t\t<MediaUpload\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tisReplacingMedia={ ! hasOnlyColorBackground }\n\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\topenMediaOptionsRef.current = open;\n\t\t\t\t\treturn renderContent( getMediaOptions );\n\t\t\t\t} }\n\t\t\t/>\n\n\t\t\t{ isImage &&\n\t\t\t\turl &&\n\t\t\t\topenMediaOptionsRef.current &&\n\t\t\t\tisParentSelected &&\n\t\t\t\t! isUploadInProgress &&\n\t\t\t\t! didUploadFail && (\n\t\t\t\t\t<View style={ styles.imageEditButton }>\n\t\t\t\t\t\t<ImageEditingButton\n\t\t\t\t\t\t\tonSelectMediaUploadOption={ onSelectMedia }\n\t\t\t\t\t\t\topenMediaOptions={ openMediaOptionsRef.current }\n\t\t\t\t\t\t\tpickerOptions={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tdestructiveButton: true,\n\t\t\t\t\t\t\t\t\tid: 'clearMedia',\n\t\t\t\t\t\t\t\t\tlabel: __( 'Clear Media' ),\n\t\t\t\t\t\t\t\t\tonPress: onClearMedia,\n\t\t\t\t\t\t\t\t\tseparated: true,\n\t\t\t\t\t\t\t\t\tvalue: 'clearMedia',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\n\t\t\t{ shouldShowFailure && (\n\t\t\t\t<View\n\t\t\t\t\tpointerEvents=\"none\"\n\t\t\t\t\tstyle={ styles.uploadFailedContainer }\n\t\t\t\t>\n\t\t\t\t\t<View style={ styles.uploadFailed }>\n\t\t\t\t\t\t<Icon icon={ warning } { ...styles.uploadFailedIcon } />\n\t\t\t\t\t</View>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t</View>\n\t);\n};\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => {\n\t\tconst { getSelectedBlockClientId, getBlock } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\tconst hasInnerBlocks = getBlock( clientId )?.innerBlocks.length > 0;\n\n\t\treturn {\n\t\t\tisParentSelected: selectedBlockClientId === clientId,\n\t\t\thasInnerBlocks,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { clientId } ) => {\n\t\tconst { openGeneralSidebar } = dispatch( editPostStore );\n\t\tconst { selectBlock } = dispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\topenGeneralSidebar: () => openGeneralSidebar( 'edit-post/block' ),\n\t\t\tcloseSettingsBottomSheet() {\n\t\t\t\tdispatch( editPostStore ).closeGeneralSidebar();\n\t\t\t},\n\t\t\tselectBlock: () => selectBlock( clientId ),\n\t\t};\n\t} ),\n\twithPreferredColorScheme,\n] )( Cover );\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAD,sBAAA,CAAAF,OAAA;AAKA,IAAAI,kBAAA,GAAAJ,OAAA;AAMA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAaA,IAAAO,YAAA,GAAAP,OAAA;AAaA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAOA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,IAAA,GAAAZ,OAAA;AAEA,IAAAa,SAAA,GAAAb,OAAA;AAKA,IAAAc,MAAA,GAAAZ,sBAAA,CAAAF,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AAOA,IAAAgB,SAAA,GAAAd,sBAAA,CAAAF,OAAA;AACA,IAAAiB,eAAA,GAAAf,sBAAA,CAAAF,OAAA;AA5EA;AACA;AACA;;AAYA;AACA;AACA;;AA6CA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;AACA,MAAMkB,qBAAqB,GAAG,CAC7B,CACC,gBAAgB,EAChB;EACCC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE,IAAAC,QAAE,EAAE,cAAe;AACjC,CAAC,CACD,CACD;AAED,SAASC,wBAAwBA,CAAA,EAAG;EACnC,MAAM,CAAEC,qBAAqB,EAAEC,wBAAwB,CAAE,GACxD,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EAElB,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAIC,OAAO,GAAG,IAAI;IAElB,MAAMC,cAAc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IAAElO;EAAY,CAAC,GAAGiO,QAAQ,CAAErJ,kBAAiB,CAAC;EAEpD,OAAO;IACN/E,kBAAkB,EAAEA,CAAA,KAAMA,kBAAkB,CAAE,iBAAkB,CAAC;IACjEC,wBAAwBA,CAAA,EAAG;MAC1BmO,QAAQ,CAAEC,eAAc,CAAC,CAACC,mBAAmB,CAAC,CAAC;IAChD,CAAC;IACDnO,WAAW,EAAEA,CAAA,KAAMA,WAAW,CAAE0N,QAAS;EAC1C,CAAC;AACF,CAAE,CAAC,EACHU,iCAAwB,CACvB,CAAC,CAAE7O,KAAM,CAAC;AAAA8O,OAAA,CAAAhE,OAAA,GAAAiD,QAAA"}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_reactNativeVideo","_interopRequireDefault","_dedupe","_reactNativeBridge","_i18n","_components","_blockEditor","_compose","_data","_element","_icons","_url","_editPost","_style","_shared","_controls","_useCoverIsDark","INNER_BLOCKS_TEMPLATE","align","placeholder","__","useIsScreenReaderEnabled","isScreenReaderEnabled","setIsScreenReaderEnabled","useState","useEffect","mounted","changeListener","AccessibilityInfo","addEventListener","enabled","then","screenReaderEnabled","remove","Cover","attributes","getStylesFromColorScheme","isParentSelected","onFocus","setAttributes","openGeneralSidebar","closeSettingsBottomSheet","isSelected","selectBlock","blockWidth","hasInnerBlocks","backgroundType","dimRatio","focalPoint","minHeight","url","id","style","customOverlayColor","minHeightUnit","allowedBlocks","templateLock","customGradient","gradient","overlayColor","isDark","mediaUploadSync","convertedMinHeight","useConvertUnitToMobile","COVER_DEFAULT_HEIGHT","isImage","MEDIA_TYPE_IMAGE","THEME_COLORS_COUNT","colorsDefault","useMobileGlobalStylesColors","coverDefaultPalette","useMemo","colors","slice","gradients","gradientValue","getGradientValueBySlug","overlayColorValue","getColorObjectByAttributeValues","hasBackground","color","background","hasOnlyColorBackground","isCustomColorPickerShowing","setCustomColorPickerShowing","openMediaOptionsRef","useRef","isUploadInProgress","setIsUploadInProgress","didUploadFail","setDidUploadFail","getProtocol","shouldShowFailure","onSelectMedia","media","mediaAttributes","attributesFromMedia","undefined","useFeaturedImage","onMediaPressed","requestImageUploadCancelDialog","requestImageFailedRetryDialog","requestImageFullscreenPreview","isVideoLoading","setIsVideoLoading","onVideoLoadStart","onVideoLoad","onClearMedia","useCallback","hasParallax","setColor","_colorValue$slug","_ref","colorValue","getColorObjectByColorValue","slug","openColorPicker","__unstableMarkNextChangeAsNotPersistent","useDispatch","blockEditorStore","isCoverDark","useCoverIsDark","childrenStyles","styles","defaultColor","defaultColorLightMode","className","includes","classnames","backgroundColor","backgroundSolid","backgroundSolidDark","overlayStyles","overlay","opacity","overlaySelected","placeholderIconStyle","icon","iconDark","placeholderIcon","_react","createElement","Icon","toolbarControls","open","BlockControls","group","ToolbarButton","title","replace","onClick","accessibilityHint","Platform","OS","addMediaButton","TouchableWithoutFeedback","accessibilityLabel","accessibilityRole","onPress","current","View","selectImageContainer","selectImage","size","image","selectImageIcon","onBottomSheetClosed","InteractionManager","runAfterInteractions","selectedColorText","selectedColorTextDark","bottomLabelText","Text","toUpperCase","colorPickerControls","InspectorControls","BottomSheetConsumer","shouldEnableBottomSheetScroll","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","onHandleHardwareButtonPress","isBottomSheetContentScrolling","ColorPicker","onNavigationBack","renderContent","getMediaOptions","Fragment","renderBackground","accessible","disabled","VIDEO_BACKGROUND_TYPE","MediaUploadProgress","mediaId","onUpdateMediaProgress","onFinishMediaUploadWithSuccess","mediaServerId","mediaUrl","onFinishMediaUploadWithFailure","onMediaUploadStateReset","IMAGE_BACKGROUND_TYPE","imageContainer","Image","editButton","IMAGE_DEFAULT_FOCAL_POINT","isUploadFailed","onSelectMediaUploadOption","openMediaOptions","width","default","muted","disableFocus","repeat","resizeMode","source","uri","onLoad","onLoadStart","MediaPlaceholder","height","mediaPlaceholderEmptyStateContainer","hideContent","labels","onSelect","allowedTypes","ALLOWED_MEDIA_TYPES","colorPaletteWrapper","pointerEvents","ColorPalette","enableCustomColor","customColorIndicatorStyles","paletteColorIndicator","customIndicatorWrapperStyles","paletteCustomIndicatorWrapper","onCustomPress","defaultSettings","shouldShowCustomLabel","shouldShowCustomVerticalSeparator","backgroundContainer","content","InnerBlocks","template","templateInsertUpdatesSelection","overlayContainer","Gradient","MediaUpload","isReplacingMedia","render","imageEditButton","ImageEditingButton","pickerOptions","destructiveButton","label","separated","value","uploadFailedContainer","uploadFailed","warning","uploadFailedIcon","_default","compose","withSelect","select","clientId","getSelectedBlockClientId","getBlock","selectedBlockClientId","innerBlocks","length","withDispatch","dispatch","editPostStore","closeGeneralSidebar","withPreferredColorScheme","exports"],"sources":["@wordpress/block-library/src/cover/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tTouchableWithoutFeedback,\n\tInteractionManager,\n\tAccessibilityInfo,\n\tText,\n\tPlatform,\n} from 'react-native';\nimport Video from 'react-native-video';\nimport classnames from 'classnames/dedupe';\n\n/**\n * WordPress dependencies\n */\nimport {\n\trequestImageFailedRetryDialog,\n\trequestImageUploadCancelDialog,\n\trequestImageFullscreenPreview,\n\tmediaUploadSync,\n} from '@wordpress/react-native-bridge';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tIcon,\n\tImage,\n\tImageEditingButton,\n\tIMAGE_DEFAULT_FOCAL_POINT,\n\tToolbarButton,\n\tGradient,\n\tColorPalette,\n\tColorPicker,\n\tBottomSheetConsumer,\n\tuseConvertUnitToMobile,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tInspectorControls,\n\tMEDIA_TYPE_IMAGE,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tgetGradientValueBySlug,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { useDispatch, withSelect, withDispatch } from '@wordpress/data';\nimport {\n\tuseEffect,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { cover as icon, replace, image, warning } from '@wordpress/icons';\nimport { getProtocol } from '@wordpress/url';\n// eslint-disable-next-line no-restricted-imports\nimport { store as editPostStore } from '@wordpress/edit-post';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport {\n\tattributesFromMedia,\n\tALLOWED_MEDIA_TYPES,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tCOVER_DEFAULT_HEIGHT,\n} from './shared';\nimport Controls from './controls';\nimport useCoverIsDark from './use-cover-is-dark';\n\n/**\n * Constants\n */\nconst INNER_BLOCKS_TEMPLATE = [\n\t[\n\t\t'core/paragraph',\n\t\t{\n\t\t\talign: 'center',\n\t\t\tplaceholder: __( 'Write title…' ),\n\t\t},\n\t],\n];\n\nfunction useIsScreenReaderEnabled() {\n\tconst [ isScreenReaderEnabled, setIsScreenReaderEnabled ] =\n\t\tuseState( false );\n\n\tuseEffect( () => {\n\t\tlet mounted = true;\n\n\t\tconst changeListener = AccessibilityInfo.addEventListener(\n\t\t\t'screenReaderChanged',\n\t\t\t( enabled ) => setIsScreenReaderEnabled( enabled )\n\t\t);\n\n\t\tAccessibilityInfo.isScreenReaderEnabled().then(\n\t\t\t( screenReaderEnabled ) => {\n\t\t\t\tif ( mounted && screenReaderEnabled ) {\n\t\t\t\t\tsetIsScreenReaderEnabled( screenReaderEnabled );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\n\t\t\tchangeListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn isScreenReaderEnabled;\n}\n\nconst Cover = ( {\n\tattributes,\n\tgetStylesFromColorScheme,\n\tisParentSelected,\n\tonFocus,\n\tsetAttributes,\n\topenGeneralSidebar,\n\tcloseSettingsBottomSheet,\n\tisSelected,\n\tselectBlock,\n\tblockWidth,\n\thasInnerBlocks,\n} ) => {\n\tconst {\n\t\tbackgroundType,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\tminHeight,\n\t\turl,\n\t\tid,\n\t\tstyle,\n\t\tcustomOverlayColor,\n\t\tminHeightUnit = 'px',\n\t\tallowedBlocks,\n\t\ttemplateLock,\n\t\tcustomGradient,\n\t\tgradient,\n\t\toverlayColor,\n\t\tisDark,\n\t} = attributes;\n\tconst isScreenReaderEnabled = useIsScreenReaderEnabled();\n\n\tuseEffect( () => {\n\t\t// Sync with local media store.\n\t\tmediaUploadSync();\n\t}, [] );\n\n\tconst convertedMinHeight = useConvertUnitToMobile(\n\t\tminHeight || COVER_DEFAULT_HEIGHT,\n\t\tminHeightUnit\n\t);\n\n\tconst isImage = backgroundType === MEDIA_TYPE_IMAGE;\n\n\tconst THEME_COLORS_COUNT = 4;\n\tconst colorsDefault = useMobileGlobalStylesColors();\n\tconst coverDefaultPalette = useMemo( () => {\n\t\treturn {\n\t\t\tcolors: colorsDefault.slice( 0, THEME_COLORS_COUNT ),\n\t\t};\n\t}, [ colorsDefault ] );\n\tconst gradients = useMobileGlobalStylesColors( 'gradients' );\n\tconst gradientValue =\n\t\tcustomGradient || getGradientValueBySlug( gradients, gradient );\n\tconst overlayColorValue = getColorObjectByAttributeValues(\n\t\tcolorsDefault,\n\t\toverlayColor\n\t);\n\n\tconst hasBackground = !! (\n\t\turl ||\n\t\t( style && style.color && style.color.background ) ||\n\t\tattributes.overlayColor ||\n\t\toverlayColorValue.color ||\n\t\tcustomOverlayColor ||\n\t\tgradientValue\n\t);\n\n\tconst hasOnlyColorBackground = ! url && ( hasBackground || hasInnerBlocks );\n\n\tconst [ isCustomColorPickerShowing, setCustomColorPickerShowing ] =\n\t\tuseState( false );\n\n\tconst openMediaOptionsRef = useRef();\n\n\t// Initialize uploading flag to false, awaiting sync.\n\tconst [ isUploadInProgress, setIsUploadInProgress ] = useState( false );\n\n\t// Initialize upload failure flag to true if url is local.\n\tconst [ didUploadFail, setDidUploadFail ] = useState(\n\t\tid && getProtocol( url ) === 'file:'\n\t);\n\n\t// Don't show failure if upload is in progress.\n\tconst shouldShowFailure = didUploadFail && ! isUploadInProgress;\n\n\tconst onSelectMedia = ( media ) => {\n\t\tsetDidUploadFail( false );\n\n\t\tconst mediaAttributes = attributesFromMedia( media );\n\t\tsetAttributes( {\n\t\t\t...mediaAttributes,\n\t\t\tfocalPoint: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\tisDark: undefined,\n\t\t} );\n\t};\n\n\tconst onMediaPressed = () => {\n\t\tif ( isUploadInProgress ) {\n\t\t\trequestImageUploadCancelDialog( id );\n\t\t} else if ( shouldShowFailure ) {\n\t\t\trequestImageFailedRetryDialog( id );\n\t\t} else if ( isImage && url ) {\n\t\t\trequestImageFullscreenPreview( url );\n\t\t}\n\t};\n\n\tconst [ isVideoLoading, setIsVideoLoading ] = useState( true );\n\n\tconst onVideoLoadStart = () => {\n\t\tsetIsVideoLoading( true );\n\t};\n\n\tconst onVideoLoad = () => {\n\t\tsetIsVideoLoading( false );\n\t};\n\n\tconst onClearMedia = useCallback( () => {\n\t\tsetAttributes( {\n\t\t\tfocalPoint: undefined,\n\t\t\thasParallax: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t} );\n\t\tcloseSettingsBottomSheet();\n\t}, [ closeSettingsBottomSheet ] );\n\n\tfunction setColor( color ) {\n\t\tconst colorValue = getColorObjectByColorValue( colorsDefault, color );\n\n\t\tsetAttributes( {\n\t\t\t// Clear all related attributes (only one should be set).\n\t\t\toverlayColor: colorValue?.slug ?? undefined,\n\t\t\tcustomOverlayColor: ( ! colorValue?.slug && color ) ?? undefined,\n\t\t\tgradient: undefined,\n\t\t\tcustomGradient: undefined,\n\t\t} );\n\t}\n\n\tfunction openColorPicker() {\n\t\tselectBlock();\n\t\tsetCustomColorPickerShowing( true );\n\t\topenGeneralSidebar();\n\t}\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst isCoverDark = useCoverIsDark(\n\t\tisDark,\n\t\turl,\n\t\tdimRatio,\n\t\toverlayColorValue?.color\n\t);\n\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t// Used to set a default color for its InnerBlocks\n\t\t// since there's no system to inherit styles yet\n\t\t// the RichText component will check if there are\n\t\t// parent styles for the current block. If there are,\n\t\t// it will use that color instead.\n\t\tsetAttributes( {\n\t\t\tisDark: isCoverDark,\n\t\t\tchildrenStyles: isCoverDark\n\t\t\t\t? styles.defaultColor\n\t\t\t\t: styles.defaultColorLightMode,\n\t\t} );\n\n\t\t// Ensure that \"is-light\" is removed from \"className\" attribute if cover background is dark.\n\t\tif ( isCoverDark && attributes.className?.includes( 'is-light' ) ) {\n\t\t\tconst className = classnames( attributes.className, {\n\t\t\t\t'is-light': false,\n\t\t\t} );\n\t\t\tsetAttributes( {\n\t\t\t\tclassName: className !== '' ? className : undefined,\n\t\t\t} );\n\t\t}\n\t}, [ isCoverDark ] );\n\n\tconst backgroundColor = getStylesFromColorScheme(\n\t\tstyles.backgroundSolid,\n\t\tstyles.backgroundSolidDark\n\t);\n\n\tconst overlayStyles = [\n\t\tstyles.overlay,\n\t\turl && { opacity: dimRatio / 100 },\n\t\t! gradientValue && {\n\t\t\tbackgroundColor:\n\t\t\t\tcustomOverlayColor ||\n\t\t\t\toverlayColorValue?.color ||\n\t\t\t\tstyle?.color?.background ||\n\t\t\t\tstyles.overlay?.color,\n\t\t},\n\t\t// While we don't support theme colors we add a default bg color.\n\t\t! overlayColorValue.color && ! url ? backgroundColor : {},\n\t\tisImage &&\n\t\t\tisParentSelected &&\n\t\t\t! isUploadInProgress &&\n\t\t\t! didUploadFail &&\n\t\t\tstyles.overlaySelected,\n\t];\n\n\tconst placeholderIconStyle = getStylesFromColorScheme(\n\t\tstyles.icon,\n\t\tstyles.iconDark\n\t);\n\n\tconst placeholderIcon = <Icon icon={ icon } { ...placeholderIconStyle } />;\n\n\tconst toolbarControls = ( open ) => (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarButton\n\t\t\t\ttitle={ __( 'Edit cover media' ) }\n\t\t\t\ticon={ replace }\n\t\t\t\tonClick={ open }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst accessibilityHint =\n\t\tPlatform.OS === 'ios'\n\t\t\t? __( 'Double tap to open Action Sheet to add image or video' )\n\t\t\t: __( 'Double tap to open Bottom Sheet to add image or video' );\n\n\tconst addMediaButton = () => (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\taccessibilityLabel={ __( 'Add image or video' ) }\n\t\t\taccessibilityRole=\"button\"\n\t\t\tonPress={ openMediaOptionsRef.current }\n\t\t>\n\t\t\t<View style={ styles.selectImageContainer }>\n\t\t\t\t<View style={ styles.selectImage }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tsize={ 16 }\n\t\t\t\t\t\ticon={ image }\n\t\t\t\t\t\t{ ...styles.selectImageIcon }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n\n\tconst onBottomSheetClosed = useCallback( () => {\n\t\tInteractionManager.runAfterInteractions( () => {\n\t\t\tsetCustomColorPickerShowing( false );\n\t\t} );\n\t}, [] );\n\n\tconst selectedColorText = getStylesFromColorScheme(\n\t\tstyles.selectedColorText,\n\t\tstyles.selectedColorTextDark\n\t);\n\n\tconst bottomLabelText = customOverlayColor ? (\n\t\t<Text style={ selectedColorText }>\n\t\t\t{ customOverlayColor.toUpperCase() }\n\t\t</Text>\n\t) : (\n\t\t__( 'Select a color' )\n\t);\n\n\tconst colorPickerControls = (\n\t\t<InspectorControls>\n\t\t\t<BottomSheetConsumer>\n\t\t\t\t{ ( {\n\t\t\t\t\tshouldEnableBottomSheetScroll,\n\t\t\t\t\tshouldEnableBottomSheetMaxHeight,\n\t\t\t\t\tonHandleClosingBottomSheet,\n\t\t\t\t\tonHandleHardwareButtonPress,\n\t\t\t\t\tisBottomSheetContentScrolling,\n\t\t\t\t} ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tshouldEnableBottomSheetScroll={\n\t\t\t\t\t\t\tshouldEnableBottomSheetScroll\n\t\t\t\t\t\t}\n\t\t\t\t\t\tshouldEnableBottomSheetMaxHeight={\n\t\t\t\t\t\t\tshouldEnableBottomSheetMaxHeight\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetColor={ setColor }\n\t\t\t\t\t\tonNavigationBack={ closeSettingsBottomSheet }\n\t\t\t\t\t\tonHandleClosingBottomSheet={\n\t\t\t\t\t\t\tonHandleClosingBottomSheet\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonHandleHardwareButtonPress={\n\t\t\t\t\t\t\tonHandleHardwareButtonPress\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonBottomSheetClosed={ onBottomSheetClosed }\n\t\t\t\t\t\tisBottomSheetContentScrolling={\n\t\t\t\t\t\t\tisBottomSheetContentScrolling\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbottomLabelText={ bottomLabelText }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BottomSheetConsumer>\n\t\t</InspectorControls>\n\t);\n\n\tconst renderContent = ( getMediaOptions ) => (\n\t\t<>\n\t\t\t{ renderBackground( getMediaOptions ) }\n\t\t\t{ isParentSelected && hasOnlyColorBackground && addMediaButton() }\n\t\t</>\n\t);\n\n\tconst renderBackground = ( getMediaOptions ) => (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessible={ ! isParentSelected }\n\t\t\tonPress={ onMediaPressed }\n\t\t\tdisabled={ ! isParentSelected }\n\t\t>\n\t\t\t<View style={ [ styles.background, backgroundColor ] }>\n\t\t\t\t{ getMediaOptions() }\n\t\t\t\t{ isParentSelected &&\n\t\t\t\t\tbackgroundType === VIDEO_BACKGROUND_TYPE &&\n\t\t\t\t\ttoolbarControls( openMediaOptionsRef.current ) }\n\t\t\t\t<MediaUploadProgress\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tonUpdateMediaProgress={ () => {\n\t\t\t\t\t\tsetIsUploadInProgress( true );\n\t\t\t\t\t} }\n\t\t\t\t\tonFinishMediaUploadWithSuccess={ ( {\n\t\t\t\t\t\tmediaServerId,\n\t\t\t\t\t\tmediaUrl,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\tsetIsUploadInProgress( false );\n\t\t\t\t\t\tsetDidUploadFail( false );\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tid: mediaServerId,\n\t\t\t\t\t\t\turl: mediaUrl,\n\t\t\t\t\t\t\tbackgroundType,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tonFinishMediaUploadWithFailure={ () => {\n\t\t\t\t\t\tsetIsUploadInProgress( false );\n\t\t\t\t\t\tsetDidUploadFail( true );\n\t\t\t\t\t} }\n\t\t\t\t\tonMediaUploadStateReset={ () => {\n\t\t\t\t\t\tsetIsUploadInProgress( false );\n\t\t\t\t\t\tsetDidUploadFail( false );\n\t\t\t\t\t\tsetAttributes( { id: undefined, url: undefined } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\n\t\t\t\t{ IMAGE_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t<View style={ styles.imageContainer }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\teditButton={ false }\n\t\t\t\t\t\t\tfocalPoint={\n\t\t\t\t\t\t\t\tfocalPoint || IMAGE_DEFAULT_FOCAL_POINT\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisSelected={ isParentSelected }\n\t\t\t\t\t\t\tisUploadFailed={ didUploadFail }\n\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\tonSelectMediaUploadOption={ onSelectMedia }\n\t\t\t\t\t\t\topenMediaOptions={ openMediaOptionsRef.current }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\twidth={ styles.image?.width }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\n\t\t\t\t{ VIDEO_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t<Video\n\t\t\t\t\t\tmuted\n\t\t\t\t\t\tdisableFocus\n\t\t\t\t\t\trepeat\n\t\t\t\t\t\tresizeMode={ 'cover' }\n\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t\tonLoad={ onVideoLoad }\n\t\t\t\t\t\tonLoadStart={ onVideoLoadStart }\n\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\tstyles.background,\n\t\t\t\t\t\t\t// Hide Video component since it has black background while loading the source.\n\t\t\t\t\t\t\t{ opacity: isVideoLoading ? 0 : 1 },\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n\n\tif (\n\t\t( ! hasBackground && ! hasInnerBlocks ) ||\n\t\tisCustomColorPickerShowing\n\t) {\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t{ isCustomColorPickerShowing && colorPickerControls }\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\theight={\n\t\t\t\t\t\tstyles.mediaPlaceholderEmptyStateContainer?.height\n\t\t\t\t\t}\n\t\t\t\t\tbackgroundColor={ customOverlayColor }\n\t\t\t\t\thideContent={\n\t\t\t\t\t\tcustomOverlayColor !== '' &&\n\t\t\t\t\t\tcustomOverlayColor !== undefined\n\t\t\t\t\t}\n\t\t\t\t\ticon={ placeholderIcon }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'Cover' ),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t>\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ styles.colorPaletteWrapper }\n\t\t\t\t\t\tpointerEvents={\n\t\t\t\t\t\t\tisScreenReaderEnabled ? 'none' : 'auto'\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BottomSheetConsumer>\n\t\t\t\t\t\t\t{ ( { shouldEnableBottomSheetScroll } ) => (\n\t\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\t\tenableCustomColor={ true }\n\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles={\n\t\t\t\t\t\t\t\t\t\tstyles.paletteColorIndicator\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcustomIndicatorWrapperStyles={\n\t\t\t\t\t\t\t\t\t\tstyles.paletteCustomIndicatorWrapper\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetColor={ setColor }\n\t\t\t\t\t\t\t\t\tonCustomPress={ openColorPicker }\n\t\t\t\t\t\t\t\t\tdefaultSettings={ coverDefaultPalette }\n\t\t\t\t\t\t\t\t\tshouldShowCustomLabel={ false }\n\t\t\t\t\t\t\t\t\tshouldShowCustomVerticalSeparator={ false }\n\t\t\t\t\t\t\t\t\tshouldEnableBottomSheetScroll={\n\t\t\t\t\t\t\t\t\t\tshouldEnableBottomSheetScroll\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BottomSheetConsumer>\n\t\t\t\t\t</View>\n\t\t\t\t</MediaPlaceholder>\n\t\t\t</View>\n\t\t);\n\t}\n\n\treturn (\n\t\t<View style={ styles.backgroundContainer }>\n\t\t\t{ isSelected && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<Controls\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tdidUploadFail={ didUploadFail }\n\t\t\t\t\t\thasOnlyColorBackground={ hasOnlyColorBackground }\n\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\tonClearMedia={ onClearMedia }\n\t\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t/>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\n\t\t\t<View\n\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\tstyle={ [ styles.content, { minHeight: convertedMinHeight } ] }\n\t\t\t>\n\t\t\t\t<InnerBlocks\n\t\t\t\t\tallowedBlocks={ allowedBlocks }\n\t\t\t\t\ttemplate={ INNER_BLOCKS_TEMPLATE }\n\t\t\t\t\ttemplateLock={ templateLock }\n\t\t\t\t\ttemplateInsertUpdatesSelection\n\t\t\t\t\tblockWidth={ blockWidth }\n\t\t\t\t/>\n\t\t\t</View>\n\n\t\t\t<View pointerEvents=\"none\" style={ styles.overlayContainer }>\n\t\t\t\t<View style={ overlayStyles }>\n\t\t\t\t\t{ gradientValue && (\n\t\t\t\t\t\t<Gradient\n\t\t\t\t\t\t\tgradientValue={ gradientValue }\n\t\t\t\t\t\t\tstyle={ styles.background }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</View>\n\t\t\t</View>\n\n\t\t\t<MediaUpload\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tisReplacingMedia={ ! hasOnlyColorBackground }\n\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\topenMediaOptionsRef.current = open;\n\t\t\t\t\treturn renderContent( getMediaOptions );\n\t\t\t\t} }\n\t\t\t/>\n\n\t\t\t{ isImage &&\n\t\t\t\turl &&\n\t\t\t\topenMediaOptionsRef.current &&\n\t\t\t\tisParentSelected &&\n\t\t\t\t! isUploadInProgress &&\n\t\t\t\t! didUploadFail && (\n\t\t\t\t\t<View style={ styles.imageEditButton }>\n\t\t\t\t\t\t<ImageEditingButton\n\t\t\t\t\t\t\tonSelectMediaUploadOption={ onSelectMedia }\n\t\t\t\t\t\t\topenMediaOptions={ openMediaOptionsRef.current }\n\t\t\t\t\t\t\tpickerOptions={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tdestructiveButton: true,\n\t\t\t\t\t\t\t\t\tid: 'clearMedia',\n\t\t\t\t\t\t\t\t\tlabel: __( 'Clear Media' ),\n\t\t\t\t\t\t\t\t\tonPress: onClearMedia,\n\t\t\t\t\t\t\t\t\tseparated: true,\n\t\t\t\t\t\t\t\t\tvalue: 'clearMedia',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\n\t\t\t{ shouldShowFailure && (\n\t\t\t\t<View\n\t\t\t\t\tpointerEvents=\"none\"\n\t\t\t\t\tstyle={ styles.uploadFailedContainer }\n\t\t\t\t>\n\t\t\t\t\t<View style={ styles.uploadFailed }>\n\t\t\t\t\t\t<Icon icon={ warning } { ...styles.uploadFailedIcon } />\n\t\t\t\t\t</View>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t</View>\n\t);\n};\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => {\n\t\tconst { getSelectedBlockClientId, getBlock } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\tconst hasInnerBlocks = getBlock( clientId )?.innerBlocks.length > 0;\n\n\t\treturn {\n\t\t\tisParentSelected: selectedBlockClientId === clientId,\n\t\t\thasInnerBlocks,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { clientId } ) => {\n\t\tconst { openGeneralSidebar } = dispatch( editPostStore );\n\t\tconst { selectBlock } = dispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\topenGeneralSidebar: () => openGeneralSidebar( 'edit-post/block' ),\n\t\t\tcloseSettingsBottomSheet() {\n\t\t\t\tdispatch( editPostStore ).closeG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AAQ,CAAEtJ,kBAAiB,CAAC;EAEpD,OAAO;IACN/E,kBAAkB,EAAEA,CAAA,KAAMA,kBAAkB,CAAE,iBAAkB,CAAC;IACjEC,wBAAwBA,CAAA,EAAG;MAC1BoO,QAAQ,CAAEC,eAAc,CAAC,CAACC,mBAAmB,CAAC,CAAC;IAChD,CAAC;IACDpO,WAAW,EAAEA,CAAA,KAAMA,WAAW,CAAE2N,QAAS;EAC1C,CAAC;AACF,CAAE,CAAC,EACHU,iCAAwB,CACvB,CAAC,CAAE9O,KAAM,CAAC;AAAA+O,OAAA,CAAAjE,OAAA,GAAAkD,QAAA"}
|
package/build/embed/util.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.removeAspectRatioClasses = exports.matchesPatterns = exports.isFromWordP
|
|
|
12
12
|
var _react = require("react");
|
|
13
13
|
var _dedupe = _interopRequireDefault(require("classnames/dedupe"));
|
|
14
14
|
var _memize = _interopRequireDefault(require("memize"));
|
|
15
|
-
var
|
|
15
|
+
var _components = require("@wordpress/components");
|
|
16
16
|
var _element = require("@wordpress/element");
|
|
17
17
|
var _blocks = require("@wordpress/blocks");
|
|
18
18
|
var _constants = require("./constants");
|
|
@@ -80,9 +80,6 @@ const metadata = {
|
|
|
80
80
|
const {
|
|
81
81
|
name: DEFAULT_EMBED_BLOCK
|
|
82
82
|
} = metadata;
|
|
83
|
-
const {
|
|
84
|
-
kebabCase
|
|
85
|
-
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
86
83
|
|
|
87
84
|
/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
|
|
88
85
|
|
|
@@ -322,6 +319,9 @@ const getAttributesFromPreview = (0, _memize.default)((preview, title, currentCl
|
|
|
322
319
|
html,
|
|
323
320
|
provider_name: providerName
|
|
324
321
|
} = preview;
|
|
322
|
+
const {
|
|
323
|
+
kebabCase
|
|
324
|
+
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
325
325
|
const providerNameSlug = kebabCase((providerName || title).toLowerCase());
|
|
326
326
|
if (isFromWordPress(html)) {
|
|
327
327
|
type = _constants.WP_EMBED_TYPE;
|
package/build/embed/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dedupe","_interopRequireDefault","require","_memize","_blockEditor","_element","_blocks","_constants","_lockUnlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","url","type","__experimentalRole","caption","source","selector","providerNameSlug","allowResponsive","responsive","previewable","supports","align","spacing","margin","editorStyle","style","DEFAULT_EMBED_BLOCK","kebabCase","unlock","blockEditorPrivateApis","getEmbedInfoByProvider","provider","getBlockVariations","find","exports","matchesPatterns","patterns","some","pattern","match","findMoreSuitableBlock","isFromWordPress","html","includes","getPhotoHtml","photo","imageUrl","thumbnail_url","photoPreview","_react","createElement","src","alt","width","renderToString","createUpgradedEmbedBlock","props","attributesFromPreview","preview","restAttributes","getBlockType","matchedBlock","isCurrentBlockWP","WP_EMBED_TYPE","shouldCreateNewBlock","createBlock","wpVariation","hasAspectRatioClass","existingClassNames","ASPECT_RATIOS","className","removeAspectRatioClasses","aspectRatioClassNames","reduce","accumulator","classnames","getClassNames","previewDocument","document","implementation","createHTMLDocument","body","innerHTML","iframe","querySelector","height","aspectRatio","toFixed","ratioIndex","length","potentialRatio","ratio","ratioDiff","fallback","onReplace","link","href","content","getAttributesFromPreview","memoize","currentClassNames","isResponsive","provider_name","providerName","toLowerCase","getMergedAttributesWithPreview","currentAttributes"],"sources":["@wordpress/block-library/src/embed/util.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames/dedupe';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\nimport { unlock } from '../lock-unlock';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\nconst { kebabCase } = unlock( blockEditorPrivateApis );\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test agains.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return;\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Determine if the block already has an aspect ratio class applied.\n *\n * @param {string} existingClassNames Existing block classes.\n * @return {boolean} True or false if the classnames contain an aspect ratio class.\n */\nexport const hasAspectRatioClass = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\treturn false;\n\t}\n\treturn ASPECT_RATIOS.some( ( { className } ) =>\n\t\texistingClassNames.includes( className )\n\t);\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an emtpy string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator[ className ] = false;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ 'wp-has-aspect-ratio': false }\n\t);\n\treturn classnames( existingClassNames, aspectRatioClassNames );\n};\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn classnames(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\t// Aspect ratio classes are removed when the embed URL is updated.\n\t\t// If the embed already has an aspect ratio class, that means the URL has not changed.\n\t\t// Which also means no need to regenerate it with getClassNames.\n\t\tif ( hasAspectRatioClass( currentClassNames ) ) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tclassName,\n\t\t\tisResponsive,\n\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AAA,CAAAuE,8BAAA,GAAAA,8BAAA"}
|
|
1
|
+
{"version":3,"names":["_dedupe","_interopRequireDefault","require","_memize","_components","_element","_blocks","_constants","_lockUnlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","url","type","__experimentalRole","caption","source","selector","providerNameSlug","allowResponsive","responsive","previewable","supports","align","spacing","margin","editorStyle","style","DEFAULT_EMBED_BLOCK","getEmbedInfoByProvider","provider","getBlockVariations","find","exports","matchesPatterns","patterns","some","pattern","match","findMoreSuitableBlock","isFromWordPress","html","includes","getPhotoHtml","photo","imageUrl","thumbnail_url","photoPreview","_react","createElement","src","alt","width","renderToString","createUpgradedEmbedBlock","props","attributesFromPreview","preview","restAttributes","getBlockType","matchedBlock","isCurrentBlockWP","WP_EMBED_TYPE","shouldCreateNewBlock","createBlock","wpVariation","hasAspectRatioClass","existingClassNames","ASPECT_RATIOS","className","removeAspectRatioClasses","aspectRatioClassNames","reduce","accumulator","classnames","getClassNames","previewDocument","document","implementation","createHTMLDocument","body","innerHTML","iframe","querySelector","height","aspectRatio","toFixed","ratioIndex","length","potentialRatio","ratio","ratioDiff","fallback","onReplace","link","href","content","getAttributesFromPreview","memoize","currentClassNames","isResponsive","provider_name","providerName","kebabCase","unlock","componentsPrivateApis","toLowerCase","getMergedAttributesWithPreview","currentAttributes"],"sources":["@wordpress/block-library/src/embed/util.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames/dedupe';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\nimport { unlock } from '../lock-unlock';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test agains.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return;\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Determine if the block already has an aspect ratio class applied.\n *\n * @param {string} existingClassNames Existing block classes.\n * @return {boolean} True or false if the classnames contain an aspect ratio class.\n */\nexport const hasAspectRatioClass = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\treturn false;\n\t}\n\treturn ASPECT_RATIOS.some( ( { className } ) =>\n\t\texistingClassNames.includes( className )\n\t);\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an emtpy string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator[ className ] = false;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ 'wp-has-aspect-ratio': false }\n\t);\n\treturn classnames( existingClassNames, aspectRatioClassNames );\n};\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn classnames(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst { kebabCase } = unlock( componentsPrivateApis );\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\t// Aspect ratio classes are removed when the embed URL is updated.\n\t\t// If the embed already has an aspect ratio class, that means the URL has not changed.\n\t\t// Which also means no need to regenerate it with getClassNames.\n\t\tif ( hasAspectRatioClass( currentClassNames ) ) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tclassName,\n\t\t\tisResponsive,\n\t\t\tallowResponsive\n\t\t),\n\t};\n};\n"],"mappings":";;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,O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
63
63
|
}) {
|
|
64
64
|
const {
|
|
65
65
|
id,
|
|
66
|
-
fileId,
|
|
67
66
|
fileName,
|
|
68
67
|
href,
|
|
69
68
|
textLinkHref,
|
|
@@ -74,24 +73,24 @@ function FileEdit({
|
|
|
74
73
|
previewHeight
|
|
75
74
|
} = attributes;
|
|
76
75
|
const {
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
getSettings
|
|
77
|
+
} = (0, _data.useSelect)(_blockEditor.store);
|
|
78
|
+
const {
|
|
79
|
+
media
|
|
79
80
|
} = (0, _data.useSelect)(select => ({
|
|
80
|
-
media: id === undefined ? undefined : select(_coreData.store).getMedia(id)
|
|
81
|
-
mediaUpload: select(_blockEditor.store).getSettings().mediaUpload
|
|
81
|
+
media: id === undefined ? undefined : select(_coreData.store).getMedia(id)
|
|
82
82
|
}), [id]);
|
|
83
83
|
const {
|
|
84
84
|
createErrorNotice
|
|
85
85
|
} = (0, _data.useDispatch)(_notices.store);
|
|
86
86
|
const {
|
|
87
|
-
toggleSelection
|
|
88
|
-
__unstableMarkNextChangeAsNotPersistent
|
|
87
|
+
toggleSelection
|
|
89
88
|
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
90
89
|
(0, _element.useEffect)(() => {
|
|
91
90
|
// Upload a file drag-and-dropped into the editor.
|
|
92
91
|
if ((0, _blob.isBlobURL)(href)) {
|
|
93
92
|
const file = (0, _blob.getBlobByURL)(href);
|
|
94
|
-
mediaUpload({
|
|
93
|
+
getSettings().mediaUpload({
|
|
95
94
|
filesList: [file],
|
|
96
95
|
onFileChange: ([newMedia]) => onSelectFile(newMedia),
|
|
97
96
|
onError: onUploadError
|
|
@@ -104,27 +103,20 @@ function FileEdit({
|
|
|
104
103
|
});
|
|
105
104
|
}
|
|
106
105
|
}, []);
|
|
107
|
-
(0, _element.useEffect)(() => {
|
|
108
|
-
if (!fileId && href) {
|
|
109
|
-
// Add a unique fileId to each file block.
|
|
110
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
111
|
-
setAttributes({
|
|
112
|
-
fileId: `wp-block-file--media-${clientId}`
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}, [href, fileId, clientId]);
|
|
116
106
|
function onSelectFile(newMedia) {
|
|
117
|
-
if (newMedia
|
|
118
|
-
|
|
119
|
-
setAttributes({
|
|
120
|
-
href: newMedia.url,
|
|
121
|
-
fileName: newMedia.title,
|
|
122
|
-
textLinkHref: newMedia.url,
|
|
123
|
-
id: newMedia.id,
|
|
124
|
-
displayPreview: isPdf ? true : undefined,
|
|
125
|
-
previewHeight: isPdf ? 600 : undefined
|
|
126
|
-
});
|
|
107
|
+
if (!newMedia || !newMedia.url) {
|
|
108
|
+
return;
|
|
127
109
|
}
|
|
110
|
+
const isPdf = newMedia.url.endsWith('.pdf');
|
|
111
|
+
setAttributes({
|
|
112
|
+
href: newMedia.url,
|
|
113
|
+
fileName: newMedia.title,
|
|
114
|
+
textLinkHref: newMedia.url,
|
|
115
|
+
id: newMedia.id,
|
|
116
|
+
displayPreview: isPdf ? true : undefined,
|
|
117
|
+
previewHeight: isPdf ? 600 : undefined,
|
|
118
|
+
fileId: `wp-block-file--media-${clientId}`
|
|
119
|
+
});
|
|
128
120
|
}
|
|
129
121
|
function onUploadError(message) {
|
|
130
122
|
setAttributes({
|
package/build/file/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blob","_components","_data","_blockEditor","_element","_compose","_i18n","_icons","_coreData","_notices","_inspector","_utils","_removeAnchorTag","MIN_PREVIEW_HEIGHT","exports","MAX_PREVIEW_HEIGHT","ClipboardToolbarButton","text","disabled","createNotice","useDispatch","noticesStore","ref","useCopyToClipboard","__","isDismissible","type","_react","createElement","ToolbarButton","className","FileEdit","attributes","isSelected","setAttributes","clientId","id","fileId","fileName","href","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","media","mediaUpload","useSelect","select","undefined","coreStore","getMedia","blockEditorStore","getSettings","createErrorNotice","toggleSelection","__unstableMarkNextChangeAsNotPersistent","useEffect","isBlobURL","file","getBlobByURL","filesList","onFileChange","newMedia","onSelectFile","onError","onUploadError","revokeBlobURL","RichText","isEmpty","_x","url","isPdf","endsWith","title","message","changeLinkDestinationOption","newHref","changeOpenInNewWindow","newValue","changeShowDownloadButton","changeDisplayPreview","handleOnResizeStop","event","direction","elt","delta","newHeight","parseInt","height","changePreviewHeight","Math","max","attachmentPage","link","blockProps","useBlockProps","classnames","getAnimateClassName","displayPreviewInEditor","browserSupportsPdfs","MediaPlaceholder","icon","BlockIcon","labels","instructions","onSelect","accept","Fragment","default","hrefs","openInNewWindow","BlockControls","group","MediaReplaceFlow","mediaId","mediaURL","ResizableBox","size","minHeight","maxHeight","minWidth","grid","enable","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","onResizeStart","onResizeStop","showHandle","data","tagName","value","placeholder","withoutInteractiveFormatting","onChange","removeAnchorTag","__experimentalGetElementClassName","_default"],"sources":["@wordpress/block-library/src/file/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tResizableBox,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { file as icon } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport FileBlockInspector from './inspector';\nimport { browserSupportsPdfs } from './utils';\nimport removeAnchorTag from '../utils/remove-anchor-tag';\n\nexport const MIN_PREVIEW_HEIGHT = 200;\nexport const MAX_PREVIEW_HEIGHT = 2000;\n\nfunction ClipboardToolbarButton( { text, disabled } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( text, () => {\n\t\tcreateNotice( 'info', __( 'Copied URL to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tclassName=\"components-clipboard-toolbar-button\"\n\t\t\tref={ ref }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ __( 'Copy URL' ) }\n\t\t</ToolbarButton>\n\t);\n}\n\nfunction FileEdit( { attributes, isSelected, setAttributes, clientId } ) {\n\tconst {\n\t\tid,\n\t\tfileId,\n\t\tfileName,\n\t\thref,\n\t\ttextLinkHref,\n\t\ttextLinkTarget,\n\t\tshowDownloadButton,\n\t\tdownloadButtonText,\n\t\tdisplayPreview,\n\t\tpreviewHeight,\n\t} = attributes;\n\tconst { media, mediaUpload } = useSelect(\n\t\t( select ) => ( {\n\t\t\tmedia:\n\t\t\t\tid === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: select( coreStore ).getMedia( id ),\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t} ),\n\t\t[ id ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { toggleSelection, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Upload a file drag-and-dropped into the editor.\n\t\tif ( isBlobURL( href ) ) {\n\t\t\tconst file = getBlobByURL( href );\n\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList: [ file ],\n\t\t\t\tonFileChange: ( [ newMedia ] ) => onSelectFile( newMedia ),\n\t\t\t\tonError: onUploadError,\n\t\t\t} );\n\n\t\t\trevokeBlobURL( href );\n\t\t}\n\n\t\tif ( RichText.isEmpty( downloadButtonText ) ) {\n\t\t\tsetAttributes( {\n\t\t\t\tdownloadButtonText: _x( 'Download', 'button label' ),\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! fileId && href ) {\n\t\t\t// Add a unique fileId to each file block.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { fileId: `wp-block-file--media-${ clientId }` } );\n\t\t}\n\t}, [ href, fileId, clientId ] );\n\n\tfunction onSelectFile( newMedia ) {\n\t\tif ( newMedia && newMedia.url ) {\n\t\t\tconst isPdf = newMedia.url.endsWith( '.pdf' );\n\t\t\tsetAttributes( {\n\t\t\t\thref: newMedia.url,\n\t\t\t\tfileName: newMedia.title,\n\t\t\t\ttextLinkHref: newMedia.url,\n\t\t\t\tid: newMedia.id,\n\t\t\t\tdisplayPreview: isPdf ? true : undefined,\n\t\t\t\tpreviewHeight: isPdf ? 600 : undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tsetAttributes( { href: undefined } );\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tfunction changeLinkDestinationOption( newHref ) {\n\t\t// Choose Media File or Attachment Page (when file is in Media Library).\n\t\tsetAttributes( { textLinkHref: newHref } );\n\t}\n\n\tfunction changeOpenInNewWindow( newValue ) {\n\t\tsetAttributes( {\n\t\t\ttextLinkTarget: newValue ? '_blank' : false,\n\t\t} );\n\t}\n\n\tfunction changeShowDownloadButton( newValue ) {\n\t\tsetAttributes( { showDownloadButton: newValue } );\n\t}\n\n\tfunction changeDisplayPreview( newValue ) {\n\t\tsetAttributes( { displayPreview: newValue } );\n\t}\n\n\tfunction handleOnResizeStop( event, direction, elt, delta ) {\n\t\ttoggleSelection( true );\n\n\t\tconst newHeight = parseInt( previewHeight + delta.height, 10 );\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tfunction changePreviewHeight( newValue ) {\n\t\tconst newHeight = Math.max(\n\t\t\tparseInt( newValue, 10 ),\n\t\t\tMIN_PREVIEW_HEIGHT\n\t\t);\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tconst attachmentPage = media && media.link;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\tisBlobURL( href ) && getAnimateClassName( { type: 'loading' } ),\n\t\t\t{\n\t\t\t\t'is-transient': isBlobURL( href ),\n\t\t\t}\n\t\t),\n\t} );\n\n\tconst displayPreviewInEditor = browserSupportsPdfs() && displayPreview;\n\n\tif ( ! href ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'File' ),\n\t\t\t\t\t\tinstructions: __(\n\t\t\t\t\t\t\t'Upload a file or pick one from your media library.'\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<FileBlockInspector\n\t\t\t\threfs={ { href, textLinkHref, attachmentPage } }\n\t\t\t\t{ ...{\n\t\t\t\t\topenInNewWindow: !! textLinkTarget,\n\t\t\t\t\tshowDownloadButton,\n\t\t\t\t\tchangeLinkDestinationOption,\n\t\t\t\t\tchangeOpenInNewWindow,\n\t\t\t\t\tchangeShowDownloadButton,\n\t\t\t\t\tdisplayPreview,\n\t\t\t\t\tchangeDisplayPreview,\n\t\t\t\t\tpreviewHeight,\n\t\t\t\t\tchangePreviewHeight,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ href }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t\t<ClipboardToolbarButton\n\t\t\t\t\ttext={ href }\n\t\t\t\t\tdisabled={ isBlobURL( href ) }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ displayPreviewInEditor && (\n\t\t\t\t\t<ResizableBox\n\t\t\t\t\t\tsize={ { height: previewHeight } }\n\t\t\t\t\t\tminHeight={ MIN_PREVIEW_HEIGHT }\n\t\t\t\t\t\tmaxHeight={ MAX_PREVIEW_HEIGHT }\n\t\t\t\t\t\tminWidth=\"100%\"\n\t\t\t\t\t\tgrid={ [ 10, 10 ] }\n\t\t\t\t\t\tenable={ {\n\t\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\t\tright: false,\n\t\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResizeStart={ () => toggleSelection( false ) }\n\t\t\t\t\t\tonResizeStop={ handleOnResizeStop }\n\t\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t>\n\t\t\t\t\t\t<object\n\t\t\t\t\t\t\tclassName=\"wp-block-file__preview\"\n\t\t\t\t\t\t\tdata={ href }\n\t\t\t\t\t\t\ttype=\"application/pdf\"\n\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t'Embed of the selected PDF file.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isSelected && (\n\t\t\t\t\t\t\t<div className=\"wp-block-file__preview-overlay\" />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ResizableBox>\n\t\t\t\t) }\n\t\t\t\t<div className={ 'wp-block-file__content-wrapper' }>\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"a\"\n\t\t\t\t\t\tvalue={ fileName }\n\t\t\t\t\t\tplaceholder={ __( 'Write file name…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tfileName: removeAnchorTag( text ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thref={ textLinkHref }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showDownloadButton && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t'wp-block-file__button-richtext-wrapper'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ /* Using RichText here instead of PlainText so that it can be styled like a button. */ }\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\ttagName=\"div\" // Must be block-level or else cursor disappears.\n\t\t\t\t\t\t\t\taria-label={ __( 'Download button text' ) }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'wp-block-file__button',\n\t\t\t\t\t\t\t\t\t__experimentalGetElementClassName(\n\t\t\t\t\t\t\t\t\t\t'button'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tvalue={ downloadButtonText }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ __( 'Add text…' ) }\n\t\t\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tdownloadButtonText:\n\t\t\t\t\t\t\t\t\t\t\tremoveAnchorTag( text ),\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t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KAAK,EAAGpG,QAAU;IAClBqG,WAAW,EAAG,IAAAnH,QAAE,EAAE,kBAAmB,CAAG;IACxCoH,4BAA4B;IAC5BC,QAAQ,EAAK5H,IAAI,IAChBiB,aAAa,CAAE;MACdI,QAAQ,EAAE,IAAAwG,wBAAe,EAAE7H,IAAK;IACjC,CAAE,CACF;IACDsB,IAAI,EAAGC;EAAc,CACrB,CAAC,EACAE,kBAAkB,IACnB,IAAAf,MAAA,CAAAC,aAAA;IACCE,SAAS,EACR;EACA,GAGD,IAAAH,MAAA,CAAAC,aAAA,EAACzB,YAAA,CAAAkE,QAAQ;IACRoE,OAAO,EAAC,KAAK,CAAC;IAAA;IACd,cAAa,IAAAjH,QAAE,EAAE,sBAAuB,CAAG;IAC3CM,SAAS,EAAG,IAAAoE,mBAAU,EACrB,uBAAuB,EACvB,IAAA6C,8CAAiC,EAChC,QACD,CACD,CAAG;IACHL,KAAK,EAAG/F,kBAAoB;IAC5BiG,4BAA4B;IAC5BD,WAAW,EAAG,IAAAnH,QAAE,EAAE,WAAY,CAAG;IACjCqH,QAAQ,EAAK5H,IAAI,IAChBiB,aAAa,CAAE;MACdS,kBAAkB,EACjB,IAAAmG,wBAAe,EAAE7H,IAAK;IACxB,CAAE;EACF,CACD,CACG,CAEF,CACD,CACJ,CAAC;AAEL;AAAC,IAAA+H,QAAA,GAEcjH,QAAQ;AAAAjB,OAAA,CAAAgG,OAAA,GAAAkC,QAAA"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blob","_components","_data","_blockEditor","_element","_compose","_i18n","_icons","_coreData","_notices","_inspector","_utils","_removeAnchorTag","MIN_PREVIEW_HEIGHT","exports","MAX_PREVIEW_HEIGHT","ClipboardToolbarButton","text","disabled","createNotice","useDispatch","noticesStore","ref","useCopyToClipboard","__","isDismissible","type","_react","createElement","ToolbarButton","className","FileEdit","attributes","isSelected","setAttributes","clientId","id","fileName","href","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","getSettings","useSelect","blockEditorStore","media","select","undefined","coreStore","getMedia","createErrorNotice","toggleSelection","useEffect","isBlobURL","file","getBlobByURL","mediaUpload","filesList","onFileChange","newMedia","onSelectFile","onError","onUploadError","revokeBlobURL","RichText","isEmpty","_x","url","isPdf","endsWith","title","fileId","message","changeLinkDestinationOption","newHref","changeOpenInNewWindow","newValue","changeShowDownloadButton","changeDisplayPreview","handleOnResizeStop","event","direction","elt","delta","newHeight","parseInt","height","changePreviewHeight","Math","max","attachmentPage","link","blockProps","useBlockProps","classnames","getAnimateClassName","displayPreviewInEditor","browserSupportsPdfs","MediaPlaceholder","icon","BlockIcon","labels","instructions","onSelect","accept","Fragment","default","hrefs","openInNewWindow","BlockControls","group","MediaReplaceFlow","mediaId","mediaURL","ResizableBox","size","minHeight","maxHeight","minWidth","grid","enable","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","onResizeStart","onResizeStop","showHandle","data","tagName","value","placeholder","withoutInteractiveFormatting","onChange","removeAnchorTag","__experimentalGetElementClassName","_default"],"sources":["@wordpress/block-library/src/file/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tResizableBox,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { file as icon } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport FileBlockInspector from './inspector';\nimport { browserSupportsPdfs } from './utils';\nimport removeAnchorTag from '../utils/remove-anchor-tag';\n\nexport const MIN_PREVIEW_HEIGHT = 200;\nexport const MAX_PREVIEW_HEIGHT = 2000;\n\nfunction ClipboardToolbarButton( { text, disabled } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( text, () => {\n\t\tcreateNotice( 'info', __( 'Copied URL to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tclassName=\"components-clipboard-toolbar-button\"\n\t\t\tref={ ref }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ __( 'Copy URL' ) }\n\t\t</ToolbarButton>\n\t);\n}\n\nfunction FileEdit( { attributes, isSelected, setAttributes, clientId } ) {\n\tconst {\n\t\tid,\n\t\tfileName,\n\t\thref,\n\t\ttextLinkHref,\n\t\ttextLinkTarget,\n\t\tshowDownloadButton,\n\t\tdownloadButtonText,\n\t\tdisplayPreview,\n\t\tpreviewHeight,\n\t} = attributes;\n\tconst { getSettings } = useSelect( blockEditorStore );\n\tconst { media } = useSelect(\n\t\t( select ) => ( {\n\t\t\tmedia:\n\t\t\t\tid === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: select( coreStore ).getMedia( id ),\n\t\t} ),\n\t\t[ id ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { toggleSelection } = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Upload a file drag-and-dropped into the editor.\n\t\tif ( isBlobURL( href ) ) {\n\t\t\tconst file = getBlobByURL( href );\n\n\t\t\tgetSettings().mediaUpload( {\n\t\t\t\tfilesList: [ file ],\n\t\t\t\tonFileChange: ( [ newMedia ] ) => onSelectFile( newMedia ),\n\t\t\t\tonError: onUploadError,\n\t\t\t} );\n\n\t\t\trevokeBlobURL( href );\n\t\t}\n\n\t\tif ( RichText.isEmpty( downloadButtonText ) ) {\n\t\t\tsetAttributes( {\n\t\t\t\tdownloadButtonText: _x( 'Download', 'button label' ),\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\tfunction onSelectFile( newMedia ) {\n\t\tif ( ! newMedia || ! newMedia.url ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPdf = newMedia.url.endsWith( '.pdf' );\n\t\tsetAttributes( {\n\t\t\thref: newMedia.url,\n\t\t\tfileName: newMedia.title,\n\t\t\ttextLinkHref: newMedia.url,\n\t\t\tid: newMedia.id,\n\t\t\tdisplayPreview: isPdf ? true : undefined,\n\t\t\tpreviewHeight: isPdf ? 600 : undefined,\n\t\t\tfileId: `wp-block-file--media-${ clientId }`,\n\t\t} );\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tsetAttributes( { href: undefined } );\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tfunction changeLinkDestinationOption( newHref ) {\n\t\t// Choose Media File or Attachment Page (when file is in Media Library).\n\t\tsetAttributes( { textLinkHref: newHref } );\n\t}\n\n\tfunction changeOpenInNewWindow( newValue ) {\n\t\tsetAttributes( {\n\t\t\ttextLinkTarget: newValue ? '_blank' : false,\n\t\t} );\n\t}\n\n\tfunction changeShowDownloadButton( newValue ) {\n\t\tsetAttributes( { showDownloadButton: newValue } );\n\t}\n\n\tfunction changeDisplayPreview( newValue ) {\n\t\tsetAttributes( { displayPreview: newValue } );\n\t}\n\n\tfunction handleOnResizeStop( event, direction, elt, delta ) {\n\t\ttoggleSelection( true );\n\n\t\tconst newHeight = parseInt( previewHeight + delta.height, 10 );\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tfunction changePreviewHeight( newValue ) {\n\t\tconst newHeight = Math.max(\n\t\t\tparseInt( newValue, 10 ),\n\t\t\tMIN_PREVIEW_HEIGHT\n\t\t);\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tconst attachmentPage = media && media.link;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\tisBlobURL( href ) && getAnimateClassName( { type: 'loading' } ),\n\t\t\t{\n\t\t\t\t'is-transient': isBlobURL( href ),\n\t\t\t}\n\t\t),\n\t} );\n\n\tconst displayPreviewInEditor = browserSupportsPdfs() && displayPreview;\n\n\tif ( ! href ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'File' ),\n\t\t\t\t\t\tinstructions: __(\n\t\t\t\t\t\t\t'Upload a file or pick one from your media library.'\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<FileBlockInspector\n\t\t\t\threfs={ { href, textLinkHref, attachmentPage } }\n\t\t\t\t{ ...{\n\t\t\t\t\topenInNewWindow: !! textLinkTarget,\n\t\t\t\t\tshowDownloadButton,\n\t\t\t\t\tchangeLinkDestinationOption,\n\t\t\t\t\tchangeOpenInNewWindow,\n\t\t\t\t\tchangeShowDownloadButton,\n\t\t\t\t\tdisplayPreview,\n\t\t\t\t\tchangeDisplayPreview,\n\t\t\t\t\tpreviewHeight,\n\t\t\t\t\tchangePreviewHeight,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ href }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t\t<ClipboardToolbarButton\n\t\t\t\t\ttext={ href }\n\t\t\t\t\tdisabled={ isBlobURL( href ) }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ displayPreviewInEditor && (\n\t\t\t\t\t<ResizableBox\n\t\t\t\t\t\tsize={ { height: previewHeight } }\n\t\t\t\t\t\tminHeight={ MIN_PREVIEW_HEIGHT }\n\t\t\t\t\t\tmaxHeight={ MAX_PREVIEW_HEIGHT }\n\t\t\t\t\t\tminWidth=\"100%\"\n\t\t\t\t\t\tgrid={ [ 10, 10 ] }\n\t\t\t\t\t\tenable={ {\n\t\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\t\tright: false,\n\t\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResizeStart={ () => toggleSelection( false ) }\n\t\t\t\t\t\tonResizeStop={ handleOnResizeStop }\n\t\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t>\n\t\t\t\t\t\t<object\n\t\t\t\t\t\t\tclassName=\"wp-block-file__preview\"\n\t\t\t\t\t\t\tdata={ href }\n\t\t\t\t\t\t\ttype=\"application/pdf\"\n\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t'Embed of the selected PDF file.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isSelected && (\n\t\t\t\t\t\t\t<div className=\"wp-block-file__preview-overlay\" />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ResizableBox>\n\t\t\t\t) }\n\t\t\t\t<div className={ 'wp-block-file__content-wrapper' }>\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"a\"\n\t\t\t\t\t\tvalue={ fileName }\n\t\t\t\t\t\tplaceholder={ __( 'Write file name…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tfileName: removeAnchorTag( text ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thref={ textLinkHref }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showDownloadButton && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t'wp-block-file__button-richtext-wrapper'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ /* Using RichText here instead of PlainText so that it can be styled like a button. */ }\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\ttagName=\"div\" // Must be block-level or else cursor disappears.\n\t\t\t\t\t\t\t\taria-label={ __( 'Download button text' ) }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'wp-block-file__button',\n\t\t\t\t\t\t\t\t\t__experimentalGetElementClassName(\n\t\t\t\t\t\t\t\t\t\t'button'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tvalue={ downloadButtonText }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ __( 'Add text…' ) }\n\t\t\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tdownloadButtonText:\n\t\t\t\t\t\t\t\t\t\t\tremoveAnchorTag( text ),\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default FileEdit;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OA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AAA;IACd,cAAa,IAAAhH,QAAE,EAAE,sBAAuB,CAAG;IAC3CM,SAAS,EAAG,IAAAmE,mBAAU,EACrB,uBAAuB,EACvB,IAAA6C,8CAAiC,EAChC,QACD,CACD,CAAG;IACHL,KAAK,EAAG/F,kBAAoB;IAC5BiG,4BAA4B;IAC5BD,WAAW,EAAG,IAAAlH,QAAE,EAAE,WAAY,CAAG;IACjCoH,QAAQ,EAAK3H,IAAI,IAChBiB,aAAa,CAAE;MACdQ,kBAAkB,EACjB,IAAAmG,wBAAe,EAAE5H,IAAK;IACxB,CAAE;EACF,CACD,CACG,CAEF,CACD,CACJ,CAAC;AAEL;AAAC,IAAA8H,QAAA,GAEchH,QAAQ;AAAAjB,OAAA,CAAA+F,OAAA,GAAAkC,QAAA"}
|
package/build/gallery/edit.js
CHANGED
|
@@ -57,6 +57,7 @@ const PLACEHOLDER_TEXT = _element.Platform.isNative ? (0, _i18n.__)('Add media')
|
|
|
57
57
|
const MOBILE_CONTROL_PROPS_RANGE_CONTROL = _element.Platform.isNative ? {
|
|
58
58
|
type: 'stepper'
|
|
59
59
|
} : {};
|
|
60
|
+
const EMPTY_ARRAY = [];
|
|
60
61
|
function GalleryEdit(props) {
|
|
61
62
|
const {
|
|
62
63
|
setAttributes,
|
|
@@ -71,6 +72,7 @@ function GalleryEdit(props) {
|
|
|
71
72
|
const {
|
|
72
73
|
columns,
|
|
73
74
|
imageCrop,
|
|
75
|
+
randomOrder,
|
|
74
76
|
linkTarget,
|
|
75
77
|
linkTo,
|
|
76
78
|
sizeSlug
|
|
@@ -88,23 +90,29 @@ function GalleryEdit(props) {
|
|
|
88
90
|
const {
|
|
89
91
|
getBlock,
|
|
90
92
|
getSettings,
|
|
91
|
-
preferredStyle
|
|
93
|
+
preferredStyle,
|
|
94
|
+
innerBlockImages,
|
|
95
|
+
blockWasJustInserted,
|
|
96
|
+
multiGallerySelection
|
|
92
97
|
} = (0, _data.useSelect)(select => {
|
|
93
|
-
|
|
94
|
-
const
|
|
98
|
+
var _getBlock$innerBlocks;
|
|
99
|
+
const {
|
|
100
|
+
getBlockName,
|
|
101
|
+
getMultiSelectedBlockClientIds,
|
|
102
|
+
getSettings: _getSettings,
|
|
103
|
+
getBlock: _getBlock,
|
|
104
|
+
wasBlockJustInserted
|
|
105
|
+
} = select(_blockEditor.store);
|
|
106
|
+
const preferredStyleVariations = _getSettings().__experimentalPreferredStyleVariations;
|
|
107
|
+
const multiSelectedClientIds = getMultiSelectedBlockClientIds();
|
|
95
108
|
return {
|
|
96
|
-
getBlock:
|
|
97
|
-
getSettings:
|
|
98
|
-
preferredStyle: preferredStyleVariations?.value?.['core/image']
|
|
109
|
+
getBlock: _getBlock,
|
|
110
|
+
getSettings: _getSettings,
|
|
111
|
+
preferredStyle: preferredStyleVariations?.value?.['core/image'],
|
|
112
|
+
innerBlockImages: (_getBlock$innerBlocks = _getBlock(clientId)?.innerBlocks) !== null && _getBlock$innerBlocks !== void 0 ? _getBlock$innerBlocks : EMPTY_ARRAY,
|
|
113
|
+
blockWasJustInserted: wasBlockJustInserted(clientId, 'inserter_menu'),
|
|
114
|
+
multiGallerySelection: multiSelectedClientIds.length && multiSelectedClientIds.every(_clientId => getBlockName(_clientId) === 'core/gallery')
|
|
99
115
|
};
|
|
100
|
-
}, []);
|
|
101
|
-
const innerBlockImages = (0, _data.useSelect)(select => {
|
|
102
|
-
var _select$getBlock$inne;
|
|
103
|
-
const innerBlocks = (_select$getBlock$inne = select(_blockEditor.store).getBlock(clientId)?.innerBlocks) !== null && _select$getBlock$inne !== void 0 ? _select$getBlock$inne : [];
|
|
104
|
-
return innerBlocks;
|
|
105
|
-
}, [clientId]);
|
|
106
|
-
const wasBlockJustInserted = (0, _data.useSelect)(select => {
|
|
107
|
-
return select(_blockEditor.store).wasBlockJustInserted(clientId, 'inserter_menu');
|
|
108
116
|
}, [clientId]);
|
|
109
117
|
const images = (0, _element.useMemo)(() => innerBlockImages?.map(block => ({
|
|
110
118
|
clientId: block.clientId,
|
|
@@ -264,6 +272,11 @@ function GalleryEdit(props) {
|
|
|
264
272
|
function getImageCropHelp(checked) {
|
|
265
273
|
return checked ? (0, _i18n.__)('Thumbnails are cropped to align.') : (0, _i18n.__)('Thumbnails are not cropped.');
|
|
266
274
|
}
|
|
275
|
+
function toggleRandomOrder() {
|
|
276
|
+
setAttributes({
|
|
277
|
+
randomOrder: !randomOrder
|
|
278
|
+
});
|
|
279
|
+
}
|
|
267
280
|
function toggleOpenInNewTab(openInNewTab) {
|
|
268
281
|
const newLinkTarget = openInNewTab ? '_blank' : undefined;
|
|
269
282
|
setAttributes({
|
|
@@ -328,7 +341,7 @@ function GalleryEdit(props) {
|
|
|
328
341
|
isAppender: hasImages,
|
|
329
342
|
disableMediaButtons: hasImages && !isSelected || imagesUploading,
|
|
330
343
|
value: hasImageIds ? images : {},
|
|
331
|
-
autoOpenMediaUpload: !hasImages && isSelected &&
|
|
344
|
+
autoOpenMediaUpload: !hasImages && isSelected && blockWasJustInserted,
|
|
332
345
|
onFocus
|
|
333
346
|
}
|
|
334
347
|
});
|
|
@@ -383,6 +396,11 @@ function GalleryEdit(props) {
|
|
|
383
396
|
checked: !!imageCrop,
|
|
384
397
|
onChange: toggleImageCrop,
|
|
385
398
|
help: getImageCropHelp
|
|
399
|
+
}), (0, _react.createElement)(_components.ToggleControl, {
|
|
400
|
+
__nextHasNoMarginBottom: true,
|
|
401
|
+
label: (0, _i18n.__)('Random order'),
|
|
402
|
+
checked: !!randomOrder,
|
|
403
|
+
onChange: toggleRandomOrder
|
|
386
404
|
}), (0, _react.createElement)(_components.SelectControl, {
|
|
387
405
|
__nextHasNoMarginBottom: true,
|
|
388
406
|
label: (0, _i18n.__)('Link to'),
|
|
@@ -409,7 +427,7 @@ function GalleryEdit(props) {
|
|
|
409
427
|
className: 'gallery-image-sizes'
|
|
410
428
|
}, (0, _react.createElement)(_components.BaseControl.VisualLabel, null, (0, _i18n.__)('Resolution')), (0, _react.createElement)(_primitives.View, {
|
|
411
429
|
className: 'gallery-image-sizes__loading'
|
|
412
|
-
}, (0, _react.createElement)(_components.Spinner, null), (0, _i18n.__)('Loading options…'))))), _element.Platform.isWeb && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_blockEditor.BlockControls, {
|
|
430
|
+
}, (0, _react.createElement)(_components.Spinner, null), (0, _i18n.__)('Loading options…'))))), _element.Platform.isWeb && (0, _react.createElement)(_react.Fragment, null, !multiGallerySelection && (0, _react.createElement)(_blockEditor.BlockControls, {
|
|
413
431
|
group: "other"
|
|
414
432
|
}, (0, _react.createElement)(_blockEditor.MediaReplaceFlow, {
|
|
415
433
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
@@ -429,7 +447,8 @@ function GalleryEdit(props) {
|
|
|
429
447
|
images: images,
|
|
430
448
|
mediaPlaceholder: !hasImages || _element.Platform.isNative ? mediaPlaceholder : undefined,
|
|
431
449
|
blockProps: innerBlocksProps,
|
|
432
|
-
insertBlocksAfter: insertBlocksAfter
|
|
450
|
+
insertBlocksAfter: insertBlocksAfter,
|
|
451
|
+
multiGallerySelection: multiGallerySelection
|
|
433
452
|
}));
|
|
434
453
|
}
|
|
435
454
|
var _default = (0, _compose.compose)([(0, _viewport.withViewportMatch)({
|