@wordpress/block-library 8.28.4 → 8.28.5
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/block/deprecated.js +71 -11
- package/build/block/deprecated.js.map +1 -1
- package/build/block/edit.js +49 -24
- package/build/block/edit.js.map +1 -1
- package/build/image/edit.js +6 -3
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +11 -5
- package/build/image/image.js.map +1 -1
- package/build/list-item/edit.js +1 -3
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +0 -7
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/index.js +4 -1
- package/build/list-item/index.js.map +1 -1
- package/build/site-logo/edit.js +7 -2
- package/build/site-logo/edit.js.map +1 -1
- package/build-module/block/deprecated.js +71 -11
- package/build-module/block/deprecated.js.map +1 -1
- package/build-module/block/edit.js +49 -24
- package/build-module/block/edit.js.map +1 -1
- package/build-module/image/edit.js +7 -4
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +11 -5
- package/build-module/image/image.js.map +1 -1
- package/build-module/list-item/edit.js +2 -4
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +0 -1
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/index.js +4 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/site-logo/edit.js +7 -2
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-style/common-rtl.css +1 -0
- package/build-style/common.css +1 -0
- package/package.json +13 -13
- package/src/block/deprecated.js +76 -11
- package/src/block/edit.js +64 -19
- package/src/block/index.php +21 -12
- package/src/image/edit.js +10 -3
- package/src/image/image.js +20 -16
- package/src/list-item/edit.js +1 -2
- package/src/list-item/hooks/index.js +0 -1
- package/src/list-item/index.js +3 -0
- package/src/navigation/index.php +1 -1
- package/src/search/index.php +1 -1
- package/src/site-logo/edit.js +10 -5
- package/build/list-item/hooks/use-copy.js +0 -39
- package/build/list-item/hooks/use-copy.js.map +0 -1
- package/build-module/list-item/hooks/use-copy.js +0 -32
- package/build-module/list-item/hooks/use-copy.js.map +0 -1
- package/src/list-item/hooks/use-copy.js +0 -38
package/src/image/edit.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
useBlockEditingMode,
|
|
21
21
|
} from '@wordpress/block-editor';
|
|
22
22
|
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
23
|
-
import { __ } from '@wordpress/i18n';
|
|
23
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
24
24
|
import { image as icon, plugins as pluginsIcon } from '@wordpress/icons';
|
|
25
25
|
import { store as noticesStore } from '@wordpress/notices';
|
|
26
26
|
|
|
@@ -336,7 +336,7 @@ export function ImageEdit( {
|
|
|
336
336
|
} );
|
|
337
337
|
|
|
338
338
|
// Much of this description is duplicated from MediaPlaceholder.
|
|
339
|
-
const { lockUrlControls = false } = useSelect(
|
|
339
|
+
const { lockUrlControls = false, lockUrlControlsMessage } = useSelect(
|
|
340
340
|
( select ) => {
|
|
341
341
|
if ( ! isSingleSelected ) {
|
|
342
342
|
return {};
|
|
@@ -351,6 +351,13 @@ export function ImageEdit( {
|
|
|
351
351
|
!! metadata?.bindings?.url &&
|
|
352
352
|
( ! blockBindingsSource ||
|
|
353
353
|
blockBindingsSource?.lockAttributesEditing ),
|
|
354
|
+
lockUrlControlsMessage: blockBindingsSource?.label
|
|
355
|
+
? sprintf(
|
|
356
|
+
/* translators: %s: Label of the bindings source. */
|
|
357
|
+
__( 'Connected to %s' ),
|
|
358
|
+
blockBindingsSource.label
|
|
359
|
+
)
|
|
360
|
+
: __( 'Connected to dynamic data' ),
|
|
354
361
|
};
|
|
355
362
|
},
|
|
356
363
|
[ isSingleSelected ]
|
|
@@ -387,7 +394,7 @@ export function ImageEdit( {
|
|
|
387
394
|
<span
|
|
388
395
|
className={ 'block-bindings-media-placeholder-message' }
|
|
389
396
|
>
|
|
390
|
-
{
|
|
397
|
+
{ lockUrlControlsMessage }
|
|
391
398
|
</span>
|
|
392
399
|
) : (
|
|
393
400
|
content
|
package/src/image/image.js
CHANGED
|
@@ -410,7 +410,9 @@ export default function Image( {
|
|
|
410
410
|
lockUrlControls = false,
|
|
411
411
|
lockHrefControls = false,
|
|
412
412
|
lockAltControls = false,
|
|
413
|
+
lockAltControlsMessage,
|
|
413
414
|
lockTitleControls = false,
|
|
415
|
+
lockTitleControlsMessage,
|
|
414
416
|
lockCaption = false,
|
|
415
417
|
} = useSelect(
|
|
416
418
|
( select ) => {
|
|
@@ -454,10 +456,24 @@ export default function Image( {
|
|
|
454
456
|
!! altBinding &&
|
|
455
457
|
( ! altBindingSource ||
|
|
456
458
|
altBindingSource?.lockAttributesEditing ),
|
|
459
|
+
lockAltControlsMessage: altBindingSource?.label
|
|
460
|
+
? sprintf(
|
|
461
|
+
/* translators: %s: Label of the bindings source. */
|
|
462
|
+
__( 'Connected to %s' ),
|
|
463
|
+
altBindingSource.label
|
|
464
|
+
)
|
|
465
|
+
: __( 'Connected to dynamic data' ),
|
|
457
466
|
lockTitleControls:
|
|
458
467
|
!! titleBinding &&
|
|
459
468
|
( ! titleBindingSource ||
|
|
460
469
|
titleBindingSource?.lockAttributesEditing ),
|
|
470
|
+
lockTitleControlsMessage: titleBindingSource?.label
|
|
471
|
+
? sprintf(
|
|
472
|
+
/* translators: %s: Label of the bindings source. */
|
|
473
|
+
__( 'Connected to %s' ),
|
|
474
|
+
titleBindingSource.label
|
|
475
|
+
)
|
|
476
|
+
: __( 'Connected to dynamic data' ),
|
|
461
477
|
};
|
|
462
478
|
},
|
|
463
479
|
[ clientId, isSingleSelected, metadata?.bindings ]
|
|
@@ -557,11 +573,7 @@ export default function Image( {
|
|
|
557
573
|
disabled={ lockAltControls }
|
|
558
574
|
help={
|
|
559
575
|
lockAltControls ? (
|
|
560
|
-
<>
|
|
561
|
-
{ __(
|
|
562
|
-
'Connected to a custom field'
|
|
563
|
-
) }
|
|
564
|
-
</>
|
|
576
|
+
<>{ lockAltControlsMessage }</>
|
|
565
577
|
) : (
|
|
566
578
|
<>
|
|
567
579
|
<ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
|
|
@@ -607,11 +619,7 @@ export default function Image( {
|
|
|
607
619
|
disabled={ lockTitleControls }
|
|
608
620
|
help={
|
|
609
621
|
lockTitleControls ? (
|
|
610
|
-
<>
|
|
611
|
-
{ __(
|
|
612
|
-
'Connected to a custom field'
|
|
613
|
-
) }
|
|
614
|
-
</>
|
|
622
|
+
<>{ lockTitleControlsMessage }</>
|
|
615
623
|
) : (
|
|
616
624
|
<>
|
|
617
625
|
{ __(
|
|
@@ -652,11 +660,7 @@ export default function Image( {
|
|
|
652
660
|
readOnly={ lockAltControls }
|
|
653
661
|
help={
|
|
654
662
|
lockAltControls ? (
|
|
655
|
-
<>
|
|
656
|
-
{ __(
|
|
657
|
-
'Connected to a custom field'
|
|
658
|
-
) }
|
|
659
|
-
</>
|
|
663
|
+
<>{ lockAltControlsMessage }</>
|
|
660
664
|
) : (
|
|
661
665
|
<>
|
|
662
666
|
<ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
|
|
@@ -694,7 +698,7 @@ export default function Image( {
|
|
|
694
698
|
readOnly={ lockTitleControls }
|
|
695
699
|
help={
|
|
696
700
|
lockTitleControls ? (
|
|
697
|
-
<>{
|
|
701
|
+
<>{ lockTitleControlsMessage }</>
|
|
698
702
|
) : (
|
|
699
703
|
<>
|
|
700
704
|
{ __(
|
package/src/list-item/edit.js
CHANGED
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
useOutdentListItem,
|
|
30
30
|
useSplit,
|
|
31
31
|
useMerge,
|
|
32
|
-
useCopy,
|
|
33
32
|
} from './hooks';
|
|
34
33
|
import { convertToListItems } from './utils';
|
|
35
34
|
|
|
@@ -79,7 +78,7 @@ export default function ListItemEdit( {
|
|
|
79
78
|
mergeBlocks,
|
|
80
79
|
} ) {
|
|
81
80
|
const { placeholder, content } = attributes;
|
|
82
|
-
const blockProps = useBlockProps(
|
|
81
|
+
const blockProps = useBlockProps();
|
|
83
82
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
84
83
|
renderAppender: false,
|
|
85
84
|
__unstableDisableDropZone: true,
|
package/src/list-item/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { listItem as icon } from '@wordpress/icons';
|
|
5
|
+
import { privateApis } from '@wordpress/block-editor';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -11,6 +12,7 @@ import metadata from './block.json';
|
|
|
11
12
|
import edit from './edit';
|
|
12
13
|
import save from './save';
|
|
13
14
|
import transforms from './transforms';
|
|
15
|
+
import { unlock } from '../lock-unlock';
|
|
14
16
|
|
|
15
17
|
const { name } = metadata;
|
|
16
18
|
|
|
@@ -27,6 +29,7 @@ export const settings = {
|
|
|
27
29
|
};
|
|
28
30
|
},
|
|
29
31
|
transforms,
|
|
32
|
+
[ unlock( privateApis ).requiresWrapperOnCopy ]: true,
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/navigation/index.php
CHANGED
|
@@ -552,7 +552,7 @@ class WP_Navigation_Block_Renderer {
|
|
|
552
552
|
return '';
|
|
553
553
|
}
|
|
554
554
|
// When adding to this array be mindful of security concerns.
|
|
555
|
-
$nav_element_context =
|
|
555
|
+
$nav_element_context = wp_interactivity_data_wp_context(
|
|
556
556
|
array(
|
|
557
557
|
'overlayOpenedBy' => array(
|
|
558
558
|
'click' => false,
|
package/src/search/index.php
CHANGED
|
@@ -179,7 +179,7 @@ function render_block_core_search( $attributes ) {
|
|
|
179
179
|
if ( $is_expandable_searchfield ) {
|
|
180
180
|
$aria_label_expanded = __( 'Submit Search' );
|
|
181
181
|
$aria_label_collapsed = __( 'Expand search field' );
|
|
182
|
-
$form_context =
|
|
182
|
+
$form_context = wp_interactivity_data_wp_context(
|
|
183
183
|
array(
|
|
184
184
|
'isSearchInputVisible' => $open_by_default,
|
|
185
185
|
'inputId' => $input_id,
|
package/src/site-logo/edit.js
CHANGED
|
@@ -268,6 +268,14 @@ const SiteLogo = ( {
|
|
|
268
268
|
</ResizableBox>
|
|
269
269
|
);
|
|
270
270
|
|
|
271
|
+
// Support the previous location for the Site Icon settings. To be removed
|
|
272
|
+
// when the required WP core version for Gutenberg is >= 6.5.0.
|
|
273
|
+
const shouldUseNewUrl = ! window?.__experimentalUseCustomizerSiteLogoUrl;
|
|
274
|
+
|
|
275
|
+
const siteIconSettingsUrl = shouldUseNewUrl
|
|
276
|
+
? siteUrl + '/wp-admin/options-general.php'
|
|
277
|
+
: siteUrl + '/wp-admin/customize.php?autofocus[section]=title_tagline';
|
|
278
|
+
|
|
271
279
|
const syncSiteIconHelpText = createInterpolateElement(
|
|
272
280
|
__(
|
|
273
281
|
'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. To use a custom icon that is different from your site logo, use the <a>Site Icon settings</a>.'
|
|
@@ -276,10 +284,7 @@ const SiteLogo = ( {
|
|
|
276
284
|
a: (
|
|
277
285
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
278
286
|
<a
|
|
279
|
-
href={
|
|
280
|
-
siteUrl +
|
|
281
|
-
'/wp-admin/customize.php?autofocus[section]=title_tagline'
|
|
282
|
-
}
|
|
287
|
+
href={ siteIconSettingsUrl }
|
|
283
288
|
target="_blank"
|
|
284
289
|
rel="noopener noreferrer"
|
|
285
290
|
/>
|
|
@@ -331,7 +336,7 @@ const SiteLogo = ( {
|
|
|
331
336
|
<>
|
|
332
337
|
<ToggleControl
|
|
333
338
|
__nextHasNoMarginBottom
|
|
334
|
-
label={ __( 'Use as
|
|
339
|
+
label={ __( 'Use as Site Icon' ) }
|
|
335
340
|
onChange={ ( value ) => {
|
|
336
341
|
setAttributes( { shouldSyncIcon: value } );
|
|
337
342
|
setIcon( value ? logoId : undefined );
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useCopy;
|
|
7
|
-
var _compose = require("@wordpress/compose");
|
|
8
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
9
|
-
var _data = require("@wordpress/data");
|
|
10
|
-
/**
|
|
11
|
-
* WordPress dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
function useCopy(clientId) {
|
|
15
|
-
const {
|
|
16
|
-
getBlockRootClientId,
|
|
17
|
-
getBlockName,
|
|
18
|
-
getBlockAttributes
|
|
19
|
-
} = (0, _data.useSelect)(_blockEditor.store);
|
|
20
|
-
return (0, _compose.useRefEffect)(node => {
|
|
21
|
-
function onCopy(event) {
|
|
22
|
-
// The event propagates through all nested lists, so don't override
|
|
23
|
-
// when copying nested list items.
|
|
24
|
-
if (event.clipboardData.getData('__unstableWrapperBlockName')) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const rootClientId = getBlockRootClientId(clientId);
|
|
28
|
-
event.clipboardData.setData('__unstableWrapperBlockName', getBlockName(rootClientId));
|
|
29
|
-
event.clipboardData.setData('__unstableWrapperBlockAttributes', JSON.stringify(getBlockAttributes(rootClientId)));
|
|
30
|
-
}
|
|
31
|
-
node.addEventListener('copy', onCopy);
|
|
32
|
-
node.addEventListener('cut', onCopy);
|
|
33
|
-
return () => {
|
|
34
|
-
node.removeEventListener('copy', onCopy);
|
|
35
|
-
node.removeEventListener('cut', onCopy);
|
|
36
|
-
};
|
|
37
|
-
}, []);
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=use-copy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_blockEditor","_data","useCopy","clientId","getBlockRootClientId","getBlockName","getBlockAttributes","useSelect","blockEditorStore","useRefEffect","node","onCopy","event","clipboardData","getData","rootClientId","setData","JSON","stringify","addEventListener","removeEventListener"],"sources":["@wordpress/block-library/src/list-item/hooks/use-copy.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function useCopy( clientId ) {\n\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onCopy( event ) {\n\t\t\t// The event propagates through all nested lists, so don't override\n\t\t\t// when copying nested list items.\n\t\t\tif ( event.clipboardData.getData( '__unstableWrapperBlockName' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tevent.clipboardData.setData(\n\t\t\t\t'__unstableWrapperBlockName',\n\t\t\t\tgetBlockName( rootClientId )\n\t\t\t);\n\t\t\tevent.clipboardData.setData(\n\t\t\t\t'__unstableWrapperBlockAttributes',\n\t\t\t\tJSON.stringify( getBlockAttributes( rootClientId ) )\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'copy', onCopy );\n\t\tnode.addEventListener( 'cut', onCopy );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'copy', onCopy );\n\t\t\tnode.removeEventListener( 'cut', onCopy );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKe,SAASG,OAAOA,CAAEC,QAAQ,EAAG;EAC3C,MAAM;IAAEC,oBAAoB;IAAEC,YAAY;IAAEC;EAAmB,CAAC,GAC/D,IAAAC,eAAS,EAAEC,kBAAiB,CAAC;EAE9B,OAAO,IAAAC,qBAAY,EAAIC,IAAI,IAAM;IAChC,SAASC,MAAMA,CAAEC,KAAK,EAAG;MACxB;MACA;MACA,IAAKA,KAAK,CAACC,aAAa,CAACC,OAAO,CAAE,4BAA6B,CAAC,EAAG;QAClE;MACD;MAEA,MAAMC,YAAY,GAAGX,oBAAoB,CAAED,QAAS,CAAC;MACrDS,KAAK,CAACC,aAAa,CAACG,OAAO,CAC1B,4BAA4B,EAC5BX,YAAY,CAAEU,YAAa,CAC5B,CAAC;MACDH,KAAK,CAACC,aAAa,CAACG,OAAO,CAC1B,kCAAkC,EAClCC,IAAI,CAACC,SAAS,CAAEZ,kBAAkB,CAAES,YAAa,CAAE,CACpD,CAAC;IACF;IAEAL,IAAI,CAACS,gBAAgB,CAAE,MAAM,EAAER,MAAO,CAAC;IACvCD,IAAI,CAACS,gBAAgB,CAAE,KAAK,EAAER,MAAO,CAAC;IACtC,OAAO,MAAM;MACZD,IAAI,CAACU,mBAAmB,CAAE,MAAM,EAAET,MAAO,CAAC;MAC1CD,IAAI,CAACU,mBAAmB,CAAE,KAAK,EAAET,MAAO,CAAC;IAC1C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
-
import { useSelect } from '@wordpress/data';
|
|
7
|
-
export default function useCopy(clientId) {
|
|
8
|
-
const {
|
|
9
|
-
getBlockRootClientId,
|
|
10
|
-
getBlockName,
|
|
11
|
-
getBlockAttributes
|
|
12
|
-
} = useSelect(blockEditorStore);
|
|
13
|
-
return useRefEffect(node => {
|
|
14
|
-
function onCopy(event) {
|
|
15
|
-
// The event propagates through all nested lists, so don't override
|
|
16
|
-
// when copying nested list items.
|
|
17
|
-
if (event.clipboardData.getData('__unstableWrapperBlockName')) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const rootClientId = getBlockRootClientId(clientId);
|
|
21
|
-
event.clipboardData.setData('__unstableWrapperBlockName', getBlockName(rootClientId));
|
|
22
|
-
event.clipboardData.setData('__unstableWrapperBlockAttributes', JSON.stringify(getBlockAttributes(rootClientId)));
|
|
23
|
-
}
|
|
24
|
-
node.addEventListener('copy', onCopy);
|
|
25
|
-
node.addEventListener('cut', onCopy);
|
|
26
|
-
return () => {
|
|
27
|
-
node.removeEventListener('copy', onCopy);
|
|
28
|
-
node.removeEventListener('cut', onCopy);
|
|
29
|
-
};
|
|
30
|
-
}, []);
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=use-copy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useRefEffect","store","blockEditorStore","useSelect","useCopy","clientId","getBlockRootClientId","getBlockName","getBlockAttributes","node","onCopy","event","clipboardData","getData","rootClientId","setData","JSON","stringify","addEventListener","removeEventListener"],"sources":["@wordpress/block-library/src/list-item/hooks/use-copy.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function useCopy( clientId ) {\n\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onCopy( event ) {\n\t\t\t// The event propagates through all nested lists, so don't override\n\t\t\t// when copying nested list items.\n\t\t\tif ( event.clipboardData.getData( '__unstableWrapperBlockName' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tevent.clipboardData.setData(\n\t\t\t\t'__unstableWrapperBlockName',\n\t\t\t\tgetBlockName( rootClientId )\n\t\t\t);\n\t\t\tevent.clipboardData.setData(\n\t\t\t\t'__unstableWrapperBlockAttributes',\n\t\t\t\tJSON.stringify( getBlockAttributes( rootClientId ) )\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'copy', onCopy );\n\t\tnode.addEventListener( 'cut', onCopy );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'copy', onCopy );\n\t\t\tnode.removeEventListener( 'cut', onCopy );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,eAAe,SAASC,OAAOA,CAAEC,QAAQ,EAAG;EAC3C,MAAM;IAAEC,oBAAoB;IAAEC,YAAY;IAAEC;EAAmB,CAAC,GAC/DL,SAAS,CAAED,gBAAiB,CAAC;EAE9B,OAAOF,YAAY,CAAIS,IAAI,IAAM;IAChC,SAASC,MAAMA,CAAEC,KAAK,EAAG;MACxB;MACA;MACA,IAAKA,KAAK,CAACC,aAAa,CAACC,OAAO,CAAE,4BAA6B,CAAC,EAAG;QAClE;MACD;MAEA,MAAMC,YAAY,GAAGR,oBAAoB,CAAED,QAAS,CAAC;MACrDM,KAAK,CAACC,aAAa,CAACG,OAAO,CAC1B,4BAA4B,EAC5BR,YAAY,CAAEO,YAAa,CAC5B,CAAC;MACDH,KAAK,CAACC,aAAa,CAACG,OAAO,CAC1B,kCAAkC,EAClCC,IAAI,CAACC,SAAS,CAAET,kBAAkB,CAAEM,YAAa,CAAE,CACpD,CAAC;IACF;IAEAL,IAAI,CAACS,gBAAgB,CAAE,MAAM,EAAER,MAAO,CAAC;IACvCD,IAAI,CAACS,gBAAgB,CAAE,KAAK,EAAER,MAAO,CAAC;IACtC,OAAO,MAAM;MACZD,IAAI,CAACU,mBAAmB,CAAE,MAAM,EAAET,MAAO,CAAC;MAC1CD,IAAI,CAACU,mBAAmB,CAAE,KAAK,EAAET,MAAO,CAAC;IAC1C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
-
import { useSelect } from '@wordpress/data';
|
|
7
|
-
|
|
8
|
-
export default function useCopy( clientId ) {
|
|
9
|
-
const { getBlockRootClientId, getBlockName, getBlockAttributes } =
|
|
10
|
-
useSelect( blockEditorStore );
|
|
11
|
-
|
|
12
|
-
return useRefEffect( ( node ) => {
|
|
13
|
-
function onCopy( event ) {
|
|
14
|
-
// The event propagates through all nested lists, so don't override
|
|
15
|
-
// when copying nested list items.
|
|
16
|
-
if ( event.clipboardData.getData( '__unstableWrapperBlockName' ) ) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const rootClientId = getBlockRootClientId( clientId );
|
|
21
|
-
event.clipboardData.setData(
|
|
22
|
-
'__unstableWrapperBlockName',
|
|
23
|
-
getBlockName( rootClientId )
|
|
24
|
-
);
|
|
25
|
-
event.clipboardData.setData(
|
|
26
|
-
'__unstableWrapperBlockAttributes',
|
|
27
|
-
JSON.stringify( getBlockAttributes( rootClientId ) )
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
node.addEventListener( 'copy', onCopy );
|
|
32
|
-
node.addEventListener( 'cut', onCopy );
|
|
33
|
-
return () => {
|
|
34
|
-
node.removeEventListener( 'copy', onCopy );
|
|
35
|
-
node.removeEventListener( 'cut', onCopy );
|
|
36
|
-
};
|
|
37
|
-
}, [] );
|
|
38
|
-
}
|