@wordpress/edit-widgets 6.57.0 → 7.1.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/build/blocks/widget-area/edit/index.cjs +106 -116
- package/build/blocks/widget-area/edit/index.cjs.map +1 -7
- package/build/blocks/widget-area/edit/inner-blocks.cjs +44 -62
- package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -7
- package/build/blocks/widget-area/edit/use-is-dragging-within.cjs +41 -53
- package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -7
- package/build/blocks/widget-area/index.cjs +40 -44
- package/build/blocks/widget-area/index.cjs.map +1 -7
- package/build/components/error-boundary/index.cjs +115 -155
- package/build/components/error-boundary/index.cjs.map +1 -7
- package/build/components/header/document-tools/index.cjs +80 -115
- package/build/components/header/document-tools/index.cjs.map +1 -7
- package/build/components/header/index.cjs +72 -80
- package/build/components/header/index.cjs.map +1 -7
- package/build/components/header/undo-redo/redo.cjs +30 -52
- package/build/components/header/undo-redo/redo.cjs.map +1 -7
- package/build/components/header/undo-redo/undo.cjs +29 -51
- package/build/components/header/undo-redo/undo.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
- package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/index.cjs +94 -161
- package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -75
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcuts/index.cjs +107 -140
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
- package/build/components/layout/index.cjs +65 -74
- package/build/components/layout/index.cjs.map +1 -7
- package/build/components/layout/interface.cjs +82 -102
- package/build/components/layout/interface.cjs.map +1 -7
- package/build/components/layout/unsaved-changes-warning.cjs +44 -48
- package/build/components/layout/unsaved-changes-warning.cjs.map +1 -7
- package/build/components/more-menu/index.cjs +125 -191
- package/build/components/more-menu/index.cjs.map +1 -7
- package/build/components/more-menu/tools-more-menu-group.cjs +9 -29
- package/build/components/more-menu/tools-more-menu-group.cjs.map +1 -7
- package/build/components/notices/index.cjs +19 -39
- package/build/components/notices/index.cjs.map +1 -7
- package/build/components/save-button/index.cjs +31 -58
- package/build/components/save-button/index.cjs.map +1 -7
- package/build/components/secondary-sidebar/index.cjs +38 -45
- package/build/components/secondary-sidebar/index.cjs.map +1 -7
- package/build/components/secondary-sidebar/inserter-sidebar.cjs +50 -51
- package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -7
- package/build/components/secondary-sidebar/list-view-sidebar.cjs +51 -82
- package/build/components/secondary-sidebar/list-view-sidebar.cjs.map +1 -7
- package/build/components/sidebar/index.cjs +117 -180
- package/build/components/sidebar/index.cjs.map +1 -7
- package/build/components/sidebar/widget-areas.cjs +43 -85
- package/build/components/sidebar/widget-areas.cjs.map +1 -7
- package/build/components/welcome-guide/index.cjs +110 -186
- package/build/components/welcome-guide/index.cjs.map +1 -7
- package/build/components/widget-areas-block-editor-content/index.cjs +59 -63
- package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -7
- package/build/components/widget-areas-block-editor-provider/index.cjs +105 -140
- package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -7
- package/build/constants.cjs +11 -32
- package/build/constants.cjs.map +1 -7
- package/build/filters/index.cjs +7 -4
- package/build/filters/move-to-widget-area.cjs +38 -53
- package/build/filters/move-to-widget-area.cjs.map +1 -7
- package/build/filters/replace-media-upload.cjs +11 -9
- package/build/filters/replace-media-upload.cjs.map +1 -7
- package/build/hooks/use-last-selected-widget-area.cjs +28 -49
- package/build/hooks/use-last-selected-widget-area.cjs.map +1 -7
- package/build/hooks/use-widget-library-insertion-point.cjs +33 -67
- package/build/hooks/use-widget-library-insertion-point.cjs.map +1 -7
- package/build/index.cjs +96 -97
- package/build/index.cjs.map +1 -7
- package/build/lock-unlock.cjs +10 -35
- package/build/lock-unlock.cjs.map +1 -7
- package/build/store/actions.cjs +269 -278
- package/build/store/actions.cjs.map +1 -7
- package/build/store/constants.cjs +12 -29
- package/build/store/constants.cjs.map +1 -7
- package/build/store/index.cjs +61 -52
- package/build/store/index.cjs.map +1 -7
- package/build/store/private-selectors.cjs +11 -32
- package/build/store/private-selectors.cjs.map +1 -7
- package/build/store/reducer.cjs +107 -88
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/resolvers.cjs +60 -91
- package/build/store/resolvers.cjs.map +1 -7
- package/build/store/selectors.cjs +196 -229
- package/build/store/selectors.cjs.map +1 -7
- package/build/store/transformers.cjs +51 -82
- package/build/store/transformers.cjs.map +1 -7
- package/build/store/utils.cjs +76 -63
- package/build/store/utils.cjs.map +1 -7
- package/build-module/blocks/widget-area/edit/index.mjs +82 -94
- package/build-module/blocks/widget-area/edit/index.mjs.map +1 -7
- package/build-module/blocks/widget-area/edit/inner-blocks.mjs +19 -35
- package/build-module/blocks/widget-area/edit/inner-blocks.mjs.map +1 -7
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs +36 -33
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs.map +1 -7
- package/build-module/blocks/widget-area/index.mjs +12 -15
- package/build-module/blocks/widget-area/index.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +103 -128
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/header/document-tools/index.mjs +51 -84
- package/build-module/components/header/document-tools/index.mjs.map +1 -7
- package/build-module/components/header/index.mjs +40 -47
- package/build-module/components/header/index.mjs.map +1 -7
- package/build-module/components/header/undo-redo/redo.mjs +20 -27
- package/build-module/components/header/undo-redo/redo.mjs.map +1 -7
- package/build-module/components/header/undo-redo/undo.mjs +19 -26
- package/build-module/components/header/undo-redo/undo.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs +67 -136
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -54
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcuts/index.mjs +99 -119
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
- package/build-module/components/layout/index.mjs +29 -40
- package/build-module/components/layout/index.mjs.map +1 -7
- package/build-module/components/layout/interface.mjs +53 -76
- package/build-module/components/layout/interface.mjs.map +1 -7
- package/build-module/components/layout/unsaved-changes-warning.mjs +37 -26
- package/build-module/components/layout/unsaved-changes-warning.mjs.map +1 -7
- package/build-module/components/more-menu/index.mjs +95 -162
- package/build-module/components/more-menu/index.mjs.map +1 -7
- package/build-module/components/more-menu/tools-more-menu-group.mjs +5 -9
- package/build-module/components/more-menu/tools-more-menu-group.mjs.map +1 -7
- package/build-module/components/notices/index.mjs +12 -17
- package/build-module/components/notices/index.mjs.map +1 -7
- package/build-module/components/save-button/index.mjs +23 -35
- package/build-module/components/save-button/index.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/index.mjs +15 -20
- package/build-module/components/secondary-sidebar/index.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/inserter-sidebar.mjs +27 -25
- package/build-module/components/secondary-sidebar/inserter-sidebar.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/list-view-sidebar.mjs +39 -55
- package/build-module/components/secondary-sidebar/list-view-sidebar.mjs.map +1 -7
- package/build-module/components/sidebar/index.mjs +96 -162
- package/build-module/components/sidebar/index.mjs.map +1 -7
- package/build-module/components/sidebar/widget-areas.mjs +30 -57
- package/build-module/components/sidebar/widget-areas.mjs.map +1 -7
- package/build-module/components/welcome-guide/index.mjs +103 -164
- package/build-module/components/welcome-guide/index.mjs.map +1 -7
- package/build-module/components/widget-areas-block-editor-content/index.mjs +35 -44
- package/build-module/components/widget-areas-block-editor-content/index.mjs.map +1 -7
- package/build-module/components/widget-areas-block-editor-provider/index.mjs +76 -109
- package/build-module/components/widget-areas-block-editor-provider/index.mjs.map +1 -7
- package/build-module/constants.mjs +5 -7
- package/build-module/constants.mjs.map +1 -7
- package/build-module/filters/index.mjs +0 -2
- package/build-module/filters/move-to-widget-area.mjs +28 -48
- package/build-module/filters/move-to-widget-area.mjs.map +1 -7
- package/build-module/filters/replace-media-upload.mjs +5 -8
- package/build-module/filters/replace-media-upload.mjs.map +1 -7
- package/build-module/hooks/use-last-selected-widget-area.mjs +23 -29
- package/build-module/hooks/use-last-selected-widget-area.mjs.map +1 -7
- package/build-module/hooks/use-widget-library-insertion-point.mjs +28 -47
- package/build-module/hooks/use-widget-library-insertion-point.mjs.map +1 -7
- package/build-module/index.mjs +62 -79
- package/build-module/index.mjs.map +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +250 -247
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/constants.mjs +7 -5
- package/build-module/store/constants.mjs.map +1 -7
- package/build-module/store/index.mjs +18 -16
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/private-selectors.mjs +5 -7
- package/build-module/store/private-selectors.mjs.map +1 -7
- package/build-module/store/reducer.mjs +95 -58
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/resolvers.mjs +52 -71
- package/build-module/store/resolvers.mjs.map +1 -7
- package/build-module/store/selectors.mjs +178 -199
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/transformers.mjs +44 -56
- package/build-module/store/transformers.mjs.map +1 -7
- package/build-module/store/utils.mjs +64 -32
- package/build-module/store/utils.mjs.map +1 -7
- package/build-style/style-rtl.css +12 -12
- package/build-style/style.css +12 -12
- package/package.json +35 -36
- package/src/components/header/index.jsx +2 -2
- package/src/components/layout/interface.jsx +4 -1
- package/src/components/layout/style.scss +11 -0
- package/src/components/notices/style.scss +2 -2
- package/src/components/sidebar/index.jsx +18 -18
- package/src/components/welcome-guide/index.jsx +4 -2
- package/src/components/widget-areas-block-editor-content/index.jsx +4 -3
- package/CHANGELOG.md +0 -325
- package/build/filters/index.cjs.map +0 -7
- package/build-module/filters/index.mjs.map +0 -7
|
@@ -1,129 +1,109 @@
|
|
|
1
|
-
// packages/edit-widgets/src/components/keyboard-shortcuts/index.js
|
|
2
1
|
import { useEffect } from "@wordpress/element";
|
|
3
|
-
import {
|
|
4
|
-
useShortcut,
|
|
5
|
-
store as keyboardShortcutsStore
|
|
6
|
-
} from "@wordpress/keyboard-shortcuts";
|
|
2
|
+
import { store, useShortcut } from "@wordpress/keyboard-shortcuts";
|
|
7
3
|
import { isAppleOS } from "@wordpress/keycodes";
|
|
8
4
|
import { useDispatch } from "@wordpress/data";
|
|
9
5
|
import { __ } from "@wordpress/i18n";
|
|
10
|
-
import { store as
|
|
11
|
-
import { privateApis
|
|
12
|
-
import { store as
|
|
6
|
+
import { store as store$1 } from "@wordpress/core-data";
|
|
7
|
+
import { privateApis } from "@wordpress/block-editor";
|
|
8
|
+
import { store as store$2 } from "../../store/index.mjs";
|
|
13
9
|
import { unlock } from "../../lock-unlock.mjs";
|
|
14
|
-
|
|
10
|
+
// packages/edit-widgets/src/components/keyboard-shortcuts/index.js
|
|
11
|
+
const { usesNativeUndo } = unlock(privateApis);
|
|
15
12
|
function KeyboardShortcuts() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
event.preventDefault();
|
|
34
|
-
saveEditedWidgetAreas();
|
|
35
|
-
});
|
|
36
|
-
return null;
|
|
13
|
+
const { redo, undo } = useDispatch(store$1);
|
|
14
|
+
const { saveEditedWidgetAreas } = useDispatch(store$2);
|
|
15
|
+
useShortcut("core/edit-widgets/undo", (event) => {
|
|
16
|
+
if (usesNativeUndo(event)) return;
|
|
17
|
+
undo();
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
});
|
|
20
|
+
useShortcut("core/edit-widgets/redo", (event) => {
|
|
21
|
+
if (usesNativeUndo(event)) return;
|
|
22
|
+
redo();
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
});
|
|
25
|
+
useShortcut("core/edit-widgets/save", (event) => {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
saveEditedWidgetAreas();
|
|
28
|
+
});
|
|
29
|
+
return null;
|
|
37
30
|
}
|
|
38
31
|
function KeyboardShortcutsRegister() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
modifier: "access",
|
|
113
|
-
character: "p"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
modifier: "ctrlShift",
|
|
117
|
-
character: "~"
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
});
|
|
121
|
-
}, [registerShortcut]);
|
|
122
|
-
return null;
|
|
32
|
+
const { registerShortcut } = useDispatch(store);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
registerShortcut({
|
|
35
|
+
name: "core/edit-widgets/undo",
|
|
36
|
+
category: "global",
|
|
37
|
+
description: __("Undo your last changes."),
|
|
38
|
+
keyCombination: {
|
|
39
|
+
modifier: "primary",
|
|
40
|
+
character: "z"
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
registerShortcut({
|
|
44
|
+
name: "core/edit-widgets/redo",
|
|
45
|
+
category: "global",
|
|
46
|
+
description: __("Redo your last undo."),
|
|
47
|
+
keyCombination: {
|
|
48
|
+
modifier: "primaryShift",
|
|
49
|
+
character: "z"
|
|
50
|
+
},
|
|
51
|
+
aliases: isAppleOS() ? [] : [{
|
|
52
|
+
modifier: "primary",
|
|
53
|
+
character: "y"
|
|
54
|
+
}]
|
|
55
|
+
});
|
|
56
|
+
registerShortcut({
|
|
57
|
+
name: "core/edit-widgets/save",
|
|
58
|
+
category: "global",
|
|
59
|
+
description: __("Save your changes."),
|
|
60
|
+
keyCombination: {
|
|
61
|
+
modifier: "primary",
|
|
62
|
+
character: "s"
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
registerShortcut({
|
|
66
|
+
name: "core/edit-widgets/keyboard-shortcuts",
|
|
67
|
+
category: "main",
|
|
68
|
+
description: __("Display these keyboard shortcuts."),
|
|
69
|
+
keyCombination: {
|
|
70
|
+
modifier: "access",
|
|
71
|
+
character: "h"
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
registerShortcut({
|
|
75
|
+
name: "core/edit-widgets/next-region",
|
|
76
|
+
category: "global",
|
|
77
|
+
description: __("Navigate to the next part of the editor."),
|
|
78
|
+
keyCombination: {
|
|
79
|
+
modifier: "ctrl",
|
|
80
|
+
character: "`"
|
|
81
|
+
},
|
|
82
|
+
aliases: [{
|
|
83
|
+
modifier: "access",
|
|
84
|
+
character: "n"
|
|
85
|
+
}]
|
|
86
|
+
});
|
|
87
|
+
registerShortcut({
|
|
88
|
+
name: "core/edit-widgets/previous-region",
|
|
89
|
+
category: "global",
|
|
90
|
+
description: __("Navigate to the previous part of the editor."),
|
|
91
|
+
keyCombination: {
|
|
92
|
+
modifier: "ctrlShift",
|
|
93
|
+
character: "`"
|
|
94
|
+
},
|
|
95
|
+
aliases: [{
|
|
96
|
+
modifier: "access",
|
|
97
|
+
character: "p"
|
|
98
|
+
}, {
|
|
99
|
+
modifier: "ctrlShift",
|
|
100
|
+
character: "~"
|
|
101
|
+
}]
|
|
102
|
+
});
|
|
103
|
+
}, [registerShortcut]);
|
|
104
|
+
return null;
|
|
123
105
|
}
|
|
124
106
|
KeyboardShortcuts.Register = KeyboardShortcutsRegister;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
//# sourceMappingURL=index.mjs.map
|
|
107
|
+
export { KeyboardShortcuts as default };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/keyboard-shortcuts/index.js"],
|
|
4
|
-
"sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { isAppleOS } from '@wordpress/keycodes';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { usesNativeUndo } = unlock( blockEditorPrivateApis );\n\nfunction KeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { saveEditedWidgetAreas } = useDispatch( editWidgetsStore );\n\n\tuseShortcut( 'core/edit-widgets/undo', ( event ) => {\n\t\tif ( usesNativeUndo( event ) ) {\n\t\t\treturn;\n\t\t}\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/redo', ( event ) => {\n\t\tif ( usesNativeUndo( event ) ) {\n\t\t\treturn;\n\t\t}\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/save', ( event ) => {\n\t\tevent.preventDefault();\n\t\tsaveEditedWidgetAreas();\n\t} );\n\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t\t// Disable on Apple OS because it conflicts with the browser's\n\t\t\t// history shortcut. It's a fine alias for both Windows and Linux.\n\t\t\t// Since there's no conflict for Ctrl+Shift+Z on both Windows and\n\t\t\t// Linux, we keep it as the default for consistency.\n\t\t\taliases: isAppleOS()\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmodifier: 'primary',\n\t\t\t\t\t\t\tcharacter: 'y',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\nexport default KeyboardShortcuts;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,SAAS,iBAAiB;AACnC,SAAS,eAAe,8BAA8B;AACtD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAEvB,IAAM,EAAE,eAAe,IAAI,OAAQ,sBAAuB;AAE1D,SAAS,oBAAoB;AAC5B,QAAM,EAAE,MAAM,KAAK,IAAI,YAAa,SAAU;AAC9C,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAEhE,cAAa,0BAA0B,CAAE,UAAW;AACnD,QAAK,eAAgB,KAAM,GAAI;AAC9B;AAAA,IACD;AACA,SAAK;AACL,UAAM,eAAe;AAAA,EACtB,CAAE;AAEF,cAAa,0BAA0B,CAAE,UAAW;AACnD,QAAK,eAAgB,KAAM,GAAI;AAC9B;AAAA,IACD;AACA,SAAK;AACL,UAAM,eAAe;AAAA,EACtB,CAAE;AAEF,cAAa,0BAA0B,CAAE,UAAW;AACnD,UAAM,eAAe;AACrB,0BAAsB;AAAA,EACvB,CAAE;AAEF,SAAO;AACR;AAEA,SAAS,4BAA4B;AAEpC,QAAM,EAAE,iBAAiB,IAAI,YAAa,sBAAuB;AACjE,YAAW,MAAM;AAChB,qBAAkB;AAAA,MACjB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa,GAAI,yBAA0B;AAAA,MAC3C,gBAAgB;AAAA,QACf,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA,IACD,CAAE;AAEF,qBAAkB;AAAA,MACjB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa,GAAI,sBAAuB;AAAA,MACxC,gBAAgB;AAAA,QACf,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA;AAAA;AAAA;AAAA;AAAA,MAKA,SAAS,UAAU,IAChB,CAAC,IACD;AAAA,QACA;AAAA,UACC,UAAU;AAAA,UACV,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACH,CAAE;AAEF,qBAAkB;AAAA,MACjB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa,GAAI,oBAAqB;AAAA,MACtC,gBAAgB;AAAA,QACf,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA,IACD,CAAE;AAEF,qBAAkB;AAAA,MACjB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa,GAAI,mCAAoC;AAAA,MACrD,gBAAgB;AAAA,QACf,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA,IACD,CAAE;AAEF,qBAAkB;AAAA,MACjB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa,GAAI,0CAA2C;AAAA,MAC5D,gBAAgB;AAAA,QACf,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA,MACA,SAAS;AAAA,QACR;AAAA,UACC,UAAU;AAAA,UACV,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACD,CAAE;AAEF,qBAAkB;AAAA,MACjB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa,GAAI,8CAA+C;AAAA,MAChE,gBAAgB;AAAA,QACf,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA,MACA,SAAS;AAAA,QACR;AAAA,UACC,UAAU;AAAA,UACV,WAAW;AAAA,QACZ;AAAA,QACA;AAAA,UACC,UAAU;AAAA,UACV,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,GAAG,CAAE,gBAAiB,CAAE;AAExB,SAAO;AACR;AAEA,kBAAkB,WAAW;AAC7B,IAAO,6BAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["blockEditorPrivateApis","coreStore","editWidgetsStore","keyboardShortcutsStore"],"sources":["../../../src/components/keyboard-shortcuts/index.js"],"sourcesContent":["import { useEffect } from '@wordpress/element';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { isAppleOS } from '@wordpress/keycodes';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { usesNativeUndo } = unlock( blockEditorPrivateApis );\n\nfunction KeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { saveEditedWidgetAreas } = useDispatch( editWidgetsStore );\n\n\tuseShortcut( 'core/edit-widgets/undo', ( event ) => {\n\t\tif ( usesNativeUndo( event ) ) {\n\t\t\treturn;\n\t\t}\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/redo', ( event ) => {\n\t\tif ( usesNativeUndo( event ) ) {\n\t\t\treturn;\n\t\t}\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/save', ( event ) => {\n\t\tevent.preventDefault();\n\t\tsaveEditedWidgetAreas();\n\t} );\n\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t\t// Disable on Apple OS because it conflicts with the browser's\n\t\t\t// history shortcut. It's a fine alias for both Windows and Linux.\n\t\t\t// Since there's no conflict for Ctrl+Shift+Z on both Windows and\n\t\t\t// Linux, we keep it as the default for consistency.\n\t\t\taliases: isAppleOS()\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmodifier: 'primary',\n\t\t\t\t\t\t\tcharacter: 'y',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\nexport default KeyboardShortcuts;\n"],"mappings":";;;;;;;;;;AAaA,MAAM,EAAE,mBAAmB,OAAQA,WAAuB;AAE1D,SAAS,oBAAoB;CAC5B,MAAM,EAAE,MAAM,SAAS,YAAaC,OAAU;CAC9C,MAAM,EAAE,0BAA0B,YAAaC,OAAiB;CAEhE,YAAa,2BAA4B,UAAW;EACnD,IAAK,eAAgB,KAAM,GAC1B;EAED,KAAK;EACL,MAAM,eAAe;CACtB,CAAE;CAEF,YAAa,2BAA4B,UAAW;EACnD,IAAK,eAAgB,KAAM,GAC1B;EAED,KAAK;EACL,MAAM,eAAe;CACtB,CAAE;CAEF,YAAa,2BAA4B,UAAW;EACnD,MAAM,eAAe;EACrB,sBAAsB;CACvB,CAAE;CAEF,OAAO;AACR;AAEA,SAAS,4BAA4B;CAEpC,MAAM,EAAE,qBAAqB,YAAaC,KAAuB;CACjE,gBAAiB;EAChB,iBAAkB;GACjB,MAAM;GACN,UAAU;GACV,aAAa,GAAI,yBAA0B;GAC3C,gBAAgB;IACf,UAAU;IACV,WAAW;GACZ;EACD,CAAE;EAEF,iBAAkB;GACjB,MAAM;GACN,UAAU;GACV,aAAa,GAAI,sBAAuB;GACxC,gBAAgB;IACf,UAAU;IACV,WAAW;GACZ;GAKA,SAAS,UAAU,IAChB,CAAC,IACD,CACA;IACC,UAAU;IACV,WAAW;GACZ,CACD;EACH,CAAE;EAEF,iBAAkB;GACjB,MAAM;GACN,UAAU;GACV,aAAa,GAAI,oBAAqB;GACtC,gBAAgB;IACf,UAAU;IACV,WAAW;GACZ;EACD,CAAE;EAEF,iBAAkB;GACjB,MAAM;GACN,UAAU;GACV,aAAa,GAAI,mCAAoC;GACrD,gBAAgB;IACf,UAAU;IACV,WAAW;GACZ;EACD,CAAE;EAEF,iBAAkB;GACjB,MAAM;GACN,UAAU;GACV,aAAa,GAAI,0CAA2C;GAC5D,gBAAgB;IACf,UAAU;IACV,WAAW;GACZ;GACA,SAAS,CACR;IACC,UAAU;IACV,WAAW;GACZ,CACD;EACD,CAAE;EAEF,iBAAkB;GACjB,MAAM;GACN,UAAU;GACV,aAAa,GAAI,8CAA+C;GAChE,gBAAgB;IACf,UAAU;IACV,WAAW;GACZ;GACA,SAAS,CACR;IACC,UAAU;IACV,WAAW;GACZ,GACA;IACC,UAAU;IACV,WAAW;GACZ,CACD;EACD,CAAE;CACH,GAAG,CAAE,gBAAiB,CAAE;CAExB,OAAO;AACR;AAEA,kBAAkB,WAAW"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// packages/edit-widgets/src/components/layout/index.jsx
|
|
2
1
|
import { getAdminThemeColors } from "@wordpress/admin-ui";
|
|
3
2
|
import { __, sprintf } from "@wordpress/i18n";
|
|
4
3
|
import { useMemo } from "@wordpress/element";
|
|
5
4
|
import { useDispatch } from "@wordpress/data";
|
|
6
5
|
import { PluginArea } from "@wordpress/plugins";
|
|
7
|
-
import { store
|
|
8
|
-
import { __unstableUseNavigateRegions
|
|
6
|
+
import { store } from "@wordpress/notices";
|
|
7
|
+
import { __unstableUseNavigateRegions } from "@wordpress/components";
|
|
9
8
|
import { ThemeProvider } from "@wordpress/theme";
|
|
10
9
|
import ErrorBoundary from "../error-boundary/index.mjs";
|
|
11
10
|
import WidgetAreasBlockEditorProvider from "../widget-areas-block-editor-provider/index.mjs";
|
|
@@ -14,42 +13,32 @@ import Interface from "./interface.mjs";
|
|
|
14
13
|
import UnsavedChangesWarning from "./unsaved-changes-warning.mjs";
|
|
15
14
|
import WelcomeGuide from "../welcome-guide/index.mjs";
|
|
16
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
// packages/edit-widgets/src/components/layout/index.jsx
|
|
17
17
|
function Layout({ blockEditorSettings }) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
),
|
|
43
|
-
/* @__PURE__ */ jsx(Sidebar, {}),
|
|
44
|
-
/* @__PURE__ */ jsx(PluginArea, { onError: onPluginAreaError }),
|
|
45
|
-
/* @__PURE__ */ jsx(UnsavedChangesWarning, {}),
|
|
46
|
-
/* @__PURE__ */ jsx(WelcomeGuide, {})
|
|
47
|
-
]
|
|
48
|
-
}
|
|
49
|
-
) }) }) });
|
|
18
|
+
const { createErrorNotice } = useDispatch(store);
|
|
19
|
+
function onPluginAreaError(name) {
|
|
20
|
+
createErrorNotice(sprintf(__("The \"%s\" plugin has encountered an error and cannot be rendered."), name));
|
|
21
|
+
}
|
|
22
|
+
const navigateRegionsProps = __unstableUseNavigateRegions();
|
|
23
|
+
const adminPrimary = useMemo(() => getAdminThemeColors().primary, []);
|
|
24
|
+
return /* @__PURE__ */ jsx(ThemeProvider, {
|
|
25
|
+
isRoot: true,
|
|
26
|
+
color: { primary: adminPrimary },
|
|
27
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx("div", {
|
|
28
|
+
...navigateRegionsProps,
|
|
29
|
+
children: /* @__PURE__ */ jsxs(WidgetAreasBlockEditorProvider, {
|
|
30
|
+
blockEditorSettings,
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx(Interface, { blockEditorSettings }),
|
|
33
|
+
/* @__PURE__ */ jsx(Sidebar, {}),
|
|
34
|
+
/* @__PURE__ */ jsx(PluginArea, { onError: onPluginAreaError }),
|
|
35
|
+
/* @__PURE__ */ jsx(UnsavedChangesWarning, {}),
|
|
36
|
+
/* @__PURE__ */ jsx(WelcomeGuide, {})
|
|
37
|
+
]
|
|
38
|
+
})
|
|
39
|
+
}) })
|
|
40
|
+
});
|
|
50
41
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=index.mjs.map
|
|
42
|
+
export { Layout as default };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/layout/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { PluginArea } from '@wordpress/plugins';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport ErrorBoundary from '../error-boundary';\nimport WidgetAreasBlockEditorProvider from '../widget-areas-block-editor-provider';\nimport Sidebar from '../sidebar';\nimport Interface from './interface';\nimport UnsavedChangesWarning from './unsaved-changes-warning';\nimport WelcomeGuide from '../welcome-guide';\n\nfunction Layout( { blockEditorSettings } ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\treturn (\n\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t<ErrorBoundary>\n\t\t\t\t<div { ...navigateRegionsProps }>\n\t\t\t\t\t<WidgetAreasBlockEditorProvider\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Interface\n\t\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Sidebar />\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<WelcomeGuide />\n\t\t\t\t\t</WidgetAreasBlockEditorProvider>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</ThemeProvider>\n\t);\n}\n\nexport default Layout;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,2BAA2B;AACpC,SAAS,IAAI,eAAe;AAC5B,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,SAAS,oBAAoB;AACtC,SAAS,gCAAgC,0BAA0B;AACnE,SAAS,qBAAqB;AAC9B,OAAO,mBAAmB;AAC1B,OAAO,oCAAoC;AAC3C,OAAO,aAAa;AACpB,OAAO,eAAe;AACtB,OAAO,2BAA2B;AAClC,OAAO,kBAAkB;AAwBpB,SAGC,KAHD;AAtBL,SAAS,OAAQ,EAAE,oBAAoB,GAAI;AAC1C,QAAM,EAAE,kBAAkB,IAAI,YAAa,YAAa;AAExD,WAAS,kBAAmB,MAAO;AAClC;AAAA,MACC;AAAA;AAAA,QAEC;AAAA,UACC;AAAA,QACD;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,QAAM,uBAAuB,mBAAmB;AAChD,QAAM,eAAe,QAAS,MAAM,oBAAoB,EAAE,SAAS,CAAC,CAAE;AAEtE,SACC,oBAAC,iBAAc,QAAM,MAAC,OAAQ,EAAE,SAAS,aAAa,GACrD,8BAAC,iBACA,8BAAC,SAAM,GAAG,sBACT;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACA;AAAA;AAAA,QACD;AAAA,QACA,oBAAC,WAAQ;AAAA,QACT,oBAAC,cAAW,SAAU,mBAAoB;AAAA,QAC1C,oBAAC,yBAAsB;AAAA,QACvB,oBAAC,gBAAa;AAAA;AAAA;AAAA,EACf,GACD,GACD,GACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["noticesStore","useNavigateRegions"],"sources":["../../../src/components/layout/index.jsx"],"sourcesContent":["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { PluginArea } from '@wordpress/plugins';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport ErrorBoundary from '../error-boundary';\nimport WidgetAreasBlockEditorProvider from '../widget-areas-block-editor-provider';\nimport Sidebar from '../sidebar';\nimport Interface from './interface';\nimport UnsavedChangesWarning from './unsaved-changes-warning';\nimport WelcomeGuide from '../welcome-guide';\n\nfunction Layout( { blockEditorSettings } ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\treturn (\n\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t<ErrorBoundary>\n\t\t\t\t<div { ...navigateRegionsProps }>\n\t\t\t\t\t<WidgetAreasBlockEditorProvider\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Interface\n\t\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Sidebar />\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<WelcomeGuide />\n\t\t\t\t\t</WidgetAreasBlockEditorProvider>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</ThemeProvider>\n\t);\n}\n\nexport default Layout;\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAS,OAAQ,EAAE,uBAAwB;CAC1C,MAAM,EAAE,sBAAsB,YAAaA,KAAa;CAExD,SAAS,kBAAmB,MAAO;EAClC,kBACC,QAEC,GACC,oEACD,GACA,IACD,CACD;CACD;CAEA,MAAM,uBAAuBC,6BAAmB;CAChD,MAAM,eAAe,cAAe,oBAAoB,CAAC,CAAC,SAAS,CAAC,CAAE;CAEtE,OACC,oBAAC,eAAD;EAAe,QAAA;EAAO,OAAQ,EAAE,SAAS,aAAa;EACrD,UAAA,oBAAC,eAAD,EAAA,UACC,oBAAC,OAAD;GAAK,GAAK;GACT,UAAA,qBAAC,gCAAD;IACuB;IADvB,UAAA;KAGC,oBAAC,WAAD,EACuB,oBACtB,CAAA;KACD,oBAAC,SAAD,CAAU,CAAA;KACV,oBAAC,YAAD,EAAY,SAAU,kBAAqB,CAAA;KAC3C,oBAAC,uBAAD,CAAwB,CAAA;KACxB,oBAAC,cAAD,CAAe,CAAA;IACgB;;EAC5B,CAAA,EACS,CAAA;CACD,CAAA;AAEjB"}
|
|
@@ -1,88 +1,65 @@
|
|
|
1
|
-
// packages/edit-widgets/src/components/layout/interface.jsx
|
|
2
1
|
import { useViewportMatch } from "@wordpress/compose";
|
|
3
2
|
import { BlockBreadcrumb } from "@wordpress/block-editor";
|
|
4
3
|
import { useEffect } from "@wordpress/element";
|
|
5
4
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
6
|
-
import {
|
|
7
|
-
InterfaceSkeleton,
|
|
8
|
-
ComplementaryArea,
|
|
9
|
-
store as interfaceStore
|
|
10
|
-
} from "@wordpress/interface";
|
|
5
|
+
import { ComplementaryArea, InterfaceSkeleton, store } from "@wordpress/interface";
|
|
11
6
|
import { __ } from "@wordpress/i18n";
|
|
12
|
-
import { store as
|
|
7
|
+
import { store as store$1 } from "@wordpress/preferences";
|
|
13
8
|
import Header from "../header/index.mjs";
|
|
14
9
|
import WidgetAreasBlockEditorContent from "../widget-areas-block-editor-content/index.mjs";
|
|
15
|
-
import { store as
|
|
10
|
+
import { store as store$2 } from "../../store/index.mjs";
|
|
16
11
|
import SecondarySidebar from "../secondary-sidebar/index.mjs";
|
|
17
12
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
sidebar: __("Widgets settings"),
|
|
25
|
-
/* translators: accessibility text for the widgets screen footer landmark region. */
|
|
26
|
-
footer: __("Widgets footer")
|
|
13
|
+
// packages/edit-widgets/src/components/layout/interface.jsx
|
|
14
|
+
const interfaceLabels = {
|
|
15
|
+
header: __("Widgets top bar"),
|
|
16
|
+
body: __("Widgets and blocks"),
|
|
17
|
+
sidebar: __("Widgets settings"),
|
|
18
|
+
footer: __("Widgets footer")
|
|
27
19
|
};
|
|
28
20
|
function Interface({ blockEditorSettings }) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
header: /* @__PURE__ */ jsx(Header, {}),
|
|
72
|
-
secondarySidebar: hasSecondarySidebar && /* @__PURE__ */ jsx(SecondarySidebar, {}),
|
|
73
|
-
sidebar: /* @__PURE__ */ jsx(ComplementaryArea.Slot, { scope: "core/edit-widgets" }),
|
|
74
|
-
content: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
75
|
-
WidgetAreasBlockEditorContent,
|
|
76
|
-
{
|
|
77
|
-
blockEditorSettings
|
|
78
|
-
}
|
|
79
|
-
) }),
|
|
80
|
-
footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && /* @__PURE__ */ jsx("div", { className: "edit-widgets-layout__footer", children: /* @__PURE__ */ jsx(BlockBreadcrumb, { rootLabelText: __("Widgets") }) })
|
|
81
|
-
}
|
|
82
|
-
);
|
|
21
|
+
const isMobileViewport = useViewportMatch("medium", "<");
|
|
22
|
+
const isHugeViewport = useViewportMatch("huge", ">=");
|
|
23
|
+
const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } = useDispatch(store$2);
|
|
24
|
+
const { hasBlockBreadCrumbsEnabled, hasSidebarEnabled, isInserterOpened, isListViewOpened } = useSelect((select) => ({
|
|
25
|
+
hasSidebarEnabled: !!select(store).getActiveComplementaryArea(store$2.name),
|
|
26
|
+
isInserterOpened: !!select(store$2).isInserterOpened(),
|
|
27
|
+
isListViewOpened: !!select(store$2).isListViewOpened(),
|
|
28
|
+
hasBlockBreadCrumbsEnabled: !!select(store$1).get("core/edit-widgets", "showBlockBreadcrumbs")
|
|
29
|
+
}), []);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (hasSidebarEnabled && !isHugeViewport) {
|
|
32
|
+
setIsInserterOpened(false);
|
|
33
|
+
setIsListViewOpened(false);
|
|
34
|
+
}
|
|
35
|
+
}, [hasSidebarEnabled, isHugeViewport]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if ((isInserterOpened || isListViewOpened) && !isHugeViewport) closeGeneralSidebar();
|
|
38
|
+
}, [
|
|
39
|
+
isInserterOpened,
|
|
40
|
+
isListViewOpened,
|
|
41
|
+
isHugeViewport
|
|
42
|
+
]);
|
|
43
|
+
const secondarySidebarLabel = isListViewOpened ? __("List View") : __("Block Library");
|
|
44
|
+
const hasSecondarySidebar = isListViewOpened || isInserterOpened;
|
|
45
|
+
return /* @__PURE__ */ jsx(InterfaceSkeleton, {
|
|
46
|
+
labels: {
|
|
47
|
+
...interfaceLabels,
|
|
48
|
+
secondarySidebar: secondarySidebarLabel
|
|
49
|
+
},
|
|
50
|
+
header: /* @__PURE__ */ jsx(Header, {}),
|
|
51
|
+
secondarySidebar: hasSecondarySidebar && /* @__PURE__ */ jsx(SecondarySidebar, {}),
|
|
52
|
+
sidebar: /* @__PURE__ */ jsx(ComplementaryArea.Slot, { scope: "core/edit-widgets" }),
|
|
53
|
+
content: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(WidgetAreasBlockEditorContent, { blockEditorSettings }) }),
|
|
54
|
+
footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && /* @__PURE__ */ jsx("div", {
|
|
55
|
+
className: "edit-widgets-layout__footer",
|
|
56
|
+
children: /* @__PURE__ */ jsx(BlockBreadcrumb, {
|
|
57
|
+
className: "edit-widgets-layout__breadcrumbs",
|
|
58
|
+
rootLabelText: __("Widgets")
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
});
|
|
83
62
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
//# sourceMappingURL=interface.mjs.map
|
|
63
|
+
export { Interface as default };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=interface.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/layout/interface.jsx"],
|
|
4
|
-
"sourcesContent": ["import { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={ <Header /> }\n\t\t\tsecondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }\n\t\t\tsidebar={ <ComplementaryArea.Slot scope=\"core/edit-widgets\" /> }\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<WidgetAreasBlockEditorContent\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\thasBlockBreadCrumbsEnabled &&\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<div className=\"edit-widgets-layout__footer\">\n\t\t\t\t\t\t<BlockBreadcrumb rootLabelText={ __( 'Widgets' ) } />\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport default Interface;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,UAAU;AACnB,SAAS,SAAS,wBAAwB;AAC1C,OAAO,YAAY;AACnB,OAAO,mCAAmC;AAC1C,SAAS,SAAS,wBAAwB;AAC1C,OAAO,sBAAsB;AAgEjB,SAIR,UAJQ;AA9DZ,IAAM,kBAAkB;AAAA;AAAA,EAEvB,QAAQ,GAAI,iBAAkB;AAAA;AAAA,EAE9B,MAAM,GAAI,oBAAqB;AAAA;AAAA,EAE/B,SAAS,GAAI,kBAAmB;AAAA;AAAA,EAEhC,QAAQ,GAAI,gBAAiB;AAC9B;AAEA,SAAS,UAAW,EAAE,oBAAoB,GAAI;AAC7C,QAAM,mBAAmB,iBAAkB,UAAU,GAAI;AACzD,QAAM,iBAAiB,iBAAkB,QAAQ,IAAK;AACtD,QAAM,EAAE,qBAAqB,qBAAqB,oBAAoB,IACrE,YAAa,gBAAiB;AAC/B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAAA,IACH,CAAE,YAAc;AAAA,MACf,mBAAmB,CAAC,CAAE;AAAA,QACrB;AAAA,MACD,EAAE,2BAA4B,iBAAiB,IAAK;AAAA,MACpD,kBAAkB,CAAC,CAAE,OAAQ,gBAAiB,EAAE,iBAAiB;AAAA,MACjE,kBAAkB,CAAC,CAAE,OAAQ,gBAAiB,EAAE,iBAAiB;AAAA,MACjE,4BAA4B,CAAC,CAAE,OAAQ,gBAAiB,EAAE;AAAA,QACzD;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAGA,YAAW,MAAM;AAChB,QAAK,qBAAqB,CAAE,gBAAiB;AAC5C,0BAAqB,KAAM;AAC3B,0BAAqB,KAAM;AAAA,IAC5B;AAAA,EACD,GAAG,CAAE,mBAAmB,cAAe,CAAE;AAEzC,YAAW,MAAM;AAChB,SAAO,oBAAoB,qBAAsB,CAAE,gBAAiB;AACnE,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,kBAAkB,kBAAkB,cAAe,CAAE;AAE1D,QAAM,wBAAwB,mBAC3B,GAAI,WAAY,IAChB,GAAI,eAAgB;AAEvB,QAAM,sBAAsB,oBAAoB;AAEhD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS;AAAA,QACR,GAAG;AAAA,QACH,kBAAkB;AAAA,MACnB;AAAA,MACA,QAAS,oBAAC,UAAO;AAAA,MACjB,kBAAmB,uBAAuB,oBAAC,oBAAiB;AAAA,MAC5D,SAAU,oBAAC,kBAAkB,MAAlB,EAAuB,OAAM,qBAAoB;AAAA,MAC5D,SACC,gCACC;AAAA,QAAC;AAAA;AAAA,UACA;AAAA;AAAA,MACD,GACD;AAAA,MAED,QACC,8BACA,CAAE,oBACD,oBAAC,SAAI,WAAU,+BACd,8BAAC,mBAAgB,eAAgB,GAAI,SAAU,GAAI,GACpD;AAAA;AAAA,EAGH;AAEF;AAEA,IAAO,oBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"interface.mjs","names":["editWidgetsStore","interfaceStore","preferencesStore"],"sources":["../../../src/components/layout/interface.jsx"],"sourcesContent":["import { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={ <Header /> }\n\t\t\tsecondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }\n\t\t\tsidebar={ <ComplementaryArea.Slot scope=\"core/edit-widgets\" /> }\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<WidgetAreasBlockEditorContent\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\thasBlockBreadCrumbsEnabled &&\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<div className=\"edit-widgets-layout__footer\">\n\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\tclassName=\"edit-widgets-layout__breadcrumbs\"\n\t\t\t\t\t\t\trootLabelText={ __( 'Widgets' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport default Interface;\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,kBAAkB;CAEvB,QAAQ,GAAI,iBAAkB;CAE9B,MAAM,GAAI,oBAAqB;CAE/B,SAAS,GAAI,kBAAmB;CAEhC,QAAQ,GAAI,gBAAiB;AAC9B;AAEA,SAAS,UAAW,EAAE,uBAAwB;CAC7C,MAAM,mBAAmB,iBAAkB,UAAU,GAAI;CACzD,MAAM,iBAAiB,iBAAkB,QAAQ,IAAK;CACtD,MAAM,EAAE,qBAAqB,qBAAqB,wBACjD,YAAaA,OAAiB;CAC/B,MAAM,EACL,4BACA,mBACA,kBACA,qBACG,WACD,YAAc;EACf,mBAAmB,CAAC,CAAE,OACrBC,KACD,CAAC,CAAC,2BAA4BD,QAAiB,IAAK;EACpD,kBAAkB,CAAC,CAAE,OAAQA,OAAiB,CAAC,CAAC,iBAAiB;EACjE,kBAAkB,CAAC,CAAE,OAAQA,OAAiB,CAAC,CAAC,iBAAiB;EACjE,4BAA4B,CAAC,CAAE,OAAQE,OAAiB,CAAC,CAAC,IACzD,qBACA,sBACD;CACD,IACA,CAAC,CACF;CAGA,gBAAiB;EAChB,IAAK,qBAAqB,CAAE,gBAAiB;GAC5C,oBAAqB,KAAM;GAC3B,oBAAqB,KAAM;EAC5B;CACD,GAAG,CAAE,mBAAmB,cAAe,CAAE;CAEzC,gBAAiB;EAChB,KAAO,oBAAoB,qBAAsB,CAAE,gBAClD,oBAAoB;CAEtB,GAAG;EAAE;EAAkB;EAAkB;CAAe,CAAE;CAE1D,MAAM,wBAAwB,mBAC3B,GAAI,WAAY,IAChB,GAAI,eAAgB;CAEvB,MAAM,sBAAsB,oBAAoB;CAEhD,OACC,oBAAC,mBAAD;EACC,QAAS;GACR,GAAG;GACH,kBAAkB;EACnB;EACA,QAAS,oBAAC,QAAD,CAAS,CAAA;EAClB,kBAAmB,uBAAuB,oBAAC,kBAAD,CAAmB,CAAA;EAC7D,SAAU,oBAAC,kBAAkB,MAAnB,EAAwB,OAAM,oBAAqB,CAAA;EAC7D,SACC,oBAAA,UAAA,EAAA,UACC,oBAAC,+BAAD,EACuB,oBACtB,CAAA,EACA,CAAA;EAEH,QACC,8BACA,CAAE,oBACD,oBAAC,OAAD;GAAK,WAAU;GACd,UAAA,oBAAC,iBAAD;IACC,WAAU;IACV,eAAgB,GAAI,SAAU;GAC9B,CAAA;EACG,CAAA;CAGP,CAAA;AAEH"}
|
|
@@ -1,31 +1,42 @@
|
|
|
1
|
-
// packages/edit-widgets/src/components/layout/unsaved-changes-warning.js
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import { useEffect } from "@wordpress/element";
|
|
4
3
|
import { useSelect } from "@wordpress/data";
|
|
5
|
-
import { store
|
|
4
|
+
import { store } from "../../store/index.mjs";
|
|
5
|
+
// packages/edit-widgets/src/components/layout/unsaved-changes-warning.js
|
|
6
|
+
/**
|
|
7
|
+
* Warns the user if there are unsaved changes before leaving the editor.
|
|
8
|
+
*
|
|
9
|
+
* This is a duplicate of the component implemented in the editor package.
|
|
10
|
+
* Duplicated here as edit-widgets doesn't depend on editor.
|
|
11
|
+
*
|
|
12
|
+
* @return {Component} The component.
|
|
13
|
+
*/
|
|
6
14
|
function UnsavedChangesWarning() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const isDirty = useSelect((select) => {
|
|
16
|
+
const { getEditedWidgetAreas } = select(store);
|
|
17
|
+
return getEditedWidgetAreas()?.length > 0;
|
|
18
|
+
}, []);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
/**
|
|
21
|
+
* Warns the user if there are unsaved changes before leaving the editor.
|
|
22
|
+
*
|
|
23
|
+
* @param {Event} event `beforeunload` event.
|
|
24
|
+
*
|
|
25
|
+
* @return {string | undefined} Warning prompt message, if unsaved changes exist.
|
|
26
|
+
*/
|
|
27
|
+
const warnIfUnsavedChanges = (event) => {
|
|
28
|
+
if (isDirty) {
|
|
29
|
+
event.returnValue = __("You have unsaved changes. If you proceed, they will be lost.");
|
|
30
|
+
return event.returnValue;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
window.addEventListener("beforeunload", warnIfUnsavedChanges);
|
|
34
|
+
return () => {
|
|
35
|
+
window.removeEventListener("beforeunload", warnIfUnsavedChanges);
|
|
36
|
+
};
|
|
37
|
+
}, [isDirty]);
|
|
38
|
+
return null;
|
|
27
39
|
}
|
|
28
|
-
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=unsaved-changes-warning.mjs.map
|
|
40
|
+
export { UnsavedChangesWarning as default };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=unsaved-changes-warning.mjs.map
|