@wordpress/block-editor 14.3.2 → 14.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-heading-level-dropdown/index.js +3 -1
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-list/block.js +27 -4
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +0 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/zoom-out-separator.js +18 -1
- package/build/components/block-list/zoom-out-separator.js.map +1 -1
- package/build/components/block-switcher/utils.js +1 -1
- package/build/components/block-switcher/utils.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +6 -3
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/paste-handler.js +2 -13
- package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build/components/rich-text/index.js +34 -20
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/writing-flow/index.js +1 -2
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +1 -4
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-input.js +1 -31
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +1 -14
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +2 -6
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/utils.js +0 -27
- package/build/components/writing-flow/utils.js.map +1 -1
- package/build/hooks/layout.js +12 -8
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +20 -26
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/store/selectors.js +6 -3
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +3 -1
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-list/block.js +28 -7
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +0 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/zoom-out-separator.js +18 -1
- package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
- package/build-module/components/block-switcher/utils.js +1 -1
- package/build-module/components/block-switcher/utils.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +6 -3
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/paste-handler.js +2 -13
- package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build-module/components/rich-text/index.js +34 -20
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +1 -2
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +1 -4
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +1 -31
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +1 -14
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +2 -6
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/utils.js +0 -26
- package/build-module/components/writing-flow/utils.js.map +1 -1
- package/build-module/hooks/layout.js +13 -9
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +20 -26
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/store/selectors.js +6 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +10 -0
- package/build-style/content.css +10 -0
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/package.json +20 -20
- package/src/components/block-heading-level-dropdown/index.js +7 -1
- package/src/components/block-list/block.js +47 -11
- package/src/components/block-list/content.scss +12 -0
- package/src/components/block-list/use-block-props/use-focus-first-element.js +0 -1
- package/src/components/block-list/zoom-out-separator.js +14 -1
- package/src/components/block-switcher/test/use-transformed.patterns.js +3 -3
- package/src/components/block-switcher/test/utils.js +3 -3
- package/src/components/block-switcher/utils.js +1 -1
- package/src/components/block-toolbar/style.scss +7 -0
- package/src/components/block-variation-transforms/index.js +6 -7
- package/src/components/rich-text/event-listeners/paste-handler.js +2 -7
- package/src/components/rich-text/index.js +36 -23
- package/src/components/writing-flow/index.js +0 -2
- package/src/components/writing-flow/use-arrow-nav.js +2 -9
- package/src/components/writing-flow/use-input.js +1 -36
- package/src/components/writing-flow/use-select-all.js +1 -18
- package/src/components/writing-flow/use-selection-observer.js +3 -14
- package/src/components/writing-flow/utils.js +0 -30
- package/src/hooks/layout.js +17 -12
- package/src/hooks/use-bindings-attributes.js +24 -29
- package/src/store/selectors.js +6 -6
- package/src/store/test/private-selectors.js +2 -2
- package/src/store/test/selectors.js +10 -6
- package/build/components/writing-flow/use-event-redirect.js +0 -66
- package/build/components/writing-flow/use-event-redirect.js.map +0 -1
- package/build-module/components/writing-flow/use-event-redirect.js +0 -60
- package/build-module/components/writing-flow/use-event-redirect.js.map +0 -1
- package/src/components/writing-flow/use-event-redirect.js +0 -72
|
@@ -497,6 +497,16 @@ _::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-b
|
|
|
497
497
|
margin-right: -1px;
|
|
498
498
|
margin-left: -1px;
|
|
499
499
|
transition: background-color 0.3s ease;
|
|
500
|
+
display: flex;
|
|
501
|
+
align-items: center;
|
|
502
|
+
justify-content: center;
|
|
503
|
+
font-size: 13px;
|
|
504
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
505
|
+
color: #000;
|
|
506
|
+
font-weight: normal;
|
|
507
|
+
}
|
|
508
|
+
.is-zoomed-out .block-editor-block-list__zoom-out-separator {
|
|
509
|
+
font-size: calc(13px * ( 2 - var(--wp-block-editor-iframe-zoom-out-scale) ));
|
|
500
510
|
}
|
|
501
511
|
.block-editor-block-list__zoom-out-separator.is-dragged-over {
|
|
502
512
|
background: #ccc;
|
package/build-style/content.css
CHANGED
|
@@ -497,6 +497,16 @@ _::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-b
|
|
|
497
497
|
margin-left: -1px;
|
|
498
498
|
margin-right: -1px;
|
|
499
499
|
transition: background-color 0.3s ease;
|
|
500
|
+
display: flex;
|
|
501
|
+
align-items: center;
|
|
502
|
+
justify-content: center;
|
|
503
|
+
font-size: 13px;
|
|
504
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
505
|
+
color: #000;
|
|
506
|
+
font-weight: normal;
|
|
507
|
+
}
|
|
508
|
+
.is-zoomed-out .block-editor-block-list__zoom-out-separator {
|
|
509
|
+
font-size: calc(13px * ( 2 - var(--wp-block-editor-iframe-zoom-out-scale) ));
|
|
500
510
|
}
|
|
501
511
|
.block-editor-block-list__zoom-out-separator.is-dragged-over {
|
|
502
512
|
background: #ccc;
|
|
@@ -3465,6 +3465,10 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3465
3465
|
border: 0;
|
|
3466
3466
|
border-left: 1px solid #ddd;
|
|
3467
3467
|
}
|
|
3468
|
+
.block-editor-block-toolbar.is-connected .block-editor-block-switcher .components-button::before {
|
|
3469
|
+
background: color-mix(in srgb, var(--wp-block-synced-color) 10%, transparent);
|
|
3470
|
+
border-radius: 2px;
|
|
3471
|
+
}
|
|
3468
3472
|
.block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon, .block-editor-block-toolbar.is-connected .block-editor-block-switcher .components-button .block-editor-block-icon {
|
|
3469
3473
|
color: var(--wp-block-synced-color);
|
|
3470
3474
|
}
|
package/build-style/style.css
CHANGED
|
@@ -3466,6 +3466,10 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3466
3466
|
border: 0;
|
|
3467
3467
|
border-right: 1px solid #ddd;
|
|
3468
3468
|
}
|
|
3469
|
+
.block-editor-block-toolbar.is-connected .block-editor-block-switcher .components-button::before {
|
|
3470
|
+
background: color-mix(in srgb, var(--wp-block-synced-color) 10%, transparent);
|
|
3471
|
+
border-radius: 2px;
|
|
3472
|
+
}
|
|
3469
3473
|
.block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon, .block-editor-block-toolbar.is-connected .block-editor-block-switcher .components-button .block-editor-block-icon {
|
|
3470
3474
|
color: var(--wp-block-synced-color);
|
|
3471
3475
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.3",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -36,31 +36,31 @@
|
|
|
36
36
|
"@emotion/react": "^11.7.1",
|
|
37
37
|
"@emotion/styled": "^11.6.0",
|
|
38
38
|
"@react-spring/web": "^9.4.5",
|
|
39
|
-
"@wordpress/a11y": "^4.8.
|
|
40
|
-
"@wordpress/api-fetch": "^7.8.
|
|
39
|
+
"@wordpress/a11y": "^4.8.2",
|
|
40
|
+
"@wordpress/api-fetch": "^7.8.2",
|
|
41
41
|
"@wordpress/blob": "^4.8.1",
|
|
42
42
|
"@wordpress/block-serialization-default-parser": "^5.8.1",
|
|
43
|
-
"@wordpress/blocks": "^13.8.
|
|
44
|
-
"@wordpress/commands": "^1.8.
|
|
45
|
-
"@wordpress/components": "^28.8.
|
|
46
|
-
"@wordpress/compose": "^7.8.
|
|
47
|
-
"@wordpress/data": "^10.8.
|
|
48
|
-
"@wordpress/date": "^5.8.
|
|
49
|
-
"@wordpress/deprecated": "^4.8.
|
|
50
|
-
"@wordpress/dom": "^4.8.
|
|
43
|
+
"@wordpress/blocks": "^13.8.3",
|
|
44
|
+
"@wordpress/commands": "^1.8.3",
|
|
45
|
+
"@wordpress/components": "^28.8.3",
|
|
46
|
+
"@wordpress/compose": "^7.8.3",
|
|
47
|
+
"@wordpress/data": "^10.8.3",
|
|
48
|
+
"@wordpress/date": "^5.8.2",
|
|
49
|
+
"@wordpress/deprecated": "^4.8.2",
|
|
50
|
+
"@wordpress/dom": "^4.8.2",
|
|
51
51
|
"@wordpress/element": "^6.8.1",
|
|
52
52
|
"@wordpress/escape-html": "^3.8.1",
|
|
53
|
-
"@wordpress/hooks": "^4.8.
|
|
53
|
+
"@wordpress/hooks": "^4.8.2",
|
|
54
54
|
"@wordpress/html-entities": "^4.8.1",
|
|
55
|
-
"@wordpress/i18n": "^5.8.
|
|
56
|
-
"@wordpress/icons": "^10.8.
|
|
55
|
+
"@wordpress/i18n": "^5.8.2",
|
|
56
|
+
"@wordpress/icons": "^10.8.2",
|
|
57
57
|
"@wordpress/is-shallow-equal": "^5.8.1",
|
|
58
|
-
"@wordpress/keyboard-shortcuts": "^5.8.
|
|
59
|
-
"@wordpress/keycodes": "^4.8.
|
|
60
|
-
"@wordpress/notices": "^5.8.
|
|
61
|
-
"@wordpress/preferences": "^4.8.
|
|
58
|
+
"@wordpress/keyboard-shortcuts": "^5.8.3",
|
|
59
|
+
"@wordpress/keycodes": "^4.8.2",
|
|
60
|
+
"@wordpress/notices": "^5.8.3",
|
|
61
|
+
"@wordpress/preferences": "^4.8.3",
|
|
62
62
|
"@wordpress/private-apis": "^1.8.1",
|
|
63
|
-
"@wordpress/rich-text": "^7.8.
|
|
63
|
+
"@wordpress/rich-text": "^7.8.3",
|
|
64
64
|
"@wordpress/style-engine": "^2.8.1",
|
|
65
65
|
"@wordpress/token-list": "^3.8.1",
|
|
66
66
|
"@wordpress/url": "^4.8.1",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "6187079697e13c3292eb098d6338523a6676c6e8"
|
|
92
92
|
}
|
|
@@ -40,12 +40,18 @@ export default function HeadingLevelDropdown( {
|
|
|
40
40
|
value,
|
|
41
41
|
onChange,
|
|
42
42
|
} ) {
|
|
43
|
+
const validOptions = options
|
|
44
|
+
.filter(
|
|
45
|
+
( option ) => option === 0 || HEADING_LEVELS.includes( option )
|
|
46
|
+
)
|
|
47
|
+
.sort( ( a, b ) => a - b ); // Sorts numerically in ascending order;
|
|
48
|
+
|
|
43
49
|
return (
|
|
44
50
|
<ToolbarDropdownMenu
|
|
45
51
|
popoverProps={ POPOVER_PROPS }
|
|
46
52
|
icon={ <HeadingLevelIcon level={ value } /> }
|
|
47
53
|
label={ __( 'Change level' ) }
|
|
48
|
-
controls={
|
|
54
|
+
controls={ validOptions.map( ( targetLevel ) => {
|
|
49
55
|
const isActive = targetLevel === value;
|
|
50
56
|
return {
|
|
51
57
|
icon: <HeadingLevelIcon level={ targetLevel } />,
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
getBlockDefaultClassName,
|
|
26
26
|
hasBlockSupport,
|
|
27
27
|
store as blocksStore,
|
|
28
|
+
privateApis as blocksPrivateApis,
|
|
28
29
|
} from '@wordpress/blocks';
|
|
29
30
|
import { withFilters } from '@wordpress/components';
|
|
30
31
|
import { withDispatch, useDispatch, useSelect } from '@wordpress/data';
|
|
@@ -46,6 +47,8 @@ import { PrivateBlockContext } from './private-block-context';
|
|
|
46
47
|
|
|
47
48
|
import { unlock } from '../../lock-unlock';
|
|
48
49
|
|
|
50
|
+
const { isUnmodifiedBlockContent } = unlock( blocksPrivateApis );
|
|
51
|
+
|
|
49
52
|
/**
|
|
50
53
|
* Merges wrapper props with special handling for classNames and styles.
|
|
51
54
|
*
|
|
@@ -350,12 +353,48 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
350
353
|
removeBlock( _clientId );
|
|
351
354
|
} else {
|
|
352
355
|
registry.batch( () => {
|
|
356
|
+
const firstBlock = getBlock( firstClientId );
|
|
357
|
+
const isFirstBlockContentUnmodified =
|
|
358
|
+
isUnmodifiedBlockContent( firstBlock );
|
|
359
|
+
const defaultBlockName = getDefaultBlockName();
|
|
360
|
+
const replacement = switchToBlockType(
|
|
361
|
+
firstBlock,
|
|
362
|
+
defaultBlockName
|
|
363
|
+
);
|
|
364
|
+
const canTransformToDefaultBlock =
|
|
365
|
+
!! replacement?.length &&
|
|
366
|
+
replacement.every( ( block ) =>
|
|
367
|
+
canInsertBlockType( block.name, _clientId )
|
|
368
|
+
);
|
|
369
|
+
|
|
353
370
|
if (
|
|
371
|
+
isFirstBlockContentUnmodified &&
|
|
372
|
+
canTransformToDefaultBlock
|
|
373
|
+
) {
|
|
374
|
+
// Step 1: If the block is empty and can be transformed to the default block type.
|
|
375
|
+
replaceBlocks(
|
|
376
|
+
firstClientId,
|
|
377
|
+
replacement,
|
|
378
|
+
changeSelection
|
|
379
|
+
);
|
|
380
|
+
} else if (
|
|
381
|
+
isFirstBlockContentUnmodified &&
|
|
382
|
+
firstBlock.name === defaultBlockName
|
|
383
|
+
) {
|
|
384
|
+
// Step 2: If the block is empty and is already the default block type.
|
|
385
|
+
removeBlock( firstClientId );
|
|
386
|
+
const nextBlockClientId =
|
|
387
|
+
getNextBlockClientId( clientId );
|
|
388
|
+
if ( nextBlockClientId ) {
|
|
389
|
+
selectBlock( nextBlockClientId );
|
|
390
|
+
}
|
|
391
|
+
} else if (
|
|
354
392
|
canInsertBlockType(
|
|
355
|
-
|
|
393
|
+
firstBlock.name,
|
|
356
394
|
targetRootClientId
|
|
357
395
|
)
|
|
358
396
|
) {
|
|
397
|
+
// Step 3: If the block can be moved up.
|
|
359
398
|
moveBlocksToPosition(
|
|
360
399
|
[ firstClientId ],
|
|
361
400
|
_clientId,
|
|
@@ -363,21 +402,17 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
363
402
|
getBlockIndex( _clientId )
|
|
364
403
|
);
|
|
365
404
|
} else {
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
getDefaultBlockName()
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
if (
|
|
372
|
-
replacement &&
|
|
373
|
-
replacement.length &&
|
|
405
|
+
const canLiftAndTransformToDefaultBlock =
|
|
406
|
+
!! replacement?.length &&
|
|
374
407
|
replacement.every( ( block ) =>
|
|
375
408
|
canInsertBlockType(
|
|
376
409
|
block.name,
|
|
377
410
|
targetRootClientId
|
|
378
411
|
)
|
|
379
|
-
)
|
|
380
|
-
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
if ( canLiftAndTransformToDefaultBlock ) {
|
|
415
|
+
// Step 4: If the block can be transformed to the default block type and moved up.
|
|
381
416
|
insertBlocks(
|
|
382
417
|
replacement,
|
|
383
418
|
getBlockIndex( _clientId ),
|
|
@@ -386,6 +421,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
386
421
|
);
|
|
387
422
|
removeBlock( firstClientId, false );
|
|
388
423
|
} else {
|
|
424
|
+
// Step 5: Continue the default behavior.
|
|
389
425
|
switchToDefaultOrRemove();
|
|
390
426
|
}
|
|
391
427
|
}
|
|
@@ -461,6 +461,18 @@ _::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-b
|
|
|
461
461
|
margin-left: -1px;
|
|
462
462
|
margin-right: -1px;
|
|
463
463
|
transition: background-color 0.3s ease;
|
|
464
|
+
display: flex;
|
|
465
|
+
align-items: center;
|
|
466
|
+
justify-content: center;
|
|
467
|
+
font-size: $default-font-size;
|
|
468
|
+
font-family: $default-font;
|
|
469
|
+
color: $black;
|
|
470
|
+
font-weight: normal;
|
|
471
|
+
|
|
472
|
+
.is-zoomed-out & {
|
|
473
|
+
// Scale the font size based on the zoom level.
|
|
474
|
+
font-size: calc(#{$default-font-size} * ( 2 - var(--wp-block-editor-iframe-zoom-out-scale) ));
|
|
475
|
+
}
|
|
464
476
|
|
|
465
477
|
&.is-dragged-over {
|
|
466
478
|
background: $gray-400;
|
|
@@ -68,7 +68,6 @@ export function useFocusFirstElement( { clientId, initialPosition } ) {
|
|
|
68
68
|
textInputs[ isReverse ? textInputs.length - 1 : 0 ] || ref.current;
|
|
69
69
|
|
|
70
70
|
if ( ! isInsideRootBlock( ref.current, target ) ) {
|
|
71
|
-
ownerDocument.defaultView.getSelection().removeAllRanges();
|
|
72
71
|
ref.current.focus();
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { useReducedMotion } from '@wordpress/compose';
|
|
14
14
|
import { useSelect } from '@wordpress/data';
|
|
15
15
|
import { useState } from '@wordpress/element';
|
|
16
|
+
import { __ } from '@wordpress/i18n';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Internal dependencies
|
|
@@ -103,7 +104,19 @@ export function ZoomOutSeparator( {
|
|
|
103
104
|
data-is-insertion-point="true"
|
|
104
105
|
onDragOver={ () => setIsDraggedOver( true ) }
|
|
105
106
|
onDragLeave={ () => setIsDraggedOver( false ) }
|
|
106
|
-
|
|
107
|
+
>
|
|
108
|
+
<motion.div
|
|
109
|
+
initial={ { opacity: 0 } }
|
|
110
|
+
animate={ { opacity: 1 } }
|
|
111
|
+
exit={ { opacity: 0 } }
|
|
112
|
+
transition={ {
|
|
113
|
+
type: 'tween',
|
|
114
|
+
duration: 0.1,
|
|
115
|
+
} }
|
|
116
|
+
>
|
|
117
|
+
{ __( 'Drop pattern.' ) }
|
|
118
|
+
</motion.div>
|
|
119
|
+
</motion.div>
|
|
107
120
|
) }
|
|
108
121
|
</AnimatePresence>
|
|
109
122
|
);
|
|
@@ -20,15 +20,15 @@ describe( 'use-transformed-patterns', () => {
|
|
|
20
20
|
},
|
|
21
21
|
content: {
|
|
22
22
|
type: 'boolean',
|
|
23
|
-
|
|
23
|
+
role: 'content',
|
|
24
24
|
},
|
|
25
25
|
level: {
|
|
26
26
|
type: 'number',
|
|
27
|
-
|
|
27
|
+
role: 'content',
|
|
28
28
|
},
|
|
29
29
|
color: {
|
|
30
30
|
type: 'string',
|
|
31
|
-
|
|
31
|
+
role: 'other',
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
save() {},
|
|
@@ -18,15 +18,15 @@ describe( 'BlockSwitcher - utils', () => {
|
|
|
18
18
|
},
|
|
19
19
|
content: {
|
|
20
20
|
type: 'boolean',
|
|
21
|
-
|
|
21
|
+
role: 'content',
|
|
22
22
|
},
|
|
23
23
|
level: {
|
|
24
24
|
type: 'number',
|
|
25
|
-
|
|
25
|
+
role: 'content',
|
|
26
26
|
},
|
|
27
27
|
color: {
|
|
28
28
|
type: 'string',
|
|
29
|
-
|
|
29
|
+
role: 'other',
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
save() {},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { getBlockAttributesNamesByRole } from '@wordpress/blocks';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Try to find a matching block by a block's name in a provided
|
|
@@ -37,6 +37,13 @@
|
|
|
37
37
|
border-right: $border-width solid $gray-300;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
&.is-connected {
|
|
41
|
+
.block-editor-block-switcher .components-button::before {
|
|
42
|
+
background: color-mix(in srgb, var(--wp-block-synced-color) 10%, transparent);
|
|
43
|
+
border-radius: $radius-small;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
&.is-synced,
|
|
41
48
|
&.is-connected {
|
|
42
49
|
.block-editor-block-switcher .components-button .block-editor-block-icon {
|
|
@@ -21,6 +21,7 @@ import { chevronDown } from '@wordpress/icons';
|
|
|
21
21
|
*/
|
|
22
22
|
import BlockIcon from '../block-icon';
|
|
23
23
|
import { store as blockEditorStore } from '../../store';
|
|
24
|
+
import { unlock } from '../../lock-unlock';
|
|
24
25
|
|
|
25
26
|
function VariationsButtons( {
|
|
26
27
|
className,
|
|
@@ -142,18 +143,16 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
|
142
143
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
143
144
|
const { activeBlockVariation, variations, isContentOnly } = useSelect(
|
|
144
145
|
( select ) => {
|
|
145
|
-
const {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
__experimentalHasContentRoleAttribute,
|
|
149
|
-
} = select( blocksStore );
|
|
146
|
+
const { getActiveBlockVariation, getBlockVariations } =
|
|
147
|
+
select( blocksStore );
|
|
148
|
+
|
|
150
149
|
const { getBlockName, getBlockAttributes, getBlockEditingMode } =
|
|
151
150
|
select( blockEditorStore );
|
|
152
151
|
|
|
153
152
|
const name = blockClientId && getBlockName( blockClientId );
|
|
154
153
|
|
|
155
|
-
const
|
|
156
|
-
|
|
154
|
+
const { hasContentRoleAttribute } = unlock( select( blocksStore ) );
|
|
155
|
+
const isContentBlock = hasContentRoleAttribute( name );
|
|
157
156
|
|
|
158
157
|
return {
|
|
159
158
|
activeBlockVariation: getActiveBlockVariation(
|
|
@@ -26,15 +26,10 @@ export default ( props ) => ( element ) => {
|
|
|
26
26
|
preserveWhiteSpace,
|
|
27
27
|
pastePlainText,
|
|
28
28
|
} = props.current;
|
|
29
|
-
const { ownerDocument } = element;
|
|
30
|
-
const { defaultView } = ownerDocument;
|
|
31
|
-
const { anchorNode, focusNode } = defaultView.getSelection();
|
|
32
|
-
const containsSelection =
|
|
33
|
-
element.contains( anchorNode ) && element.contains( focusNode );
|
|
34
29
|
|
|
35
30
|
// The event listener is attached to the window, so we need to check if
|
|
36
|
-
// the target is the element.
|
|
37
|
-
if ( !
|
|
31
|
+
// the target is the element or inside the element.
|
|
32
|
+
if ( ! element.contains( event.target ) ) {
|
|
38
33
|
return;
|
|
39
34
|
}
|
|
40
35
|
|
|
@@ -165,7 +165,7 @@ export function RichTextWrapper(
|
|
|
165
165
|
isBlockSelected,
|
|
166
166
|
] );
|
|
167
167
|
|
|
168
|
-
const { disableBoundBlock, bindingsPlaceholder } = useSelect(
|
|
168
|
+
const { disableBoundBlock, bindingsPlaceholder, bindingsLabel } = useSelect(
|
|
169
169
|
( select ) => {
|
|
170
170
|
if (
|
|
171
171
|
! blockBindings?.[ identifier ] ||
|
|
@@ -179,18 +179,36 @@ export function RichTextWrapper(
|
|
|
179
179
|
const blockBindingsSource = getBlockBindingsSource(
|
|
180
180
|
relatedBinding.source
|
|
181
181
|
);
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
const blockBindingsContext = {};
|
|
183
|
+
if ( blockBindingsSource?.usesContext?.length ) {
|
|
184
|
+
for ( const key of blockBindingsSource.usesContext ) {
|
|
185
|
+
blockBindingsContext[ key ] = blockContext[ key ];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
186
188
|
|
|
187
189
|
const _disableBoundBlock =
|
|
188
190
|
! blockBindingsSource?.canUserEditValue?.( {
|
|
189
|
-
|
|
190
|
-
context:
|
|
191
|
+
registry,
|
|
192
|
+
context: blockBindingsContext,
|
|
191
193
|
args: relatedBinding.args,
|
|
192
194
|
} );
|
|
193
195
|
|
|
196
|
+
// Don't modify placeholders if value is not empty.
|
|
197
|
+
if ( adjustedValue.length > 0 ) {
|
|
198
|
+
return {
|
|
199
|
+
disableBoundBlock: _disableBoundBlock,
|
|
200
|
+
// Null values will make them fall back to the default behavior.
|
|
201
|
+
bindingsPlaceholder: null,
|
|
202
|
+
bindingsLabel: null,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const { getBlockAttributes } = select( blockEditorStore );
|
|
207
|
+
const blockAttributes = getBlockAttributes( clientId );
|
|
208
|
+
const fieldsList = blockBindingsSource?.getFieldsList?.( {
|
|
209
|
+
registry,
|
|
210
|
+
context: blockBindingsContext,
|
|
211
|
+
} );
|
|
194
212
|
const bindingKey =
|
|
195
213
|
fieldsList?.[ relatedBinding?.args?.key ]?.label ??
|
|
196
214
|
blockBindingsSource?.label;
|
|
@@ -202,12 +220,19 @@ export function RichTextWrapper(
|
|
|
202
220
|
__( 'Add %s' ),
|
|
203
221
|
bindingKey
|
|
204
222
|
);
|
|
223
|
+
const _bindingsLabel = _disableBoundBlock
|
|
224
|
+
? relatedBinding?.args?.key || blockBindingsSource?.label
|
|
225
|
+
: sprintf(
|
|
226
|
+
/* translators: %s: source label or key */
|
|
227
|
+
__( 'Empty %s; start writing to edit its value' ),
|
|
228
|
+
relatedBinding?.args?.key || blockBindingsSource?.label
|
|
229
|
+
);
|
|
205
230
|
|
|
206
231
|
return {
|
|
207
232
|
disableBoundBlock: _disableBoundBlock,
|
|
208
233
|
bindingsPlaceholder:
|
|
209
|
-
|
|
210
|
-
|
|
234
|
+
blockAttributes?.placeholder || _bindingsPlaceholder,
|
|
235
|
+
bindingsLabel: _bindingsLabel,
|
|
211
236
|
};
|
|
212
237
|
},
|
|
213
238
|
[
|
|
@@ -372,19 +397,7 @@ export function RichTextWrapper(
|
|
|
372
397
|
const inputEvents = useRef( new Set() );
|
|
373
398
|
|
|
374
399
|
function onFocus() {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if ( ! element ) {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Writing flow might be editable, so we should make sure focus goes to
|
|
382
|
-
// the root editable element.
|
|
383
|
-
while ( element.parentElement?.isContentEditable ) {
|
|
384
|
-
element = element.parentElement;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
element.focus();
|
|
400
|
+
anchorRef.current?.focus();
|
|
388
401
|
}
|
|
389
402
|
|
|
390
403
|
const TagName = tagName;
|
|
@@ -421,7 +434,7 @@ export function RichTextWrapper(
|
|
|
421
434
|
aria-readonly={ shouldDisableEditing }
|
|
422
435
|
{ ...props }
|
|
423
436
|
aria-label={
|
|
424
|
-
|
|
437
|
+
bindingsLabel || props[ 'aria-label' ] || placeholder
|
|
425
438
|
}
|
|
426
439
|
{ ...autocompleteProps }
|
|
427
440
|
ref={ useMergeRefs( [
|
|
@@ -23,7 +23,6 @@ import useSelectionObserver from './use-selection-observer';
|
|
|
23
23
|
import useClickSelection from './use-click-selection';
|
|
24
24
|
import useInput from './use-input';
|
|
25
25
|
import useClipboardHandler from './use-clipboard-handler';
|
|
26
|
-
import useEventRedirect from './use-event-redirect';
|
|
27
26
|
import { store as blockEditorStore } from '../../store';
|
|
28
27
|
|
|
29
28
|
export function useWritingFlow() {
|
|
@@ -66,7 +65,6 @@ export function useWritingFlow() {
|
|
|
66
65
|
},
|
|
67
66
|
[ hasMultiSelection ]
|
|
68
67
|
),
|
|
69
|
-
useEventRedirect(),
|
|
70
68
|
] ),
|
|
71
69
|
after,
|
|
72
70
|
];
|
|
@@ -19,7 +19,6 @@ import { useRefEffect } from '@wordpress/compose';
|
|
|
19
19
|
*/
|
|
20
20
|
import { getBlockClientId, isInSameBlock } from '../../utils/dom';
|
|
21
21
|
import { store as blockEditorStore } from '../../store';
|
|
22
|
-
import { getSelectionRoot } from './utils';
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* Returns true if the element should consider edge navigation upon a keyboard
|
|
@@ -191,7 +190,8 @@ export default function useArrowNav() {
|
|
|
191
190
|
return;
|
|
192
191
|
}
|
|
193
192
|
|
|
194
|
-
const { keyCode, shiftKey, ctrlKey, altKey, metaKey } =
|
|
193
|
+
const { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } =
|
|
194
|
+
event;
|
|
195
195
|
const isUp = keyCode === UP;
|
|
196
196
|
const isDown = keyCode === DOWN;
|
|
197
197
|
const isLeft = keyCode === LEFT;
|
|
@@ -233,11 +233,6 @@ export default function useArrowNav() {
|
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
const target =
|
|
237
|
-
ownerDocument.activeElement === node
|
|
238
|
-
? getSelectionRoot( ownerDocument )
|
|
239
|
-
: event.target;
|
|
240
|
-
|
|
241
236
|
// Abort if our current target is not a candidate for navigation
|
|
242
237
|
// (e.g. preserve native input behaviors).
|
|
243
238
|
if ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {
|
|
@@ -279,7 +274,6 @@ export default function useArrowNav() {
|
|
|
279
274
|
( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&
|
|
280
275
|
! keepCaretInsideBlock
|
|
281
276
|
) {
|
|
282
|
-
node.contentEditable = false;
|
|
283
277
|
const closestTabbable = getClosestTabbable(
|
|
284
278
|
target,
|
|
285
279
|
isReverse,
|
|
@@ -303,7 +297,6 @@ export default function useArrowNav() {
|
|
|
303
297
|
isHorizontalEdge( target, isReverseDir ) &&
|
|
304
298
|
! keepCaretInsideBlock
|
|
305
299
|
) {
|
|
306
|
-
node.contentEditable = false;
|
|
307
300
|
const closestTabbable = getClosestTabbable(
|
|
308
301
|
target,
|
|
309
302
|
isReverseDir,
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
18
|
import { store as blockEditorStore } from '../../store';
|
|
19
|
-
import { getSelectionRoot } from './utils';
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Handles input for selections across blocks.
|
|
@@ -50,24 +49,7 @@ export default function useInput() {
|
|
|
50
49
|
// DOM. This will cause React errors (and the DOM should only be
|
|
51
50
|
// altered in a controlled fashion).
|
|
52
51
|
if ( node.contentEditable === 'true' ) {
|
|
53
|
-
|
|
54
|
-
const range = selection.rangeCount
|
|
55
|
-
? selection.getRangeAt( 0 )
|
|
56
|
-
: null;
|
|
57
|
-
const root = getSelectionRoot( node.ownerDocument );
|
|
58
|
-
|
|
59
|
-
// If selection is contained within a nested editable, allow
|
|
60
|
-
// input. We need to ensure that selection is maintained.
|
|
61
|
-
if ( root ) {
|
|
62
|
-
node.contentEditable = false;
|
|
63
|
-
root.focus();
|
|
64
|
-
selection.removeAllRanges();
|
|
65
|
-
if ( range ) {
|
|
66
|
-
selection.addRange( range );
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
event.preventDefault();
|
|
70
|
-
}
|
|
52
|
+
event.preventDefault();
|
|
71
53
|
}
|
|
72
54
|
}
|
|
73
55
|
|
|
@@ -77,23 +59,6 @@ export default function useInput() {
|
|
|
77
59
|
}
|
|
78
60
|
|
|
79
61
|
if ( ! hasMultiSelection() ) {
|
|
80
|
-
const { ownerDocument } = node;
|
|
81
|
-
if ( node === ownerDocument.activeElement ) {
|
|
82
|
-
if ( event.key === 'End' || event.key === 'Home' ) {
|
|
83
|
-
const selectionRoot = getSelectionRoot( ownerDocument );
|
|
84
|
-
const selection =
|
|
85
|
-
ownerDocument.defaultView.getSelection();
|
|
86
|
-
selection.selectAllChildren( selectionRoot );
|
|
87
|
-
const method =
|
|
88
|
-
event.key === 'End'
|
|
89
|
-
? 'collapseToEnd'
|
|
90
|
-
: 'collapseToStart';
|
|
91
|
-
selection[ method ]();
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
62
|
if ( event.keyCode === ENTER ) {
|
|
98
63
|
if ( event.shiftKey || __unstableIsFullySelected() ) {
|
|
99
64
|
return;
|