@wordpress/block-editor 11.6.0 → 11.7.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/README.md +4 -0
- package/build/components/block-list/block-html.js +1 -3
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -23
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/editor-styles/index.js +20 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/color-panel.js +583 -0
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +8 -30
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +129 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +53 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +18 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -35
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +160 -86
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/appender.js +105 -0
- package/build/components/list-view/appender.js.map +1 -0
- package/build/components/list-view/block.js +5 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +25 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +37 -13
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +13 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/rich-text/format-edit.js +2 -30
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/writing-flow/use-input.js +4 -8
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +92 -229
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +4 -2
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
- package/build/hooks/contrast-checker.js.map +1 -0
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +23 -26
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +0 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +25 -76
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/grid.js +165 -0
- package/build/layouts/grid.js.map +1 -0
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build-module/components/block-list/block-html.js +1 -3
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -22
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/editor-styles/index.js +19 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +554 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -30
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +120 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +51 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +8 -35
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +161 -87
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/appender.js +88 -0
- package/build-module/components/list-view/appender.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +22 -5
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +32 -12
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +12 -4
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +3 -31
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +4 -8
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +90 -232
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +4 -2
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
- package/build-module/hooks/contrast-checker.js.map +1 -0
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/position.js +3 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +23 -26
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +0 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +23 -73
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/grid.js +151 -0
- package/build-module/layouts/grid.js.map +1 -0
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-style/style-rtl.css +26 -6
- package/build-style/style.css +26 -6
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +13 -42
- package/src/components/global-styles/get-block-css-selector.js +129 -0
- package/src/components/global-styles/hooks.js +80 -0
- package/src/components/global-styles/index.js +2 -1
- package/src/components/global-styles/test/use-global-styles-output.js +30 -1
- package/src/components/global-styles/typography-panel.js +26 -51
- package/src/components/global-styles/use-global-styles-output.js +163 -80
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +5 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +43 -10
- package/src/components/list-view/style.scss +19 -0
- package/src/components/media-replace-flow/index.js +36 -24
- package/src/components/media-replace-flow/style.scss +5 -2
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/border.js +0 -1
- package/src/hooks/color.js +120 -296
- package/src/hooks/content-lock-ui.js +6 -2
- package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +8 -5
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +0 -1
- package/src/hooks/utils.js +27 -70
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/private-apis.js +2 -0
- package/src/utils/object.js +69 -0
- package/src/utils/test/object.js +107 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import {
|
|
5
|
+
__experimentalTreeGridRow as TreeGridRow,
|
|
6
|
+
__experimentalTreeGridCell as TreeGridCell,
|
|
7
|
+
} from '@wordpress/components';
|
|
4
8
|
import { memo } from '@wordpress/element';
|
|
5
9
|
import { AsyncModeProvider, useSelect } from '@wordpress/data';
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Internal dependencies
|
|
9
13
|
*/
|
|
14
|
+
import { Appender } from './appender';
|
|
10
15
|
import ListViewBlock from './block';
|
|
11
16
|
import { useListViewContext } from './context';
|
|
12
17
|
import { isClientIdSelected } from './utils';
|
|
@@ -93,6 +98,7 @@ function ListViewBranch( props ) {
|
|
|
93
98
|
parentId,
|
|
94
99
|
shouldShowInnerBlocks = true,
|
|
95
100
|
isSyncedBranch = false,
|
|
101
|
+
showAppender: showAppenderProp = true,
|
|
96
102
|
} = props;
|
|
97
103
|
|
|
98
104
|
const parentBlockInformation = useBlockDisplayInformation( parentId );
|
|
@@ -120,8 +126,12 @@ function ListViewBranch( props ) {
|
|
|
120
126
|
return null;
|
|
121
127
|
}
|
|
122
128
|
|
|
129
|
+
// Only show the appender at the first level.
|
|
130
|
+
const showAppender = showAppenderProp && level === 1;
|
|
123
131
|
const filteredBlocks = blocks.filter( Boolean );
|
|
124
132
|
const blockCount = filteredBlocks.length;
|
|
133
|
+
// The appender means an extra row in List View, so add 1 to the row count.
|
|
134
|
+
const rowCount = showAppender ? blockCount + 1 : blockCount;
|
|
125
135
|
let nextPosition = listPosition;
|
|
126
136
|
|
|
127
137
|
return (
|
|
@@ -175,7 +185,7 @@ function ListViewBranch( props ) {
|
|
|
175
185
|
isDragged={ isDragged }
|
|
176
186
|
level={ level }
|
|
177
187
|
position={ position }
|
|
178
|
-
rowCount={
|
|
188
|
+
rowCount={ rowCount }
|
|
179
189
|
siblingBlockCount={ blockCount }
|
|
180
190
|
showBlockMovers={ showBlockMovers }
|
|
181
191
|
path={ updatedPath }
|
|
@@ -209,6 +219,25 @@ function ListViewBranch( props ) {
|
|
|
209
219
|
</AsyncModeProvider>
|
|
210
220
|
);
|
|
211
221
|
} ) }
|
|
222
|
+
{ showAppender && (
|
|
223
|
+
<TreeGridRow
|
|
224
|
+
level={ level }
|
|
225
|
+
setSize={ rowCount }
|
|
226
|
+
positionInSet={ rowCount }
|
|
227
|
+
isExpanded={ true }
|
|
228
|
+
>
|
|
229
|
+
<TreeGridCell>
|
|
230
|
+
{ ( treeGridCellProps ) => (
|
|
231
|
+
<Appender
|
|
232
|
+
clientId={ parentId }
|
|
233
|
+
nestingLevel={ level }
|
|
234
|
+
blockCount={ blockCount }
|
|
235
|
+
{ ...treeGridCellProps }
|
|
236
|
+
/>
|
|
237
|
+
) }
|
|
238
|
+
</TreeGridCell>
|
|
239
|
+
</TreeGridRow>
|
|
240
|
+
) }
|
|
212
241
|
</>
|
|
213
242
|
);
|
|
214
243
|
}
|
|
@@ -28,6 +28,7 @@ import useListViewClientIds from './use-list-view-client-ids';
|
|
|
28
28
|
import useListViewDropZone from './use-list-view-drop-zone';
|
|
29
29
|
import useListViewExpandSelectedItem from './use-list-view-expand-selected-item';
|
|
30
30
|
import { store as blockEditorStore } from '../../store';
|
|
31
|
+
import { BlockSettingsDropdown } from '../block-settings-menu/block-settings-dropdown';
|
|
31
32
|
|
|
32
33
|
const expanded = ( state, action ) => {
|
|
33
34
|
if ( Array.isArray( action.clientIds ) ) {
|
|
@@ -47,18 +48,30 @@ const expanded = ( state, action ) => {
|
|
|
47
48
|
|
|
48
49
|
export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
49
50
|
|
|
51
|
+
/** @typedef {import('react').ComponentType} ComponentType */
|
|
52
|
+
/** @typedef {import('react').Ref<HTMLElement>} Ref */
|
|
53
|
+
|
|
50
54
|
/**
|
|
51
55
|
* Show a hierarchical list of blocks.
|
|
52
56
|
*
|
|
53
|
-
* @param {Object}
|
|
54
|
-
* @param {string}
|
|
55
|
-
* @param {Array}
|
|
56
|
-
* @param {boolean}
|
|
57
|
-
* @param {boolean}
|
|
58
|
-
* @param {
|
|
57
|
+
* @param {Object} props Components props.
|
|
58
|
+
* @param {string} props.id An HTML element id for the root element of ListView.
|
|
59
|
+
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
60
|
+
* @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.
|
|
61
|
+
* @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.
|
|
62
|
+
* @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.
|
|
63
|
+
* @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.
|
|
64
|
+
* @param {Ref} ref Forwarded ref
|
|
59
65
|
*/
|
|
60
|
-
function
|
|
61
|
-
{
|
|
66
|
+
function ListViewComponent(
|
|
67
|
+
{
|
|
68
|
+
id,
|
|
69
|
+
blocks,
|
|
70
|
+
showBlockMovers = false,
|
|
71
|
+
isExpanded = false,
|
|
72
|
+
showAppender = false,
|
|
73
|
+
blockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,
|
|
74
|
+
},
|
|
62
75
|
ref
|
|
63
76
|
) {
|
|
64
77
|
const { clientIdsTree, draggedClientIds, selectedClientIds } =
|
|
@@ -170,8 +183,16 @@ function ListView(
|
|
|
170
183
|
expandedState,
|
|
171
184
|
expand,
|
|
172
185
|
collapse,
|
|
186
|
+
BlockSettingsMenu,
|
|
173
187
|
} ),
|
|
174
|
-
[
|
|
188
|
+
[
|
|
189
|
+
isMounted.current,
|
|
190
|
+
draggedClientIds,
|
|
191
|
+
expandedState,
|
|
192
|
+
expand,
|
|
193
|
+
collapse,
|
|
194
|
+
BlockSettingsMenu,
|
|
195
|
+
]
|
|
175
196
|
);
|
|
176
197
|
|
|
177
198
|
// If there are no blocks to show, do not render the list view.
|
|
@@ -204,10 +225,22 @@ function ListView(
|
|
|
204
225
|
selectedClientIds={ selectedClientIds }
|
|
205
226
|
isExpanded={ isExpanded }
|
|
206
227
|
shouldShowInnerBlocks={ shouldShowInnerBlocks }
|
|
228
|
+
showAppender={ showAppender }
|
|
207
229
|
/>
|
|
208
230
|
</ListViewContext.Provider>
|
|
209
231
|
</TreeGrid>
|
|
210
232
|
</AsyncModeProvider>
|
|
211
233
|
);
|
|
212
234
|
}
|
|
213
|
-
export
|
|
235
|
+
export const PrivateListView = forwardRef( ListViewComponent );
|
|
236
|
+
|
|
237
|
+
export default forwardRef( ( props, ref ) => {
|
|
238
|
+
return (
|
|
239
|
+
<PrivateListView
|
|
240
|
+
ref={ ref }
|
|
241
|
+
{ ...props }
|
|
242
|
+
showAppender={ false }
|
|
243
|
+
blockSettingsMenu={ BlockSettingsDropdown }
|
|
244
|
+
/>
|
|
245
|
+
);
|
|
246
|
+
} );
|
|
@@ -410,3 +410,22 @@ $block-navigation-max-indent: 8;
|
|
|
410
410
|
height: 36px;
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
.list-view-appender .block-editor-inserter__toggle {
|
|
414
|
+
background-color: #1e1e1e;
|
|
415
|
+
color: #fff;
|
|
416
|
+
margin: $grid-unit-10 0 0 24px;
|
|
417
|
+
border-radius: 2px;
|
|
418
|
+
height: 24px;
|
|
419
|
+
min-width: 24px;
|
|
420
|
+
padding: 0;
|
|
421
|
+
|
|
422
|
+
&:hover,
|
|
423
|
+
&:focus {
|
|
424
|
+
background: var(--wp-admin-theme-color);
|
|
425
|
+
color: #fff;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.list-view-appender__description {
|
|
430
|
+
display: none;
|
|
431
|
+
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -58,6 +63,7 @@ const MediaReplaceFlow = ( {
|
|
|
58
63
|
const mediaUpload = useSelect( ( select ) => {
|
|
59
64
|
return select( blockEditorStore ).getSettings().mediaUpload;
|
|
60
65
|
}, [] );
|
|
66
|
+
const canUpload = !! mediaUpload;
|
|
61
67
|
const editMediaButtonRef = useRef();
|
|
62
68
|
const errorNoticeID = `block-editor/media-replace-flow/error-notice/${ ++uniqueId }`;
|
|
63
69
|
|
|
@@ -152,7 +158,7 @@ const MediaReplaceFlow = ( {
|
|
|
152
158
|
renderContent={ ( { onClose } ) => (
|
|
153
159
|
<>
|
|
154
160
|
<NavigableMenu className="block-editor-media-replace-flow__media-upload-menu">
|
|
155
|
-
|
|
161
|
+
<MediaUploadCheck>
|
|
156
162
|
<MediaUpload
|
|
157
163
|
gallery={ gallery }
|
|
158
164
|
addToGallery={ addToGallery }
|
|
@@ -171,28 +177,26 @@ const MediaReplaceFlow = ( {
|
|
|
171
177
|
</MenuItem>
|
|
172
178
|
) }
|
|
173
179
|
/>
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
</MediaUploadCheck>
|
|
195
|
-
</>
|
|
180
|
+
<FormFileUpload
|
|
181
|
+
onChange={ ( event ) => {
|
|
182
|
+
uploadFiles( event, onClose );
|
|
183
|
+
} }
|
|
184
|
+
accept={ accept }
|
|
185
|
+
multiple={ multiple }
|
|
186
|
+
render={ ( { openFileDialog } ) => {
|
|
187
|
+
return (
|
|
188
|
+
<MenuItem
|
|
189
|
+
icon={ upload }
|
|
190
|
+
onClick={ () => {
|
|
191
|
+
openFileDialog();
|
|
192
|
+
} }
|
|
193
|
+
>
|
|
194
|
+
{ __( 'Upload' ) }
|
|
195
|
+
</MenuItem>
|
|
196
|
+
);
|
|
197
|
+
} }
|
|
198
|
+
/>
|
|
199
|
+
</MediaUploadCheck>
|
|
196
200
|
{ onToggleFeaturedImage && (
|
|
197
201
|
<MenuItem
|
|
198
202
|
icon={ postFeaturedImage }
|
|
@@ -206,7 +210,15 @@ const MediaReplaceFlow = ( {
|
|
|
206
210
|
</NavigableMenu>
|
|
207
211
|
{ onSelectURL && (
|
|
208
212
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
209
|
-
<form
|
|
213
|
+
<form
|
|
214
|
+
className={ classnames(
|
|
215
|
+
'block-editor-media-flow__url-input',
|
|
216
|
+
{
|
|
217
|
+
'has-siblings':
|
|
218
|
+
canUpload || onToggleFeaturedImage,
|
|
219
|
+
}
|
|
220
|
+
) }
|
|
221
|
+
>
|
|
210
222
|
<span className="block-editor-media-replace-flow__image-url-label">
|
|
211
223
|
{ __( 'Current media URL:' ) }
|
|
212
224
|
</span>
|
|
@@ -10,12 +10,15 @@
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.block-editor-media-flow__url-input {
|
|
13
|
-
border-top: $border-width solid $gray-900;
|
|
14
|
-
margin-top: $grid-unit-10;
|
|
15
13
|
margin-right: -$grid-unit-10;
|
|
16
14
|
margin-left: -$grid-unit-10;
|
|
17
15
|
padding: $grid-unit-20;
|
|
18
16
|
|
|
17
|
+
&.has-siblings {
|
|
18
|
+
border-top: $border-width solid $gray-900;
|
|
19
|
+
margin-top: $grid-unit-10;
|
|
20
|
+
}
|
|
21
|
+
|
|
19
22
|
.block-editor-media-replace-flow__image-url-label {
|
|
20
23
|
display: block;
|
|
21
24
|
top: $grid-unit-20;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
getActiveFormat,
|
|
6
|
-
getActiveObject,
|
|
7
|
-
isCollapsed,
|
|
8
|
-
} from '@wordpress/rich-text';
|
|
4
|
+
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
|
|
9
5
|
|
|
10
6
|
export default function FormatEdit( {
|
|
11
7
|
formatTypes,
|
|
@@ -22,37 +18,11 @@ export default function FormatEdit( {
|
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
const activeFormat = getActiveFormat( value, name );
|
|
25
|
-
|
|
21
|
+
const isActive = activeFormat !== undefined;
|
|
26
22
|
const activeObject = getActiveObject( value );
|
|
27
23
|
const isObjectActive =
|
|
28
24
|
activeObject !== undefined && activeObject.type === name;
|
|
29
25
|
|
|
30
|
-
// Edge case: un-collapsed link formats.
|
|
31
|
-
// If there is a missing link format at either end of the selection
|
|
32
|
-
// then we shouldn't show the Edit UI because the selection has exceeded
|
|
33
|
-
// the bounds of the link format.
|
|
34
|
-
// Also if the format objects don't match then we're dealing with two separate
|
|
35
|
-
// links so we should not allow the link to be modified over the top.
|
|
36
|
-
if ( name === 'core/link' && ! isCollapsed( value ) ) {
|
|
37
|
-
const formats = value.formats;
|
|
38
|
-
|
|
39
|
-
const linkFormatAtStart = formats[ value.start ]?.find(
|
|
40
|
-
( { type } ) => type === 'core/link'
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const linkFormatAtEnd = formats[ value.end - 1 ]?.find(
|
|
44
|
-
( { type } ) => type === 'core/link'
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
! linkFormatAtStart ||
|
|
49
|
-
! linkFormatAtEnd ||
|
|
50
|
-
linkFormatAtStart !== linkFormatAtEnd
|
|
51
|
-
) {
|
|
52
|
-
isActive = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
26
|
return (
|
|
57
27
|
<Edit
|
|
58
28
|
key={ name }
|
|
@@ -31,11 +31,10 @@ export default function useInput() {
|
|
|
31
31
|
|
|
32
32
|
return useRefEffect( ( node ) => {
|
|
33
33
|
function onBeforeInput( event ) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if ( event.inputType?.startsWith( 'format' ) ) {
|
|
34
|
+
// If writing flow is editable, NEVER allow the browser to alter the
|
|
35
|
+
// DOM. This will cause React errors (and the DOM should only be
|
|
36
|
+
// altered in a controlled fashion).
|
|
37
|
+
if ( node.contentEditable === 'true' ) {
|
|
39
38
|
event.preventDefault();
|
|
40
39
|
}
|
|
41
40
|
}
|