@wordpress/media-utils 5.32.0 → 5.32.1-next.47f435fc9.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/build/components/index.js +36 -11
- package/build/components/index.js.map +7 -1
- package/build/components/media-upload/index.js +156 -221
- package/build/components/media-upload/index.js.map +7 -1
- package/build/index.js +44 -65
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/private-apis.js +31 -17
- package/build/private-apis.js.map +7 -1
- package/build/utils/flatten-form-data.js +28 -20
- package/build/utils/flatten-form-data.js.map +7 -1
- package/build/utils/get-mime-types-array.js +38 -20
- package/build/utils/get-mime-types-array.js.map +7 -1
- package/build/utils/sideload-media.js +50 -38
- package/build/utils/sideload-media.js.map +7 -1
- package/build/utils/sideload-to-server.js +53 -36
- package/build/utils/sideload-to-server.js.map +7 -1
- package/build/utils/transform-attachment.js +29 -23
- package/build/utils/transform-attachment.js.map +7 -1
- package/build/utils/types.js +16 -5
- package/build/utils/types.js.map +7 -1
- package/build/utils/upload-error.js +30 -21
- package/build/utils/upload-error.js.map +7 -1
- package/build/utils/upload-media.js +62 -71
- package/build/utils/upload-media.js.map +7 -1
- package/build/utils/upload-to-server.js +54 -27
- package/build/utils/upload-to-server.js.map +7 -1
- package/build/utils/validate-file-size.js +44 -32
- package/build/utils/validate-file-size.js.map +7 -1
- package/build/utils/validate-mime-type-for-user.js +42 -30
- package/build/utils/validate-mime-type-for-user.js.map +7 -1
- package/build/utils/validate-mime-type.js +37 -32
- package/build/utils/validate-mime-type.js.map +7 -1
- package/build-module/components/index.js +5 -2
- package/build-module/components/index.js.map +7 -1
- package/build-module/components/media-upload/index.js +137 -215
- package/build-module/components/media-upload/index.js.map +7 -1
- package/build-module/index.js +16 -8
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/private-apis.js +7 -11
- package/build-module/private-apis.js.map +7 -1
- package/build-module/utils/flatten-form-data.js +7 -17
- package/build-module/utils/flatten-form-data.js.map +7 -1
- package/build-module/utils/get-mime-types-array.js +17 -17
- package/build-module/utils/get-mime-types-array.js.map +7 -1
- package/build-module/utils/sideload-media.js +28 -34
- package/build-module/utils/sideload-media.js.map +7 -1
- package/build-module/utils/sideload-to-server.js +22 -33
- package/build-module/utils/sideload-to-server.js.map +7 -1
- package/build-module/utils/transform-attachment.js +8 -20
- package/build-module/utils/transform-attachment.js.map +7 -1
- package/build-module/utils/types.js +1 -2
- package/build-module/utils/types.js.map +7 -1
- package/build-module/utils/upload-error.js +9 -17
- package/build-module/utils/upload-error.js.map +7 -1
- package/build-module/utils/upload-media.js +36 -63
- package/build-module/utils/upload-media.js.map +7 -1
- package/build-module/utils/upload-to-server.js +23 -22
- package/build-module/utils/upload-to-server.js.map +7 -1
- package/build-module/utils/validate-file-size.js +19 -25
- package/build-module/utils/validate-file-size.js.map +7 -1
- package/build-module/utils/validate-mime-type-for-user.js +18 -24
- package/build-module/utils/validate-mime-type-for-user.js.map +7 -1
- package/build-module/utils/validate-mime-type.js +14 -27
- package/build-module/utils/validate-mime-type.js.map +7 -1
- package/package.json +15 -8
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["Component","__","DEFAULT_EMPTY_GALLERY","getFeaturedImageMediaFrame","wp","window","media","view","MediaFrame","Select","extend","featuredImageToolbar","toolbar","createSelectToolbar","text","l10n","setFeaturedImage","state","options","editState","selection","get","EditImage","model","single","controller","render","content","set","loadEditor","createStates","on","states","add","FeaturedImage","editImage","getSingleMediaFrame","Library","library","query","multiple","title","priority","filterable","getGalleryDetailsMediaFrame","Post","galleryToolbar","editing","Toolbar","items","insert","style","updateGallery","insertGallery","requires","click","close","trigger","setState","reset","id","createGalleryTitle","editable","type","GalleryEdit","menu","displaySettings","GalleryAdd","slimImageObject","img","attrSet","reduce","result","key","hasOwnProperty","getAttachmentsCollection","ids","order","orderby","post__in","posts_per_page","MediaUpload","constructor","arguments","openModal","bind","onOpen","onSelect","onUpdate","onClose","initializeListeners","frame","buildAndSetGalleryFrame","addToGallery","allowedTypes","value","props","lastGalleryValue","remove","currentState","length","GalleryDetailsMediaFrame","attachments","Selection","models","toJSON","mimeType","buildAndSetFeatureImageFrame","featuredImageId","featuredImageFrame","settings","post","buildAndSetSingleMediaFrame","frameConfig","singleImageFrame","componentWillUnmount","selections","selectedImages","map","attachment","updateCollection","mode","hasMedia","Array","isArray","isGallery","gallery","valueArray","forEach","more","done","detach","frameContent","collection","toArray","mirroring","_hasMore","unstableFeaturedImageFlow","modalClass","$el","addClass","open"],"sources":["@wordpress/media-utils/src/components/media-upload/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nconst DEFAULT_EMPTY_GALLERY = [];\n\n/**\n * Prepares the Featured Image toolbars and frames.\n *\n * @return {window.wp.media.view.MediaFrame.Select} The default media workflow.\n */\nconst getFeaturedImageMediaFrame = () => {\n\tconst { wp } = window;\n\n\treturn wp.media.view.MediaFrame.Select.extend( {\n\t\t/**\n\t\t * Enables the Set Featured Image Button.\n\t\t *\n\t\t * @param {Object} toolbar toolbar for featured image state\n\t\t * @return {void}\n\t\t */\n\t\tfeaturedImageToolbar( toolbar ) {\n\t\t\tthis.createSelectToolbar( toolbar, {\n\t\t\t\ttext: wp.media.view.l10n.setFeaturedImage,\n\t\t\t\tstate: this.options.state,\n\t\t\t} );\n\t\t},\n\n\t\t/**\n\t\t * Handle the edit state requirements of selected media item.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\teditState() {\n\t\t\tconst selection = this.state( 'featured-image' ).get( 'selection' );\n\t\t\tconst view = new wp.media.view.EditImage( {\n\t\t\t\tmodel: selection.single(),\n\t\t\t\tcontroller: this,\n\t\t\t} ).render();\n\n\t\t\t// Set the view to the EditImage frame using the selected image.\n\t\t\tthis.content.set( view );\n\n\t\t\t// After bringing in the frame, load the actual editor via an ajax call.\n\t\t\tview.loadEditor();\n\t\t},\n\n\t\t/**\n\t\t * Create the default states.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tcreateStates: function createStates() {\n\t\t\tthis.on(\n\t\t\t\t'toolbar:create:featured-image',\n\t\t\t\tthis.featuredImageToolbar,\n\t\t\t\tthis\n\t\t\t);\n\t\t\tthis.on( 'content:render:edit-image', this.editState, this );\n\n\t\t\tthis.states.add( [\n\t\t\t\tnew wp.media.controller.FeaturedImage(),\n\t\t\t\tnew wp.media.controller.EditImage( {\n\t\t\t\t\tmodel: this.options.editImage,\n\t\t\t\t} ),\n\t\t\t] );\n\t\t},\n\t} );\n};\n\n/**\n * Prepares the default frame for selecting a single media item.\n *\n * @return {window.wp.media.view.MediaFrame.Select} The default media workflow.\n */\nconst getSingleMediaFrame = () => {\n\tconst { wp } = window;\n\n\t// Extend the default Select frame, and use the same `createStates` method as in core,\n\t// but with the addition of `filterable: 'uploaded'` to the Library state, so that\n\t// the user can filter the media library by uploaded media.\n\treturn wp.media.view.MediaFrame.Select.extend( {\n\t\t/**\n\t\t * Create the default states on the frame.\n\t\t */\n\t\tcreateStates() {\n\t\t\tconst options = this.options;\n\n\t\t\tif ( this.options.states ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Add the default states.\n\t\t\tthis.states.add( [\n\t\t\t\t// Main states.\n\t\t\t\tnew wp.media.controller.Library( {\n\t\t\t\t\tlibrary: wp.media.query( options.library ),\n\t\t\t\t\tmultiple: options.multiple,\n\t\t\t\t\ttitle: options.title,\n\t\t\t\t\tpriority: 20,\n\t\t\t\t\tfilterable: 'uploaded', // Allow filtering by uploaded images.\n\t\t\t\t} ),\n\t\t\t\tnew wp.media.controller.EditImage( {\n\t\t\t\t\tmodel: options.editImage,\n\t\t\t\t} ),\n\t\t\t] );\n\t\t},\n\t} );\n};\n\n/**\n * Prepares the Gallery toolbars and frames.\n *\n * @return {window.wp.media.view.MediaFrame.Post} The default media workflow.\n */\nconst getGalleryDetailsMediaFrame = () => {\n\tconst { wp } = window;\n\t/**\n\t * Custom gallery details frame.\n\t *\n\t * @see https://github.com/xwp/wp-core-media-widgets/blob/905edbccfc2a623b73a93dac803c5335519d7837/wp-admin/js/widgets/media-gallery-widget.js\n\t * @class GalleryDetailsMediaFrame\n\t * @class\n\t */\n\treturn wp.media.view.MediaFrame.Post.extend( {\n\t\t/**\n\t\t * Set up gallery toolbar.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tgalleryToolbar() {\n\t\t\tconst editing = this.state().get( 'editing' );\n\t\t\tthis.toolbar.set(\n\t\t\t\tnew wp.media.view.Toolbar( {\n\t\t\t\t\tcontroller: this,\n\t\t\t\t\titems: {\n\t\t\t\t\t\tinsert: {\n\t\t\t\t\t\t\tstyle: 'primary',\n\t\t\t\t\t\t\ttext: editing\n\t\t\t\t\t\t\t\t? wp.media.view.l10n.updateGallery\n\t\t\t\t\t\t\t\t: wp.media.view.l10n.insertGallery,\n\t\t\t\t\t\t\tpriority: 80,\n\t\t\t\t\t\t\trequires: { library: true },\n\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * @fires wp.media.controller.State#update\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tclick() {\n\t\t\t\t\t\t\t\tconst controller = this.controller,\n\t\t\t\t\t\t\t\t\tstate = controller.state();\n\n\t\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\t\tstate.trigger(\n\t\t\t\t\t\t\t\t\t'update',\n\t\t\t\t\t\t\t\t\tstate.get( 'library' )\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t// Restore and reset the default state.\n\t\t\t\t\t\t\t\tcontroller.setState( controller.options.state );\n\t\t\t\t\t\t\t\tcontroller.reset();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\n\t\t/**\n\t\t * Handle the edit state requirements of selected media item.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\teditState() {\n\t\t\tconst selection = this.state( 'gallery' ).get( 'selection' );\n\t\t\tconst view = new wp.media.view.EditImage( {\n\t\t\t\tmodel: selection.single(),\n\t\t\t\tcontroller: this,\n\t\t\t} ).render();\n\n\t\t\t// Set the view to the EditImage frame using the selected image.\n\t\t\tthis.content.set( view );\n\n\t\t\t// After bringing in the frame, load the actual editor via an ajax call.\n\t\t\tview.loadEditor();\n\t\t},\n\n\t\t/**\n\t\t * Create the default states.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tcreateStates: function createStates() {\n\t\t\tthis.on( 'toolbar:create:main-gallery', this.galleryToolbar, this );\n\t\t\tthis.on( 'content:render:edit-image', this.editState, this );\n\n\t\t\tthis.states.add( [\n\t\t\t\tnew wp.media.controller.Library( {\n\t\t\t\t\tid: 'gallery',\n\t\t\t\t\ttitle: wp.media.view.l10n.createGalleryTitle,\n\t\t\t\t\tpriority: 40,\n\t\t\t\t\ttoolbar: 'main-gallery',\n\t\t\t\t\tfilterable: 'uploaded',\n\t\t\t\t\tmultiple: 'add',\n\t\t\t\t\teditable: false,\n\n\t\t\t\t\tlibrary: wp.media.query( {\n\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\t...this.options.library,\n\t\t\t\t\t} ),\n\t\t\t\t} ),\n\t\t\t\tnew wp.media.controller.EditImage( {\n\t\t\t\t\tmodel: this.options.editImage,\n\t\t\t\t} ),\n\n\t\t\t\tnew wp.media.controller.GalleryEdit( {\n\t\t\t\t\tlibrary: this.options.selection,\n\t\t\t\t\tediting: this.options.editing,\n\t\t\t\t\tmenu: 'gallery',\n\t\t\t\t\tdisplaySettings: false,\n\t\t\t\t\tmultiple: true,\n\t\t\t\t} ),\n\n\t\t\t\tnew wp.media.controller.GalleryAdd(),\n\t\t\t] );\n\t\t},\n\t} );\n};\n\n// The media library image object contains numerous attributes\n// we only need this set to display the image in the library.\nconst slimImageObject = ( img ) => {\n\tconst attrSet = [\n\t\t'sizes',\n\t\t'mime',\n\t\t'type',\n\t\t'subtype',\n\t\t'id',\n\t\t'url',\n\t\t'alt',\n\t\t'link',\n\t\t'caption',\n\t];\n\treturn attrSet.reduce( ( result, key ) => {\n\t\tif ( img?.hasOwnProperty( key ) ) {\n\t\t\tresult[ key ] = img[ key ];\n\t\t}\n\t\treturn result;\n\t}, {} );\n};\n\nconst getAttachmentsCollection = ( ids ) => {\n\tconst { wp } = window;\n\n\treturn wp.media.query( {\n\t\torder: 'ASC',\n\t\torderby: 'post__in',\n\t\tpost__in: ids,\n\t\tposts_per_page: -1,\n\t\tquery: true,\n\t\ttype: 'image',\n\t} );\n};\n\nclass MediaUpload extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.openModal = this.openModal.bind( this );\n\t\tthis.onOpen = this.onOpen.bind( this );\n\t\tthis.onSelect = this.onSelect.bind( this );\n\t\tthis.onUpdate = this.onUpdate.bind( this );\n\t\tthis.onClose = this.onClose.bind( this );\n\t}\n\n\tinitializeListeners() {\n\t\t// When an image is selected in the media frame...\n\t\tthis.frame.on( 'select', this.onSelect );\n\t\tthis.frame.on( 'update', this.onUpdate );\n\t\tthis.frame.on( 'open', this.onOpen );\n\t\tthis.frame.on( 'close', this.onClose );\n\t}\n\n\t/**\n\t * Sets the Gallery frame and initializes listeners.\n\t *\n\t * @return {void}\n\t */\n\tbuildAndSetGalleryFrame() {\n\t\tconst {\n\t\t\taddToGallery = false,\n\t\t\tallowedTypes,\n\t\t\tmultiple = false,\n\t\t\tvalue = DEFAULT_EMPTY_GALLERY,\n\t\t} = this.props;\n\n\t\t// If the value did not changed there is no need to rebuild the frame,\n\t\t// we can continue to use the existing one.\n\t\tif ( value === this.lastGalleryValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { wp } = window;\n\n\t\tthis.lastGalleryValue = value;\n\n\t\t// If a frame already existed remove it.\n\t\tif ( this.frame ) {\n\t\t\tthis.frame.remove();\n\t\t}\n\t\tlet currentState;\n\t\tif ( addToGallery ) {\n\t\t\tcurrentState = 'gallery-library';\n\t\t} else {\n\t\t\tcurrentState = value && value.length ? 'gallery-edit' : 'gallery';\n\t\t}\n\t\tif ( ! this.GalleryDetailsMediaFrame ) {\n\t\t\tthis.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();\n\t\t}\n\t\tconst attachments = getAttachmentsCollection( value );\n\t\tconst selection = new wp.media.model.Selection( attachments.models, {\n\t\t\tprops: attachments.props.toJSON(),\n\t\t\tmultiple,\n\t\t} );\n\t\tthis.frame = new this.GalleryDetailsMediaFrame( {\n\t\t\tmimeType: allowedTypes,\n\t\t\tstate: currentState,\n\t\t\tmultiple,\n\t\t\tselection,\n\t\t\tediting: !! value?.length,\n\t\t} );\n\t\twp.media.frame = this.frame;\n\t\tthis.initializeListeners();\n\t}\n\n\t/**\n\t * Initializes the Media Library requirements for the featured image flow.\n\t *\n\t * @return {void}\n\t */\n\tbuildAndSetFeatureImageFrame() {\n\t\tconst { wp } = window;\n\t\tconst { value: featuredImageId, multiple, allowedTypes } = this.props;\n\t\tconst featuredImageFrame = getFeaturedImageMediaFrame();\n\t\tconst attachments = getAttachmentsCollection( featuredImageId );\n\t\tconst selection = new wp.media.model.Selection( attachments.models, {\n\t\t\tprops: attachments.props.toJSON(),\n\t\t} );\n\t\tthis.frame = new featuredImageFrame( {\n\t\t\tmimeType: allowedTypes,\n\t\t\tstate: 'featured-image',\n\t\t\tmultiple,\n\t\t\tselection,\n\t\t\tediting: featuredImageId,\n\t\t} );\n\t\twp.media.frame = this.frame;\n\t\t// In order to select the current featured image when opening\n\t\t// the media library we have to set the appropriate settings.\n\t\t// Currently they are set in php for the post editor, but\n\t\t// not for site editor.\n\t\twp.media.view.settings.post = {\n\t\t\t...wp.media.view.settings.post,\n\t\t\tfeaturedImageId: featuredImageId || -1,\n\t\t};\n\t}\n\n\t/**\n\t * Initializes the Media Library requirements for the single image flow.\n\t *\n\t * @return {void}\n\t */\n\tbuildAndSetSingleMediaFrame() {\n\t\tconst { wp } = window;\n\t\tconst {\n\t\t\tallowedTypes,\n\t\t\tmultiple = false,\n\t\t\ttitle = __( 'Select or Upload Media' ),\n\t\t\tvalue,\n\t\t} = this.props;\n\n\t\tconst frameConfig = {\n\t\t\ttitle,\n\t\t\tmultiple,\n\t\t};\n\t\tif ( !! allowedTypes ) {\n\t\t\tframeConfig.library = { type: allowedTypes };\n\t\t}\n\n\t\t// If a frame already exists, remove it.\n\t\tif ( this.frame ) {\n\t\t\tthis.frame.remove();\n\t\t}\n\n\t\tconst singleImageFrame = getSingleMediaFrame();\n\t\tconst attachments = getAttachmentsCollection( value );\n\t\tconst selection = new wp.media.model.Selection( attachments.models, {\n\t\t\tprops: attachments.props.toJSON(),\n\t\t} );\n\t\tthis.frame = new singleImageFrame( {\n\t\t\tmimeType: allowedTypes,\n\t\t\tmultiple,\n\t\t\tselection,\n\t\t\t...frameConfig,\n\t\t} );\n\t\twp.media.frame = this.frame;\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.frame?.remove();\n\t}\n\n\tonUpdate( selections ) {\n\t\tconst { onSelect, multiple = false } = this.props;\n\t\tconst state = this.frame.state();\n\t\tconst selectedImages = selections || state.get( 'selection' );\n\n\t\tif ( ! selectedImages || ! selectedImages.models.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( multiple ) {\n\t\t\tonSelect(\n\t\t\t\tselectedImages.models.map( ( model ) =>\n\t\t\t\t\tslimImageObject( model.toJSON() )\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\tonSelect( slimImageObject( selectedImages.models[ 0 ].toJSON() ) );\n\t\t}\n\t}\n\n\tonSelect() {\n\t\tconst { onSelect, multiple = false } = this.props;\n\t\t// Get media attachment details from the frame state.\n\t\tconst attachment = this.frame.state().get( 'selection' ).toJSON();\n\t\tonSelect( multiple ? attachment : attachment[ 0 ] );\n\t}\n\n\tonOpen() {\n\t\tconst { wp } = window;\n\t\tconst { value } = this.props;\n\t\tthis.updateCollection();\n\n\t\t//Handle active tab in media model on model open.\n\t\tif ( this.props.mode ) {\n\t\t\tthis.frame.content.mode( this.props.mode );\n\t\t}\n\n\t\t// Handle both this.props.value being either (number[]) multiple ids\n\t\t// (for galleries) or a (number) singular id (e.g. image block).\n\t\tconst hasMedia = Array.isArray( value ) ? !! value?.length : !! value;\n\n\t\tif ( ! hasMedia ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isGallery = this.props.gallery;\n\t\tconst selection = this.frame.state().get( 'selection' );\n\t\tconst valueArray = Array.isArray( value ) ? value : [ value ];\n\n\t\tif ( ! isGallery ) {\n\t\t\tvalueArray.forEach( ( id ) => {\n\t\t\t\tselection.add( wp.media.attachment( id ) );\n\t\t\t} );\n\t\t}\n\n\t\t// Load the images so they are available in the media modal.\n\t\tconst attachments = getAttachmentsCollection( valueArray );\n\n\t\t// Once attachments are loaded, set the current selection.\n\t\tattachments.more().done( function () {\n\t\t\tif ( isGallery && attachments?.models?.length ) {\n\t\t\t\tselection.add( attachments.models );\n\t\t\t}\n\t\t} );\n\t}\n\n\tonClose() {\n\t\tconst { onClose } = this.props;\n\n\t\tif ( onClose ) {\n\t\t\tonClose();\n\t\t}\n\n\t\tthis.frame.detach();\n\t}\n\n\tupdateCollection() {\n\t\tconst frameContent = this.frame.content.get();\n\t\tif ( frameContent && frameContent.collection ) {\n\t\t\tconst collection = frameContent.collection;\n\n\t\t\t// Clean all attachments we have in memory.\n\t\t\tcollection\n\t\t\t\t.toArray()\n\t\t\t\t.forEach( ( model ) => model.trigger( 'destroy', model ) );\n\n\t\t\t// Reset has more flag, if library had small amount of items all items may have been loaded before.\n\t\t\tcollection.mirroring._hasMore = true;\n\n\t\t\t// Request items.\n\t\t\tcollection.more();\n\t\t}\n\t}\n\n\topenModal() {\n\t\tconst {\n\t\t\tgallery = false,\n\t\t\tunstableFeaturedImageFlow = false,\n\t\t\tmodalClass,\n\t\t} = this.props;\n\n\t\tif ( gallery ) {\n\t\t\tthis.buildAndSetGalleryFrame();\n\t\t} else {\n\t\t\tthis.buildAndSetSingleMediaFrame();\n\t\t}\n\n\t\tif ( modalClass ) {\n\t\t\tthis.frame.$el.addClass( modalClass );\n\t\t}\n\n\t\tif ( unstableFeaturedImageFlow ) {\n\t\t\tthis.buildAndSetFeatureImageFrame();\n\t\t}\n\t\tthis.initializeListeners();\n\t\tthis.frame.open();\n\t}\n\n\trender() {\n\t\treturn this.props.render( { open: this.openModal } );\n\t}\n}\n\nexport default MediaUpload;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,MAAMC,qBAAqB,GAAG,EAAE;;AAEhC;AACA;AACA;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGC,MAAM;EAErB,OAAOD,EAAE,CAACE,KAAK,CAACC,IAAI,CAACC,UAAU,CAACC,MAAM,CAACC,MAAM,CAAE;IAC9C;AACF;AACA;AACA;AACA;AACA;IACEC,oBAAoBA,CAAEC,OAAO,EAAG;MAC/B,IAAI,CAACC,mBAAmB,CAAED,OAAO,EAAE;QAClCE,IAAI,EAAEV,EAAE,CAACE,KAAK,CAACC,IAAI,CAACQ,IAAI,CAACC,gBAAgB;QACzCC,KAAK,EAAE,IAAI,CAACC,OAAO,CAACD;MACrB,CAAE,CAAC;IACJ,CAAC;IAED;AACF;AACA;AACA;AACA;IACEE,SAASA,CAAA,EAAG;MACX,MAAMC,SAAS,GAAG,IAAI,CAACH,KAAK,CAAE,gBAAiB,CAAC,CAACI,GAAG,CAAE,WAAY,CAAC;MACnE,MAAMd,IAAI,GAAG,IAAIH,EAAE,CAACE,KAAK,CAACC,IAAI,CAACe,SAAS,CAAE;QACzCC,KAAK,EAAEH,SAAS,CAACI,MAAM,CAAC,CAAC;QACzBC,UAAU,EAAE;MACb,CAAE,CAAC,CAACC,MAAM,CAAC,CAAC;;MAEZ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AH,UAAU,CAACJ,IAAI,CAAC,CAAC;IAClB;EACD;EAEA7C,SAASA,CAAA,EAAG;IACX,MAAM;MACL0C,OAAO,GAAG,KAAK;MACfW,yBAAyB,GAAG,KAAK;MACjCC;IACD,CAAC,GAAG,IAAI,CAAC1C,KAAK;IAEd,IAAK8B,OAAO,EAAG;MACd,IAAI,CAAClC,uBAAuB,CAAC,CAAC;IAC/B,CAAC,MAAM;MACN,IAAI,CAACoB,2BAA2B,CAAC,CAAC;IACnC;IAEA,IAAK0B,UAAU,EAAG;MACjB,IAAI,CAAC/C,KAAK,CAACgD,GAAG,CAACC,QAAQ,CAAEF,UAAW,CAAC;IACtC;IAEA,IAAKD,yBAAyB,EAAG;MAChC,IAAI,CAAC9B,4BAA4B,CAAC,CAAC;IACpC;IACA,IAAI,CAACjB,mBAAmB,CAAC,CAAC;IAC1B,IAAI,CAACC,KAAK,CAACkD,IAAI,CAAC,CAAC;EAClB;EAEAnH,MAAMA,CAAA,EAAG;IACR,OAAO,IAAI,CAACsE,KAAK,CAACtE,MAAM,CAAE;MAAEmH,IAAI,EAAE,IAAI,CAACzD;IAAU,CAAE,CAAC;EACrD;AACD;AAEA,eAAeH,WAAW","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/media-upload/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nconst DEFAULT_EMPTY_GALLERY = [];\n\n/**\n * Prepares the Featured Image toolbars and frames.\n *\n * @return {window.wp.media.view.MediaFrame.Select} The default media workflow.\n */\nconst getFeaturedImageMediaFrame = () => {\n\tconst { wp } = window;\n\n\treturn wp.media.view.MediaFrame.Select.extend( {\n\t\t/**\n\t\t * Enables the Set Featured Image Button.\n\t\t *\n\t\t * @param {Object} toolbar toolbar for featured image state\n\t\t * @return {void}\n\t\t */\n\t\tfeaturedImageToolbar( toolbar ) {\n\t\t\tthis.createSelectToolbar( toolbar, {\n\t\t\t\ttext: wp.media.view.l10n.setFeaturedImage,\n\t\t\t\tstate: this.options.state,\n\t\t\t} );\n\t\t},\n\n\t\t/**\n\t\t * Handle the edit state requirements of selected media item.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\teditState() {\n\t\t\tconst selection = this.state( 'featured-image' ).get( 'selection' );\n\t\t\tconst view = new wp.media.view.EditImage( {\n\t\t\t\tmodel: selection.single(),\n\t\t\t\tcontroller: this,\n\t\t\t} ).render();\n\n\t\t\t// Set the view to the EditImage frame using the selected image.\n\t\t\tthis.content.set( view );\n\n\t\t\t// After bringing in the frame, load the actual editor via an ajax call.\n\t\t\tview.loadEditor();\n\t\t},\n\n\t\t/**\n\t\t * Create the default states.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tcreateStates: function createStates() {\n\t\t\tthis.on(\n\t\t\t\t'toolbar:create:featured-image',\n\t\t\t\tthis.featuredImageToolbar,\n\t\t\t\tthis\n\t\t\t);\n\t\t\tthis.on( 'content:render:edit-image', this.editState, this );\n\n\t\t\tthis.states.add( [\n\t\t\t\tnew wp.media.controller.FeaturedImage(),\n\t\t\t\tnew wp.media.controller.EditImage( {\n\t\t\t\t\tmodel: this.options.editImage,\n\t\t\t\t} ),\n\t\t\t] );\n\t\t},\n\t} );\n};\n\n/**\n * Prepares the default frame for selecting a single media item.\n *\n * @return {window.wp.media.view.MediaFrame.Select} The default media workflow.\n */\nconst getSingleMediaFrame = () => {\n\tconst { wp } = window;\n\n\t// Extend the default Select frame, and use the same `createStates` method as in core,\n\t// but with the addition of `filterable: 'uploaded'` to the Library state, so that\n\t// the user can filter the media library by uploaded media.\n\treturn wp.media.view.MediaFrame.Select.extend( {\n\t\t/**\n\t\t * Create the default states on the frame.\n\t\t */\n\t\tcreateStates() {\n\t\t\tconst options = this.options;\n\n\t\t\tif ( this.options.states ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Add the default states.\n\t\t\tthis.states.add( [\n\t\t\t\t// Main states.\n\t\t\t\tnew wp.media.controller.Library( {\n\t\t\t\t\tlibrary: wp.media.query( options.library ),\n\t\t\t\t\tmultiple: options.multiple,\n\t\t\t\t\ttitle: options.title,\n\t\t\t\t\tpriority: 20,\n\t\t\t\t\tfilterable: 'uploaded', // Allow filtering by uploaded images.\n\t\t\t\t} ),\n\t\t\t\tnew wp.media.controller.EditImage( {\n\t\t\t\t\tmodel: options.editImage,\n\t\t\t\t} ),\n\t\t\t] );\n\t\t},\n\t} );\n};\n\n/**\n * Prepares the Gallery toolbars and frames.\n *\n * @return {window.wp.media.view.MediaFrame.Post} The default media workflow.\n */\nconst getGalleryDetailsMediaFrame = () => {\n\tconst { wp } = window;\n\t/**\n\t * Custom gallery details frame.\n\t *\n\t * @see https://github.com/xwp/wp-core-media-widgets/blob/905edbccfc2a623b73a93dac803c5335519d7837/wp-admin/js/widgets/media-gallery-widget.js\n\t * @class GalleryDetailsMediaFrame\n\t * @class\n\t */\n\treturn wp.media.view.MediaFrame.Post.extend( {\n\t\t/**\n\t\t * Set up gallery toolbar.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tgalleryToolbar() {\n\t\t\tconst editing = this.state().get( 'editing' );\n\t\t\tthis.toolbar.set(\n\t\t\t\tnew wp.media.view.Toolbar( {\n\t\t\t\t\tcontroller: this,\n\t\t\t\t\titems: {\n\t\t\t\t\t\tinsert: {\n\t\t\t\t\t\t\tstyle: 'primary',\n\t\t\t\t\t\t\ttext: editing\n\t\t\t\t\t\t\t\t? wp.media.view.l10n.updateGallery\n\t\t\t\t\t\t\t\t: wp.media.view.l10n.insertGallery,\n\t\t\t\t\t\t\tpriority: 80,\n\t\t\t\t\t\t\trequires: { library: true },\n\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * @fires wp.media.controller.State#update\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tclick() {\n\t\t\t\t\t\t\t\tconst controller = this.controller,\n\t\t\t\t\t\t\t\t\tstate = controller.state();\n\n\t\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\t\tstate.trigger(\n\t\t\t\t\t\t\t\t\t'update',\n\t\t\t\t\t\t\t\t\tstate.get( 'library' )\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t// Restore and reset the default state.\n\t\t\t\t\t\t\t\tcontroller.setState( controller.options.state );\n\t\t\t\t\t\t\t\tcontroller.reset();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\n\t\t/**\n\t\t * Handle the edit state requirements of selected media item.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\teditState() {\n\t\t\tconst selection = this.state( 'gallery' ).get( 'selection' );\n\t\t\tconst view = new wp.media.view.EditImage( {\n\t\t\t\tmodel: selection.single(),\n\t\t\t\tcontroller: this,\n\t\t\t} ).render();\n\n\t\t\t// Set the view to the EditImage frame using the selected image.\n\t\t\tthis.content.set( view );\n\n\t\t\t// After bringing in the frame, load the actual editor via an ajax call.\n\t\t\tview.loadEditor();\n\t\t},\n\n\t\t/**\n\t\t * Create the default states.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tcreateStates: function createStates() {\n\t\t\tthis.on( 'toolbar:create:main-gallery', this.galleryToolbar, this );\n\t\t\tthis.on( 'content:render:edit-image', this.editState, this );\n\n\t\t\tthis.states.add( [\n\t\t\t\tnew wp.media.controller.Library( {\n\t\t\t\t\tid: 'gallery',\n\t\t\t\t\ttitle: wp.media.view.l10n.createGalleryTitle,\n\t\t\t\t\tpriority: 40,\n\t\t\t\t\ttoolbar: 'main-gallery',\n\t\t\t\t\tfilterable: 'uploaded',\n\t\t\t\t\tmultiple: 'add',\n\t\t\t\t\teditable: false,\n\n\t\t\t\t\tlibrary: wp.media.query( {\n\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\t...this.options.library,\n\t\t\t\t\t} ),\n\t\t\t\t} ),\n\t\t\t\tnew wp.media.controller.EditImage( {\n\t\t\t\t\tmodel: this.options.editImage,\n\t\t\t\t} ),\n\n\t\t\t\tnew wp.media.controller.GalleryEdit( {\n\t\t\t\t\tlibrary: this.options.selection,\n\t\t\t\t\tediting: this.options.editing,\n\t\t\t\t\tmenu: 'gallery',\n\t\t\t\t\tdisplaySettings: false,\n\t\t\t\t\tmultiple: true,\n\t\t\t\t} ),\n\n\t\t\t\tnew wp.media.controller.GalleryAdd(),\n\t\t\t] );\n\t\t},\n\t} );\n};\n\n// The media library image object contains numerous attributes\n// we only need this set to display the image in the library.\nconst slimImageObject = ( img ) => {\n\tconst attrSet = [\n\t\t'sizes',\n\t\t'mime',\n\t\t'type',\n\t\t'subtype',\n\t\t'id',\n\t\t'url',\n\t\t'alt',\n\t\t'link',\n\t\t'caption',\n\t];\n\treturn attrSet.reduce( ( result, key ) => {\n\t\tif ( img?.hasOwnProperty( key ) ) {\n\t\t\tresult[ key ] = img[ key ];\n\t\t}\n\t\treturn result;\n\t}, {} );\n};\n\nconst getAttachmentsCollection = ( ids ) => {\n\tconst { wp } = window;\n\n\treturn wp.media.query( {\n\t\torder: 'ASC',\n\t\torderby: 'post__in',\n\t\tpost__in: ids,\n\t\tposts_per_page: -1,\n\t\tquery: true,\n\t\ttype: 'image',\n\t} );\n};\n\nclass MediaUpload extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.openModal = this.openModal.bind( this );\n\t\tthis.onOpen = this.onOpen.bind( this );\n\t\tthis.onSelect = this.onSelect.bind( this );\n\t\tthis.onUpdate = this.onUpdate.bind( this );\n\t\tthis.onClose = this.onClose.bind( this );\n\t}\n\n\tinitializeListeners() {\n\t\t// When an image is selected in the media frame...\n\t\tthis.frame.on( 'select', this.onSelect );\n\t\tthis.frame.on( 'update', this.onUpdate );\n\t\tthis.frame.on( 'open', this.onOpen );\n\t\tthis.frame.on( 'close', this.onClose );\n\t}\n\n\t/**\n\t * Sets the Gallery frame and initializes listeners.\n\t *\n\t * @return {void}\n\t */\n\tbuildAndSetGalleryFrame() {\n\t\tconst {\n\t\t\taddToGallery = false,\n\t\t\tallowedTypes,\n\t\t\tmultiple = false,\n\t\t\tvalue = DEFAULT_EMPTY_GALLERY,\n\t\t} = this.props;\n\n\t\t// If the value did not changed there is no need to rebuild the frame,\n\t\t// we can continue to use the existing one.\n\t\tif ( value === this.lastGalleryValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { wp } = window;\n\n\t\tthis.lastGalleryValue = value;\n\n\t\t// If a frame already existed remove it.\n\t\tif ( this.frame ) {\n\t\t\tthis.frame.remove();\n\t\t}\n\t\tlet currentState;\n\t\tif ( addToGallery ) {\n\t\t\tcurrentState = 'gallery-library';\n\t\t} else {\n\t\t\tcurrentState = value && value.length ? 'gallery-edit' : 'gallery';\n\t\t}\n\t\tif ( ! this.GalleryDetailsMediaFrame ) {\n\t\t\tthis.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();\n\t\t}\n\t\tconst attachments = getAttachmentsCollection( value );\n\t\tconst selection = new wp.media.model.Selection( attachments.models, {\n\t\t\tprops: attachments.props.toJSON(),\n\t\t\tmultiple,\n\t\t} );\n\t\tthis.frame = new this.GalleryDetailsMediaFrame( {\n\t\t\tmimeType: allowedTypes,\n\t\t\tstate: currentState,\n\t\t\tmultiple,\n\t\t\tselection,\n\t\t\tediting: !! value?.length,\n\t\t} );\n\t\twp.media.frame = this.frame;\n\t\tthis.initializeListeners();\n\t}\n\n\t/**\n\t * Initializes the Media Library requirements for the featured image flow.\n\t *\n\t * @return {void}\n\t */\n\tbuildAndSetFeatureImageFrame() {\n\t\tconst { wp } = window;\n\t\tconst { value: featuredImageId, multiple, allowedTypes } = this.props;\n\t\tconst featuredImageFrame = getFeaturedImageMediaFrame();\n\t\tconst attachments = getAttachmentsCollection( featuredImageId );\n\t\tconst selection = new wp.media.model.Selection( attachments.models, {\n\t\t\tprops: attachments.props.toJSON(),\n\t\t} );\n\t\tthis.frame = new featuredImageFrame( {\n\t\t\tmimeType: allowedTypes,\n\t\t\tstate: 'featured-image',\n\t\t\tmultiple,\n\t\t\tselection,\n\t\t\tediting: featuredImageId,\n\t\t} );\n\t\twp.media.frame = this.frame;\n\t\t// In order to select the current featured image when opening\n\t\t// the media library we have to set the appropriate settings.\n\t\t// Currently they are set in php for the post editor, but\n\t\t// not for site editor.\n\t\twp.media.view.settings.post = {\n\t\t\t...wp.media.view.settings.post,\n\t\t\tfeaturedImageId: featuredImageId || -1,\n\t\t};\n\t}\n\n\t/**\n\t * Initializes the Media Library requirements for the single image flow.\n\t *\n\t * @return {void}\n\t */\n\tbuildAndSetSingleMediaFrame() {\n\t\tconst { wp } = window;\n\t\tconst {\n\t\t\tallowedTypes,\n\t\t\tmultiple = false,\n\t\t\ttitle = __( 'Select or Upload Media' ),\n\t\t\tvalue,\n\t\t} = this.props;\n\n\t\tconst frameConfig = {\n\t\t\ttitle,\n\t\t\tmultiple,\n\t\t};\n\t\tif ( !! allowedTypes ) {\n\t\t\tframeConfig.library = { type: allowedTypes };\n\t\t}\n\n\t\t// If a frame already exists, remove it.\n\t\tif ( this.frame ) {\n\t\t\tthis.frame.remove();\n\t\t}\n\n\t\tconst singleImageFrame = getSingleMediaFrame();\n\t\tconst attachments = getAttachmentsCollection( value );\n\t\tconst selection = new wp.media.model.Selection( attachments.models, {\n\t\t\tprops: attachments.props.toJSON(),\n\t\t} );\n\t\tthis.frame = new singleImageFrame( {\n\t\t\tmimeType: allowedTypes,\n\t\t\tmultiple,\n\t\t\tselection,\n\t\t\t...frameConfig,\n\t\t} );\n\t\twp.media.frame = this.frame;\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.frame?.remove();\n\t}\n\n\tonUpdate( selections ) {\n\t\tconst { onSelect, multiple = false } = this.props;\n\t\tconst state = this.frame.state();\n\t\tconst selectedImages = selections || state.get( 'selection' );\n\n\t\tif ( ! selectedImages || ! selectedImages.models.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( multiple ) {\n\t\t\tonSelect(\n\t\t\t\tselectedImages.models.map( ( model ) =>\n\t\t\t\t\tslimImageObject( model.toJSON() )\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\tonSelect( slimImageObject( selectedImages.models[ 0 ].toJSON() ) );\n\t\t}\n\t}\n\n\tonSelect() {\n\t\tconst { onSelect, multiple = false } = this.props;\n\t\t// Get media attachment details from the frame state.\n\t\tconst attachment = this.frame.state().get( 'selection' ).toJSON();\n\t\tonSelect( multiple ? attachment : attachment[ 0 ] );\n\t}\n\n\tonOpen() {\n\t\tconst { wp } = window;\n\t\tconst { value } = this.props;\n\t\tthis.updateCollection();\n\n\t\t//Handle active tab in media model on model open.\n\t\tif ( this.props.mode ) {\n\t\t\tthis.frame.content.mode( this.props.mode );\n\t\t}\n\n\t\t// Handle both this.props.value being either (number[]) multiple ids\n\t\t// (for galleries) or a (number) singular id (e.g. image block).\n\t\tconst hasMedia = Array.isArray( value ) ? !! value?.length : !! value;\n\n\t\tif ( ! hasMedia ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isGallery = this.props.gallery;\n\t\tconst selection = this.frame.state().get( 'selection' );\n\t\tconst valueArray = Array.isArray( value ) ? value : [ value ];\n\n\t\tif ( ! isGallery ) {\n\t\t\tvalueArray.forEach( ( id ) => {\n\t\t\t\tselection.add( wp.media.attachment( id ) );\n\t\t\t} );\n\t\t}\n\n\t\t// Load the images so they are available in the media modal.\n\t\tconst attachments = getAttachmentsCollection( valueArray );\n\n\t\t// Once attachments are loaded, set the current selection.\n\t\tattachments.more().done( function () {\n\t\t\tif ( isGallery && attachments?.models?.length ) {\n\t\t\t\tselection.add( attachments.models );\n\t\t\t}\n\t\t} );\n\t}\n\n\tonClose() {\n\t\tconst { onClose } = this.props;\n\n\t\tif ( onClose ) {\n\t\t\tonClose();\n\t\t}\n\n\t\tthis.frame.detach();\n\t}\n\n\tupdateCollection() {\n\t\tconst frameContent = this.frame.content.get();\n\t\tif ( frameContent && frameContent.collection ) {\n\t\t\tconst collection = frameContent.collection;\n\n\t\t\t// Clean all attachments we have in memory.\n\t\t\tcollection\n\t\t\t\t.toArray()\n\t\t\t\t.forEach( ( model ) => model.trigger( 'destroy', model ) );\n\n\t\t\t// Reset has more flag, if library had small amount of items all items may have been loaded before.\n\t\t\tcollection.mirroring._hasMore = true;\n\n\t\t\t// Request items.\n\t\t\tcollection.more();\n\t\t}\n\t}\n\n\topenModal() {\n\t\tconst {\n\t\t\tgallery = false,\n\t\t\tunstableFeaturedImageFlow = false,\n\t\t\tmodalClass,\n\t\t} = this.props;\n\n\t\tif ( gallery ) {\n\t\t\tthis.buildAndSetGalleryFrame();\n\t\t} else {\n\t\t\tthis.buildAndSetSingleMediaFrame();\n\t\t}\n\n\t\tif ( modalClass ) {\n\t\t\tthis.frame.$el.addClass( modalClass );\n\t\t}\n\n\t\tif ( unstableFeaturedImageFlow ) {\n\t\t\tthis.buildAndSetFeatureImageFrame();\n\t\t}\n\t\tthis.initializeListeners();\n\t\tthis.frame.open();\n\t}\n\n\trender() {\n\t\treturn this.props.render( { open: this.openModal } );\n\t}\n}\n\nexport default MediaUpload;\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAEnB,MAAM,wBAAwB,CAAC;AAO/B,MAAM,6BAA6B,MAAM;AACxC,QAAM,EAAE,GAAG,IAAI;AAEf,SAAO,GAAG,MAAM,KAAK,WAAW,OAAO,OAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO9C,qBAAsB,SAAU;AAC/B,WAAK,oBAAqB,SAAS;AAAA,QAClC,MAAM,GAAG,MAAM,KAAK,KAAK;AAAA,QACzB,OAAO,KAAK,QAAQ;AAAA,MACrB,CAAE;AAAA,IACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,YAAY;AACX,YAAM,YAAY,KAAK,MAAO,gBAAiB,EAAE,IAAK,WAAY;AAClE,YAAM,OAAO,IAAI,GAAG,M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
7
|
+
}
|
package/build-module/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export * from "./components";
|
|
2
|
+
import { uploadMedia } from "./utils/upload-media";
|
|
3
|
+
import { transformAttachment } from "./utils/transform-attachment";
|
|
4
|
+
import { validateFileSize } from "./utils/validate-file-size";
|
|
5
|
+
import { validateMimeType } from "./utils/validate-mime-type";
|
|
6
|
+
import { validateMimeTypeForUser } from "./utils/validate-mime-type-for-user";
|
|
7
|
+
import { privateApis } from "./private-apis";
|
|
8
|
+
export {
|
|
9
|
+
privateApis,
|
|
10
|
+
transformAttachment,
|
|
11
|
+
uploadMedia,
|
|
12
|
+
validateFileSize,
|
|
13
|
+
validateMimeType,
|
|
14
|
+
validateMimeTypeForUser
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './components';\n\nexport { uploadMedia } from './utils/upload-media';\nexport { transformAttachment } from './utils/transform-attachment';\nexport { validateFileSize } from './utils/validate-file-size';\nexport { validateMimeType } from './utils/validate-mime-type';\nexport { validateMimeTypeForUser } from './utils/validate-mime-type-for-user';\n\nexport type { Attachment, RestAttachment } from './utils/types';\n\nexport { privateApis } from './private-apis';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AAEd,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AAIxC,SAAS,mBAAmB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
|
|
2
|
+
const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
3
|
+
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
4
|
+
"@wordpress/media-utils"
|
|
5
|
+
);
|
|
6
|
+
export {
|
|
6
7
|
lock,
|
|
7
8
|
unlock
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=lock-unlock.js.map
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lock-unlock.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/media-utils'\n\t);\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,wDAAwD;AAE1D,MAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { sideloadMedia } from './utils/sideload-media';
|
|
5
|
-
import { lock } from './lock-unlock';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Private @wordpress/media-utils APIs.
|
|
9
|
-
*/
|
|
10
|
-
export const privateApis = {};
|
|
1
|
+
import { sideloadMedia } from "./utils/sideload-media";
|
|
2
|
+
import { lock } from "./lock-unlock";
|
|
3
|
+
const privateApis = {};
|
|
11
4
|
lock(privateApis, {
|
|
12
5
|
sideloadMedia
|
|
13
6
|
});
|
|
14
|
-
|
|
7
|
+
export {
|
|
8
|
+
privateApis
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/private-apis.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { sideloadMedia } from './utils/sideload-media';\nimport { lock } from './lock-unlock';\n\n/**\n * Private @wordpress/media-utils APIs.\n */\nexport const privateApis = {};\n\nlock( privateApis, {\n\tsideloadMedia,\n} );\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAKd,MAAM,cAAc,CAAC;AAE5B,KAAM,aAAa;AAAA,EAClB;AACD,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines whether the passed argument appears to be a plain object.
|
|
3
|
-
*
|
|
4
|
-
* @param data The object to inspect.
|
|
5
|
-
*/
|
|
6
1
|
function isPlainObject(data) {
|
|
7
|
-
return data !== null && typeof data ===
|
|
2
|
+
return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
|
|
8
3
|
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Recursively flatten data passed to form data, to allow using multi-level objects.
|
|
12
|
-
*
|
|
13
|
-
* @param {FormData} formData Form data object.
|
|
14
|
-
* @param {string} key Key to amend to form data object
|
|
15
|
-
* @param {string|Object} data Data to be amended to form data.
|
|
16
|
-
*/
|
|
17
|
-
export function flattenFormData(formData, key, data) {
|
|
4
|
+
function flattenFormData(formData, key, data) {
|
|
18
5
|
if (isPlainObject(data)) {
|
|
19
6
|
for (const [name, value] of Object.entries(data)) {
|
|
20
7
|
flattenFormData(formData, `${key}[${name}]`, value);
|
|
21
8
|
}
|
|
22
|
-
} else if (data !==
|
|
9
|
+
} else if (data !== void 0) {
|
|
23
10
|
formData.append(key, String(data));
|
|
24
11
|
}
|
|
25
12
|
}
|
|
26
|
-
|
|
13
|
+
export {
|
|
14
|
+
flattenFormData
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=flatten-form-data.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/flatten-form-data.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Determines whether the passed argument appears to be a plain object.\n *\n * @param data The object to inspect.\n */\nfunction isPlainObject( data: unknown ): data is Record< string, unknown > {\n\treturn (\n\t\tdata !== null &&\n\t\ttypeof data === 'object' &&\n\t\tObject.getPrototypeOf( data ) === Object.prototype\n\t);\n}\n\n/**\n * Recursively flatten data passed to form data, to allow using multi-level objects.\n *\n * @param {FormData} formData Form data object.\n * @param {string} key Key to amend to form data object\n * @param {string|Object} data Data to be amended to form data.\n */\nexport function flattenFormData(\n\tformData: FormData,\n\tkey: string,\n\tdata: string | undefined | Record< string, string >\n) {\n\tif ( isPlainObject( data ) ) {\n\t\tfor ( const [ name, value ] of Object.entries( data ) ) {\n\t\t\tflattenFormData( formData, `${ key }[${ name }]`, value );\n\t\t}\n\t} else if ( data !== undefined ) {\n\t\tformData.append( key, String( data ) );\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,cAAe,MAAmD;AAC1E,SACC,SAAS,QACT,OAAO,SAAS,YAChB,OAAO,eAAgB,IAAK,MAAM,OAAO;AAE3C;AASO,SAAS,gBACf,UACA,KACA,MACC;AACD,MAAK,cAAe,IAAK,GAAI;AAC5B,eAAY,CAAE,MAAM,KAAM,KAAK,OAAO,QAAS,IAAK,GAAI;AACvD,sBAAiB,UAAU,GAAI,GAAI,IAAK,IAAK,KAAK,KAAM;AAAA,IACzD;AAAA,EACD,WAAY,SAAS,QAAY;AAChC,aAAS,OAAQ,KAAK,OAAQ,IAAK,CAAE;AAAA,EACtC;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
* Browsers may use unexpected mime types, and they differ from browser to browser.
|
|
3
|
-
* This function computes a flexible array of mime types from the mime type structured provided by the server.
|
|
4
|
-
* Converts { jpg|jpeg|jpe: "image/jpeg" } into [ "image/jpeg", "image/jpg", "image/jpeg", "image/jpe" ]
|
|
5
|
-
*
|
|
6
|
-
* @param {?Object} wpMimeTypesObject Mime type object received from the server.
|
|
7
|
-
* Extensions are keys separated by '|' and values are mime types associated with an extension.
|
|
8
|
-
*
|
|
9
|
-
* @return An array of mime types or null
|
|
10
|
-
*/
|
|
11
|
-
export function getMimeTypesArray(wpMimeTypesObject) {
|
|
1
|
+
function getMimeTypesArray(wpMimeTypesObject) {
|
|
12
2
|
if (!wpMimeTypesObject) {
|
|
13
3
|
return null;
|
|
14
4
|
}
|
|
15
|
-
return Object.entries(wpMimeTypesObject).flatMap(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
return Object.entries(wpMimeTypesObject).flatMap(
|
|
6
|
+
([extensionsString, mime]) => {
|
|
7
|
+
const [type] = mime.split("/");
|
|
8
|
+
const extensions = extensionsString.split("|");
|
|
9
|
+
return [
|
|
10
|
+
mime,
|
|
11
|
+
...extensions.map(
|
|
12
|
+
(extension) => `${type}/${extension}`
|
|
13
|
+
)
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
);
|
|
20
17
|
}
|
|
21
|
-
|
|
18
|
+
export {
|
|
19
|
+
getMimeTypesArray
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=get-mime-types-array.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/get-mime-types-array.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Browsers may use unexpected mime types, and they differ from browser to browser.\n * This function computes a flexible array of mime types from the mime type structured provided by the server.\n * Converts { jpg|jpeg|jpe: \"image/jpeg\" } into [ \"image/jpeg\", \"image/jpg\", \"image/jpeg\", \"image/jpe\" ]\n *\n * @param {?Object} wpMimeTypesObject Mime type object received from the server.\n * Extensions are keys separated by '|' and values are mime types associated with an extension.\n *\n * @return An array of mime types or null\n */\nexport function getMimeTypesArray(\n\twpMimeTypesObject?: Record< string, string > | null\n) {\n\tif ( ! wpMimeTypesObject ) {\n\t\treturn null;\n\t}\n\treturn Object.entries( wpMimeTypesObject ).flatMap(\n\t\t( [ extensionsString, mime ] ) => {\n\t\t\tconst [ type ] = mime.split( '/' );\n\t\t\tconst extensions = extensionsString.split( '|' );\n\t\t\treturn [\n\t\t\t\tmime,\n\t\t\t\t...extensions.map(\n\t\t\t\t\t( extension ) => `${ type }/${ extension }`\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAUO,SAAS,kBACf,mBACC;AACD,MAAK,CAAE,mBAAoB;AAC1B,WAAO;AAAA,EACR;AACA,SAAO,OAAO,QAAS,iBAAkB,EAAE;AAAA,IAC1C,CAAE,CAAE,kBAAkB,IAAK,MAAO;AACjC,YAAM,CAAE,IAAK,IAAI,KAAK,MAAO,GAAI;AACjC,YAAM,aAAa,iBAAiB,MAAO,GAAI;AAC/C,aAAO;AAAA,QACN;AAAA,QACA,GAAG,WAAW;AAAA,UACb,CAAE,cAAe,GAAI,IAAK,IAAK,SAAU;AAAA,QAC1C;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { sideloadToServer } from './sideload-to-server';
|
|
11
|
-
import { UploadError } from './upload-error';
|
|
12
|
-
const noop = () => {};
|
|
13
|
-
/**
|
|
14
|
-
* Uploads a file to the server without creating an attachment.
|
|
15
|
-
*
|
|
16
|
-
* @param $0 Parameters object passed to the function.
|
|
17
|
-
* @param $0.file Media File to Save.
|
|
18
|
-
* @param $0.attachmentId Parent attachment ID.
|
|
19
|
-
* @param $0.additionalData Additional data to include in the request.
|
|
20
|
-
* @param $0.signal Abort signal.
|
|
21
|
-
* @param $0.onFileChange Function called each time a file or a temporary representation of the file is available.
|
|
22
|
-
* @param $0.onError Function called when an error happens.
|
|
23
|
-
*/
|
|
24
|
-
export async function sideloadMedia({
|
|
1
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
2
|
+
import { sideloadToServer } from "./sideload-to-server";
|
|
3
|
+
import { UploadError } from "./upload-error";
|
|
4
|
+
const noop = () => {
|
|
5
|
+
};
|
|
6
|
+
async function sideloadMedia({
|
|
25
7
|
file,
|
|
26
8
|
attachmentId,
|
|
27
9
|
additionalData = {},
|
|
@@ -30,7 +12,12 @@ export async function sideloadMedia({
|
|
|
30
12
|
onError = noop
|
|
31
13
|
}) {
|
|
32
14
|
try {
|
|
33
|
-
const attachment = await sideloadToServer(
|
|
15
|
+
const attachment = await sideloadToServer(
|
|
16
|
+
file,
|
|
17
|
+
attachmentId,
|
|
18
|
+
additionalData,
|
|
19
|
+
signal
|
|
20
|
+
);
|
|
34
21
|
onFileChange?.([attachment]);
|
|
35
22
|
} catch (error) {
|
|
36
23
|
let message;
|
|
@@ -38,15 +25,22 @@ export async function sideloadMedia({
|
|
|
38
25
|
message = error.message;
|
|
39
26
|
} else {
|
|
40
27
|
message = sprintf(
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
// translators: %s: file name
|
|
29
|
+
__("Error while sideloading file %s to the server."),
|
|
30
|
+
file.name
|
|
31
|
+
);
|
|
43
32
|
}
|
|
44
|
-
onError(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
onError(
|
|
34
|
+
new UploadError({
|
|
35
|
+
code: "GENERAL",
|
|
36
|
+
message,
|
|
37
|
+
file,
|
|
38
|
+
cause: error instanceof Error ? error : void 0
|
|
39
|
+
})
|
|
40
|
+
);
|
|
50
41
|
}
|
|
51
42
|
}
|
|
52
|
-
|
|
43
|
+
export {
|
|
44
|
+
sideloadMedia
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=sideload-media.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/sideload-media.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tOnChangeHandler,\n\tOnErrorHandler,\n\tCreateSideloadFile,\n\tRestAttachment,\n} from './types';\nimport { sideloadToServer } from './sideload-to-server';\nimport { UploadError } from './upload-error';\n\nconst noop = () => {};\n\ninterface SideloadMediaArgs {\n\t// Additional data to include in the request.\n\tadditionalData?: CreateSideloadFile;\n\t// File to sideload.\n\tfile: File;\n\t// Attachment ID.\n\tattachmentId: RestAttachment[ 'id' ];\n\t// Function called when an error happens.\n\tonError?: OnErrorHandler;\n\t// Function called each time a file or a temporary representation of the file is available.\n\tonFileChange?: OnChangeHandler;\n\t// Abort signal.\n\tsignal?: AbortSignal;\n}\n\n/**\n * Uploads a file to the server without creating an attachment.\n *\n * @param $0 Parameters object passed to the function.\n * @param $0.file Media File to Save.\n * @param $0.attachmentId Parent attachment ID.\n * @param $0.additionalData Additional data to include in the request.\n * @param $0.signal Abort signal.\n * @param $0.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param $0.onError Function called when an error happens.\n */\nexport async function sideloadMedia( {\n\tfile,\n\tattachmentId,\n\tadditionalData = {},\n\tsignal,\n\tonFileChange,\n\tonError = noop,\n}: SideloadMediaArgs ) {\n\ttry {\n\t\tconst attachment = await sideloadToServer(\n\t\t\tfile,\n\t\t\tattachmentId,\n\t\t\tadditionalData,\n\t\t\tsignal\n\t\t);\n\t\tonFileChange?.( [ attachment ] );\n\t} catch ( error ) {\n\t\tlet message;\n\t\tif ( error instanceof Error ) {\n\t\t\tmessage = error.message;\n\t\t} else {\n\t\t\tmessage = sprintf(\n\t\t\t\t// translators: %s: file name\n\t\t\t\t__( 'Error while sideloading file %s to the server.' ),\n\t\t\t\tfile.name\n\t\t\t);\n\t\t}\n\t\tonError(\n\t\t\tnew UploadError( {\n\t\t\t\tcode: 'GENERAL',\n\t\t\t\tmessage,\n\t\t\t\tfile,\n\t\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t\t} )\n\t\t);\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,IAAI,eAAe;AAW5B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAE5B,MAAM,OAAO,MAAM;AAAC;AA4BpB,eAAsB,cAAe;AAAA,EACpC;AAAA,EACA;AAAA,EACA,iBAAiB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA,UAAU;AACX,GAAuB;AACtB,MAAI;AACH,UAAM,aAAa,MAAM;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AACA,mBAAgB,CAAE,UAAW,CAAE;AAAA,EAChC,SAAU,OAAQ;AACjB,QAAI;AACJ,QAAK,iBAAiB,OAAQ;AAC7B,gBAAU,MAAM;AAAA,IACjB,OAAO;AACN,gBAAU;AAAA;AAAA,QAET,GAAI,gDAAiD;AAAA,QACrD,KAAK;AAAA,MACN;AAAA,IACD;AACA;AAAA,MACC,IAAI,YAAa;AAAA,QAChB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,OAAO,iBAAiB,QAAQ,QAAQ;AAAA,MACzC,CAAE;AAAA,IACH;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { flattenFormData } from './flatten-form-data';
|
|
11
|
-
import { transformAttachment } from './transform-attachment';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Uploads a file to the server without creating an attachment.
|
|
15
|
-
*
|
|
16
|
-
* @param file Media File to Save.
|
|
17
|
-
* @param attachmentId Parent attachment ID.
|
|
18
|
-
* @param additionalData Additional data to include in the request.
|
|
19
|
-
* @param signal Abort signal.
|
|
20
|
-
*
|
|
21
|
-
* @return The saved attachment.
|
|
22
|
-
*/
|
|
23
|
-
export async function sideloadToServer(file, attachmentId, additionalData = {}, signal) {
|
|
24
|
-
// Create upload payload.
|
|
1
|
+
import apiFetch from "@wordpress/api-fetch";
|
|
2
|
+
import { flattenFormData } from "./flatten-form-data";
|
|
3
|
+
import { transformAttachment } from "./transform-attachment";
|
|
4
|
+
async function sideloadToServer(file, attachmentId, additionalData = {}, signal) {
|
|
25
5
|
const data = new FormData();
|
|
26
|
-
data.append(
|
|
6
|
+
data.append("file", file, file.name || file.type.replace("/", "."));
|
|
27
7
|
for (const [key, value] of Object.entries(additionalData)) {
|
|
28
|
-
flattenFormData(
|
|
8
|
+
flattenFormData(
|
|
9
|
+
data,
|
|
10
|
+
key,
|
|
11
|
+
value
|
|
12
|
+
);
|
|
29
13
|
}
|
|
30
|
-
return transformAttachment(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
return transformAttachment(
|
|
15
|
+
await apiFetch({
|
|
16
|
+
path: `/wp/v2/media/${attachmentId}/sideload`,
|
|
17
|
+
body: data,
|
|
18
|
+
method: "POST",
|
|
19
|
+
signal
|
|
20
|
+
})
|
|
21
|
+
);
|
|
36
22
|
}
|
|
37
|
-
|
|
23
|
+
export {
|
|
24
|
+
sideloadToServer
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=sideload-to-server.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/sideload-to-server.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport type { CreateSideloadFile, RestAttachment } from './types';\nimport { flattenFormData } from './flatten-form-data';\nimport { transformAttachment } from './transform-attachment';\n\n/**\n * Uploads a file to the server without creating an attachment.\n *\n * @param file Media File to Save.\n * @param attachmentId Parent attachment ID.\n * @param additionalData Additional data to include in the request.\n * @param signal Abort signal.\n *\n * @return The saved attachment.\n */\nexport async function sideloadToServer(\n\tfile: File,\n\tattachmentId: RestAttachment[ 'id' ],\n\tadditionalData: CreateSideloadFile = {},\n\tsignal?: AbortSignal\n) {\n\t// Create upload payload.\n\tconst data = new FormData();\n\tdata.append( 'file', file, file.name || file.type.replace( '/', '.' ) );\n\tfor ( const [ key, value ] of Object.entries( additionalData ) ) {\n\t\tflattenFormData(\n\t\t\tdata,\n\t\t\tkey,\n\t\t\tvalue as string | Record< string, string > | undefined\n\t\t);\n\t}\n\n\treturn transformAttachment(\n\t\tawait apiFetch< RestAttachment >( {\n\t\t\tpath: `/wp/v2/media/${ attachmentId }/sideload`,\n\t\t\tbody: data,\n\t\t\tmethod: 'POST',\n\t\t\tsignal,\n\t\t} )\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,cAAc;AAMrB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AAYpC,eAAsB,iBACrB,MACA,cACA,iBAAqC,CAAC,GACtC,QACC;AAED,QAAM,OAAO,IAAI,SAAS;AAC1B,OAAK,OAAQ,QAAQ,MAAM,KAAK,QAAQ,KAAK,KAAK,QAAS,KAAK,GAAI,CAAE;AACtE,aAAY,CAAE,KAAK,KAAM,KAAK,OAAO,QAAS,cAAe,GAAI;AAChE;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,MAAM,SAA4B;AAAA,MACjC,MAAM,gBAAiB,YAAa;AAAA,MACpC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR;AAAA,IACD,CAAE;AAAA,EACH;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Transforms an attachment object from the REST API shape into the shape expected by the block editor and other consumers.
|
|
7
|
-
*
|
|
8
|
-
* @param attachment REST API attachment object.
|
|
9
|
-
*/
|
|
10
|
-
export function transformAttachment(attachment) {
|
|
11
|
-
var _attachment$caption$r;
|
|
12
|
-
// eslint-disable-next-line camelcase
|
|
13
|
-
const {
|
|
14
|
-
alt_text,
|
|
15
|
-
source_url,
|
|
16
|
-
...savedMediaProps
|
|
17
|
-
} = attachment;
|
|
1
|
+
function transformAttachment(attachment) {
|
|
2
|
+
const { alt_text, source_url, ...savedMediaProps } = attachment;
|
|
18
3
|
return {
|
|
19
4
|
...savedMediaProps,
|
|
20
5
|
alt: attachment.alt_text,
|
|
21
|
-
caption:
|
|
6
|
+
caption: attachment.caption?.raw ?? "",
|
|
22
7
|
title: attachment.title.raw,
|
|
23
8
|
url: attachment.source_url,
|
|
24
|
-
poster: attachment._embedded?.[
|
|
9
|
+
poster: attachment._embedded?.["wp:featuredmedia"]?.[0]?.source_url || void 0
|
|
25
10
|
};
|
|
26
11
|
}
|
|
27
|
-
|
|
12
|
+
export {
|
|
13
|
+
transformAttachment
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=transform-attachment.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/transform-attachment.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Attachment, RestAttachment } from './types';\n\n/**\n * Transforms an attachment object from the REST API shape into the shape expected by the block editor and other consumers.\n *\n * @param attachment REST API attachment object.\n */\nexport function transformAttachment( attachment: RestAttachment ): Attachment {\n\t// eslint-disable-next-line camelcase\n\tconst { alt_text, source_url, ...savedMediaProps } = attachment;\n\treturn {\n\t\t...savedMediaProps,\n\t\talt: attachment.alt_text,\n\t\tcaption: attachment.caption?.raw ?? '',\n\t\ttitle: attachment.title.raw,\n\t\turl: attachment.source_url,\n\t\tposter:\n\t\t\tattachment._embedded?.[ 'wp:featuredmedia' ]?.[ 0 ]?.source_url ||\n\t\t\tundefined,\n\t};\n}\n"],
|
|
5
|
+
"mappings": "AAUO,SAAS,oBAAqB,YAAyC;AAE7E,QAAM,EAAE,UAAU,YAAY,GAAG,gBAAgB,IAAI;AACrD,SAAO;AAAA,IACN,GAAG;AAAA,IACH,KAAK,WAAW;AAAA,IAChB,SAAS,WAAW,SAAS,OAAO;AAAA,IACpC,OAAO,WAAW,MAAM;AAAA,IACxB,KAAK,WAAW;AAAA,IAChB,QACC,WAAW,YAAa,kBAAmB,IAAK,CAAE,GAAG,cACrD;AAAA,EACF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": [],
|
|
4
|
+
"sourcesContent": [],
|
|
5
|
+
"mappings": "",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|