@wordpress/block-library 7.6.0 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/button/deprecated.js +175 -35
- package/build/button/deprecated.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/button/save.js +1 -1
- package/build/button/save.js.map +1 -1
- package/build/columns/index.js +3 -1
- package/build/columns/index.js.map +1 -1
- package/build/cover/deprecated.js +212 -207
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/index.js +13 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/save.js +18 -5
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +14 -17
- package/build/cover/shared.js.map +1 -1
- package/build/file/edit.js +1 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/save.js +9 -1
- package/build/file/save.js.map +1 -1
- package/build/gallery/gap-styles.js +14 -4
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/gallery/index.js +1 -1
- package/build/image/edit.js +5 -59
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +56 -3
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +3 -13
- package/build/image/image.js.map +1 -1
- package/build/list-item/hooks/use-split.js +17 -3
- package/build/list-item/hooks/use-split.js.map +1 -1
- package/build/navigation-link/edit.js +31 -5
- package/build/navigation-link/edit.js.map +1 -1
- package/build/post-author-name/index.js +3 -0
- package/build/post-author-name/index.js.map +1 -1
- package/build/post-author-name/transforms.js +41 -0
- package/build/post-author-name/transforms.js.map +1 -0
- package/build/post-comments-form/form.js +11 -1
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-date/edit.js +13 -7
- package/build/post-date/edit.js.map +1 -1
- package/build/search/edit.js +1 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +4 -0
- package/build/search/index.js.map +1 -1
- package/build/shortcode/edit.native.js +16 -13
- package/build/shortcode/edit.native.js.map +1 -1
- package/build/social-links/edit.js +2 -2
- package/build/social-links/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +11 -3
- package/build/table-of-contents/edit.js.map +1 -1
- package/build-module/button/deprecated.js +175 -35
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/save.js +2 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/columns/index.js +3 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/cover/deprecated.js +206 -198
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/index.js +14 -4
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/save.js +19 -6
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +11 -12
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/file/edit.js +2 -2
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/save.js +7 -2
- package/build-module/file/save.js.map +1 -1
- package/build-module/gallery/gap-styles.js +14 -4
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/gallery/index.js +1 -1
- package/build-module/image/edit.js +5 -56
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +57 -5
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +4 -14
- package/build-module/image/image.js.map +1 -1
- package/build-module/list-item/hooks/use-split.js +19 -5
- package/build-module/list-item/hooks/use-split.js.map +1 -1
- package/build-module/navigation-link/edit.js +31 -6
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/post-author-name/index.js +2 -0
- package/build-module/post-author-name/index.js.map +1 -1
- package/build-module/post-author-name/transforms.js +32 -0
- package/build-module/post-author-name/transforms.js.map +1 -0
- package/build-module/post-comments-form/form.js +7 -1
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-date/edit.js +15 -9
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/search/edit.js +2 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +4 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/shortcode/edit.native.js +17 -13
- package/build-module/shortcode/edit.native.js.map +1 -1
- package/build-module/social-links/edit.js +2 -2
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +12 -4
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-style/cover/style-rtl.css +32 -23
- package/build-style/cover/style.css +32 -23
- package/build-style/site-logo/style-rtl.css +4 -0
- package/build-style/site-logo/style.css +4 -0
- package/build-style/style-rtl.css +36 -23
- package/build-style/style.css +36 -23
- package/package.json +28 -28
- package/src/button/deprecated.js +145 -0
- package/src/button/edit.js +3 -1
- package/src/button/save.js +3 -1
- package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/buttons/test/edit.native.js +1 -1
- package/src/columns/block.json +3 -1
- package/src/cover/deprecated.js +230 -183
- package/src/cover/edit/index.js +25 -13
- package/src/cover/save.js +26 -13
- package/src/cover/shared.js +5 -7
- package/src/cover/style.scss +27 -22
- package/src/file/edit.js +5 -1
- package/src/file/save.js +14 -2
- package/src/gallery/block.json +1 -1
- package/src/gallery/gap-styles.js +21 -6
- package/src/gallery/index.php +23 -12
- package/src/image/edit.js +1 -53
- package/src/image/edit.native.js +65 -3
- package/src/image/image.js +2 -11
- package/src/image/styles.native.scss +11 -0
- package/src/list-item/hooks/use-split.js +18 -9
- package/src/navigation-link/edit.js +35 -5
- package/src/navigation-link/test/edit.js +0 -20
- package/src/post-author/index.php +3 -2
- package/src/post-author-name/index.js +2 -0
- package/src/post-author-name/index.php +1 -1
- package/src/post-author-name/transforms.js +25 -0
- package/src/post-comments/index.php +1 -1
- package/src/post-comments-form/form.js +11 -1
- package/src/post-comments-form/index.php +1 -1
- package/src/post-date/edit.js +4 -3
- package/src/query-pagination/index.php +0 -1
- package/src/search/block.json +4 -0
- package/src/search/edit.js +3 -1
- package/src/search/index.php +28 -15
- package/src/shortcode/edit.native.js +29 -15
- package/src/shortcode/style.native.scss +11 -4
- package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
- package/src/shortcode/test/edit.native.js +58 -40
- package/src/site-logo/style.scss +6 -0
- package/src/social-links/edit.js +11 -10
- package/src/table-of-contents/edit.js +19 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/cover/shared.js"],"names":["POSITION_CLASSNAMES","center","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","COVER_MIN_HEIGHT","COVER_MAX_HEIGHT","COVER_DEFAULT_HEIGHT","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/cover/shared.js"],"names":["POSITION_CLASSNAMES","center","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","COVER_MIN_HEIGHT","COVER_MAX_HEIGHT","COVER_DEFAULT_HEIGHT","DEFAULT_FOCAL_POINT","x","y","ALLOWED_MEDIA_TYPES","mediaPosition","Math","round","dimRatioToClass","ratio","undefined","attributesFromMedia","setAttributes","dimRatio","media","url","id","type","mediaType","media_type","alt","backgroundType","focalPoint","hasParallax","isContentPositionCenter","contentPosition","getPositionClassName"],"mappings":";;;;;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG;AAC3B,cAAY,sBADe;AAE3B,gBAAc,wBAFa;AAG3B,eAAa,uBAHc;AAI3B,iBAAe,yBAJY;AAK3B,mBAAiB,2BALU;AAM3BC,EAAAA,MAAM,EAAE,2BANmB;AAO3B,kBAAgB,0BAPW;AAQ3B,iBAAe,yBARY;AAS3B,mBAAiB,2BATU;AAU3B,kBAAgB;AAVW,CAA5B;AAaO,MAAMC,qBAAqB,GAAG,OAA9B;;AACA,MAAMC,qBAAqB,GAAG,OAA9B;;AACA,MAAMC,gBAAgB,GAAG,EAAzB;;AACA,MAAMC,gBAAgB,GAAG,IAAzB;;AACA,MAAMC,oBAAoB,GAAG,GAA7B;;AACA,MAAMC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;AACA;AACD,KARD,MAQO;AACN;AACA,UACCiB,KAAK,CAACG,IAAN,KAAerB,qBAAf,IACAkB,KAAK,CAACG,IAAN,KAAepB,qBAFhB,EAGE;AACD;AACA;;AACDqB,MAAAA,SAAS,GAAGJ,KAAK,CAACG,IAAlB;AACA;;AAEDL,IAAAA,aAAa,CAAE;AACdC,MAAAA,QAAQ,EAAEA,QAAQ,KAAK,GAAb,GAAmB,EAAnB,GAAwBA,QADpB;AAEdE,MAAAA,GAAG,EAAED,KAAK,CAACC,GAFG;AAGdC,MAAAA,EAAE,EAAEF,KAAK,CAACE,EAHI;AAIdI,MAAAA,GAAG,EAAEN,KAAF,aAAEA,KAAF,uBAAEA,KAAK,CAAEM,GAJE;AAKdC,MAAAA,cAAc,EAAEH,SALF;AAMd,UAAKA,SAAS,KAAKrB,qBAAd,GACF;AAAEyB,QAAAA,UAAU,EAAEZ,SAAd;AAAyBa,QAAAA,WAAW,EAAEb;AAAtC,OADE,GAEF,EAFH;AANc,KAAF,CAAb;AAUA,GAzCD;AA0CA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASc,uBAAT,CAAkCC,eAAlC,EAAoD;AAC1D,SACC,CAAEA,eAAF,IACAA,eAAe,KAAK,eADpB,IAEAA,eAAe,KAAK,QAHrB;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,oBAAT,CAA+BD,eAA/B,EAAiD;AACvD;AACD;AACA;AACC,MAAKD,uBAAuB,CAAEC,eAAF,CAA5B,EAAkD,OAAO,EAAP;AAElD,SAAO/B,mBAAmB,CAAE+B,eAAF,CAA1B;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlobTypeByURL, isBlobURL } from '@wordpress/blob';\n\nconst POSITION_CLASSNAMES = {\n\t'top left': 'is-position-top-left',\n\t'top center': 'is-position-top-center',\n\t'top right': 'is-position-top-right',\n\t'center left': 'is-position-center-left',\n\t'center center': 'is-position-center-center',\n\tcenter: 'is-position-center-center',\n\t'center right': 'is-position-center-right',\n\t'bottom left': 'is-position-bottom-left',\n\t'bottom center': 'is-position-bottom-center',\n\t'bottom right': 'is-position-bottom-right',\n};\n\nexport const IMAGE_BACKGROUND_TYPE = 'image';\nexport const VIDEO_BACKGROUND_TYPE = 'video';\nexport const COVER_MIN_HEIGHT = 50;\nexport const COVER_MAX_HEIGHT = 1000;\nexport const COVER_DEFAULT_HEIGHT = 300;\nexport const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\nexport const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\n\nexport function mediaPosition( { x, y } = DEFAULT_FOCAL_POINT ) {\n\treturn `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;\n}\n\nexport function dimRatioToClass( ratio ) {\n\treturn ratio === 50 || ! ratio === undefined\n\t\t? null\n\t\t: 'has-background-dim-' + 10 * Math.round( ratio / 10 );\n}\n\nexport function attributesFromMedia( setAttributes, dimRatio ) {\n\treturn ( media ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( { url: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tmedia.type = getBlobTypeByURL( media.url );\n\t\t}\n\n\t\tlet mediaType;\n\t\t// For media selections originated from a file upload.\n\t\tif ( media.media_type ) {\n\t\t\tif ( media.media_type === IMAGE_BACKGROUND_TYPE ) {\n\t\t\t\tmediaType = IMAGE_BACKGROUND_TYPE;\n\t\t\t} else {\n\t\t\t\t// only images and videos are accepted so if the media_type is not an image we can assume it is a video.\n\t\t\t\t// Videos contain the media type of 'file' in the object returned from the rest api.\n\t\t\t\tmediaType = VIDEO_BACKGROUND_TYPE;\n\t\t\t}\n\t\t} else {\n\t\t\t// For media selections originated from existing files in the media library.\n\t\t\tif (\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE &&\n\t\t\t\tmedia.type !== VIDEO_BACKGROUND_TYPE\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmediaType = media.type;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\turl: media.url,\n\t\t\tid: media.id,\n\t\t\talt: media?.alt,\n\t\t\tbackgroundType: mediaType,\n\t\t\t...( mediaType === VIDEO_BACKGROUND_TYPE\n\t\t\t\t? { focalPoint: undefined, hasParallax: undefined }\n\t\t\t\t: {} ),\n\t\t} );\n\t};\n}\n\n/**\n * Checks of the contentPosition is the center (default) position.\n *\n * @param {string} contentPosition The current content position.\n * @return {boolean} Whether the contentPosition is center.\n */\nexport function isContentPositionCenter( contentPosition ) {\n\treturn (\n\t\t! contentPosition ||\n\t\tcontentPosition === 'center center' ||\n\t\tcontentPosition === 'center'\n\t);\n}\n\n/**\n * Retrieves the className for the current contentPosition.\n * The default position (center) will not have a className.\n *\n * @param {string} contentPosition The current content position.\n * @return {string} The className assigned to the contentPosition.\n */\nexport function getPositionClassName( contentPosition ) {\n\t/*\n\t * Only render a className if the contentPosition is not center (the default).\n\t */\n\tif ( isContentPositionCenter( contentPosition ) ) return '';\n\n\treturn POSITION_CLASSNAMES[ contentPosition ];\n}\n"]}
|
package/build/file/edit.js
CHANGED
|
@@ -298,7 +298,7 @@ function FileEdit(_ref2) {
|
|
|
298
298
|
tagName: "div" // Must be block-level or else cursor disappears.
|
|
299
299
|
,
|
|
300
300
|
"aria-label": (0, _i18n.__)('Download button text'),
|
|
301
|
-
className: 'wp-block-file__button',
|
|
301
|
+
className: (0, _classnames.default)('wp-block-file__button', _blockEditor.__experimentalElementButtonClassName),
|
|
302
302
|
value: downloadButtonText,
|
|
303
303
|
withoutInteractiveFormatting: true,
|
|
304
304
|
placeholder: (0, _i18n.__)('Add text…'),
|
package/build/file/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/file/edit.js"],"names":["MIN_PREVIEW_HEIGHT","MAX_PREVIEW_HEIGHT","ClipboardToolbarButton","text","disabled","createNotice","noticesStore","ref","isDismissible","type","FileEdit","attributes","isSelected","setAttributes","noticeUI","noticeOperations","clientId","id","fileId","fileName","href","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","media","mediaUpload","select","undefined","coreStore","getMedia","blockEditorStore","getSettings","toggleSelection","__unstableMarkNextChangeAsNotPersistent","file","filesList","onFileChange","newMedia","onSelectFile","onError","onUploadError","changeDownloadButtonText","url","isPdf","endsWith","title","message","removeAllNotices","createErrorNotice","changeLinkDestinationOption","newHref","changeOpenInNewWindow","newValue","changeShowDownloadButton","replace","changeDisplayPreview","handleOnResizeStop","event","direction","elt","delta","newHeight","parseInt","height","changePreviewHeight","Math","max","attachmentPage","link","blockProps","className","displayPreviewInEditor","icon","instructions","openInNewWindow","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft"],"mappings":";;;;;;;;;AAyBA;;AAtBA;;AAKA;;AACA;;AAMA;;AACA;;AAUA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AApCA;AACA;AACA;;AAGA;AACA;AACA;;AAyBA;AACA;AACA;AAIO,MAAMA,kBAAkB,GAAG,GAA3B;;AACA,MAAMC,kBAAkB,GAAG,IAA3B;;;AAEP,SAASC,sBAAT,OAAsD;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAAmB,uBAAaC,cAAb,CAAzB;AACA,QAAMC,GAAG,GAAG,iCAAoBJ,IAApB,EAA0B,MAAM;AAC3CE,IAAAA,YAAY,CAAE,MAAF,EAAU,cAAI,0BAAJ,CAAV,EAA4C;AACvDG,MAAAA,aAAa,EAAE,IADwC;AAEvDC,MAAAA,IAAI,EAAE;AAFiD,KAA5C,CAAZ;AAIA,GALW,CAAZ;AAOA,SACC,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,GAAG,EAAGF,GAFP;AA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,EAAKhB,IAAF,IACVU,aAAa,CAAE;AAAEM,MAAAA,QAAQ,EAAEhB;AAAZ,KAAF,CANf;AAQC,IAAA,IAAI,EAAGkB;AARR,IADD,EAWGE,kBAAkB,IACnB;AACC,IAAA,SAAS,EACR;AAFF,KAMC,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,KADT,CACe;AADf;AAEC,kBAAa,cAAI,sBAAJ,CAFd;AAGC,IAAA,SAAS,EAAG,uBAHb;AAIC,IAAA,KAAK,EAAGC,kBAJT;AAKC,IAAA,4BAA4B,MAL7B;AAMC,IAAA,WAAW,EAAG,cAAI,WAAJ,CANf;AAOC,IAAA,QAAQ,EAAKrB,IAAF,IACVyC,wBAAwB,CAAEzC,IAAF;AAR1B,IAND,CAZF,CAnCD,CA5BD,CADD;AAmGA;;eAEc,6BAAaO,QAAb,C","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\twithNotices,\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} 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( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tnoticeUI,\n\tnoticeOperations,\n\tclientId,\n} ) {\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 {\n\t\ttoggleSelection,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Upload a file drag-and-dropped into the editor.\n\t\tif ( isBlobURL( href ) ) {\n\t\t\tconst file = getBlobByURL( href );\n\n\t\t\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\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\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\tnotices={ noticeUI }\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={ 'wp-block-file__button' }\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\tchangeDownloadButtonText( text )\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 withNotices( FileEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/file/edit.js"],"names":["MIN_PREVIEW_HEIGHT","MAX_PREVIEW_HEIGHT","ClipboardToolbarButton","text","disabled","createNotice","noticesStore","ref","isDismissible","type","FileEdit","attributes","isSelected","setAttributes","noticeUI","noticeOperations","clientId","id","fileId","fileName","href","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","media","mediaUpload","select","undefined","coreStore","getMedia","blockEditorStore","getSettings","toggleSelection","__unstableMarkNextChangeAsNotPersistent","file","filesList","onFileChange","newMedia","onSelectFile","onError","onUploadError","changeDownloadButtonText","url","isPdf","endsWith","title","message","removeAllNotices","createErrorNotice","changeLinkDestinationOption","newHref","changeOpenInNewWindow","newValue","changeShowDownloadButton","replace","changeDisplayPreview","handleOnResizeStop","event","direction","elt","delta","newHeight","parseInt","height","changePreviewHeight","Math","max","attachmentPage","link","blockProps","className","displayPreviewInEditor","icon","instructions","openInNewWindow","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","__experimentalElementButtonClassName"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAKA;;AACA;;AAMA;;AACA;;AAWA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AArCA;AACA;AACA;;AAGA;AACA;AACA;;AA0BA;AACA;AACA;AAIO,MAAMA,kBAAkB,GAAG,GAA3B;;AACA,MAAMC,kBAAkB,GAAG,IAA3B;;;AAEP,SAASC,sBAAT,OAAsD;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAAmB,uBAAaC,cAAb,CAAzB;AACA,QAAMC,GAAG,GAAG,iCAAoBJ,IAApB,EAA0B,MAAM;AAC3CE,IAAAA,YAAY,CAAE,MAAF,EAAU,cAAI,0BAAJ,CAAV,EAA4C;AACvDG,MAAAA,aAAa,EAAE,IADwC;AAEvDC,MAAAA,IAAI,EAAE;AAFiD,KAA5C,CAAZ;AAIA,GALW,CAAZ;AAOA,SACC,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,GAAG,EAAGF,GAFP;AAGC,IAAA,QAAQ,EAAGH;AAHZ,KAKG,cAAI,UAAJ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,QAAQ,EAAEhB;AAAZ,KAAF,CANf;AAQC,IAAA,IAAI,EAAGkB;AARR,IADD,EAWGE,kBAAkB,IACnB;AACC,IAAA,SAAS,EACR;AAFF,KAMC,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,KADT,CACe;AADf;AAEC,kBAAa,cAAI,sBAAJ,CAFd;AAGC,IAAA,SAAS,EAAG,yBACX,uBADW,EAEX+D,iDAFW,CAHb;AAOC,IAAA,KAAK,EAAG9D,kBAPT;AAQC,IAAA,4BAA4B,MAR7B;AASC,IAAA,WAAW,EAAG,cAAI,WAAJ,CATf;AAUC,IAAA,QAAQ,EAAKrB,IAAF,IACVyC,wBAAwB,CAAEzC,IAAF;AAX1B,IAND,CAZF,CAnCD,CA5BD,CADD;AAsGA;;eAEc,6BAAaO,QAAb,C","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\twithNotices,\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__experimentalElementButtonClassName,\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( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tnoticeUI,\n\tnoticeOperations,\n\tclientId,\n} ) {\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 {\n\t\ttoggleSelection,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Upload a file drag-and-dropped into the editor.\n\t\tif ( isBlobURL( href ) ) {\n\t\t\tconst file = getBlobByURL( href );\n\n\t\t\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\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\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\tnotices={ noticeUI }\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__experimentalElementButtonClassName\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\tchangeDownloadButtonText( text )\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 withNotices( FileEdit );\n"]}
|
package/build/file/save.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -7,10 +9,16 @@ exports.default = save;
|
|
|
7
9
|
|
|
8
10
|
var _element = require("@wordpress/element");
|
|
9
11
|
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
10
14
|
var _blockEditor = require("@wordpress/block-editor");
|
|
11
15
|
|
|
12
16
|
var _i18n = require("@wordpress/i18n");
|
|
13
17
|
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
14
22
|
/**
|
|
15
23
|
* WordPress dependencies
|
|
16
24
|
*/
|
|
@@ -54,7 +62,7 @@ function save(_ref) {
|
|
|
54
62
|
value: fileName
|
|
55
63
|
})), showDownloadButton && (0, _element.createElement)("a", {
|
|
56
64
|
href: href,
|
|
57
|
-
className:
|
|
65
|
+
className: (0, _classnames.default)('wp-block-file__button', _blockEditor.__experimentalElementButtonClassName),
|
|
58
66
|
download: true,
|
|
59
67
|
"aria-describedby": describedById
|
|
60
68
|
}, (0, _element.createElement)(_blockEditor.RichText.Content, {
|
package/build/file/save.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/file/save.js"],"names":["save","attributes","href","fileId","fileName","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","pdfEmbedLabel","RichText","isEmpty","hasFilename","describedById","undefined","useBlockProps","width","height"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/file/save.js"],"names":["save","attributes","href","fileId","fileName","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","pdfEmbedLabel","RichText","isEmpty","hasFilename","describedById","undefined","useBlockProps","width","height","__experimentalElementButtonClassName"],"mappings":";;;;;;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A,SAAS,EAAG,yBACX,uBADW,EAEXkB,iDAFW,CAFb;AAMC,IAAA,QAAQ,EAAG,IANZ;AAOC,wBAAmBL;AAPpB,KASC,4BAAC,qBAAD,CAAU,OAAV;AAAkB,IAAA,KAAK,EAAGP;AAA1B,IATD,CA5BF,CAFF;AA6CA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\t__experimentalElementButtonClassName,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\n\nexport default function save( { attributes } ) {\n\tconst {\n\t\thref,\n\t\tfileId,\n\t\tfileName,\n\t\ttextLinkHref,\n\t\ttextLinkTarget,\n\t\tshowDownloadButton,\n\t\tdownloadButtonText,\n\t\tdisplayPreview,\n\t\tpreviewHeight,\n\t} = attributes;\n\n\tconst pdfEmbedLabel = RichText.isEmpty( fileName )\n\t\t? __( 'PDF embed' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: filename. */\n\t\t\t\t__( 'Embed of %s.' ),\n\t\t\t\tfileName\n\t\t );\n\n\tconst hasFilename = ! RichText.isEmpty( fileName );\n\n\t// Only output an `aria-describedby` when the element it's referring to is\n\t// actually rendered.\n\tconst describedById = hasFilename ? fileId : undefined;\n\n\treturn (\n\t\thref && (\n\t\t\t<div { ...useBlockProps.save() }>\n\t\t\t\t{ displayPreview && (\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__embed\"\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\tstyle={ {\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\theight: `${ previewHeight }px`,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-label={ pdfEmbedLabel }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ hasFilename && (\n\t\t\t\t\t<a\n\t\t\t\t\t\tid={ describedById }\n\t\t\t\t\t\thref={ textLinkHref }\n\t\t\t\t\t\ttarget={ textLinkTarget }\n\t\t\t\t\t\trel={\n\t\t\t\t\t\t\ttextLinkTarget ? 'noreferrer noopener' : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<RichText.Content value={ fileName } />\n\t\t\t\t\t</a>\n\t\t\t\t) }\n\t\t\t\t{ showDownloadButton && (\n\t\t\t\t\t<a\n\t\t\t\t\t\thref={ href }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'wp-block-file__button',\n\t\t\t\t\t\t\t__experimentalElementButtonClassName\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdownload={ true }\n\t\t\t\t\t\taria-describedby={ describedById }\n\t\t\t\t\t>\n\t\t\t\t\t\t<RichText.Content value={ downloadButtonText } />\n\t\t\t\t\t</a>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t)\n\t);\n}\n"]}
|
|
@@ -20,10 +20,20 @@ function GapStyles(_ref) {
|
|
|
20
20
|
const styleElement = (0, _element.useContext)(_blockEditor.BlockList.__unstableElementContext); // --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
|
|
21
21
|
// gap on the gallery.
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const fallbackValue = `var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )`;
|
|
24
|
+
let gapValue = fallbackValue;
|
|
25
|
+
let column = fallbackValue;
|
|
26
|
+
let row; // Check for the possibility of split block gap values. See: https://github.com/WordPress/gutenberg/pull/37736
|
|
27
|
+
|
|
28
|
+
if (!!blockGap) {
|
|
29
|
+
row = typeof blockGap === 'string' ? blockGap : (blockGap === null || blockGap === void 0 ? void 0 : blockGap.top) || fallbackValue;
|
|
30
|
+
column = typeof blockGap === 'string' ? blockGap : (blockGap === null || blockGap === void 0 ? void 0 : blockGap.left) || fallbackValue;
|
|
31
|
+
gapValue = row === column ? row : `${row} ${column}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const gap = `#block-${clientId} {
|
|
35
|
+
--wp--style--unstable-gallery-gap: ${column};
|
|
36
|
+
gap: ${gapValue}
|
|
27
37
|
}`;
|
|
28
38
|
|
|
29
39
|
const GapStyle = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/gap-styles.js"],"names":["GapStyles","blockGap","clientId","styleElement","BlockList","__unstableElementContext","gapValue","gap","GapStyle"],"mappings":";;;;;;;AAIA;;AADA;;AAHA;AACA;AACA;AAIe,SAASA,SAAT,OAA6C;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAyB;AAC3D,QAAMC,YAAY,GAAG,yBAAYC,uBAAUC,wBAAtB,CAArB,CAD2D,CAE3D;AACA;;AACA,QAAMC,QAAQ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/gallery/gap-styles.js"],"names":["GapStyles","blockGap","clientId","styleElement","BlockList","__unstableElementContext","fallbackValue","gapValue","column","row","top","left","gap","GapStyle"],"mappings":";;;;;;;AAIA;;AADA;;AAHA;AACA;AACA;AAIe,SAASA,SAAT,OAA6C;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAyB;AAC3D,QAAMC,YAAY,GAAG,yBAAYC,uBAAUC,wBAAtB,CAArB,CAD2D,CAE3D;AACA;;AACA,QAAMC,aAAa,GAAI,oHAAvB;AACA,MAAIC,QAAQ,GAAGD,aAAf;AACA,MAAIE,MAAM,GAAGF,aAAb;AACA,MAAIG,GAAJ,CAP2D,CAS3D;;AACA,MAAK,CAAC,CAAER,QAAR,EAAmB;AAClBQ,IAAAA,GAAG,GACF,OAAOR,QAAP,KAAoB,QAApB,GACGA,QADH,GAEG,CAAAA,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAES,GAAV,KAAiBJ,aAHrB;AAIAE,IAAAA,MAAM,GACL,OAAOP,QAAP,KAAoB,QAApB,GACGA,QADH,GAEG,CAAAA,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEU,IAAV,KAAkBL,aAHtB;AAIAC,IAAAA,QAAQ,GAAGE,GAAG,KAAKD,MAAR,GAAiBC,GAAjB,GAAwB,GAAGA,GAAK,IAAID,MAAQ,EAAvD;AACA;;AAED,QAAMI,GAAG,GAAI,UAAUV,QAAU;AAClC,uCAAwCM,MAAQ;AAChD,SAAUD,QAAU;AACpB,GAHC;;AAKA,QAAMM,QAAQ,GAAG,MAAM;AACtB,WAAO,2CAASD,GAAT,CAAP;AACA,GAFD;;AAIA,SAAOA,GAAG,IAAIT,YAAP,GACJ,2BAAc,4BAAC,QAAD,OAAd,EAA4BA,YAA5B,CADI,GAEJ,IAFH;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockList } from '@wordpress/block-editor';\nimport { useContext, createPortal } from '@wordpress/element';\n\nexport default function GapStyles( { blockGap, clientId } ) {\n\tconst styleElement = useContext( BlockList.__unstableElementContext );\n\t// --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default\n\t// gap on the gallery.\n\tconst fallbackValue = `var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )`;\n\tlet gapValue = fallbackValue;\n\tlet column = fallbackValue;\n\tlet row;\n\n\t// Check for the possibility of split block gap values. See: https://github.com/WordPress/gutenberg/pull/37736\n\tif ( !! blockGap ) {\n\t\trow =\n\t\t\ttypeof blockGap === 'string'\n\t\t\t\t? blockGap\n\t\t\t\t: blockGap?.top || fallbackValue;\n\t\tcolumn =\n\t\t\ttypeof blockGap === 'string'\n\t\t\t\t? blockGap\n\t\t\t\t: blockGap?.left || fallbackValue;\n\t\tgapValue = row === column ? row : `${ row } ${ column }`;\n\t}\n\n\tconst gap = `#block-${ clientId } {\n\t\t--wp--style--unstable-gallery-gap: ${ column };\n\t\tgap: ${ gapValue }\n\t}`;\n\n\tconst GapStyle = () => {\n\t\treturn <style>{ gap }</style>;\n\t};\n\n\treturn gap && styleElement\n\t\t? createPortal( <GapStyle />, styleElement )\n\t\t: null;\n}\n"]}
|
package/build/gallery/index.js
CHANGED
|
@@ -136,7 +136,7 @@ const metadata = {
|
|
|
136
136
|
html: false,
|
|
137
137
|
units: ["px", "em", "rem", "vh", "vw"],
|
|
138
138
|
spacing: {
|
|
139
|
-
blockGap:
|
|
139
|
+
blockGap: ["horizontal", "vertical"],
|
|
140
140
|
__experimentalSkipSerialization: ["blockGap"],
|
|
141
141
|
__experimentalDefaultControls: {
|
|
142
142
|
blockGap: true
|
package/build/image/edit.js
CHANGED
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.ImageEdit = ImageEdit;
|
|
9
|
-
exports.isExternalImage = exports.default = void 0;
|
|
10
|
-
exports.isMediaDestroyed = isMediaDestroyed;
|
|
11
|
-
exports.pickRelevantMediaFiles = void 0;
|
|
9
|
+
exports.pickRelevantMediaFiles = exports.isExternalImage = exports.default = void 0;
|
|
12
10
|
|
|
13
11
|
var _element = require("@wordpress/element");
|
|
14
12
|
|
|
@@ -94,23 +92,6 @@ exports.isExternalImage = isExternalImage;
|
|
|
94
92
|
function hasDefaultSize(image, defaultSize) {
|
|
95
93
|
return (0, _lodash.has)(image, ['sizes', defaultSize, 'url']) || (0, _lodash.has)(image, ['media_details', 'sizes', defaultSize, 'source_url']);
|
|
96
94
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Checks if a media attachment object has been "destroyed",
|
|
99
|
-
* that is, removed from the media library. The core Media Library
|
|
100
|
-
* adds a `destroyed` property to a deleted attachment object in the media collection.
|
|
101
|
-
*
|
|
102
|
-
* @param {number} id The attachment id.
|
|
103
|
-
*
|
|
104
|
-
* @return {boolean} Whether the image has been destroyed.
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
function isMediaDestroyed(id) {
|
|
109
|
-
var _window, _window$wp, _window$wp$media;
|
|
110
|
-
|
|
111
|
-
const attachment = ((_window = window) === null || _window === void 0 ? void 0 : (_window$wp = _window.wp) === null || _window$wp === void 0 ? void 0 : (_window$wp$media = _window$wp.media) === null || _window$wp$media === void 0 ? void 0 : _window$wp$media.attachment(id)) || {};
|
|
112
|
-
return attachment.destroyed;
|
|
113
|
-
}
|
|
114
95
|
|
|
115
96
|
function ImageEdit(_ref) {
|
|
116
97
|
let {
|
|
@@ -153,39 +134,7 @@ function ImageEdit(_ref) {
|
|
|
153
134
|
getSettings
|
|
154
135
|
} = select(_blockEditor.store);
|
|
155
136
|
return (0, _lodash.pick)(getSettings(), ['imageDefaultSize', 'mediaUpload']);
|
|
156
|
-
}, []);
|
|
157
|
-
// fired when the media modal closes.
|
|
158
|
-
|
|
159
|
-
function onCloseModal() {
|
|
160
|
-
if (isMediaDestroyed(attributes === null || attributes === void 0 ? void 0 : attributes.id)) {
|
|
161
|
-
setAttributes({
|
|
162
|
-
url: undefined,
|
|
163
|
-
id: undefined
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/*
|
|
168
|
-
Runs an error callback if the image does not load.
|
|
169
|
-
If the error callback is triggered, we infer that that image
|
|
170
|
-
has been deleted.
|
|
171
|
-
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
function onImageError() {
|
|
175
|
-
let isReplaced = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
176
|
-
noticeOperations.removeAllNotices();
|
|
177
|
-
noticeOperations.createErrorNotice((0, _i18n.sprintf)(
|
|
178
|
-
/* translators: %s url or missing image */
|
|
179
|
-
(0, _i18n.__)('Error loading image: %s'), url)); // If the image block was not replaced with an embed,
|
|
180
|
-
// clear the attributes and trigger the placeholder.
|
|
181
|
-
|
|
182
|
-
if (!isReplaced) {
|
|
183
|
-
setAttributes({
|
|
184
|
-
url: undefined,
|
|
185
|
-
id: undefined
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
137
|
+
}, []);
|
|
189
138
|
|
|
190
139
|
function onUploadError(message) {
|
|
191
140
|
noticeOperations.removeAllNotices();
|
|
@@ -199,7 +148,7 @@ function ImageEdit(_ref) {
|
|
|
199
148
|
}
|
|
200
149
|
|
|
201
150
|
function onSelectImage(media) {
|
|
202
|
-
var
|
|
151
|
+
var _window, _window$wp, _window$wp$media, _window$wp$media$view, _window$wp$media$view2, _window$wp$media$view3;
|
|
203
152
|
|
|
204
153
|
if (!media || !media.url) {
|
|
205
154
|
setAttributes({
|
|
@@ -250,7 +199,7 @@ function ImageEdit(_ref) {
|
|
|
250
199
|
// Use the WordPress option to determine the proper default.
|
|
251
200
|
// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.
|
|
252
201
|
// TODO: fix this in a follow up PR, requires updating media-text and ui component.
|
|
253
|
-
switch (((
|
|
202
|
+
switch (((_window = window) === null || _window === void 0 ? void 0 : (_window$wp = _window.wp) === null || _window$wp === void 0 ? void 0 : (_window$wp$media = _window$wp.media) === null || _window$wp$media === void 0 ? void 0 : (_window$wp$media$view = _window$wp$media.view) === null || _window$wp$media$view === void 0 ? void 0 : (_window$wp$media$view2 = _window$wp$media$view.settings) === null || _window$wp$media$view2 === void 0 ? void 0 : (_window$wp$media$view3 = _window$wp$media$view2.defaultProps) === null || _window$wp$media$view3 === void 0 ? void 0 : _window$wp$media$view3.link) || _constants.LINK_DESTINATION_NONE) {
|
|
254
203
|
case 'file':
|
|
255
204
|
case _constants.LINK_DESTINATION_MEDIA:
|
|
256
205
|
linkDestination = _constants.LINK_DESTINATION_MEDIA;
|
|
@@ -376,9 +325,7 @@ function ImageEdit(_ref) {
|
|
|
376
325
|
onUploadError: onUploadError,
|
|
377
326
|
containerRef: ref,
|
|
378
327
|
context: context,
|
|
379
|
-
clientId: clientId
|
|
380
|
-
onCloseModal: onCloseModal,
|
|
381
|
-
onImageLoadError: onImageError
|
|
328
|
+
clientId: clientId
|
|
382
329
|
}), !url && (0, _element.createElement)(_blockEditor.BlockControls, {
|
|
383
330
|
group: "block"
|
|
384
331
|
}, (0, _element.createElement)(_blockEditor.BlockAlignmentControl, {
|
|
@@ -392,7 +339,6 @@ function ImageEdit(_ref) {
|
|
|
392
339
|
onSelectURL: onSelectURL,
|
|
393
340
|
notices: noticeUI,
|
|
394
341
|
onError: onUploadError,
|
|
395
|
-
onClose: onCloseModal,
|
|
396
342
|
accept: "image/*",
|
|
397
343
|
allowedTypes: _constants.ALLOWED_MEDIA_TYPES,
|
|
398
344
|
value: {
|
package/build/image/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/image/edit.js"],"names":["pickRelevantMediaFiles","image","size","imageProps","url","isTemporaryImage","id","isExternalImage","hasDefaultSize","defaultSize","isMediaDestroyed","attachment","window","wp","media","destroyed","ImageEdit","attributes","setAttributes","isSelected","className","noticeUI","insertBlocksAfter","noticeOperations","onReplace","context","clientId","alt","caption","align","width","height","sizeSlug","temporaryURL","setTemporaryURL","altRef","current","captionRef","ref","imageDefaultSize","mediaUpload","select","getSettings","blockEditorStore","onCloseModal","undefined","onImageError","isReplaced","removeAllNotices","createErrorNotice","onUploadError","message","src","onSelectImage","title","mediaAttributes","additionalAttributes","linkDestination","view","settings","defaultProps","link","LINK_DESTINATION_NONE","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","href","onSelectURL","newURL","updateAlignment","nextAlign","extraUpdatedAttributes","includes","isTemp","file","filesList","onFileChange","img","allowedTypes","ALLOWED_MEDIA_TYPES","onError","isExternal","mediaPreview","classes","blockProps","icon"],"mappings":";;;;;;;;;;;;AAoBA;;AAjBA;;A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ARhB;AASC,IAAA,KAAK,EAAG;AAAEzE,MAAAA,EAAF;AAAM8C,MAAAA;AAAN,KATT;AAUC,IAAA,YAAY,EAAG8B,YAVhB;AAWC,IAAA,mBAAmB,EAAGjD,YAAY,IAAI7B;AAXvC,IA3BD,CADD;AA2CA;;eAEc,6BAAaY,SAAb,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { get, has, omit, pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport { withNotices } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockAlignmentControl,\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { image as icon } from '@wordpress/icons';\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 = pick( image, [ 'alt', 'id', 'link', 'caption' ] );\n\timageProps.url =\n\t\tget( image, [ 'sizes', size, 'url' ] ) ||\n\t\tget( image, [ '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 default image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} defaultSize\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasDefaultSize( image, defaultSize ) {\n\treturn (\n\t\thas( image, [ 'sizes', defaultSize, 'url' ] ) ||\n\t\thas( image, [ 'media_details', 'sizes', defaultSize, 'source_url' ] )\n\t);\n}\n\n/**\n * Checks if a media attachment object has been \"destroyed\",\n * that is, removed from the media library. The core Media Library\n * adds a `destroyed` property to a deleted attachment object in the media collection.\n *\n * @param {number} id The attachment id.\n *\n * @return {boolean} Whether the image has been destroyed.\n */\nexport function isMediaDestroyed( id ) {\n\tconst attachment = window?.wp?.media?.attachment( id ) || {};\n\treturn attachment.destroyed;\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tclassName,\n\tnoticeUI,\n\tinsertBlocksAfter,\n\tnoticeOperations,\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} = 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\treturn pick( getSettings(), [ 'imageDefaultSize', 'mediaUpload' ] );\n\t}, [] );\n\n\t// A callback passed to MediaUpload,\n\t// fired when the media modal closes.\n\tfunction onCloseModal() {\n\t\tif ( isMediaDestroyed( attributes?.id ) ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\tid: undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\t/*\n\t\t Runs an error callback if the image does not load.\n\t\t If the error callback is triggered, we infer that that image\n\t\t has been deleted.\n\t*/\n\tfunction onImageError( isReplaced = false ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s url or missing image */\n\t\t\t\t__( 'Error loading image: %s' ),\n\t\t\t\turl\n\t\t\t)\n\t\t);\n\t\t// If the image block was not replaced with an embed,\n\t\t// clear the attributes and trigger the placeholder.\n\t\tif ( ! isReplaced ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\tid: undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\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\tlet mediaAttributes = pickRelevantMediaFiles( media, imageDefaultSize );\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 && ! get( mediaAttributes, [ 'caption' ] ) ) {\n\t\t\tmediaAttributes = omit( mediaAttributes, [ 'caption' ] );\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\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\t// Fallback to size \"full\" if there's no default image size.\n\t\t\t\t// It means the image is smaller, and the block will use a full-size URL.\n\t\t\t\tsizeSlug: hasDefaultSize( media, imageDefaultSize )\n\t\t\t\t\t? imageDefaultSize\n\t\t\t\t\t: 'full',\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Image Size\"\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\twidth: undefined,\n\t\t\t\theight: 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 classes = classnames( className, {\n\t\t'is-transient': temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref,\n\t\tclassName: classes,\n\t} );\n\n\treturn (\n\t\t<figure { ...blockProps }>\n\t\t\t{ ( temporaryURL || url ) && (\n\t\t\t\t<Image\n\t\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\t\tcontainerRef={ ref }\n\t\t\t\t\tcontext={ context }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tonCloseModal={ onCloseModal }\n\t\t\t\t\tonImageLoadError={ onImageError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! url && (\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\tnotices={ noticeUI }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tonClose={ onCloseModal }\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 withNotices( ImageEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/image/edit.js"],"names":["pickRelevantMediaFiles","image","size","imageProps","url","isTemporaryImage","id","isExternalImage","hasDefaultSize","defaultSize","ImageEdit","attributes","setAttributes","isSelected","className","noticeUI","insertBlocksAfter","noticeOperations","onReplace","context","clientId","alt","caption","align","width","height","sizeSlug","temporaryURL","setTemporaryURL","altRef","current","captionRef","ref","imageDefaultSize","mediaUpload","select","getSettings","blockEditorStore","onUploadError","message","removeAllNotices","createErrorNotice","src","undefined","onSelectImage","media","title","mediaAttributes","additionalAttributes","linkDestination","window","wp","view","settings","defaultProps","link","LINK_DESTINATION_NONE","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","href","onSelectURL","newURL","updateAlignment","nextAlign","extraUpdatedAttributes","includes","isTemp","file","filesList","onFileChange","img","allowedTypes","ALLOWED_MEDIA_TYPES","onError","isExternal","mediaPreview","classes","blockProps","icon"],"mappings":";;;;;;;;;;AAoBA;;AAjBA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AASA;;AACA;;AAKA;;AAKA;;AAhCA;AACA;AACA;;AAIA;AACA;AACA;;AAgBA;AACA;AACA;;AAGA;AACA;AACA;AASO,MAAMA,sBAAsB,GAAG,CAAEC,KAAF,EAASC,IAAT,KAAmB;AACxD,QAAMC,UAAU,GAAG,kBAAMF,KAAN,EAAa,CAAE,KAAF,EAAS,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APhB;AAQC,IAAA,KAAK,EAAG;AAAEnE,MAAAA,EAAF;AAAMoC,MAAAA;AAAN,KART;AASC,IAAA,YAAY,EAAGkC,YAThB;AAUC,IAAA,mBAAmB,EAAGjD,YAAY,IAAIvB;AAVvC,IAzBD,CADD;AAwCA;;eAEc,6BAAaM,SAAb,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { get, has, omit, pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport { withNotices } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockAlignmentControl,\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { image as icon } from '@wordpress/icons';\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 = pick( image, [ 'alt', 'id', 'link', 'caption' ] );\n\timageProps.url =\n\t\tget( image, [ 'sizes', size, 'url' ] ) ||\n\t\tget( image, [ '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 default image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} defaultSize\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasDefaultSize( image, defaultSize ) {\n\treturn (\n\t\thas( image, [ 'sizes', defaultSize, 'url' ] ) ||\n\t\thas( image, [ 'media_details', 'sizes', defaultSize, 'source_url' ] )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tclassName,\n\tnoticeUI,\n\tinsertBlocksAfter,\n\tnoticeOperations,\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} = 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\treturn pick( getSettings(), [ 'imageDefaultSize', 'mediaUpload' ] );\n\t}, [] );\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\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\tlet mediaAttributes = pickRelevantMediaFiles( media, imageDefaultSize );\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 && ! get( mediaAttributes, [ 'caption' ] ) ) {\n\t\t\tmediaAttributes = omit( mediaAttributes, [ 'caption' ] );\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\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\t// Fallback to size \"full\" if there's no default image size.\n\t\t\t\t// It means the image is smaller, and the block will use a full-size URL.\n\t\t\t\tsizeSlug: hasDefaultSize( media, imageDefaultSize )\n\t\t\t\t\t? imageDefaultSize\n\t\t\t\t\t: 'full',\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Image Size\"\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\twidth: undefined,\n\t\t\t\theight: 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 classes = classnames( className, {\n\t\t'is-transient': temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref,\n\t\tclassName: classes,\n\t} );\n\n\treturn (\n\t\t<figure { ...blockProps }>\n\t\t\t{ ( temporaryURL || url ) && (\n\t\t\t\t<Image\n\t\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\t\tcontainerRef={ ref }\n\t\t\t\t\tcontext={ context }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! url && (\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\tnotices={ noticeUI }\n\t\t\t\tonError={ onUploadError }\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 withNotices( ImageEdit );\n"]}
|
|
@@ -37,6 +37,8 @@ var _coreData = require("@wordpress/core-data");
|
|
|
37
37
|
|
|
38
38
|
var _editPost = require("@wordpress/edit-post");
|
|
39
39
|
|
|
40
|
+
var _notices = require("@wordpress/notices");
|
|
41
|
+
|
|
40
42
|
var _styles = _interopRequireDefault(require("./styles.scss"));
|
|
41
43
|
|
|
42
44
|
var _utils = require("./utils");
|
|
@@ -196,6 +198,7 @@ class ImageEdit extends _element.Component {
|
|
|
196
198
|
this.onImagePressed = this.onImagePressed.bind(this);
|
|
197
199
|
this.onSetFeatured = this.onSetFeatured.bind(this);
|
|
198
200
|
this.onFocusCaption = this.onFocusCaption.bind(this);
|
|
201
|
+
this.onSelectURL = this.onSelectURL.bind(this);
|
|
199
202
|
this.updateAlignment = this.updateAlignment.bind(this);
|
|
200
203
|
this.accessibilityLabelCreator = this.accessibilityLabelCreator.bind(this);
|
|
201
204
|
this.setMappedAttributes = this.setMappedAttributes.bind(this);
|
|
@@ -458,6 +461,40 @@ class ImageEdit extends _element.Component {
|
|
|
458
461
|
});
|
|
459
462
|
}
|
|
460
463
|
|
|
464
|
+
onSelectURL(newURL) {
|
|
465
|
+
const {
|
|
466
|
+
createErrorNotice,
|
|
467
|
+
imageDefaultSize,
|
|
468
|
+
setAttributes
|
|
469
|
+
} = this.props;
|
|
470
|
+
|
|
471
|
+
if ((0, _url.isURL)(newURL)) {
|
|
472
|
+
this.setState({
|
|
473
|
+
isFetchingImage: true
|
|
474
|
+
}); // Use RN's Image.getSize to determine if URL is a valid image
|
|
475
|
+
|
|
476
|
+
_reactNative.Image.getSize(newURL, () => {
|
|
477
|
+
setAttributes({
|
|
478
|
+
url: newURL,
|
|
479
|
+
id: undefined,
|
|
480
|
+
width: undefined,
|
|
481
|
+
height: undefined,
|
|
482
|
+
sizeSlug: imageDefaultSize
|
|
483
|
+
});
|
|
484
|
+
this.setState({
|
|
485
|
+
isFetchingImage: false
|
|
486
|
+
});
|
|
487
|
+
}, () => {
|
|
488
|
+
createErrorNotice((0, _i18n.__)('Image file not found.'));
|
|
489
|
+
this.setState({
|
|
490
|
+
isFetchingImage: false
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
} else {
|
|
494
|
+
createErrorNotice((0, _i18n.__)('Invalid URL.'));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
461
498
|
onFocusCaption() {
|
|
462
499
|
if (this.props.onFocus) {
|
|
463
500
|
this.props.onFocus();
|
|
@@ -476,6 +513,14 @@ class ImageEdit extends _element.Component {
|
|
|
476
513
|
}, this.props.getStylesFromColorScheme(_styles.default.iconPlaceholder, _styles.default.iconPlaceholderDark)));
|
|
477
514
|
}
|
|
478
515
|
|
|
516
|
+
showLoadingIndicator() {
|
|
517
|
+
return (0, _element.createElement)(_reactNative.View, {
|
|
518
|
+
style: _styles.default.image__loading
|
|
519
|
+
}, (0, _element.createElement)(_reactNative.ActivityIndicator, {
|
|
520
|
+
animating: true
|
|
521
|
+
}));
|
|
522
|
+
}
|
|
523
|
+
|
|
479
524
|
getWidth() {
|
|
480
525
|
const {
|
|
481
526
|
attributes
|
|
@@ -595,7 +640,8 @@ class ImageEdit extends _element.Component {
|
|
|
595
640
|
|
|
596
641
|
render() {
|
|
597
642
|
const {
|
|
598
|
-
isCaptionSelected
|
|
643
|
+
isCaptionSelected,
|
|
644
|
+
isFetchingImage
|
|
599
645
|
} = this.state;
|
|
600
646
|
const {
|
|
601
647
|
attributes,
|
|
@@ -683,9 +729,10 @@ class ImageEdit extends _element.Component {
|
|
|
683
729
|
if (!url) {
|
|
684
730
|
return (0, _element.createElement)(_reactNative.View, {
|
|
685
731
|
style: _styles.default.content
|
|
686
|
-
}, (0, _element.createElement)(_blockEditor.MediaPlaceholder, {
|
|
732
|
+
}, isFetchingImage && this.showLoadingIndicator(), (0, _element.createElement)(_blockEditor.MediaPlaceholder, {
|
|
687
733
|
allowedTypes: [_blockEditor.MEDIA_TYPE_IMAGE],
|
|
688
734
|
onSelect: this.onSelectMediaUploadOption,
|
|
735
|
+
onSelectURL: this.onSelectURL,
|
|
689
736
|
icon: this.getPlaceholderIcon(),
|
|
690
737
|
onFocus: this.props.onFocus,
|
|
691
738
|
autoOpenMediaUpload: isSelected && wasBlockJustInserted
|
|
@@ -738,7 +785,7 @@ class ImageEdit extends _element.Component {
|
|
|
738
785
|
} = _ref6;
|
|
739
786
|
return (0, _element.createElement)(_reactNative.View, {
|
|
740
787
|
style: imageContainerStyles
|
|
741
|
-
}, (0, _element.createElement)(_components.Image, (0, _extends2.default)({
|
|
788
|
+
}, isFetchingImage && this.showLoadingIndicator(), (0, _element.createElement)(_components.Image, (0, _extends2.default)({
|
|
742
789
|
align: align && alignToFlex[align],
|
|
743
790
|
alt: alt,
|
|
744
791
|
isSelected: isSelected && !isCaptionSelected,
|
|
@@ -767,6 +814,7 @@ class ImageEdit extends _element.Component {
|
|
|
767
814
|
allowedTypes: [_blockEditor.MEDIA_TYPE_IMAGE],
|
|
768
815
|
isReplacingMedia: true,
|
|
769
816
|
onSelect: this.onSelectMediaUploadOption,
|
|
817
|
+
onSelectURL: this.onSelectURL,
|
|
770
818
|
render: _ref7 => {
|
|
771
819
|
let {
|
|
772
820
|
open,
|
|
@@ -817,7 +865,12 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, props) => {
|
|
|
817
865
|
wasBlockJustInserted: wasBlockJustInserted(clientId, 'inserter_menu')
|
|
818
866
|
};
|
|
819
867
|
}), (0, _data.withDispatch)(dispatch => {
|
|
868
|
+
const {
|
|
869
|
+
createErrorNotice
|
|
870
|
+
} = dispatch(_notices.store);
|
|
820
871
|
return {
|
|
872
|
+
createErrorNotice,
|
|
873
|
+
|
|
821
874
|
closeSettingsBottomSheet() {
|
|
822
875
|
dispatch(_editPost.store).closeGeneralSidebar();
|
|
823
876
|
}
|