@wordpress/block-editor 13.0.0 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-bindings-toolbar-indicator/index.js +1 -1
- package/build/components/block-bindings-toolbar-indicator/index.js.map +1 -1
- package/build/components/button-block-appender/index.js +4 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +3 -3
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -3
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +3 -2
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -0
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +9 -12
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +22 -3
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +2 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-bindings-toolbar-indicator/index.js +1 -1
- package/build-module/components/block-bindings-toolbar-indicator/index.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +4 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +4 -4
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -3
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +4 -3
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -0
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +9 -12
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +23 -4
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +2 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +1 -1
- package/build-style/content.css +1 -1
- package/build-style/style-rtl.css +6 -2
- package/build-style/style.css +6 -2
- package/package.json +31 -31
- package/src/components/block-bindings-toolbar-indicator/index.js +3 -1
- package/src/components/block-canvas/style.scss +2 -2
- package/src/components/block-variation-picker/content.scss +1 -1
- package/src/components/button-block-appender/index.js +2 -0
- package/src/components/global-styles/background-panel.js +13 -4
- package/src/components/global-styles/hooks.js +1 -0
- package/src/components/inserter/block-types-tab.js +0 -1
- package/src/components/inserter/hooks/use-block-types-state.js +10 -5
- package/src/components/inserter/style.scss +4 -0
- package/src/components/link-control/link-preview.js +1 -0
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +14 -4
- package/src/components/writing-flow/use-clipboard-handler.js +29 -7
- package/src/store/actions.js +1 -1
- package/src/store/selectors.js +3 -1
|
@@ -131,6 +131,7 @@ export default function LinkPreview({
|
|
|
131
131
|
// Ends up looking like "Copy link: https://example.com".
|
|
132
132
|
isEmptyURL || showIconLabels ? '' : ': ' + value.url),
|
|
133
133
|
ref: ref,
|
|
134
|
+
__experimentalIsFocusable: true,
|
|
134
135
|
disabled: isEmptyURL,
|
|
135
136
|
size: "compact"
|
|
136
137
|
}), /*#__PURE__*/_jsx(ViewerSlot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","__","sprintf","Button","ExternalLink","__experimentalTruncate","Truncate","useCopyToClipboard","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","copySmall","__unstableStripHTML","stripHTML","useDispatch","useSelect","store","noticesStore","preferencesStore","ViewerSlot","useRichUrlData","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","showIconLabels","select","get","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","isEmptyURL","displayTitle","title","icon","src","alt","size","createNotice","ref","isDismissible","type","className","children","href","numberOfLines","label","onClick","disabled","fillProps"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit, copySmall } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n} ) {\n\tconst showIconLabels = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showIconLabels' ),\n\t\t[]\n\t);\n\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 24 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( value.url, () => {\n\t\tcreateNotice( 'info', __( 'Link copied to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ clsx( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\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</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit link' ) }\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).\n\t\t\t\t\t\t__( 'Copy link%s' ), // Ends up looking like \"Copy link: https://example.com\".\n\t\t\t\t\t\tisEmptyURL || showIconLabels ? '' : ': ' + value.url\n\t\t\t\t\t) }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tdisabled={ isEmptyURL }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,MAAM,EACNC,YAAY,EACZC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,gBAAgB;AACnE,SAASC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,EAAEC,SAAS,QAAQ,kBAAkB;AAC9E,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,SAASC,UAAU,QAAQ,eAAe;AAE1C,OAAOC,cAAc,MAAM,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEjD,eAAe,SAASC,WAAWA,CAAE;EACpCC,KAAK;EACLC,WAAW;EACXC,eAAe,GAAG,KAAK;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tB,IAAA;cAAMkC,SAAS,EAAC,6CAA6C;cAAAC,QAAA,eAC5DnC,IAAA,CAACpB,QAAQ;gBAACyD,aAAa,EAAG,CAAG;gBAAAF,QAAA,EAC1Bb;cAAU,CACH;YAAC,CACN,CACN;UAAA,CACA,CAAC,gBAEHtB,IAAA;YAAMkC,SAAS,EAAC,qDAAqD;YAAAC,QAAA,EAClE5D,EAAE,CAAE,eAAgB;UAAC,CAClB;QACN,CACI,CAAC;MAAA,CACF,CAAC,eACPyB,IAAA,CAACvB,MAAM;QACNiD,IAAI,EAAGtC,IAAM;QACbkD,KAAK,EAAG/D,EAAE,CAAE,WAAY,CAAG;QAC3BgE,OAAO,EAAGhC,WAAa;QACvBsB,IAAI,EAAC;MAAS,CACd,CAAC,EACApB,gBAAgB,iBACjBT,IAAA,CAACvB,MAAM;QACNiD,IAAI,EAAGvC,OAAS;QAChBmD,KAAK,EAAG/D,EAAE,CAAE,aAAc,CAAG;QAC7BgE,OAAO,EAAG7B,QAAU;QACpBmB,IAAI,EAAC;MAAS,CACd,CACD,eACD7B,IAAA,CAACvB,MAAM;QACNiD,IAAI,EAAGrC,SAAW;QAClBiD,KAAK,EAAG9D,OAAO;QACd;QACAD,EAAE,CAAE,aAAc,CAAC;QAAE;QACrBgD,UAAU,IAAIZ,cAAc,GAAG,EAAE,GAAG,IAAI,GAAGL,KAAK,CAACS,GAClD,CAAG;QACHgB,GAAG,EAAGA,GAAK;QACXS,QAAQ,
|
|
1
|
+
{"version":3,"names":["clsx","__","sprintf","Button","ExternalLink","__experimentalTruncate","Truncate","useCopyToClipboard","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","copySmall","__unstableStripHTML","stripHTML","useDispatch","useSelect","store","noticesStore","preferencesStore","ViewerSlot","useRichUrlData","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","showIconLabels","select","get","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","isEmptyURL","displayTitle","title","icon","src","alt","size","createNotice","ref","isDismissible","type","className","children","href","numberOfLines","label","onClick","__experimentalIsFocusable","disabled","fillProps"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit, copySmall } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n} ) {\n\tconst showIconLabels = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showIconLabels' ),\n\t\t[]\n\t);\n\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 24 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( value.url, () => {\n\t\tcreateNotice( 'info', __( 'Link copied to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ clsx( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\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</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit link' ) }\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).\n\t\t\t\t\t\t__( 'Copy link%s' ), // Ends up looking like \"Copy link: https://example.com\".\n\t\t\t\t\t\tisEmptyURL || showIconLabels ? '' : ': ' + value.url\n\t\t\t\t\t) }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t\tdisabled={ isEmptyURL }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t<ViewerSlot f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GtC,IAAM;QACbkD,KAAK,EAAG/D,EAAE,CAAE,WAAY,CAAG;QAC3BgE,OAAO,EAAGhC,WAAa;QACvBsB,IAAI,EAAC;MAAS,CACd,CAAC,EACApB,gBAAgB,iBACjBT,IAAA,CAACvB,MAAM;QACNiD,IAAI,EAAGvC,OAAS;QAChBmD,KAAK,EAAG/D,EAAE,CAAE,aAAc,CAAG;QAC7BgE,OAAO,EAAG7B,QAAU;QACpBmB,IAAI,EAAC;MAAS,CACd,CACD,eACD7B,IAAA,CAACvB,MAAM;QACNiD,IAAI,EAAGrC,SAAW;QAClBiD,KAAK,EAAG9D,OAAO;QACd;QACAD,EAAE,CAAE,aAAc,CAAC;QAAE;QACrBgD,UAAU,IAAIZ,cAAc,GAAG,EAAE,GAAG,IAAI,GAAGL,KAAK,CAACS,GAClD,CAAG;QACHgB,GAAG,EAAGA,GAAK;QACXS,yBAAyB;QACzBC,QAAQ,EAAGlB,UAAY;QACvBM,IAAI,EAAC;MAAS,CACd,CAAC,eACF7B,IAAA,CAACH,UAAU;QAAC6C,SAAS,EAAGpC;MAAO,CAAE,CAAC;IAAA,CAC9B;EAAC,CACF,CAAC;AAER","ignoreList":[]}
|
|
@@ -107,7 +107,7 @@ const LinkControlSearchInput = forwardRef(({
|
|
|
107
107
|
className: className,
|
|
108
108
|
value: value,
|
|
109
109
|
onChange: onInputChange,
|
|
110
|
-
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : __('Search or type
|
|
110
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : __('Search or type URL'),
|
|
111
111
|
__experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null,
|
|
112
112
|
__experimentalFetchLinkSuggestions: searchHandler,
|
|
113
113
|
__experimentalHandleURLSuggestions: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","jsx","_jsx","jsxs","_jsxs","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","ref","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","id","restLinkProps","disableSuggestions","__nextHasNoMarginBottom","label","__experimentalRenderSuggestions","__experimentalFetchLinkSuggestions","__experimentalHandleURLSuggestions","__experimentalShowInitialSuggestions","onSubmit","event","hasSuggestion","trim","preventDefault"],"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst instanceId = useInstanceId( LinkControlSearchInput );\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\tinstanceId,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tconst { id, url, ...restLinkProps } = currentLink ?? {};\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...restLinkProps, ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type
|
|
1
|
+
{"version":3,"names":["useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","jsx","_jsx","jsxs","_jsxs","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","ref","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","id","restLinkProps","disableSuggestions","__nextHasNoMarginBottom","label","__experimentalRenderSuggestions","__experimentalFetchLinkSuggestions","__experimentalHandleURLSuggestions","__experimentalShowInitialSuggestions","onSubmit","event","hasSuggestion","trim","preventDefault"],"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst instanceId = useInstanceId( LinkControlSearchInput );\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\tinstanceId,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tconst { id, url, ...restLinkProps } = currentLink ?? {};\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...restLinkProps, ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type URL' ) }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tref={ ref }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;AACzD,SAASC,EAAE,QAAQ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ACnCA,UACD,CAAC;IACF;EACD,CAAC;EAED,oBACCjC,KAAA;IAAKS,SAAS,EAAC,mDAAmD;IAAAF,QAAA,gBACjET,IAAA,CAACL,QAAQ;MACRsD,kBAAkB,EAAGvC,WAAW,EAAEgC,GAAG,KAAKlC,KAAO;MACjD0C,uBAAuB;MACvBC,KAAK,EAAGzD,EAAE,CAAE,MAAO,CAAG;MACtBgC,mBAAmB,EAAGA,mBAAqB;MAC3Cf,SAAS,EAAGA,SAAW;MACvBH,KAAK,EAAGA,KAAO;MACfO,QAAQ,EAAGkB,aAAe;MAC1BrB,WAAW,EAAGA,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAIlB,EAAE,CAAE,oBAAqB,CAAG;MACzD0D,+BAA+B,EAC9BnC,eAAe,GAAGmB,uBAAuB,GAAG,IAC5C;MACDiB,kCAAkC,EAAGxB,aAAe;MACpDyB,kCAAkC;MAClCC,oCAAoC,EACnCjC,sBACA;MACDkC,QAAQ,EAAGA,CAAErB,UAAU,EAAEsB,KAAK,KAAM;QACnC,MAAMC,aAAa,GAAGvB,UAAU,IAAIJ,iBAAiB;;QAErD;QACA;QACA,IAAK,CAAE2B,aAAa,IAAI,CAAElD,KAAK,EAAEmD,IAAI,CAAC,CAAC,EAAEb,MAAM,EAAG;UACjDW,KAAK,CAACG,cAAc,CAAC,CAAC;QACvB,CAAC,MAAM;UACNtB,oBAAoB,CACnBoB,aAAa,IAAI;YAAEhB,GAAG,EAAElC;UAAM,CAC/B,CAAC;QACF;MACD,CAAG;MACHmB,GAAG,EAAGA;IAAK,CACX,CAAC,EACAlB,QAAQ;EAAA,CACN,CAAC;AAER,CACD,CAAC;AAED,eAAeF,sBAAsB","ignoreList":[]}
|
|
@@ -23,22 +23,19 @@ export default function useSpacingSizes() {
|
|
|
23
23
|
name: __('None'),
|
|
24
24
|
slug: '0',
|
|
25
25
|
size: 0
|
|
26
|
-
}, ...customSizes, ...themeSizes, ...defaultSizes]
|
|
26
|
+
}, ...customSizes, ...themeSizes, ...defaultSizes];
|
|
27
|
+
|
|
28
|
+
// Only sort if more than one origin has presets defined in order to
|
|
29
|
+
// preserve order for themes that don't include default presets and
|
|
30
|
+
// want a custom order.
|
|
31
|
+
if ((customSizes.length && 1) + (themeSizes.length && 1) + (defaultSizes.length && 1) > 1) {
|
|
32
|
+
sizes.sort((a, b) => compare(a.slug, b.slug));
|
|
33
|
+
}
|
|
27
34
|
return sizes.length > RANGE_CONTROL_MAX_SIZE ? [{
|
|
28
35
|
name: __('Default'),
|
|
29
36
|
slug: 'default',
|
|
30
37
|
size: undefined
|
|
31
|
-
}, ...sizes] :
|
|
32
|
-
// See https://github.com/WordPress/gutenberg/pull/44247 for reasoning
|
|
33
|
-
// to use the index as the name in the range control.
|
|
34
|
-
sizes.map(({
|
|
35
|
-
slug,
|
|
36
|
-
size
|
|
37
|
-
}, i) => ({
|
|
38
|
-
name: i,
|
|
39
|
-
slug,
|
|
40
|
-
size
|
|
41
|
-
}));
|
|
38
|
+
}, ...sizes] : sizes;
|
|
42
39
|
}, [customSizes, themeSizes, defaultSizes]);
|
|
43
40
|
}
|
|
44
41
|
//# sourceMappingURL=use-spacing-sizes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","__","useSettings","RANGE_CONTROL_MAX_SIZE","EMPTY_ARRAY","compare","Intl","Collator","numeric","useSpacingSizes","customSpacingSizes","themeSpacingSizes","defaultSpacingSizes","defaultSpacingSizesEnabled","customSizes","themeSizes","defaultSizes","sizes","name","slug","size","sort","a","b","
|
|
1
|
+
{"version":3,"names":["useMemo","__","useSettings","RANGE_CONTROL_MAX_SIZE","EMPTY_ARRAY","compare","Intl","Collator","numeric","useSpacingSizes","customSpacingSizes","themeSpacingSizes","defaultSpacingSizes","defaultSpacingSizesEnabled","customSizes","themeSizes","defaultSizes","sizes","name","slug","size","length","sort","a","b","undefined"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../use-settings';\nimport { RANGE_CONTROL_MAX_SIZE } from '../utils';\n\nconst EMPTY_ARRAY = [];\n\nconst compare = new Intl.Collator( 'und', { numeric: true } ).compare;\n\nexport default function useSpacingSizes() {\n\tconst [\n\t\tcustomSpacingSizes,\n\t\tthemeSpacingSizes,\n\t\tdefaultSpacingSizes,\n\t\tdefaultSpacingSizesEnabled,\n\t] = useSettings(\n\t\t'spacing.spacingSizes.custom',\n\t\t'spacing.spacingSizes.theme',\n\t\t'spacing.spacingSizes.default',\n\t\t'spacing.defaultSpacingSizes'\n\t);\n\n\tconst customSizes = customSpacingSizes ?? EMPTY_ARRAY;\n\n\tconst themeSizes = themeSpacingSizes ?? EMPTY_ARRAY;\n\n\tconst defaultSizes =\n\t\tdefaultSpacingSizes && defaultSpacingSizesEnabled !== false\n\t\t\t? defaultSpacingSizes\n\t\t\t: EMPTY_ARRAY;\n\n\treturn useMemo( () => {\n\t\tconst sizes = [\n\t\t\t{ name: __( 'None' ), slug: '0', size: 0 },\n\t\t\t...customSizes,\n\t\t\t...themeSizes,\n\t\t\t...defaultSizes,\n\t\t];\n\n\t\t// Only sort if more than one origin has presets defined in order to\n\t\t// preserve order for themes that don't include default presets and\n\t\t// want a custom order.\n\t\tif (\n\t\t\t( customSizes.length && 1 ) +\n\t\t\t\t( themeSizes.length && 1 ) +\n\t\t\t\t( defaultSizes.length && 1 ) >\n\t\t\t1\n\t\t) {\n\t\t\tsizes.sort( ( a, b ) => compare( a.slug, b.slug ) );\n\t\t}\n\n\t\treturn sizes.length > RANGE_CONTROL_MAX_SIZE\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: __( 'Default' ),\n\t\t\t\t\t\tslug: 'default',\n\t\t\t\t\t\tsize: undefined,\n\t\t\t\t\t},\n\t\t\t\t\t...sizes,\n\t\t\t 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ACA;MACDJ,KAAK,CAACK,IAAI,CAAE,CAAEC,CAAC,EAAEC,CAAC,KAAMnB,OAAO,CAAEkB,CAAC,CAACJ,IAAI,EAAEK,CAAC,CAACL,IAAK,CAAE,CAAC;IACpD;IAEA,OAAOF,KAAK,CAACI,MAAM,GAAGlB,sBAAsB,GACzC,CACA;MACCe,IAAI,EAAEjB,EAAE,CAAE,SAAU,CAAC;MACrBkB,IAAI,EAAE,SAAS;MACfC,IAAI,EAAEK;IACP,CAAC,EACD,GAAGR,KAAK,CACP,GACDA,KAAK;EACT,CAAC,EAAE,CAAEH,WAAW,EAAEC,UAAU,EAAEC,YAAY,CAAG,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { pasteHandler, findTransform, getBlockTransforms, hasBlockSupport } from '@wordpress/blocks';
|
|
4
|
+
import { pasteHandler, findTransform, getBlockTransforms, hasBlockSupport, switchToBlockType } from '@wordpress/blocks';
|
|
5
5
|
import { documentHasSelection, documentHasUncollapsedSelection } from '@wordpress/dom';
|
|
6
6
|
import { useDispatch, useRegistry, useSelect } from '@wordpress/data';
|
|
7
7
|
import { useRefEffect } from '@wordpress/compose';
|
|
@@ -158,10 +158,29 @@ export default function useClipboardHandler() {
|
|
|
158
158
|
}
|
|
159
159
|
const [firstSelectedClientId] = selectedBlockClientIds;
|
|
160
160
|
const rootClientId = getBlockRootClientId(firstSelectedClientId);
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
const newBlocks = [];
|
|
162
|
+
for (const block of blocks) {
|
|
163
|
+
if (canInsertBlockType(block.name, rootClientId)) {
|
|
164
|
+
newBlocks.push(block);
|
|
165
|
+
} else {
|
|
166
|
+
// If a block cannot be inserted in a root block, try
|
|
167
|
+
// converting it to that root block type and insert the
|
|
168
|
+
// inner blocks.
|
|
169
|
+
// Example: paragraphs cannot be inserted into a list,
|
|
170
|
+
// so convert the paragraphs to a list for list items.
|
|
171
|
+
const rootBlockName = getBlockName(rootClientId);
|
|
172
|
+
const switchedBlocks = block.name !== rootBlockName ? switchToBlockType(block, rootBlockName) : [block];
|
|
173
|
+
if (!switchedBlocks) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
for (const switchedBlock of switchedBlocks) {
|
|
177
|
+
for (const innerBlock of switchedBlock.innerBlocks) {
|
|
178
|
+
newBlocks.push(innerBlock);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
163
182
|
}
|
|
164
|
-
__unstableSplitSelection(
|
|
183
|
+
__unstableSplitSelection(newBlocks);
|
|
165
184
|
event.preventDefault();
|
|
166
185
|
}
|
|
167
186
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["pasteHandler","findTransform","getBlockTransforms","hasBlockSupport","documentHasSelection","documentHasUncollapsedSelection","useDispatch","useRegistry","useSelect","useRefEffect","store","blockEditorStore","useNotifyCopy","setClipboardBlocks","getPasteEventData","useClipboardHandler","registry","getBlocksByClientId","getSelectedBlockClientIds","hasMultiSelection","getSettings","getBlockName","__unstableIsFullySelected","__unstableIsSelectionCollapsed","__unstableIsSelectionMergeable","__unstableGetSelectedBlocksWithPartialSelection","canInsertBlockType","getBlockRootClientId","flashBlock","removeBlocks","replaceBlocks","__unstableDeleteSelection","__unstableExpandSelection","__unstableSplitSelection","notifyCopy","node","handler","event","defaultPrevented","selectedBlockClientIds","length","target","ownerDocument","hasSelection","type","activeElement","isContentEditable","contains","isSelectionMergeable","shouldHandleWholeBlocks","expandSelectionIsNeeded","preventDefault","blocks","head","tail","inBetweenBlocks","slice","contentEditable","__experimentalCanUserUseUnfilteredHTML","canUserUseUnfilteredHTML","isInternal","clipboardData","getData","plainText","html","files","isFullySelected","fromTransforms","reduce","accumulator","file","transformation","transform","isMatch","push","flat","HTML","mode","__deprecatedOnSplit","firstSelectedClientId","rootClientId","every","block","name","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-clipboard-handler.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useNotifyCopy } from '../../utils/use-notify-copy';\nimport { setClipboardBlocks } from './utils';\nimport { getPasteEventData } from '../../utils/pasting';\n\nexport default function useClipboardHandler() {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t\tgetBlockName,\n\t\t__unstableIsFullySelected,\n\t\t__unstableIsSelectionCollapsed,\n\t\t__unstableIsSelectionMergeable,\n\t\t__unstableGetSelectedBlocksWithPartialSelection,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tflashBlock,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableSplitSelection,\n\t} = useDispatch( blockEditorStore );\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Let native copy/paste behaviour take over in input fields.\n\t\t\t// But always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument ) &&\n\t\t\t\t\t\t ! ownerDocument.activeElement.isContentEditable;\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { activeElement } = event.target.ownerDocument;\n\n\t\t\tif ( ! node.contains( activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isSelectionMergeable = __unstableIsSelectionMergeable();\n\t\t\tconst shouldHandleWholeBlocks =\n\t\t\t\t__unstableIsSelectionCollapsed() || __unstableIsFullySelected();\n\t\t\tconst expandSelectionIsNeeded =\n\t\t\t\t! shouldHandleWholeBlocks && ! isSelectionMergeable;\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\t// If we have a partial selection that is not mergeable, just\n\t\t\t\t// expand the selection to the whole blocks.\n\t\t\t\tif ( expandSelectionIsNeeded ) {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t} else {\n\t\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\t\tlet blocks;\n\t\t\t\t\t// Check if we have partial selection.\n\t\t\t\t\tif ( shouldHandleWholeBlocks ) {\n\t\t\t\t\t\tblocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [ head, tail ] =\n\t\t\t\t\t\t\t__unstableGetSelectedBlocksWithPartialSelection();\n\t\t\t\t\t\tconst inBetweenBlocks = getBlocksByClientId(\n\t\t\t\t\t\t\tselectedBlockClientIds.slice(\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length - 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tblocks = [ head, ...inBetweenBlocks, tail ];\n\t\t\t\t\t}\n\n\t\t\t\t\tsetClipboardBlocks( event, blocks, registry );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\t// We need to also check if at the start we needed to\n\t\t\t\t// expand the selection, as in this point we might have\n\t\t\t\t// programmatically fully selected the blocks above.\n\t\t\t\tif ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {\n\t\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t\t} else {\n\t\t\t\t\tevent.target.ownerDocument.activeElement.contentEditable = false;\n\t\t\t\t\t__unstableDeleteSelection();\n\t\t\t\t}\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML:\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst isInternal =\n\t\t\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\t\t\t\tif ( isInternal ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { plainText, html, files } = getPasteEventData( event );\n\t\t\t\tconst isFullySelected = __unstableIsFullySelected();\n\t\t\t\tlet blocks = [];\n\n\t\t\t\tif ( files.length ) {\n\t\t\t\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\t\t\t\tblocks = files\n\t\t\t\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\t\tfromTransforms,\n\t\t\t\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\t\taccumulator.push(\n\t\t\t\t\t\t\t\t\ttransformation.transform( [ file ] )\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 accumulator;\n\t\t\t\t\t\t}, [] )\n\t\t\t\t\t\t.flat();\n\t\t\t\t} else {\n\t\t\t\t\tblocks = pasteHandler( {\n\t\t\t\t\t\tHTML: html,\n\t\t\t\t\t\tplainText,\n\t\t\t\t\t\tmode: isFullySelected ? 'BLOCKS' : 'AUTO',\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t// Inline paste: let rich text handle it.\n\t\t\t\tif ( typeof blocks === 'string' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isFullySelected ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\t\tblocks,\n\t\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t\t-1\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If a block doesn't support splitting, let rich text paste\n\t\t\t\t// inline.\n\t\t\t\tif (\n\t\t\t\t\t! hasMultiSelection() &&\n\t\t\t\t\t! hasBlockSupport(\n\t\t\t\t\t\tgetBlockName( selectedBlockClientIds[ 0 ] ),\n\t\t\t\t\t\t'splitting',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t) &&\n\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst [ firstSelectedClientId ] = selectedBlockClientIds;\n\t\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\t\tfirstSelectedClientId\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\t! blocks.every( ( block ) =>\n\t\t\t\t\t\tcanInsertBlockType( block.name, rootClientId )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t__unstableSplitSelection( blocks );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,YAAY,EACZC,aAAa,EACbC,kBAAkB,EAClBC,eAAe,QACT,mBAAmB;AAC1B,SACCC,oBAAoB,EACpBC,+BAA+B,QACzB,gBAAgB;AACvB,SAASC,WAAW,EAAEC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACrE,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,aAAa,QAAQ,6BAA6B;AAC3D,SAASC,kBAAkB,QAAQ,SAAS;AAC5C,SAASC,iBAAiB,QAAQ,qBAAqB;AAEvD,eAAe,SAASC,mBAAmBA,CAAA,EAAG;EAC7C,MAAMC,QAAQ,GAAGT,WAAW,CAAC,CAAC;EAC9B,MAAM;IACLU,mBAAmB;IACnBC,yBAAyB;IACzBC,iBAAiB;IACjBC,WAAW;IACXC,YAAY;IACZC,yBAAyB;IACzBC,8BAA8B;IAC9BC,8BAA8B;IAC9BC,+CAA+C;IAC/CC,kBAAkB;IAClBC;EACD,CAAC,GAAGnB,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CAACc,cAAc,CAAC,CAAC;UACtB;QACD;;QAEA;QACA;QACA,IACC,CAAEhC,iBAAiB,CAAC,CAAC,IACrB,CAAEhB,eAAe,CAChBkB,YAAY,CAAEkB,sBAAsB,CAAE,CAAC,CAAG,CAAC,EAC3C,WAAW,EACX,KACD,CAAC,IACD,CAAEF,KAAK,CAACyC,mBAAmB,EAC1B;UACD;QACD;QAEA,MAAM,CAAEC,qBAAqB,CAAE,GAAGxC,sBAAsB;QACxD,MAAMyC,YAAY,GAAGrD,oBAAoB,CACxCoD,qBACD,CAAC;QAED,IACC,CAAE3B,MAAM,CAAC6B,KAAK,CAAIC,KAAK,IACtBxD,kBAAkB,CAAEwD,KAAK,CAACC,IAAI,EAAEH,YAAa,CAC9C,CAAC,EACA;UACD;QACD;QAEA/C,wBAAwB,CAAEmB,MAAO,CAAC;QAClCf,KAAK,CAACc,cAAc,CAAC,CAAC;MACvB;IACD;IAEAhB,IAAI,CAACO,aAAa,CAAC0C,gBAAgB,CAAE,MAAM,EAAEhD,OAAQ,CAAC;IACtDD,IAAI,CAACO,aAAa,CAAC0C,gBAAgB,CAAE,KAAK,EAAEhD,OAAQ,CAAC;IACrDD,IAAI,CAACO,aAAa,CAAC0C,gBAAgB,CAAE,OAAO,EAAEhD,OAAQ,CAAC;IAEvD,OAAO,MAAM;MACZD,IAAI,CAACO,aAAa,CAAC2C,mBAAmB,CAAE,MAAM,EAAEjD,OAAQ,CAAC;MACzDD,IAAI,CAACO,aAAa,CAAC2C,mBAAmB,CAAE,KAAK,EAAEjD,OAAQ,CAAC;MACxDD,IAAI,CAACO,aAAa,CAAC2C,mBAAmB,CAAE,OAAO,EAAEjD,OAAQ,CAAC;IAC3D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["pasteHandler","findTransform","getBlockTransforms","hasBlockSupport","switchToBlockType","documentHasSelection","documentHasUncollapsedSelection","useDispatch","useRegistry","useSelect","useRefEffect","store","blockEditorStore","useNotifyCopy","setClipboardBlocks","getPasteEventData","useClipboardHandler","registry","getBlocksByClientId","getSelectedBlockClientIds","hasMultiSelection","getSettings","getBlockName","__unstableIsFullySelected","__unstableIsSelectionCollapsed","__unstableIsSelectionMergeable","__unstableGetSelectedBlocksWithPartialSelection","canInsertBlockType","getBlockRootClientId","flashBlock","removeBlocks","replaceBlocks","__unstableDeleteSelection","__unstableExpandSelection","__unstableSplitSelection","notifyCopy","node","handler","event","defaultPrevented","selectedBlockClientIds","length","target","ownerDocument","hasSelection","type","activeElement","isContentEditable","contains","isSelectionMergeable","shouldHandleWholeBlocks","expandSelectionIsNeeded","preventDefault","blocks","head","tail","inBetweenBlocks","slice","contentEditable","__experimentalCanUserUseUnfilteredHTML","canUserUseUnfilteredHTML","isInternal","clipboardData","getData","plainText","html","files","isFullySelected","fromTransforms","reduce","accumulator","file","transformation","transform","isMatch","push","flat","HTML","mode","__deprecatedOnSplit","firstSelectedClientId","rootClientId","newBlocks","block","name","rootBlockName","switchedBlocks","switchedBlock","innerBlock","innerBlocks","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-clipboard-handler.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\thasBlockSupport,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useNotifyCopy } from '../../utils/use-notify-copy';\nimport { setClipboardBlocks } from './utils';\nimport { getPasteEventData } from '../../utils/pasting';\n\nexport default function useClipboardHandler() {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t\tgetBlockName,\n\t\t__unstableIsFullySelected,\n\t\t__unstableIsSelectionCollapsed,\n\t\t__unstableIsSelectionMergeable,\n\t\t__unstableGetSelectedBlocksWithPartialSelection,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tflashBlock,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableSplitSelection,\n\t} = useDispatch( blockEditorStore );\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Let native copy/paste behaviour take over in input fields.\n\t\t\t// But always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument ) &&\n\t\t\t\t\t\t ! ownerDocument.activeElement.isContentEditable;\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { activeElement } = event.target.ownerDocument;\n\n\t\t\tif ( ! node.contains( activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isSelectionMergeable = __unstableIsSelectionMergeable();\n\t\t\tconst shouldHandleWholeBlocks =\n\t\t\t\t__unstableIsSelectionCollapsed() || __unstableIsFullySelected();\n\t\t\tconst expandSelectionIsNeeded =\n\t\t\t\t! shouldHandleWholeBlocks && ! isSelectionMergeable;\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\t// If we have a partial selection that is not mergeable, just\n\t\t\t\t// expand the selection to the whole blocks.\n\t\t\t\tif ( expandSelectionIsNeeded ) {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t} else {\n\t\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\t\tlet blocks;\n\t\t\t\t\t// Check if we have partial selection.\n\t\t\t\t\tif ( shouldHandleWholeBlocks ) {\n\t\t\t\t\t\tblocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [ head, tail ] =\n\t\t\t\t\t\t\t__unstableGetSelectedBlocksWithPartialSelection();\n\t\t\t\t\t\tconst inBetweenBlocks = getBlocksByClientId(\n\t\t\t\t\t\t\tselectedBlockClientIds.slice(\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length - 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tblocks = [ head, ...inBetweenBlocks, tail ];\n\t\t\t\t\t}\n\n\t\t\t\t\tsetClipboardBlocks( event, blocks, registry );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\t// We need to also check if at the start we needed to\n\t\t\t\t// expand the selection, as in this point we might have\n\t\t\t\t// programmatically fully selected the blocks above.\n\t\t\t\tif ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {\n\t\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t\t} else {\n\t\t\t\t\tevent.target.ownerDocument.activeElement.contentEditable = false;\n\t\t\t\t\t__unstableDeleteSelection();\n\t\t\t\t}\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML:\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst isInternal =\n\t\t\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\t\t\t\tif ( isInternal ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { plainText, html, files } = getPasteEventData( event );\n\t\t\t\tconst isFullySelected = __unstableIsFullySelected();\n\t\t\t\tlet blocks = [];\n\n\t\t\t\tif ( files.length ) {\n\t\t\t\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\t\t\t\tblocks = files\n\t\t\t\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\t\tfromTransforms,\n\t\t\t\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\t\taccumulator.push(\n\t\t\t\t\t\t\t\t\ttransformation.transform( [ file ] )\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 accumulator;\n\t\t\t\t\t\t}, [] )\n\t\t\t\t\t\t.flat();\n\t\t\t\t} else {\n\t\t\t\t\tblocks = pasteHandler( {\n\t\t\t\t\t\tHTML: html,\n\t\t\t\t\t\tplainText,\n\t\t\t\t\t\tmode: isFullySelected ? 'BLOCKS' : 'AUTO',\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t// Inline paste: let rich text handle it.\n\t\t\t\tif ( typeof blocks === 'string' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isFullySelected ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\t\tblocks,\n\t\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t\t-1\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If a block doesn't support splitting, let rich text paste\n\t\t\t\t// inline.\n\t\t\t\tif (\n\t\t\t\t\t! hasMultiSelection() &&\n\t\t\t\t\t! hasBlockSupport(\n\t\t\t\t\t\tgetBlockName( selectedBlockClientIds[ 0 ] ),\n\t\t\t\t\t\t'splitting',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t) &&\n\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst [ firstSelectedClientId ] = selectedBlockClientIds;\n\t\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\t\tfirstSelectedClientId\n\t\t\t\t);\n\n\t\t\t\tconst newBlocks = [];\n\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( canInsertBlockType( block.name, rootClientId ) ) {\n\t\t\t\t\t\tnewBlocks.push( block );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If a block cannot be inserted in a root block, try\n\t\t\t\t\t\t// converting it to that root block type and insert the\n\t\t\t\t\t\t// inner blocks.\n\t\t\t\t\t\t// Example: paragraphs cannot be inserted into a list,\n\t\t\t\t\t\t// so convert the paragraphs to a list for list items.\n\t\t\t\t\t\tconst rootBlockName = getBlockName( rootClientId );\n\t\t\t\t\t\tconst switchedBlocks =\n\t\t\t\t\t\t\tblock.name !== rootBlockName\n\t\t\t\t\t\t\t\t? switchToBlockType( block, rootBlockName )\n\t\t\t\t\t\t\t\t: [ block ];\n\n\t\t\t\t\t\tif ( ! switchedBlocks ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor ( const switchedBlock of switchedBlocks ) {\n\t\t\t\t\t\t\tfor ( const innerBlock of switchedBlock.innerBlocks ) {\n\t\t\t\t\t\t\t\tnewBlocks.push( innerBlock );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t__unstableSplitSelection( newBlocks );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,YAAY,EACZC,aAAa,EACbC,kBAAkB,EAClBC,eAAe,EACfC,iBAAiB,QACX,mBAAmB;AAC1B,SACCC,oBAAoB,EACpBC,+BAA+B,QACzB,gBAAgB;AACvB,SAASC,WAAW,EAAEC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACrE,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,aAAa,QAAQ,6BAA6B;AAC3D,SAASC,kBAAkB,QAAQ,SAAS;AAC5C,SAASC,iBAAiB,QAAQ,qBAAqB;AAEvD,eAAe,SAASC,mBAAmBA,CAAA,EAAG;EAC7C,MAAMC,QAAQ,GAAGT,WAAW,CAAC,CAAC;EAC9B,MAAM;IACLU,mBAAmB;IACnBC,yBAAyB;IACzBC,iBAAiB;IACjBC,WAAW;IACXC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MAAM,EAAErD,OAAQ,CAAC;IACtDD,IAAI,CAACO,aAAa,CAAC+C,gBAAgB,CAAE,KAAK,EAAErD,OAAQ,CAAC;IACrDD,IAAI,CAACO,aAAa,CAAC+C,gBAAgB,CAAE,OAAO,EAAErD,OAAQ,CAAC;IAEvD,OAAO,MAAM;MACZD,IAAI,CAACO,aAAa,CAACgD,mBAAmB,CAAE,MAAM,EAAEtD,OAAQ,CAAC;MACzDD,IAAI,CAACO,aAAa,CAACgD,mBAAmB,CAAE,KAAK,EAAEtD,OAAQ,CAAC;MACxDD,IAAI,CAACO,aAAa,CAACgD,mBAAmB,CAAE,OAAO,EAAEtD,OAAQ,CAAC;IAC3D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
|
|
@@ -1688,7 +1688,7 @@ export function __unstableSetTemporarilyEditingAsBlocks(temporarilyEditingAsBloc
|
|
|
1688
1688
|
* per_page: 'page_size',
|
|
1689
1689
|
* search: 'q',
|
|
1690
1690
|
* };
|
|
1691
|
-
* const url = new URL( 'https://api.openverse.
|
|
1691
|
+
* const url = new URL( 'https://api.openverse.org/v1/images/' );
|
|
1692
1692
|
* Object.entries( finalQuery ).forEach( ( [ key, value ] ) => {
|
|
1693
1693
|
* const queryKey = mapFromInserterMediaRequest[ key ] || key;
|
|
1694
1694
|
* url.searchParams.set( queryKey, value );
|