@wordpress/block-editor 14.16.0 → 14.18.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 +18 -10
- 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-list/block.js +4 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +14 -11
- package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.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/block-tools/use-show-block-tools.js +3 -2
- package/build/components/block-tools/use-show-block-tools.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/inserter/media-tab/media-preview.js +1 -7
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -2
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/link-control/index.js +2 -0
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +2 -1
- 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/spacing-visualizer.js +14 -8
- package/build/hooks/spacing-visualizer.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 +19 -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-list/block.js +4 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +14 -11
- package/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.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/block-tools/use-show-block-tools.js +3 -2
- package/build-module/components/block-tools/use-show-block-tools.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/inserter/media-tab/media-preview.js +1 -7
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- 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/link-control/index.js +4 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -1
- 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/spacing-visualizer.js +15 -9
- package/build-module/hooks/spacing-visualizer.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 +1 -0
- package/build-style/content.css +1 -0
- package/build-style/style-rtl.css +7 -2
- package/build-style/style.css +8 -2
- package/package.json +34 -34
- package/src/components/background-image-control/index.js +22 -7
- package/src/components/block-canvas/index.js +5 -3
- package/src/components/block-inspector/style.scss +4 -2
- package/src/components/block-list/block.js +6 -2
- package/src/components/block-list/content.scss +1 -0
- package/src/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +14 -11
- 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/block-tools/use-show-block-tools.js +2 -0
- 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/inserter/media-tab/media-preview.js +1 -8
- package/src/components/keyboard-shortcuts/index.js +2 -2
- package/src/components/link-control/index.js +6 -1
- package/src/components/media-placeholder/index.js +1 -1
- package/src/components/media-placeholder/style.scss +6 -0
- package/src/components/rich-text/event-listeners/delete.js +1 -6
- package/src/components/use-resize-canvas/index.js +1 -1
- package/src/hooks/duotone.js +4 -3
- package/src/hooks/spacing-visualizer.js +14 -17
- 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
package/build-style/style.css
CHANGED
|
@@ -319,12 +319,14 @@ iframe[name=editor-canvas] {
|
|
|
319
319
|
margin-bottom: 1.5em;
|
|
320
320
|
}
|
|
321
321
|
.block-editor-block-inspector .components-base-control:where(:not(:last-child)),
|
|
322
|
-
.block-editor-block-inspector .components-radio-control:where(:not(:last-child))
|
|
322
|
+
.block-editor-block-inspector .components-radio-control:where(:not(:last-child)),
|
|
323
|
+
.block-editor-block-inspector .block-editor-html-element-control:where(:not(:last-child)) {
|
|
323
324
|
margin-bottom: 16px;
|
|
324
325
|
}
|
|
325
326
|
.block-editor-block-inspector .components-focal-point-picker-control .components-base-control,
|
|
326
327
|
.block-editor-block-inspector .components-query-controls .components-base-control,
|
|
327
|
-
.block-editor-block-inspector .components-range-control .components-base-control
|
|
328
|
+
.block-editor-block-inspector .components-range-control .components-base-control,
|
|
329
|
+
.block-editor-block-inspector .block-editor-html-element-control .components-base-control {
|
|
328
330
|
margin-bottom: 0;
|
|
329
331
|
}
|
|
330
332
|
.block-editor-block-inspector .components-panel__body {
|
|
@@ -3030,6 +3032,10 @@ iframe[name=editor-canvas] {
|
|
|
3030
3032
|
width: 300px;
|
|
3031
3033
|
}
|
|
3032
3034
|
}
|
|
3035
|
+
.block-editor-media-placeholder__url-input-form input {
|
|
3036
|
+
/* rtl:ignore */
|
|
3037
|
+
direction: ltr;
|
|
3038
|
+
}
|
|
3033
3039
|
|
|
3034
3040
|
.modal-open .block-editor-media-replace-flow__options {
|
|
3035
3041
|
display: none;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.18.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,38 +37,38 @@
|
|
|
37
37
|
"@emotion/react": "^11.7.1",
|
|
38
38
|
"@emotion/styled": "^11.6.0",
|
|
39
39
|
"@react-spring/web": "^9.4.5",
|
|
40
|
-
"@wordpress/a11y": "^4.
|
|
41
|
-
"@wordpress/api-fetch": "^7.
|
|
42
|
-
"@wordpress/blob": "^4.
|
|
43
|
-
"@wordpress/block-serialization-default-parser": "^5.
|
|
44
|
-
"@wordpress/blocks": "^14.
|
|
45
|
-
"@wordpress/commands": "^1.
|
|
46
|
-
"@wordpress/components": "^29.
|
|
47
|
-
"@wordpress/compose": "^7.
|
|
48
|
-
"@wordpress/data": "^10.
|
|
49
|
-
"@wordpress/date": "^5.
|
|
50
|
-
"@wordpress/deprecated": "^4.
|
|
51
|
-
"@wordpress/dom": "^4.
|
|
52
|
-
"@wordpress/element": "^6.
|
|
53
|
-
"@wordpress/escape-html": "^3.
|
|
54
|
-
"@wordpress/hooks": "^4.
|
|
55
|
-
"@wordpress/html-entities": "^4.
|
|
56
|
-
"@wordpress/i18n": "^5.
|
|
57
|
-
"@wordpress/icons": "^10.
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
59
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
60
|
-
"@wordpress/keycodes": "^4.
|
|
61
|
-
"@wordpress/notices": "^5.
|
|
62
|
-
"@wordpress/preferences": "^4.
|
|
63
|
-
"@wordpress/priority-queue": "^3.
|
|
64
|
-
"@wordpress/private-apis": "^1.
|
|
65
|
-
"@wordpress/rich-text": "^7.
|
|
66
|
-
"@wordpress/style-engine": "^2.
|
|
67
|
-
"@wordpress/token-list": "^3.
|
|
68
|
-
"@wordpress/upload-media": "^0.
|
|
69
|
-
"@wordpress/url": "^4.
|
|
70
|
-
"@wordpress/warning": "^3.
|
|
71
|
-
"@wordpress/wordcount": "^4.
|
|
40
|
+
"@wordpress/a11y": "^4.23.0",
|
|
41
|
+
"@wordpress/api-fetch": "^7.23.0",
|
|
42
|
+
"@wordpress/blob": "^4.23.0",
|
|
43
|
+
"@wordpress/block-serialization-default-parser": "^5.23.0",
|
|
44
|
+
"@wordpress/blocks": "^14.12.0",
|
|
45
|
+
"@wordpress/commands": "^1.23.0",
|
|
46
|
+
"@wordpress/components": "^29.9.0",
|
|
47
|
+
"@wordpress/compose": "^7.23.0",
|
|
48
|
+
"@wordpress/data": "^10.23.0",
|
|
49
|
+
"@wordpress/date": "^5.23.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.23.0",
|
|
51
|
+
"@wordpress/dom": "^4.23.0",
|
|
52
|
+
"@wordpress/element": "^6.23.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.23.0",
|
|
54
|
+
"@wordpress/hooks": "^4.23.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.23.0",
|
|
56
|
+
"@wordpress/i18n": "^5.23.0",
|
|
57
|
+
"@wordpress/icons": "^10.23.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.23.0",
|
|
59
|
+
"@wordpress/keyboard-shortcuts": "^5.23.0",
|
|
60
|
+
"@wordpress/keycodes": "^4.23.0",
|
|
61
|
+
"@wordpress/notices": "^5.23.0",
|
|
62
|
+
"@wordpress/preferences": "^4.23.0",
|
|
63
|
+
"@wordpress/priority-queue": "^3.23.0",
|
|
64
|
+
"@wordpress/private-apis": "^1.23.0",
|
|
65
|
+
"@wordpress/rich-text": "^7.23.0",
|
|
66
|
+
"@wordpress/style-engine": "^2.23.0",
|
|
67
|
+
"@wordpress/token-list": "^3.23.0",
|
|
68
|
+
"@wordpress/upload-media": "^0.8.0",
|
|
69
|
+
"@wordpress/url": "^4.23.0",
|
|
70
|
+
"@wordpress/warning": "^3.23.0",
|
|
71
|
+
"@wordpress/wordcount": "^4.23.0",
|
|
72
72
|
"change-case": "^4.1.2",
|
|
73
73
|
"clsx": "^2.1.1",
|
|
74
74
|
"colord": "^2.7.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "ab5c79cd40adbb68898536c50e035b0a734338ea"
|
|
95
95
|
}
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
FocalPointPicker,
|
|
18
18
|
MenuItem,
|
|
19
19
|
VisuallyHidden,
|
|
20
|
-
__experimentalItemGroup as ItemGroup,
|
|
21
20
|
__experimentalHStack as HStack,
|
|
22
21
|
__experimentalTruncate as Truncate,
|
|
23
22
|
Dropdown,
|
|
@@ -119,13 +118,16 @@ function InspectorImagePreviewItem( {
|
|
|
119
118
|
className,
|
|
120
119
|
onToggleCallback = noop,
|
|
121
120
|
} ) {
|
|
121
|
+
const { isOpen, ...restToggleProps } = toggleProps;
|
|
122
|
+
|
|
122
123
|
useEffect( () => {
|
|
123
|
-
if ( typeof
|
|
124
|
-
onToggleCallback(
|
|
124
|
+
if ( typeof isOpen !== 'undefined' ) {
|
|
125
|
+
onToggleCallback( isOpen );
|
|
125
126
|
}
|
|
126
|
-
}, [
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
}, [ isOpen, onToggleCallback ] );
|
|
128
|
+
|
|
129
|
+
const renderPreviewContent = () => {
|
|
130
|
+
return (
|
|
129
131
|
<HStack
|
|
130
132
|
justify="flex-start"
|
|
131
133
|
as="span"
|
|
@@ -162,7 +164,20 @@ function InspectorImagePreviewItem( {
|
|
|
162
164
|
</VisuallyHidden>
|
|
163
165
|
</FlexItem>
|
|
164
166
|
</HStack>
|
|
165
|
-
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return as === 'button' ? (
|
|
171
|
+
<Button
|
|
172
|
+
__next40pxDefaultSize
|
|
173
|
+
className={ className }
|
|
174
|
+
{ ...restToggleProps }
|
|
175
|
+
aria-expanded={ isOpen }
|
|
176
|
+
>
|
|
177
|
+
{ renderPreviewContent() }
|
|
178
|
+
</Button>
|
|
179
|
+
) : (
|
|
180
|
+
renderPreviewContent()
|
|
166
181
|
);
|
|
167
182
|
}
|
|
168
183
|
|
|
@@ -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
|
}
|
|
@@ -262,15 +262,19 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
262
262
|
// Do not add new properties here, use `useDispatch` instead to avoid
|
|
263
263
|
// leaking new props to the public API (editor.BlockListBlock filter).
|
|
264
264
|
return {
|
|
265
|
-
setAttributes(
|
|
265
|
+
setAttributes( nextAttributes ) {
|
|
266
266
|
const { getMultiSelectedBlockClientIds } =
|
|
267
267
|
registry.select( blockEditorStore );
|
|
268
268
|
const multiSelectedBlockClientIds =
|
|
269
269
|
getMultiSelectedBlockClientIds();
|
|
270
|
-
const { clientId } = ownProps;
|
|
270
|
+
const { clientId, attributes } = ownProps;
|
|
271
271
|
const clientIds = multiSelectedBlockClientIds.length
|
|
272
272
|
? multiSelectedBlockClientIds
|
|
273
273
|
: [ clientId ];
|
|
274
|
+
const newAttributes =
|
|
275
|
+
typeof nextAttributes === 'function'
|
|
276
|
+
? nextAttributes( attributes )
|
|
277
|
+
: nextAttributes;
|
|
274
278
|
|
|
275
279
|
updateBlockAttributes( clientIds, newAttributes );
|
|
276
280
|
},
|
|
@@ -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;
|
|
@@ -41,12 +41,15 @@ function restore( node ) {
|
|
|
41
41
|
|
|
42
42
|
function down( event ) {
|
|
43
43
|
const { target } = event;
|
|
44
|
-
const { ownerDocument, isContentEditable } = target;
|
|
44
|
+
const { ownerDocument, isContentEditable, tagName } = target;
|
|
45
|
+
const isInputOrTextArea = [ 'INPUT', 'TEXTAREA' ].includes( tagName );
|
|
46
|
+
|
|
45
47
|
const nodes = nodesByDocument.get( ownerDocument );
|
|
46
48
|
|
|
47
|
-
if ( isContentEditable ) {
|
|
48
|
-
// Whenever an editable element is clicked,
|
|
49
|
-
// blocks contain this element, and temporarily
|
|
49
|
+
if ( isContentEditable || isInputOrTextArea ) {
|
|
50
|
+
// Whenever an editable element or an input or textarea is clicked,
|
|
51
|
+
// check which draggable blocks contain this element, and temporarily
|
|
52
|
+
// disable draggability.
|
|
50
53
|
for ( const node of nodes ) {
|
|
51
54
|
if (
|
|
52
55
|
node.getAttribute( 'draggable' ) === 'true' &&
|
|
@@ -57,8 +60,8 @@ function down( event ) {
|
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
} else {
|
|
60
|
-
// Whenever a non-editable element is clicked,
|
|
61
|
-
// for any blocks that were previously disabled.
|
|
63
|
+
// Whenever a non-editable element or an input or textarea is clicked,
|
|
64
|
+
// re-enable draggability for any blocks that were previously disabled.
|
|
62
65
|
for ( const node of nodes ) {
|
|
63
66
|
restore( node );
|
|
64
67
|
}
|
|
@@ -66,11 +69,11 @@ function down( event ) {
|
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
/**
|
|
69
|
-
* In Firefox, the `draggable` and `contenteditable`
|
|
70
|
-
* together. When
|
|
71
|
-
* doesn't get set in the right place. The only
|
|
72
|
-
* remove the `draggable` attribute clicking inside
|
|
73
|
-
*
|
|
72
|
+
* In Firefox, the `draggable` and `contenteditable` or `input` or `textarea`
|
|
73
|
+
* elements don't play well together. When these elements are within a
|
|
74
|
+
* `draggable` element, selection doesn't get set in the right place. The only
|
|
75
|
+
* solution is to temporarily remove the `draggable` attribute clicking inside
|
|
76
|
+
* these elements.
|
|
74
77
|
* @return {Function} Cleanup function.
|
|
75
78
|
*/
|
|
76
79
|
export function useFirefoxDraggableCompatibility() {
|
|
@@ -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
|
}
|
|
@@ -25,6 +25,7 @@ export function useShowBlockTools() {
|
|
|
25
25
|
getSettings,
|
|
26
26
|
__unstableGetEditorMode,
|
|
27
27
|
isTyping,
|
|
28
|
+
isBlockInterfaceHidden,
|
|
28
29
|
} = unlock( select( blockEditorStore ) );
|
|
29
30
|
|
|
30
31
|
const clientId =
|
|
@@ -45,6 +46,7 @@ export function useShowBlockTools() {
|
|
|
45
46
|
editorMode !== 'navigation' &&
|
|
46
47
|
isEmptyDefaultBlock;
|
|
47
48
|
const _showBlockToolbarPopover =
|
|
49
|
+
! isBlockInterfaceHidden() &&
|
|
48
50
|
! getSettings().hasFixedToolbar &&
|
|
49
51
|
! _showEmptyBlockSideInserter &&
|
|
50
52
|
hasSelectedBlock &&
|
|
@@ -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
|
+
};
|
|
@@ -36,7 +36,6 @@ import { getBlockAndPreviewFromMedia } from './utils';
|
|
|
36
36
|
import { store as blockEditorStore } from '../../../store';
|
|
37
37
|
|
|
38
38
|
const ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
39
|
-
const MAXIMUM_TITLE_LENGTH = 25;
|
|
40
39
|
const MEDIA_OPTIONS_POPOVER_PROPS = {
|
|
41
40
|
position: 'bottom left',
|
|
42
41
|
className:
|
|
@@ -239,12 +238,6 @@ export function MediaPreview( { media, onClick, category } ) {
|
|
|
239
238
|
? media.title
|
|
240
239
|
: media.title?.rendered || __( 'no title' );
|
|
241
240
|
|
|
242
|
-
let truncatedTitle;
|
|
243
|
-
if ( title.length > MAXIMUM_TITLE_LENGTH ) {
|
|
244
|
-
const omission = '...';
|
|
245
|
-
truncatedTitle =
|
|
246
|
-
title.slice( 0, MAXIMUM_TITLE_LENGTH - omission.length ) + omission;
|
|
247
|
-
}
|
|
248
241
|
const onMouseEnter = useCallback( () => setIsHovered( true ), [] );
|
|
249
242
|
const onMouseLeave = useCallback( () => setIsHovered( false ), [] );
|
|
250
243
|
return (
|
|
@@ -268,7 +261,7 @@ export function MediaPreview( { media, onClick, category } ) {
|
|
|
268
261
|
onMouseEnter={ onMouseEnter }
|
|
269
262
|
onMouseLeave={ onMouseLeave }
|
|
270
263
|
>
|
|
271
|
-
<Tooltip text={
|
|
264
|
+
<Tooltip text={ title }>
|
|
272
265
|
<Composite.Item
|
|
273
266
|
render={
|
|
274
267
|
<div
|
|
@@ -501,7 +501,7 @@ function LinkControl( {
|
|
|
501
501
|
LinkControl.ViewerFill = ViewerFill;
|
|
502
502
|
LinkControl.DEFAULT_LINK_SETTINGS = DEFAULT_LINK_SETTINGS;
|
|
503
503
|
|
|
504
|
-
|
|
504
|
+
const DeprecatedExperimentalLinkControl = ( props ) => {
|
|
505
505
|
deprecated( 'wp.blockEditor.__experimentalLinkControl', {
|
|
506
506
|
since: '6.8',
|
|
507
507
|
alternative: 'wp.blockEditor.LinkControl',
|
|
@@ -510,4 +510,9 @@ export const DeprecatedExperimentalLinkControl = ( props ) => {
|
|
|
510
510
|
return <LinkControl { ...props } />;
|
|
511
511
|
};
|
|
512
512
|
|
|
513
|
+
DeprecatedExperimentalLinkControl.ViewerFill = LinkControl.ViewerFill;
|
|
514
|
+
DeprecatedExperimentalLinkControl.DEFAULT_LINK_SETTINGS =
|
|
515
|
+
LinkControl.DEFAULT_LINK_SETTINGS;
|
|
516
|
+
|
|
517
|
+
export { DeprecatedExperimentalLinkControl };
|
|
513
518
|
export default LinkControl;
|
|
@@ -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 }
|
|
@@ -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
|
}
|