@wordpress/editor 14.8.17 → 14.8.19

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.
Files changed (40) hide show
  1. package/build/components/post-publish-panel/maybe-upload-media.js +1 -0
  2. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  3. package/build/components/post-publish-panel/media-util.js +1 -0
  4. package/build/components/post-publish-panel/media-util.js.map +1 -1
  5. package/build/components/post-title/index.js +19 -17
  6. package/build/components/post-title/index.js.map +1 -1
  7. package/build/components/provider/use-block-editor-settings.js +7 -7
  8. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  9. package/build/dataviews/actions/restore-post.js +1 -0
  10. package/build/dataviews/actions/restore-post.js.map +1 -1
  11. package/build/dataviews/actions/trash-post.js +1 -0
  12. package/build/dataviews/actions/trash-post.js.map +1 -1
  13. package/build/store/constants.js +1 -0
  14. package/build/store/constants.js.map +1 -1
  15. package/build/store/private-actions.js +1 -0
  16. package/build/store/private-actions.js.map +1 -1
  17. package/build-module/components/post-publish-panel/maybe-upload-media.js +1 -0
  18. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  19. package/build-module/components/post-publish-panel/media-util.js +1 -0
  20. package/build-module/components/post-publish-panel/media-util.js.map +1 -1
  21. package/build-module/components/post-title/index.js +19 -17
  22. package/build-module/components/post-title/index.js.map +1 -1
  23. package/build-module/components/provider/use-block-editor-settings.js +8 -8
  24. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  25. package/build-module/dataviews/actions/restore-post.js +1 -0
  26. package/build-module/dataviews/actions/restore-post.js.map +1 -1
  27. package/build-module/dataviews/actions/trash-post.js +1 -0
  28. package/build-module/dataviews/actions/trash-post.js.map +1 -1
  29. package/build-module/store/constants.js +1 -0
  30. package/build-module/store/constants.js.map +1 -1
  31. package/build-module/store/private-actions.js +1 -0
  32. package/build-module/store/private-actions.js.map +1 -1
  33. package/build-style/style-rtl.css +1 -2
  34. package/build-style/style.css +1 -2
  35. package/build-types/components/post-title/index.d.ts +1 -1
  36. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  37. package/package.json +20 -20
  38. package/src/components/post-title/index.js +19 -17
  39. package/src/components/provider/use-block-editor-settings.js +5 -9
  40. package/tsconfig.tsbuildinfo +1 -1
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_data","_i18n","_blockEditor","_element","_blob","_mediaUtil","_jsxRuntime","flattenBlocks","blocks","result","forEach","block","push","innerBlocks","hasExternalMedia","name","attributes","url","id","mediaUrl","mediaId","undefined","getMediaInfo","alt","mediaAlt","Image","clientId","selectBlock","useDispatch","blockEditorStore","jsx","__unstableMotion","img","tabIndex","role","__","onClick","onKeyDown","event","key","preventDefault","src","animate","opacity","exit","scale","style","width","height","objectFit","borderRadius","cursor","whileHover","MaybeUploadMediaPanel","isUploading","setIsUploading","useState","isAnimating","setIsAnimating","hadUploadError","setHadUploadError","editorBlocks","mediaUpload","useSelect","select","getBlocks","getSettings","blocksWithExternalMedia","filter","updateBlockAttributes","length","panelBodyTitle","className","children","updateBlockWithUploadedMedia","media","uploadImages","mediaUrls","Set","map","uploadPromises","Object","fromEntries","entries","fetchMedia","filePromise","uploadPromise","then","blob","Promise","resolve","reject","filesList","onFileChange","isBlobURL","onError","allSettled","catch","finally","jsxs","PanelBody","initialOpen","title","display","flexWrap","gap","__unstableAnimatePresence","onExitComplete","Spinner","Button","size","variant"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-upload-media.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\tSpinner,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState } from '@wordpress/element';\nimport { isBlobURL } from '@wordpress/blob';\n\n/**\n * Internal dependencies\n */\nimport { fetchMedia } from './media-util';\n\nfunction flattenBlocks( blocks ) {\n\tconst result = [];\n\n\tblocks.forEach( ( block ) => {\n\t\tresult.push( block );\n\t\tresult.push( ...flattenBlocks( block.innerBlocks ) );\n\t} );\n\n\treturn result;\n}\n\n/**\n * Determine whether a block has external media.\n *\n * Different blocks use different attribute names (and potentially\n * different logic as well) in determining whether the media is\n * present, and whether it's external.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {boolean?} Whether the block has external media\n */\nfunction hasExternalMedia( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\treturn block.attributes.url && ! block.attributes.id;\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\treturn block.attributes.mediaUrl && ! block.attributes.mediaId;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Retrieve media info from a block.\n *\n * Different blocks use different attribute names, so we need this\n * function to normalize things into a consistent naming scheme.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {{url: ?string, alt: ?string, id: ?number}} The media info for the block.\n */\nfunction getMediaInfo( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\tconst { url, alt, id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\tconst { mediaUrl: url, mediaAlt: alt, mediaId: id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\treturn {};\n}\n\n// Image component to represent a single image in the upload dialog.\nfunction Image( { clientId, alt, url } ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn (\n\t\t<motion.img\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\taria-label={ __( 'Select image block.' ) }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( event.key === 'Enter' || event.key === ' ' ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tkey={ clientId }\n\t\t\talt={ alt }\n\t\t\tsrc={ url }\n\t\t\tanimate={ { opacity: 1 } }\n\t\t\texit={ { opacity: 0, scale: 0 } }\n\t\t\tstyle={ {\n\t\t\t\twidth: '32px',\n\t\t\t\theight: '32px',\n\t\t\t\tobjectFit: 'cover',\n\t\t\t\tborderRadius: '2px',\n\t\t\t\tcursor: 'pointer',\n\t\t\t} }\n\t\t\twhileHover={ { scale: 1.08 } }\n\t\t/>\n\t);\n}\n\nexport default function MaybeUploadMediaPanel() {\n\tconst [ isUploading, setIsUploading ] = useState( false );\n\tconst [ isAnimating, setIsAnimating ] = useState( false );\n\tconst [ hadUploadError, setHadUploadError ] = useState( false );\n\tconst { editorBlocks, mediaUpload } = useSelect(\n\t\t( select ) => ( {\n\t\t\teditorBlocks: select( blockEditorStore ).getBlocks(),\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Get a list of blocks with external media.\n\tconst blocksWithExternalMedia = flattenBlocks( editorBlocks ).filter(\n\t\t( block ) => hasExternalMedia( block )\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tif ( ! mediaUpload || ! blocksWithExternalMedia.length ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'External media' ) }\n\t\t</span>,\n\t];\n\n\t/**\n\t * Update an individual block to point to newly-added library media.\n\t *\n\t * Different blocks use different attribute names, so we need this\n\t * function to ensure we modify the correct attributes for each type.\n\t *\n\t * @param {{name: string, attributes: Object}} block The block.\n\t * @param {{id: number, url: string}} media Media library file info.\n\t */\n\tfunction updateBlockWithUploadedMedia( block, media ) {\n\t\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tid: media.id,\n\t\t\t\turl: media.url,\n\t\t\t} );\n\t\t}\n\n\t\tif ( block.name === 'core/media-text' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tmediaId: media.id,\n\t\t\t\tmediaUrl: media.url,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle fetching and uploading all external media in the post.\n\tfunction uploadImages() {\n\t\tsetIsUploading( true );\n\t\tsetHadUploadError( false );\n\n\t\t// Multiple blocks can be using the same URL, so we\n\t\t// should ensure we only fetch and upload each of them once.\n\t\tconst mediaUrls = new Set(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\t\t\t\treturn url;\n\t\t\t} )\n\t\t);\n\n\t\t// Create an upload promise for each URL, that we can wait for in all\n\t\t// blocks that make use of that media.\n\t\tconst uploadPromises = Object.fromEntries(\n\t\t\tObject.entries( fetchMedia( [ ...mediaUrls ] ) ).map(\n\t\t\t\t( [ url, filePromise ] ) => {\n\t\t\t\t\tconst uploadPromise = filePromise.then(\n\t\t\t\t\t\t( blob ) =>\n\t\t\t\t\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\t\t\t\t\tmediaUpload( {\n\t\t\t\t\t\t\t\t\tfilesList: [ blob ],\n\t\t\t\t\t\t\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\t\t\t\t\t\t\tif ( isBlobURL( media.url ) ) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tresolve( media );\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tonError() {\n\t\t\t\t\t\t\t\t\t\treject();\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);\n\n\t\t\t\t\treturn [ url, uploadPromise ];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\n\t\t// Wait for all blocks to be updated with library media.\n\t\tPromise.allSettled(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\n\t\t\t\treturn uploadPromises[ url ]\n\t\t\t\t\t.then( ( media ) =>\n\t\t\t\t\t\tupdateBlockWithUploadedMedia( block, media )\n\t\t\t\t\t)\n\t\t\t\t\t.then( () => setIsAnimating( true ) )\n\t\t\t\t\t.catch( () => setHadUploadError( true ) );\n\t\t\t} )\n\t\t).finally( () => {\n\t\t\tsetIsUploading( false );\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'inline-flex',\n\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\tgap: '8px',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<AnimatePresence\n\t\t\t\t\tonExitComplete={ () => setIsAnimating( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ blocksWithExternalMedia.map( ( block ) => {\n\t\t\t\t\t\tconst { url, alt } = getMediaInfo( block );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\t\tkey={ block.clientId }\n\t\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\talt={ alt }\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</AnimatePresence>\n\t\t\t\t{ isUploading || isAnimating ? (\n\t\t\t\t\t<Spinner />\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ uploadImages }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ hadUploadError && <p>{ __( 'Upload failed, try again.' ) }</p> }\n\t\t</PanelBody>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAN,OAAA;AAA0C,IAAAO,WAAA,GAAAP,OAAA;AAnB1C;AACA;AACA;;AAcA;AACA;AACA;;AAGA,SAASQ,aAAaA,CAAEC,MAAM,EAAG;EAChC,MAAMC,MAAM,GAAG,EAAE;EAEjBD,MAAM,CAACE,OAAO,CAAIC,KAAK,IAAM;IAC5BF,MAAM,CAACG,IAAI,CAAED,KAAM,CAAC;IACpBF,MAAM,CAACG,IAAI,CAAE,GAAGL,aAAa,CAAEI,KAAK,CAACE,WAAY,CAAE,CAAC;EACrD,CAAE,CAAC;EAEH,OAAOJ,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,gBAAgBA,CAAEH,KAAK,EAAG;EAClC,IAAKA,KAAK,CAACI,IAAI,KAAK,YAAY,IAAIJ,KAAK,CAACI,IAAI,KAAK,YAAY,EAAG;IACjE,OAAOJ,KAAK,CAACK,UAAU,CAACC,GAAG,IAAI,CAAEN,KAAK,CAACK,UAAU,CAACE,EAAE;EACrD;EAEA,IAAKP,KAAK,CAACI,IAAI,KAAK,iBAAiB,EAAG;IACvC,OAAOJ,KAAK,CAACK,UAAU,CAACG,QAAQ,IAAI,CAA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"names":["_components","require","_data","_i18n","_blockEditor","_element","_blob","_mediaUtil","_jsxRuntime","flattenBlocks","blocks","result","forEach","block","push","innerBlocks","hasExternalMedia","name","attributes","url","id","mediaUrl","mediaId","undefined","getMediaInfo","alt","mediaAlt","Image","clientId","selectBlock","useDispatch","blockEditorStore","jsx","__unstableMotion","img","tabIndex","role","__","onClick","onKeyDown","event","key","preventDefault","src","animate","opacity","exit","scale","style","width","height","objectFit","borderRadius","cursor","whileHover","MaybeUploadMediaPanel","isUploading","setIsUploading","useState","isAnimating","setIsAnimating","hadUploadError","setHadUploadError","editorBlocks","mediaUpload","useSelect","select","getBlocks","getSettings","blocksWithExternalMedia","filter","updateBlockAttributes","length","panelBodyTitle","className","children","updateBlockWithUploadedMedia","media","uploadImages","mediaUrls","Set","map","uploadPromises","Object","fromEntries","entries","fetchMedia","filePromise","uploadPromise","then","blob","Promise","resolve","reject","filesList","onFileChange","isBlobURL","onError","allSettled","catch","finally","jsxs","PanelBody","initialOpen","title","display","flexWrap","gap","__unstableAnimatePresence","onExitComplete","Spinner","Button","size","variant"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-upload-media.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\tSpinner,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState } from '@wordpress/element';\nimport { isBlobURL } from '@wordpress/blob';\n\n/**\n * Internal dependencies\n */\nimport { fetchMedia } from './media-util';\n\nfunction flattenBlocks( blocks ) {\n\tconst result = [];\n\n\tblocks.forEach( ( block ) => {\n\t\tresult.push( block );\n\t\tresult.push( ...flattenBlocks( block.innerBlocks ) );\n\t} );\n\n\treturn result;\n}\n\n/**\n * Determine whether a block has external media.\n *\n * Different blocks use different attribute names (and potentially\n * different logic as well) in determining whether the media is\n * present, and whether it's external.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {boolean?} Whether the block has external media\n */\nfunction hasExternalMedia( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\treturn block.attributes.url && ! block.attributes.id;\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\treturn block.attributes.mediaUrl && ! block.attributes.mediaId;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Retrieve media info from a block.\n *\n * Different blocks use different attribute names, so we need this\n * function to normalize things into a consistent naming scheme.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {{url: ?string, alt: ?string, id: ?number}} The media info for the block.\n */\nfunction getMediaInfo( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\tconst { url, alt, id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\tconst { mediaUrl: url, mediaAlt: alt, mediaId: id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\treturn {};\n}\n\n// Image component to represent a single image in the upload dialog.\nfunction Image( { clientId, alt, url } ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn (\n\t\t<motion.img\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\taria-label={ __( 'Select image block.' ) }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( event.key === 'Enter' || event.key === ' ' ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tkey={ clientId }\n\t\t\talt={ alt }\n\t\t\tsrc={ url }\n\t\t\tanimate={ { opacity: 1 } }\n\t\t\texit={ { opacity: 0, scale: 0 } }\n\t\t\tstyle={ {\n\t\t\t\twidth: '32px',\n\t\t\t\theight: '32px',\n\t\t\t\tobjectFit: 'cover',\n\t\t\t\tborderRadius: '2px',\n\t\t\t\tcursor: 'pointer',\n\t\t\t} }\n\t\t\twhileHover={ { scale: 1.08 } }\n\t\t/>\n\t);\n}\n\nexport default function MaybeUploadMediaPanel() {\n\tconst [ isUploading, setIsUploading ] = useState( false );\n\tconst [ isAnimating, setIsAnimating ] = useState( false );\n\tconst [ hadUploadError, setHadUploadError ] = useState( false );\n\tconst { editorBlocks, mediaUpload } = useSelect(\n\t\t( select ) => ( {\n\t\t\teditorBlocks: select( blockEditorStore ).getBlocks(),\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Get a list of blocks with external media.\n\tconst blocksWithExternalMedia = flattenBlocks( editorBlocks ).filter(\n\t\t( block ) => hasExternalMedia( block )\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tif ( ! mediaUpload || ! blocksWithExternalMedia.length ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'External media' ) }\n\t\t</span>,\n\t];\n\n\t/**\n\t * Update an individual block to point to newly-added library media.\n\t *\n\t * Different blocks use different attribute names, so we need this\n\t * function to ensure we modify the correct attributes for each type.\n\t *\n\t * @param {{name: string, attributes: Object}} block The block.\n\t * @param {{id: number, url: string}} media Media library file info.\n\t */\n\tfunction updateBlockWithUploadedMedia( block, media ) {\n\t\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tid: media.id,\n\t\t\t\turl: media.url,\n\t\t\t} );\n\t\t}\n\n\t\tif ( block.name === 'core/media-text' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tmediaId: media.id,\n\t\t\t\tmediaUrl: media.url,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle fetching and uploading all external media in the post.\n\tfunction uploadImages() {\n\t\tsetIsUploading( true );\n\t\tsetHadUploadError( false );\n\n\t\t// Multiple blocks can be using the same URL, so we\n\t\t// should ensure we only fetch and upload each of them once.\n\t\tconst mediaUrls = new Set(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\t\t\t\treturn url;\n\t\t\t} )\n\t\t);\n\n\t\t// Create an upload promise for each URL, that we can wait for in all\n\t\t// blocks that make use of that media.\n\t\tconst uploadPromises = Object.fromEntries(\n\t\t\tObject.entries( fetchMedia( [ ...mediaUrls ] ) ).map(\n\t\t\t\t( [ url, filePromise ] ) => {\n\t\t\t\t\tconst uploadPromise = filePromise.then(\n\t\t\t\t\t\t( blob ) =>\n\t\t\t\t\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\t\t\t\t\tmediaUpload( {\n\t\t\t\t\t\t\t\t\tfilesList: [ blob ],\n\t\t\t\t\t\t\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\t\t\t\t\t\t\tif ( isBlobURL( media.url ) ) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tresolve( media );\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tonError() {\n\t\t\t\t\t\t\t\t\t\treject();\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);\n\n\t\t\t\t\treturn [ url, uploadPromise ];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\n\t\t// Wait for all blocks to be updated with library media.\n\t\tPromise.allSettled(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\n\t\t\t\treturn uploadPromises[ url ]\n\t\t\t\t\t.then( ( media ) =>\n\t\t\t\t\t\tupdateBlockWithUploadedMedia( block, media )\n\t\t\t\t\t)\n\t\t\t\t\t.then( () => setIsAnimating( true ) )\n\t\t\t\t\t.catch( () => setHadUploadError( true ) );\n\t\t\t} )\n\t\t).finally( () => {\n\t\t\tsetIsUploading( false );\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'inline-flex',\n\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\tgap: '8px',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<AnimatePresence\n\t\t\t\t\tonExitComplete={ () => setIsAnimating( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ blocksWithExternalMedia.map( ( block ) => {\n\t\t\t\t\t\tconst { url, alt } = getMediaInfo( block );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\t\tkey={ block.clientId }\n\t\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\talt={ alt }\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</AnimatePresence>\n\t\t\t\t{ isUploading || isAnimating ? (\n\t\t\t\t\t<Spinner />\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ uploadImages }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ hadUploadError && <p>{ __( 'Upload failed, try again.' ) }</p> }\n\t\t</PanelBody>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA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AA,EAAChC,WAAA,CAAA4G,yBAAe;QACfC,cAAc,EAAGA,CAAA,KAAMjD,cAAc,CAAE,KAAM,CAAG;QAAAe,QAAA,EAE9CN,uBAAuB,CAACY,GAAG,CAAIpE,KAAK,IAAM;UAC3C,MAAM;YAAEM,GAAG;YAAEM;UAAI,CAAC,GAAGD,YAAY,CAAEX,KAAM,CAAC;UAC1C,oBACC,IAAAL,WAAA,CAAAwB,GAAA,EAACL,KAAK;YAELC,QAAQ,EAAGf,KAAK,CAACe,QAAU;YAC3BT,GAAG,EAAGA,GAAK;YACXM,GAAG,EAAGA;UAAK,GAHLZ,KAAK,CAACe,QAIZ,CAAC;QAEJ,CAAE;MAAC,CACa,CAAC,EAChB4B,WAAW,IAAIG,WAAW,gBAC3B,IAAAnD,WAAA,CAAAwB,GAAA,EAAChC,WAAA,CAAA8G,OAAO,IAAE,CAAC,gBAEX,IAAAtG,WAAA,CAAAwB,GAAA,EAAChC,WAAA,CAAA+G,MAAM;QACNC,IAAI,EAAC,SAAS;QACdC,OAAO,EAAC,SAAS;QACjB3E,OAAO,EAAGwC,YAAc;QAAAH,QAAA,EAEtB,IAAAtC,QAAE,EAAE,QAAS;MAAC,CACT,CACR;IAAA,CACG,CAAC,EACJwB,cAAc,iBAAI,IAAArD,WAAA,CAAAwB,GAAA;MAAA2C,QAAA,EAAK,IAAAtC,QAAE,EAAE,2BAA4B;IAAC,CAAK,CAAC;EAAA,CACtD,CAAC;AAEd","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_uuid","require","_url","generateUniqueBasenames","urls","basenames","Set","Object","fromEntries","map","url","filename","getFilename","basename","parts","split","length","pop","join","uuid","has","add","fetchMedia","entries","filePromise","window","fetch","includes","then","response","blob","File","type"],"sources":["@wordpress/editor/src/components/post-publish-panel/media-util.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Generate a list of unique basenames given a list of URLs.\n *\n * We want all basenames to be unique, since sometimes the extension\n * doesn't reflect the mime type, and may end up getting changed by\n * the server, on upload.\n *\n * @param {string[]} urls The list of URLs\n * @return {Record< string, string >} A URL => basename record.\n */\nexport function generateUniqueBasenames( urls ) {\n\tconst basenames = new Set();\n\n\treturn Object.fromEntries(\n\t\turls.map( ( url ) => {\n\t\t\t// We prefer to match the remote filename, if possible.\n\t\t\tconst filename = getFilename( url );\n\t\t\tlet basename = '';\n\n\t\t\tif ( filename ) {\n\t\t\t\tconst parts = filename.split( '.' );\n\t\t\t\tif ( parts.length > 1 ) {\n\t\t\t\t\t// Assume the last part is the extension.\n\t\t\t\t\tparts.pop();\n\t\t\t\t}\n\t\t\t\tbasename = parts.join( '.' );\n\t\t\t}\n\n\t\t\tif ( ! basename ) {\n\t\t\t\t// It looks like we don't have a basename, so let's use a UUID.\n\t\t\t\tbasename = uuid();\n\t\t\t}\n\n\t\t\tif ( basenames.has( basename ) ) {\n\t\t\t\t// Append a UUID to deduplicate the basename.\n\t\t\t\t// The server will try to deduplicate on its own if we don't do this,\n\t\t\t\t// but it may run into a race condition\n\t\t\t\t// (see https://github.com/WordPress/gutenberg/issues/64899).\n\t\t\t\t// Deduplicating the filenames before uploading is safer.\n\t\t\t\tbasename = `${ basename }-${ uuid() }`;\n\t\t\t}\n\n\t\t\tbasenames.add( basename );\n\n\t\t\treturn [ url, basename ];\n\t\t} )\n\t);\n}\n\n/**\n * Fetch a list of URLs, turning those into promises for files with\n * unique filenames.\n *\n * @param {string[]} urls The list of URLs\n * @return {Record< string, Promise< File > >} A URL => File promise record.\n */\nexport function fetchMedia( urls ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( generateUniqueBasenames( urls ) ).map(\n\t\t\t( [ url, basename ] ) => {\n\t\t\t\tconst filePromise = window\n\t\t\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t\t.then( ( blob ) => {\n\t\t\t\t\t\t// The server will reject the upload if it doesn't have an extension,\n\t\t\t\t\t\t// even though it'll rewrite the file name to match the mime type.\n\t\t\t\t\t\t// Here we provide it with a safe extension to get it past that check.\n\t\t\t\t\t\treturn new File( [ blob ], `${ basename }.png`, {\n\t\t\t\t\t\t\ttype: blob.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\n\t\t\t\treturn [ url, filePromise ];\n\t\t\t}\n\t\t)\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,IAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,uBAAuBA,CAAEC,IAAI,EAAG;EAC/C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAE3B,OAAOC,MAAM,CAACC,WAAW,CACxBJ,IAAI,CAACK,GAAG,CAAIC,GAAG,IAAM;IACpB;IACA,MAAMC,QAAQ,GAAG,IAAAC,gBAAW,EAAEF,GAAI,CAAC;IACnC,IAAIG,QAAQ,GAAG,EAAE;IAEjB,IAAKF,QAAQ,EAAG;MACf,MAAMG,KAAK,GAAGH,QAAQ,CAACI,KAAK,CAAE,GAAI,CAAC;MACnC,IAAKD,KAAK,CAACE,MAAM,GAAG,CAAC,EAAG;QACvB;QACAF,KAAK,CAACG,GAAG,CAAC,CAAC;MACZ;MACAJ,QAAQ,GAAGC,KAAK,CAACI,IAAI,CAAE,GAAI,CAAC;IAC7B;IAEA,IAAK,CAAEL,QAAQ,EAAG;MACjB;MACAA,QAAQ,GAAG,IAAAM,QAAI,EAAC,CAAC;IAClB;IAEA,IAAKd,SAAS,CAACe,GAAG,CAAEP,QAAS,CAAC,EAAG;MAChC;MACA;MACA;MACA;MACA;MACAA,QAAQ,GAAI,GAAGA,QAAU,IAAI,IAAAM,QAAI,EAAC,CAAG,EAAC;IACvC;IAEAd,SAAS,CAACgB,GAAG,CAAER,QAAS,CAAC;IAEzB,OAAO,CAAEH,GAAG,EAAEG,QAAQ,CAAE;EACzB,CAAE,CACH,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,UAAUA,CAAElB,IAAI,EAAG;EAClC,OAAOG,MAAM,CAACC,WAAW,CACxBD,MAAM,CAACgB,OAAO,CAAEpB,uBAAuB,CAAEC,IAAK,CAAE,CAAC,CAACK,GAAG,CACpD,CAAE,CAAEC,GAAG,EAAEG,QAAQ,CAAE,KAAM;IACxB,MAAMW,WAAW,GAAGC,MAAM,CACxBC,KAAK,CAAEhB,GAAG,CAACiB,QAAQ,CAAE,GAAI,CAAC,GAAGjB,GAAG,GAAGA,GAAG,GAAG,GAAI,CAAC,CAC9CkB,IAAI,CAAIC,QAAQ,IAAMA,QAAQ,CAACC,IAAI,CAAC,CAAE,CAAC,CACvCF,IAAI,CAAIE,IAAI,IAAM;MAClB;MACA;MACA;MACA,OAAO,IAAIC,IAAI,CAAE,CAAED,IAAI,CAAE,EAAG,GAAGjB,QAAU,MAAK,EAAE;QAC/CmB,IAAI,EAAEF,IAAI,CAACE;MACZ,CAAE,CAAC;IACJ,CAAE,CAAC;IAEJ,OAAO,CAAEtB,GAAG,EAAEc,WAAW,CAAE;EAC5B,CACD,CACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_uuid","require","_url","generateUniqueBasenames","urls","basenames","Set","Object","fromEntries","map","url","filename","getFilename","basename","parts","split","length","pop","join","uuid","has","add","fetchMedia","entries","filePromise","window","fetch","includes","then","response","blob","File","type"],"sources":["@wordpress/editor/src/components/post-publish-panel/media-util.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Generate a list of unique basenames given a list of URLs.\n *\n * We want all basenames to be unique, since sometimes the extension\n * doesn't reflect the mime type, and may end up getting changed by\n * the server, on upload.\n *\n * @param {string[]} urls The list of URLs\n * @return {Record< string, string >} A URL => basename record.\n */\nexport function generateUniqueBasenames( urls ) {\n\tconst basenames = new Set();\n\n\treturn Object.fromEntries(\n\t\turls.map( ( url ) => {\n\t\t\t// We prefer to match the remote filename, if possible.\n\t\t\tconst filename = getFilename( url );\n\t\t\tlet basename = '';\n\n\t\t\tif ( filename ) {\n\t\t\t\tconst parts = filename.split( '.' );\n\t\t\t\tif ( parts.length > 1 ) {\n\t\t\t\t\t// Assume the last part is the extension.\n\t\t\t\t\tparts.pop();\n\t\t\t\t}\n\t\t\t\tbasename = parts.join( '.' );\n\t\t\t}\n\n\t\t\tif ( ! basename ) {\n\t\t\t\t// It looks like we don't have a basename, so let's use a UUID.\n\t\t\t\tbasename = uuid();\n\t\t\t}\n\n\t\t\tif ( basenames.has( basename ) ) {\n\t\t\t\t// Append a UUID to deduplicate the basename.\n\t\t\t\t// The server will try to deduplicate on its own if we don't do this,\n\t\t\t\t// but it may run into a race condition\n\t\t\t\t// (see https://github.com/WordPress/gutenberg/issues/64899).\n\t\t\t\t// Deduplicating the filenames before uploading is safer.\n\t\t\t\tbasename = `${ basename }-${ uuid() }`;\n\t\t\t}\n\n\t\t\tbasenames.add( basename );\n\n\t\t\treturn [ url, basename ];\n\t\t} )\n\t);\n}\n\n/**\n * Fetch a list of URLs, turning those into promises for files with\n * unique filenames.\n *\n * @param {string[]} urls The list of URLs\n * @return {Record< string, Promise< File > >} A URL => File promise record.\n */\nexport function fetchMedia( urls ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( generateUniqueBasenames( urls ) ).map(\n\t\t\t( [ url, basename ] ) => {\n\t\t\t\tconst filePromise = window\n\t\t\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t\t.then( ( blob ) => {\n\t\t\t\t\t\t// The server will reject the upload if it doesn't have an extension,\n\t\t\t\t\t\t// even though it'll rewrite the file name to match the mime type.\n\t\t\t\t\t\t// Here we provide it with a safe extension to get it past that check.\n\t\t\t\t\t\treturn new File( [ blob ], `${ basename }.png`, {\n\t\t\t\t\t\t\ttype: blob.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\n\t\t\t\treturn [ url, filePromise ];\n\t\t\t}\n\t\t)\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,IAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,uBAAuBA,CAAEC,IAAI,EAAG;EAC/C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAE3B,OAAOC,MAAM,CAACC,WAAW,CACxBJ,IAAI,CAACK,GAAG,CAAIC,GAAG,IAAM;IACpB;IACA,MAAMC,QAAQ,GAAG,IAAAC,gBAAW,EAAEF,GAAI,CAAC;IACnC,IAAIG,QAAQ,GAAG,EAAE;IAEjB,IAAKF,QAAQ,EAAG;MACf,MAAMG,KAAK,GAAGH,QAAQ,CAACI,KAAK,CAAE,GAAI,CAAC;MACnC,IAAKD,KAAK,CAACE,MAAM,GAAG,CAAC,EAAG;QACvB;QACAF,KAAK,CAACG,GAAG,CAAC,CAAC;MACZ;MACAJ,QAAQ,GAAGC,KAAK,CAACI,IAAI,CAAE,GAAI,CAAC;IAC7B;IAEA,IAAK,CAAEL,QAAQ,EAAG;MACjB;MACAA,QAAQ,GAAG,IAAAM,QAAI,EAAC,CAAC;IAClB;IAEA,IAAKd,SAAS,CAACe,GAAG,CAAEP,QAAS,CAAC,EAAG;MAChC;MACA;MACA;MACA;MACA;MACAA,QAAQ,GAAI,GAAGA,QAAU,IAAI,IAAAM,QAAI,EAAC,CAAG,EAAC;IACvC;IAEAd,SAAS,CAACgB,GAAG,CAAER,QAAS,CAAC;IAEzB,OAAO,CAAEH,GAAG,EAAEG,QAAQ,CAAE;EACzB,CAAE,CACH,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,UAAUA,CAAElB,IAAI,EAAG;EAClC,OAAOG,MAAM,CAACC,WAAW,CACxBD,MAAM,CAACgB,OAAO,CAAEpB,uBAAuB,CAAEC,IAAK,CAAE,CAAC,CAACK,GAAG,CACpD,CAAE,CAAEC,GAAG,EAAEG,QAAQ,CAAE,KAAM;IACxB,MAAMW,WAAW,GAAGC,MAAM,CACxBC,KAAK,CAAEhB,GAAG,CAACiB,QAAQ,CAAE,GAAI,CAAC,GAAGjB,GAAG,GAAGA,GAAG,GAAG,GAAI,CAAC,CAC9CkB,IAAI,CAAIC,QAAQ,IAAMA,QAAQ,CAACC,IAAI,CAAC,CAAE,CAAC,CACvCF,IAAI,CAAIE,IAAI,IAAM;MAClB;MACA;MACA;MACA,OAAO,IAAIC,IAAI,CAAE,CAAED,IAAI,CAAE,EAAG,GAAGjB,QAAU,MAAK,EAAE;QAC/CmB,IAAI,EAAEF,IAAI,CAACE;MACZ,CAAE,CAAC;IACJ,CAAE,CAAC;IAEJ,OAAO,CAAEtB,GAAG,EAAEc,WAAW,CAAE;EAC5B,CACD,CACD,CAAC;AACF","ignoreList":[]}
@@ -33,7 +33,7 @@ var _jsxRuntime = require("react/jsx-runtime");
33
33
  * Internal dependencies
