@wordpress/edit-widgets 4.7.0 → 4.10.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 +6 -0
- package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build/components/error-boundary/index.js +3 -0
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +17 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +12 -14
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build/filters/move-to-widget-area.js.map +1 -1
- package/build/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/resolvers.js.map +1 -1
- package/build/store/selectors.js +5 -7
- package/build/store/selectors.js.map +1 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build-module/components/error-boundary/index.js +2 -0
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +17 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +12 -13
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/filters/move-to-widget-area.js.map +1 -1
- package/build-module/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/resolvers.js.map +1 -1
- package/build-module/store/selectors.js +5 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +5 -14
- package/build-style/style.css +5 -14
- package/package.json +26 -26
- package/src/blocks/widget-area/edit/inner-blocks.js +2 -1
- package/src/components/error-boundary/index.js +3 -0
- package/src/components/header/index.js +4 -8
- package/src/components/header/style.scss +4 -10
- package/src/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/src/components/layout/interface.js +2 -5
- package/src/components/save-button/index.js +2 -3
- package/src/components/secondary-sidebar/index.js +2 -3
- package/src/components/sidebar/index.js +2 -5
- package/src/components/test/error-boundary.js +38 -0
- package/src/components/widget-areas-block-editor-provider/index.js +2 -9
- package/src/filters/move-to-widget-area.js +19 -24
- package/src/hooks/use-last-selected-widget-area.js +4 -6
- package/src/hooks/use-widget-library-insertion-point.js +2 -3
- package/src/store/actions.js +262 -258
- package/src/store/resolvers.js +69 -60
- package/src/store/selectors.js +32 -28
|
@@ -6,6 +6,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
import { Button } from '@wordpress/components';
|
|
7
7
|
import { Warning } from '@wordpress/block-editor';
|
|
8
8
|
import { useCopyToClipboard } from '@wordpress/compose';
|
|
9
|
+
import { doAction } from '@wordpress/hooks';
|
|
9
10
|
|
|
10
11
|
function CopyButton( { text, children } ) {
|
|
11
12
|
const ref = useCopyToClipboard( text );
|
|
@@ -29,6 +30,8 @@ export default class ErrorBoundary extends Component {
|
|
|
29
30
|
|
|
30
31
|
componentDidCatch( error ) {
|
|
31
32
|
this.setState( { error } );
|
|
33
|
+
|
|
34
|
+
doAction( 'editor.ErrorBoundary.errorLogged', error );
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
reboot() {
|
|
@@ -35,19 +35,15 @@ function Header() {
|
|
|
35
35
|
[ widgetAreaClientId ]
|
|
36
36
|
);
|
|
37
37
|
const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {
|
|
38
|
-
const { isInserterOpened, isListViewOpened } =
|
|
39
|
-
editWidgetsStore
|
|
40
|
-
);
|
|
38
|
+
const { isInserterOpened, isListViewOpened } =
|
|
39
|
+
select( editWidgetsStore );
|
|
41
40
|
return {
|
|
42
41
|
isInserterOpen: isInserterOpened(),
|
|
43
42
|
isListViewOpen: isListViewOpened(),
|
|
44
43
|
};
|
|
45
44
|
}, [] );
|
|
46
|
-
const {
|
|
47
|
-
|
|
48
|
-
setIsInserterOpened,
|
|
49
|
-
setIsListViewOpened,
|
|
50
|
-
} = useDispatch( editWidgetsStore );
|
|
45
|
+
const { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =
|
|
46
|
+
useDispatch( editWidgetsStore );
|
|
51
47
|
const { selectBlock } = useDispatch( blockEditorStore );
|
|
52
48
|
const handleClick = () => {
|
|
53
49
|
if ( isInserterOpen ) {
|
|
@@ -25,18 +25,12 @@
|
|
|
25
25
|
|
|
26
26
|
.edit-widgets-header__actions {
|
|
27
27
|
display: flex;
|
|
28
|
+
align-items: center;
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
margin-right: $grid-unit-05;
|
|
31
|
-
|
|
32
|
-
@include break-small() {
|
|
33
|
-
margin-right: $grid-unit-15;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
30
|
+
gap: $grid-unit-05;
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
margin-right: 0;
|
|
32
|
+
@include break-small() {
|
|
33
|
+
gap: $grid-unit-10;
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
|
|
@@ -20,8 +20,20 @@ export const textFormattingShortcuts = [
|
|
|
20
20
|
keyCombination: { modifier: 'primaryShift', character: 'k' },
|
|
21
21
|
description: __( 'Remove a link.' ),
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
keyCombination: { character: '[[' },
|
|
25
|
+
description: __( 'Insert a link to a post or page' ),
|
|
26
|
+
},
|
|
23
27
|
{
|
|
24
28
|
keyCombination: { modifier: 'primary', character: 'u' },
|
|
25
29
|
description: __( 'Underline the selected text.' ),
|
|
26
30
|
},
|
|
31
|
+
{
|
|
32
|
+
keyCombination: { modifier: 'access', character: 'd' },
|
|
33
|
+
description: __( 'Strikethrough the selected text.' ),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
keyCombination: { modifier: 'access', character: 'x' },
|
|
37
|
+
description: __( 'Make the selected text inline code.' ),
|
|
38
|
+
},
|
|
27
39
|
];
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { isString } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -37,7 +36,7 @@ const ShortcutList = ( { shortcuts } ) => (
|
|
|
37
36
|
className="edit-widgets-keyboard-shortcut-help-modal__shortcut"
|
|
38
37
|
key={ index }
|
|
39
38
|
>
|
|
40
|
-
{
|
|
39
|
+
{ typeof shortcut === 'string' ? (
|
|
41
40
|
<DynamicShortcut name={ shortcut } />
|
|
42
41
|
) : (
|
|
43
42
|
<Shortcut { ...shortcut } />
|
|
@@ -36,11 +36,8 @@ const interfaceLabels = {
|
|
|
36
36
|
function Interface( { blockEditorSettings } ) {
|
|
37
37
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
38
38
|
const isHugeViewport = useViewportMatch( 'huge', '>=' );
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
setIsListViewOpened,
|
|
42
|
-
closeGeneralSidebar,
|
|
43
|
-
} = useDispatch( editWidgetsStore );
|
|
39
|
+
const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =
|
|
40
|
+
useDispatch( editWidgetsStore );
|
|
44
41
|
const {
|
|
45
42
|
hasBlockBreadCrumbsEnabled,
|
|
46
43
|
hasSidebarEnabled,
|
|
@@ -12,9 +12,8 @@ import { store as editWidgetsStore } from '../../store';
|
|
|
12
12
|
|
|
13
13
|
function SaveButton() {
|
|
14
14
|
const { hasEditedWidgetAreaIds, isSaving } = useSelect( ( select ) => {
|
|
15
|
-
const { getEditedWidgetAreas, isSavingWidgetAreas } =
|
|
16
|
-
editWidgetsStore
|
|
17
|
-
);
|
|
15
|
+
const { getEditedWidgetAreas, isSavingWidgetAreas } =
|
|
16
|
+
select( editWidgetsStore );
|
|
18
17
|
|
|
19
18
|
return {
|
|
20
19
|
hasEditedWidgetAreaIds: getEditedWidgetAreas()?.length > 0,
|
|
@@ -15,9 +15,8 @@ import ListViewSidebar from './list-view-sidebar';
|
|
|
15
15
|
|
|
16
16
|
export default function SecondarySidebar() {
|
|
17
17
|
const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {
|
|
18
|
-
const { isInserterOpened, isListViewOpened } =
|
|
19
|
-
editWidgetsStore
|
|
20
|
-
);
|
|
18
|
+
const { isInserterOpened, isListViewOpened } =
|
|
19
|
+
select( editWidgetsStore );
|
|
21
20
|
return {
|
|
22
21
|
isInserterOpen: isInserterOpened(),
|
|
23
22
|
isListViewOpen: isListViewOpened(),
|
|
@@ -69,11 +69,8 @@ export default function Sidebar() {
|
|
|
69
69
|
isGeneralSidebarOpen,
|
|
70
70
|
selectedWidgetAreaBlock,
|
|
71
71
|
} = useSelect( ( select ) => {
|
|
72
|
-
const {
|
|
73
|
-
|
|
74
|
-
getBlock,
|
|
75
|
-
getBlockParentsByBlockName,
|
|
76
|
-
} = select( blockEditorStore );
|
|
72
|
+
const { getSelectedBlock, getBlock, getBlockParentsByBlockName } =
|
|
73
|
+
select( blockEditorStore );
|
|
77
74
|
const { getActiveComplementaryArea } = select( interfaceStore );
|
|
78
75
|
|
|
79
76
|
const selectedBlock = getSelectedBlock();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import * as wpHooks from '@wordpress/hooks';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import ErrorBoundary from '../error-boundary';
|
|
9
|
+
/**
|
|
10
|
+
* External dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { render } from '@testing-library/react';
|
|
13
|
+
|
|
14
|
+
const theError = new Error( 'Kaboom' );
|
|
15
|
+
|
|
16
|
+
const ChildComponent = () => {
|
|
17
|
+
throw theError;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe( 'Error Boundary', () => {
|
|
21
|
+
describe( 'when error is thrown from a Child component', () => {
|
|
22
|
+
it( 'calls the `editor.ErrorBoundary.errorLogged` hook action with the error object', () => {
|
|
23
|
+
const doAction = jest.spyOn( wpHooks, 'doAction' );
|
|
24
|
+
|
|
25
|
+
render(
|
|
26
|
+
<ErrorBoundary>
|
|
27
|
+
<ChildComponent />
|
|
28
|
+
</ErrorBoundary>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect( doAction ).toHaveBeenCalledWith(
|
|
32
|
+
'editor.ErrorBoundary.errorLogged',
|
|
33
|
+
theError
|
|
34
|
+
);
|
|
35
|
+
expect( console ).toHaveErrored();
|
|
36
|
+
} );
|
|
37
|
+
} );
|
|
38
|
+
} );
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { defaultTo } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -41,10 +36,8 @@ export default function WidgetAreasBlockEditorProvider( {
|
|
|
41
36
|
keepCaretInsideBlock,
|
|
42
37
|
} = useSelect(
|
|
43
38
|
( select ) => ( {
|
|
44
|
-
hasUploadPermissions:
|
|
45
|
-
select( coreStore ).canUser( 'create', 'media' ),
|
|
46
|
-
true
|
|
47
|
-
),
|
|
39
|
+
hasUploadPermissions:
|
|
40
|
+
select( coreStore ).canUser( 'create', 'media' ) ?? true,
|
|
48
41
|
widgetAreas: select( editWidgetsStore ).getWidgetAreas(),
|
|
49
42
|
widgets: select( editWidgetsStore ).getWidgets(),
|
|
50
43
|
reusableBlocks: ALLOW_REUSABLE_BLOCKS
|
|
@@ -16,33 +16,28 @@ import { store as editWidgetsStore } from '../store';
|
|
|
16
16
|
const withMoveToWidgetAreaToolbarItem = createHigherOrderComponent(
|
|
17
17
|
( BlockEdit ) => ( props ) => {
|
|
18
18
|
const { clientId, name: blockName } = props;
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if ( blockName === 'core/widget-area' ) {
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
19
|
+
const { widgetAreas, currentWidgetAreaId, canInsertBlockInWidgetArea } =
|
|
20
|
+
useSelect(
|
|
21
|
+
( select ) => {
|
|
22
|
+
// Component won't display for a widget area, so don't run selectors.
|
|
23
|
+
if ( blockName === 'core/widget-area' ) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
const selectors = select( editWidgetsStore );
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
29
|
+
const widgetAreaBlock =
|
|
30
|
+
selectors.getParentWidgetAreaBlock( clientId );
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
32
|
+
return {
|
|
33
|
+
widgetAreas: selectors.getWidgetAreas(),
|
|
34
|
+
currentWidgetAreaId: widgetAreaBlock?.attributes?.id,
|
|
35
|
+
canInsertBlockInWidgetArea:
|
|
36
|
+
selectors.canInsertBlockInWidgetArea( blockName ),
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
[ clientId, blockName ]
|
|
40
|
+
);
|
|
46
41
|
|
|
47
42
|
const { moveBlockToWidgetArea } = useDispatch( editWidgetsStore );
|
|
48
43
|
const hasMultipleWidgetAreas = widgetAreas?.length > 1;
|
|
@@ -19,9 +19,8 @@ import { buildWidgetAreasPostId, KIND, POST_TYPE } from '../store/utils';
|
|
|
19
19
|
*/
|
|
20
20
|
const useLastSelectedWidgetArea = () =>
|
|
21
21
|
useSelect( ( select ) => {
|
|
22
|
-
const { getBlockSelectionEnd, getBlockName } =
|
|
23
|
-
blockEditorStore
|
|
24
|
-
);
|
|
22
|
+
const { getBlockSelectionEnd, getBlockName } =
|
|
23
|
+
select( blockEditorStore );
|
|
25
24
|
const selectionEndClientId = getBlockSelectionEnd();
|
|
26
25
|
|
|
27
26
|
// If the selected block is a widget area, return its clientId.
|
|
@@ -30,9 +29,8 @@ const useLastSelectedWidgetArea = () =>
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
const { getParentWidgetAreaBlock } = select( widgetsEditorStore );
|
|
33
|
-
const widgetAreaBlock =
|
|
34
|
-
selectionEndClientId
|
|
35
|
-
);
|
|
32
|
+
const widgetAreaBlock =
|
|
33
|
+
getParentWidgetAreaBlock( selectionEndClientId );
|
|
36
34
|
const widgetAreaBlockClientId = widgetAreaBlock?.clientId;
|
|
37
35
|
|
|
38
36
|
if ( widgetAreaBlockClientId ) {
|
|
@@ -32,9 +32,8 @@ const useWidgetLibraryInsertionPoint = () => {
|
|
|
32
32
|
getBlockIndex,
|
|
33
33
|
} = select( blockEditorStore );
|
|
34
34
|
|
|
35
|
-
const insertionPoint =
|
|
36
|
-
editWidgetsStore
|
|
37
|
-
).__experimentalGetInsertionPoint();
|
|
35
|
+
const insertionPoint =
|
|
36
|
+
select( editWidgetsStore ).__experimentalGetInsertionPoint();
|
|
38
37
|
|
|
39
38
|
// "Browse all" in the quick inserter will set the rootClientId to the current block.
|
|
40
39
|
// Otherwise, it will just be undefined, and we'll have to handle it differently below.
|