@wordpress/block-editor 14.17.0 → 14.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/background-image-control/index.js +21 -11
- package/build/components/background-image-control/index.js.map +1 -1
- package/build/components/block-canvas/index.js +6 -3
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js +3 -3
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-toolbar/use-has-block-toolbar.js +3 -12
- package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
- package/build/components/child-layout-control/index.js +1 -0
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/html-element-control/index.js +107 -0
- package/build/components/html-element-control/index.js.map +1 -0
- package/build/components/html-element-control/messages.js +25 -0
- package/build/components/html-element-control/messages.js.map +1 -0
- package/build/components/keyboard-shortcuts/index.js +2 -2
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +5 -5
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/delete.js +1 -9
- package/build/components/rich-text/event-listeners/delete.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +1 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/hooks/duotone.js +1 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +4 -1
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build-module/components/background-image-control/index.js +21 -11
- package/build-module/components/background-image-control/index.js.map +1 -1
- package/build-module/components/block-canvas/index.js +6 -3
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js +3 -3
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-toolbar/use-has-block-toolbar.js +3 -12
- package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +1 -0
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/html-element-control/index.js +102 -0
- package/build-module/components/html-element-control/index.js.map +1 -0
- package/build-module/components/html-element-control/messages.js +19 -0
- package/build-module/components/html-element-control/messages.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/index.js +2 -2
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +5 -5
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/delete.js +1 -9
- package/build-module/components/rich-text/event-listeners/delete.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +1 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/hooks/duotone.js +1 -1
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +3 -1
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-style/content-rtl.css +131 -9
- package/build-style/content.css +131 -9
- package/build-style/default-editor-styles-rtl.css +130 -9
- package/build-style/default-editor-styles.css +130 -9
- package/build-style/style-rtl.css +137 -11
- package/build-style/style.css +138 -11
- package/package.json +34 -34
- package/src/components/background-image-control/index.js +21 -13
- package/src/components/block-canvas/index.js +5 -3
- package/src/components/block-inspector/style.scss +4 -2
- package/src/components/block-list/content.scss +1 -0
- package/src/components/block-settings-menu/block-mode-toggle.js +3 -3
- package/src/components/block-settings-menu/test/block-mode-toggle.js +1 -1
- package/src/components/block-toolbar/use-has-block-toolbar.js +7 -13
- package/src/components/child-layout-control/index.js +1 -0
- package/src/components/html-element-control/index.js +109 -0
- package/src/components/html-element-control/messages.js +34 -0
- package/src/components/keyboard-shortcuts/index.js +2 -2
- package/src/components/media-placeholder/index.js +5 -5
- package/src/components/media-placeholder/style.scss +6 -0
- package/src/components/rich-text/README.md +1 -1
- package/src/components/rich-text/event-listeners/delete.js +1 -6
- package/src/components/url-popover/stories/index.story.js +9 -1
- package/src/components/use-resize-canvas/index.js +1 -1
- package/src/hooks/duotone.js +4 -3
- package/src/hooks/typography.js +5 -3
- package/src/private-apis.js +2 -0
- package/src/private-apis.native.js +2 -0
- package/src/store/actions.js +5 -1
- package/src/store/test/actions.js +122 -0
|
@@ -249,6 +249,7 @@ function BackgroundImageControls( {
|
|
|
249
249
|
onResetImage = noop,
|
|
250
250
|
displayInPanel,
|
|
251
251
|
defaultValues,
|
|
252
|
+
containerRef,
|
|
252
253
|
} ) {
|
|
253
254
|
const [ isUploading, setIsUploading ] = useState( false );
|
|
254
255
|
const { getSettings } = useSelect( blockEditorStore );
|
|
@@ -256,7 +257,6 @@ function BackgroundImageControls( {
|
|
|
256
257
|
const { id, title, url } = style?.background?.backgroundImage || {
|
|
257
258
|
...inheritedValue?.background?.backgroundImage,
|
|
258
259
|
};
|
|
259
|
-
const replaceContainerRef = useRef();
|
|
260
260
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
261
261
|
const onUploadError = ( message ) => {
|
|
262
262
|
createErrorNotice( message, { type: 'snackbar' } );
|
|
@@ -324,6 +324,8 @@ function BackgroundImageControls( {
|
|
|
324
324
|
} )
|
|
325
325
|
);
|
|
326
326
|
setIsUploading( false );
|
|
327
|
+
// Close the dropdown and focus the toggle button.
|
|
328
|
+
closeAndFocus();
|
|
327
329
|
};
|
|
328
330
|
|
|
329
331
|
// Drag and drop callback, restricting image to one.
|
|
@@ -342,14 +344,19 @@ function BackgroundImageControls( {
|
|
|
342
344
|
const hasValue = hasBackgroundImageValue( style );
|
|
343
345
|
|
|
344
346
|
const closeAndFocus = () => {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
347
|
+
// Use requestAnimationFrame to ensure DOM updates are complete
|
|
348
|
+
window.requestAnimationFrame( () => {
|
|
349
|
+
const [ toggleButton ] = focus.tabbable.find(
|
|
350
|
+
containerRef?.current
|
|
351
|
+
);
|
|
352
|
+
if ( ! toggleButton ) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
// Focus the toggle button and close the dropdown menu.
|
|
356
|
+
// This ensures similar behaviour as to selecting an image, where the dropdown is
|
|
357
|
+
// closed and focus is redirected to the dropdown toggle button.
|
|
358
|
+
toggleButton.focus();
|
|
359
|
+
} );
|
|
353
360
|
};
|
|
354
361
|
|
|
355
362
|
const onRemove = () =>
|
|
@@ -363,10 +370,7 @@ function BackgroundImageControls( {
|
|
|
363
370
|
title || getFilename( url ) || __( 'Add background image' );
|
|
364
371
|
|
|
365
372
|
return (
|
|
366
|
-
<div
|
|
367
|
-
ref={ replaceContainerRef }
|
|
368
|
-
className="block-editor-global-styles-background-panel__image-tools-panel-item"
|
|
369
|
-
>
|
|
373
|
+
<div className="block-editor-global-styles-background-panel__image-tools-panel-item">
|
|
370
374
|
{ isUploading && <LoadingSpinner /> }
|
|
371
375
|
<MediaReplaceFlow
|
|
372
376
|
mediaId={ id }
|
|
@@ -697,9 +701,11 @@ export default function BackgroundImagePanel( {
|
|
|
697
701
|
settings?.background?.backgroundRepeat );
|
|
698
702
|
|
|
699
703
|
const [ isDropDownOpen, setIsDropDownOpen ] = useState( false );
|
|
704
|
+
const containerRef = useRef();
|
|
700
705
|
|
|
701
706
|
return (
|
|
702
707
|
<div
|
|
708
|
+
ref={ containerRef }
|
|
703
709
|
className={ clsx(
|
|
704
710
|
'block-editor-global-styles-background-panel__inspector-media-replace-container',
|
|
705
711
|
{
|
|
@@ -727,6 +733,7 @@ export default function BackgroundImagePanel( {
|
|
|
727
733
|
} }
|
|
728
734
|
onRemoveImage={ () => setIsDropDownOpen( false ) }
|
|
729
735
|
defaultValues={ defaultValues }
|
|
736
|
+
containerRef={ containerRef }
|
|
730
737
|
/>
|
|
731
738
|
<BackgroundSizeControls
|
|
732
739
|
onChange={ onChange }
|
|
@@ -747,6 +754,7 @@ export default function BackgroundImagePanel( {
|
|
|
747
754
|
resetBackground();
|
|
748
755
|
} }
|
|
749
756
|
onRemoveImage={ () => setIsDropDownOpen( false ) }
|
|
757
|
+
containerRef={ containerRef }
|
|
750
758
|
/>
|
|
751
759
|
) }
|
|
752
760
|
</div>
|
|
@@ -56,8 +56,7 @@ export function ExperimentalBlockCanvas( {
|
|
|
56
56
|
return (
|
|
57
57
|
<BlockTools
|
|
58
58
|
__unstableContentRef={ localRef }
|
|
59
|
-
|
|
60
|
-
style={ { height } }
|
|
59
|
+
style={ { height, display: 'flex' } }
|
|
61
60
|
>
|
|
62
61
|
<EditorStyles
|
|
63
62
|
styles={ styles }
|
|
@@ -68,6 +67,10 @@ export function ExperimentalBlockCanvas( {
|
|
|
68
67
|
ref={ contentRef }
|
|
69
68
|
className="editor-styles-wrapper"
|
|
70
69
|
tabIndex={ -1 }
|
|
70
|
+
style={ {
|
|
71
|
+
height: '100%',
|
|
72
|
+
width: '100%',
|
|
73
|
+
} }
|
|
71
74
|
>
|
|
72
75
|
{ children }
|
|
73
76
|
</WritingFlow>
|
|
@@ -78,7 +81,6 @@ export function ExperimentalBlockCanvas( {
|
|
|
78
81
|
return (
|
|
79
82
|
<BlockTools
|
|
80
83
|
__unstableContentRef={ localRef }
|
|
81
|
-
className="block-editor-block-canvas"
|
|
82
84
|
style={ { height, display: 'flex' } }
|
|
83
85
|
>
|
|
84
86
|
<Iframe
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.components-base-control,
|
|
14
|
-
.components-radio-control
|
|
14
|
+
.components-radio-control,
|
|
15
|
+
.block-editor-html-element-control {
|
|
15
16
|
&:where(:not(:last-child)) {
|
|
16
17
|
margin-bottom: $grid-unit-20;
|
|
17
18
|
}
|
|
@@ -20,7 +21,8 @@
|
|
|
20
21
|
// Reset unwanted margin-bottom from being applied to BaseControls within certain components.
|
|
21
22
|
.components-focal-point-picker-control,
|
|
22
23
|
.components-query-controls,
|
|
23
|
-
.components-range-control
|
|
24
|
+
.components-range-control,
|
|
25
|
+
.block-editor-html-element-control {
|
|
24
26
|
.components-base-control {
|
|
25
27
|
margin-bottom: 0;
|
|
26
28
|
}
|
|
@@ -365,6 +365,7 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
|
|
|
365
365
|
border: none;
|
|
366
366
|
outline: none;
|
|
367
367
|
border-radius: $radius-small;
|
|
368
|
+
box-sizing: border-box;
|
|
368
369
|
box-shadow: inset 0 0 0 $border-width $gray-900;
|
|
369
370
|
resize: none;
|
|
370
371
|
overflow: hidden;
|
|
@@ -14,7 +14,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
14
14
|
const noop = () => {};
|
|
15
15
|
|
|
16
16
|
export default function BlockModeToggle( { clientId, onToggle = noop } ) {
|
|
17
|
-
const { blockType, mode,
|
|
17
|
+
const { blockType, mode, enabled } = useSelect(
|
|
18
18
|
( select ) => {
|
|
19
19
|
const { getBlock, getBlockMode, getSettings } =
|
|
20
20
|
select( blockEditorStore );
|
|
@@ -23,7 +23,7 @@ export default function BlockModeToggle( { clientId, onToggle = noop } ) {
|
|
|
23
23
|
return {
|
|
24
24
|
mode: getBlockMode( clientId ),
|
|
25
25
|
blockType: block ? getBlockType( block.name ) : null,
|
|
26
|
-
|
|
26
|
+
enabled: getSettings().codeEditingEnabled && !! block?.isValid,
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
29
|
[ clientId ]
|
|
@@ -33,7 +33,7 @@ export default function BlockModeToggle( { clientId, onToggle = noop } ) {
|
|
|
33
33
|
if (
|
|
34
34
|
! blockType ||
|
|
35
35
|
! hasBlockSupport( blockType, 'html', true ) ||
|
|
36
|
-
!
|
|
36
|
+
! enabled
|
|
37
37
|
) {
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
@@ -14,7 +14,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
14
14
|
* @return {boolean} Whether the block toolbar component will be rendered.
|
|
15
15
|
*/
|
|
16
16
|
export function useHasBlockToolbar() {
|
|
17
|
-
const
|
|
17
|
+
const enabled = useSelect( ( select ) => {
|
|
18
18
|
const { getBlockEditingMode, getBlockName, getBlockSelectionStart } =
|
|
19
19
|
select( blockEditorStore );
|
|
20
20
|
|
|
@@ -27,18 +27,12 @@ export function useHasBlockToolbar() {
|
|
|
27
27
|
selectedBlockClientId &&
|
|
28
28
|
getBlockType( getBlockName( selectedBlockClientId ) );
|
|
29
29
|
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
getBlockEditingMode( selectedBlockClientId ) === 'disabled',
|
|
36
|
-
};
|
|
30
|
+
return (
|
|
31
|
+
blockType &&
|
|
32
|
+
hasBlockSupport( blockType, '__experimentalToolbar', true ) &&
|
|
33
|
+
getBlockEditingMode( selectedBlockClientId ) !== 'disabled'
|
|
34
|
+
);
|
|
37
35
|
}, [] );
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return true;
|
|
37
|
+
return enabled;
|
|
44
38
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
SelectControl,
|
|
7
|
+
Notice,
|
|
8
|
+
__experimentalVStack as VStack,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { store as blockEditorStore } from '../../store';
|
|
16
|
+
import { htmlElementMessages } from './messages';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Renders a SelectControl for choosing HTML elements with validation
|
|
20
|
+
* to prevent duplicate <main> elements.
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} props Component props.
|
|
23
|
+
* @param {string} props.tagName The current HTML tag name.
|
|
24
|
+
* @param {Function} props.onChange Function to call when the tag is changed.
|
|
25
|
+
* @param {string} props.clientId The client ID of the current block.
|
|
26
|
+
* @param {Array} props.options SelectControl options (optional).
|
|
27
|
+
*
|
|
28
|
+
* @return {Component} The HTML element select control with validation.
|
|
29
|
+
*/
|
|
30
|
+
export default function HTMLElementControl( {
|
|
31
|
+
tagName,
|
|
32
|
+
onChange,
|
|
33
|
+
clientId,
|
|
34
|
+
options = [
|
|
35
|
+
{ label: __( 'Default (<div>)' ), value: 'div' },
|
|
36
|
+
{ label: '<header>', value: 'header' },
|
|
37
|
+
{ label: '<main>', value: 'main' },
|
|
38
|
+
{ label: '<section>', value: 'section' },
|
|
39
|
+
{ label: '<article>', value: 'article' },
|
|
40
|
+
{ label: '<aside>', value: 'aside' },
|
|
41
|
+
{ label: '<footer>', value: 'footer' },
|
|
42
|
+
],
|
|
43
|
+
} ) {
|
|
44
|
+
const checkForMainTag =
|
|
45
|
+
!! clientId && options.some( ( option ) => option.value === 'main' );
|
|
46
|
+
|
|
47
|
+
const hasMainElementElsewhere = useSelect(
|
|
48
|
+
( select ) => {
|
|
49
|
+
if ( ! checkForMainTag ) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { getClientIdsWithDescendants, getBlockAttributes } =
|
|
54
|
+
select( blockEditorStore );
|
|
55
|
+
|
|
56
|
+
return getClientIdsWithDescendants().some( ( id ) => {
|
|
57
|
+
// Skip the current block.
|
|
58
|
+
if ( id === clientId ) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return getBlockAttributes( id )?.tagName === 'main';
|
|
63
|
+
} );
|
|
64
|
+
},
|
|
65
|
+
[ clientId, checkForMainTag ]
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// Create a modified options array that disables the main option if needed.
|
|
69
|
+
const modifiedOptions = options.map( ( option ) => {
|
|
70
|
+
if (
|
|
71
|
+
option.value === 'main' &&
|
|
72
|
+
hasMainElementElsewhere &&
|
|
73
|
+
tagName !== 'main'
|
|
74
|
+
) {
|
|
75
|
+
return {
|
|
76
|
+
...option,
|
|
77
|
+
disabled: true,
|
|
78
|
+
label: sprintf(
|
|
79
|
+
/* translators: %s: HTML element name */
|
|
80
|
+
__( '%s (Already in use)' ),
|
|
81
|
+
option.label
|
|
82
|
+
),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return option;
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<VStack spacing={ 2 } className="block-editor-html-element-control">
|
|
90
|
+
<SelectControl
|
|
91
|
+
__nextHasNoMarginBottom
|
|
92
|
+
__next40pxDefaultSize
|
|
93
|
+
label={ __( 'HTML element' ) }
|
|
94
|
+
options={ modifiedOptions }
|
|
95
|
+
value={ tagName }
|
|
96
|
+
onChange={ onChange }
|
|
97
|
+
help={ htmlElementMessages[ tagName ] }
|
|
98
|
+
/>
|
|
99
|
+
|
|
100
|
+
{ tagName === 'main' && hasMainElementElsewhere && (
|
|
101
|
+
<Notice status="warning" isDismissible={ false }>
|
|
102
|
+
{ __(
|
|
103
|
+
'Multiple <main> elements detected. The duplicate may be in your content or template. This is not valid HTML and may cause accessibility issues. Please change this HTML element.'
|
|
104
|
+
) }
|
|
105
|
+
</Notice>
|
|
106
|
+
) }
|
|
107
|
+
</VStack>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Messages providing helpful descriptions for HTML elements.
|
|
8
|
+
*/
|
|
9
|
+
export const htmlElementMessages = {
|
|
10
|
+
article: __(
|
|
11
|
+
'The <article> element should represent a self-contained, syndicatable portion of the document.'
|
|
12
|
+
),
|
|
13
|
+
aside: __(
|
|
14
|
+
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
|
|
15
|
+
),
|
|
16
|
+
div: __(
|
|
17
|
+
'The <div> element should only be used if the block is a design element with no semantic meaning.'
|
|
18
|
+
),
|
|
19
|
+
footer: __(
|
|
20
|
+
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
|
|
21
|
+
),
|
|
22
|
+
header: __(
|
|
23
|
+
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
|
|
24
|
+
),
|
|
25
|
+
main: __(
|
|
26
|
+
'The <main> element should be used for the primary content of your document only.'
|
|
27
|
+
),
|
|
28
|
+
nav: __(
|
|
29
|
+
'The <nav> element should be used to identify groups of links that are intended to be used for website or page content navigation.'
|
|
30
|
+
),
|
|
31
|
+
section: __(
|
|
32
|
+
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
|
|
33
|
+
),
|
|
34
|
+
};
|
|
@@ -47,7 +47,7 @@ const InsertFromURLPopover = ( {
|
|
|
47
47
|
<InputControl
|
|
48
48
|
__next40pxDefaultSize
|
|
49
49
|
label={ __( 'URL' ) }
|
|
50
|
-
type="
|
|
50
|
+
type="text" // Use text instead of URL to allow relative paths (e.g., /image/image.jpg)
|
|
51
51
|
hideLabelFromVision
|
|
52
52
|
placeholder={ __( 'Paste or type URL' ) }
|
|
53
53
|
onChange={ onChange }
|
|
@@ -272,11 +272,11 @@ export function MediaPlaceholder( {
|
|
|
272
272
|
} )
|
|
273
273
|
).catch( ( err ) => onError( err ) );
|
|
274
274
|
|
|
275
|
-
if (
|
|
276
|
-
|
|
277
|
-
} else {
|
|
278
|
-
onSelect( uploadedMediaList[ 0 ] );
|
|
275
|
+
if ( ! uploadedMediaList?.length ) {
|
|
276
|
+
return;
|
|
279
277
|
}
|
|
278
|
+
|
|
279
|
+
onSelect( multiple ? uploadedMediaList : uploadedMediaList[ 0 ] );
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
const onUpload = ( event ) => {
|
|
@@ -23,7 +23,7 @@ _Default: `div`._ The [tag name](https://www.w3.org/TR/html51/syntax.html#tag-na
|
|
|
23
23
|
### `placeholder: String`
|
|
24
24
|
|
|
25
25
|
_Optional._ Placeholder text to show when the field is empty, similar to the
|
|
26
|
-
[`input` and `textarea` attribute of the same name](https://developer.mozilla.org/en-US/docs/
|
|
26
|
+
[`input` and `textarea` attribute of the same name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/placeholder).
|
|
27
27
|
|
|
28
28
|
### `disableLineBreaks: Boolean`
|
|
29
29
|
|
|
@@ -6,7 +6,7 @@ import { isCollapsed, isEmpty } from '@wordpress/rich-text';
|
|
|
6
6
|
|
|
7
7
|
export default ( props ) => ( element ) => {
|
|
8
8
|
function onKeyDown( event ) {
|
|
9
|
-
const { keyCode
|
|
9
|
+
const { keyCode } = event;
|
|
10
10
|
|
|
11
11
|
if ( event.defaultPrevented ) {
|
|
12
12
|
return;
|
|
@@ -30,11 +30,6 @@ export default ( props ) => ( element ) => {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// Exclude (command|ctrl)+shift+backspace as they are shortcuts for deleting blocks.
|
|
34
|
-
if ( shiftKey && ( ctrlKey || metaKey ) ) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
33
|
if ( onMerge ) {
|
|
39
34
|
onMerge( ! isReverse );
|
|
40
35
|
}
|
|
@@ -20,6 +20,10 @@ const TestURLPopover = () => {
|
|
|
20
20
|
const close = () => setVisiblility( false );
|
|
21
21
|
const setTarget = () => {};
|
|
22
22
|
|
|
23
|
+
const handleUrlChange = ( event ) => {
|
|
24
|
+
setUrl( event.target.value );
|
|
25
|
+
};
|
|
26
|
+
|
|
23
27
|
return (
|
|
24
28
|
<>
|
|
25
29
|
<Button
|
|
@@ -40,7 +44,11 @@ const TestURLPopover = () => {
|
|
|
40
44
|
) }
|
|
41
45
|
>
|
|
42
46
|
<form onSubmit={ close }>
|
|
43
|
-
<input
|
|
47
|
+
<input
|
|
48
|
+
type="url"
|
|
49
|
+
value={ url }
|
|
50
|
+
onChange={ handleUrlChange }
|
|
51
|
+
/>
|
|
44
52
|
<Button
|
|
45
53
|
__next40pxDefaultSize
|
|
46
54
|
icon={ keyboardReturn }
|
package/src/hooks/duotone.js
CHANGED
|
@@ -124,9 +124,10 @@ function DuotonePanelPure( { style, setAttributes, name } ) {
|
|
|
124
124
|
return null;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
const duotonePresetOrColors =
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
const duotonePresetOrColors =
|
|
128
|
+
duotoneStyle === 'unset' || Array.isArray( duotoneStyle )
|
|
129
|
+
? duotoneStyle
|
|
130
|
+
: getColorsFromDuotonePreset( duotoneStyle, duotonePalette );
|
|
130
131
|
|
|
131
132
|
return (
|
|
132
133
|
<>
|
package/src/hooks/typography.js
CHANGED
|
@@ -53,9 +53,11 @@ function styleToAttributes( style ) {
|
|
|
53
53
|
const updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };
|
|
54
54
|
const fontSizeValue = style?.typography?.fontSize;
|
|
55
55
|
const fontFamilyValue = style?.typography?.fontFamily;
|
|
56
|
-
const fontSizeSlug =
|
|
57
|
-
|
|
58
|
-
:
|
|
56
|
+
const fontSizeSlug =
|
|
57
|
+
typeof fontSizeValue === 'string' &&
|
|
58
|
+
fontSizeValue?.startsWith( 'var:preset|font-size|' )
|
|
59
|
+
? fontSizeValue.substring( 'var:preset|font-size|'.length )
|
|
60
|
+
: undefined;
|
|
59
61
|
const fontFamilySlug = fontFamilyValue?.startsWith(
|
|
60
62
|
'var:preset|font-family|'
|
|
61
63
|
)
|
package/src/private-apis.js
CHANGED
|
@@ -50,6 +50,7 @@ import useBlockDisplayTitle from './components/block-title/use-block-display-tit
|
|
|
50
50
|
import TabbedSidebar from './components/tabbed-sidebar';
|
|
51
51
|
import CommentIconSlotFill from './components/collab/block-comment-icon-slot';
|
|
52
52
|
import CommentIconToolbarSlotFill from './components/collab/block-comment-icon-toolbar-slot';
|
|
53
|
+
import HTMLElementControl from './components/html-element-control';
|
|
53
54
|
/**
|
|
54
55
|
* Private @wordpress/block-editor APIs.
|
|
55
56
|
*/
|
|
@@ -80,6 +81,7 @@ lock( privateApis, {
|
|
|
80
81
|
TextAlignmentControl,
|
|
81
82
|
usesContextKey,
|
|
82
83
|
useFlashEditableBlocks,
|
|
84
|
+
HTMLElementControl,
|
|
83
85
|
useZoomOut,
|
|
84
86
|
globalStylesDataKey,
|
|
85
87
|
globalStylesLinksDataKey,
|
|
@@ -6,6 +6,7 @@ import { ExperimentalBlockEditorProvider } from './components/provider';
|
|
|
6
6
|
import { getRichTextValues } from './components/rich-text/get-rich-text-values';
|
|
7
7
|
import { lock } from './lock-unlock';
|
|
8
8
|
import { PrivateRichText } from './components/rich-text/';
|
|
9
|
+
import HTMLElementControl from './components/html-element-control';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Private @wordpress/block-editor APIs.
|
|
@@ -16,4 +17,5 @@ lock( privateApis, {
|
|
|
16
17
|
ExperimentalBlockEditorProvider,
|
|
17
18
|
getRichTextValues,
|
|
18
19
|
PrivateRichText,
|
|
20
|
+
HTMLElementControl,
|
|
19
21
|
} );
|
package/src/store/actions.js
CHANGED
|
@@ -1157,7 +1157,11 @@ export const mergeBlocks =
|
|
|
1157
1157
|
const blockA = select.getBlock( clientIdA );
|
|
1158
1158
|
const blockAType = getBlockType( blockA.name );
|
|
1159
1159
|
|
|
1160
|
-
if (
|
|
1160
|
+
if (
|
|
1161
|
+
! blockAType ||
|
|
1162
|
+
select.getBlockEditingMode( clientIdA ) === 'disabled' ||
|
|
1163
|
+
select.getBlockEditingMode( clientIdB ) === 'disabled'
|
|
1164
|
+
) {
|
|
1161
1165
|
return;
|
|
1162
1166
|
}
|
|
1163
1167
|
|