@wordpress/customize-widgets 5.32.0 → 5.32.1-next.ff1cebbba.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/components/block-appender/index.js +33 -27
- package/build/components/block-appender/index.js.map +7 -1
- package/build/components/block-inspector-button/index.js +51 -36
- package/build/components/block-inspector-button/index.js.map +7 -1
- package/build/components/customize-widgets/index.js +83 -61
- package/build/components/customize-widgets/index.js.map +7 -1
- package/build/components/customize-widgets/use-clear-selected-block.js +56 -63
- package/build/components/customize-widgets/use-clear-selected-block.js.map +7 -1
- package/build/components/error-boundary/index.js +46 -45
- package/build/components/error-boundary/index.js.map +7 -1
- package/build/components/focus-control/index.js +69 -57
- package/build/components/focus-control/index.js.map +7 -1
- package/build/components/focus-control/use-blocks-focus-control.js +38 -31
- package/build/components/focus-control/use-blocks-focus-control.js.map +7 -1
- package/build/components/header/index.js +110 -71
- package/build/components/header/index.js.map +7 -1
- package/build/components/inserter/index.js +77 -53
- package/build/components/inserter/index.js.map +7 -1
- package/build/components/inserter/use-inserter.js +46 -29
- package/build/components/inserter/use-inserter.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +74 -71
- package/build/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +61 -44
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +155 -110
- package/build/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +76 -56
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build/components/keyboard-shortcuts/index.js +60 -51
- package/build/components/keyboard-shortcuts/index.js.map +7 -1
- package/build/components/more-menu/index.js +151 -90
- package/build/components/more-menu/index.js.map +7 -1
- package/build/components/sidebar-block-editor/index.js +133 -105
- package/build/components/sidebar-block-editor/index.js.map +7 -1
- package/build/components/sidebar-block-editor/sidebar-adapter.js +73 -67
- package/build/components/sidebar-block-editor/sidebar-adapter.js.map +7 -1
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js +51 -33
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js.map +7 -1
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js +100 -79
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js.map +7 -1
- package/build/components/sidebar-controls/index.js +45 -31
- package/build/components/sidebar-controls/index.js.map +7 -1
- package/build/components/welcome-guide/index.js +86 -58
- package/build/components/welcome-guide/index.js.map +7 -1
- package/build/controls/inserter-outer-section.js +49 -58
- package/build/controls/inserter-outer-section.js.map +7 -1
- package/build/controls/inspector-section.js +30 -36
- package/build/controls/inspector-section.js.map +7 -1
- package/build/controls/sidebar-control.js +51 -30
- package/build/controls/sidebar-control.js.map +7 -1
- package/build/controls/sidebar-section.js +71 -39
- package/build/controls/sidebar-section.js.map +7 -1
- package/build/filters/index.js +4 -6
- package/build/filters/index.js.map +7 -1
- package/build/filters/move-to-sidebar.js +77 -79
- package/build/filters/move-to-sidebar.js.map +7 -1
- package/build/filters/replace-media-upload.js +9 -11
- package/build/filters/replace-media-upload.js.map +7 -1
- package/build/filters/wide-widget-display.js +20 -25
- package/build/filters/wide-widget-display.js.map +7 -1
- package/build/index.js +81 -70
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/store/actions.js +27 -44
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -10
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +44 -40
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +25 -19
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +31 -44
- package/build/store/selectors.js.map +7 -1
- package/build/utils.js +45 -73
- package/build/utils.js.map +7 -1
- package/build-module/components/block-appender/index.js +17 -20
- package/build-module/components/block-appender/index.js.map +7 -1
- package/build-module/components/block-inspector-button/index.js +33 -30
- package/build-module/components/block-inspector-button/index.js.map +7 -1
- package/build-module/components/customize-widgets/index.js +52 -51
- package/build-module/components/customize-widgets/index.js.map +7 -1
- package/build-module/components/customize-widgets/use-clear-selected-block.js +38 -58
- package/build-module/components/customize-widgets/use-clear-selected-block.js.map +7 -1
- package/build-module/components/error-boundary/index.js +27 -37
- package/build-module/components/error-boundary/index.js.map +7 -1
- package/build-module/components/focus-control/index.js +50 -45
- package/build-module/components/focus-control/index.js.map +7 -1
- package/build-module/components/focus-control/use-blocks-focus-control.js +17 -22
- package/build-module/components/focus-control/use-blocks-focus-control.js.map +7 -1
- package/build-module/components/header/index.js +81 -63
- package/build-module/components/header/index.js.map +7 -1
- package/build-module/components/inserter/index.js +59 -47
- package/build-module/components/inserter/index.js.map +7 -1
- package/build-module/components/inserter/use-inserter.js +28 -23
- package/build-module/components/inserter/use-inserter.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +62 -75
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +33 -37
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +130 -103
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -50
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcuts/index.js +44 -44
- package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
- package/build-module/components/more-menu/index.js +129 -84
- package/build-module/components/more-menu/index.js.map +7 -1
- package/build-module/components/sidebar-block-editor/index.js +109 -96
- package/build-module/components/sidebar-block-editor/index.js.map +7 -1
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js +54 -59
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js.map +7 -1
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js +22 -25
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js.map +7 -1
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js +70 -70
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js.map +7 -1
- package/build-module/components/sidebar-controls/index.js +24 -25
- package/build-module/components/sidebar-controls/index.js.map +7 -1
- package/build-module/components/welcome-guide/index.js +68 -52
- package/build-module/components/welcome-guide/index.js.map +7 -1
- package/build-module/controls/inserter-outer-section.js +31 -52
- package/build-module/controls/inserter-outer-section.js.map +7 -1
- package/build-module/controls/inspector-section.js +13 -32
- package/build-module/controls/inspector-section.js.map +7 -1
- package/build-module/controls/sidebar-control.js +22 -22
- package/build-module/controls/sidebar-control.js.map +7 -1
- package/build-module/controls/sidebar-section.js +43 -32
- package/build-module/controls/sidebar-section.js.map +7 -1
- package/build-module/filters/index.js +4 -7
- package/build-module/filters/index.js.map +7 -1
- package/build-module/filters/move-to-sidebar.js +83 -76
- package/build-module/filters/move-to-sidebar.js.map +7 -1
- package/build-module/filters/replace-media-upload.js +8 -7
- package/build-module/filters/replace-media-upload.js.map +7 -1
- package/build-module/filters/wide-widget-display.js +20 -22
- package/build-module/filters/wide-widget-display.js.map +7 -1
- package/build-module/index.js +53 -51
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/store/actions.js +6 -40
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -5
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +10 -30
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +7 -14
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +10 -40
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/utils.js +21 -66
- package/build-module/utils.js.map +7 -1
- package/build-style/style-rtl.css +14 -149
- package/build-style/style.css +14 -149
- package/package.json +30 -23
- package/src/components/block-inspector-button/style.scss +3 -0
- package/src/components/header/style.scss +5 -0
- package/src/components/inserter/style.scss +3 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +2 -0
- package/src/components/more-menu/style.scss +2 -0
- package/src/components/sidebar-block-editor/style.scss +2 -0
- package/src/components/welcome-guide/style.scss +2 -0
- package/src/controls/style.scss +2 -0
- package/src/style.scss +10 -8
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/sidebar-block-editor/sidebar-editor-provider.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useSidebarBlockEditor from './use-sidebar-block-editor';\nimport useBlocksFocusControl from '../focus-control/use-blocks-focus-control';\n\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\n\nexport default function SidebarEditorProvider( {\n\tsidebar,\n\tsettings,\n\tchildren,\n} ) {\n\tconst [ blocks, onInput, onChange ] = useSidebarBlockEditor( sidebar );\n\n\tuseBlocksFocusControl( blocks );\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tsettings={ settings }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t{ children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAyBE;AAtBF,SAAS,eAAe,8BAA8B;AAKtD,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAElC,SAAS,cAAc;AAEvB,MAAM,EAAE,gCAAgC,IAAI,OAAQ,sBAAuB;AAE5D,SAAR,sBAAwC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,QAAQ,SAAS,QAAS,IAAI,sBAAuB,OAAQ;AAErE,wBAAuB,MAAO;AAE9B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAiB;AAAA,MAEf;AAAA;AAAA,EACH;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,40 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState, useEffect, useCallback } from '@wordpress/element';
|
|
10
|
-
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
11
|
-
import { getWidgetIdFromBlock, addWidgetIdToBlock } from '@wordpress/widgets';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { blockToWidget, widgetToBlock } from '../../utils';
|
|
1
|
+
import fastDeepEqual from "fast-deep-equal/es6";
|
|
2
|
+
import { useState, useEffect, useCallback } from "@wordpress/element";
|
|
3
|
+
import isShallowEqual from "@wordpress/is-shallow-equal";
|
|
4
|
+
import { getWidgetIdFromBlock, addWidgetIdToBlock } from "@wordpress/widgets";
|
|
5
|
+
import { blockToWidget, widgetToBlock } from "../../utils";
|
|
17
6
|
function widgetsToBlocks(widgets) {
|
|
18
|
-
return widgets.map(widget => widgetToBlock(widget));
|
|
7
|
+
return widgets.map((widget) => widgetToBlock(widget));
|
|
19
8
|
}
|
|
20
|
-
|
|
21
|
-
const [blocks, setBlocks] = useState(
|
|
9
|
+
function useSidebarBlockEditor(sidebar) {
|
|
10
|
+
const [blocks, setBlocks] = useState(
|
|
11
|
+
() => widgetsToBlocks(sidebar.getWidgets())
|
|
12
|
+
);
|
|
22
13
|
useEffect(() => {
|
|
23
14
|
return sidebar.subscribe((prevWidgets, nextWidgets) => {
|
|
24
|
-
setBlocks(prevBlocks => {
|
|
25
|
-
const prevWidgetsMap = new Map(
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
setBlocks((prevBlocks) => {
|
|
16
|
+
const prevWidgetsMap = new Map(
|
|
17
|
+
prevWidgets.map((widget) => [widget.id, widget])
|
|
18
|
+
);
|
|
19
|
+
const prevBlocksMap = new Map(
|
|
20
|
+
prevBlocks.map((block) => [
|
|
21
|
+
getWidgetIdFromBlock(block),
|
|
22
|
+
block
|
|
23
|
+
])
|
|
24
|
+
);
|
|
25
|
+
const nextBlocks = nextWidgets.map((nextWidget) => {
|
|
28
26
|
const prevWidget = prevWidgetsMap.get(nextWidget.id);
|
|
29
|
-
|
|
30
|
-
// Bail out updates.
|
|
31
27
|
if (prevWidget && prevWidget === nextWidget) {
|
|
32
28
|
return prevBlocksMap.get(nextWidget.id);
|
|
33
29
|
}
|
|
34
30
|
return widgetToBlock(nextWidget);
|
|
35
31
|
});
|
|
36
|
-
|
|
37
|
-
// Bail out updates.
|
|
38
32
|
if (isShallowEqual(prevBlocks, nextBlocks)) {
|
|
39
33
|
return prevBlocks;
|
|
40
34
|
}
|
|
@@ -42,51 +36,57 @@ export default function useSidebarBlockEditor(sidebar) {
|
|
|
42
36
|
});
|
|
43
37
|
});
|
|
44
38
|
}, [sidebar]);
|
|
45
|
-
const onChangeBlocks = useCallback(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const prevBlocksMap = new Map(prevBlocks.map(block => [getWidgetIdFromBlock(block), block]));
|
|
51
|
-
const nextWidgets = nextBlocks.map(nextBlock => {
|
|
52
|
-
const widgetId = getWidgetIdFromBlock(nextBlock);
|
|
53
|
-
|
|
54
|
-
// Update existing widgets.
|
|
55
|
-
if (widgetId && prevBlocksMap.has(widgetId)) {
|
|
56
|
-
const prevBlock = prevBlocksMap.get(widgetId);
|
|
57
|
-
const prevWidget = sidebar.getWidget(widgetId);
|
|
58
|
-
|
|
59
|
-
// Bail out updates by returning the previous widgets.
|
|
60
|
-
// Deep equality is necessary until the block editor's internals changes.
|
|
61
|
-
if (fastDeepEqual(nextBlock, prevBlock) && prevWidget) {
|
|
62
|
-
return prevWidget;
|
|
63
|
-
}
|
|
64
|
-
return blockToWidget(nextBlock, prevWidget);
|
|
39
|
+
const onChangeBlocks = useCallback(
|
|
40
|
+
(nextBlocks) => {
|
|
41
|
+
setBlocks((prevBlocks) => {
|
|
42
|
+
if (isShallowEqual(prevBlocks, nextBlocks)) {
|
|
43
|
+
return prevBlocks;
|
|
65
44
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (updatedNextBlocks === nextBlocks) {
|
|
82
|
-
updatedNextBlocks = nextBlocks.slice();
|
|
45
|
+
const prevBlocksMap = new Map(
|
|
46
|
+
prevBlocks.map((block) => [
|
|
47
|
+
getWidgetIdFromBlock(block),
|
|
48
|
+
block
|
|
49
|
+
])
|
|
50
|
+
);
|
|
51
|
+
const nextWidgets = nextBlocks.map((nextBlock) => {
|
|
52
|
+
const widgetId = getWidgetIdFromBlock(nextBlock);
|
|
53
|
+
if (widgetId && prevBlocksMap.has(widgetId)) {
|
|
54
|
+
const prevBlock = prevBlocksMap.get(widgetId);
|
|
55
|
+
const prevWidget = sidebar.getWidget(widgetId);
|
|
56
|
+
if (fastDeepEqual(nextBlock, prevBlock) && prevWidget) {
|
|
57
|
+
return prevWidget;
|
|
58
|
+
}
|
|
59
|
+
return blockToWidget(nextBlock, prevWidget);
|
|
83
60
|
}
|
|
84
|
-
|
|
61
|
+
return blockToWidget(nextBlock);
|
|
62
|
+
});
|
|
63
|
+
if (isShallowEqual(sidebar.getWidgets(), nextWidgets)) {
|
|
64
|
+
return prevBlocks;
|
|
85
65
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
66
|
+
const addedWidgetIds = sidebar.setWidgets(nextWidgets);
|
|
67
|
+
return nextBlocks.reduce(
|
|
68
|
+
(updatedNextBlocks, nextBlock, index) => {
|
|
69
|
+
const addedWidgetId = addedWidgetIds[index];
|
|
70
|
+
if (addedWidgetId !== null) {
|
|
71
|
+
if (updatedNextBlocks === nextBlocks) {
|
|
72
|
+
updatedNextBlocks = nextBlocks.slice();
|
|
73
|
+
}
|
|
74
|
+
updatedNextBlocks[index] = addWidgetIdToBlock(
|
|
75
|
+
nextBlock,
|
|
76
|
+
addedWidgetId
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return updatedNextBlocks;
|
|
80
|
+
},
|
|
81
|
+
nextBlocks
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
[sidebar]
|
|
86
|
+
);
|
|
90
87
|
return [blocks, onChangeBlocks, onChangeBlocks];
|
|
91
88
|
}
|
|
92
|
-
|
|
89
|
+
export {
|
|
90
|
+
useSidebarBlockEditor as default
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=use-sidebar-block-editor.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/sidebar-block-editor/use-sidebar-block-editor.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { getWidgetIdFromBlock, addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport { blockToWidget, widgetToBlock } from '../../utils';\n\nfunction widgetsToBlocks( widgets ) {\n\treturn widgets.map( ( widget ) => widgetToBlock( widget ) );\n}\n\nexport default function useSidebarBlockEditor( sidebar ) {\n\tconst [ blocks, setBlocks ] = useState( () =>\n\t\twidgetsToBlocks( sidebar.getWidgets() )\n\t);\n\n\tuseEffect( () => {\n\t\treturn sidebar.subscribe( ( prevWidgets, nextWidgets ) => {\n\t\t\tsetBlocks( ( prevBlocks ) => {\n\t\t\t\tconst prevWidgetsMap = new Map(\n\t\t\t\t\tprevWidgets.map( ( widget ) => [ widget.id, widget ] )\n\t\t\t\t);\n\t\t\t\tconst prevBlocksMap = new Map(\n\t\t\t\t\tprevBlocks.map( ( block ) => [\n\t\t\t\t\t\tgetWidgetIdFromBlock( block ),\n\t\t\t\t\t\tblock,\n\t\t\t\t\t] )\n\t\t\t\t);\n\n\t\t\t\tconst nextBlocks = nextWidgets.map( ( nextWidget ) => {\n\t\t\t\t\tconst prevWidget = prevWidgetsMap.get( nextWidget.id );\n\n\t\t\t\t\t// Bail out updates.\n\t\t\t\t\tif ( prevWidget && prevWidget === nextWidget ) {\n\t\t\t\t\t\treturn prevBlocksMap.get( nextWidget.id );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn widgetToBlock( nextWidget );\n\t\t\t\t} );\n\n\t\t\t\t// Bail out updates.\n\t\t\t\tif ( isShallowEqual( prevBlocks, nextBlocks ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\treturn nextBlocks;\n\t\t\t} );\n\t\t} );\n\t}, [ sidebar ] );\n\n\tconst onChangeBlocks = useCallback(\n\t\t( nextBlocks ) => {\n\t\t\tsetBlocks( ( prevBlocks ) => {\n\t\t\t\tif ( isShallowEqual( prevBlocks, nextBlocks ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\tconst prevBlocksMap = new Map(\n\t\t\t\t\tprevBlocks.map( ( block ) => [\n\t\t\t\t\t\tgetWidgetIdFromBlock( block ),\n\t\t\t\t\t\tblock,\n\t\t\t\t\t] )\n\t\t\t\t);\n\n\t\t\t\tconst nextWidgets = nextBlocks.map( ( nextBlock ) => {\n\t\t\t\t\tconst widgetId = getWidgetIdFromBlock( nextBlock );\n\n\t\t\t\t\t// Update existing widgets.\n\t\t\t\t\tif ( widgetId && prevBlocksMap.has( widgetId ) ) {\n\t\t\t\t\t\tconst prevBlock = prevBlocksMap.get( widgetId );\n\t\t\t\t\t\tconst prevWidget = sidebar.getWidget( widgetId );\n\n\t\t\t\t\t\t// Bail out updates by returning the previous widgets.\n\t\t\t\t\t\t// Deep equality is necessary until the block editor's internals changes.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tfastDeepEqual( nextBlock, prevBlock ) &&\n\t\t\t\t\t\t\tprevWidget\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn prevWidget;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn blockToWidget( nextBlock, prevWidget );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Add a new widget.\n\t\t\t\t\treturn blockToWidget( nextBlock );\n\t\t\t\t} );\n\n\t\t\t\t// Bail out updates if the updated widgets are the same.\n\t\t\t\tif ( isShallowEqual( sidebar.getWidgets(), nextWidgets ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\tconst addedWidgetIds = sidebar.setWidgets( nextWidgets );\n\n\t\t\t\treturn nextBlocks.reduce(\n\t\t\t\t\t( updatedNextBlocks, nextBlock, index ) => {\n\t\t\t\t\t\tconst addedWidgetId = addedWidgetIds[ index ];\n\n\t\t\t\t\t\tif ( addedWidgetId !== null ) {\n\t\t\t\t\t\t\t// Only create a new instance if necessary to prevent\n\t\t\t\t\t\t\t// the whole editor from re-rendering on every edit.\n\t\t\t\t\t\t\tif ( updatedNextBlocks === nextBlocks ) {\n\t\t\t\t\t\t\t\tupdatedNextBlocks = nextBlocks.slice();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tupdatedNextBlocks[ index ] = addWidgetIdToBlock(\n\t\t\t\t\t\t\t\tnextBlock,\n\t\t\t\t\t\t\t\taddedWidgetId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}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3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const SidebarControlsContext = createContext();
|
|
7
|
-
SidebarControlsContext.displayName = 'SidebarControlsContext';
|
|
8
|
-
export default function SidebarControls({
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useMemo, useContext } from "@wordpress/element";
|
|
3
|
+
const SidebarControlsContext = createContext();
|
|
4
|
+
SidebarControlsContext.displayName = "SidebarControlsContext";
|
|
5
|
+
function SidebarControls({
|
|
9
6
|
sidebarControls,
|
|
10
7
|
activeSidebarControl,
|
|
11
8
|
children
|
|
12
9
|
}) {
|
|
13
|
-
const context = useMemo(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
10
|
+
const context = useMemo(
|
|
11
|
+
() => ({
|
|
12
|
+
sidebarControls,
|
|
13
|
+
activeSidebarControl
|
|
14
|
+
}),
|
|
15
|
+
[sidebarControls, activeSidebarControl]
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ jsx(SidebarControlsContext.Provider, { value: context, children });
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
sidebarControls
|
|
25
|
-
} = useContext(SidebarControlsContext);
|
|
19
|
+
function useSidebarControls() {
|
|
20
|
+
const { sidebarControls } = useContext(SidebarControlsContext);
|
|
26
21
|
return sidebarControls;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
const {
|
|
30
|
-
activeSidebarControl
|
|
31
|
-
} = useContext(SidebarControlsContext);
|
|
23
|
+
function useActiveSidebarControl() {
|
|
24
|
+
const { activeSidebarControl } = useContext(SidebarControlsContext);
|
|
32
25
|
return activeSidebarControl;
|
|
33
26
|
}
|
|
34
|
-
|
|
27
|
+
export {
|
|
28
|
+
SidebarControlsContext,
|
|
29
|
+
SidebarControls as default,
|
|
30
|
+
useActiveSidebarControl,
|
|
31
|
+
useSidebarControls
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/sidebar-controls/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useMemo, useContext } from '@wordpress/element';\n\nexport const SidebarControlsContext = createContext();\nSidebarControlsContext.displayName = 'SidebarControlsContext';\n\nexport default function SidebarControls( {\n\tsidebarControls,\n\tactiveSidebarControl,\n\tchildren,\n} ) {\n\tconst context = useMemo(\n\t\t() => ( {\n\t\t\tsidebarControls,\n\t\t\tactiveSidebarControl,\n\t\t} ),\n\t\t[ sidebarControls, activeSidebarControl ]\n\t);\n\n\treturn (\n\t\t<SidebarControlsContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</SidebarControlsContext.Provider>\n\t);\n}\n\nexport function useSidebarControls() {\n\tconst { sidebarControls } = useContext( SidebarControlsContext );\n\n\treturn sidebarControls;\n}\n\nexport function useActiveSidebarControl() {\n\tconst { activeSidebarControl } = useContext( SidebarControlsContext );\n\n\treturn activeSidebarControl;\n}\n"],
|
|
5
|
+
"mappings": "AAsBE;AAnBF,SAAS,eAAe,SAAS,kBAAkB;AAE5C,MAAM,yBAAyB,cAAc;AACpD,uBAAuB,cAAc;AAEtB,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,UAAU;AAAA,IACf,OAAQ;AAAA,MACP;AAAA,MACA;AAAA,IACD;AAAA,IACA,CAAE,iBAAiB,oBAAqB;AAAA,EACzC;AAEA,SACC,oBAAC,uBAAuB,UAAvB,EAAgC,OAAQ,SACtC,UACH;AAEF;AAEO,SAAS,qBAAqB;AACpC,QAAM,EAAE,gBAAgB,IAAI,WAAY,sBAAuB;AAE/D,SAAO;AACR;AAEO,SAAS,0BAA0B;AACzC,QAAM,EAAE,qBAAqB,IAAI,WAAY,sBAAuB;AAEpE,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,60 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = useDispatch(preferencesStore);
|
|
15
|
-
const isEntirelyBlockWidgets = sidebar.getWidgets().every(widget => widget.id.startsWith('block-'));
|
|
16
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
17
|
-
className: "customize-widgets-welcome-guide",
|
|
18
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
19
|
-
className: "customize-widgets-welcome-guide__image__wrapper",
|
|
20
|
-
children: /*#__PURE__*/_jsxs("picture", {
|
|
21
|
-
children: [/*#__PURE__*/_jsx("source", {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { Button, ExternalLink } from "@wordpress/components";
|
|
4
|
+
import { useDispatch } from "@wordpress/data";
|
|
5
|
+
import { store as preferencesStore } from "@wordpress/preferences";
|
|
6
|
+
function WelcomeGuide({ sidebar }) {
|
|
7
|
+
const { toggle } = useDispatch(preferencesStore);
|
|
8
|
+
const isEntirelyBlockWidgets = sidebar.getWidgets().every((widget) => widget.id.startsWith("block-"));
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", { className: "customize-widgets-welcome-guide", children: [
|
|
10
|
+
/* @__PURE__ */ jsx("div", { className: "customize-widgets-welcome-guide__image__wrapper", children: /* @__PURE__ */ jsxs("picture", { children: [
|
|
11
|
+
/* @__PURE__ */ jsx(
|
|
12
|
+
"source",
|
|
13
|
+
{
|
|
22
14
|
srcSet: "https://s.w.org/images/block-editor/welcome-editor.svg",
|
|
23
15
|
media: "(prefers-reduced-motion: reduce)"
|
|
24
|
-
}
|
|
16
|
+
}
|
|
17
|
+
),
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
"img",
|
|
20
|
+
{
|
|
25
21
|
className: "customize-widgets-welcome-guide__image",
|
|
26
22
|
src: "https://s.w.org/images/block-editor/welcome-editor.gif",
|
|
27
23
|
width: "312",
|
|
28
24
|
height: "240",
|
|
29
25
|
alt: ""
|
|
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
|
-
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
] }) }),
|
|
29
|
+
/* @__PURE__ */ jsx("h1", { className: "customize-widgets-welcome-guide__heading", children: __("Welcome to block Widgets") }),
|
|
30
|
+
/* @__PURE__ */ jsx("p", { className: "customize-widgets-welcome-guide__text", children: isEntirelyBlockWidgets ? __(
|
|
31
|
+
"Your theme provides different \u201Cblock\u201D areas for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site."
|
|
32
|
+
) : __(
|
|
33
|
+
"You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly."
|
|
34
|
+
) }),
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
Button,
|
|
37
|
+
{
|
|
38
|
+
size: "compact",
|
|
39
|
+
variant: "primary",
|
|
40
|
+
onClick: () => toggle("core/customize-widgets", "welcomeGuide"),
|
|
41
|
+
children: __("Got it")
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ jsx("hr", { className: "customize-widgets-welcome-guide__separator" }),
|
|
45
|
+
!isEntirelyBlockWidgets && /* @__PURE__ */ jsxs("p", { className: "customize-widgets-welcome-guide__more-info", children: [
|
|
46
|
+
__("Want to stick with the old widgets?"),
|
|
47
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
49
|
+
ExternalLink,
|
|
50
|
+
{
|
|
51
|
+
href: __(
|
|
52
|
+
"https://wordpress.org/plugins/classic-widgets/"
|
|
53
|
+
),
|
|
54
|
+
children: __("Get the Classic Widgets plugin.")
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] }),
|
|
58
|
+
/* @__PURE__ */ jsxs("p", { className: "customize-widgets-welcome-guide__more-info", children: [
|
|
59
|
+
__("New to the block editor?"),
|
|
60
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
ExternalLink,
|
|
63
|
+
{
|
|
64
|
+
href: __(
|
|
65
|
+
"https://wordpress.org/documentation/article/wordpress-block-editor/"
|
|
66
|
+
),
|
|
67
|
+
children: __("Here's a detailed guide.")
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] })
|
|
71
|
+
] });
|
|
59
72
|
}
|
|
60
|
-
|
|
73
|
+
export {
|
|
74
|
+
WelcomeGuide as default
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/welcome-guide/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button, ExternalLink } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nexport default function WelcomeGuide( { sidebar } ) {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst isEntirelyBlockWidgets = sidebar\n\t\t.getWidgets()\n\t\t.every( ( widget ) => widget.id.startsWith( 'block-' ) );\n\n\treturn (\n\t\t<div className=\"customize-widgets-welcome-guide\">\n\t\t\t<div className=\"customize-widgets-welcome-guide__image__wrapper\">\n\t\t\t\t<picture>\n\t\t\t\t\t<source\n\t\t\t\t\t\tsrcSet=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t\t\t/>\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"customize-widgets-welcome-guide__image\"\n\t\t\t\t\t\tsrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\twidth=\"312\"\n\t\t\t\t\t\theight=\"240\"\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t/>\n\t\t\t\t</picture>\n\t\t\t</div>\n\t\t\t<h1 className=\"customize-widgets-welcome-guide__heading\">\n\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t</h1>\n\t\t\t<p className=\"customize-widgets-welcome-guide__text\">\n\t\t\t\t{ isEntirelyBlockWidgets\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Your theme provides different \u201Cblock\u201D areas for you to add and edit content.\u00A0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site.'\n\t\t\t\t\t )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t ) }\n\t\t\t</p>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () =>\n\t\t\t\t\ttoggle( 'core/customize-widgets', 'welcomeGuide' )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ __( 'Got it' ) }\n\t\t\t</Button>\n\t\t\t<hr className=\"customize-widgets-welcome-guide__separator\" />\n\t\t\t{ ! isEntirelyBlockWidgets && (\n\t\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t\t{ __( 'Want to stick with the old widgets?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Get the Classic Widgets plugin.' ) }\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t{ __( 'New to the block editor?' ) }\n\t\t\t\t<br />\n\t\t\t\t<ExternalLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( \"Here's a detailed guide.\" ) }\n\t\t\t\t</ExternalLink>\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAkBI,SACC,KADD;AAfJ,SAAS,UAAU;AACnB,SAAS,QAAQ,oBAAoB;AACrC,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAE3B,SAAR,aAA+B,EAAE,QAAQ,GAAI;AACnD,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AAEjD,QAAM,yBAAyB,QAC7B,WAAW,EACX,MAAO,CAAE,WAAY,OAAO,GAAG,WAAY,QAAS,CAAE;AAExD,SACC,qBAAC,SAAI,WAAU,mCACd;AAAA,wBAAC,SAAI,WAAU,mDACd,+BAAC,aACA;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,QAAO;AAAA,UACP,OAAM;AAAA;AAAA,MACP;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,KAAI;AAAA,UACJ,OAAM;AAAA,UACN,QAAO;AAAA,UACP,KAAI;AAAA;AAAA,MACL;AAAA,OACD,GACD;AAAA,IACA,oBAAC,QAAG,WAAU,4CACX,aAAI,0BAA2B,GAClC;AAAA,IACA,oBAAC,OAAE,WAAU,yCACV,mCACC;AAAA,MACA;AAAA,IACA,IACA;AAAA,MACA;AAAA,IACA,GACJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,SAAU,MACT,OAAQ,0BAA0B,cAAe;AAAA,QAGhD,aAAI,QAAS;AAAA;AAAA,IAChB;AAAA,IACA,oBAAC,QAAG,WAAU,8CAA6C;AAAA,IACzD,CAAE,0BACH,qBAAC,OAAE,WAAU,8CACV;AAAA,SAAI,qCAAsC;AAAA,MAC5C,oBAAC,QAAG;AAAA,MACJ;AAAA,QAAC;AAAA;AAAA,UACA,MAAO;AAAA,YACN;AAAA,UACD;AAAA,UAEE,aAAI,iCAAkC;AAAA;AAAA,MACzC;AAAA,OACD;AAAA,IAED,qBAAC,OAAE,WAAU,8CACV;AAAA,SAAI,0BAA2B;AAAA,MACjC,oBAAC,QAAG;AAAA,MACJ;AAAA,QAAC;AAAA;AAAA,UACA,MAAO;AAAA,YACN;AAAA,UACD;AAAA,UAEE,aAAI,0BAA2B;AAAA;AAAA,MAClC;AAAA,OACD;AAAA,KACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { dispatch } from '@wordpress/data';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { store as customizeWidgetsStore } from '../store';
|
|
12
|
-
export default function getInserterOuterSection() {
|
|
1
|
+
import { ESCAPE } from "@wordpress/keycodes";
|
|
2
|
+
import { focus } from "@wordpress/dom";
|
|
3
|
+
import { dispatch } from "@wordpress/data";
|
|
4
|
+
import { store as customizeWidgetsStore } from "../store";
|
|
5
|
+
function getInserterOuterSection() {
|
|
13
6
|
const {
|
|
14
|
-
wp: {
|
|
15
|
-
customize
|
|
16
|
-
}
|
|
7
|
+
wp: { customize }
|
|
17
8
|
} = window;
|
|
18
9
|
const OuterSection = customize.OuterSection;
|
|
19
|
-
// Override the OuterSection class to handle multiple outer sections.
|
|
20
|
-
// It closes all the other outer sections whenever one is opened.
|
|
21
|
-
// The result is that at most one outer section can be opened at the same time.
|
|
22
10
|
customize.OuterSection = class extends OuterSection {
|
|
23
11
|
onChangeExpanded(expanded, args) {
|
|
24
12
|
if (expanded) {
|
|
25
|
-
customize.section.each(section => {
|
|
26
|
-
if (section.params.type ===
|
|
13
|
+
customize.section.each((section) => {
|
|
14
|
+
if (section.params.type === "outer" && section.id !== this.id) {
|
|
27
15
|
if (section.expanded()) {
|
|
28
16
|
section.collapse();
|
|
29
17
|
}
|
|
@@ -33,37 +21,34 @@ export default function getInserterOuterSection() {
|
|
|
33
21
|
return super.onChangeExpanded(expanded, args);
|
|
34
22
|
}
|
|
35
23
|
};
|
|
36
|
-
// Handle constructor so that "params.type" can be correctly pointed to "outer".
|
|
37
24
|
customize.sectionConstructor.outer = customize.OuterSection;
|
|
38
25
|
return class InserterOuterSection extends customize.OuterSection {
|
|
39
26
|
constructor(...args) {
|
|
40
27
|
super(...args);
|
|
41
|
-
|
|
42
|
-
// This is necessary since we're creating a new class which is not identical to the original OuterSection.
|
|
43
|
-
// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
|
|
44
|
-
this.params.type = 'outer';
|
|
28
|
+
this.params.type = "outer";
|
|
45
29
|
this.activeElementBeforeExpanded = null;
|
|
46
30
|
const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
31
|
+
ownerWindow.addEventListener(
|
|
32
|
+
"keydown",
|
|
33
|
+
(event) => {
|
|
34
|
+
if (this.expanded() && (event.keyCode === ESCAPE || event.code === "Escape") && !event.defaultPrevented) {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
dispatch(customizeWidgetsStore).setIsInserterOpened(
|
|
38
|
+
false
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
// Use capture mode to make this run before other event listeners.
|
|
43
|
+
true
|
|
44
|
+
);
|
|
45
|
+
this.contentContainer.addClass("widgets-inserter");
|
|
62
46
|
this.isFromInternalAction = false;
|
|
63
47
|
this.expanded.bind(() => {
|
|
64
48
|
if (!this.isFromInternalAction) {
|
|
65
|
-
|
|
66
|
-
|
|
49
|
+
dispatch(customizeWidgetsStore).setIsInserterOpened(
|
|
50
|
+
this.expanded()
|
|
51
|
+
);
|
|
67
52
|
}
|
|
68
53
|
this.isFromInternalAction = false;
|
|
69
54
|
});
|
|
@@ -75,9 +60,6 @@ export default function getInserterOuterSection() {
|
|
|
75
60
|
this.isFromInternalAction = true;
|
|
76
61
|
this.expand({
|
|
77
62
|
completeCallback() {
|
|
78
|
-
// We have to do this in a "completeCallback" or else the elements will not yet be visible/tabbable.
|
|
79
|
-
// The first one should be the close button,
|
|
80
|
-
// we want to skip it and choose the second one instead, which is the search box.
|
|
81
63
|
const searchBox = focus.tabbable.find(contentContainer)[1];
|
|
82
64
|
if (searchBox) {
|
|
83
65
|
searchBox.focus();
|
|
@@ -93,13 +75,7 @@ export default function getInserterOuterSection() {
|
|
|
93
75
|
this.isFromInternalAction = true;
|
|
94
76
|
this.collapse({
|
|
95
77
|
completeCallback() {
|
|
96
|
-
// Return back the focus when closing the inserter.
|
|
97
|
-
// Only do this if the active element which triggers the action is inside the inserter,
|
|
98
|
-
// (the close button for instance). In that case the focus will be lost.
|
|
99
|
-
// Otherwise, we don't hijack the focus when the user is focusing on other elements
|
|
100
|
-
// (like the quick inserter).
|
|
101
78
|
if (contentContainer.contains(activeElement)) {
|
|
102
|
-
// Return back the focus when closing the inserter.
|
|
103
79
|
if (this.activeElementBeforeExpanded) {
|
|
104
80
|
this.activeElementBeforeExpanded.focus();
|
|
105
81
|
}
|
|
@@ -110,4 +86,7 @@ export default function getInserterOuterSection() {
|
|
|
110
86
|
}
|
|
111
87
|
};
|
|
112
88
|
}
|
|
113
|
-
|
|
89
|
+
export {
|
|
90
|
+
getInserterOuterSection as default
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=inserter-outer-section.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/controls/inserter-outer-section.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../store';\n\nexport default function getInserterOuterSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst OuterSection = customize.OuterSection;\n\t// Override the OuterSection class to handle multiple outer sections.\n\t// It closes all the other outer sections whenever one is opened.\n\t// The result is that at most one outer section can be opened at the same time.\n\tcustomize.OuterSection = class extends OuterSection {\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tif ( expanded ) {\n\t\t\t\tcustomize.section.each( ( section ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tsection.params.type === 'outer' &&\n\t\t\t\t\t\tsection.id !== this.id\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ( section.expanded() ) {\n\t\t\t\t\t\t\tsection.collapse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn super.onChangeExpanded( expanded, args );\n\t\t}\n\t};\n\t// Handle constructor so that \"params.type\" can be correctly pointed to \"outer\".\n\tcustomize.sectionConstructor.outer = customize.OuterSection;\n\n\treturn class InserterOuterSection extends customize.OuterSection {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\t// This is necessary since we're creating a new class which is not identical to the original OuterSection.\n\t\t\t// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436\n\t\t\tthis.params.type = 'outer';\n\n\t\t\tthis.activeElementBeforeExpanded = null;\n\n\t\t\tconst ownerWindow =\n\t\t\t\tthis.contentContainer[ 0 ].ownerDocument.defaultView;\n\n\t\t\t// Handle closing the inserter when pressing the Escape key.\n\t\t\townerWindow.addEventListener(\n\t\t\t\t'keydown',\n\t\t\t\t( event ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.expanded() &&\n\t\t\t\t\t\t( event.keyCode === ESCAPE ||\n\t\t\t\t\t\t\tevent.code === 'Escape' ) &&\n\t\t\t\t\t\t! event.defaultPrevented\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t// Use capture mode to make this run before other event listeners.\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tthis.contentContainer.addClass( 'widgets-inserter' );\n\n\t\t\t// Set a flag if the state is being changed from open() or close().\n\t\t\t// Don't propagate the event if it's an internal action to prevent infinite loop.\n\t\t\tthis.isFromInternalAction = false;\n\t\t\tthis.expanded.bind( () => {\n\t\t\t\tif ( ! this.isFromInternalAction ) {\n\t\t\t\t\t// Propagate the event to React to sync the state.\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tthis.expanded()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isFromInternalAction = false;\n\t\t\t} );\n\t\t}\n\t\topen() {\n\t\t\tif ( ! this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tthis.activeElementBeforeExpanded =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.expand( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// We have to do this in a \"completeCallback\" or else the elements will not yet be visible/tabbable.\n\t\t\t\t\t\t// The first one should be the close button,\n\t\t\t\t\t\t// we want to skip it and choose the second one instead, which is the search box.\n\t\t\t\t\t\tconst searchBox =\n\t\t\t\t\t\t\tfocus.tabbable.find( contentContainer )[ 1 ];\n\t\t\t\t\t\tif ( searchBox ) {\n\t\t\t\t\t\t\tsearchBox.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t\tclose() {\n\t\t\tif ( this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tconst activeElement =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.collapse( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t// Only do this if the active element which triggers the action is inside the inserter,\n\t\t\t\t\t\t// (the close button for instance). In that case the focus will be lost.\n\t\t\t\t\t\t// Otherwise, we don't hijack the focus when the user is focusing on other elements\n\t\t\t\t\t\t// (like the quick inserter).\n\t\t\t\t\t\tif ( contentContainer.contains( activeElement ) ) {\n\t\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t\tif ( this.activeElementBeforeExpanded ) {\n\t\t\t\t\t\t\t\tthis.activeElementBefor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