@wordpress/block-editor 8.5.6 → 8.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-variation-transforms/index.js +5 -0
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +0 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +0 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +20 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/warning/index.js +6 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/hooks/dimensions.js +14 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +38 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/layouts/flex.js +5 -2
- package/build/layouts/flex.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +5 -0
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +0 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +0 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +20 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/warning/index.js +6 -1
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/hooks/dimensions.js +14 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +39 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/layouts/flex.js +4 -2
- package/build-module/layouts/flex.js.map +1 -1
- package/package.json +4 -4
- package/src/components/block-variation-transforms/index.js +3 -0
- package/src/components/media-placeholder/index.js +0 -2
- package/src/components/media-replace-flow/index.js +0 -2
- package/src/components/rich-text/use-paste-handler.js +17 -5
- package/src/components/warning/index.js +47 -42
- package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
- package/src/components/warning/test/index.js +1 -1
- package/src/hooks/dimensions.js +11 -3
- package/src/hooks/layout.js +54 -4
- package/src/layouts/flex.js +11 -3
|
@@ -119,6 +119,11 @@ function __experimentalBlockVariationTransforms(_ref4) {
|
|
|
119
119
|
|
|
120
120
|
const hasUniqueIcons = (0, _element.useMemo)(() => {
|
|
121
121
|
const variationIcons = new Set();
|
|
122
|
+
|
|
123
|
+
if (!variations) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
122
127
|
variations.forEach(variation => {
|
|
123
128
|
if (variation.icon) {
|
|
124
129
|
variationIcons.add(variation.icon);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-variation-transforms/index.js"],"names":["VariationsButtons","className","onSelectVariation","selectedValue","variations","map","variation","name","icon","title","VariationsDropdown","selectOptions","description","value","label","info","position","chevronDown","iconPosition","__experimentalBlockVariationTransforms","blockClientId","updateBlockAttributes","blockEditorStore","activeBlockVariation","select","getActiveBlockVariation","getBlockVariations","blocksStore","getBlockName","getBlockAttributes","hasUniqueIcons","variationIcons","Set","forEach","add","size","length","variationName","find","attributes","baseClass","Component"],"mappings":";;;;;;;AAaA;;AAVA;;AACA;;AACA;;AAOA;;AAEA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,SAASA,iBAAT,OAKI;AAAA,MALwB;AAC3BC,IAAAA,SAD2B;AAE3BC,IAAAA,iBAF2B;AAG3BC,IAAAA,aAH2B;AAI3BC,IAAAA;AAJ2B,GAKxB;AACH,SACC;AAAU,IAAA,SAAS,EAAGH;AAAtB,KACC,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACG,cAAI,wBAAJ,CADH,CADD,EAIGG,UAAU,CAACC,GAAX,CAAkBC,SAAF,IACjB,4BAAC,kBAAD;AACC,IAAA,GAAG,EAAGA,SAAS,CAACC,IADjB;AAEC,IAAA,IAAI,EAAGD,SAAS,CA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AA,OAAO,EAAGU,aADX;AAEC,IAAA,KAAK,EAAGR,aAFT;AAGC,IAAA,QAAQ,EAAGD;AAHZ,IADD,CADD,CAZF,CADD;AAyBA;;AAED,SAASiB,sCAAT,QAAqE;AAAA,MAApB;AAAEC,IAAAA;AAAF,GAAoB;AACpE,QAAM;AAAEC,IAAAA;AAAF,MAA4B,uBAAaC,YAAb,CAAlC;AACA,QAAM;AAAEC,IAAAA,oBAAF;AAAwBnB,IAAAA;AAAxB,MAAuC,qBAC1CoB,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,uBAAF;AAA2BC,MAAAA;AAA3B,QAAkDF,MAAM,CAC7DG,aAD6D,CAA9D;AAGA,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QAAuCL,MAAM,CAClDF,YADkD,CAAnD;AAGA,UAAMf,IAAI,GAAGa,aAAa,IAAIQ,YAAY,CAAER,aAAF,CAA1C;AACA,WAAO;AACNG,MAAAA,oBAAoB,EAAEE,uBAAuB,CAC5ClB,IAD4C,EAE5CsB,kBAAkB,CAAET,aAAF,CAF0B,CADvC;AAKNhB,MAAAA,UAAU,EAAEG,IAAI,IAAImB,kBAAkB,CAAEnB,IAAF,EAAQ,WAAR;AALhC,KAAP;AAOA,GAhB2C,EAiB5C,CAAEa,aAAF,CAjB4C,CAA7C;AAoBA,QAAMjB,aAAa,GAAGoB,oBAAH,aAAGA,oBAAH,uBAAGA,oBAAoB,CAAEhB,IAA5C,CAtBoE,CAwBpE;;AACA,QAAMuB,cAAc,GAAG,sBAAS,MAAM;AACrC,UAAMC,cAAc,GAAG,IAAIC,GAAJ,EAAvB;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-variation-transforms/index.js"],"names":["VariationsButtons","className","onSelectVariation","selectedValue","variations","map","variation","name","icon","title","VariationsDropdown","selectOptions","description","value","label","info","position","chevronDown","iconPosition","__experimentalBlockVariationTransforms","blockClientId","updateBlockAttributes","blockEditorStore","activeBlockVariation","select","getActiveBlockVariation","getBlockVariations","blocksStore","getBlockName","getBlockAttributes","hasUniqueIcons","variationIcons","Set","forEach","add","size","length","variationName","find","attributes","baseClass","Component"],"mappings":";;;;;;;AAaA;;AAVA;;AACA;;AACA;;AAOA;;AAEA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,SAASA,iBAAT,OAKI;AAAA,MALwB;AAC3BC,IAAAA,SAD2B;AAE3BC,IAAAA,iBAF2B;AAG3BC,IAAAA,aAH2B;AAI3BC,IAAAA;AAJ2B,GAKxB;AACH,SACC;AAAU,IAAA,SAAS,EAAGH;AAAtB,KACC,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACG,cAAI,wBAAJ,CADH,CADD,EAIGG,UAAU,CAACC,GAAX,CAAkBC,SAAF,IACjB,4BAAC,kBAAD;AACC,IAAA,GAAG,EAAGA,SAAS,CAACC,IADjB;AAEC,IAAA,IAAI,EAAGD,SAAS,CAACE,IAFlB;AAGC,IAAA,SAAS,EAAGL,aAAa,KAAKG,SAAS,CAACC,IAHzC;AAIC,IAAA,KAAK,EACJJ,aAAa,KAAKG,SAAS,CAACC,IAA5B,GACGD,SAAS,CAACG,KADb,GAEG;AACA;AACA,kBAAI,iBAAJ,CAFA,EAGAH,SAAS,CAACG,KAHV,CAPL;AAaC,IAAA,OAAO,EAAG,MAAMP,iBAAiB,CAAEI,SAAS,CAACC,IAAZ,CAblC;AAcC,kBAAaD,SAAS,CAACG,KAdxB;AAeC,IAAA,WAAW;AAfZ,IADC,CAJH,CADD;AA0BA;;AAED,SAASC,kBAAT,QAKI;AAAA,MALyB;AAC5BT,IAAAA,SAD4B;AAE5BC,IAAAA,iBAF4B;AAG5BC,IAAAA,aAH4B;AAI5BC,IAAAA;AAJ4B,GAKzB;AACH,QAAMO,aAAa,GAAGP,UAAU,CAACC,GAAX,CACrB;AAAA,QAAE;AAAEE,MAAAA,IAAF;AAAQE,MAAAA,KAAR;AAAeG,MAAAA;AA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AAS,EAAG8B,SADb;AAEC,IAAA,iBAAiB,EAAGtC,iBAFrB;AAGC,IAAA,aAAa,EAAGC,aAHjB;AAIC,IAAA,UAAU,EAAGC;AAJd,IADD;AAQA;;eAEce,sC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItemsChoice,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction VariationsButtons( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<fieldset className={ className }>\n\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t{ __( 'Transform to variation' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t<Button\n\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\ticon={ variation.icon }\n\t\t\t\t\tisPressed={ selectedValue === variation.name }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tselectedValue === variation.name\n\t\t\t\t\t\t\t? variation.title\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the block variation */\n\t\t\t\t\t\t\t\t\t__( 'Transform to %s' ),\n\t\t\t\t\t\t\t\t\tvariation.title\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => onSelectVariation( variation.name ) }\n\t\t\t\t\taria-label={ variation.title }\n\t\t\t\t\tshowTooltip\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</fieldset>\n\t);\n}\n\nfunction VariationsDropdown( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\tconst selectOptions = variations.map(\n\t\t( { name, title, description } ) => ( {\n\t\t\tvalue: name,\n\t\t\tlabel: title,\n\t\t\tinfo: description,\n\t\t} )\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName={ className }\n\t\t\tlabel={ __( 'Transform to variation' ) }\n\t\t\ttext={ __( 'Transform to variation' ) }\n\t\t\tpopoverProps={ {\n\t\t\t\tposition: 'bottom center',\n\t\t\t\tclassName: `${ className }__popover`,\n\t\t\t} }\n\t\t\ticon={ chevronDown }\n\t\t\ttoggleProps={ { iconPosition: 'right' } }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<div className={ `${ className }__container` }>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tchoices={ selectOptions }\n\t\t\t\t\t\t\tvalue={ selectedValue }\n\t\t\t\t\t\t\tonSelect={ onSelectVariation }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction __experimentalBlockVariationTransforms( { blockClientId } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { activeBlockVariation, variations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } = select(\n\t\t\t\tblocksStore\n\t\t\t);\n\t\t\tconst { getBlockName, getBlockAttributes } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst name = blockClientId && getBlockName( blockClientId );\n\t\t\treturn {\n\t\t\t\tactiveBlockVariation: getActiveBlockVariation(\n\t\t\t\t\tname,\n\t\t\t\t\tgetBlockAttributes( blockClientId )\n\t\t\t\t),\n\t\t\t\tvariations: name && getBlockVariations( name, 'transform' ),\n\t\t\t};\n\t\t},\n\t\t[ blockClientId ]\n\t);\n\n\tconst selectedValue = activeBlockVariation?.name;\n\n\t// Check if each variation has a unique icon.\n\tconst hasUniqueIcons = useMemo( () => {\n\t\tconst variationIcons = new Set();\n\t\tif ( ! variations ) {\n\t\t\treturn false;\n\t\t}\n\t\tvariations.forEach( ( variation ) => {\n\t\t\tif ( variation.icon ) {\n\t\t\t\tvariationIcons.add( variation.icon );\n\t\t\t}\n\t\t} );\n\t\treturn variationIcons.size === variations.length;\n\t}, [ variations ] );\n\n\tconst onSelectVariation = ( variationName ) => {\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\t...variations.find( ( { name } ) => name === variationName )\n\t\t\t\t.attributes,\n\t\t} );\n\t};\n\n\tconst baseClass = 'block-editor-block-variation-transforms';\n\n\t// Skip rendering if there are no variations\n\tif ( ! variations?.length ) return null;\n\n\tconst Component = hasUniqueIcons ? VariationsButtons : VariationsDropdown;\n\n\treturn (\n\t\t<Component\n\t\t\tclassName={ baseClass }\n\t\t\tonSelectVariation={ onSelectVariation }\n\t\t\tselectedValue={ selectedValue }\n\t\t\tvariations={ variations }\n\t\t/>\n\t);\n}\n\nexport default __experimentalBlockVariationTransforms;\n"]}
|
|
@@ -91,7 +91,6 @@ function MediaPlaceholder(_ref2) {
|
|
|
91
91
|
onDoubleClick,
|
|
92
92
|
onFilesPreUpload = _lodash.noop,
|
|
93
93
|
onHTMLDrop = _lodash.noop,
|
|
94
|
-
onClose = _lodash.noop,
|
|
95
94
|
children,
|
|
96
95
|
mediaLibraryButton,
|
|
97
96
|
placeholder,
|
|
@@ -331,7 +330,6 @@ function MediaPlaceholder(_ref2) {
|
|
|
331
330
|
gallery: multiple && onlyAllowsImages(),
|
|
332
331
|
multiple: multiple,
|
|
333
332
|
onSelect: onSelect,
|
|
334
|
-
onClose: onClose,
|
|
335
333
|
allowedTypes: allowedTypes,
|
|
336
334
|
value: Array.isArray(value) ? value.map(_ref7 => {
|
|
337
335
|
let {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"names":["InsertFromURLPopover","src","onChange","onSubmit","onClose","keyboardReturn","MediaPlaceholder","value","allowedTypes","className","icon","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onDoubleClick","onFilesPreUpload","noop","onHTMLDrop","children","mediaLibraryButton","placeholder","style","mediaUpload","select","getSettings","blockEditorStore","setSrc","isURLInputVisible","setIsURLInputVisible","onlyAllowsImages","length","every","allowedType","startsWith","onChangeSrc","event","target","openURLInput","closeURLInput","onSubmitSrc","preventDefault","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","onUpload","defaultRenderPlaceholder","content","instructions","title","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","renderPlaceholder","renderDropZone","renderCancelLink","renderUrlSelectionUI","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","Array","isArray","openFileDialog"],"mappings":";;;;;;;;;;AAiBA;;AAdA;;AACA;;AAKA;;AAOA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAIA;AACA;AACA;;AAaA;AACA;AACA;AAMA,MAAMA,oBAAoB,GAAG;AAAA,MAAE;AAAEC,IAAAA,GAAF;AAAOC,IAAAA,QAAP;AAAiBC,IAAAA,QAAjB;AAA2BC,IAAAA;AAA3B,GAAF;AAAA,SAC5B,4BAAC,mBAAD;AAAY,IAAA,OAAO,EAAGA;AAAtB,KACC;AACC,IAAA,SAAS,EAAC,gDADX;AAEC,IAAA,QAAQ,EAAGD;AAFZ,KAIC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,kBAAa,cAAI,KAAJ,CAHd;AAIC,IAAA,WAAW,EAAG,cAAI,mBAAJ,CAJf;AAKC,IAAA,QAAQ,EAAGD,QALZ;AAMC,IAAA,KAAK,EAAGD;AANT,IAJ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aAAOF,iBAAiB,CAAEX,OAAF,CAAxB;AACA;;AAED,WAAOW,iBAAiB,CAAEQ,wBAAF,CAAxB;AACA,GAzFD;;AA2FA,MAAK3E,mBAAL,EAA2B;AAC1B,WAAO,4BAAC,cAAD,QAAoBoE,cAAc,EAAlC,CAAP;AACA;;AAED,SACC,4BAAC,cAAD;AACC,IAAA,QAAQ,EAAGD,iBAAiB,CAAEG,oBAAoB,EAAtB;AAD7B,KAGGC,wBAAwB,EAH3B,CADD;AAOA;AAED;AACA;AACA;;;eACe,6BAAa,yBAAb,EAA0CrF,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFormFileUpload,\n\tPlaceholder,\n\tDropZone,\n\twithFilters,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { keyboardReturn } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport URLPopover from '../url-popover';\nimport { store as blockEditorStore } from '../../store';\n\nconst InsertFromURLPopover = ( { src, onChange, onSubmit, onClose } ) => (\n\t<URLPopover onClose={ onClose }>\n\t\t<form\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\taria-label={ __( 'URL' ) }\n\t\t\t\tplaceholder={ __( 'Paste or type URL' ) }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ src }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-submit-button\"\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t</URLPopover>\n);\n\nexport function MediaPlaceholder( {\n\tvalue = {},\n\tallowedTypes,\n\tclassName,\n\ticon,\n\tlabels = {},\n\tmediaPreview,\n\tnotices,\n\tisAppender,\n\taccept,\n\taddToGallery,\n\tmultiple = false,\n\thandleUpload = true,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop = noop,\n\tonClose = noop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\n} ) {\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\tconst [ src, setSrc ] = useState( '' );\n\tconst [ isURLInputVisible, setIsURLInputVisible ] = useState( false );\n\n\tuseEffect( () => {\n\t\tsetSrc( value?.src ?? '' );\n\t}, [ value?.src ] );\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst onChangeSrc = ( event ) => {\n\t\tsetSrc( event.target.value );\n\t};\n\n\tconst openURLInput = () => {\n\t\tsetIsURLInputVisible( true );\n\t};\n\tconst closeURLInput = () => {\n\t\tsetIsURLInputVisible( false );\n\t};\n\n\tconst onSubmitSrc = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( src && onSelectURL ) {\n\t\t\tonSelectURL( src );\n\t\t\tcloseURLInput();\n\t\t}\n\t};\n\n\tconst onFilesUpload = ( files ) => {\n\t\tif ( ! handleUpload ) {\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesPreUpload( files );\n\t\tlet setMedia;\n\t\tif ( multiple ) {\n\t\t\tif ( addToGallery ) {\n\t\t\t\t// Since the setMedia function runs multiple times per upload group\n\t\t\t\t// and is passed newMedia containing every item in its group each time, we must\n\t\t\t\t// filter out whatever this upload group had previously returned to the\n\t\t\t\t// gallery before adding and returning the image array with replacement newMedia\n\t\t\t\t// values.\n\n\t\t\t\t// Define an array to store urls from newMedia between subsequent function calls.\n\t\t\t\tlet lastMediaPassed = [];\n\t\t\t\tsetMedia = ( newMedia ) => {\n\t\t\t\t\t// Remove any images this upload group is responsible for (lastMediaPassed).\n\t\t\t\t\t// Their replacements are contained in newMedia.\n\t\t\t\t\tconst filteredMedia = ( value ?? [] ).filter( ( item ) => {\n\t\t\t\t\t\t// If Item has id, only remove it if lastMediaPassed has an item with that id.\n\t\t\t\t\t\tif ( item.id ) {\n\t\t\t\t\t\t\treturn ! lastMediaPassed.some(\n\t\t\t\t\t\t\t\t// Be sure to convert to number for comparison.\n\t\t\t\t\t\t\t\t( { id } ) => Number( id ) === Number( item.id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Compare transient images via .includes since gallery may append extra info onto the url.\n\t\t\t\t\t\treturn ! lastMediaPassed.some( ( { urlSlug } ) =>\n\t\t\t\t\t\t\titem.url.includes( urlSlug )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\t// Return the filtered media array along with newMedia.\n\t\t\t\t\tonSelect( filteredMedia.concat( newMedia ) );\n\t\t\t\t\t// Reset lastMediaPassed and set it with ids and urls from newMedia.\n\t\t\t\t\tlastMediaPassed = newMedia.map( ( media ) => {\n\t\t\t\t\t\t// Add everything up to '.fileType' to compare via .includes.\n\t\t\t\t\t\tconst cutOffIndex = media.url.lastIndexOf( '.' );\n\t\t\t\t\t\tconst urlSlug = media.url.slice( 0, cutOffIndex );\n\t\t\t\t\t\treturn { id: media.id, urlSlug };\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tsetMedia = onSelect;\n\t\t\t}\n\t\t} else {\n\t\t\tsetMedia = ( [ media ] ) => onSelect( media );\n\t\t}\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tconst onUpload = ( event ) => {\n\t\tonFilesUpload( event.target.files );\n\t};\n\n\tconst defaultRenderPlaceholder = ( content ) => {\n\t\tlet { instructions, title } = labels;\n\n\t\tif ( ! mediaUpload && ! onSelectURL ) {\n\t\t\tinstructions = __(\n\t\t\t\t'To edit this block, you need permission to upload media.'\n\t\t\t);\n\t\t}\n\n\t\tif ( instructions === undefined || title === undefined ) {\n\t\t\tconst typesAllowed = allowedTypes ?? [];\n\n\t\t\tconst [ firstAllowedType ] = typesAllowed;\n\t\t\tconst isOneType = 1 === typesAllowed.length;\n\t\t\tconst isAudio = isOneType && 'audio' === firstAllowedType;\n\t\t\tconst isImage = isOneType && 'image' === firstAllowedType;\n\t\t\tconst isVideo = isOneType && 'video' === firstAllowedType;\n\n\t\t\tif ( instructions === undefined && mediaUpload ) {\n\t\t\t\tinstructions = __(\n\t\t\t\t\t'Upload a media file or pick one from your media library.'\n\t\t\t\t);\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an audio file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\tinstructions = __(\n\t\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\t);\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload a video file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( title === undefined ) {\n\t\t\t\ttitle = __( 'Media' );\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\ttitle = __( 'Audio' );\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\ttitle = __( 'Image' );\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\ttitle = __( 'Video' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst placeholderClassName = classnames(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName,\n\t\t\t{\n\t\t\t\t'is-appender': isAppender,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tnotices={ notices }\n\t\t\t\tonDoubleClick={ onDoubleClick }\n\t\t\t\tpreview={ mediaPreview }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t\t{ children }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\tconst renderPlaceholder = placeholder ?? defaultRenderPlaceholder;\n\n\tconst renderDropZone = () => {\n\t\tif ( disableDropZone ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<DropZone onFilesDrop={ onFilesUpload } onHTMLDrop={ onHTMLDrop } />\n\t\t);\n\t};\n\n\tconst renderCancelLink = () => {\n\t\treturn (\n\t\t\tonCancel && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-media-placeholder__cancel-button\"\n\t\t\t\t\ttitle={ __( 'Cancel' ) }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderUrlSelectionUI = () => {\n\t\treturn (\n\t\t\tonSelectURL && (\n\t\t\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\t\t\tonClick={ openURLInput }\n\t\t\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ isURLInputVisible && (\n\t\t\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderMediaUploadChecked = () => {\n\t\tconst defaultButton = ( { open } ) => {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Media Library' ) }\n\t\t\t\t</Button>\n\t\t\t);\n\t\t};\n\t\tconst libraryButton = mediaLibraryButton ?? defaultButton;\n\t\tconst uploadMediaLibraryButton = (\n\t\t\t<MediaUpload\n\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\tgallery={ multiple && onlyAllowsImages() }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonClose={ onClose }\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tvalue={\n\t\t\t\t\tArray.isArray( value )\n\t\t\t\t\t\t? value.map( ( { id } ) => id )\n\t\t\t\t\t\t: value.id\n\t\t\t\t}\n\t\t\t\trender={ libraryButton }\n\t\t\t/>\n\t\t);\n\n\t\tif ( mediaUpload && isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\tconst content = (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn renderPlaceholder( content );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tif ( mediaUpload ) {\n\t\t\tconst content = (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</FormFileUpload>\n\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t</>\n\t\t\t);\n\t\t\treturn renderPlaceholder( content );\n\t\t}\n\n\t\treturn renderPlaceholder( uploadMediaLibraryButton );\n\t};\n\n\tif ( disableMediaButtons ) {\n\t\treturn <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck\n\t\t\tfallback={ renderPlaceholder( renderUrlSelectionUI() ) }\n\t\t>\n\t\t\t{ renderMediaUploadChecked() }\n\t\t</MediaUploadCheck>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md\n */\nexport default withFilters( 'editor.MediaPlaceholder' )( MediaPlaceholder );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"names":["InsertFromURLPopover","src","onChange","onSubmit","onClose","keyboardReturn","MediaPlaceholder","value","allowedTypes","className","icon","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onDoubleClick","onFilesPreUpload","noop","onHTMLDrop","children","mediaLibraryButton","placeholder","style","mediaUpload","select","getSettings","blockEditorStore","setSrc","isURLInputVisible","setIsURLInputVisible","onlyAllowsImages","length","every","allowedType","startsWith","onChangeSrc","event","target","openURLInput","closeURLInput","onSubmitSrc","preventDefault","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","onUpload","defaultRenderPlaceholder","content","instructions","title","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","renderPlaceholder","renderDropZone","renderCancelLink","renderUrlSelectionUI","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","Array","isArray","openFileDialog"],"mappings":";;;;;;;;;;AAiBA;;AAdA;;AACA;;AAKA;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,EAZvB,EAaGD,gBAAgB,EAbnB,CADD;AAiBA,iBAAOF,iBAAiB,CAAEX,OAAF,CAAxB;AACA;AAvBF,QAFD,CADD;AA8BA;;AAED,QAAK3C,WAAL,EAAmB;AAClB,YAAM2C,OAAO,GACZ,qDACGY,cAAc,EADjB,EAEC,4BAAC,0BAAD;AACC,QAAA,OAAO,EAAC,SADT;AAEC,QAAA,SAAS,EAAG,yBACX,wCADW,EAEX,+CAFW,CAFb;AAMC,QAAA,QAAQ,EAAGd,QANZ;AAOC,QAAA,MAAM,EAAG3D,MAPV;AAQC,QAAA,QAAQ,EAAGE;AARZ,SAUG,cAAI,QAAJ,CAVH,CAFD,EAcG8E,wBAdH,EAeGL,oBAAoB,EAfvB,EAgBGD,gBAAgB,EAhBnB,CADD;AAoBA,aAAOF,iBAAiB,CAAEX,OAAF,CAAxB;AACA;;AAED,WAAOW,iBAAiB,CAAEQ,wBAAF,CAAxB;AACA,GAxFD;;AA0FA,MAAK3E,mBAAL,EAA2B;AAC1B,WAAO,4BAAC,cAAD,QAAoBoE,cAAc,EAAlC,CAAP;AACA;;AAED,SACC,4BAAC,cAAD;AACC,IAAA,QAAQ,EAAGD,iBAAiB,CAAEG,oBAAoB,EAAtB;AAD7B,KAGGC,wBAAwB,EAH3B,CADD;AAOA;AAED;AACA;AACA;;;eACe,6BAAa,yBAAb,EAA0CrF,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFormFileUpload,\n\tPlaceholder,\n\tDropZone,\n\twithFilters,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { keyboardReturn } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport URLPopover from '../url-popover';\nimport { store as blockEditorStore } from '../../store';\n\nconst InsertFromURLPopover = ( { src, onChange, onSubmit, onClose } ) => (\n\t<URLPopover onClose={ onClose }>\n\t\t<form\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\taria-label={ __( 'URL' ) }\n\t\t\t\tplaceholder={ __( 'Paste or type URL' ) }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ src }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-submit-button\"\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t</URLPopover>\n);\n\nexport function MediaPlaceholder( {\n\tvalue = {},\n\tallowedTypes,\n\tclassName,\n\ticon,\n\tlabels = {},\n\tmediaPreview,\n\tnotices,\n\tisAppender,\n\taccept,\n\taddToGallery,\n\tmultiple = false,\n\thandleUpload = true,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop = noop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\n} ) {\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\tconst [ src, setSrc ] = useState( '' );\n\tconst [ isURLInputVisible, setIsURLInputVisible ] = useState( false );\n\n\tuseEffect( () => {\n\t\tsetSrc( value?.src ?? '' );\n\t}, [ value?.src ] );\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst onChangeSrc = ( event ) => {\n\t\tsetSrc( event.target.value );\n\t};\n\n\tconst openURLInput = () => {\n\t\tsetIsURLInputVisible( true );\n\t};\n\tconst closeURLInput = () => {\n\t\tsetIsURLInputVisible( false );\n\t};\n\n\tconst onSubmitSrc = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( src && onSelectURL ) {\n\t\t\tonSelectURL( src );\n\t\t\tcloseURLInput();\n\t\t}\n\t};\n\n\tconst onFilesUpload = ( files ) => {\n\t\tif ( ! handleUpload ) {\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesPreUpload( files );\n\t\tlet setMedia;\n\t\tif ( multiple ) {\n\t\t\tif ( addToGallery ) {\n\t\t\t\t// Since the setMedia function runs multiple times per upload group\n\t\t\t\t// and is passed newMedia containing every item in its group each time, we must\n\t\t\t\t// filter out whatever this upload group had previously returned to the\n\t\t\t\t// gallery before adding and returning the image array with replacement newMedia\n\t\t\t\t// values.\n\n\t\t\t\t// Define an array to store urls from newMedia between subsequent function calls.\n\t\t\t\tlet lastMediaPassed = [];\n\t\t\t\tsetMedia = ( newMedia ) => {\n\t\t\t\t\t// Remove any images this upload group is responsible for (lastMediaPassed).\n\t\t\t\t\t// Their replacements are contained in newMedia.\n\t\t\t\t\tconst filteredMedia = ( value ?? [] ).filter( ( item ) => {\n\t\t\t\t\t\t// If Item has id, only remove it if lastMediaPassed has an item with that id.\n\t\t\t\t\t\tif ( item.id ) {\n\t\t\t\t\t\t\treturn ! lastMediaPassed.some(\n\t\t\t\t\t\t\t\t// Be sure to convert to number for comparison.\n\t\t\t\t\t\t\t\t( { id } ) => Number( id ) === Number( item.id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Compare transient images via .includes since gallery may append extra info onto the url.\n\t\t\t\t\t\treturn ! lastMediaPassed.some( ( { urlSlug } ) =>\n\t\t\t\t\t\t\titem.url.includes( urlSlug )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\t// Return the filtered media array along with newMedia.\n\t\t\t\t\tonSelect( filteredMedia.concat( newMedia ) );\n\t\t\t\t\t// Reset lastMediaPassed and set it with ids and urls from newMedia.\n\t\t\t\t\tlastMediaPassed = newMedia.map( ( media ) => {\n\t\t\t\t\t\t// Add everything up to '.fileType' to compare via .includes.\n\t\t\t\t\t\tconst cutOffIndex = media.url.lastIndexOf( '.' );\n\t\t\t\t\t\tconst urlSlug = media.url.slice( 0, cutOffIndex );\n\t\t\t\t\t\treturn { id: media.id, urlSlug };\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tsetMedia = onSelect;\n\t\t\t}\n\t\t} else {\n\t\t\tsetMedia = ( [ media ] ) => onSelect( media );\n\t\t}\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tconst onUpload = ( event ) => {\n\t\tonFilesUpload( event.target.files );\n\t};\n\n\tconst defaultRenderPlaceholder = ( content ) => {\n\t\tlet { instructions, title } = labels;\n\n\t\tif ( ! mediaUpload && ! onSelectURL ) {\n\t\t\tinstructions = __(\n\t\t\t\t'To edit this block, you need permission to upload media.'\n\t\t\t);\n\t\t}\n\n\t\tif ( instructions === undefined || title === undefined ) {\n\t\t\tconst typesAllowed = allowedTypes ?? [];\n\n\t\t\tconst [ firstAllowedType ] = typesAllowed;\n\t\t\tconst isOneType = 1 === typesAllowed.length;\n\t\t\tconst isAudio = isOneType && 'audio' === firstAllowedType;\n\t\t\tconst isImage = isOneType && 'image' === firstAllowedType;\n\t\t\tconst isVideo = isOneType && 'video' === firstAllowedType;\n\n\t\t\tif ( instructions === undefined && mediaUpload ) {\n\t\t\t\tinstructions = __(\n\t\t\t\t\t'Upload a media file or pick one from your media library.'\n\t\t\t\t);\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an audio file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\tinstructions = __(\n\t\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\t);\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload a video file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( title === undefined ) {\n\t\t\t\ttitle = __( 'Media' );\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\ttitle = __( 'Audio' );\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\ttitle = __( 'Image' );\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\ttitle = __( 'Video' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst placeholderClassName = classnames(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName,\n\t\t\t{\n\t\t\t\t'is-appender': isAppender,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tnotices={ notices }\n\t\t\t\tonDoubleClick={ onDoubleClick }\n\t\t\t\tpreview={ mediaPreview }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t\t{ children }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\tconst renderPlaceholder = placeholder ?? defaultRenderPlaceholder;\n\n\tconst renderDropZone = () => {\n\t\tif ( disableDropZone ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<DropZone onFilesDrop={ onFilesUpload } onHTMLDrop={ onHTMLDrop } />\n\t\t);\n\t};\n\n\tconst renderCancelLink = () => {\n\t\treturn (\n\t\t\tonCancel && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-media-placeholder__cancel-button\"\n\t\t\t\t\ttitle={ __( 'Cancel' ) }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderUrlSelectionUI = () => {\n\t\treturn (\n\t\t\tonSelectURL && (\n\t\t\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\t\t\tonClick={ openURLInput }\n\t\t\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ isURLInputVisible && (\n\t\t\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderMediaUploadChecked = () => {\n\t\tconst defaultButton = ( { open } ) => {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Media Library' ) }\n\t\t\t\t</Button>\n\t\t\t);\n\t\t};\n\t\tconst libraryButton = mediaLibraryButton ?? defaultButton;\n\t\tconst uploadMediaLibraryButton = (\n\t\t\t<MediaUpload\n\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\tgallery={ multiple && onlyAllowsImages() }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tvalue={\n\t\t\t\t\tArray.isArray( value )\n\t\t\t\t\t\t? value.map( ( { id } ) => id )\n\t\t\t\t\t\t: value.id\n\t\t\t\t}\n\t\t\t\trender={ libraryButton }\n\t\t\t/>\n\t\t);\n\n\t\tif ( mediaUpload && isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\tconst content = (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn renderPlaceholder( content );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tif ( mediaUpload ) {\n\t\t\tconst content = (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</FormFileUpload>\n\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t</>\n\t\t\t);\n\t\t\treturn renderPlaceholder( content );\n\t\t}\n\n\t\treturn renderPlaceholder( uploadMediaLibraryButton );\n\t};\n\n\tif ( disableMediaButtons ) {\n\t\treturn <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck\n\t\t\tfallback={ renderPlaceholder( renderUrlSelectionUI() ) }\n\t\t>\n\t\t\t{ renderMediaUploadChecked() }\n\t\t</MediaUploadCheck>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md\n */\nexport default withFilters( 'editor.MediaPlaceholder' )( MediaPlaceholder );\n"]}
|
|
@@ -59,7 +59,6 @@ const MediaReplaceFlow = _ref => {
|
|
|
59
59
|
onSelect,
|
|
60
60
|
onSelectURL,
|
|
61
61
|
onFilesUpload = _lodash.noop,
|
|
62
|
-
onCloseModal = _lodash.noop,
|
|
63
62
|
name = (0, _i18n.__)('Replace'),
|
|
64
63
|
createNotice,
|
|
65
64
|
removeNotice,
|
|
@@ -175,7 +174,6 @@ const MediaReplaceFlow = _ref => {
|
|
|
175
174
|
value: multiple ? mediaIds : mediaId,
|
|
176
175
|
onSelect: media => selectMedia(media, onClose),
|
|
177
176
|
allowedTypes: allowedTypes,
|
|
178
|
-
onClose: onCloseModal,
|
|
179
177
|
render: _ref5 => {
|
|
180
178
|
let {
|
|
181
179
|
open
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"names":["MediaReplaceFlow","mediaURL","mediaId","mediaIds","allowedTypes","accept","onError","onSelect","onSelectURL","onFilesUpload","noop","onCloseModal","name","createNotice","removeNotice","children","multiple","addToGallery","handleUpload","mediaURLValue","setMediaURLValue","mediaUpload","select","blockEditorStore","getSettings","editMediaButtonRef","errorNoticeID","onUploadError","message","safeMessage","setTimeout","speak","id","isDismissible","selectMedia","media","closeMenu","url","uploadFiles","event","files","target","filesList","onFileChange","openOnArrowDown","keyCode","DOWN","preventDefault","click","onlyAllowsImages","length","every","allowedType","startsWith","gallery","POPOVER_PROPS","isAlternate","isOpen","onToggle","onClose","open","mediaIcon","openFileDialog","upload","current","focus","dispatch","noticesStore"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;AAMA,MAAMA,gBAAgB,GAAG,QAkBlB;AAAA,MAlBoB;AAC1BC,IAAAA,QAD0B;AAE1BC,IAAAA,OAF0B;AAG1BC,IAAAA,QAH0B;AAI1BC,IAAAA,YAJ0B;AAK1BC,IAAAA,MAL0B;AAM1BC,IAAAA,OAN0B;AAO1BC,IAAAA,QAP0B;AAQ1BC,IAAAA,WAR0B;AAS1BC,IAAAA,aAAa,GAAGC,YATU;AAU1BC,IAAAA,YAAY,GAAGD,YAVW;AAW1BE,IAAAA,IAAI,GAAG,cAAI,SAAJ,CAXmB;AAY1BC,IAAAA,YAZ0B;AAa1BC,IAAAA,YAb0B;AAc1BC,IAAAA,Q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,cAAI,QAAJ,CANH,CADD;AAUA;AAjBF,QADD,CAjBD,EAsCG/C,QAtCH,CADD,EAyCGP,WAAW,IACZ;AACA;AAAM,QAAA,SAAS,EAAC;AAAhB,SACC;AAAM,QAAA,SAAS,EAAC;AAAhB,SACG,cAAI,oBAAJ,CADH,CADD,EAIC,4BAAC,oBAAD;AACC,QAAA,KAAK,EAAG;AAAE6B,UAAAA,GAAG,EAAElB;AAAP,SADT;AAEC,QAAA,QAAQ,EAAG,EAFZ;AAGC,QAAA,eAAe,EAAG,KAHnB;AAIC,QAAA,QAAQ,EAAG,SAAe;AAAA,cAAb;AAAEkB,YAAAA;AAAF,WAAa;AACzBjB,UAAAA,gBAAgB,CAAEiB,GAAF,CAAhB;AACA7B,UAAAA,WAAW,CAAE6B,GAAF,CAAX;AACAZ,UAAAA,kBAAkB,CAACuC,OAAnB,CAA2BC,KAA3B;AACA;AARF,QAJD,CA3CF,CADe;AAAA;AAdjB,IADD;AA+EA,CAlLD;AAoLA;AACA;AACA;;;eACe,sBAAS,CACvB,wBAAgBC,QAAF,IAAgB;AAC7B,QAAM;AAAErD,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAiCoD,QAAQ,CAAEC,cAAF,CAA/C;AACA,SAAO;AACNtD,IAAAA,YADM;AAENC,IAAAA;AAFM,GAAP;AAIA,CAND,CADuB,EAQvB,6BAAa,yBAAb,CARuB,CAAT,EASVd,gBATU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop, uniqueId } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tFormFileUpload,\n\tNavigableMenu,\n\tMenuItem,\n\tToolbarButton,\n\tDropdown,\n\twithFilters,\n} from '@wordpress/components';\nimport { useSelect, withDispatch } from '@wordpress/data';\nimport { DOWN } from '@wordpress/keycodes';\nimport { upload, media as mediaIcon } from '@wordpress/icons';\nimport { compose } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport LinkControl from '../link-control';\nimport { store as blockEditorStore } from '../../store';\n\nconst MediaReplaceFlow = ( {\n\tmediaURL,\n\tmediaId,\n\tmediaIds,\n\tallowedTypes,\n\taccept,\n\tonError,\n\tonSelect,\n\tonSelectURL,\n\tonFilesUpload = noop,\n\tonCloseModal = noop,\n\tname = __( 'Replace' ),\n\tcreateNotice,\n\tremoveNotice,\n\tchildren,\n\tmultiple = false,\n\taddToGallery,\n\thandleUpload = true,\n} ) => {\n\tconst [ mediaURLValue, setMediaURLValue ] = useState( mediaURL );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst editMediaButtonRef = useRef();\n\tconst errorNoticeID = uniqueId(\n\t\t'block-editor/media-replace-flow/error-notice/'\n\t);\n\n\tconst onUploadError = ( message ) => {\n\t\tconst safeMessage = stripHTML( message );\n\t\tif ( onError ) {\n\t\t\tonError( safeMessage );\n\t\t\treturn;\n\t\t}\n\t\t// We need to set a timeout for showing the notice\n\t\t// so that VoiceOver and possibly other screen readers\n\t\t// can announce the error afer the toolbar button\n\t\t// regains focus once the upload dialog closes.\n\t\t// Otherwise VO simply skips over the notice and announces\n\t\t// the focused element and the open menu.\n\t\tsetTimeout( () => {\n\t\t\tcreateNotice( 'error', safeMessage, {\n\t\t\t\tspeak: true,\n\t\t\t\tid: errorNoticeID,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}, 1000 );\n\t};\n\n\tconst selectMedia = ( media, closeMenu ) => {\n\t\tcloseMenu();\n\t\tsetMediaURLValue( media?.url );\n\t\t// Calling `onSelect` after the state update since it might unmount the component.\n\t\tonSelect( media );\n\t\tspeak( __( 'The media file has been replaced' ) );\n\t\tremoveNotice( errorNoticeID );\n\t};\n\n\tconst uploadFiles = ( event, closeMenu ) => {\n\t\tconst files = event.target.files;\n\t\tif ( ! handleUpload ) {\n\t\t\tcloseMenu();\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesUpload( files );\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\tselectMedia( media, closeMenu );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.target.click();\n\t\t}\n\t};\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst gallery = multiple && onlyAllowsImages();\n\n\tconst POPOVER_PROPS = {\n\t\tisAlternate: true,\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tcontentClassName=\"block-editor-media-replace-flow__options\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ editMediaButtonRef }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</ToolbarButton>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu className=\"block-editor-media-replace-flow__media-upload-menu\">\n\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\tgallery={ gallery }\n\t\t\t\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\tvalue={ multiple ? mediaIds : mediaId }\n\t\t\t\t\t\t\tonSelect={ ( media ) =>\n\t\t\t\t\t\t\t\tselectMedia( media, onClose )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t\t\tonClose={ onCloseModal }\n\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t<MenuItem icon={ mediaIcon } onClick={ open }>\n\t\t\t\t\t\t\t\t\t{ __( 'Open Media Library' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\t\t\t\t\tuploadFiles( event, onClose );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\topenFileDialog();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MediaUploadCheck>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t{ onSelectURL && (\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t<form className=\"block-editor-media-flow__url-input\">\n\t\t\t\t\t\t\t<span className=\"block-editor-media-replace-flow__image-url-label\">\n\t\t\t\t\t\t\t\t{ __( 'Current media URL:' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tvalue={ { url: mediaURLValue } }\n\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\tsetMediaURLValue( url );\n\t\t\t\t\t\t\t\t\tonSelectURL( url );\n\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md\n */\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createNotice, removeNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tcreateNotice,\n\t\t\tremoveNotice,\n\t\t};\n\t} ),\n\twithFilters( 'editor.MediaReplaceFlow' ),\n] )( MediaReplaceFlow );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"names":["MediaReplaceFlow","mediaURL","mediaId","mediaIds","allowedTypes","accept","onError","onSelect","onSelectURL","onFilesUpload","noop","name","createNotice","removeNotice","children","multiple","addToGallery","handleUpload","mediaURLValue","setMediaURLValue","mediaUpload","select","blockEditorStore","getSettings","editMediaButtonRef","errorNoticeID","onUploadError","message","safeMessage","setTimeout","speak","id","isDismissible","selectMedia","media","closeMenu","url","uploadFiles","event","files","target","filesList","onFileChange","openOnArrowDown","keyCode","DOWN","preventDefault","click","onlyAllowsImages","length","every","allowedType","startsWith","gallery","POPOVER_PROPS","isAlternate","isOpen","onToggle","onClose","open","mediaIcon","openFileDialog","upload","current","focus","dispatch","noticesStore"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;AAMA,MAAMA,gBAAgB,GAAG,QAiBlB;AAAA,MAjBoB;AAC1BC,IAAAA,QAD0B;AAE1BC,IAAAA,OAF0B;AAG1BC,IAAAA,QAH0B;AAI1BC,IAAAA,YAJ0B;AAK1BC,IAAAA,MAL0B;AAM1BC,IAAAA,OAN0B;AAO1BC,IAAAA,QAP0B;AAQ1BC,IAAAA,WAR0B;AAS1BC,IAAAA,aAAa,GAAGC,YATU;AAU1BC,IAAAA,IAAI,GAAG,cAAI,SAAJ,CAVmB;AAW1BC,IAAAA,YAX0B;AAY1BC,IAAAA,YAZ0B;AAa1BC,IAAAA,QAb0B;AAc1BC,IAAAA,QAAQ,GAAG,KAde;AAe1BC,IAAAA,YAf0B;AAgB1BC,IAAAA,YAAY,GAAG;AAhBW,GAiBpB;AACN,QAAM,CAAEC,aAAF,EAAiBC,gBAAjB,IAAsC,uBAAUlB,QAAV,CAA5C;AACA,QAAMmB,WAAW,GAAG,qBAAaC,MAAF,IAAc;AAC5C,WAAOA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,GAAyCH,WAAhD;AACA,GAFmB,EAEjB,EAFiB,CAApB;AAGA,QAAMI,kBAAkB,GAAG,sBAA3B;AACA,QAAMC,aAAa,GAAG,sBACrB,+CADqB,CAAtB;;AAIA,QAAMC,aAAa,GAAKC,OAAF,IAAe;AACpC,UAAMC,WAAW,GAAG,8BAAWD,OAAX,CAApB;;AACA,QAAKrB,OAAL,EAAe;AACdA,MAAAA,OAAO,CAAEs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A;AAdjB,IADD;AA8EA,CAhLD;AAkLA;AACA;AACA;;;eACe,sBAAS,CACvB,wBAAgBC,QAAF,IAAgB;AAC7B,QAAM;AAAErD,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAiCoD,QAAQ,CAAEC,cAAF,CAA/C;AACA,SAAO;AACNtD,IAAAA,YADM;AAENC,IAAAA;AAFM,GAAP;AAIA,CAND,CADuB,EAQvB,6BAAa,yBAAb,CARuB,CAAT,EASVb,gBATU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop, uniqueId } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tFormFileUpload,\n\tNavigableMenu,\n\tMenuItem,\n\tToolbarButton,\n\tDropdown,\n\twithFilters,\n} from '@wordpress/components';\nimport { useSelect, withDispatch } from '@wordpress/data';\nimport { DOWN } from '@wordpress/keycodes';\nimport { upload, media as mediaIcon } from '@wordpress/icons';\nimport { compose } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport LinkControl from '../link-control';\nimport { store as blockEditorStore } from '../../store';\n\nconst MediaReplaceFlow = ( {\n\tmediaURL,\n\tmediaId,\n\tmediaIds,\n\tallowedTypes,\n\taccept,\n\tonError,\n\tonSelect,\n\tonSelectURL,\n\tonFilesUpload = noop,\n\tname = __( 'Replace' ),\n\tcreateNotice,\n\tremoveNotice,\n\tchildren,\n\tmultiple = false,\n\taddToGallery,\n\thandleUpload = true,\n} ) => {\n\tconst [ mediaURLValue, setMediaURLValue ] = useState( mediaURL );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst editMediaButtonRef = useRef();\n\tconst errorNoticeID = uniqueId(\n\t\t'block-editor/media-replace-flow/error-notice/'\n\t);\n\n\tconst onUploadError = ( message ) => {\n\t\tconst safeMessage = stripHTML( message );\n\t\tif ( onError ) {\n\t\t\tonError( safeMessage );\n\t\t\treturn;\n\t\t}\n\t\t// We need to set a timeout for showing the notice\n\t\t// so that VoiceOver and possibly other screen readers\n\t\t// can announce the error afer the toolbar button\n\t\t// regains focus once the upload dialog closes.\n\t\t// Otherwise VO simply skips over the notice and announces\n\t\t// the focused element and the open menu.\n\t\tsetTimeout( () => {\n\t\t\tcreateNotice( 'error', safeMessage, {\n\t\t\t\tspeak: true,\n\t\t\t\tid: errorNoticeID,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}, 1000 );\n\t};\n\n\tconst selectMedia = ( media, closeMenu ) => {\n\t\tcloseMenu();\n\t\tsetMediaURLValue( media?.url );\n\t\t// Calling `onSelect` after the state update since it might unmount the component.\n\t\tonSelect( media );\n\t\tspeak( __( 'The media file has been replaced' ) );\n\t\tremoveNotice( errorNoticeID );\n\t};\n\n\tconst uploadFiles = ( event, closeMenu ) => {\n\t\tconst files = event.target.files;\n\t\tif ( ! handleUpload ) {\n\t\t\tcloseMenu();\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesUpload( files );\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\tselectMedia( media, closeMenu );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.target.click();\n\t\t}\n\t};\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst gallery = multiple && onlyAllowsImages();\n\n\tconst POPOVER_PROPS = {\n\t\tisAlternate: true,\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tcontentClassName=\"block-editor-media-replace-flow__options\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ editMediaButtonRef }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</ToolbarButton>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu className=\"block-editor-media-replace-flow__media-upload-menu\">\n\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\tgallery={ gallery }\n\t\t\t\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\tvalue={ multiple ? mediaIds : mediaId }\n\t\t\t\t\t\t\tonSelect={ ( media ) =>\n\t\t\t\t\t\t\t\tselectMedia( media, onClose )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t<MenuItem icon={ mediaIcon } onClick={ open }>\n\t\t\t\t\t\t\t\t\t{ __( 'Open Media Library' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\t\t\t\t\tuploadFiles( event, onClose );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\topenFileDialog();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MediaUploadCheck>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t{ onSelectURL && (\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t<form className=\"block-editor-media-flow__url-input\">\n\t\t\t\t\t\t\t<span className=\"block-editor-media-replace-flow__image-url-label\">\n\t\t\t\t\t\t\t\t{ __( 'Current media URL:' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tvalue={ { url: mediaURLValue } }\n\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\tsetMediaURLValue( url );\n\t\t\t\t\t\t\t\t\tonSelectURL( url );\n\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md\n */\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createNotice, removeNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tcreateNotice,\n\t\t\tremoveNotice,\n\t\t};\n\t} ),\n\twithFilters( 'editor.MediaReplaceFlow' ),\n] )( MediaReplaceFlow );\n"]}
|
|
@@ -245,8 +245,8 @@ function usePasteHandler(props) {
|
|
|
245
245
|
}, []);
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
|
-
* Normalizes a given string of HTML to remove the Windows
|
|
249
|
-
* and any preceeding and trailing
|
|
248
|
+
* Normalizes a given string of HTML to remove the Windows-specific "Fragment"
|
|
249
|
+
* comments and any preceeding and trailing content.
|
|
250
250
|
*
|
|
251
251
|
* @param {string} html the html to be normalized
|
|
252
252
|
* @return {string} the normalized html
|
|
@@ -254,9 +254,24 @@ function usePasteHandler(props) {
|
|
|
254
254
|
|
|
255
255
|
|
|
256
256
|
function removeWindowsFragments(html) {
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
|
|
257
|
+
const startStr = '<!--StartFragment-->';
|
|
258
|
+
const startIdx = html.indexOf(startStr);
|
|
259
|
+
|
|
260
|
+
if (startIdx > -1) {
|
|
261
|
+
html = html.substring(startIdx + startStr.length);
|
|
262
|
+
} else {
|
|
263
|
+
// No point looking for EndFragment
|
|
264
|
+
return html;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const endStr = '<!--EndFragment-->';
|
|
268
|
+
const endIdx = html.indexOf(endStr);
|
|
269
|
+
|
|
270
|
+
if (endIdx > -1) {
|
|
271
|
+
html = html.substring(0, endIdx);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return html;
|
|
260
275
|
}
|
|
261
276
|
/**
|
|
262
277
|
* Removes the charset meta tag inserted by Chromium.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-paste-handler.js"],"names":["adjustLines","value","isMultiline","LINE_SEPARATOR","RegExp","usePasteHandler","props","propsRef","current","element","_onPaste","event","isSelected","disableFormats","onChange","formatTypes","tagName","onReplace","onSplit","onSplitMiddle","__unstableEmbedURLOnPaste","multilineTag","preserveWhiteSpace","pastePlainText","clipboardData","plainText","html","getData","error1","error2","removeWindowsFragments","removeCharsetMetaTag","preventDefault","window","console","log","transformed","reduce","accumlator","__unstablePasteRule","files","isInternal","pastedMultilineTag","undefined","pastedValue","multilineWrapperTags","activeFormats","text","length","content","HTML","mode","pastedBlocks","trim","valueToInsert","addEventListener","removeEventListener","startReg","endReg","replace","metaTag","startsWith","slice"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AAKA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAcA;AACA;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CAAsBC,KAAtB,EAA6BC,WAA7B,EAA2C;AAC1C,MAAKA,WAAL,EAAmB;AAClB,WAAO,uBAASD,KAAT,EAAgB,MAAhB,EAAwBE,mCAAxB,CAAP;AACA;;AAED,SAAO,uBAASF,KAAT,EAAgB,IAAIG,MAAJ,CAAYD,mCAAZ,EAA4B,GAA5B,CAAhB,EAAmD,IAAnD,CAAP;AACA;;AAEM,SAASE,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,QAAQ,GAAG,qBAAQD,KAAR,CAAjB;AACAC,EAAAA,QAAQ,CAACC,OAAT,GAAmBF,KAAnB;AACA,SAAO,2BAAgBG,OAAF,IAAe;AACnC,aAASC,QAAT,CAAmBC,KAAnB,EAA2B;AAC1B,YAAM;AACLC,QAAAA,UADK;AAELC,QAAAA,cAFK;AAGLC,QAAAA,QAHK;AAILb,QAAAA,KAJK;AAKLc,QAAAA,WALK;AAMLC,QAAAA,OANK;AAOLC,QAAAA,SAPK;AAQLC,QAA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9C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS3B,oBAAT,CAA+BL,IAA/B,EAAsC;AACrC,QAAMkC,OAAO,GAAI,wBAAjB;;AAEA,MAAKlC,IAAI,CAACmC,UAAL,CAAiBD,OAAjB,CAAL,EAAkC;AACjC,WAAOlC,IAAI,CAACoC,KAAL,CAAYF,OAAO,CAACZ,MAApB,CAAP;AACA;;AAED,SAAOtB,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\tisEmpty,\n\tinsert,\n\tcreate,\n\treplace,\n\t__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { filePasteHandler } from './file-paste-handler';\nimport { addActiveFormats, isShortcode } from './utils';\nimport { splitValue } from './split-value';\nimport { shouldDismissPastedFiles } from '../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\n/**\n * Replaces line separators with line breaks if not multiline.\n * Replaces line breaks with line separators if multiline.\n *\n * @param {RichTextValue} value Value to adjust.\n * @param {boolean} isMultiline Whether to adjust to multiline or not.\n *\n * @return {RichTextValue} Adjusted value.\n */\nfunction adjustLines( value, isMultiline ) {\n\tif ( isMultiline ) {\n\t\treturn replace( value, /\\n+/g, LINE_SEPARATOR );\n\t}\n\n\treturn replace( value, new RegExp( LINE_SEPARATOR, 'g' ), '\\n' );\n}\n\nexport function usePasteHandler( props ) {\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction _onPaste( event ) {\n\t\t\tconst {\n\t\t\t\tisSelected,\n\t\t\t\tdisableFormats,\n\t\t\t\tonChange,\n\t\t\t\tvalue,\n\t\t\t\tformatTypes,\n\t\t\t\ttagName,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonSplitMiddle,\n\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\tmultilineTag,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t\tpastePlainText,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { clipboardData } = event;\n\n\t\t\tlet plainText = '';\n\t\t\tlet html = '';\n\n\t\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t\t// arguments first, then fallback to `Text` if they fail.\n\t\t\ttry {\n\t\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t\t} catch ( error1 ) {\n\t\t\t\ttry {\n\t\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t\t} catch ( error2 ) {\n\t\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t\t// behaviour.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove Windows-specific metadata appended within copied HTML text.\n\t\t\thtml = removeWindowsFragments( html );\n\n\t\t\t// Strip meta tag.\n\t\t\thtml = removeCharsetMetaTag( html );\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\t\tif ( disableFormats ) {\n\t\t\t\tonChange( insert( value, plainText ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumlator === value ) {\n\t\t\t\t\t\taccumlator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst files = [ ...getFilesFromDataTransfer( clipboardData ) ];\n\t\t\tconst isInternal = clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t\t// without filtering the data. The filters are only meant for externally\n\t\t\t// pasted content and remove inline styles.\n\t\t\tif ( isInternal ) {\n\t\t\t\tconst pastedMultilineTag =\n\t\t\t\t\tclipboardData.getData( 'rich-text-multi-line-tag' ) ||\n\t\t\t\t\tundefined;\n\t\t\t\tlet pastedValue = create( {\n\t\t\t\t\thtml,\n\t\t\t\t\tmultilineTag: pastedMultilineTag,\n\t\t\t\t\tmultilineWrapperTags:\n\t\t\t\t\t\tpastedMultilineTag === 'li'\n\t\t\t\t\t\t\t? [ 'ul', 'ol' ]\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\t\t\t\tpastedValue = adjustLines( pastedValue, !! multilineTag );\n\t\t\t\taddActiveFormats( pastedValue, value.activeFormats );\n\t\t\t\tonChange( insert( value, pastedValue ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( pastePlainText ) {\n\t\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Process any attached files, unless we infer that the files in\n\t\t\t// question are redundant \"screenshots\" of the actual HTML payload,\n\t\t\t// as created by certain office-type programs.\n\t\t\t//\n\t\t\t// @see shouldDismissPastedFiles\n\t\t\tif (\n\t\t\t\tfiles?.length &&\n\t\t\t\t! shouldDismissPastedFiles( files, html, plainText )\n\t\t\t) {\n\t\t\t\tconst content = pasteHandler( {\n\t\t\t\t\tHTML: filePasteHandler( files ),\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\ttagName,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\n\t\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\twindow.console.log( 'Received items:\\n\\n', files );\n\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet mode = onReplace && onSplit ? 'AUTO' : 'INLINE';\n\n\t\t\t// Force the blocks mode when the user is pasting\n\t\t\t// on a new line & the content resembles a shortcode.\n\t\t\t// Otherwise it's going to be detected as inline\n\t\t\t// and the shortcode won't be replaced.\n\t\t\tif (\n\t\t\t\tmode === 'AUTO' &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisShortcode( plainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisURL( plainText.trim() )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tconst content = pasteHandler( {\n\t\t\t\tHTML: html,\n\t\t\t\tplainText,\n\t\t\t\tmode,\n\t\t\t\ttagName,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tlet valueToInsert = create( { html: content } );\n\n\t\t\t\t// If the content should be multiline, we should process text\n\t\t\t\t// separated by a line break as separate lines.\n\t\t\t\tvalueToInsert = adjustLines( valueToInsert, !! multilineTag );\n\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t} else if ( content.length > 0 ) {\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'paste', _onPaste );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'paste', _onPaste );\n\t\t};\n\t}, [] );\n}\n\n/**\n * Normalizes a given string of HTML to remove the Windows specific \"Fragment\" comments\n * and any preceeding and trailing whitespace.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startReg = /.*<!--StartFragment-->/s;\n\tconst endReg = /<!--EndFragment-->.*/s;\n\n\treturn html.replace( startReg, '' ).replace( endReg, '' );\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-paste-handler.js"],"names":["adjustLines","value","isMultiline","LINE_SEPARATOR","RegExp","usePasteHandler","props","propsRef","current","element","_onPaste","event","isSelected","disableFormats","onChange","formatTypes","tagName","onReplace","onSplit","onSplitMiddle","__unstableEmbedURLOnPaste","multilineTag","preserveWhiteSpace","pastePlainText","clipboardData","plainText","html","getData","error1","error2","removeWindowsFragments","removeCharsetMetaTag","preventDefault","window","console","log","transformed","reduce","accumlator","__unstablePasteRule","files","isInternal","pastedMultilineTag","undefined","pastedValue","multilineWrapperTags","activeFormats","text","length","content","HTML","mode","pastedBlocks","trim","valueToInsert","addEventListener","removeEventListener","startStr","startIdx","indexOf","substring","endStr","endIdx","metaTag","startsWith","slice"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AAKA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAcA;AACA;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CAAsBC,KAAtB,EAA6BC,WAA7B,EAA2C;AAC1C,MAAKA,WAAL,EAAmB;AAClB,WAAO,uBAASD,KAAT,EAAgB,MAAhB,EAAwBE,mCAAxB,CAAP;AACA;;AAED,SAAO,uBAASF,KAAT,EAAgB,IAAIG,MAAJ,CAAYD,mCAAZ,EAA4B,GAA5B,CAAhB,EAAmD,IAAnD,CAAP;AACA;;AAEM,SAASE,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,QAAQ,GAAG,qBAAQD,KAAR,CAAjB;AACAC,EAAAA,QAAQ,CAACC,OAAT,GAAmBF,KAAnB;AACA,SAAO,2BAAgBG,OAAF,IAAe;AACnC,aAASC,QAAT,CAAmBC,KAAnB,EAA2B;AAC1B,YAAM;AACLC,QAAAA,UADK;AAELC,QAAAA,cAFK;AAGLC,QAAAA,QAHK;AAILb,QAAAA,KAJK;AAKLc,QAAAA,WALK;AAMLC,QAAAA,OANK;AAOLC,QAAAA,SAPK;AAQLC,QAAAA,O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GA,IAAI,CAACkC,SAAL,CAAgBF,QAAQ,GAAGD,QAAQ,CAACT,MAApC,CAAP;AACA,GAFD,MAEO;AACN;AACA,WAAOtB,IAAP;AACA;;AAED,QAAMmC,MAAM,GAAG,oBAAf;AACA,QAAMC,MAAM,GAAGpC,IAAI,CAACiC,OAAL,CAAcE,MAAd,CAAf;;AACA,MAAKC,MAAM,GAAG,CAAC,CAAf,EAAmB;AAClBpC,IAAAA,IAAI,GAAGA,IAAI,CAACkC,SAAL,CAAgB,CAAhB,EAAmBE,MAAnB,CAAP;AACA;;AAED,SAAOpC,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASK,oBAAT,CAA+BL,IAA/B,EAAsC;AACrC,QAAMqC,OAAO,GAAI,wBAAjB;;AAEA,MAAKrC,IAAI,CAACsC,UAAL,CAAiBD,OAAjB,CAAL,EAAkC;AACjC,WAAOrC,IAAI,CAACuC,KAAL,CAAYF,OAAO,CAACf,MAApB,CAAP;AACA;;AAED,SAAOtB,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\tisEmpty,\n\tinsert,\n\tcreate,\n\treplace,\n\t__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { filePasteHandler } from './file-paste-handler';\nimport { addActiveFormats, isShortcode } from './utils';\nimport { splitValue } from './split-value';\nimport { shouldDismissPastedFiles } from '../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\n/**\n * Replaces line separators with line breaks if not multiline.\n * Replaces line breaks with line separators if multiline.\n *\n * @param {RichTextValue} value Value to adjust.\n * @param {boolean} isMultiline Whether to adjust to multiline or not.\n *\n * @return {RichTextValue} Adjusted value.\n */\nfunction adjustLines( value, isMultiline ) {\n\tif ( isMultiline ) {\n\t\treturn replace( value, /\\n+/g, LINE_SEPARATOR );\n\t}\n\n\treturn replace( value, new RegExp( LINE_SEPARATOR, 'g' ), '\\n' );\n}\n\nexport function usePasteHandler( props ) {\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction _onPaste( event ) {\n\t\t\tconst {\n\t\t\t\tisSelected,\n\t\t\t\tdisableFormats,\n\t\t\t\tonChange,\n\t\t\t\tvalue,\n\t\t\t\tformatTypes,\n\t\t\t\ttagName,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonSplitMiddle,\n\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\tmultilineTag,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t\tpastePlainText,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { clipboardData } = event;\n\n\t\t\tlet plainText = '';\n\t\t\tlet html = '';\n\n\t\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t\t// arguments first, then fallback to `Text` if they fail.\n\t\t\ttry {\n\t\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t\t} catch ( error1 ) {\n\t\t\t\ttry {\n\t\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t\t} catch ( error2 ) {\n\t\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t\t// behaviour.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove Windows-specific metadata appended within copied HTML text.\n\t\t\thtml = removeWindowsFragments( html );\n\n\t\t\t// Strip meta tag.\n\t\t\thtml = removeCharsetMetaTag( html );\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\t\tif ( disableFormats ) {\n\t\t\t\tonChange( insert( value, plainText ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumlator === value ) {\n\t\t\t\t\t\taccumlator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst files = [ ...getFilesFromDataTransfer( clipboardData ) ];\n\t\t\tconst isInternal = clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t\t// without filtering the data. The filters are only meant for externally\n\t\t\t// pasted content and remove inline styles.\n\t\t\tif ( isInternal ) {\n\t\t\t\tconst pastedMultilineTag =\n\t\t\t\t\tclipboardData.getData( 'rich-text-multi-line-tag' ) ||\n\t\t\t\t\tundefined;\n\t\t\t\tlet pastedValue = create( {\n\t\t\t\t\thtml,\n\t\t\t\t\tmultilineTag: pastedMultilineTag,\n\t\t\t\t\tmultilineWrapperTags:\n\t\t\t\t\t\tpastedMultilineTag === 'li'\n\t\t\t\t\t\t\t? [ 'ul', 'ol' ]\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\t\t\t\tpastedValue = adjustLines( pastedValue, !! multilineTag );\n\t\t\t\taddActiveFormats( pastedValue, value.activeFormats );\n\t\t\t\tonChange( insert( value, pastedValue ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( pastePlainText ) {\n\t\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Process any attached files, unless we infer that the files in\n\t\t\t// question are redundant \"screenshots\" of the actual HTML payload,\n\t\t\t// as created by certain office-type programs.\n\t\t\t//\n\t\t\t// @see shouldDismissPastedFiles\n\t\t\tif (\n\t\t\t\tfiles?.length &&\n\t\t\t\t! shouldDismissPastedFiles( files, html, plainText )\n\t\t\t) {\n\t\t\t\tconst content = pasteHandler( {\n\t\t\t\t\tHTML: filePasteHandler( files ),\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\ttagName,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\n\t\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\twindow.console.log( 'Received items:\\n\\n', files );\n\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet mode = onReplace && onSplit ? 'AUTO' : 'INLINE';\n\n\t\t\t// Force the blocks mode when the user is pasting\n\t\t\t// on a new line & the content resembles a shortcode.\n\t\t\t// Otherwise it's going to be detected as inline\n\t\t\t// and the shortcode won't be replaced.\n\t\t\tif (\n\t\t\t\tmode === 'AUTO' &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisShortcode( plainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisURL( plainText.trim() )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tconst content = pasteHandler( {\n\t\t\t\tHTML: html,\n\t\t\t\tplainText,\n\t\t\t\tmode,\n\t\t\t\ttagName,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tlet valueToInsert = create( { html: content } );\n\n\t\t\t\t// If the content should be multiline, we should process text\n\t\t\t\t// separated by a line break as separate lines.\n\t\t\t\tvalueToInsert = adjustLines( valueToInsert, !! multilineTag );\n\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t} else if ( content.length > 0 ) {\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'paste', _onPaste );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'paste', _onPaste );\n\t\t};\n\t}, [] );\n}\n\n/**\n * Normalizes a given string of HTML to remove the Windows-specific \"Fragment\"\n * comments and any preceeding and trailing content.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startStr = '<!--StartFragment-->';\n\tconst startIdx = html.indexOf( startStr );\n\tif ( startIdx > -1 ) {\n\t\thtml = html.substring( startIdx + startStr.length );\n\t} else {\n\t\t// No point looking for EndFragment\n\t\treturn html;\n\t}\n\n\tconst endStr = '<!--EndFragment-->';\n\tconst endIdx = html.indexOf( endStr );\n\tif ( endIdx > -1 ) {\n\t\thtml = html.substring( 0, endIdx );\n\t}\n\n\treturn html;\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n"]}
|
|
@@ -32,6 +32,11 @@ function Warning(_ref) {
|
|
|
32
32
|
secondaryActions
|
|
33
33
|
} = _ref;
|
|
34
34
|
return (0, _element.createElement)("div", {
|
|
35
|
+
style: {
|
|
36
|
+
display: 'contents',
|
|
37
|
+
all: 'initial'
|
|
38
|
+
}
|
|
39
|
+
}, (0, _element.createElement)("div", {
|
|
35
40
|
className: (0, _classnames.default)(className, 'block-editor-warning')
|
|
36
41
|
}, (0, _element.createElement)("div", {
|
|
37
42
|
className: "block-editor-warning__contents"
|
|
@@ -54,7 +59,7 @@ function Warning(_ref) {
|
|
|
54
59
|
}, () => (0, _element.createElement)(_components.MenuGroup, null, secondaryActions.map((item, pos) => (0, _element.createElement)(_components.MenuItem, {
|
|
55
60
|
onClick: item.onClick,
|
|
56
61
|
key: pos
|
|
57
|
-
}, item.title)))))));
|
|
62
|
+
}, item.title))))))));
|
|
58
63
|
}
|
|
59
64
|
/**
|
|
60
65
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["Warning","className","actions","children","secondaryActions","Children","count","map","action","i","moreHorizontal","position","item","pos","onClick","title"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,OAAT,OAAuE;AAAA,MAArD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA;AAAhC,GAAqD;AACtE,SACC;AAAK,IAAA,SAAS,EAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["Warning","className","actions","children","secondaryActions","display","all","Children","count","map","action","i","moreHorizontal","position","item","pos","onClick","title"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,OAAT,OAAuE;AAAA,MAArD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA;AAAhC,GAAqD;AACtE,SACC;AAAK,IAAA,KAAK,EAAG;AAAEC,MAAAA,OAAO,EAAE,UAAX;AAAuBC,MAAAA,GAAG,EAAE;AAA5B;AAAb,KACC;AAAK,IAAA,SAAS,EAAG,yBAAYL,SAAZ,EAAuB,sBAAvB;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,SAAS,EAAC;AAAb,KACGE,QADH,CADD,EAKG,CAAEI,kBAASC,KAAT,CAAgBN,OAAhB,IAA4B,CAA5B,IAAiCE,gBAAnC,KACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGG,kBAASC,KAAT,CAAgBN,OAAhB,IAA4B,CAA5B,IACDK,kBAASE,GAAT,CAAcP,OAAd,EAAuB,CAAEQ,MAAF,EAAUC,CAAV,KACtB;AACC,IAAA,GAAG,EAAGA,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,MAJH,CADD,CAFF,EAUGN,gBAAgB,IACjB,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAGQ,qBAFR;AAGC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAHT;AAIC,IAAA,YAAY,EAAG;AACdC,MAAAA,QAAQ,EAAE,aADI;AAEdZ,MAAAA,SAAS,EACR;AAHa,KAJhB;AASC,IAAA,OAAO;AATR,KAWG,MACD,4BAAC,qBAAD,QACGG,gBAAgB,CAACK,GAAjB,CACD,CAAEK,IAAF,EAAQC,GAAR,KACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAGD,IAAI,CAACE,OADhB;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGD,IAAI,CAACG,KAJR,CAFA,CADH,CAZF,CAXF,CANF,CADD,CADD,CADD;AAqDA;AAED;AACA;AACA;;;eACejB,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div style={ { display: 'contents', all: 'initial' } }>\n\t\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t\t<p className=\"block-editor-warning__message\">\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</p>\n\n\t\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</DropdownMenu>\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</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
|
|
@@ -133,7 +133,7 @@ const useIsDimensionsDisabled = function () {
|
|
|
133
133
|
return gapDisabled && paddingDisabled && marginDisabled;
|
|
134
134
|
};
|
|
135
135
|
/**
|
|
136
|
-
* Custom hook to retrieve which padding/margin is supported
|
|
136
|
+
* Custom hook to retrieve which padding/margin/blockGap is supported
|
|
137
137
|
* e.g. top, right, bottom or left.
|
|
138
138
|
*
|
|
139
139
|
* Sides are opted into by default. It is only if a specific side is set to
|
|
@@ -142,18 +142,28 @@ const useIsDimensionsDisabled = function () {
|
|
|
142
142
|
* @param {string} blockName Block name.
|
|
143
143
|
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
|
144
144
|
*
|
|
145
|
-
* @return {
|
|
145
|
+
* @return {?string[]} Strings representing the custom sides available.
|
|
146
146
|
*/
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
function useCustomSides(blockName, feature) {
|
|
150
|
+
var _support$feature;
|
|
151
|
+
|
|
150
152
|
const support = (0, _blocks.getBlockSupport)(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
|
|
151
153
|
|
|
152
154
|
if (!support || typeof support[feature] === 'boolean') {
|
|
153
155
|
return;
|
|
154
|
-
}
|
|
156
|
+
} // Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
|
|
157
|
+
|
|
155
158
|
|
|
156
|
-
|
|
159
|
+
if (Array.isArray(support[feature])) {
|
|
160
|
+
return support[feature];
|
|
161
|
+
} // Finally, attempt to return `.sides` if the setting is an object.
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if ((_support$feature = support[feature]) !== null && _support$feature !== void 0 && _support$feature.sides) {
|
|
165
|
+
return support[feature].sides;
|
|
166
|
+
}
|
|
157
167
|
}
|
|
158
168
|
/**
|
|
159
169
|
* Custom hook to determine whether the sides configured in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/dimensions.js"],"names":["SPACING_SUPPORT_KEY","ALL_SIDES","AXIAL_SIDES","DimensionsPanel","props","isGapDisabled","isPaddingDisabled","isMarginDisabled","isDisabled","useIsDimensionsDisabled","isSupported","hasDimensionsSupport","name","defaultSpacingControls","createResetAllFilter","attribute","newAttributes","style","spacing","undefined","padding","clientId","margin","blockGap","blockName","Platform","OS","gapDisabled","paddingDisabled","marginDisabled","useCustomSides","feature","support","useIsDimensionsSupportValid","sides","some","side","includes","console","warn"],"mappings":";;;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAOA;;AAOA;;AA1BA;AACA;AACA;;AAMA;AACA;AACA;AAwBO,MAAMA,mBAAmB,GAAG,SAA5B;;AACA,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;;AACA,MAAMC,WAAW,GAAG,CAAE,UAAF,EAAc,YAAd,CAApB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,aAAa,GAAG,2BAAkBD,KAAlB,CAAtB;AACA,QAAME,iBAAiB,GAAG,mCAAsBF,KAAtB,CAA1B;AACA,QAAMG,gBAAgB,GAAG,iCAAqBH,KAArB,CAAzB;AACA,QAAMI,UAAU,GAAGC,uBAAuB,CAAEL,KAAF,CAA1C;AACA,QAAMM,WAAW,GAAGC,oBAAoB,CAAEP,KAAK,CAACQ,IAAR,CAAxC;;AAEA,MAAKJ,UAAU,IAAI,CAAEE,WAArB,EAAmC;AAClC,WAAO,IAAP;AACA;;AAED,QAAMG,sBAAsB,GAAG,6BAAiBT,KAAK,CAACQ,IAAvB,EAA6B,CAC3DZ,mBAD2D,EAE3D,+BAF2D,CAA7B,CAA/B;;AAKA,QAAMc,oBAAoB,GAAKC,SAAF,IAAmBC,aAAF;AAAA;;AAAA,WAAuB,EACpE,GAAGA,aADiE;AAEpEC,MAAAA,KAAK,EAAE,EACN,GAAGD,a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D,EAA2D;AACjE,QAAMG,KAAK,GAAGJ,cAAc,CAAEN,SAAF,EAAaO,OAAb,CAA5B;;AAEA,MACCG,KAAK,IACLA,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYnC,SAAS,CAACoC,QAAV,CAAoBD,IAApB,CAAxB,CADA,IAEAF,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYlC,WAAW,CAACmC,QAAZ,CAAsBD,IAAtB,CAAxB,CAHD,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAOR,OAAS,qBAAqBP,SAAW,0EADlD;AAGA,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tGapEdit,\n\thasGapSupport,\n\thasGapValue,\n\tresetGap,\n\tuseIsGapDisabled,\n} from './gap';\nimport {\n\tMarginEdit,\n\thasMarginSupport,\n\thasMarginValue,\n\tresetMargin,\n\tuseIsMarginDisabled,\n} from './margin';\nimport {\n\tPaddingEdit,\n\thasPaddingSupport,\n\thasPaddingValue,\n\tresetPadding,\n\tuseIsPaddingDisabled,\n} from './padding';\n\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\n/**\n * Inspector controls for dimensions support.\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Inspector controls for spacing support features.\n */\nexport function DimensionsPanel( props ) {\n\tconst isGapDisabled = useIsGapDisabled( props );\n\tconst isPaddingDisabled = useIsPaddingDisabled( props );\n\tconst isMarginDisabled = useIsMarginDisabled( props );\n\tconst isDisabled = useIsDimensionsDisabled( props );\n\tconst isSupported = hasDimensionsSupport( props.name );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultSpacingControls = getBlockSupport( props.name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\tspacing: {\n\t\t\t\t...newAttributes.style?.spacing,\n\t\t\t\t[ attribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"dimensions\">\n\t\t\t{ ! isPaddingDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasPaddingValue( props ) }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tonDeselect={ () => resetPadding( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'padding' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.padding }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<PaddingEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isMarginDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasMarginValue( props ) }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tonDeselect={ () => resetMargin( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'margin' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.margin }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<MarginEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isGapDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasGapValue( props ) }\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\tonDeselect={ () => resetGap( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'blockGap' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.blockGap }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<GapEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is dimensions related block support.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\thasGapSupport( blockName ) ||\n\t\thasPaddingSupport( blockName ) ||\n\t\thasMarginSupport( blockName )\n\t);\n}\n\n/**\n * Determines whether dimensions support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} If spacing support is completely disabled.\n */\nconst useIsDimensionsDisabled = ( props = {} ) => {\n\tconst gapDisabled = useIsGapDisabled( props );\n\tconst paddingDisabled = useIsPaddingDisabled( props );\n\tconst marginDisabled = useIsMarginDisabled( props );\n\n\treturn gapDisabled && paddingDisabled && marginDisabled;\n};\n\n/**\n * Custom hook to retrieve which padding/margin is supported\n * e.g. top, right, bottom or left.\n *\n * Sides are opted into by default. It is only if a specific side is set to\n * false that it is omitted.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {Object} Sides supporting custom margin.\n */\nexport function useCustomSides( blockName, feature ) {\n\tconst support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );\n\n\t// Skip when setting is boolean as theme isn't setting arbitrary sides.\n\tif ( ! support || typeof support[ feature ] === 'boolean' ) {\n\t\treturn;\n\t}\n\n\treturn support[ feature ];\n}\n\n/**\n * Custom hook to determine whether the sides configured in the\n * block support are valid. A dimension property cannot declare\n * support for a mix of axial and individual sides.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {boolean} If the feature has a valid configuration of sides.\n */\nexport function useIsDimensionsSupportValid( blockName, feature ) {\n\tconst sides = useCustomSides( blockName, feature );\n\n\tif (\n\t\tsides &&\n\t\tsides.some( ( side ) => ALL_SIDES.includes( side ) ) &&\n\t\tsides.some( ( side ) => AXIAL_SIDES.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support both axial and arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/dimensions.js"],"names":["SPACING_SUPPORT_KEY","ALL_SIDES","AXIAL_SIDES","DimensionsPanel","props","isGapDisabled","isPaddingDisabled","isMarginDisabled","isDisabled","useIsDimensionsDisabled","isSupported","hasDimensionsSupport","name","defaultSpacingControls","createResetAllFilter","attribute","newAttributes","style","spacing","undefined","padding","clientId","margin","blockGap","blockName","Platform","OS","gapDisabled","paddingDisabled","marginDisabled","useCustomSides","feature","support","Array","isArray","sides","useIsDimensionsSupportValid","some","side","includes","console","warn"],"mappings":";;;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAOA;;AAOA;;AA1BA;AACA;AACA;;AAMA;AACA;AACA;AAwBO,MAAMA,mBAAmB,GAAG,SAA5B;;AACA,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;;AACA,MAAMC,WAAW,GAAG,CAAE,UAAF,EAAc,YAAd,CAApB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,aAAa,GAAG,2BAAkBD,KAAlB,CAAtB;AACA,QAAME,iBAAiB,GAAG,mCAAsBF,KAAtB,CAA1B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,SAAOuB,WAAW,IAAIC,eAAf,IAAkCC,cAAzC;AACA,CAND;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,CAAyBN,SAAzB,EAAoCO,OAApC,EAA8C;AAAA;;AACpD,QAAMC,OAAO,GAAG,6BAAiBR,SAAjB,EAA4BxB,mBAA5B,CAAhB,CADoD,CAGpD;;AACA,MAAK,CAAEgC,OAAF,IAAa,OAAOA,OAAO,CAAED,OAAF,CAAd,KAA8B,SAAhD,EAA4D;AAC3D;AACA,GANmD,CAQpD;;;AACA,MAAKE,KAAK,CAACC,OAAN,CAAeF,OAAO,CAAED,OAAF,CAAtB,CAAL,EAA2C;AAC1C,WAAOC,OAAO,CAAED,OAAF,CAAd;AACA,GAXmD,CAapD;;;AACA,0BAAKC,OAAO,CAAED,OAAF,CAAZ,6CAAK,iBAAoBI,KAAzB,EAAiC;AAChC,WAAOH,OAAO,CAAED,OAAF,CAAP,CAAmBI,KAA1B;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,2BAAT,CAAsCZ,SAAtC,EAAiDO,OAAjD,EAA2D;AACjE,QAAMI,KAAK,GAAGL,cAAc,CAAEN,SAAF,EAAaO,OAAb,CAA5B;;AAEA,MACCI,KAAK,IACLA,KAAK,CAACE,IAAN,CAAcC,IAAF,IAAYrC,SAAS,CAACsC,QAAV,CAAoBD,IAApB,CAAxB,CADA,IAEAH,KAAK,CAACE,IAAN,CAAcC,IAAF,IAAYpC,WAAW,CAACqC,QAAZ,CAAsBD,IAAtB,CAAxB,CAHD,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAOV,OAAS,qBAAqBP,SAAW,0EADlD;AAGA,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tGapEdit,\n\thasGapSupport,\n\thasGapValue,\n\tresetGap,\n\tuseIsGapDisabled,\n} from './gap';\nimport {\n\tMarginEdit,\n\thasMarginSupport,\n\thasMarginValue,\n\tresetMargin,\n\tuseIsMarginDisabled,\n} from './margin';\nimport {\n\tPaddingEdit,\n\thasPaddingSupport,\n\thasPaddingValue,\n\tresetPadding,\n\tuseIsPaddingDisabled,\n} from './padding';\n\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\n/**\n * Inspector controls for dimensions support.\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Inspector controls for spacing support features.\n */\nexport function DimensionsPanel( props ) {\n\tconst isGapDisabled = useIsGapDisabled( props );\n\tconst isPaddingDisabled = useIsPaddingDisabled( props );\n\tconst isMarginDisabled = useIsMarginDisabled( props );\n\tconst isDisabled = useIsDimensionsDisabled( props );\n\tconst isSupported = hasDimensionsSupport( props.name );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultSpacingControls = getBlockSupport( props.name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\tspacing: {\n\t\t\t\t...newAttributes.style?.spacing,\n\t\t\t\t[ attribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"dimensions\">\n\t\t\t{ ! isPaddingDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasPaddingValue( props ) }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tonDeselect={ () => resetPadding( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'padding' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.padding }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<PaddingEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isMarginDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasMarginValue( props ) }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tonDeselect={ () => resetMargin( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'margin' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.margin }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<MarginEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isGapDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasGapValue( props ) }\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\tonDeselect={ () => resetGap( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'blockGap' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.blockGap }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<GapEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is dimensions related block support.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\thasGapSupport( blockName ) ||\n\t\thasPaddingSupport( blockName ) ||\n\t\thasMarginSupport( blockName )\n\t);\n}\n\n/**\n * Determines whether dimensions support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} If spacing support is completely disabled.\n */\nconst useIsDimensionsDisabled = ( props = {} ) => {\n\tconst gapDisabled = useIsGapDisabled( props );\n\tconst paddingDisabled = useIsPaddingDisabled( props );\n\tconst marginDisabled = useIsMarginDisabled( props );\n\n\treturn gapDisabled && paddingDisabled && marginDisabled;\n};\n\n/**\n * Custom hook to retrieve which padding/margin/blockGap is supported\n * e.g. top, right, bottom or left.\n *\n * Sides are opted into by default. It is only if a specific side is set to\n * false that it is omitted.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {?string[]} Strings representing the custom sides available.\n */\nexport function useCustomSides( blockName, feature ) {\n\tconst support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );\n\n\t// Skip when setting is boolean as theme isn't setting arbitrary sides.\n\tif ( ! support || typeof support[ feature ] === 'boolean' ) {\n\t\treturn;\n\t}\n\n\t// Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).\n\tif ( Array.isArray( support[ feature ] ) ) {\n\t\treturn support[ feature ];\n\t}\n\n\t// Finally, attempt to return `.sides` if the setting is an object.\n\tif ( support[ feature ]?.sides ) {\n\t\treturn support[ feature ].sides;\n\t}\n}\n\n/**\n * Custom hook to determine whether the sides configured in the\n * block support are valid. A dimension property cannot declare\n * support for a mix of axial and individual sides.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {boolean} If the feature has a valid configuration of sides.\n */\nexport function useIsDimensionsSupportValid( blockName, feature ) {\n\tconst sides = useCustomSides( blockName, feature );\n\n\tif (\n\t\tsides &&\n\t\tsides.some( ( side ) => ALL_SIDES.includes( side ) ) &&\n\t\tsides.some( ( side ) => AXIAL_SIDES.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support both axial and arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n"]}
|
package/build/hooks/layout.js
CHANGED
|
@@ -52,6 +52,42 @@ var _layouts = require("../layouts");
|
|
|
52
52
|
* Internal dependencies
|
|
53
53
|
*/
|
|
54
54
|
const layoutBlockSupportKey = '__experimentalLayout';
|
|
55
|
+
/**
|
|
56
|
+
* Generates the utility classnames for the given blocks layout attributes.
|
|
57
|
+
* This method was primarily added to reintroduce classnames that were removed
|
|
58
|
+
* in the 5.9 release (https://github.com/WordPress/gutenberg/issues/38719), rather
|
|
59
|
+
* than providing an extensive list of all possible layout classes. The plan is to
|
|
60
|
+
* have the style engine generate a more extensive list of utility classnames which
|
|
61
|
+
* will then replace this method.
|
|
62
|
+
*
|
|
63
|
+
* @param { Array } attributes Array of block attributes.
|
|
64
|
+
*
|
|
65
|
+
* @return { Array } Array of CSS classname strings.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
function getLayoutClasses(attributes) {
|
|
69
|
+
var _attributes$layout, _attributes$layout2, _attributes$layout3;
|
|
70
|
+
|
|
71
|
+
const layoutClassnames = [];
|
|
72
|
+
|
|
73
|
+
if (!attributes.layout) {
|
|
74
|
+
return layoutClassnames;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (attributes !== null && attributes !== void 0 && (_attributes$layout = attributes.layout) !== null && _attributes$layout !== void 0 && _attributes$layout.orientation) {
|
|
78
|
+
layoutClassnames.push(`is-${(0, _lodash.kebabCase)(attributes.layout.orientation)}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (attributes !== null && attributes !== void 0 && (_attributes$layout2 = attributes.layout) !== null && _attributes$layout2 !== void 0 && _attributes$layout2.justifyContent) {
|
|
82
|
+
layoutClassnames.push(`is-content-justification-${(0, _lodash.kebabCase)(attributes.layout.justifyContent)}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (attributes !== null && attributes !== void 0 && (_attributes$layout3 = attributes.layout) !== null && _attributes$layout3 !== void 0 && _attributes$layout3.flexWrap && attributes.layout.flexWrap === 'nowrap') {
|
|
86
|
+
layoutClassnames.push('is-nowrap');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return layoutClassnames;
|
|
90
|
+
}
|
|
55
91
|
|
|
56
92
|
function LayoutPanel(_ref) {
|
|
57
93
|
let {
|
|
@@ -222,9 +258,10 @@ const withLayoutStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock
|
|
|
222
258
|
default: defaultBlockLayout
|
|
223
259
|
} = (0, _blocks.getBlockSupport)(name, layoutBlockSupportKey) || {};
|
|
224
260
|
const usedLayout = layout !== null && layout !== void 0 && layout.inherit ? defaultThemeLayout : layout || defaultBlockLayout || {};
|
|
261
|
+
const layoutClasses = shouldRenderLayoutStyles ? getLayoutClasses(attributes) : null;
|
|
225
262
|
const className = (0, _classnames.default)(props === null || props === void 0 ? void 0 : props.className, {
|
|
226
263
|
[`wp-container-${id}`]: shouldRenderLayoutStyles
|
|
227
|
-
});
|
|
264
|
+
}, layoutClasses);
|
|
228
265
|
return (0, _element.createElement)(_element.Fragment, null, shouldRenderLayoutStyles && element && (0, _element.createPortal)((0, _element.createElement)(_layout.LayoutStyle, {
|
|
229
266
|
blockName: name,
|
|
230
267
|
selector: `.wp-container-${id}`,
|