@wordpress/customize-widgets 5.57.0 → 6.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/components/block-appender/index.cjs +24 -41
- package/build/components/block-appender/index.cjs.map +1 -7
- package/build/components/block-inspector-button/index.cjs +24 -52
- package/build/components/block-inspector-button/index.cjs.map +1 -7
- package/build/components/customize-widgets/index.cjs +76 -95
- package/build/components/customize-widgets/index.cjs.map +1 -7
- package/build/components/customize-widgets/use-clear-selected-block.cjs +58 -67
- package/build/components/customize-widgets/use-clear-selected-block.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/focus-control/index.cjs +44 -84
- package/build/components/focus-control/index.cjs.map +1 -7
- package/build/components/focus-control/use-blocks-focus-control.cjs +28 -49
- package/build/components/focus-control/use-blocks-focus-control.cjs.map +1 -7
- package/build/components/header/index.cjs +84 -122
- package/build/components/header/index.cjs.map +1 -7
- package/build/components/inserter/index.cjs +43 -78
- package/build/components/inserter/index.cjs.map +1 -7
- package/build/components/inserter/use-inserter.cjs +22 -54
- package/build/components/inserter/use-inserter.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 +103 -165
- package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -76
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcuts/index.cjs +70 -100
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
- package/build/components/more-menu/index.cjs +103 -151
- package/build/components/more-menu/index.cjs.map +1 -7
- package/build/components/sidebar-block-editor/index.cjs +122 -155
- package/build/components/sidebar-block-editor/index.cjs.map +1 -7
- package/build/components/sidebar-block-editor/sidebar-adapter.cjs +207 -270
- package/build/components/sidebar-block-editor/sidebar-adapter.cjs.map +1 -7
- package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs +40 -50
- package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs.map +1 -7
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs +75 -110
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs.map +1 -7
- package/build/components/sidebar-controls/index.cjs +27 -53
- package/build/components/sidebar-controls/index.cjs.map +1 -7
- package/build/components/welcome-guide/index.cjs +70 -94
- package/build/components/welcome-guide/index.cjs.map +1 -7
- package/build/controls/inserter-outer-section.cjs +68 -110
- package/build/controls/inserter-outer-section.cjs.map +1 -7
- package/build/controls/inspector-section.cjs +57 -90
- package/build/controls/inspector-section.cjs.map +1 -7
- package/build/controls/sidebar-control.cjs +55 -69
- package/build/controls/sidebar-control.cjs.map +1 -7
- package/build/controls/sidebar-section.cjs +79 -103
- package/build/controls/sidebar-section.cjs.map +1 -7
- package/build/filters/index.cjs +8 -5
- package/build/filters/move-to-sidebar.cjs +62 -78
- package/build/filters/move-to-sidebar.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/filters/wide-widget-display.cjs +20 -20
- package/build/filters/wide-widget-display.cjs.map +1 -7
- package/build/index.cjs +84 -91
- 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 +49 -32
- 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 +49 -41
- package/build/store/index.cjs.map +1 -7
- package/build/store/reducer.cjs +20 -33
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/selectors.cjs +47 -38
- package/build/store/selectors.cjs.map +1 -7
- package/build/utils.cjs +81 -108
- package/build/utils.cjs.map +1 -7
- package/build-module/components/block-appender/index.mjs +18 -23
- package/build-module/components/block-appender/index.mjs.map +1 -7
- package/build-module/components/block-inspector-button/index.mjs +15 -28
- package/build-module/components/block-inspector-button/index.mjs.map +1 -7
- package/build-module/components/customize-widgets/index.mjs +46 -72
- package/build-module/components/customize-widgets/index.mjs.map +1 -7
- package/build-module/components/customize-widgets/use-clear-selected-block.mjs +52 -46
- package/build-module/components/customize-widgets/use-clear-selected-block.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/focus-control/index.mjs +37 -66
- package/build-module/components/focus-control/index.mjs.map +1 -7
- package/build-module/components/focus-control/use-blocks-focus-control.mjs +21 -27
- package/build-module/components/focus-control/use-blocks-focus-control.mjs.map +1 -7
- package/build-module/components/header/index.mjs +55 -92
- package/build-module/components/header/index.mjs.map +1 -7
- package/build-module/components/inserter/index.mjs +33 -53
- package/build-module/components/inserter/index.mjs.map +1 -7
- package/build-module/components/inserter/use-inserter.mjs +17 -34
- package/build-module/components/inserter/use-inserter.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 +75 -139
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -55
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcuts/index.mjs +62 -79
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
- package/build-module/components/more-menu/index.mjs +76 -128
- package/build-module/components/more-menu/index.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/index.mjs +86 -128
- package/build-module/components/sidebar-block-editor/index.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs +202 -250
- package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs +17 -25
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs +54 -86
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs.map +1 -7
- package/build-module/components/sidebar-controls/index.mjs +19 -27
- package/build-module/components/sidebar-controls/index.mjs.map +1 -7
- package/build-module/components/welcome-guide/index.mjs +62 -71
- package/build-module/components/welcome-guide/index.mjs.map +1 -7
- package/build-module/controls/inserter-outer-section.mjs +61 -88
- package/build-module/controls/inserter-outer-section.mjs.map +1 -7
- package/build-module/controls/inspector-section.mjs +52 -70
- package/build-module/controls/inspector-section.mjs.map +1 -7
- package/build-module/controls/sidebar-control.mjs +33 -45
- package/build-module/controls/sidebar-control.mjs.map +1 -7
- package/build-module/controls/sidebar-section.mjs +59 -80
- package/build-module/controls/sidebar-section.mjs.map +1 -7
- package/build-module/filters/index.mjs +0 -2
- package/build-module/filters/move-to-sidebar.mjs +52 -79
- package/build-module/filters/move-to-sidebar.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/filters/wide-widget-display.mjs +13 -18
- package/build-module/filters/wide-widget-display.mjs.map +1 -7
- package/build-module/index.mjs +53 -71
- 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 +44 -8
- 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 +15 -11
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +15 -13
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +41 -13
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/utils.mjs +74 -82
- package/build-module/utils.mjs.map +1 -7
- package/package.json +30 -31
- package/src/components/customize-widgets/index.jsx +5 -2
- package/src/components/customize-widgets/use-clear-selected-block.js +2 -1
- package/src/components/welcome-guide/index.jsx +6 -2
- package/CHANGELOG.md +0 -289
- package/build/filters/index.cjs.map +0 -7
- package/build-module/filters/index.mjs.map +0 -7
|
@@ -1,73 +1,55 @@
|
|
|
1
1
|
// packages/customize-widgets/src/controls/inspector-section.js
|
|
2
2
|
function getInspectorSection() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.expand({
|
|
53
|
-
allowMultiple: true
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
close() {
|
|
57
|
-
this.collapse({
|
|
58
|
-
allowMultiple: true
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
collapse(options) {
|
|
62
|
-
this.isOpen = false;
|
|
63
|
-
super.collapse(options);
|
|
64
|
-
}
|
|
65
|
-
triggerActiveCallbacks() {
|
|
66
|
-
this.active.callbacks.fireWith(this.active, [false, true]);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
3
|
+
const { wp: { customize } } = window;
|
|
4
|
+
return class InspectorSection extends customize.Section {
|
|
5
|
+
constructor(id, options) {
|
|
6
|
+
super(id, options);
|
|
7
|
+
this.parentSection = options.parentSection;
|
|
8
|
+
this.returnFocusWhenClose = null;
|
|
9
|
+
this._isOpen = false;
|
|
10
|
+
}
|
|
11
|
+
get isOpen() {
|
|
12
|
+
return this._isOpen;
|
|
13
|
+
}
|
|
14
|
+
set isOpen(value) {
|
|
15
|
+
this._isOpen = value;
|
|
16
|
+
this.triggerActiveCallbacks();
|
|
17
|
+
}
|
|
18
|
+
ready() {
|
|
19
|
+
this.contentContainer[0].classList.add("customize-widgets-layout__inspector");
|
|
20
|
+
}
|
|
21
|
+
isContextuallyActive() {
|
|
22
|
+
return this.isOpen;
|
|
23
|
+
}
|
|
24
|
+
onChangeExpanded(expanded, args) {
|
|
25
|
+
super.onChangeExpanded(expanded, args);
|
|
26
|
+
if (this.parentSection && !args.unchanged) {
|
|
27
|
+
if (expanded) this.parentSection.collapse({ manualTransition: true });
|
|
28
|
+
else this.parentSection.expand({
|
|
29
|
+
manualTransition: true,
|
|
30
|
+
completeCallback: () => {
|
|
31
|
+
if (this.returnFocusWhenClose && !this.contentContainer[0].contains(this.returnFocusWhenClose)) this.returnFocusWhenClose.focus();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
open({ returnFocusWhenClose } = {}) {
|
|
37
|
+
this.isOpen = true;
|
|
38
|
+
this.returnFocusWhenClose = returnFocusWhenClose;
|
|
39
|
+
this.expand({ allowMultiple: true });
|
|
40
|
+
}
|
|
41
|
+
close() {
|
|
42
|
+
this.collapse({ allowMultiple: true });
|
|
43
|
+
}
|
|
44
|
+
collapse(options) {
|
|
45
|
+
this.isOpen = false;
|
|
46
|
+
super.collapse(options);
|
|
47
|
+
}
|
|
48
|
+
triggerActiveCallbacks() {
|
|
49
|
+
this.active.callbacks.fireWith(this.active, [false, true]);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
69
52
|
}
|
|
70
|
-
export {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
//# sourceMappingURL=inspector-section.mjs.map
|
|
53
|
+
export { getInspectorSection as default };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=inspector-section.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/controls/inspector-section.js"],
|
|
4
|
-
"sourcesContent": ["export default function getInspectorSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class InspectorSection extends customize.Section {\n\t\tconstructor( id, options ) {\n\t\t\tsuper( id, options );\n\n\t\t\tthis.parentSection = options.parentSection;\n\n\t\t\tthis.returnFocusWhenClose = null;\n\t\t\tthis._isOpen = false;\n\t\t}\n\t\tget isOpen() {\n\t\t\treturn this._isOpen;\n\t\t}\n\t\tset isOpen( value ) {\n\t\t\tthis._isOpen = value;\n\t\t\tthis.triggerActiveCallbacks();\n\t\t}\n\t\tready() {\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets-layout__inspector'\n\t\t\t);\n\t\t}\n\t\tisContextuallyActive() {\n\t\t\treturn this.isOpen;\n\t\t}\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tsuper.onChangeExpanded( expanded, args );\n\n\t\t\tif ( this.parentSection && ! args.unchanged ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.parentSection.collapse( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tthis.parentSection.expand( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t\tcompleteCallback: () => {\n\t\t\t\t\t\t\t// Return focus after finishing the transition.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose &&\n\t\t\t\t\t\t\t\t! this.contentContainer[ 0 ].contains(\n\t\t\t\t\t\t\t\t\tthis.returnFocusWhenClose\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose.focus();\n\t\t\t\t\t\t\t}\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\topen( { returnFocusWhenClose } = {} ) {\n\t\t\tthis.isOpen = true;\n\t\t\tthis.returnFocusWhenClose = returnFocusWhenClose;\n\n\t\t\tthis.expand( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tclose() {\n\t\t\tthis.collapse( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tcollapse( options ) {\n\t\t\t// Overridden collapse() function. Mostly call the parent collapse(), but also\n\t\t\t// move our .isOpen to false.\n\t\t\t// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work\n\t\t\t// because the block settings sidebar is a layer \"on top of\" the G editor sidebar.\n\t\t\t//\n\t\t\t// For example, when closing the block settings sidebar, the G\n\t\t\t// editor sidebar would display, and onChangeExpanded in\n\t\t\t// inspector-section would run with expanded=true, but I want\n\t\t\t// isOpen to be false when the block settings is closed.\n\t\t\tthis.isOpen = false;\n\t\t\tsuper.collapse( options );\n\t\t}\n\t\ttriggerActiveCallbacks() {\n\t\t\t// Manually fire the callbacks associated with moving this.active\n\t\t\t// from false to true. \"active\" is always true for this section,\n\t\t\t// and \"isContextuallyActive\" reflects if the block settings\n\t\t\t// sidebar is currently visible, that is, it has replaced the main\n\t\t\t// Gutenberg view.\n\t\t\t// The WP customizer only checks \".isContextuallyActive()\" when\n\t\t\t// \".active\" changes values. But our \".active\" never changes value.\n\t\t\t// The WP customizer never foresaw a section being used a way we\n\t\t\t// fit the block settings sidebar into a section. By manually\n\t\t\t// triggering the \"this.active\" callbacks, we force the WP\n\t\t\t// customizer to query our .isContextuallyActive() function and\n\t\t\t// update its view of our status.\n\t\t\tthis.active.callbacks.fireWith( this.active, [ false, true ] );\n\t\t}\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";AAAe,SAAR,sBAAuC;AAC7C,QAAM;AAAA,IACL,IAAI,EAAE,UAAU;AAAA,EACjB,IAAI;AAEJ,SAAO,MAAM,yBAAyB,UAAU,QAAQ;AAAA,IACvD,YAAa,IAAI,SAAU;AAC1B,YAAO,IAAI,OAAQ;AAEnB,WAAK,gBAAgB,QAAQ;AAE7B,WAAK,uBAAuB;AAC5B,WAAK,UAAU;AAAA,IAChB;AAAA,IACA,IAAI,SAAS;AACZ,aAAO,KAAK;AAAA,IACb;AAAA,IACA,IAAI,OAAQ,OAAQ;AACnB,WAAK,UAAU;AACf,WAAK,uBAAuB;AAAA,IAC7B;AAAA,IACA,QAAQ;AACP,WAAK,iBAAkB,CAAE,EAAE,UAAU;AAAA,QACpC;AAAA,MACD;AAAA,IACD;AAAA,IACA,uBAAuB;AACtB,aAAO,KAAK;AAAA,IACb;AAAA,IACA,iBAAkB,UAAU,MAAO;AAClC,YAAM,iBAAkB,UAAU,IAAK;AAEvC,UAAK,KAAK,iBAAiB,CAAE,KAAK,WAAY;AAC7C,YAAK,UAAW;AACf,eAAK,cAAc,SAAU;AAAA,YAC5B,kBAAkB;AAAA,UACnB,CAAE;AAAA,QACH,OAAO;AACN,eAAK,cAAc,OAAQ;AAAA,YAC1B,kBAAkB;AAAA,YAClB,kBAAkB,MAAM;AAEvB,kBACC,KAAK,wBACL,CAAE,KAAK,iBAAkB,CAAE,EAAE;AAAA,gBAC5B,KAAK;AAAA,cACN,GACC;AACD,qBAAK,qBAAqB,MAAM;AAAA,cACjC;AAAA,YACD;AAAA,UACD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,IACD;AAAA,IACA,KAAM,EAAE,qBAAqB,IAAI,CAAC,GAAI;AACrC,WAAK,SAAS;AACd,WAAK,uBAAuB;AAE5B,WAAK,OAAQ;AAAA,QACZ,eAAe;AAAA,MAChB,CAAE;AAAA,IACH;AAAA,IACA,QAAQ;AACP,WAAK,SAAU;AAAA,QACd,eAAe;AAAA,MAChB,CAAE;AAAA,IACH;AAAA,IACA,SAAU,SAAU;AAUnB,WAAK,SAAS;AACd,YAAM,SAAU,OAAQ;AAAA,IACzB;AAAA,IACA,yBAAyB;AAaxB,WAAK,OAAO,UAAU,SAAU,KAAK,QAAQ,CAAE,OAAO,IAAK,CAAE;AAAA,IAC9D;AAAA,EACD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"inspector-section.mjs","names":[],"sources":["../../src/controls/inspector-section.js"],"sourcesContent":["export default function getInspectorSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class InspectorSection extends customize.Section {\n\t\tconstructor( id, options ) {\n\t\t\tsuper( id, options );\n\n\t\t\tthis.parentSection = options.parentSection;\n\n\t\t\tthis.returnFocusWhenClose = null;\n\t\t\tthis._isOpen = false;\n\t\t}\n\t\tget isOpen() {\n\t\t\treturn this._isOpen;\n\t\t}\n\t\tset isOpen( value ) {\n\t\t\tthis._isOpen = value;\n\t\t\tthis.triggerActiveCallbacks();\n\t\t}\n\t\tready() {\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets-layout__inspector'\n\t\t\t);\n\t\t}\n\t\tisContextuallyActive() {\n\t\t\treturn this.isOpen;\n\t\t}\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tsuper.onChangeExpanded( expanded, args );\n\n\t\t\tif ( this.parentSection && ! args.unchanged ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.parentSection.collapse( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tthis.parentSection.expand( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t\tcompleteCallback: () => {\n\t\t\t\t\t\t\t// Return focus after finishing the transition.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose &&\n\t\t\t\t\t\t\t\t! this.contentContainer[ 0 ].contains(\n\t\t\t\t\t\t\t\t\tthis.returnFocusWhenClose\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose.focus();\n\t\t\t\t\t\t\t}\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\topen( { returnFocusWhenClose } = {} ) {\n\t\t\tthis.isOpen = true;\n\t\t\tthis.returnFocusWhenClose = returnFocusWhenClose;\n\n\t\t\tthis.expand( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tclose() {\n\t\t\tthis.collapse( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tcollapse( options ) {\n\t\t\t// Overridden collapse() function. Mostly call the parent collapse(), but also\n\t\t\t// move our .isOpen to false.\n\t\t\t// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work\n\t\t\t// because the block settings sidebar is a layer \"on top of\" the G editor sidebar.\n\t\t\t//\n\t\t\t// For example, when closing the block settings sidebar, the G\n\t\t\t// editor sidebar would display, and onChangeExpanded in\n\t\t\t// inspector-section would run with expanded=true, but I want\n\t\t\t// isOpen to be false when the block settings is closed.\n\t\t\tthis.isOpen = false;\n\t\t\tsuper.collapse( options );\n\t\t}\n\t\ttriggerActiveCallbacks() {\n\t\t\t// Manually fire the callbacks associated with moving this.active\n\t\t\t// from false to true. \"active\" is always true for this section,\n\t\t\t// and \"isContextuallyActive\" reflects if the block settings\n\t\t\t// sidebar is currently visible, that is, it has replaced the main\n\t\t\t// Gutenberg view.\n\t\t\t// The WP customizer only checks \".isContextuallyActive()\" when\n\t\t\t// \".active\" changes values. But our \".active\" never changes value.\n\t\t\t// The WP customizer never foresaw a section being used a way we\n\t\t\t// fit the block settings sidebar into a section. By manually\n\t\t\t// triggering the \"this.active\" callbacks, we force the WP\n\t\t\t// customizer to query our .isContextuallyActive() function and\n\t\t\t// update its view of our status.\n\t\t\tthis.active.callbacks.fireWith( this.active, [ false, true ] );\n\t\t}\n\t};\n}\n"],"mappings":";AAAA,SAAwB,sBAAsB;CAC7C,MAAM,EACL,IAAI,EAAE,gBACH;CAEJ,OAAO,MAAM,yBAAyB,UAAU,QAAQ;EACvD,YAAa,IAAI,SAAU;GAC1B,MAAO,IAAI,OAAQ;GAEnB,KAAK,gBAAgB,QAAQ;GAE7B,KAAK,uBAAuB;GAC5B,KAAK,UAAU;EAChB;EACA,IAAI,SAAS;GACZ,OAAO,KAAK;EACb;EACA,IAAI,OAAQ,OAAQ;GACnB,KAAK,UAAU;GACf,KAAK,uBAAuB;EAC7B;EACA,QAAQ;GACP,KAAK,iBAAkB,EAAG,CAAC,UAAU,IACpC,qCACD;EACD;EACA,uBAAuB;GACtB,OAAO,KAAK;EACb;EACA,iBAAkB,UAAU,MAAO;GAClC,MAAM,iBAAkB,UAAU,IAAK;GAEvC,IAAK,KAAK,iBAAiB,CAAE,KAAK,WAAY;IAC7C,IAAK,UACJ,KAAK,cAAc,SAAU,EAC5B,kBAAkB,KACnB,CAAE;SAEF,KAAK,cAAc,OAAQ;KAC1B,kBAAkB;KAClB,wBAAwB;MAEvB,IACC,KAAK,wBACL,CAAE,KAAK,iBAAkB,EAAG,CAAC,SAC5B,KAAK,oBACN,GAEA,KAAK,qBAAqB,MAAM;KAElC;IACD,CAAE;GAEJ;EACD;EACA,KAAM,EAAE,yBAAyB,CAAC,GAAI;GACrC,KAAK,SAAS;GACd,KAAK,uBAAuB;GAE5B,KAAK,OAAQ,EACZ,eAAe,KAChB,CAAE;EACH;EACA,QAAQ;GACP,KAAK,SAAU,EACd,eAAe,KAChB,CAAE;EACH;EACA,SAAU,SAAU;GAUnB,KAAK,SAAS;GACd,MAAM,SAAU,OAAQ;EACzB;EACA,yBAAyB;GAaxB,KAAK,OAAO,UAAU,SAAU,KAAK,QAAQ,CAAE,OAAO,IAAK,CAAE;EAC9D;CACD;AACD"}
|
|
@@ -1,50 +1,38 @@
|
|
|
1
|
-
// packages/customize-widgets/src/controls/sidebar-control.js
|
|
2
1
|
import { dispatch } from "@wordpress/data";
|
|
3
2
|
import SidebarAdapter from "../components/sidebar-block-editor/sidebar-adapter.mjs";
|
|
4
3
|
import getInserterOuterSection from "./inserter-outer-section.mjs";
|
|
5
|
-
import { store
|
|
6
|
-
|
|
4
|
+
import { store } from "../store/index.mjs";
|
|
5
|
+
// packages/customize-widgets/src/controls/sidebar-control.js
|
|
6
|
+
const getInserterId = (controlId) => `widgets-inserter-${controlId}`;
|
|
7
7
|
function getSidebarControl() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!expanded) {
|
|
36
|
-
dispatch(customizeWidgetsStore).setIsInserterOpened(
|
|
37
|
-
false
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
this.subscribers.forEach(
|
|
41
|
-
(subscriber) => subscriber(expanded, args)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
8
|
+
const { wp: { customize } } = window;
|
|
9
|
+
return class SidebarControl extends customize.Control {
|
|
10
|
+
constructor(...args) {
|
|
11
|
+
super(...args);
|
|
12
|
+
this.subscribers = /* @__PURE__ */ new Set();
|
|
13
|
+
}
|
|
14
|
+
ready() {
|
|
15
|
+
const InserterOuterSection = getInserterOuterSection();
|
|
16
|
+
this.inserter = new InserterOuterSection(getInserterId(this.id), {});
|
|
17
|
+
customize.section.add(this.inserter);
|
|
18
|
+
this.sectionInstance = customize.section(this.section());
|
|
19
|
+
this.inspector = this.sectionInstance.inspector;
|
|
20
|
+
this.sidebarAdapter = new SidebarAdapter(this.setting, customize);
|
|
21
|
+
}
|
|
22
|
+
subscribe(callback) {
|
|
23
|
+
this.subscribers.add(callback);
|
|
24
|
+
return () => {
|
|
25
|
+
this.subscribers.delete(callback);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
onChangeSectionExpanded(expanded, args) {
|
|
29
|
+
if (!args.unchanged) {
|
|
30
|
+
if (!expanded) dispatch(store).setIsInserterOpened(false);
|
|
31
|
+
this.subscribers.forEach((subscriber) => subscriber(expanded, args));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
46
35
|
}
|
|
47
|
-
export {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=sidebar-control.mjs.map
|
|
36
|
+
export { getSidebarControl as default };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=sidebar-control.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/controls/sidebar-control.js"],
|
|
4
|
-
"sourcesContent": ["import { dispatch } from '@wordpress/data';\nimport SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';\nimport getInserterOuterSection from './inserter-outer-section';\nimport { store as customizeWidgetsStore } from '../store';\n\nconst getInserterId = ( controlId ) => `widgets-inserter-${ controlId }`;\n\nexport default function getSidebarControl() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class SidebarControl extends customize.Control {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\tthis.subscribers = new Set();\n\t\t}\n\n\t\tready() {\n\t\t\tconst InserterOuterSection = getInserterOuterSection();\n\t\t\tthis.inserter = new InserterOuterSection(\n\t\t\t\tgetInserterId( this.id ),\n\t\t\t\t{}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inserter );\n\n\t\t\tthis.sectionInstance = customize.section( this.section() );\n\n\t\t\tthis.inspector = this.sectionInstance.inspector;\n\n\t\t\tthis.sidebarAdapter = new SidebarAdapter( this.setting, customize );\n\t\t}\n\n\t\tsubscribe( callback ) {\n\t\t\tthis.subscribers.add( callback );\n\n\t\t\treturn () => {\n\t\t\t\tthis.subscribers.delete( callback );\n\t\t\t};\n\t\t}\n\n\t\tonChangeSectionExpanded( expanded, args ) {\n\t\t\tif ( ! args.unchanged ) {\n\t\t\t\t// Close the inserter when the section collapses.\n\t\t\t\tif ( ! expanded ) {\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.subscribers.forEach( ( subscriber ) =>\n\t\t\t\t\tsubscriber( expanded, args )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,gBAAgB;AACzB,OAAO,oBAAoB;AAC3B,OAAO,6BAA6B;AACpC,SAAS,SAAS,6BAA6B;AAE/C,IAAM,gBAAgB,CAAE,cAAe,oBAAqB,SAAU;AAEvD,SAAR,oBAAqC;AAC3C,QAAM;AAAA,IACL,IAAI,EAAE,UAAU;AAAA,EACjB,IAAI;AAEJ,SAAO,MAAM,uBAAuB,UAAU,QAAQ;AAAA,IACrD,eAAgB,MAAO;AACtB,YAAO,GAAG,IAAK;AAEf,WAAK,cAAc,oBAAI,IAAI;AAAA,IAC5B;AAAA,IAEA,QAAQ;AACP,YAAM,uBAAuB,wBAAwB;AACrD,WAAK,WAAW,IAAI;AAAA,QACnB,cAAe,KAAK,EAAG;AAAA,QACvB,CAAC;AAAA,MACF;AACA,gBAAU,QAAQ,IAAK,KAAK,QAAS;AAErC,WAAK,kBAAkB,UAAU,QAAS,KAAK,QAAQ,CAAE;AAEzD,WAAK,YAAY,KAAK,gBAAgB;AAEtC,WAAK,iBAAiB,IAAI,eAAgB,KAAK,SAAS,SAAU;AAAA,IACnE;AAAA,IAEA,UAAW,UAAW;AACrB,WAAK,YAAY,IAAK,QAAS;AAE/B,aAAO,MAAM;AACZ,aAAK,YAAY,OAAQ,QAAS;AAAA,MACnC;AAAA,IACD;AAAA,IAEA,wBAAyB,UAAU,MAAO;AACzC,UAAK,CAAE,KAAK,WAAY;AAEvB,YAAK,CAAE,UAAW;AACjB,mBAAU,qBAAsB,EAAE;AAAA,YACjC;AAAA,UACD;AAAA,QACD;AAEA,aAAK,YAAY;AAAA,UAAS,CAAE,eAC3B,WAAY,UAAU,IAAK;AAAA,QAC5B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"sidebar-control.mjs","names":["customizeWidgetsStore"],"sources":["../../src/controls/sidebar-control.js"],"sourcesContent":["import { dispatch } from '@wordpress/data';\nimport SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';\nimport getInserterOuterSection from './inserter-outer-section';\nimport { store as customizeWidgetsStore } from '../store';\n\nconst getInserterId = ( controlId ) => `widgets-inserter-${ controlId }`;\n\nexport default function getSidebarControl() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class SidebarControl extends customize.Control {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\tthis.subscribers = new Set();\n\t\t}\n\n\t\tready() {\n\t\t\tconst InserterOuterSection = getInserterOuterSection();\n\t\t\tthis.inserter = new InserterOuterSection(\n\t\t\t\tgetInserterId( this.id ),\n\t\t\t\t{}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inserter );\n\n\t\t\tthis.sectionInstance = customize.section( this.section() );\n\n\t\t\tthis.inspector = this.sectionInstance.inspector;\n\n\t\t\tthis.sidebarAdapter = new SidebarAdapter( this.setting, customize );\n\t\t}\n\n\t\tsubscribe( callback ) {\n\t\t\tthis.subscribers.add( callback );\n\n\t\t\treturn () => {\n\t\t\t\tthis.subscribers.delete( callback );\n\t\t\t};\n\t\t}\n\n\t\tonChangeSectionExpanded( expanded, args ) {\n\t\t\tif ( ! args.unchanged ) {\n\t\t\t\t// Close the inserter when the section collapses.\n\t\t\t\tif ( ! expanded ) {\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.subscribers.forEach( ( subscriber ) =>\n\t\t\t\t\tsubscriber( expanded, args )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n}\n"],"mappings":";;;;;AAKA,MAAM,iBAAkB,cAAe,oBAAqB;AAE5D,SAAwB,oBAAoB;CAC3C,MAAM,EACL,IAAI,EAAE,gBACH;CAEJ,OAAO,MAAM,uBAAuB,UAAU,QAAQ;EACrD,YAAa,GAAG,MAAO;GACtB,MAAO,GAAG,IAAK;GAEf,KAAK,8BAAc,IAAI,IAAI;EAC5B;EAEA,QAAQ;GACP,MAAM,uBAAuB,wBAAwB;GACrD,KAAK,WAAW,IAAI,qBACnB,cAAe,KAAK,EAAG,GACvB,CAAC,CACF;GACA,UAAU,QAAQ,IAAK,KAAK,QAAS;GAErC,KAAK,kBAAkB,UAAU,QAAS,KAAK,QAAQ,CAAE;GAEzD,KAAK,YAAY,KAAK,gBAAgB;GAEtC,KAAK,iBAAiB,IAAI,eAAgB,KAAK,SAAS,SAAU;EACnE;EAEA,UAAW,UAAW;GACrB,KAAK,YAAY,IAAK,QAAS;GAE/B,aAAa;IACZ,KAAK,YAAY,OAAQ,QAAS;GACnC;EACD;EAEA,wBAAyB,UAAU,MAAO;GACzC,IAAK,CAAE,KAAK,WAAY;IAEvB,IAAK,CAAE,UACN,SAAUA,KAAsB,CAAC,CAAC,oBACjC,KACD;IAGD,KAAK,YAAY,SAAW,eAC3B,WAAY,UAAU,IAAK,CAC5B;GACD;EACD;CACD;AACD"}
|
|
@@ -1,84 +1,63 @@
|
|
|
1
|
-
// packages/customize-widgets/src/controls/sidebar-section.js
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import getInspectorSection from "./inspector-section.mjs";
|
|
4
|
-
|
|
3
|
+
// packages/customize-widgets/src/controls/sidebar-section.js
|
|
4
|
+
const getInspectorSectionId = (sidebarId) => `widgets-inspector-${sidebarId}`;
|
|
5
5
|
function getSidebarSection() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.contentContainer.closest(".wp-full-overlay").addClass("section-open");
|
|
61
|
-
this.contentContainer.removeClass("open");
|
|
62
|
-
}
|
|
63
|
-
const handleTransitionEnd = () => {
|
|
64
|
-
this.contentContainer.removeClass("busy");
|
|
65
|
-
args.completeCallback();
|
|
66
|
-
};
|
|
67
|
-
if (isReducedMotion) {
|
|
68
|
-
handleTransitionEnd();
|
|
69
|
-
} else {
|
|
70
|
-
this.contentContainer.one(
|
|
71
|
-
"transitionend",
|
|
72
|
-
handleTransitionEnd
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
super.onChangeExpanded(expanded, args);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
6
|
+
const { wp: { customize } } = window;
|
|
7
|
+
const reduceMotionMediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
8
|
+
let isReducedMotion = reduceMotionMediaQuery.matches;
|
|
9
|
+
reduceMotionMediaQuery.addEventListener("change", (event) => {
|
|
10
|
+
isReducedMotion = event.matches;
|
|
11
|
+
});
|
|
12
|
+
return class SidebarSection extends customize.Section {
|
|
13
|
+
ready() {
|
|
14
|
+
const InspectorSection = getInspectorSection();
|
|
15
|
+
this.inspector = new InspectorSection(getInspectorSectionId(this.id), {
|
|
16
|
+
title: __("Block Settings"),
|
|
17
|
+
parentSection: this,
|
|
18
|
+
customizeAction: [
|
|
19
|
+
__("Customizing"),
|
|
20
|
+
__("Widgets"),
|
|
21
|
+
this.params.title
|
|
22
|
+
].join(" ▸ ")
|
|
23
|
+
});
|
|
24
|
+
customize.section.add(this.inspector);
|
|
25
|
+
this.contentContainer[0].classList.add("customize-widgets__sidebar-section");
|
|
26
|
+
}
|
|
27
|
+
hasSubSectionOpened() {
|
|
28
|
+
return this.inspector.expanded();
|
|
29
|
+
}
|
|
30
|
+
onChangeExpanded(expanded, _args) {
|
|
31
|
+
const controls = this.controls();
|
|
32
|
+
const args = {
|
|
33
|
+
..._args,
|
|
34
|
+
completeCallback() {
|
|
35
|
+
controls.forEach((control) => {
|
|
36
|
+
control.onChangeSectionExpanded?.(expanded, args);
|
|
37
|
+
});
|
|
38
|
+
_args.completeCallback?.();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (args.manualTransition) {
|
|
42
|
+
if (expanded) {
|
|
43
|
+
this.contentContainer.addClass(["busy", "open"]);
|
|
44
|
+
this.contentContainer.removeClass("is-sub-section-open");
|
|
45
|
+
this.contentContainer.closest(".wp-full-overlay").addClass("section-open");
|
|
46
|
+
} else {
|
|
47
|
+
this.contentContainer.addClass(["busy", "is-sub-section-open"]);
|
|
48
|
+
this.contentContainer.closest(".wp-full-overlay").addClass("section-open");
|
|
49
|
+
this.contentContainer.removeClass("open");
|
|
50
|
+
}
|
|
51
|
+
const handleTransitionEnd = () => {
|
|
52
|
+
this.contentContainer.removeClass("busy");
|
|
53
|
+
args.completeCallback();
|
|
54
|
+
};
|
|
55
|
+
if (isReducedMotion) handleTransitionEnd();
|
|
56
|
+
else this.contentContainer.one("transitionend", handleTransitionEnd);
|
|
57
|
+
} else super.onChangeExpanded(expanded, args);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
80
60
|
}
|
|
81
|
-
export {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=sidebar-section.mjs.map
|
|
61
|
+
export { getSidebarSection as default };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=sidebar-section.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/controls/sidebar-section.js"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport getInspectorSection from './inspector-section';\n\nconst getInspectorSectionId = ( sidebarId ) =>\n\t`widgets-inspector-${ sidebarId }`;\n\nexport default function getSidebarSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst reduceMotionMediaQuery = window.matchMedia(\n\t\t'(prefers-reduced-motion: reduce)'\n\t);\n\tlet isReducedMotion = reduceMotionMediaQuery.matches;\n\treduceMotionMediaQuery.addEventListener( 'change', ( event ) => {\n\t\tisReducedMotion = event.matches;\n\t} );\n\n\treturn class SidebarSection extends customize.Section {\n\t\tready() {\n\t\t\tconst InspectorSection = getInspectorSection();\n\t\t\tthis.inspector = new InspectorSection(\n\t\t\t\tgetInspectorSectionId( this.id ),\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Block Settings' ),\n\t\t\t\t\tparentSection: this,\n\t\t\t\t\tcustomizeAction: [\n\t\t\t\t\t\t__( 'Customizing' ),\n\t\t\t\t\t\t__( 'Widgets' ),\n\t\t\t\t\t\tthis.params.title,\n\t\t\t\t\t].join( ' ▸ ' ),\n\t\t\t\t}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inspector );\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets__sidebar-section'\n\t\t\t);\n\t\t}\n\t\thasSubSectionOpened() {\n\t\t\treturn this.inspector.expanded();\n\t\t}\n\t\tonChangeExpanded( expanded, _args ) {\n\t\t\tconst controls = this.controls();\n\t\t\tconst args = {\n\t\t\t\t..._args,\n\t\t\t\tcompleteCallback() {\n\t\t\t\t\tcontrols.forEach( ( control ) => {\n\t\t\t\t\t\tcontrol.onChangeSectionExpanded?.( expanded, args );\n\t\t\t\t\t} );\n\t\t\t\t\t_args.completeCallback?.();\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tif ( args.manualTransition ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.contentContainer.addClass( [ 'busy', 'open' ] );\n\t\t\t\t\tthis.contentContainer.removeClass( 'is-sub-section-open' );\n\t\t\t\t\tthis.contentContainer\n\t\t\t\t\t\t.closest( '.wp-full-overlay' )\n\t\t\t\t\t\t.addClass( 'section-open' );\n\t\t\t\t} else {\n\t\t\t\t\tthis.contentContainer.addClass( [\n\t\t\t\t\t\t'busy',\n\t\t\t\t\t\t'is-sub-section-open',\n\t\t\t\t\t] );\n\t\t\t\t\tthis.contentContainer\n\t\t\t\t\t\t.closest( '.wp-full-overlay' )\n\t\t\t\t\t\t.addClass( 'section-open' );\n\t\t\t\t\tthis.contentContainer.removeClass( 'open' );\n\t\t\t\t}\n\n\t\t\t\tconst handleTransitionEnd = () => {\n\t\t\t\t\tthis.contentContainer.removeClass( 'busy' );\n\t\t\t\t\targs.completeCallback();\n\t\t\t\t};\n\n\t\t\t\tif ( isReducedMotion ) {\n\t\t\t\t\thandleTransitionEnd();\n\t\t\t\t} else {\n\t\t\t\t\tthis.contentContainer.one(\n\t\t\t\t\t\t'transitionend',\n\t\t\t\t\t\thandleTransitionEnd\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.onChangeExpanded( expanded, args );\n\t\t\t}\n\t\t}\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AACnB,OAAO,yBAAyB;AAEhC,IAAM,wBAAwB,CAAE,cAC/B,qBAAsB,SAAU;AAElB,SAAR,oBAAqC;AAC3C,QAAM;AAAA,IACL,IAAI,EAAE,UAAU;AAAA,EACjB,IAAI;AAEJ,QAAM,yBAAyB,OAAO;AAAA,IACrC;AAAA,EACD;AACA,MAAI,kBAAkB,uBAAuB;AAC7C,yBAAuB,iBAAkB,UAAU,CAAE,UAAW;AAC/D,sBAAkB,MAAM;AAAA,EACzB,CAAE;AAEF,SAAO,MAAM,uBAAuB,UAAU,QAAQ;AAAA,IACrD,QAAQ;AACP,YAAM,mBAAmB,oBAAoB;AAC7C,WAAK,YAAY,IAAI;AAAA,QACpB,sBAAuB,KAAK,EAAG;AAAA,QAC/B;AAAA,UACC,OAAO,GAAI,gBAAiB;AAAA,UAC5B,eAAe;AAAA,UACf,iBAAiB;AAAA,YAChB,GAAI,aAAc;AAAA,YAClB,GAAI,SAAU;AAAA,YACd,KAAK,OAAO;AAAA,UACb,EAAE,KAAM,KAAM;AAAA,QACf;AAAA,MACD;AACA,gBAAU,QAAQ,IAAK,KAAK,SAAU;AACtC,WAAK,iBAAkB,CAAE,EAAE,UAAU;AAAA,QACpC;AAAA,MACD;AAAA,IACD;AAAA,IACA,sBAAsB;AACrB,aAAO,KAAK,UAAU,SAAS;AAAA,IAChC;AAAA,IACA,iBAAkB,UAAU,OAAQ;AACnC,YAAM,WAAW,KAAK,SAAS;AAC/B,YAAM,OAAO;AAAA,QACZ,GAAG;AAAA,QACH,mBAAmB;AAClB,mBAAS,QAAS,CAAE,YAAa;AAChC,oBAAQ,0BAA2B,UAAU,IAAK;AAAA,UACnD,CAAE;AACF,gBAAM,mBAAmB;AAAA,QAC1B;AAAA,MACD;AAEA,UAAK,KAAK,kBAAmB;AAC5B,YAAK,UAAW;AACf,eAAK,iBAAiB,SAAU,CAAE,QAAQ,MAAO,CAAE;AACnD,eAAK,iBAAiB,YAAa,qBAAsB;AACzD,eAAK,iBACH,QAAS,kBAAmB,EAC5B,SAAU,cAAe;AAAA,QAC5B,OAAO;AACN,eAAK,iBAAiB,SAAU;AAAA,YAC/B;AAAA,YACA;AAAA,UACD,CAAE;AACF,eAAK,iBACH,QAAS,kBAAmB,EAC5B,SAAU,cAAe;AAC3B,eAAK,iBAAiB,YAAa,MAAO;AAAA,QAC3C;AAEA,cAAM,sBAAsB,MAAM;AACjC,eAAK,iBAAiB,YAAa,MAAO;AAC1C,eAAK,iBAAiB;AAAA,QACvB;AAEA,YAAK,iBAAkB;AACtB,8BAAoB;AAAA,QACrB,OAAO;AACN,eAAK,iBAAiB;AAAA,YACrB;AAAA,YACA;AAAA,UACD;AAAA,QACD;AAAA,MACD,OAAO;AACN,cAAM,iBAAkB,UAAU,IAAK;AAAA,MACxC;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"sidebar-section.mjs","names":[],"sources":["../../src/controls/sidebar-section.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport getInspectorSection from './inspector-section';\n\nconst getInspectorSectionId = ( sidebarId ) =>\n\t`widgets-inspector-${ sidebarId }`;\n\nexport default function getSidebarSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst reduceMotionMediaQuery = window.matchMedia(\n\t\t'(prefers-reduced-motion: reduce)'\n\t);\n\tlet isReducedMotion = reduceMotionMediaQuery.matches;\n\treduceMotionMediaQuery.addEventListener( 'change', ( event ) => {\n\t\tisReducedMotion = event.matches;\n\t} );\n\n\treturn class SidebarSection extends customize.Section {\n\t\tready() {\n\t\t\tconst InspectorSection = getInspectorSection();\n\t\t\tthis.inspector = new InspectorSection(\n\t\t\t\tgetInspectorSectionId( this.id ),\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Block Settings' ),\n\t\t\t\t\tparentSection: this,\n\t\t\t\t\tcustomizeAction: [\n\t\t\t\t\t\t__( 'Customizing' ),\n\t\t\t\t\t\t__( 'Widgets' ),\n\t\t\t\t\t\tthis.params.title,\n\t\t\t\t\t].join( ' ▸ ' ),\n\t\t\t\t}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inspector );\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets__sidebar-section'\n\t\t\t);\n\t\t}\n\t\thasSubSectionOpened() {\n\t\t\treturn this.inspector.expanded();\n\t\t}\n\t\tonChangeExpanded( expanded, _args ) {\n\t\t\tconst controls = this.controls();\n\t\t\tconst args = {\n\t\t\t\t..._args,\n\t\t\t\tcompleteCallback() {\n\t\t\t\t\tcontrols.forEach( ( control ) => {\n\t\t\t\t\t\tcontrol.onChangeSectionExpanded?.( expanded, args );\n\t\t\t\t\t} );\n\t\t\t\t\t_args.completeCallback?.();\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tif ( args.manualTransition ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.contentContainer.addClass( [ 'busy', 'open' ] );\n\t\t\t\t\tthis.contentContainer.removeClass( 'is-sub-section-open' );\n\t\t\t\t\tthis.contentContainer\n\t\t\t\t\t\t.closest( '.wp-full-overlay' )\n\t\t\t\t\t\t.addClass( 'section-open' );\n\t\t\t\t} else {\n\t\t\t\t\tthis.contentContainer.addClass( [\n\t\t\t\t\t\t'busy',\n\t\t\t\t\t\t'is-sub-section-open',\n\t\t\t\t\t] );\n\t\t\t\t\tthis.contentContainer\n\t\t\t\t\t\t.closest( '.wp-full-overlay' )\n\t\t\t\t\t\t.addClass( 'section-open' );\n\t\t\t\t\tthis.contentContainer.removeClass( 'open' );\n\t\t\t\t}\n\n\t\t\t\tconst handleTransitionEnd = () => {\n\t\t\t\t\tthis.contentContainer.removeClass( 'busy' );\n\t\t\t\t\targs.completeCallback();\n\t\t\t\t};\n\n\t\t\t\tif ( isReducedMotion ) {\n\t\t\t\t\thandleTransitionEnd();\n\t\t\t\t} else {\n\t\t\t\t\tthis.contentContainer.one(\n\t\t\t\t\t\t'transitionend',\n\t\t\t\t\t\thandleTransitionEnd\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.onChangeExpanded( expanded, args );\n\t\t\t}\n\t\t}\n\t};\n}\n"],"mappings":";;;AAGA,MAAM,yBAA0B,cAC/B,qBAAsB;AAEvB,SAAwB,oBAAoB;CAC3C,MAAM,EACL,IAAI,EAAE,gBACH;CAEJ,MAAM,yBAAyB,OAAO,WACrC,kCACD;CACA,IAAI,kBAAkB,uBAAuB;CAC7C,uBAAuB,iBAAkB,WAAY,UAAW;EAC/D,kBAAkB,MAAM;CACzB,CAAE;CAEF,OAAO,MAAM,uBAAuB,UAAU,QAAQ;EACrD,QAAQ;GACP,MAAM,mBAAmB,oBAAoB;GAC7C,KAAK,YAAY,IAAI,iBACpB,sBAAuB,KAAK,EAAG,GAC/B;IACC,OAAO,GAAI,gBAAiB;IAC5B,eAAe;IACf,iBAAiB;KAChB,GAAI,aAAc;KAClB,GAAI,SAAU;KACd,KAAK,OAAO;IACb,CAAC,CAAC,KAAM,KAAM;GACf,CACD;GACA,UAAU,QAAQ,IAAK,KAAK,SAAU;GACtC,KAAK,iBAAkB,EAAG,CAAC,UAAU,IACpC,oCACD;EACD;EACA,sBAAsB;GACrB,OAAO,KAAK,UAAU,SAAS;EAChC;EACA,iBAAkB,UAAU,OAAQ;GACnC,MAAM,WAAW,KAAK,SAAS;GAC/B,MAAM,OAAO;IACZ,GAAG;IACH,mBAAmB;KAClB,SAAS,SAAW,YAAa;MAChC,QAAQ,0BAA2B,UAAU,IAAK;KACnD,CAAE;KACF,MAAM,mBAAmB;IAC1B;GACD;GAEA,IAAK,KAAK,kBAAmB;IAC5B,IAAK,UAAW;KACf,KAAK,iBAAiB,SAAU,CAAE,QAAQ,MAAO,CAAE;KACnD,KAAK,iBAAiB,YAAa,qBAAsB;KACzD,KAAK,iBACH,QAAS,kBAAmB,CAAC,CAC7B,SAAU,cAAe;IAC5B,OAAO;KACN,KAAK,iBAAiB,SAAU,CAC/B,QACA,qBACD,CAAE;KACF,KAAK,iBACH,QAAS,kBAAmB,CAAC,CAC7B,SAAU,cAAe;KAC3B,KAAK,iBAAiB,YAAa,MAAO;IAC3C;IAEA,MAAM,4BAA4B;KACjC,KAAK,iBAAiB,YAAa,MAAO;KAC1C,KAAK,iBAAiB;IACvB;IAEA,IAAK,iBACJ,oBAAoB;SAEpB,KAAK,iBAAiB,IACrB,iBACA,mBACD;GAEF,OACC,MAAM,iBAAkB,UAAU,IAAK;EAEzC;CACD;AACD"}
|
|
@@ -1,85 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
BlockControls,
|
|
4
|
-
store as blockEditorStore
|
|
5
|
-
} from "@wordpress/block-editor";
|
|
1
|
+
import { BlockControls, store } from "@wordpress/block-editor";
|
|
6
2
|
import { createHigherOrderComponent } from "@wordpress/compose";
|
|
7
|
-
import {
|
|
3
|
+
import { useDispatch, useSelect } from "@wordpress/data";
|
|
8
4
|
import { addFilter } from "@wordpress/hooks";
|
|
9
5
|
import { MoveToWidgetArea, getWidgetIdFromBlock } from "@wordpress/widgets";
|
|
10
|
-
import {
|
|
11
|
-
useSidebarControls,
|
|
12
|
-
useActiveSidebarControl
|
|
13
|
-
} from "../components/sidebar-controls/index.mjs";
|
|
6
|
+
import { useActiveSidebarControl, useSidebarControls } from "../components/sidebar-controls/index.mjs";
|
|
14
7
|
import { useFocusControl } from "../components/focus-control/index.mjs";
|
|
15
8
|
import { blockToWidget } from "../utils.mjs";
|
|
16
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
(sidebarControl) => ({
|
|
67
|
-
id: sidebarControl.id,
|
|
68
|
-
name: sidebarControl.params.label,
|
|
69
|
-
description: sidebarControl.params.description
|
|
70
|
-
})
|
|
71
|
-
),
|
|
72
|
-
currentWidgetAreaId: activeSidebarControl?.id,
|
|
73
|
-
onSelect: moveToSidebar
|
|
74
|
-
}
|
|
75
|
-
) })
|
|
76
|
-
] });
|
|
77
|
-
},
|
|
78
|
-
"withMoveToSidebarToolbarItem"
|
|
79
|
-
);
|
|
80
|
-
addFilter(
|
|
81
|
-
"editor.BlockEdit",
|
|
82
|
-
"core/customize-widgets/block-edit",
|
|
83
|
-
withMoveToSidebarToolbarItem
|
|
84
|
-
);
|
|
85
|
-
//# sourceMappingURL=move-to-sidebar.mjs.map
|
|
10
|
+
// packages/customize-widgets/src/filters/move-to-sidebar.jsx
|
|
11
|
+
const withMoveToSidebarToolbarItem = createHigherOrderComponent((BlockEdit) => (props) => {
|
|
12
|
+
let widgetId = getWidgetIdFromBlock(props);
|
|
13
|
+
const sidebarControls = useSidebarControls();
|
|
14
|
+
const activeSidebarControl = useActiveSidebarControl();
|
|
15
|
+
const hasMultipleSidebars = sidebarControls?.length > 1;
|
|
16
|
+
const blockName = props.name;
|
|
17
|
+
const clientId = props.clientId;
|
|
18
|
+
const canInsertBlockInSidebar = useSelect((select) => {
|
|
19
|
+
return select(store).canInsertBlockType(blockName, "");
|
|
20
|
+
}, [blockName]);
|
|
21
|
+
const block = useSelect((select) => select(store).getBlock(clientId), [clientId]);
|
|
22
|
+
const { removeBlock } = useDispatch(store);
|
|
23
|
+
const [, focusWidget] = useFocusControl();
|
|
24
|
+
function moveToSidebar(sidebarControlId) {
|
|
25
|
+
const newSidebarControl = sidebarControls.find((sidebarControl) => sidebarControl.id === sidebarControlId);
|
|
26
|
+
if (widgetId) {
|
|
27
|
+
/**
|
|
28
|
+
* If there's a widgetId, move it to the other sidebar.
|
|
29
|
+
*/
|
|
30
|
+
const oldSetting = activeSidebarControl.setting;
|
|
31
|
+
const newSetting = newSidebarControl.setting;
|
|
32
|
+
oldSetting(oldSetting().filter((id) => id !== widgetId));
|
|
33
|
+
newSetting([...newSetting(), widgetId]);
|
|
34
|
+
} else {
|
|
35
|
+
/**
|
|
36
|
+
* If there isn't a widgetId, it's most likely a inner block.
|
|
37
|
+
* First, remove the block in the original sidebar,
|
|
38
|
+
* then, create a new widget in the new sidebar and get back its widgetId.
|
|
39
|
+
*/
|
|
40
|
+
const sidebarAdapter = newSidebarControl.sidebarAdapter;
|
|
41
|
+
removeBlock(clientId);
|
|
42
|
+
widgetId = sidebarAdapter.setWidgets([...sidebarAdapter.getWidgets(), blockToWidget(block)]).reverse().find((id) => !!id);
|
|
43
|
+
}
|
|
44
|
+
focusWidget(widgetId);
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(BlockEdit, { ...props }, "edit"), hasMultipleSidebars && canInsertBlockInSidebar && /* @__PURE__ */ jsx(BlockControls, { children: /* @__PURE__ */ jsx(MoveToWidgetArea, {
|
|
47
|
+
widgetAreas: sidebarControls.map((sidebarControl) => ({
|
|
48
|
+
id: sidebarControl.id,
|
|
49
|
+
name: sidebarControl.params.label,
|
|
50
|
+
description: sidebarControl.params.description
|
|
51
|
+
})),
|
|
52
|
+
currentWidgetAreaId: activeSidebarControl?.id,
|
|
53
|
+
onSelect: moveToSidebar
|
|
54
|
+
}) })] });
|
|
55
|
+
}, "withMoveToSidebarToolbarItem");
|
|
56
|
+
addFilter("editor.BlockEdit", "core/customize-widgets/block-edit", withMoveToSidebarToolbarItem);
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=move-to-sidebar.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/filters/move-to-sidebar.jsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { MoveToWidgetArea, getWidgetIdFromBlock } from '@wordpress/widgets';\nimport {\n\tuseSidebarControls,\n\tuseActiveSidebarControl,\n} from '../components/sidebar-controls';\nimport { useFocusControl } from '../components/focus-control';\nimport { blockToWidget } from '../utils';\n\nconst withMoveToSidebarToolbarItem = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tlet widgetId = getWidgetIdFromBlock( props );\n\t\tconst sidebarControls = useSidebarControls();\n\t\tconst activeSidebarControl = useActiveSidebarControl();\n\t\tconst hasMultipleSidebars = sidebarControls?.length > 1;\n\t\tconst blockName = props.name;\n\t\tconst clientId = props.clientId;\n\t\tconst canInsertBlockInSidebar = useSelect(\n\t\t\t( select ) => {\n\t\t\t\t// Use an empty string to represent the root block list, which\n\t\t\t\t// in the customizer editor represents a sidebar/widget area.\n\t\t\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\t\t\tblockName,\n\t\t\t\t\t''\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ blockName ]\n\t\t);\n\t\tconst block = useSelect(\n\t\t\t( select ) => select( blockEditorStore ).getBlock( clientId ),\n\t\t\t[ clientId ]\n\t\t);\n\t\tconst { removeBlock } = useDispatch( blockEditorStore );\n\t\tconst [ , focusWidget ] = useFocusControl();\n\n\t\tfunction moveToSidebar( sidebarControlId ) {\n\t\t\tconst newSidebarControl = sidebarControls.find(\n\t\t\t\t( sidebarControl ) => sidebarControl.id === sidebarControlId\n\t\t\t);\n\n\t\t\tif ( widgetId ) {\n\t\t\t\t/**\n\t\t\t\t * If there's a widgetId, move it to the other sidebar.\n\t\t\t\t */\n\t\t\t\tconst oldSetting = activeSidebarControl.setting;\n\t\t\t\tconst newSetting = newSidebarControl.setting;\n\n\t\t\t\toldSetting( oldSetting().filter( ( id ) => id !== widgetId ) );\n\t\t\t\tnewSetting( [ ...newSetting(), widgetId ] );\n\t\t\t} else {\n\t\t\t\t/**\n\t\t\t\t * If there isn't a widgetId, it's most likely a inner block.\n\t\t\t\t * First, remove the block in the original sidebar,\n\t\t\t\t * then, create a new widget in the new sidebar and get back its widgetId.\n\t\t\t\t */\n\t\t\t\tconst sidebarAdapter = newSidebarControl.sidebarAdapter;\n\n\t\t\t\tremoveBlock( clientId );\n\t\t\t\tconst addedWidgetIds = sidebarAdapter.setWidgets( [\n\t\t\t\t\t...sidebarAdapter.getWidgets(),\n\t\t\t\t\tblockToWidget( block ),\n\t\t\t\t] );\n\t\t\t\t// The last non-null id is the added widget's id.\n\t\t\t\twidgetId = addedWidgetIds.reverse().find( ( id ) => !! id );\n\t\t\t}\n\n\t\t\t// Move focus to the moved widget and expand the sidebar.\n\t\t\tfocusWidget( widgetId );\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t{ hasMultipleSidebars && canInsertBlockInSidebar && (\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<MoveToWidgetArea\n\t\t\t\t\t\t\twidgetAreas={ sidebarControls.map(\n\t\t\t\t\t\t\t\t( sidebarControl ) => ( {\n\t\t\t\t\t\t\t\t\tid: sidebarControl.id,\n\t\t\t\t\t\t\t\t\tname: sidebarControl.params.label,\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\tsidebarControl.params.description,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tcurrentWidgetAreaId={ activeSidebarControl?.id }\n\t\t\t\t\t\t\tonSelect={ moveToSidebar }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withMoveToSidebarToolbarItem'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/customize-widgets/block-edit',\n\twithMoveToSidebarToolbarItem\n);\n"],
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,kCAAkC;AAC3C,SAAS,WAAW,mBAAmB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB,4BAA4B;AACvD;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAgE3B,mBACC,KADD;AA9DH,IAAM,+BAA+B;AAAA,EACpC,CAAE,cAAe,CAAE,UAAW;AAC7B,QAAI,WAAW,qBAAsB,KAAM;AAC3C,UAAM,kBAAkB,mBAAmB;AAC3C,UAAM,uBAAuB,wBAAwB;AACrD,UAAM,sBAAsB,iBAAiB,SAAS;AACtD,UAAM,YAAY,MAAM;AACxB,UAAM,WAAW,MAAM;AACvB,UAAM,0BAA0B;AAAA,MAC/B,CAAE,WAAY;AAGb,eAAO,OAAQ,gBAAiB,EAAE;AAAA,UACjC;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,MACA,CAAE,SAAU;AAAA,IACb;AACA,UAAM,QAAQ;AAAA,MACb,CAAE,WAAY,OAAQ,gBAAiB,EAAE,SAAU,QAAS;AAAA,MAC5D,CAAE,QAAS;AAAA,IACZ;AACA,UAAM,EAAE,YAAY,IAAI,YAAa,gBAAiB;AACtD,UAAM,CAAE,EAAE,WAAY,IAAI,gBAAgB;AAE1C,aAAS,cAAe,kBAAmB;AAC1C,YAAM,oBAAoB,gBAAgB;AAAA,QACzC,CAAE,mBAAoB,eAAe,OAAO;AAAA,MAC7C;AAEA,UAAK,UAAW;AAIf,cAAM,aAAa,qBAAqB;AACxC,cAAM,aAAa,kBAAkB;AAErC,mBAAY,WAAW,EAAE,OAAQ,CAAE,OAAQ,OAAO,QAAS,CAAE;AAC7D,mBAAY,CAAE,GAAG,WAAW,GAAG,QAAS,CAAE;AAAA,MAC3C,OAAO;AAMN,cAAM,iBAAiB,kBAAkB;AAEzC,oBAAa,QAAS;AACtB,cAAM,iBAAiB,eAAe,WAAY;AAAA,UACjD,GAAG,eAAe,WAAW;AAAA,UAC7B,cAAe,KAAM;AAAA,QACtB,CAAE;AAEF,mBAAW,eAAe,QAAQ,EAAE,KAAM,CAAE,OAAQ,CAAC,CAAE,EAAG;AAAA,MAC3D;AAGA,kBAAa,QAAS;AAAA,IACvB;AAEA,WACC,iCACC;AAAA,0BAAC,aAAuB,GAAG,SAAZ,MAAoB;AAAA,MACjC,uBAAuB,2BACxB,oBAAC,iBACA;AAAA,QAAC;AAAA;AAAA,UACA,aAAc,gBAAgB;AAAA,YAC7B,CAAE,oBAAsB;AAAA,cACvB,IAAI,eAAe;AAAA,cACnB,MAAM,eAAe,OAAO;AAAA,cAC5B,aACC,eAAe,OAAO;AAAA,YACxB;AAAA,UACD;AAAA,UACA,qBAAsB,sBAAsB;AAAA,UAC5C,UAAW;AAAA;AAAA,MACZ,GACD;AAAA,OAEF;AAAA,EAEF;AAAA,EACA;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"move-to-sidebar.mjs","names":["blockEditorStore"],"sources":["../../src/filters/move-to-sidebar.jsx"],"sourcesContent":["import {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { MoveToWidgetArea, getWidgetIdFromBlock } from '@wordpress/widgets';\nimport {\n\tuseSidebarControls,\n\tuseActiveSidebarControl,\n} from '../components/sidebar-controls';\nimport { useFocusControl } from '../components/focus-control';\nimport { blockToWidget } from '../utils';\n\nconst withMoveToSidebarToolbarItem = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tlet widgetId = getWidgetIdFromBlock( props );\n\t\tconst sidebarControls = useSidebarControls();\n\t\tconst activeSidebarControl = useActiveSidebarControl();\n\t\tconst hasMultipleSidebars = sidebarControls?.length > 1;\n\t\tconst blockName = props.name;\n\t\tconst clientId = props.clientId;\n\t\tconst canInsertBlockInSidebar = useSelect(\n\t\t\t( select ) => {\n\t\t\t\t// Use an empty string to represent the root block list, which\n\t\t\t\t// in the customizer editor represents a sidebar/widget area.\n\t\t\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\t\t\tblockName,\n\t\t\t\t\t''\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ blockName ]\n\t\t);\n\t\tconst block = useSelect(\n\t\t\t( select ) => select( blockEditorStore ).getBlock( clientId ),\n\t\t\t[ clientId ]\n\t\t);\n\t\tconst { removeBlock } = useDispatch( blockEditorStore );\n\t\tconst [ , focusWidget ] = useFocusControl();\n\n\t\tfunction moveToSidebar( sidebarControlId ) {\n\t\t\tconst newSidebarControl = sidebarControls.find(\n\t\t\t\t( sidebarControl ) => sidebarControl.id === sidebarControlId\n\t\t\t);\n\n\t\t\tif ( widgetId ) {\n\t\t\t\t/**\n\t\t\t\t * If there's a widgetId, move it to the other sidebar.\n\t\t\t\t */\n\t\t\t\tconst oldSetting = activeSidebarControl.setting;\n\t\t\t\tconst newSetting = newSidebarControl.setting;\n\n\t\t\t\toldSetting( oldSetting().filter( ( id ) => id !== widgetId ) );\n\t\t\t\tnewSetting( [ ...newSetting(), widgetId ] );\n\t\t\t} else {\n\t\t\t\t/**\n\t\t\t\t * If there isn't a widgetId, it's most likely a inner block.\n\t\t\t\t * First, remove the block in the original sidebar,\n\t\t\t\t * then, create a new widget in the new sidebar and get back its widgetId.\n\t\t\t\t */\n\t\t\t\tconst sidebarAdapter = newSidebarControl.sidebarAdapter;\n\n\t\t\t\tremoveBlock( clientId );\n\t\t\t\tconst addedWidgetIds = sidebarAdapter.setWidgets( [\n\t\t\t\t\t...sidebarAdapter.getWidgets(),\n\t\t\t\t\tblockToWidget( block ),\n\t\t\t\t] );\n\t\t\t\t// The last non-null id is the added widget's id.\n\t\t\t\twidgetId = addedWidgetIds.reverse().find( ( id ) => !! id );\n\t\t\t}\n\n\t\t\t// Move focus to the moved widget and expand the sidebar.\n\t\t\tfocusWidget( widgetId );\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t{ hasMultipleSidebars && canInsertBlockInSidebar && (\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<MoveToWidgetArea\n\t\t\t\t\t\t\twidgetAreas={ sidebarControls.map(\n\t\t\t\t\t\t\t\t( sidebarControl ) => ( {\n\t\t\t\t\t\t\t\t\tid: sidebarControl.id,\n\t\t\t\t\t\t\t\t\tname: sidebarControl.params.label,\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\tsidebarControl.params.description,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tcurrentWidgetAreaId={ activeSidebarControl?.id }\n\t\t\t\t\t\t\tonSelect={ moveToSidebar }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withMoveToSidebarToolbarItem'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/customize-widgets/block-edit',\n\twithMoveToSidebarToolbarItem\n);\n"],"mappings":";;;;;;;;;;AAeA,MAAM,+BAA+B,4BAClC,eAAiB,UAAW;CAC7B,IAAI,WAAW,qBAAsB,KAAM;CAC3C,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,uBAAuB,wBAAwB;CACrD,MAAM,sBAAsB,iBAAiB,SAAS;CACtD,MAAM,YAAY,MAAM;CACxB,MAAM,WAAW,MAAM;CACvB,MAAM,0BAA0B,WAC7B,WAAY;EAGb,OAAO,OAAQA,KAAiB,CAAC,CAAC,mBACjC,WACA,EACD;CACD,GACA,CAAE,SAAU,CACb;CACA,MAAM,QAAQ,WACX,WAAY,OAAQA,KAAiB,CAAC,CAAC,SAAU,QAAS,GAC5D,CAAE,QAAS,CACZ;CACA,MAAM,EAAE,gBAAgB,YAAaA,KAAiB;CACtD,MAAM,GAAI,eAAgB,gBAAgB;CAE1C,SAAS,cAAe,kBAAmB;EAC1C,MAAM,oBAAoB,gBAAgB,MACvC,mBAAoB,eAAe,OAAO,gBAC7C;EAEA,IAAK,UAAW;;;;GAIf,MAAM,aAAa,qBAAqB;GACxC,MAAM,aAAa,kBAAkB;GAErC,WAAY,WAAW,CAAC,CAAC,QAAU,OAAQ,OAAO,QAAS,CAAE;GAC7D,WAAY,CAAE,GAAG,WAAW,GAAG,QAAS,CAAE;EAC3C,OAAO;;;;;;GAMN,MAAM,iBAAiB,kBAAkB;GAEzC,YAAa,QAAS;GAMtB,WALuB,eAAe,WAAY,CACjD,GAAG,eAAe,WAAW,GAC7B,cAAe,KAAM,CACtB,CAEwB,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAQ,OAAQ,CAAC,CAAE,EAAG;EAC3D;EAGA,YAAa,QAAS;CACvB;CAEA,OACC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,WAAD,EAAsB,GAAK,MAAS,GAArB,MAAqB,GAClC,uBAAuB,2BACxB,oBAAC,eAAD,EAAA,UACC,oBAAC,kBAAD;EACC,aAAc,gBAAgB,KAC3B,oBAAsB;GACvB,IAAI,eAAe;GACnB,MAAM,eAAe,OAAO;GAC5B,aACC,eAAe,OAAO;EACxB,EACD;EACA,qBAAsB,sBAAsB;EAC5C,UAAW;CACX,CAAA,EACa,CAAA,CAEf,EAAA,CAAA;AAEJ,GACA,8BACD;AAEA,UACC,oBACA,qCACA,4BACD"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
// packages/customize-widgets/src/filters/replace-media-upload.js
|
|
2
1
|
import { addFilter } from "@wordpress/hooks";
|
|
3
2
|
import { MediaUpload } from "@wordpress/media-utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
);
|
|
10
|
-
//# sourceMappingURL=replace-media-upload.mjs.map
|
|
3
|
+
// packages/customize-widgets/src/filters/replace-media-upload.js
|
|
4
|
+
const replaceMediaUpload = () => MediaUpload;
|
|
5
|
+
addFilter("editor.MediaUpload", "core/edit-widgets/replace-media-upload", replaceMediaUpload);
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=replace-media-upload.mjs.map
|