@wordpress/block-library 8.23.0 → 8.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/block/edit.js +8 -11
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +3 -4
- package/build/block/edit.native.js.map +1 -1
- package/build/button/edit.js +4 -7
- package/build/button/edit.js.map +1 -1
- package/build/column/edit.js +1 -1
- package/build/column/edit.js.map +1 -1
- package/build/column/edit.native.js +1 -1
- package/build/column/edit.native.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/file/edit.js +8 -9
- package/build/file/edit.js.map +1 -1
- package/build/file/view.js +4 -6
- package/build/file/view.js.map +1 -1
- package/build/group/edit.js +3 -7
- package/build/group/edit.js.map +1 -1
- package/build/image/edit.js +17 -18
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +22 -15
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +35 -27
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +2 -3
- package/build/image/index.js.map +1 -1
- package/build/image/view.js +233 -268
- package/build/image/view.js.map +1 -1
- package/build/navigation/view.js +153 -176
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/index.js +2 -1
- package/build/navigation-link/index.js.map +1 -1
- package/build/pattern/edit.js +1 -3
- package/build/pattern/edit.js.map +1 -1
- package/build/post-template/edit.js +1 -1
- package/build/post-template/edit.js.map +1 -1
- package/build/query/view.js +52 -60
- package/build/query/view.js.map +1 -1
- package/build/search/view.js +66 -74
- package/build/search/view.js.map +1 -1
- package/build/utils/remove-anchor-tag.js +17 -0
- package/build/utils/remove-anchor-tag.js.map +1 -0
- package/build-module/block/edit.js +8 -11
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +3 -4
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/button/edit.js +4 -7
- package/build-module/button/edit.js.map +1 -1
- package/build-module/column/edit.js +1 -1
- package/build-module/column/edit.js.map +1 -1
- package/build-module/column/edit.native.js +1 -1
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/file/edit.js +8 -9
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/view.js +5 -7
- package/build-module/file/view.js.map +1 -1
- package/build-module/group/edit.js +3 -7
- package/build-module/group/edit.js.map +1 -1
- package/build-module/image/edit.js +18 -19
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +23 -16
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +36 -28
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +2 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/view.js +234 -269
- package/build-module/image/view.js.map +1 -1
- package/build-module/navigation/view.js +154 -177
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/index.js +2 -1
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/pattern/edit.js +1 -3
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-template/edit.js +1 -1
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/query/view.js +53 -61
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/view.js +67 -75
- package/build-module/search/view.js.map +1 -1
- package/build-module/utils/remove-anchor-tag.js +11 -0
- package/build-module/utils/remove-anchor-tag.js.map +1 -0
- package/build-style/cover/style-rtl.css +14 -14
- package/build-style/cover/style.css +14 -14
- package/build-style/editor-rtl.css +6 -9
- package/build-style/editor.css +6 -9
- package/build-style/gallery/style-rtl.css +28 -0
- package/build-style/gallery/style.css +28 -0
- package/build-style/image/editor-rtl.css +0 -3
- package/build-style/image/editor.css +0 -3
- package/build-style/style-rtl.css +42 -14
- package/build-style/style.css +42 -14
- package/package.json +32 -32
- package/src/block/edit.js +18 -19
- package/src/block/edit.native.js +5 -13
- package/src/button/edit.js +6 -6
- package/src/buttons/test/__snapshots__/edit.native.js.snap +0 -6
- package/src/buttons/test/edit.native.js +0 -27
- package/src/column/edit.js +1 -1
- package/src/column/edit.native.js +1 -1
- package/src/cover/edit/index.js +1 -0
- package/src/cover/style.scss +1 -1
- package/src/cover/test/edit.js +1 -1
- package/src/editor.scss +6 -6
- package/src/file/edit.js +11 -10
- package/src/file/index.php +30 -11
- package/src/file/view.js +5 -7
- package/src/gallery/style.scss +1 -0
- package/src/group/edit.js +3 -11
- package/src/heading/test/__snapshots__/index.native.js.snap +6 -0
- package/src/heading/test/index.native.js +40 -0
- package/src/image/block.json +2 -3
- package/src/image/edit.js +16 -21
- package/src/image/edit.native.js +17 -18
- package/src/image/editor.scss +0 -7
- package/src/image/image.js +48 -51
- package/src/image/index.php +54 -45
- package/src/image/view.js +278 -334
- package/src/navigation/index.php +19 -10
- package/src/navigation/view.js +159 -192
- package/src/navigation-link/block.json +2 -1
- package/src/paragraph/test/edit.native.js +37 -1
- package/src/pattern/edit.js +5 -3
- package/src/post-template/edit.js +1 -1
- package/src/query/index.php +36 -22
- package/src/query/view.js +58 -65
- package/src/query-pagination-next/index.php +3 -3
- package/src/query-pagination-numbers/index.php +1 -1
- package/src/query-pagination-previous/index.php +3 -3
- package/src/search/index.php +40 -40
- package/src/search/view.js +58 -63
- package/src/utils/remove-anchor-tag.js +10 -0
- package/tsconfig.json +1 -0
|
@@ -23,6 +23,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
23
23
|
*/
|
|
24
24
|
import FileBlockInspector from './inspector';
|
|
25
25
|
import { browserSupportsPdfs } from './utils';
|
|
26
|
+
import removeAnchorTag from '../utils/remove-anchor-tag';
|
|
26
27
|
export const MIN_PREVIEW_HEIGHT = 200;
|
|
27
28
|
export const MAX_PREVIEW_HEIGHT = 2000;
|
|
28
29
|
function ClipboardToolbarButton({
|
|
@@ -88,7 +89,9 @@ function FileEdit({
|
|
|
88
89
|
revokeBlobURL(href);
|
|
89
90
|
}
|
|
90
91
|
if (downloadButtonText === undefined) {
|
|
91
|
-
|
|
92
|
+
setAttributes({
|
|
93
|
+
downloadButtonText: _x('Download', 'button label')
|
|
94
|
+
});
|
|
92
95
|
}
|
|
93
96
|
}, []);
|
|
94
97
|
useEffect(() => {
|
|
@@ -137,12 +140,6 @@ function FileEdit({
|
|
|
137
140
|
showDownloadButton: newValue
|
|
138
141
|
});
|
|
139
142
|
}
|
|
140
|
-
function changeDownloadButtonText(newValue) {
|
|
141
|
-
// Remove anchor tags from button text content.
|
|
142
|
-
setAttributes({
|
|
143
|
-
downloadButtonText: newValue.replace(/<\/?a[^>]*>/g, '')
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
143
|
function changeDisplayPreview(newValue) {
|
|
147
144
|
setAttributes({
|
|
148
145
|
displayPreview: newValue
|
|
@@ -250,7 +247,7 @@ function FileEdit({
|
|
|
250
247
|
placeholder: __('Write file name…'),
|
|
251
248
|
withoutInteractiveFormatting: true,
|
|
252
249
|
onChange: text => setAttributes({
|
|
253
|
-
fileName: text
|
|
250
|
+
fileName: removeAnchorTag(text)
|
|
254
251
|
}),
|
|
255
252
|
href: textLinkHref
|
|
256
253
|
}), showDownloadButton && createElement("div", {
|
|
@@ -263,7 +260,9 @@ function FileEdit({
|
|
|
263
260
|
value: downloadButtonText,
|
|
264
261
|
withoutInteractiveFormatting: true,
|
|
265
262
|
placeholder: __('Add text…'),
|
|
266
|
-
onChange: text =>
|
|
263
|
+
onChange: text => setAttributes({
|
|
264
|
+
downloadButtonText: removeAnchorTag(text)
|
|
265
|
+
})
|
|
267
266
|
})))));
|
|
268
267
|
}
|
|
269
268
|
export default FileEdit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","getBlobByURL","isBlobURL","revokeBlobURL","__unstableGetAnimateClassName","getAnimateClassName","ResizableBox","ToolbarButton","useSelect","useDispatch","BlockControls","BlockIcon","MediaPlaceholder","MediaReplaceFlow","RichText","useBlockProps","store","blockEditorStore","__experimentalGetElementClassName","useEffect","useCopyToClipboard","__","_x","file","icon","coreStore","noticesStore","FileBlockInspector","browserSupportsPdfs","MIN_PREVIEW_HEIGHT","MAX_PREVIEW_HEIGHT","ClipboardToolbarButton","text","disabled","createNotice","ref","isDismissible","type","createElement","className","FileEdit","attributes","isSelected","setAttributes","clientId","id","fileId","fileName","href","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","media","mediaUpload","select","undefined","getMedia","getSettings","createErrorNotice","toggleSelection","__unstableMarkNextChangeAsNotPersistent","filesList","onFileChange","newMedia","onSelectFile","onError","onUploadError","changeDownloadButtonText","url","isPdf","endsWith","title","message","changeLinkDestinationOption","newHref","changeOpenInNewWindow","newValue","changeShowDownloadButton","replace","changeDisplayPreview","handleOnResizeStop","event","direction","elt","delta","newHeight","parseInt","height","changePreviewHeight","Math","max","attachmentPage","link","blockProps","displayPreviewInEditor","labels","instructions","onSelect","accept","Fragment","hrefs","openInNewWindow","group","mediaId","mediaURL","size","minHeight","maxHeight","minWidth","grid","enable","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","onResizeStart","onResizeStop","showHandle","data","tagName","value","placeholder","withoutInteractiveFormatting","onChange"],"sources":["@wordpress/block-library/src/file/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tResizableBox,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { file as icon } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport FileBlockInspector from './inspector';\nimport { browserSupportsPdfs } from './utils';\n\nexport const MIN_PREVIEW_HEIGHT = 200;\nexport const MAX_PREVIEW_HEIGHT = 2000;\n\nfunction ClipboardToolbarButton( { text, disabled } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( text, () => {\n\t\tcreateNotice( 'info', __( 'Copied URL to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tclassName=\"components-clipboard-toolbar-button\"\n\t\t\tref={ ref }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ __( 'Copy URL' ) }\n\t\t</ToolbarButton>\n\t);\n}\n\nfunction FileEdit( { attributes, isSelected, setAttributes, clientId } ) {\n\tconst {\n\t\tid,\n\t\tfileId,\n\t\tfileName,\n\t\thref,\n\t\ttextLinkHref,\n\t\ttextLinkTarget,\n\t\tshowDownloadButton,\n\t\tdownloadButtonText,\n\t\tdisplayPreview,\n\t\tpreviewHeight,\n\t} = attributes;\n\tconst { media, mediaUpload } = useSelect(\n\t\t( select ) => ( {\n\t\t\tmedia:\n\t\t\t\tid === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: select( coreStore ).getMedia( id ),\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t} ),\n\t\t[ id ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { toggleSelection, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Upload a file drag-and-dropped into the editor.\n\t\tif ( isBlobURL( href ) ) {\n\t\t\tconst file = getBlobByURL( href );\n\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList: [ file ],\n\t\t\t\tonFileChange: ( [ newMedia ] ) => onSelectFile( newMedia ),\n\t\t\t\tonError: onUploadError,\n\t\t\t} );\n\n\t\t\trevokeBlobURL( href );\n\t\t}\n\n\t\tif ( downloadButtonText === undefined ) {\n\t\t\tchangeDownloadButtonText( _x( 'Download', 'button label' ) );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! fileId && href ) {\n\t\t\t// Add a unique fileId to each file block.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { fileId: `wp-block-file--media-${ clientId }` } );\n\t\t}\n\t}, [ href, fileId, clientId ] );\n\n\tfunction onSelectFile( newMedia ) {\n\t\tif ( newMedia && newMedia.url ) {\n\t\t\tconst isPdf = newMedia.url.endsWith( '.pdf' );\n\t\t\tsetAttributes( {\n\t\t\t\thref: newMedia.url,\n\t\t\t\tfileName: newMedia.title,\n\t\t\t\ttextLinkHref: newMedia.url,\n\t\t\t\tid: newMedia.id,\n\t\t\t\tdisplayPreview: isPdf ? true : undefined,\n\t\t\t\tpreviewHeight: isPdf ? 600 : undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tsetAttributes( { href: undefined } );\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tfunction changeLinkDestinationOption( newHref ) {\n\t\t// Choose Media File or Attachment Page (when file is in Media Library).\n\t\tsetAttributes( { textLinkHref: newHref } );\n\t}\n\n\tfunction changeOpenInNewWindow( newValue ) {\n\t\tsetAttributes( {\n\t\t\ttextLinkTarget: newValue ? '_blank' : false,\n\t\t} );\n\t}\n\n\tfunction changeShowDownloadButton( newValue ) {\n\t\tsetAttributes( { showDownloadButton: newValue } );\n\t}\n\n\tfunction changeDownloadButtonText( newValue ) {\n\t\t// Remove anchor tags from button text content.\n\t\tsetAttributes( {\n\t\t\tdownloadButtonText: newValue.replace( /<\\/?a[^>]*>/g, '' ),\n\t\t} );\n\t}\n\n\tfunction changeDisplayPreview( newValue ) {\n\t\tsetAttributes( { displayPreview: newValue } );\n\t}\n\n\tfunction handleOnResizeStop( event, direction, elt, delta ) {\n\t\ttoggleSelection( true );\n\n\t\tconst newHeight = parseInt( previewHeight + delta.height, 10 );\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tfunction changePreviewHeight( newValue ) {\n\t\tconst newHeight = Math.max(\n\t\t\tparseInt( newValue, 10 ),\n\t\t\tMIN_PREVIEW_HEIGHT\n\t\t);\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tconst attachmentPage = media && media.link;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\tisBlobURL( href ) && getAnimateClassName( { type: 'loading' } ),\n\t\t\t{\n\t\t\t\t'is-transient': isBlobURL( href ),\n\t\t\t}\n\t\t),\n\t} );\n\n\tconst displayPreviewInEditor = browserSupportsPdfs() && displayPreview;\n\n\tif ( ! href ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'File' ),\n\t\t\t\t\t\tinstructions: __(\n\t\t\t\t\t\t\t'Upload a file or pick one from your media library.'\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<FileBlockInspector\n\t\t\t\threfs={ { href, textLinkHref, attachmentPage } }\n\t\t\t\t{ ...{\n\t\t\t\t\topenInNewWindow: !! textLinkTarget,\n\t\t\t\t\tshowDownloadButton,\n\t\t\t\t\tchangeLinkDestinationOption,\n\t\t\t\t\tchangeOpenInNewWindow,\n\t\t\t\t\tchangeShowDownloadButton,\n\t\t\t\t\tdisplayPreview,\n\t\t\t\t\tchangeDisplayPreview,\n\t\t\t\t\tpreviewHeight,\n\t\t\t\t\tchangePreviewHeight,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ href }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t\t<ClipboardToolbarButton\n\t\t\t\t\ttext={ href }\n\t\t\t\t\tdisabled={ isBlobURL( href ) }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ displayPreviewInEditor && (\n\t\t\t\t\t<ResizableBox\n\t\t\t\t\t\tsize={ { height: previewHeight } }\n\t\t\t\t\t\tminHeight={ MIN_PREVIEW_HEIGHT }\n\t\t\t\t\t\tmaxHeight={ MAX_PREVIEW_HEIGHT }\n\t\t\t\t\t\tminWidth=\"100%\"\n\t\t\t\t\t\tgrid={ [ 10, 10 ] }\n\t\t\t\t\t\tenable={ {\n\t\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\t\tright: false,\n\t\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResizeStart={ () => toggleSelection( false ) }\n\t\t\t\t\t\tonResizeStop={ handleOnResizeStop }\n\t\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t>\n\t\t\t\t\t\t<object\n\t\t\t\t\t\t\tclassName=\"wp-block-file__preview\"\n\t\t\t\t\t\t\tdata={ href }\n\t\t\t\t\t\t\ttype=\"application/pdf\"\n\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t'Embed of the selected PDF file.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isSelected && (\n\t\t\t\t\t\t\t<div className=\"wp-block-file__preview-overlay\" />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ResizableBox>\n\t\t\t\t) }\n\t\t\t\t<div className={ 'wp-block-file__content-wrapper' }>\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"a\"\n\t\t\t\t\t\tvalue={ fileName }\n\t\t\t\t\t\tplaceholder={ __( 'Write file name…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\tsetAttributes( { fileName: text } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thref={ textLinkHref }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showDownloadButton && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t'wp-block-file__button-richtext-wrapper'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ /* Using RichText here instead of PlainText so that it can be styled like a button. */ }\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\ttagName=\"div\" // Must be block-level or else cursor disappears.\n\t\t\t\t\t\t\t\taria-label={ __( 'Download button text' ) }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'wp-block-file__button',\n\t\t\t\t\t\t\t\t\t__experimentalGetElementClassName(\n\t\t\t\t\t\t\t\t\t\t'button'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tvalue={ downloadButtonText }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ __( 'Add text…' ) }\n\t\t\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\t\t\tchangeDownloadButt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AQ;IACRgH,OAAO,EAAC,KAAK,CAAC;IAAA;IACd,cAAazG,EAAE,CAAE,sBAAuB,CAAG;IAC3CkB,SAAS,EAAGvC,UAAU,CACrB,uBAAuB,EACvBkB,iCAAiC,CAChC,QACD,CACD,CAAG;IACH6G,KAAK,EAAG3E,kBAAoB;IAC5B6E,4BAA4B;IAC5BD,WAAW,EAAG3G,EAAE,CAAE,WAAY,CAAG;IACjC6G,QAAQ,EAAKlG,IAAI,IAChBsC,wBAAwB,CAAEtC,IAAK;EAC/B,CACD,CACG,CAEF,CACD,CACJ,CAAC;AAEL;AAEA,eAAeQ,QAAQ"}
|
|
1
|
+
{"version":3,"names":["classnames","getBlobByURL","isBlobURL","revokeBlobURL","__unstableGetAnimateClassName","getAnimateClassName","ResizableBox","ToolbarButton","useSelect","useDispatch","BlockControls","BlockIcon","MediaPlaceholder","MediaReplaceFlow","RichText","useBlockProps","store","blockEditorStore","__experimentalGetElementClassName","useEffect","useCopyToClipboard","__","_x","file","icon","coreStore","noticesStore","FileBlockInspector","browserSupportsPdfs","removeAnchorTag","MIN_PREVIEW_HEIGHT","MAX_PREVIEW_HEIGHT","ClipboardToolbarButton","text","disabled","createNotice","ref","isDismissible","type","createElement","className","FileEdit","attributes","isSelected","setAttributes","clientId","id","fileId","fileName","href","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","media","mediaUpload","select","undefined","getMedia","getSettings","createErrorNotice","toggleSelection","__unstableMarkNextChangeAsNotPersistent","filesList","onFileChange","newMedia","onSelectFile","onError","onUploadError","url","isPdf","endsWith","title","message","changeLinkDestinationOption","newHref","changeOpenInNewWindow","newValue","changeShowDownloadButton","changeDisplayPreview","handleOnResizeStop","event","direction","elt","delta","newHeight","parseInt","height","changePreviewHeight","Math","max","attachmentPage","link","blockProps","displayPreviewInEditor","labels","instructions","onSelect","accept","Fragment","hrefs","openInNewWindow","group","mediaId","mediaURL","size","minHeight","maxHeight","minWidth","grid","enable","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","onResizeStart","onResizeStop","showHandle","data","tagName","value","placeholder","withoutInteractiveFormatting","onChange"],"sources":["@wordpress/block-library/src/file/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tResizableBox,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { file as icon } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport FileBlockInspector from './inspector';\nimport { browserSupportsPdfs } from './utils';\nimport removeAnchorTag from '../utils/remove-anchor-tag';\n\nexport const MIN_PREVIEW_HEIGHT = 200;\nexport const MAX_PREVIEW_HEIGHT = 2000;\n\nfunction ClipboardToolbarButton( { text, disabled } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( text, () => {\n\t\tcreateNotice( 'info', __( 'Copied URL to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tclassName=\"components-clipboard-toolbar-button\"\n\t\t\tref={ ref }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ __( 'Copy URL' ) }\n\t\t</ToolbarButton>\n\t);\n}\n\nfunction FileEdit( { attributes, isSelected, setAttributes, clientId } ) {\n\tconst {\n\t\tid,\n\t\tfileId,\n\t\tfileName,\n\t\thref,\n\t\ttextLinkHref,\n\t\ttextLinkTarget,\n\t\tshowDownloadButton,\n\t\tdownloadButtonText,\n\t\tdisplayPreview,\n\t\tpreviewHeight,\n\t} = attributes;\n\tconst { media, mediaUpload } = useSelect(\n\t\t( select ) => ( {\n\t\t\tmedia:\n\t\t\t\tid === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: select( coreStore ).getMedia( id ),\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t} ),\n\t\t[ id ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { toggleSelection, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Upload a file drag-and-dropped into the editor.\n\t\tif ( isBlobURL( href ) ) {\n\t\t\tconst file = getBlobByURL( href );\n\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList: [ file ],\n\t\t\t\tonFileChange: ( [ newMedia ] ) => onSelectFile( newMedia ),\n\t\t\t\tonError: onUploadError,\n\t\t\t} );\n\n\t\t\trevokeBlobURL( href );\n\t\t}\n\n\t\tif ( downloadButtonText === undefined ) {\n\t\t\tsetAttributes( {\n\t\t\t\tdownloadButtonText: _x( 'Download', 'button label' ),\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! fileId && href ) {\n\t\t\t// Add a unique fileId to each file block.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { fileId: `wp-block-file--media-${ clientId }` } );\n\t\t}\n\t}, [ href, fileId, clientId ] );\n\n\tfunction onSelectFile( newMedia ) {\n\t\tif ( newMedia && newMedia.url ) {\n\t\t\tconst isPdf = newMedia.url.endsWith( '.pdf' );\n\t\t\tsetAttributes( {\n\t\t\t\thref: newMedia.url,\n\t\t\t\tfileName: newMedia.title,\n\t\t\t\ttextLinkHref: newMedia.url,\n\t\t\t\tid: newMedia.id,\n\t\t\t\tdisplayPreview: isPdf ? true : undefined,\n\t\t\t\tpreviewHeight: isPdf ? 600 : undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tsetAttributes( { href: undefined } );\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tfunction changeLinkDestinationOption( newHref ) {\n\t\t// Choose Media File or Attachment Page (when file is in Media Library).\n\t\tsetAttributes( { textLinkHref: newHref } );\n\t}\n\n\tfunction changeOpenInNewWindow( newValue ) {\n\t\tsetAttributes( {\n\t\t\ttextLinkTarget: newValue ? '_blank' : false,\n\t\t} );\n\t}\n\n\tfunction changeShowDownloadButton( newValue ) {\n\t\tsetAttributes( { showDownloadButton: newValue } );\n\t}\n\n\tfunction changeDisplayPreview( newValue ) {\n\t\tsetAttributes( { displayPreview: newValue } );\n\t}\n\n\tfunction handleOnResizeStop( event, direction, elt, delta ) {\n\t\ttoggleSelection( true );\n\n\t\tconst newHeight = parseInt( previewHeight + delta.height, 10 );\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tfunction changePreviewHeight( newValue ) {\n\t\tconst newHeight = Math.max(\n\t\t\tparseInt( newValue, 10 ),\n\t\t\tMIN_PREVIEW_HEIGHT\n\t\t);\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tconst attachmentPage = media && media.link;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\tisBlobURL( href ) && getAnimateClassName( { type: 'loading' } ),\n\t\t\t{\n\t\t\t\t'is-transient': isBlobURL( href ),\n\t\t\t}\n\t\t),\n\t} );\n\n\tconst displayPreviewInEditor = browserSupportsPdfs() && displayPreview;\n\n\tif ( ! href ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'File' ),\n\t\t\t\t\t\tinstructions: __(\n\t\t\t\t\t\t\t'Upload a file or pick one from your media library.'\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<FileBlockInspector\n\t\t\t\threfs={ { href, textLinkHref, attachmentPage } }\n\t\t\t\t{ ...{\n\t\t\t\t\topenInNewWindow: !! textLinkTarget,\n\t\t\t\t\tshowDownloadButton,\n\t\t\t\t\tchangeLinkDestinationOption,\n\t\t\t\t\tchangeOpenInNewWindow,\n\t\t\t\t\tchangeShowDownloadButton,\n\t\t\t\t\tdisplayPreview,\n\t\t\t\t\tchangeDisplayPreview,\n\t\t\t\t\tpreviewHeight,\n\t\t\t\t\tchangePreviewHeight,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ href }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t\t<ClipboardToolbarButton\n\t\t\t\t\ttext={ href }\n\t\t\t\t\tdisabled={ isBlobURL( href ) }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ displayPreviewInEditor && (\n\t\t\t\t\t<ResizableBox\n\t\t\t\t\t\tsize={ { height: previewHeight } }\n\t\t\t\t\t\tminHeight={ MIN_PREVIEW_HEIGHT }\n\t\t\t\t\t\tmaxHeight={ MAX_PREVIEW_HEIGHT }\n\t\t\t\t\t\tminWidth=\"100%\"\n\t\t\t\t\t\tgrid={ [ 10, 10 ] }\n\t\t\t\t\t\tenable={ {\n\t\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\t\tright: false,\n\t\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResizeStart={ () => toggleSelection( false ) }\n\t\t\t\t\t\tonResizeStop={ handleOnResizeStop }\n\t\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t>\n\t\t\t\t\t\t<object\n\t\t\t\t\t\t\tclassName=\"wp-block-file__preview\"\n\t\t\t\t\t\t\tdata={ href }\n\t\t\t\t\t\t\ttype=\"application/pdf\"\n\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t'Embed of the selected PDF file.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isSelected && (\n\t\t\t\t\t\t\t<div className=\"wp-block-file__preview-overlay\" />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ResizableBox>\n\t\t\t\t) }\n\t\t\t\t<div className={ 'wp-block-file__content-wrapper' }>\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"a\"\n\t\t\t\t\t\tvalue={ fileName }\n\t\t\t\t\t\tplaceholder={ __( 'Write file name…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tfileName: removeAnchorTag( text ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thref={ textLinkHref }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showDownloadButton && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t'wp-block-file__button-richtext-wrapper'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ /* Using RichText here instead of PlainText so that it can be styled like a button. */ }\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\ttagName=\"div\" // Must be block-level or else cursor disappears.\n\t\t\t\t\t\t\t\taria-label={ __( 'Download button text' ) }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'wp-block-file__button',\n\t\t\t\t\t\t\t\t\t__experimentalGetElementClassName(\n\t\t\t\t\t\t\t\t\t\t'button'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tvalue={ downloadButtonText }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ __( 'Add text…' ) }\n\t\t\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tdownloadButtonText:\n\t\t\t\t\t\t\t\t\t\t\tremoveAnchorTag( text ),\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default FileEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,YAAY,EAAEC,SAAS,EAAEC,aAAa,QAAQ,iBAAiB;AACxE,SACCC,6BAA6B,IAAIC,mBAAmB,EACpDC,YAAY,EACZC,aAAa,QACP,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,aAAa,EACbC,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,iCAAiC,QAC3B,yBAAyB;AAChC,SAASC,SAAS,QAAQ,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AI,EAAG3E,IAAM;IACbX,IAAI,EAAC,iBAAiB;IACtB,cAAajB,EAAE,CACd,iCACD;EAAG,CACH,CAAC,EACA,CAAEsB,UAAU,IACbJ,aAAA;IAAKC,SAAS,EAAC;EAAgC,CAAE,CAErC,CACd,EACDD,aAAA;IAAKC,SAAS,EAAG;EAAkC,GAClDD,aAAA,CAACzB,QAAQ;IACR+G,OAAO,EAAC,GAAG;IACXC,KAAK,EAAG9E,QAAU;IAClB+E,WAAW,EAAG1G,EAAE,CAAE,kBAAmB,CAAG;IACxC2G,4BAA4B;IAC5BC,QAAQ,EAAKhG,IAAI,IAChBW,aAAa,CAAE;MACdI,QAAQ,EAAEnB,eAAe,CAAEI,IAAK;IACjC,CAAE,CACF;IACDgB,IAAI,EAAGC;EAAc,CACrB,CAAC,EACAE,kBAAkB,IACnBb,aAAA;IACCC,SAAS,EACR;EACA,GAGDD,aAAA,CAACzB,QAAQ;IACR+G,OAAO,EAAC,KAAK,CAAC;IAAA;IACd,cAAaxG,EAAE,CAAE,sBAAuB,CAAG;IAC3CmB,SAAS,EAAGxC,UAAU,CACrB,uBAAuB,EACvBkB,iCAAiC,CAChC,QACD,CACD,CAAG;IACH4G,KAAK,EAAGzE,kBAAoB;IAC5B2E,4BAA4B;IAC5BD,WAAW,EAAG1G,EAAE,CAAE,WAAY,CAAG;IACjC4G,QAAQ,EAAKhG,IAAI,IAChBW,aAAa,CAAE;MACdS,kBAAkB,EACjBxB,eAAe,CAAEI,IAAK;IACxB,CAAE;EACF,CACD,CACG,CAEF,CACD,CACJ,CAAC;AAEL;AAEA,eAAeQ,QAAQ"}
|
|
@@ -5,13 +5,11 @@ import { store } from '@wordpress/interactivity';
|
|
|
5
5
|
/**
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
|
-
import { browserSupportsPdfs
|
|
9
|
-
store({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
hasPdfPreview
|
|
14
|
-
}
|
|
8
|
+
import { browserSupportsPdfs } from './utils';
|
|
9
|
+
store('core/file', {
|
|
10
|
+
state: {
|
|
11
|
+
get hasPdfPreview() {
|
|
12
|
+
return browserSupportsPdfs();
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","browserSupportsPdfs","
|
|
1
|
+
{"version":3,"names":["store","browserSupportsPdfs","state","hasPdfPreview"],"sources":["@wordpress/block-library/src/file/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n/**\n * Internal dependencies\n */\nimport { browserSupportsPdfs } from './utils';\n\nstore( 'core/file', {\n\tstate: {\n\t\tget hasPdfPreview() {\n\t\t\treturn browserSupportsPdfs();\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,0BAA0B;AAChD;AACA;AACA;AACA,SAASC,mBAAmB,QAAQ,SAAS;AAE7CD,KAAK,CAAE,WAAW,EAAE;EACnBE,KAAK,EAAE;IACN,IAAIC,aAAaA,CAAA,EAAG;MACnB,OAAOF,mBAAmB,CAAC,CAAC;IAC7B;EACD;AACD,CAAE,CAAC"}
|
|
@@ -71,8 +71,7 @@ function GroupEdit({
|
|
|
71
71
|
attributes,
|
|
72
72
|
name,
|
|
73
73
|
setAttributes,
|
|
74
|
-
clientId
|
|
75
|
-
__unstableLayoutClassNames: layoutClassNames
|
|
74
|
+
clientId
|
|
76
75
|
}) {
|
|
77
76
|
const {
|
|
78
77
|
hasInnerBlocks,
|
|
@@ -102,9 +101,7 @@ function GroupEdit({
|
|
|
102
101
|
const layoutSupportEnabled = themeSupportsLayout || type === 'flex' || type === 'grid';
|
|
103
102
|
|
|
104
103
|
// Hooks.
|
|
105
|
-
const blockProps = useBlockProps(
|
|
106
|
-
className: !layoutSupportEnabled ? layoutClassNames : null
|
|
107
|
-
});
|
|
104
|
+
const blockProps = useBlockProps();
|
|
108
105
|
const [showPlaceholder, setShowPlaceholder] = useShouldShowPlaceHolder({
|
|
109
106
|
attributes,
|
|
110
107
|
usedLayoutType: type,
|
|
@@ -129,8 +126,7 @@ function GroupEdit({
|
|
|
129
126
|
}, {
|
|
130
127
|
templateLock,
|
|
131
128
|
allowedBlocks,
|
|
132
|
-
renderAppender
|
|
133
|
-
__unstableDisableLayoutClassNames: !layoutSupportEnabled
|
|
129
|
+
renderAppender
|
|
134
130
|
});
|
|
135
131
|
const {
|
|
136
132
|
selectBlock
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","useSelect","InnerBlocks","useBlockProps","InspectorControls","useInnerBlocksProps","store","blockEditorStore","SelectControl","__","View","GroupPlaceHolder","useShouldShowPlaceHolder","GroupEditControls","tagName","onSelectTagName","htmlElementMessages","header","main","section","article","aside","footer","createElement","group","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onChange","help","GroupEdit","attributes","name","setAttributes","clientId","__unstableLayoutClassNames","layoutClassNames","hasInnerBlocks","themeSupportsLayout","select","getBlock","getSettings","block","innerBlocks","length","supportsLayout","TagName","templateLock","allowedBlocks","layout","type","layoutSupportEnabled","blockProps","className","showPlaceholder","setShowPlaceholder","usedLayoutType","renderAppender","ButtonBlockAppender","innerBlocksProps","__unstableDisableLayoutClassNames","selectBlock","selectVariation","nextVariation","Fragment","children","onSelect"],"sources":["@wordpress/block-library/src/group/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInnerBlocks,\n\tuseBlockProps,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';\n\n/**\n * Render inspector controls for the Group block.\n *\n * @param {Object} props Component props.\n * @param {string} props.tagName The HTML tag name.\n * @param {Function} props.onSelectTagName onChange function for the SelectControl.\n *\n * @return {JSX.Element} The control group.\n */\nfunction GroupEditControls( { tagName, onSelectTagName } ) {\n\tconst htmlElementMessages = {\n\t\theader: __(\n\t\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t\t),\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\tarticle: __(\n\t\t\t'The <article> element should represent a self-contained, syndicatable portion of the document.'\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t\tfooter: __(\n\t\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t\t),\n\t};\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<SelectControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\toptions={ [\n\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t] }\n\t\t\t\tvalue={ tagName }\n\t\t\t\tonChange={ onSelectTagName }\n\t\t\t\thelp={ htmlElementMessages[ tagName ] }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction GroupEdit( {\n\tattributes,\n\tname,\n\tsetAttributes,\n\tclientId,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst { hasInnerBlocks, themeSupportsLayout } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getSettings } = select( blockEditorStore );\n\t\t\tconst block = getBlock( clientId );\n\t\t\treturn {\n\t\t\t\thasInnerBlocks: !! ( block && block.innerBlocks.length ),\n\t\t\t\tthemeSupportsLayout: getSettings()?.supportsLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst {\n\t\ttagName: TagName = 'div',\n\t\ttemplateLock,\n\t\tallowedBlocks,\n\t\tlayout = {},\n\t} = attributes;\n\n\t// Layout settings.\n\tconst { type = 'default' } = layout;\n\tconst layoutSupportEnabled =\n\t\tthemeSupportsLayout || type === 'flex' || type === 'grid';\n\n\t// Hooks.\n\tconst blockProps = useBlockProps( {\n\t\tclassName: ! layoutSupportEnabled ? layoutClassNames : null,\n\t} );\n\tconst [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {\n\t\tattributes,\n\t\tusedLayoutType: type,\n\t\thasInnerBlocks,\n\t} );\n\n\t// Default to the regular appender being rendered.\n\tlet renderAppender;\n\tif ( showPlaceholder ) {\n\t\t// In the placeholder state, ensure the appender is not rendered.\n\t\t// This is needed because `...innerBlocksProps` is used in the placeholder\n\t\t// state so that blocks can dragged onto the placeholder area\n\t\t// from both the list view and in the editor canvas.\n\t\trenderAppender = false;\n\t} else if ( ! hasInnerBlocks ) {\n\t\t// When there is no placeholder, but the block is also empty,\n\t\t// use the larger button appender.\n\t\trenderAppender = InnerBlocks.ButtonBlockAppender;\n\t}\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\tlayoutSupportEnabled\n\t\t\t? blockProps\n\t\t\t: { className: 'wp-block-group__inner-container' },\n\t\t{\n\t\t\ttemplateLock,\n\t\t\tallowedBlocks,\n\t\t\trenderAppender,\n\t\t\t__unstableDisableLayoutClassNames: ! layoutSupportEnabled,\n\t\t}\n\t);\n\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\tconst selectVariation = ( nextVariation ) => {\n\t\tsetAttributes( nextVariation.attributes );\n\t\tselectBlock( clientId, -1 );\n\t\tsetShowPlaceholder( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<GroupEditControls\n\t\t\t\ttagName={ TagName }\n\t\t\t\tonSelectTagName={ ( value ) =>\n\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ showPlaceholder && (\n\t\t\t\t<View>\n\t\t\t\t\t{ innerBlocksProps.children }\n\t\t\t\t\t<GroupPlaceHolder\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tonSelect={ selectVariation }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t\t{ layoutSupportEnabled && ! showPlaceholder && (\n\t\t\t\t<TagName { ...innerBlocksProps } />\n\t\t\t) }\n\t\t\t{ /* Ideally this is not needed but it's there for backward compatibility reason\n\t\t\t\tto keep this div for themes that might rely on its presence */ }\n\t\t\t{ ! layoutSupportEnabled && ! showPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default GroupEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,WAAW,EACXC,aAAa,EACbC,iBAAiB,EACjBC,mBAAmB,EACnBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,QAAQ,uBAAuB;;AAE5C;AACA;AACA;AACA,OAAOC,gBAAgB,IAAIC,wBAAwB,QAAQ,eAAe;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAAE;EAAEC,OAAO;EAAEC;AAAgB,CAAC,EAAG;EAC1D,MAAMC,mBAAmB,GAAG;IA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,CAAET;EACtC,CACD,CAAC;EAED,MAAM;IAAEU;EAAY,CAAC,GAAG/D,WAAW,CAAEO,gBAAiB,CAAC;EAEvD,MAAMyD,eAAe,GAAKC,aAAa,IAAM;IAC5C9B,aAAa,CAAE8B,aAAa,CAAChC,UAAW,CAAC;IACzC8B,WAAW,CAAE3B,QAAQ,EAAE,CAAC,CAAE,CAAC;IAC3BqB,kBAAkB,CAAE,KAAM,CAAC;EAC5B,CAAC;EAED,OACClC,aAAA,CAAA2C,QAAA,QACC3C,aAAA,CAACV,iBAAiB;IACjBC,OAAO,EAAGkC,OAAS;IACnBjC,eAAe,EAAKc,KAAK,IACxBM,aAAa,CAAE;MAAErB,OAAO,EAAEe;IAAM,CAAE;EAClC,CACD,CAAC,EACA2B,eAAe,IAChBjC,aAAA,CAACb,IAAI,QACFmD,gBAAgB,CAACM,QAAQ,EAC3B5C,aAAA,CAACZ,gBAAgB;IAChBuB,IAAI,EAAGA,IAAM;IACbkC,QAAQ,EAAGJ;EAAiB,CAC5B,CACI,CACN,EACCX,oBAAoB,IAAI,CAAEG,eAAe,IAC1CjC,aAAA,CAACyB,OAAO;IAAA,GAAMa;EAAgB,CAAI,CAClC,EAGC,CAAER,oBAAoB,IAAI,CAAEG,eAAe,IAC5CjC,aAAA,CAACyB,OAAO;IAAA,GAAMM;EAAU,GACvB/B,aAAA;IAAA,GAAUsC;EAAgB,CAAI,CACtB,CAET,CAAC;AAEL;AAEA,eAAe7B,SAAS"}
|
|
1
|
+
{"version":3,"names":["useDispatch","useSelect","InnerBlocks","useBlockProps","InspectorControls","useInnerBlocksProps","store","blockEditorStore","SelectControl","__","View","GroupPlaceHolder","useShouldShowPlaceHolder","GroupEditControls","tagName","onSelectTagName","htmlElementMessages","header","main","section","article","aside","footer","createElement","group","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onChange","help","GroupEdit","attributes","name","setAttributes","clientId","hasInnerBlocks","themeSupportsLayout","select","getBlock","getSettings","block","innerBlocks","length","supportsLayout","TagName","templateLock","allowedBlocks","layout","type","layoutSupportEnabled","blockProps","showPlaceholder","setShowPlaceholder","usedLayoutType","renderAppender","ButtonBlockAppender","innerBlocksProps","className","selectBlock","selectVariation","nextVariation","Fragment","children","onSelect"],"sources":["@wordpress/block-library/src/group/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInnerBlocks,\n\tuseBlockProps,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';\n\n/**\n * Render inspector controls for the Group block.\n *\n * @param {Object} props Component props.\n * @param {string} props.tagName The HTML tag name.\n * @param {Function} props.onSelectTagName onChange function for the SelectControl.\n *\n * @return {JSX.Element} The control group.\n */\nfunction GroupEditControls( { tagName, onSelectTagName } ) {\n\tconst htmlElementMessages = {\n\t\theader: __(\n\t\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t\t),\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\tarticle: __(\n\t\t\t'The <article> element should represent a self-contained, syndicatable portion of the document.'\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t\tfooter: __(\n\t\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t\t),\n\t};\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<SelectControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\toptions={ [\n\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t] }\n\t\t\t\tvalue={ tagName }\n\t\t\t\tonChange={ onSelectTagName }\n\t\t\t\thelp={ htmlElementMessages[ tagName ] }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction GroupEdit( { attributes, name, setAttributes, clientId } ) {\n\tconst { hasInnerBlocks, themeSupportsLayout } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getSettings } = select( blockEditorStore );\n\t\t\tconst block = getBlock( clientId );\n\t\t\treturn {\n\t\t\t\thasInnerBlocks: !! ( block && block.innerBlocks.length ),\n\t\t\t\tthemeSupportsLayout: getSettings()?.supportsLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst {\n\t\ttagName: TagName = 'div',\n\t\ttemplateLock,\n\t\tallowedBlocks,\n\t\tlayout = {},\n\t} = attributes;\n\n\t// Layout settings.\n\tconst { type = 'default' } = layout;\n\tconst layoutSupportEnabled =\n\t\tthemeSupportsLayout || type === 'flex' || type === 'grid';\n\n\t// Hooks.\n\tconst blockProps = useBlockProps();\n\n\tconst [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {\n\t\tattributes,\n\t\tusedLayoutType: type,\n\t\thasInnerBlocks,\n\t} );\n\n\t// Default to the regular appender being rendered.\n\tlet renderAppender;\n\tif ( showPlaceholder ) {\n\t\t// In the placeholder state, ensure the appender is not rendered.\n\t\t// This is needed because `...innerBlocksProps` is used in the placeholder\n\t\t// state so that blocks can dragged onto the placeholder area\n\t\t// from both the list view and in the editor canvas.\n\t\trenderAppender = false;\n\t} else if ( ! hasInnerBlocks ) {\n\t\t// When there is no placeholder, but the block is also empty,\n\t\t// use the larger button appender.\n\t\trenderAppender = InnerBlocks.ButtonBlockAppender;\n\t}\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\tlayoutSupportEnabled\n\t\t\t? blockProps\n\t\t\t: { className: 'wp-block-group__inner-container' },\n\t\t{\n\t\t\ttemplateLock,\n\t\t\tallowedBlocks,\n\t\t\trenderAppender,\n\t\t}\n\t);\n\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\tconst selectVariation = ( nextVariation ) => {\n\t\tsetAttributes( nextVariation.attributes );\n\t\tselectBlock( clientId, -1 );\n\t\tsetShowPlaceholder( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<GroupEditControls\n\t\t\t\ttagName={ TagName }\n\t\t\t\tonSelectTagName={ ( value ) =>\n\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ showPlaceholder && (\n\t\t\t\t<View>\n\t\t\t\t\t{ innerBlocksProps.children }\n\t\t\t\t\t<GroupPlaceHolder\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tonSelect={ selectVariation }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t\t{ layoutSupportEnabled && ! showPlaceholder && (\n\t\t\t\t<TagName { ...innerBlocksProps } />\n\t\t\t) }\n\t\t\t{ /* Ideally this is not needed but it's there for backward compatibility reason\n\t\t\t\tto keep this div for themes that might rely on its presence */ }\n\t\t\t{ ! layoutSupportEnabled && ! showPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default GroupEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,WAAW,EACXC,a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import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
|
|
11
11
|
import { Placeholder } from '@wordpress/components';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
-
import {
|
|
13
|
+
import { BlockIcon, MediaPlaceholder, useBlockProps, store as blockEditorStore, __experimentalUseBorderProps as useBorderProps, useBlockEditingMode } from '@wordpress/block-editor';
|
|
14
14
|
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
import { image as icon } from '@wordpress/icons';
|
|
@@ -80,13 +80,13 @@ export function ImageEdit({
|
|
|
80
80
|
url = '',
|
|
81
81
|
alt,
|
|
82
82
|
caption,
|
|
83
|
-
align,
|
|
84
83
|
id,
|
|
85
84
|
width,
|
|
86
85
|
height,
|
|
87
86
|
sizeSlug,
|
|
88
87
|
aspectRatio,
|
|
89
|
-
scale
|
|
88
|
+
scale,
|
|
89
|
+
align
|
|
90
90
|
} = attributes;
|
|
91
91
|
const [temporaryURL, setTemporaryURL] = useState();
|
|
92
92
|
const altRef = useRef();
|
|
@@ -97,6 +97,20 @@ export function ImageEdit({
|
|
|
97
97
|
useEffect(() => {
|
|
98
98
|
captionRef.current = caption;
|
|
99
99
|
}, [caption]);
|
|
100
|
+
const {
|
|
101
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
102
|
+
} = useDispatch(blockEditorStore);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (['wide', 'full'].includes(align)) {
|
|
105
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
106
|
+
setAttributes({
|
|
107
|
+
width: undefined,
|
|
108
|
+
height: undefined,
|
|
109
|
+
aspectRatio: undefined,
|
|
110
|
+
scale: undefined
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}, [align]);
|
|
100
114
|
const ref = useRef();
|
|
101
115
|
const {
|
|
102
116
|
imageDefaultSize,
|
|
@@ -226,16 +240,6 @@ export function ImageEdit({
|
|
|
226
240
|
});
|
|
227
241
|
}
|
|
228
242
|
}
|
|
229
|
-
function updateAlignment(nextAlign) {
|
|
230
|
-
const extraUpdatedAttributes = ['wide', 'full'].includes(nextAlign) ? {
|
|
231
|
-
width: undefined,
|
|
232
|
-
height: undefined
|
|
233
|
-
} : {};
|
|
234
|
-
setAttributes({
|
|
235
|
-
...extraUpdatedAttributes,
|
|
236
|
-
align: nextAlign
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
243
|
let isTemp = isTemporaryImage(id, url);
|
|
240
244
|
|
|
241
245
|
// Upload a temporary image on mount.
|
|
@@ -323,12 +327,7 @@ export function ImageEdit({
|
|
|
323
327
|
context: context,
|
|
324
328
|
clientId: clientId,
|
|
325
329
|
blockEditingMode: blockEditingMode
|
|
326
|
-
}),
|
|
327
|
-
group: "block"
|
|
328
|
-
}, createElement(BlockAlignmentControl, {
|
|
329
|
-
value: align,
|
|
330
|
-
onChange: updateAlignment
|
|
331
|
-
})), createElement(MediaPlaceholder, {
|
|
330
|
+
}), createElement(MediaPlaceholder, {
|
|
332
331
|
icon: createElement(BlockIcon, {
|
|
333
332
|
icon: icon
|
|
334
333
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","getBlobByURL","isBlobURL","revokeBlobURL","Placeholder","useDispatch","useSelect","BlockAlignmentControl","BlockControls","BlockIcon","MediaPlaceholder","useBlockProps","store","blockEditorStore","__experimentalUseBorderProps","useBorderProps","useBlockEditingMode","useEffect","useRef","useState","__","image","icon","noticesStore","Image","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","ALLOWED_MEDIA_TYPES","pickRelevantMediaFiles","size","imageProps","Object","fromEntries","entries","filter","key","includes","url","sizes","media_details","source_url","isTemporaryImage","id","isExternalImage","hasSize","_image$sizes$size","_image$media_details$","ImageEdit","attributes","setAttributes","isSelected","className","insertBlocksAfter","onReplace","context","clientId","alt","caption","align","width","height","sizeSlug","aspectRatio","scale","temporaryURL","setTemporaryURL","altRef","current","captionRef","ref","imageDefaultSize","mediaUpload","select","getSettings","settings","blockEditingMode","createErrorNotice","onUploadError","message","type","src","undefined","onSelectImage","media","title","newSize","mediaAttributes","omittedCaption","restMediaAttributes","additionalAttributes","linkDestination","window","wp","view","defaultProps","link","href","onSelectURL","newURL","updateAlignment","nextAlign","extraUpdatedAttributes","isTemp","file","filesList","onFileChange","img","allowedTypes","onError","isExternal","mediaPreview","createElement","borderProps","classes","style","keys","length","blockProps","placeholder","content","withIllustration","label","instructions","objectFit","containerRef","group","value","onChange","onSelect","accept","disableMediaButtons"],"sources":["@wordpress/block-library/src/image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tBlockAlignmentControl,\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { image as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport Image from './image';\n\n/**\n * Module constants\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_CUSTOM,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n\tALLOWED_MEDIA_TYPES,\n} from './constants';\n\nexport const pickRelevantMediaFiles = ( image, size ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\timage?.sizes?.[ size ]?.url ||\n\t\timage?.media_details?.sizes?.[ size ]?.source_url ||\n\t\timage.url;\n\treturn imageProps;\n};\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily\n * while the image is being uploaded and will not have an id yet allocated.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the URL a Blob URL\n */\nconst isTemporaryImage = ( id, url ) => ! id && isBlobURL( url );\n\n/**\n * Is the url for the image hosted externally. An externally hosted image has no\n * id and is not a blob url.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the url an externally hosted url?\n */\nexport const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );\n\n/**\n * Checks if WP generated the specified image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} size\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasSize( image, size ) {\n\treturn (\n\t\t'url' in ( image?.sizes?.[ size ] ?? {} ) ||\n\t\t'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tclassName,\n\tinsertBlocksAfter,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\talign,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tsizeSlug,\n\t\taspectRatio,\n\t\tscale,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState();\n\n\tconst altRef = useRef();\n\tuseEffect( () => {\n\t\taltRef.current = alt;\n\t}, [ alt ] );\n\n\tconst captionRef = useRef();\n\tuseEffect( () => {\n\t\tcaptionRef.current = caption;\n\t}, [ caption ] );\n\n\tconst ref = useRef();\n\tconst { imageDefaultSize, mediaUpload } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\timageDefaultSize: settings.imageDefaultSize,\n\t\t\tmediaUpload: settings.mediaUpload,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetAttributes( {\n\t\t\tsrc: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t} );\n\t\tsetTemporaryURL( undefined );\n\t}\n\n\tfunction onSelectImage( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\talt: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tsetTemporaryURL();\n\n\t\t// Try to use the previous selected image size if its available\n\t\t// otherwise try the default image size or fallback to \"full\"\n\t\tlet newSize = 'full';\n\t\tif ( sizeSlug && hasSize( media, sizeSlug ) ) {\n\t\t\tnewSize = sizeSlug;\n\t\t} else if ( hasSize( media, imageDefaultSize ) ) {\n\t\t\tnewSize = imageDefaultSize;\n\t\t}\n\n\t\tlet mediaAttributes = pickRelevantMediaFiles( media, newSize );\n\n\t\t// If a caption text was meanwhile written by the user,\n\t\t// make sure the text is not overwritten by empty captions.\n\t\tif ( captionRef.current && ! mediaAttributes.caption ) {\n\t\t\tconst { caption: omittedCaption, ...restMediaAttributes } =\n\t\t\t\tmediaAttributes;\n\t\t\tmediaAttributes = restMediaAttributes;\n\t\t}\n\n\t\tlet additionalAttributes;\n\t\t// Reset the dimension attributes if changing to a different image.\n\t\tif ( ! media.id || media.id !== id ) {\n\t\t\tadditionalAttributes = {\n\t\t\t\tsizeSlug: newSize,\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Resolution\"\n\t\t\t// option is not changed.\n\t\t\tadditionalAttributes = { url };\n\t\t}\n\n\t\t// Check if default link setting should be used.\n\t\tlet linkDestination = attributes.linkDestination;\n\t\tif ( ! linkDestination ) {\n\t\t\t// Use the WordPress option to determine the proper default.\n\t\t\t// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.\n\t\t\t// TODO: fix this in a follow up PR, requires updating media-text and ui component.\n\t\t\tswitch (\n\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\tLINK_DESTINATION_NONE\n\t\t\t) {\n\t\t\t\tcase 'file':\n\t\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_MEDIA;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'post':\n\t\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_ATTACHMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_CUSTOM:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_CUSTOM;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_NONE:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_NONE;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if the image is linked to it's media.\n\t\tlet href;\n\t\tswitch ( linkDestination ) {\n\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\thref = media.url;\n\t\t\t\tbreak;\n\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\thref = media.link;\n\t\t\t\tbreak;\n\t\t}\n\t\tmediaAttributes.href = href;\n\n\t\tsetAttributes( {\n\t\t\t...mediaAttributes,\n\t\t\t...additionalAttributes,\n\t\t\tlinkDestination,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newURL ) {\n\t\tif ( newURL !== url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: newURL,\n\t\t\t\tid: undefined,\n\t\t\t\tsizeSlug: imageDefaultSize,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction updateAlignment( nextAlign ) {\n\t\tconst extraUpdatedAttributes = [ 'wide', 'full' ].includes( nextAlign )\n\t\t\t? { width: undefined, height: undefined }\n\t\t\t: {};\n\t\tsetAttributes( {\n\t\t\t...extraUpdatedAttributes,\n\t\t\talign: nextAlign,\n\t\t} );\n\t}\n\n\tlet isTemp = isTemporaryImage( id, url );\n\n\t// Upload a temporary image on mount.\n\tuseEffect( () => {\n\t\tif ( ! isTemp ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = getBlobByURL( url );\n\n\t\tif ( file ) {\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList: [ file ],\n\t\t\t\tonFileChange: ( [ img ] ) => {\n\t\t\t\t\tonSelectImage( img );\n\t\t\t\t},\n\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\tonError: ( message ) => {\n\t\t\t\t\tisTemp = false;\n\t\t\t\t\tonUploadError( message );\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\t// If an image is temporary, revoke the Blob url when it is uploaded (and is\n\t// no longer temporary).\n\tuseEffect( () => {\n\t\tif ( isTemp ) {\n\t\t\tsetTemporaryURL( url );\n\t\t\treturn;\n\t\t}\n\t\trevokeBlobURL( temporaryURL );\n\t}, [ isTemp, url ] );\n\n\tconst isExternal = isExternalImage( id, url );\n\tconst src = isExternal ? url : undefined;\n\tconst mediaPreview = !! url && (\n\t\t<img\n\t\t\talt={ __( 'Edit image' ) }\n\t\t\ttitle={ __( 'Edit image' ) }\n\t\t\tclassName={ 'edit-image-preview' }\n\t\t\tsrc={ url }\n\t\t/>\n\t);\n\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t'has-custom-border':\n\t\t\t!! borderProps.className ||\n\t\t\t( borderProps.style &&\n\t\t\t\tObject.keys( borderProps.style ).length > 0 ),\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref,\n\t\tclassName: classes,\n\t} );\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames( 'block-editor-media-placeholder', {\n\t\t\t\t\t[ borderProps.className ]:\n\t\t\t\t\t\t!! borderProps.className && ! isSelected,\n\t\t\t\t} ) }\n\t\t\t\twithIllustration={ true }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! ( width && height ) && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\twidth: height && aspectRatio ? '100%' : width,\n\t\t\t\t\theight: width && aspectRatio ? '100%' : height,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\treturn (\n\t\t<figure { ...blockProps }>\n\t\t\t<Image\n\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\tcontainerRef={ ref }\n\t\t\t\tcontext={ context }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\t/>\n\t\t\t{ ! url && blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\tvalue={ align }\n\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<MediaPlaceholder\n\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tvalue={ { id, src } }\n\t\t\t\tmediaPreview={ mediaPreview }\n\t\t\t\tdisableMediaButtons={ temporaryURL || url }\n\t\t\t/>\n\t\t</figure>\n\t);\n}\n\nexport default ImageEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,YAAY,EAAEC,SAAS,EAAEC,aAAa,QAAQ,iBAAiB;AACxE,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,qBAAqB,EACrBC,aAAa,EACbC,SAAS,EACTC,gBAAgB,EAChBC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,4BAA4B,IAAIC,cAAc,EAC9CC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,IAAI,QAAQ,kBAAkB;AAChD,SAASV,KAAK,IAAIW,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,O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OAAO,EAAG/B,aAAe;IACzByC,WAAW,EAAGA,WAAa;IAC3BW,MAAM,EAAC,SAAS;IAChBtB,YAAY,EAAGhF,mBAAqB;IACpCmG,KAAK,EAAG;MAAEpF,EAAE;MAAEsC;IAAI,CAAG;IACrB8B,YAAY,EAAGA,YAAc;IAC7BoB,mBAAmB,EAAGlE,YAAY,IAAI3B;EAAK,CAC3C,CACM,CAAC;AAEX;AAEA,eAAeU,SAAS"}
|
|
1
|
+
{"version":3,"names":["classnames","getBlobByURL","isBlobURL","revokeBlobURL","Placeholder","useDispatch","useSelect","BlockIcon","MediaPlaceholder","useBlockProps","store","blockEditorStore","__experimentalUseBorderProps","useBorderProps","useBlockEditingMode","useEffect","useRef","useState","__","image","icon","noticesStore","Image","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","ALLOWED_MEDIA_TYPES","pickRelevantMediaFiles","size","imageProps","Object","fromEntries","entries","filter","key","includes","url","sizes","media_details","source_url","isTemporaryImage","id","isExternalImage","hasSize","_image$sizes$size","_image$media_details$","ImageEdit","attributes","setAttributes","isSelected","className","insertBlocksAfter","onReplace","context","clientId","alt","caption","width","height","sizeSlug","aspectRatio","scale","align","temporaryURL","setTemporaryURL","altRef","current","captionRef","__unstableMarkNextChangeAsNotPersistent","undefined","ref","imageDefaultSize","mediaUpload","select","getSettings","settings","blockEditingMode","createErrorNotice","onUploadError","message","type","src","onSelectImage","media","title","newSize","mediaAttributes","omittedCaption","restMediaAttributes","additionalAttributes","linkDestination","window","wp","view","defaultProps","link","href","onSelectURL","newURL","isTemp","file","filesList","onFileChange","img","allowedTypes","onError","isExternal","mediaPreview","createElement","borderProps","classes","style","keys","length","blockProps","placeholder","content","withIllustration","label","instructions","objectFit","containerRef","onSelect","accept","value","disableMediaButtons"],"sources":["@wordpress/block-library/src/image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tBlockIcon,\n\tMediaPlaceholder,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { image as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport Image from './image';\n\n/**\n * Module constants\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_CUSTOM,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n\tALLOWED_MEDIA_TYPES,\n} from './constants';\n\nexport const pickRelevantMediaFiles = ( image, size ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\timage?.sizes?.[ size ]?.url ||\n\t\timage?.media_details?.sizes?.[ size ]?.source_url ||\n\t\timage.url;\n\treturn imageProps;\n};\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily\n * while the image is being uploaded and will not have an id yet allocated.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the URL a Blob URL\n */\nconst isTemporaryImage = ( id, url ) => ! id && isBlobURL( url );\n\n/**\n * Is the url for the image hosted externally. An externally hosted image has no\n * id and is not a blob url.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the url an externally hosted url?\n */\nexport const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );\n\n/**\n * Checks if WP generated the specified image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} size\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasSize( image, size ) {\n\treturn (\n\t\t'url' in ( image?.sizes?.[ size ] ?? {} ) ||\n\t\t'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tclassName,\n\tinsertBlocksAfter,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tsizeSlug,\n\t\taspectRatio,\n\t\tscale,\n\t\talign,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState();\n\n\tconst altRef = useRef();\n\tuseEffect( () => {\n\t\taltRef.current = alt;\n\t}, [ alt ] );\n\n\tconst captionRef = useRef();\n\tuseEffect( () => {\n\t\tcaptionRef.current = caption;\n\t}, [ caption ] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( [ 'wide', 'full' ].includes( align ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\taspectRatio: undefined,\n\t\t\t\tscale: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ align ] );\n\n\tconst ref = useRef();\n\tconst { imageDefaultSize, mediaUpload } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\timageDefaultSize: settings.imageDefaultSize,\n\t\t\tmediaUpload: settings.mediaUpload,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetAttributes( {\n\t\t\tsrc: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t} );\n\t\tsetTemporaryURL( undefined );\n\t}\n\n\tfunction onSelectImage( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\talt: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tsetTemporaryURL();\n\n\t\t// Try to use the previous selected image size if its available\n\t\t// otherwise try the default image size or fallback to \"full\"\n\t\tlet newSize = 'full';\n\t\tif ( sizeSlug && hasSize( media, sizeSlug ) ) {\n\t\t\tnewSize = sizeSlug;\n\t\t} else if ( hasSize( media, imageDefaultSize ) ) {\n\t\t\tnewSize = imageDefaultSize;\n\t\t}\n\n\t\tlet mediaAttributes = pickRelevantMediaFiles( media, newSize );\n\n\t\t// If a caption text was meanwhile written by the user,\n\t\t// make sure the text is not overwritten by empty captions.\n\t\tif ( captionRef.current && ! mediaAttributes.caption ) {\n\t\t\tconst { caption: omittedCaption, ...restMediaAttributes } =\n\t\t\t\tmediaAttributes;\n\t\t\tmediaAttributes = restMediaAttributes;\n\t\t}\n\n\t\tlet additionalAttributes;\n\t\t// Reset the dimension attributes if changing to a different image.\n\t\tif ( ! media.id || media.id !== id ) {\n\t\t\tadditionalAttributes = {\n\t\t\t\tsizeSlug: newSize,\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Resolution\"\n\t\t\t// option is not changed.\n\t\t\tadditionalAttributes = { url };\n\t\t}\n\n\t\t// Check if default link setting should be used.\n\t\tlet linkDestination = attributes.linkDestination;\n\t\tif ( ! linkDestination ) {\n\t\t\t// Use the WordPress option to determine the proper default.\n\t\t\t// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.\n\t\t\t// TODO: fix this in a follow up PR, requires updating media-text and ui component.\n\t\t\tswitch (\n\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\tLINK_DESTINATION_NONE\n\t\t\t) {\n\t\t\t\tcase 'file':\n\t\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_MEDIA;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'post':\n\t\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_ATTACHMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_CUSTOM:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_CUSTOM;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_NONE:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_NONE;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if the image is linked to it's media.\n\t\tlet href;\n\t\tswitch ( linkDestination ) {\n\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\thref = media.url;\n\t\t\t\tbreak;\n\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\thref = media.link;\n\t\t\t\tbreak;\n\t\t}\n\t\tmediaAttributes.href = href;\n\n\t\tsetAttributes( {\n\t\t\t...mediaAttributes,\n\t\t\t...additionalAttributes,\n\t\t\tlinkDestination,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newURL ) {\n\t\tif ( newURL !== url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: newURL,\n\t\t\t\tid: undefined,\n\t\t\t\tsizeSlug: imageDefaultSize,\n\t\t\t} );\n\t\t}\n\t}\n\n\tlet isTemp = isTemporaryImage( id, url );\n\n\t// Upload a temporary image on mount.\n\tuseEffect( () => {\n\t\tif ( ! isTemp ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = getBlobByURL( url );\n\n\t\tif ( file ) {\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList: [ file ],\n\t\t\t\tonFileChange: ( [ img ] ) => {\n\t\t\t\t\tonSelectImage( img );\n\t\t\t\t},\n\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\tonError: ( message ) => {\n\t\t\t\t\tisTemp = false;\n\t\t\t\t\tonUploadError( message );\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\t// If an image is temporary, revoke the Blob url when it is uploaded (and is\n\t// no longer temporary).\n\tuseEffect( () => {\n\t\tif ( isTemp ) {\n\t\t\tsetTemporaryURL( url );\n\t\t\treturn;\n\t\t}\n\t\trevokeBlobURL( temporaryURL );\n\t}, [ isTemp, url ] );\n\n\tconst isExternal = isExternalImage( id, url );\n\tconst src = isExternal ? url : undefined;\n\tconst mediaPreview = !! url && (\n\t\t<img\n\t\t\talt={ __( 'Edit image' ) }\n\t\t\ttitle={ __( 'Edit image' ) }\n\t\t\tclassName={ 'edit-image-preview' }\n\t\t\tsrc={ url }\n\t\t/>\n\t);\n\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t'has-custom-border':\n\t\t\t!! borderProps.className ||\n\t\t\t( borderProps.style &&\n\t\t\t\tObject.keys( borderProps.style ).length > 0 ),\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref,\n\t\tclassName: classes,\n\t} );\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames( 'block-editor-media-placeholder', {\n\t\t\t\t\t[ borderProps.className ]:\n\t\t\t\t\t\t!! borderProps.className && ! isSelected,\n\t\t\t\t} ) }\n\t\t\t\twithIllustration={ true }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! ( width && height ) && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\twidth: height && aspectRatio ? '100%' : width,\n\t\t\t\t\theight: width && aspectRatio ? '100%' : height,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\treturn (\n\t\t<figure { ...blockProps }>\n\t\t\t<Image\n\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\tcontainerRef={ ref }\n\t\t\t\tcontext={ context }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\t/>\n\t\t\t<MediaPlaceholder\n\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tvalue={ { id, src } }\n\t\t\t\tmediaPreview={ mediaPreview }\n\t\t\t\tdisableMediaButtons={ temporaryURL || url }\n\t\t\t/>\n\t\t</figure>\n\t);\n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,UAAY;IACzBE,iBAAiB,EAAGA,iBAAmB;IACvCC,SAAS,EAAGA,SAAW;IACvB8B,aAAa,EAAGA,aAAe;IAC/Be,WAAW,EAAGA,WAAa;IAC3BnB,aAAa,EAAGA,aAAe;IAC/B2C,YAAY,EAAGnD,GAAK;IACpBjB,OAAO,EAAGA,OAAS;IACnBC,QAAQ,EAAGA,QAAU;IACrBsB,gBAAgB,EAAGA;EAAkB,CACrC,CAAC,EACFgC,aAAA,CAACrG,gBAAgB;IAChBY,IAAI,EAAGyF,aAAA,CAACtG,SAAS;MAACa,IAAI,EAAGA;IAAM,CAAE,CAAG;IACpCuG,QAAQ,EAAGxC,aAAe;IAC1Be,WAAW,EAAGA,WAAa;IAC3BQ,OAAO,EAAG3B,aAAe;IACzBqC,WAAW,EAAGA,WAAa;IAC3BQ,MAAM,EAAC,SAAS;IAChBnB,YAAY,EAAG9E,mBAAqB;IACpCkG,KAAK,EAAG;MAAEnF,EAAE;MAAEwC;IAAI,CAAG;IACrB0B,YAAY,EAAGA,YAAc;IAC7BkB,mBAAmB,EAAG9D,YAAY,IAAI3B;EAAK,CAC3C,CACM,CAAC;AAEX;AAEA,eAAeU,SAAS"}
|
|
@@ -11,7 +11,7 @@ import { useRoute } from '@react-navigation/native';
|
|
|
11
11
|
import { Component, useEffect } from '@wordpress/element';
|
|
12
12
|
import { requestMediaImport, mediaUploadSync, requestImageFailedRetryDialog, requestImageUploadCancelDialog, requestImageFullscreenPreview, setFeaturedImage } from '@wordpress/react-native-bridge';
|
|
13
13
|
import { Icon, PanelBody, ToolbarButton, ToolbarGroup, Image, WIDE_ALIGNMENTS, LinkSettingsNavigation, BottomSheet, BottomSheetTextControl, BottomSheetSelectControl, FooterMessageControl, FooterMessageLink, Badge } from '@wordpress/components';
|
|
14
|
-
import { BlockCaption, MediaPlaceholder, MediaUpload, MediaUploadProgress, MEDIA_TYPE_IMAGE, BlockControls, InspectorControls,
|
|
14
|
+
import { BlockCaption, MediaPlaceholder, MediaUpload, MediaUploadProgress, MEDIA_TYPE_IMAGE, BlockControls, InspectorControls, BlockStyles, store as blockEditorStore, blockSettingsScreens } from '@wordpress/block-editor';
|
|
15
15
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
16
16
|
import { getProtocol, hasQueryArg, isURL } from '@wordpress/url';
|
|
17
17
|
import { doAction, hasAction } from '@wordpress/hooks';
|
|
@@ -153,7 +153,6 @@ export class ImageEdit extends Component {
|
|
|
153
153
|
this.onSetFeatured = this.onSetFeatured.bind(this);
|
|
154
154
|
this.onFocusCaption = this.onFocusCaption.bind(this);
|
|
155
155
|
this.onSelectURL = this.onSelectURL.bind(this);
|
|
156
|
-
this.updateAlignment = this.updateAlignment.bind(this);
|
|
157
156
|
this.accessibilityLabelCreator = this.accessibilityLabelCreator.bind(this);
|
|
158
157
|
this.setMappedAttributes = this.setMappedAttributes.bind(this);
|
|
159
158
|
this.onSizeChangeValue = this.onSizeChangeValue.bind(this);
|
|
@@ -233,6 +232,23 @@ export class ImageEdit extends Component {
|
|
|
233
232
|
this.replacedFeaturedImage = false;
|
|
234
233
|
setFeaturedImage(id);
|
|
235
234
|
}
|
|
235
|
+
const {
|
|
236
|
+
align
|
|
237
|
+
} = attributes;
|
|
238
|
+
const {
|
|
239
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
240
|
+
} = this.props;
|
|
241
|
+
|
|
242
|
+
// Update the attributes if the align is wide or full
|
|
243
|
+
if (['wide', 'full'].includes(align)) {
|
|
244
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
245
|
+
setAttributes({
|
|
246
|
+
width: undefined,
|
|
247
|
+
height: undefined,
|
|
248
|
+
aspectRatio: undefined,
|
|
249
|
+
scale: undefined
|
|
250
|
+
});
|
|
251
|
+
}
|
|
236
252
|
}
|
|
237
253
|
static getDerivedStateFromProps(props, state) {
|
|
238
254
|
// Avoid a UI flicker in the toolbar by insuring that isCaptionSelected
|
|
@@ -320,16 +336,6 @@ export class ImageEdit extends Component {
|
|
|
320
336
|
height: undefined
|
|
321
337
|
});
|
|
322
338
|
}
|
|
323
|
-
updateAlignment(nextAlign) {
|
|
324
|
-
const extraUpdatedAttributes = Object.values(WIDE_ALIGNMENTS.alignments).includes(nextAlign) ? {
|
|
325
|
-
width: undefined,
|
|
326
|
-
height: undefined
|
|
327
|
-
} : {};
|
|
328
|
-
this.props.setAttributes({
|
|
329
|
-
...extraUpdatedAttributes,
|
|
330
|
-
align: nextAlign
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
339
|
onSetNewTab(value) {
|
|
334
340
|
const updatedLinkTarget = getUpdatedLinkTargetSettings(value, this.props.attributes);
|
|
335
341
|
this.props.setAttributes(updatedLinkTarget);
|
|
@@ -601,10 +607,7 @@ export class ImageEdit extends Component {
|
|
|
601
607
|
title: __('Edit image'),
|
|
602
608
|
icon: replace,
|
|
603
609
|
onClick: open
|
|
604
|
-
}))
|
|
605
|
-
value: align,
|
|
606
|
-
onChange: this.updateAlignment
|
|
607
|
-
}));
|
|
610
|
+
})));
|
|
608
611
|
const getInspectorControls = () => createElement(InspectorControls, null, createElement(PanelBody, {
|
|
609
612
|
title: __('Settings')
|
|
610
613
|
}), createElement(PanelBody, {
|
|
@@ -768,7 +771,11 @@ export default compose([withSelect((select, props) => {
|
|
|
768
771
|
const {
|
|
769
772
|
createErrorNotice
|
|
770
773
|
} = dispatch(noticesStore);
|
|
774
|
+
const {
|
|
775
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
776
|
+
} = dispatch(blockEditorStore);
|
|
771
777
|
return {
|
|
778
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
772
779
|
createErrorNotice,
|
|
773
780
|
closeSettingsBottomSheet() {
|
|
774
781
|
dispatch(editPostStore).closeGeneralSidebar();
|