34
34
  */
35
35
 
36
- function PostTitle(_, forwardedRef) {
36
+ const PostTitle = (0, _element.forwardRef)((_, forwardedRef) => {
37
37
  const {
38
38
  placeholder
39
39
  } = (0, _data.useSelect)(select => {
@@ -167,24 +167,21 @@ function PostTitle(_, forwardedRef) {
167
167
  return (
168
168
  /*#__PURE__*/
169
169
  /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
170
- (0, _jsxRuntime.jsx)(_postTypeSupportCheck.default, {
171
- supportKeys: "title",
172
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
173
- ref: (0, _compose.useMergeRefs)([richTextRef, focusRef]),
174
- contentEditable: true,
175
- className: className,
176
- "aria-label": decodedPlaceholder,
177
- role: "textbox",
178
- "aria-multiline": "true",
179
- onFocus: onSelect,
180
- onBlur: onUnselect,
181
- onKeyDown: onKeyDown,
182
- onPaste: onPaste
183
- })
170
+ (0, _jsxRuntime.jsx)("h1", {
171
+ ref: (0, _compose.useMergeRefs)([richTextRef, focusRef]),
172
+ contentEditable: true,
173
+ className: className,
174
+ "aria-label": decodedPlaceholder,
175
+ role: "textbox",
176
+ "aria-multiline": "true",
177
+ onFocus: onSelect,
178
+ onBlur: onUnselect,
179
+ onKeyDown: onKeyDown,
180
+ onPaste: onPaste
184
181
  })
185
182
  /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
186
183
  );
187
- }
184
+ });
188
185
 
189
186
  /**
190
187
  * Renders the `PostTitle` component.
@@ -194,5 +191,10 @@ function PostTitle(_, forwardedRef) {
194
191
  *
195
192
  * @return {Component} The rendered PostTitle component.
196
193
  */
197
- var _default = exports.default = (0, _element.forwardRef)(PostTitle);
194
+ var _default = exports.default = (0, _element.forwardRef)((_, forwardedRef) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_postTypeSupportCheck.default, {
195
+ supportKeys: "title",
196
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PostTitle, {
197
+ ref: forwardedRef
198
+ })
199
+ }));
198
200
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_element","_htmlEntities","_data","_blockEditor","_keycodes","_blocks","_richText","_compose","_dom","_constants","_usePostTitleFocus","_usePostTitle","_postTypeSupportCheck","_jsxRuntime","PostTitle","_","forwardedRef","placeholder","useSelect","select","getSettings","blockEditorStore","titlePlaceholder","isSelected","setIsSelected","useState","ref","focusRef","usePostTitleFocus","title","setTitle","onUpdate","usePostTitle","selection","setSelection","clearSelectedBlock","insertBlocks","insertDefaultBlock","useDispatch","decodedPlaceholder","decodeEntities","__","value","onChange","richTextRef","useRichText","newValue","replace","REGEXP_NEWLINES","selectionStart","start","selectionEnd","end","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","onInsertBlockAfter","blocks","onSelect","onUnselect","onEnterPress","undefined","onKeyDown","event","keyCode","ENTER","preventDefault","onPaste","clipboardData","plainText","html","getData","error","window","console","log","content","pasteHandler","HTML","length","firstBlock","name","contentNoHTML","stripHTML","attributes","slice","insert","create","className","clsx","DEFAULT_CLASSNAMES","jsx","default","supportKeys","children","useMergeRefs","contentEditable","role","onFocus","onBlur","_default","exports","forwardRef"],"sources":["@wordpress/editor/src/components/post-title/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst { placeholder } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder } = getSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: title,\n\t\tonChange( newValue ) {\n\t\t\tonUpdate( newValue.replace( REGEXP_NEWLINES, ' ' ) );\n\t\t},\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error ) {\n\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t// behaviour.\n\t\t\treturn;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\t\t\tonChange( insert( value, create( { html: contentNoHTML } ) ) );\n\t\t}\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t} );\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\t\tcontentEditable\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ decodedPlaceholder }\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline=\"true\"\n\t\t\t\tonFocus={ onSelect }\n\t\t\t\tonBlur={ onUnselect }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonPaste={ onPaste }\n\t\t\t/>\n\t\t</PostTypeSupportCheck>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n}\n\n/**\n * Renders the `PostTitle` component.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Forwarded ref for the component.\n *\n * @return {Component} The rendered PostTitle component.\n */\nexport default forwardRef( PostTitle );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAKA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,IAAA,GAAAV,OAAA;AAKA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,kBAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,aAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,qBAAA,GAAAf,sBAAA,CAAAC,OAAA;AAA8D,IAAAe,WAAA,GAAAf,OAAA;AA5B9D;AACA;AACA;;AAEA;AACA;AACA;;AAgBA;AACA;AACA;;AAMA,SAASgB,SA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F,GAAA,EAACjF,qBAAA,CAAAkF,OAAoB;MAACC,WAAW,EAAC,OAAO;MAAAC,QAAA,eACxC,IAAAnF,WAAA,CAAAgF,GAAA;QACCnE,GAAG,EAAG,IAAAuE,qBAAY,EAAE,CAAErD,WAAW,EAAEjB,QAAQ,CAAG,CAAG;QACjDuE,eAAe;QACfR,SAAS,EAAGA,SAAW;QACvB,cAAanD,kBAAoB;QACjC4D,IAAI,EAAC,SAAS;QACd,kBAAe,MAAM;QACrBC,OAAO,EAAGxC,QAAU;QACpByC,MAAM,EAAGxC,UAAY;QACrBG,SAAS,EAAGA,SAAW;QACvBK,OAAO,EAAGA;MAAS,CACnB;IAAC,CACmB;IACtB;EAAA;AAEF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAAAiC,QAAA,GAAAC,OAAA,CAAAT,OAAA,GAQe,IAAAU,mBAAU,EAAE1F,SAAU,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_element","_htmlEntities","_data","_blockEditor","_keycodes","_blocks","_richText","_compose","_dom","_constants","_usePostTitleFocus","_usePostTitle","_postTypeSupportCheck","_jsxRuntime","PostTitle","forwardRef","_","forwardedRef","placeholder","useSelect","select","getSettings","blockEditorStore","titlePlaceholder","isSelected","setIsSelected","useState","ref","focusRef","usePostTitleFocus","title","setTitle","onUpdate","usePostTitle","selection","setSelection","clearSelectedBlock","insertBlocks","insertDefaultBlock","useDispatch","decodedPlaceholder","decodeEntities","__","value","onChange","richTextRef","useRichText","newValue","replace","REGEXP_NEWLINES","selectionStart","start","selectionEnd","end","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","onInsertBlockAfter","blocks","onSelect","onUnselect","onEnterPress","undefined","onKeyDown","event","keyCode","ENTER","preventDefault","onPaste","clipboardData","plainText","html","getData","error","window","console","log","content","pasteHandler","HTML","length","firstBlock","name","contentNoHTML","stripHTML","attributes","slice","insert","create","className","clsx","DEFAULT_CLASSNAMES","jsx","useMergeRefs","contentEditable","role","onFocus","onBlur","_default","exports","default","supportKeys","children"],"sources":["@wordpress/editor/src/components/post-title/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nconst PostTitle = forwardRef( ( _, forwardedRef ) => {\n\tconst { placeholder } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder } = getSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: title,\n\t\tonChange( newValue ) {\n\t\t\tonUpdate( newValue.replace( REGEXP_NEWLINES, ' ' ) );\n\t\t},\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error ) {\n\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t// behaviour.\n\t\t\treturn;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\t\t\tonChange( insert( value, create( { html: contentNoHTML } ) ) );\n\t\t}\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = clsx( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t} );\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<h1\n\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\tcontentEditable\n\t\t\tclassName={ className }\n\t\t\taria-label={ decodedPlaceholder }\n\t\t\trole=\"textbox\"\n\t\t\taria-multiline=\"true\"\n\t\t\tonFocus={ onSelect }\n\t\t\tonBlur={ onUnselect }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonPaste={ onPaste }\n\t\t/>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n} );\n\n/**\n * Renders the `PostTitle` component.\n *\n * @param {Object} _ Unused parameter.\n * @param {Element} forwardedRef Forwarded ref for the component.\n *\n * @return {Component} The rendered PostTitle component.\n */\nexport default forwardRef( ( _, forwardedRef ) => (\n\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t<PostTitle ref={ forwardedRef } />\n\t</PostTypeSupportCheck>\n) );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAKA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,IAAA,GAAAV,OAAA;AAKA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,kBAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,aAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,qBAAA,GAAAf,sBAAA,CAAAC,OAAA;AAA8D,IAAAe,WAAA,GAAAf,OAAA;AA5B9D;AACA;AACA;;AAEA;AACA;AACA;;AAgBA;AACA;AACA;;AAMA,MAAMgB,SAAS,GAAG,IAAAC,mBAAU,EAAE,CAAEC,CAAC,EAAEC,YAAY,KAAM;EACpD,MAAM;IAAEC;EAAY,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAChD,MAAM;MAAEC;IAAY,CAAC,GAAGD,MAAM,CAAEE,kBAAiB,CAAC;IAClD,MAAM;MAAEC;IAAiB,CAAC,GAAGF,WAAW,CAAC,CAAC;IAE1C,OAAO;MACNH,WAAW,EAAEK;IACd,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAAG,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AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAAA8B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAQe,IAAAvF,mBAAU,EAAE,CAAEC,CAAC,EAAEC,YAAY,kBAC3C,IAAAJ,WAAA,CAAAiF,GAAA,EAAClF,qBAAA,CAAA0F,OAAoB;EAACC,WAAW,EAAC,OAAO;EAAAC,QAAA,eACxC,IAAA3F,WAAA,CAAAiF,GAAA,EAAChF,SAAS;IAACa,GAAG,EAAGV;EAAc,CAAE;AAAC,CACb,CACrB,CAAC","ignoreList":[]}
@@ -29,15 +29,15 @@ var _globalStylesProvider = require("../global-styles-provider");
29
29
  const EMPTY_OBJECT = {};
30
30
  function __experimentalReusableBlocksSelect(select) {
31
31
  const {
32
- getEntityRecords,
33
- hasFinishedResolution
32
+ RECEIVE_INTERMEDIATE_RESULTS
33
+ } = (0, _lockUnlock.unlock)(_coreData.privateApis);
34
+ const {
35
+ getEntityRecords
34
36
  } = select(_coreData.store);
35
- const reusableBlocks = getEntityRecords('postType', 'wp_block', {
36
- per_page: -1
37
+ return getEntityRecords('postType', 'wp_block', {
38
+ per_page: -1,
39
+ [RECEIVE_INTERMEDIATE_RESULTS]: true
37
40
  });
38
- return hasFinishedResolution('getEntityRecords', ['postType', 'wp_block', {
39
- per_page: -1
40
- }]) ? reusableBlocks : undefined;
41
41
  }
42
42
  const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', 'alignWide', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'canUpdateBlockBindings', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'fontSizes', 'gradients', 'generateAnchors', 'onNavigateToEntityRecord', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'locale', 'maxWidth', 'postContentAttributes', 'postsPerPage', 'readOnly', 'styles', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme'];
43
43
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_coreData","_i18n","_preferences","_compose","_blocks","_blockEditor","_mediaCategories","_interopRequireDefault","_utils","_store","_lockUnlock","_globalStylesProvider","EMPTY_OBJECT","__experimentalReusableBlocksSelect","select","getEntityRecords","hasFinishedResolution","coreStore","reusableBlocks","per_page","undefined","BLOCK_EDITOR_SETTINGS","globalStylesDataKey","globalStylesLinksDataKey","selectBlockPatternsKey","reusableBlocksSelectKey","sectionRootClientIdKey","unlock","privateApis","useBlockEditorSettings","settings","postType","postId","renderingMode","_mergedGlobalStyles$s","_mergedGlobalStyles$_","_settings$__experimen","_settings$__experimen2","isLargeViewport","useViewportMatch","allowRightClickOverrides","blockTypes","focusMode","hasFixedToolbar","isDistractionFree","keepCaretInsideBlock","hasUploadPermissions","hiddenBlockTypes","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","pageForPosts","userPatternCategories","restBlockPatternCategories","sectionRootClientId","useSelect","_canUser","canUser","getRawEntityRecord","getEntityRecord","getUserPatternCategories","getBlockPatternCategories","get","preferencesStore","getBlockTypes","blocksStore","getBlocksByName","getBlockAttributes","blockEditorStore","siteSettings","kind","name","getSectionRootBlock","_getBlocksByName$find","_getBlocksByName$","find","clientId","tagName","_links","hasOwnProperty","page_on_front","page_for_posts","merged","mergedGlobalStyles","useGlobalStylesContext","globalStylesData","styles","globalStylesLinksData","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","blockPatterns","useMemo","filter","postTypes","Array","isArray","includes","blockPatternCategories","x","index","arr","findIndex","y","undo","setIsInserterOpened","useDispatch","editorStore","saveEntityRecord","createPageEntity","useCallback","options","Promise","reject","message","__","allowedBlockTypes","length","defaultAllowedBlockTypes","map","type","forceDisableFocusMode","blockEditorSettings","Object","fromEntries","entries","key","mediaUpload","getBlockPatternsForPostType","patterns","__experimentalUserPatternCategories","__experimentalFetchLinkSuggestions","search","searchOptions","fetchLinkSuggestions","inserterMediaCategories","__experimentalFetchRichUrlData","fetchUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot","templateLock","template","__experimentalSetIsInserterOpened","_default","exports","default"],"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useGlobalStylesContext } from '../global-styles-provider';\n\nconst EMPTY_OBJECT = {};\n\nfunction __experimentalReusableBlocksSelect( select ) {\n\tconst { getEntityRecords, hasFinishedResolution } = select( coreStore );\n\tconst reusableBlocks = getEntityRecords( 'postType', 'wp_block', {\n\t\tper_page: -1,\n\t} );\n\treturn hasFinishedResolution( 'getEntityRecords', [\n\t\t'postType',\n\t\t'wp_block',\n\t\t{ per_page: -1 },\n\t] )\n\t\t? reusableBlocks\n\t\t: undefined;\n}\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'alignWide',\n\t'blockInspectorTabs',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'canUpdateBlockBindings',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'onNavigateToEntityRecord',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isRTL',\n\t'locale',\n\t'maxWidth',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableIsPreviewMode',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n];\n\nconst {\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n} = unlock( privateApis );\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n * @param {string} renderingMode Editor rendering mode.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId, renderingMode ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tallowRightClickOverrides,\n\t\tblockTypes,\n\t\tfocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\thasUploadPermissions,\n\t\thiddenBlockTypes,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tuserPatternCategories,\n\t\trestBlockPatternCategories,\n\t\tsectionRootClientId,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetUserPatternCategories,\n\t\t\t\tgetBlockPatternCategories,\n\t\t\t} = select( coreStore );\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst { getBlocksByName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tfunction getSectionRootBlock() {\n\t\t\t\tif ( renderingMode === 'template-locked' ) {\n\t\t\t\t\treturn getBlocksByName( 'core/post-content' )?.[ 0 ] ?? '';\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tgetBlocksByName( 'core/group' ).find(\n\t\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )?.tagName === 'main'\n\t\t\t\t\t) ?? ''\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tallowRightClickOverrides: get(\n\t\t\t\t\t'core',\n\t\t\t\t\t'allowRightClickOverrides'\n\t\t\t\t),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\tfocusMode: get( 'core', 'focusMode' ),\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tget( 'core', 'fixedToolbar' ) || ! isLargeViewport,\n\t\t\t\thiddenBlockTypes: get( 'core', 'hiddenBlockTypes' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tkeepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),\n\t\t\t\thasUploadPermissions:\n\t\t\t\t\tcanUser( 'create', {\n\t\t\t\t\t\tkind: 'root',\n\t\t\t\t\t\tname: 'media',\n\t\t\t\t\t} ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'page',\n\t\t\t\t} ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t\t\trestBlockPatternCategories: getBlockPatternCategories(),\n\t\t\t\tsectionRootClientId: getSectionRootBlock(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId, isLargeViewport, renderingMode ]\n\t);\n\n\tconst { merged: mergedGlobalStyles } = useGlobalStylesContext();\n\tconst globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT;\n\tconst globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT;\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[ ...( settingsBlockPatterns || [] ) ].filter(\n\t\t\t\t( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t),\n\t\t[ settingsBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo, setIsInserterOpened } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\tconst allowedBlockTypes = useMemo( () => {\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes && hiddenBlockTypes.length > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\treturn defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn settings.allowedBlockTypes;\n\t}, [ settings.allowedBlockTypes, hiddenBlockTypes, blockTypes ] );\n\n\tconst forceDisableFocusMode = settings.focusMode === false;\n\n\treturn useMemo( () => {\n\t\tconst blockEditorSettings = {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\t[ globalStylesDataKey ]: globalStylesData,\n\t\t\t[ globalStylesLinksDataKey ]: globalStylesLinksData,\n\t\t\tallowedBlockTypes,\n\t\t\tallowRightClickOverrides,\n\t\t\tfocusMode: focusMode && ! forceDisableFocusMode,\n\t\t\thasFixedToolbar,\n\t\t\tisDistractionFree,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t[ selectBlockPatternsKey ]: ( select ) => {\n\t\t\t\tconst { hasFinishedResolution, getBlockPatternsForPostType } =\n\t\t\t\t\tunlock( select( coreStore ) );\n\t\t\t\tconst patterns = getBlockPatternsForPostType( postType );\n\t\t\t\treturn hasFinishedResolution( 'getBlockPatterns' )\n\t\t\t\t\t? patterns\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t\t[ reusableBlocksSelectKey ]: __experimentalReusableBlocksSelect,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: ! isDistractionFree && postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\t[ sectionRootClientIdKey ]: sectionRootClientId,\n\t\t};\n\n\t\treturn blockEditorSettings;\n\t}, [\n\t\tallowedBlockTypes,\n\t\tallowRightClickOverrides,\n\t\tfocusMode,\n\t\tforceDisableFocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\tsettings,\n\t\thasUploadPermissions,\n\t\tuserPatternCategories,\n\t\tblockPatterns,\n\t\tblockPatternCategories,\n\t\tcanUseUnfilteredHTML,\n\t\tundo,\n\t\tcreatePageEntity,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tpostType,\n\t\tsetIsInserterOpened,\n\t\tsectionRootClientId,\n\t\tglobalStylesData,\n\t\tglobalStylesLinksData,\n\t] );\n}\n\nexport default useBlockEditorS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qB,EACrBjF,eAAe,EACfC,iBAAiB,EACjBC,oBAAoB,EACpBf,QAAQ,EACRgB,oBAAoB,EACpBM,qBAAqB,EACrB0C,aAAa,EACbO,sBAAsB,EACtBrD,oBAAoB,EACpB2D,IAAI,EACJK,gBAAgB,EAChB/D,kBAAkB,EAClBC,WAAW,EACXC,YAAY,EACZpB,QAAQ,EACR6E,mBAAmB,EACnBtD,mBAAmB,EACnB+B,gBAAgB,EAChBE,qBAAqB,CACpB,CAAC;AACJ;AAAC,IAAA+D,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc3H,sBAAsB","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_data","_coreData","_i18n","_preferences","_compose","_blocks","_blockEditor","_mediaCategories","_interopRequireDefault","_utils","_store","_lockUnlock","_globalStylesProvider","EMPTY_OBJECT","__experimentalReusableBlocksSelect","select","RECEIVE_INTERMEDIATE_RESULTS","unlock","coreDataPrivateApis","getEntityRecords","coreStore","per_page","BLOCK_EDITOR_SETTINGS","globalStylesDataKey","globalStylesLinksDataKey","selectBlockPatternsKey","reusableBlocksSelectKey","sectionRootClientIdKey","privateApis","useBlockEditorSettings","settings","postType","postId","renderingMode","_mergedGlobalStyles$s","_mergedGlobalStyles$_","_settings$__experimen","_settings$__experimen2","isLargeViewport","useViewportMatch","allowRightClickOverrides","blockTypes","focusMode","hasFixedToolbar","isDistractionFree","keepCaretInsideBlock","hasUploadPermissions","hiddenBlockTypes","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","pageForPosts","userPatternCategories","restBlockPatternCategories","sectionRootClientId","useSelect","_canUser","canUser","getRawEntityRecord","getEntityRecord","getUserPatternCategories","getBlockPatternCategories","get","preferencesStore","getBlockTypes","blocksStore","getBlocksByName","getBlockAttributes","blockEditorStore","siteSettings","kind","name","undefined","getSectionRootBlock","_getBlocksByName$find","_getBlocksByName$","find","clientId","tagName","_links","hasOwnProperty","page_on_front","page_for_posts","merged","mergedGlobalStyles","useGlobalStylesContext","globalStylesData","styles","globalStylesLinksData","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","blockPatterns","useMemo","filter","postTypes","Array","isArray","includes","blockPatternCategories","x","index","arr","findIndex","y","undo","setIsInserterOpened","useDispatch","editorStore","saveEntityRecord","createPageEntity","useCallback","options","Promise","reject","message","__","allowedBlockTypes","length","defaultAllowedBlockTypes","map","type","forceDisableFocusMode","blockEditorSettings","Object","fromEntries","entries","key","mediaUpload","hasFinishedResolution","getBlockPatternsForPostType","patterns","__experimentalUserPatternCategories","__experimentalFetchLinkSuggestions","search","searchOptions","fetchLinkSuggestions","inserterMediaCategories","__experimentalFetchRichUrlData","fetchUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot","templateLock","template","__experimentalSetIsInserterOpened","_default","exports","default"],"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useGlobalStylesContext } from '../global-styles-provider';\n\nconst EMPTY_OBJECT = {};\n\nfunction __experimentalReusableBlocksSelect( select ) {\n\tconst { RECEIVE_INTERMEDIATE_RESULTS } = unlock( coreDataPrivateApis );\n\tconst { getEntityRecords } = select( coreStore );\n\treturn getEntityRecords( 'postType', 'wp_block', {\n\t\tper_page: -1,\n\t\t[ RECEIVE_INTERMEDIATE_RESULTS ]: true,\n\t} );\n}\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'alignWide',\n\t'blockInspectorTabs',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'canUpdateBlockBindings',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'onNavigateToEntityRecord',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isRTL',\n\t'locale',\n\t'maxWidth',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableIsPreviewMode',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n];\n\nconst {\n\tglobalStylesDataKey,\n\tglobalStylesLinksDataKey,\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n} = unlock( privateApis );\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n * @param {string} renderingMode Editor rendering mode.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId, renderingMode ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tallowRightClickOverrides,\n\t\tblockTypes,\n\t\tfocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\thasUploadPermissions,\n\t\thiddenBlockTypes,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tuserPatternCategories,\n\t\trestBlockPatternCategories,\n\t\tsectionRootClientId,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetUserPatternCategories,\n\t\t\t\tgetBlockPatternCategories,\n\t\t\t} = select( coreStore );\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst { getBlocksByName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tfunction getSectionRootBlock() {\n\t\t\t\tif ( renderingMode === 'template-locked' ) {\n\t\t\t\t\treturn getBlocksByName( 'core/post-content' )?.[ 0 ] ?? '';\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tgetBlocksByName( 'core/group' ).find(\n\t\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )?.tagName === 'main'\n\t\t\t\t\t) ?? ''\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tallowRightClickOverrides: get(\n\t\t\t\t\t'core',\n\t\t\t\t\t'allowRightClickOverrides'\n\t\t\t\t),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\tfocusMode: get( 'core', 'focusMode' ),\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tget( 'core', 'fixedToolbar' ) || ! isLargeViewport,\n\t\t\t\thiddenBlockTypes: get( 'core', 'hiddenBlockTypes' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tkeepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),\n\t\t\t\thasUploadPermissions:\n\t\t\t\t\tcanUser( 'create', {\n\t\t\t\t\t\tkind: 'root',\n\t\t\t\t\t\tname: 'media',\n\t\t\t\t\t} ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'page',\n\t\t\t\t} ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t\t\trestBlockPatternCategories: getBlockPatternCategories(),\n\t\t\t\tsectionRootClientId: getSectionRootBlock(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId, isLargeViewport, renderingMode ]\n\t);\n\n\tconst { merged: mergedGlobalStyles } = useGlobalStylesContext();\n\tconst globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT;\n\tconst globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT;\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[ ...( settingsBlockPatterns || [] ) ].filter(\n\t\t\t\t( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t),\n\t\t[ settingsBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo, setIsInserterOpened } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\tconst allowedBlockTypes = useMemo( () => {\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes && hiddenBlockTypes.length > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\treturn defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn settings.allowedBlockTypes;\n\t}, [ settings.allowedBlockTypes, hiddenBlockTypes, blockTypes ] );\n\n\tconst forceDisableFocusMode = settings.focusMode === false;\n\n\treturn useMemo( () => {\n\t\tconst blockEditorSettings = {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\t[ globalStylesDataKey ]: globalStylesData,\n\t\t\t[ globalStylesLinksDataKey ]: globalStylesLinksData,\n\t\t\tallowedBlockTypes,\n\t\t\tallowRightClickOverrides,\n\t\t\tfocusMode: focusMode && ! forceDisableFocusMode,\n\t\t\thasFixedToolbar,\n\t\t\tisDistractionFree,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t[ selectBlockPatternsKey ]: ( select ) => {\n\t\t\t\tconst { hasFinishedResolution, getBlockPatternsForPostType } =\n\t\t\t\t\tunlock( select( coreStore ) );\n\t\t\t\tconst patterns = getBlockPatternsForPostType( postType );\n\t\t\t\treturn hasFinishedResolution( 'getBlockPatterns' )\n\t\t\t\t\t? patterns\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t\t[ reusableBlocksSelectKey ]: __experimentalReusableBlocksSelect,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: ! isDistractionFree && postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\t[ sectionRootClientIdKey ]: sectionRootClientId,\n\t\t};\n\n\t\treturn blockEditorSettings;\n\t}, [\n\t\tallowedBlockTypes,\n\t\tallowRightClickOverrides,\n\t\tfocusMode,\n\t\tforceDisableFocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\tsettings,\n\t\thasUploadPermissions,\n\t\tuserPatternCategories,\n\t\tblockPatterns,\n\t\tblockPatternCategories,\n\t\tcanUseUnfilteredHTML,\n\t\tundo,\n\t\tcreatePageEntity,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tpostType,\n\t\tsetIsInserterOpened,\n\t\tsectionRootClientId,\n\t\tglobalStylesData,\n\t\tglobalStylesLinksData,\n\t] );\n}\n\nexport default useBlockEditorSettings;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAQA,IAAAQ,gBAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,qBAAA,GAAAb,OAAA;AA3BA;AACA;AACA;;AAkBA;AACA;AACA;;AAOA,MAAMc,YAAY,GAAG,CAAC,CAAC;AAEvB,SAASC,kCAAkCA,CAAEC,MAAM,EAAG;EACrD,MAAM;IAAEC;EAA6B,CAAC,GAAG,IAAAC,kBAAM,EAAEC,qBAAoB,CAAC;EACtE,MAAM;IAAEC;EAAiB,CAAC,GAAGJ,MAAM,CAAEK,eAAU,CAAC;EAChD,OAAOD,gBAAgB,CAAE,UAAU,EAAE,UAAU,EAAE;IAChDE,QAAQ,EAAE,CAAC,CAAC;IACZ,CAAEL,4BAA4B,GAAI;EACnC,CAAE,CAAC;AACJ;AAEA,MAAMM,qBAAqB,GAAG,CAC7B,8BAA8B,EAC9B,kCAAkC,EAClC,wBAAwB,EACxB,sCAAsC,EACtC,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACR,qBAAqB,EACrB,wBAAwB,EACxB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B,CAAC,EAAE,CACFN,iBAAiB,EACjBhF,wBAAwB,EACxBE,SAAS,EACTmF,qBAAqB,EACrBlF,eAAe,EACfC,iBAAiB,EACjBC,oBAAoB,EACpBf,QAAQ,EACRgB,oBAAoB,EACpBM,qBAAqB,EACrB2C,aAAa,EACbO,sBAAsB,EACtBtD,oBAAoB,EACpB4D,IAAI,EACJK,gBAAgB,EAChBhE,kBAAkB,EAClBC,WAAW,EACXC,YAAY,EACZpB,QAAQ,EACR8E,mBAAmB,EACnBvD,mBAAmB,EACnBgC,gBAAgB,EAChBE,qBAAqB,CACpB,CAAC;AACJ;AAAC,IAAAgE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc7H,sBAAsB","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_coreData","_i18n","_notices","_utils","restorePost","id","label","__","isPrimary","icon","backup","supportsBulk","isEligible","item","isTemplateOrTemplatePart","type","status","permissions","update","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","noticesStore","editEntityRecord","saveEditedEntityRecord","coreStore","Promise","allSettled","map","post","promiseResult","throwOnError","every","successMessage","length","sprintf","getItemTitle","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/restore-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst restorePost: Action< PostWithPermissions > = {\n\tid: 'restore',\n\tlabel: __( 'Restore' ),\n\tisPrimary: true,\n\ticon: backup,\n\tsupportsBulk: true,\n\tisEligible( item ) {\n\t\treturn (\n\t\t\t! isTemplateOrTemplatePart( item ) &&\n\t\t\titem.type !== 'wp_block' &&\n\t\t\titem.status === 'trash' &&\n\t\t\titem.permissions?.update\n\t\t);\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tregistry.dispatch( coreStore );\n\t\tawait Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn saveEditedEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( posts.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else if ( posts[ 0 ].type === 'page' ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d pages have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'restore-post-action',\n\t\t\t} );\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tonActionPerformed( posts );\n\t\t\t}\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to move a single post to the trash.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to move multiple posts to the trash\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while restoring the posts: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while restoring the posts: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t},\n};\n\nexport default restorePost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,MAAA,GAAAJ,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAMK,WAA0C,GAAG;EAClDC,EAAE,EAAE,SAAS;EACbC,KAAK,EAAE,IAAAC,QAAE,EAAE,SAAU,CAAC;EACtBC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,aAAM;EACZC,YAAY,EAAE,IAAI;EAClBC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OACC,CAAE,IAAAC,+BAAwB,EAAED,IAAK,CAAC,IAClCA,IAAI,CAACE,IAAI,KAAK,UAAU,IACxBF,IAAI,CAACG,MAAM,KAAK,OAAO,IACvBH,IAAI,CAACI,WAAW,EAAEC,MAAM;EAE1B,CAAC;EACD,MAAMC,QAAQA,CAAEC,KAAK,EAAE;IAAEC,QAAQ;IAAEC;EAAkB,CAAC,EAAG;IACxD,MAAM;MAAEC,mBAAmB;MAAEC;IAAkB,CAAC,GAC/CH,QAAQ,CAACI,QAAQ,CAAEC,cAAa,CAAC;IAClC,MAAM;MAAEC,gBAAgB;MAAEC;IAAuB,CAAC,GACjDP,QAAQ,CAACI,QAAQ,CAAEI,eAAU,CAAC;IAC/B,MAAMC,OAAO,CAACC,UAAU,CACvBX,KAAK,CAACY,GAAG,CAAIC,IAAI,IAAM;MACtB,OAAON,gBAAgB,CAAE,UAAU,EAAEM,IAAI,CAAClB,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AAC,OAAA,GAEanD,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["_icons","require","_coreData","_i18n","_notices","_utils","restorePost","id","label","__","isPrimary","icon","backup","supportsBulk","isEligible","item","isTemplateOrTemplatePart","type","status","permissions","update","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","noticesStore","editEntityRecord","saveEditedEntityRecord","coreStore","Promise","allSettled","map","post","promiseResult","throwOnError","every","successMessage","length","sprintf","getItemTitle","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/restore-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst restorePost: Action< PostWithPermissions > = {\n\tid: 'restore',\n\tlabel: __( 'Restore' ),\n\tisPrimary: true,\n\ticon: backup,\n\tsupportsBulk: true,\n\tisEligible( item ) {\n\t\treturn (\n\t\t\t! isTemplateOrTemplatePart( item ) &&\n\t\t\titem.type !== 'wp_block' &&\n\t\t\titem.status === 'trash' &&\n\t\t\titem.permissions?.update\n\t\t);\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tregistry.dispatch( coreStore );\n\t\tawait Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn saveEditedEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( posts.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else if ( posts[ 0 ].type === 'page' ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d pages have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'restore-post-action',\n\t\t\t} );\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tonActionPerformed( posts );\n\t\t\t}\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to move a single post to the trash.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to move multiple posts to the trash\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while restoring the posts: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while restoring the posts: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t},\n};\n\nexport default restorePost;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,MAAA,GAAAJ,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAMK,WAA0C,GAAG;EAClDC,EAAE,EAAE,SAAS;EACbC,KAAK,EAAE,IAA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AAU,CAACC,MAAM,EAAEC,OAAO,EAAG;YACjCC,aAAa,CAACK,GAAG,CAAER,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;UAC/C;QACD;QACA,IAAKC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UAC/BV,YAAY,GAAG,IAAAlC,QAAE,EAChB,8CACD,CAAC;QACF,CAAC,MAAM,IAAKsC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UACtCV,YAAY,GAAG,IAAAF,aAAO,GACrB;UACA,IAAAhC,QAAE,EAAE,iDAAkD,CAAC,EACvD,CAAE,GAAGsC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAG,IAAAF,aAAO,GACrB;UACA,IAAAhC,QAAE,EACD,oDACD,CAAC,EACD,CAAE,GAAGsC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACA5B,iBAAiB,CAAEiB,YAAY,EAAE;QAChC1B,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEanD,WAAW","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_data","_coreData","_i18n","_notices","_element","_components","_utils","_jsxRuntime","trashPost","id","label","__","isPrimary","icon","trash","isEligible","item","isTemplateOrTemplatePart","type","status","includes","permissions","delete","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","createSuccessNotice","createErrorNotice","useDispatch","noticesStore","deleteEntityRecord","coreStore","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","length","sprintf","getItemTitle","_n","__experimentalHStack","justify","Button","__next40pxDefaultSize","variant","onClick","disabled","accessibleWhenDisabled","promiseResult","Promise","allSettled","map","toString","throwOnError","every","successMessage","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_x","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/trash-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (\n\t\t\t!! item.status &&\n\t\t\t! [ 'auto-draft', 'trash' ].includes( item.status ) &&\n\t\t\titem.permissions?.delete\n\t\t);\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The item's title.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move \"%s\" to the trash?'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: The number of items (2 or more).\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d item to the trash ?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d items to the trash ?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\titems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tdeleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\t\t\titem.id.toString(),\n\t\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t\t{ throwOnError: true }\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\t// If all the promises were fulfilled with success.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet successMessage;\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The item's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the trash.' ),\n\t\t\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The number of items. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'%s item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%s items moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\titems.length\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\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tid: 'move-to-trash-action',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If there was at least one failure.\n\t\t\t\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t\t\t\t// If we were trying to delete a single item.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// If we were trying to delete multiple items.\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst errorMessages = new Set();\n\t\t\t\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the items to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while moving the items to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t\t\t\t);\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\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( items );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Trash', 'verb' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport default trashPost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAWA,IAAAO,MAAA,GAAAP,OAAA;AAAiE,IAAAQ,WAAA,GAAAR,OAAA;AApBjE;AAC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BACA,IAAAlC,QAAE,EACD,0DACD,CAAC,EACD,CAAE,GAAGyD,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;gBACF,CAAC,MAAM;kBACNJ,YAAY,GAAG,IAAAnB,aAAO,GACrB;kBACA,IAAAlC,QAAE,EACD,8DACD,CAAC,EACD,CAAE,GAAGyD,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;gBACF;cACD;cACA1C,iBAAiB,CAAE+B,YAAY,EAAE;gBAChC9C,IAAI,EAAE;cACP,CAAE,CAAC;YACJ;YACA,IAAKU,iBAAiB,EAAG;cACxBA,iBAAiB,CAAEF,KAAM,CAAC;YAC3B;YACAI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjByB,QAAQ,EAAGzB,MAAQ;UACnB0B,sBAAsB;UAAAd,QAAA,EAEpB,IAAAmC,QAAE,EAAE,OAAO,EAAE,MAAO;QAAC,CAChB,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavE,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["_icons","require","_data","_coreData","_i18n","_notices","_element","_components","_utils","_jsxRuntime","trashPost","id","label","__","isPrimary","icon","trash","isEligible","item","isTemplateOrTemplatePart","type","status","includes","permissions","delete","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","createSuccessNotice","createErrorNotice","useDispatch","noticesStore","deleteEntityRecord","coreStore","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","length","sprintf","getItemTitle","_n","__experimentalHStack","justify","Button","__next40pxDefaultSize","variant","onClick","disabled","accessibleWhenDisabled","promiseResult","Promise","allSettled","map","toString","throwOnError","every","successMessage","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_x","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/trash-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (\n\t\t\t!! item.status &&\n\t\t\t! [ 'auto-draft', 'trash' ].includes( item.status ) &&\n\t\t\titem.permissions?.delete\n\t\t);\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The item's title.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move \"%s\" to the trash?'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: The number of items (2 or more).\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d item to the trash ?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d items to the trash ?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\titems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tdeleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\t\t\titem.id.toString(),\n\t\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t\t{ throwOnError: true }\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\t// If all the promises were fulfilled with success.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet successMessage;\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The item's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the trash.' ),\n\t\t\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The number of items. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'%s item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%s items moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\titems.length\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\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tid: 'move-to-trash-action',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If there was at least one failure.\n\t\t\t\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t\t\t\t// If we were trying to delete a single item.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// If we were trying to delete multiple items.\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst errorMessages = new Set();\n\t\t\t\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the items to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while moving the items to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t\t\t\t);\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\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( items );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Trash', 'verb' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport default trashPost;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAWA,IAAAO,MAAA,GAAAP,OAAA;AAAiE,IAAAQ,WAAA,GAAAR,OAAA;AApBjE;AACA;AACA;;AAeA;AACA;AACA;;AAIA,MAAMS,SAAwC,GAAG;EAChDC,EAAE,EAAE,eAAe;EACnBC,KAAK,EAAE,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,CAAC,MAAM;kBACNJ,YAAY,GAAG,IAAAnB,aAAO,GACrB;kBACA,IAAAlC,QAAE,EACD,8DACD,CAAC,EACD,CAAE,GAAGyD,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;gBACF;cACD;cACA1C,iBAAiB,CAAE+B,YAAY,EAAE;gBAChC9C,IAAI,EAAE;cACP,CAAE,CAAC;YACJ;YACA,IAAKU,iBAAiB,EAAG;cACxBA,iBAAiB,CAAEF,KAAM,CAAC;YAC3B;YACAI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjByB,QAAQ,EAAGzB,MAAQ;UACnB0B,sBAAsB;UAAAd,QAAA,EAEpB,IAAAmC,QAAE,EAAE,OAAO,EAAE,MAAO;QAAC,CAChB,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavE,SAAS","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["EDIT_MERGE_PROPERTIES","exports","Set","STORE_NAME","SAVE_POST_NOTICE_ID","TRASH_POST_NOTICE_ID","PERMALINK_POSTNAME_REGEX","ONE_MINUTE_IN_MS","AUTOSAVE_PROPERTIES","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","TEMPLATE_POST_TYPES","GLOBAL_POST_TYPES"],"sources":["@wordpress/editor/src/store/constants.ts"],"sourcesContent":["/**\n * Set of post properties for which edits should assume a merging behavior,\n * assuming an object value.\n *\n * @type {Set}\n */\nexport const EDIT_MERGE_PROPERTIES = new Set( [ 'meta' ] );\n\n/**\n * Constant for the store module (or reducer) key.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/editor';\n\nexport const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';\nexport const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID';\nexport const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;\nexport const ONE_MINUTE_IN_MS = 60 * 1000;\nexport const AUTOSAVE_PROPERTIES = [ 'title', 'excerpt', 'content' ];\nexport const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const PATTERN_POST_TYPE = 'wp_block';\nexport const NAVIGATION_POST_TYPE = 'wp_navigation';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\nexport const TEMPLATE_POST_TYPES = [ 'wp_template', 'wp_template_part' ];\nexport const GLOBAL_POST_TYPES = [\n\t...TEMPLATE_POST_TYPES,\n\t'wp_block',\n\t'wp_navigation',\n];\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAIE,GAAG,CAAE,CAAE,MAAM,CAAG,CAAC;;AAE1D;AACA;AACA;AACA;AACA;AACO,MAAMC,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG,aAAa;AAEhC,MAAMC,mBAAmB,GAAAH,OAAA,CAAAG,mBAAA,GAAG,qBAAqB;AACjD,MAAMC,oBAAoB,GAAAJ,OAAA,CAAAI,oBAAA,GAAG,sBAAsB;AACnD,MAAMC,wBAAwB,GAAAL,OAAA,CAAAK,wBAAA,GAAG,yBAAyB;AAC1D,MAAMC,gBAAgB,GAAAN,OAAA,CAAAM,gBAAA,GAAG,EAAE,GAAG,IAAI;AAClC,MAAMC,mBAAmB,GAAAP,OAAA,CAAAO,mBAAA,GAAG,CAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAE;AAC7D,MAAMC,mCAAmC,GAAAR,OAAA,CAAAQ,mCAAA,GAAG,eAAe;AAC3D,MAAMC,kBAAkB,GAAAT,OAAA,CAAAS,kBAAA,GAAG,aAAa;AACxC,MAAMC,uBAAuB,GAAAV,OAAA,CAAAU,uBAAA,GAAG,kBAAkB;AAClD,MAAMC,iBAAiB,GAAAX,OAAA,CAAAW,iBAAA,GAAG,UAAU;AACpC,MAAMC,oBAAoB,GAAAZ,OAAA,CAAAY,oBAAA,GAAG,eAAe;AAC5C,MAAMC,gBAAgB,GAAAb,OAAA,CAAAa,gBAAA,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AACM,MAAMC,mBAAmB,GAAAjB,OAAA,CAAAiB,mBAAA,GAAG,CAAE,aAAa,EAAE,kBAAkB,CAAE;AACjE,MAAMC,iBAAiB,GAAAlB,OAAA,CAAAkB,iBAAA,GAAG,CAChC,GAAGD,mBAAmB,EACtB,UAAU,EACV,eAAe,CACf","ignoreList":[]}
1
+ {"version":3,"names":["EDIT_MERGE_PROPERTIES","exports","Set","STORE_NAME","SAVE_POST_NOTICE_ID","TRASH_POST_NOTICE_ID","PERMALINK_POSTNAME_REGEX","ONE_MINUTE_IN_MS","AUTOSAVE_PROPERTIES","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","TEMPLATE_POST_TYPES","GLOBAL_POST_TYPES"],"sources":["@wordpress/editor/src/store/constants.ts"],"sourcesContent":["/**\n * Set of post properties for which edits should assume a merging behavior,\n * assuming an object value.\n *\n * @type {Set}\n */\nexport const EDIT_MERGE_PROPERTIES = new Set( [ 'meta' ] );\n\n/**\n * Constant for the store module (or reducer) key.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/editor';\n\nexport const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';\nexport const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID';\nexport const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;\nexport const ONE_MINUTE_IN_MS = 60 * 1000;\nexport const AUTOSAVE_PROPERTIES = [ 'title', 'excerpt', 'content' ];\nexport const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const PATTERN_POST_TYPE = 'wp_block';\nexport const NAVIGATION_POST_TYPE = 'wp_navigation';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\nexport const TEMPLATE_POST_TYPES = [ 'wp_template', 'wp_template_part' ];\nexport const GLOBAL_POST_TYPES = [\n\t...TEMPLATE_POST_TYPES,\n\t'wp_block',\n\t'wp_navigation',\n];\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAIE,GAAG,CAAE,CAAE,MAAM,CAAG,CAAC;;AAE1D;AACA;AACA;AACA;AACA;AACO,MAAMC,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG,aAAa;AAEhC,MAAMC,mBAAmB,GAAAH,OAAA,CAAAG,mBAAA,GAAG,qBAAqB;AACjD,MAAMC,oBAAoB,GAAAJ,OAAA,CAAAI,oBAAA,GAAG,sBAAsB;AACnD,MAAMC,wBAAwB,GAAAL,OAAA,CAAAK,wBAAA,GAAG,yBAAyB;AAC1D,MAAMC,gBAAgB,GAAAN,OAAA,CAAAM,gBAAA,GAAG,EAAE,GAAG,IAAI;AAClC,MAAMC,mBAAmB,GAAAP,OAAA,CAAAO,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