@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,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
function getInspectorSection() {
|
|
2
2
|
const {
|
|
3
|
-
wp: {
|
|
4
|
-
customize
|
|
5
|
-
}
|
|
3
|
+
wp: { customize }
|
|
6
4
|
} = window;
|
|
7
5
|
return class InspectorSection extends customize.Section {
|
|
8
6
|
constructor(id, options) {
|
|
@@ -19,7 +17,9 @@ export default function getInspectorSection() {
|
|
|
19
17
|
this.triggerActiveCallbacks();
|
|
20
18
|
}
|
|
21
19
|
ready() {
|
|
22
|
-
this.contentContainer[0].classList.add(
|
|
20
|
+
this.contentContainer[0].classList.add(
|
|
21
|
+
"customize-widgets-layout__inspector"
|
|
22
|
+
);
|
|
23
23
|
}
|
|
24
24
|
isContextuallyActive() {
|
|
25
25
|
return this.isOpen;
|
|
@@ -35,8 +35,9 @@ export default function getInspectorSection() {
|
|
|
35
35
|
this.parentSection.expand({
|
|
36
36
|
manualTransition: true,
|
|
37
37
|
completeCallback: () => {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (this.returnFocusWhenClose && !this.contentContainer[0].contains(
|
|
39
|
+
this.returnFocusWhenClose
|
|
40
|
+
)) {
|
|
40
41
|
this.returnFocusWhenClose.focus();
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -44,9 +45,7 @@ export default function getInspectorSection() {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
open({
|
|
48
|
-
returnFocusWhenClose
|
|
49
|
-
} = {}) {
|
|
48
|
+
open({ returnFocusWhenClose } = {}) {
|
|
50
49
|
this.isOpen = true;
|
|
51
50
|
this.returnFocusWhenClose = returnFocusWhenClose;
|
|
52
51
|
this.expand({
|
|
@@ -59,33 +58,15 @@ export default function getInspectorSection() {
|
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
collapse(options) {
|
|
62
|
-
// Overridden collapse() function. Mostly call the parent collapse(), but also
|
|
63
|
-
// move our .isOpen to false.
|
|
64
|
-
// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work
|
|
65
|
-
// because the block settings sidebar is a layer "on top of" the G editor sidebar.
|
|
66
|
-
//
|
|
67
|
-
// For example, when closing the block settings sidebar, the G
|
|
68
|
-
// editor sidebar would display, and onChangeExpanded in
|
|
69
|
-
// inspector-section would run with expanded=true, but I want
|
|
70
|
-
// isOpen to be false when the block settings is closed.
|
|
71
61
|
this.isOpen = false;
|
|
72
62
|
super.collapse(options);
|
|
73
63
|
}
|
|
74
64
|
triggerActiveCallbacks() {
|
|
75
|
-
// Manually fire the callbacks associated with moving this.active
|
|
76
|
-
// from false to true. "active" is always true for this section,
|
|
77
|
-
// and "isContextuallyActive" reflects if the block settings
|
|
78
|
-
// sidebar is currently visible, that is, it has replaced the main
|
|
79
|
-
// Gutenberg view.
|
|
80
|
-
// The WP customizer only checks ".isContextuallyActive()" when
|
|
81
|
-
// ".active" changes values. But our ".active" never changes value.
|
|
82
|
-
// The WP customizer never foresaw a section being used a way we
|
|
83
|
-
// fit the block settings sidebar into a section. By manually
|
|
84
|
-
// triggering the "this.active" callbacks, we force the WP
|
|
85
|
-
// customizer to query our .isContextuallyActive() function and
|
|
86
|
-
// update its view of our status.
|
|
87
65
|
this.active.callbacks.fireWith(this.active, [false, true]);
|
|
88
66
|
}
|
|
89
67
|
};
|
|
90
68
|
}
|
|
91
|
-
|
|
69
|
+
export {
|
|
70
|
+
getInspectorSection as default
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=inspector-section.js.map
|
|
@@ -1 +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,29 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';
|
|
10
|
-
import getInserterOuterSection from './inserter-outer-section';
|
|
11
|
-
import { store as customizeWidgetsStore } from '../store';
|
|
12
|
-
const getInserterId = controlId => `widgets-inserter-${controlId}`;
|
|
13
|
-
export default function getSidebarControl() {
|
|
1
|
+
import { dispatch } from "@wordpress/data";
|
|
2
|
+
import SidebarAdapter from "../components/sidebar-block-editor/sidebar-adapter";
|
|
3
|
+
import getInserterOuterSection from "./inserter-outer-section";
|
|
4
|
+
import { store as customizeWidgetsStore } from "../store";
|
|
5
|
+
const getInserterId = (controlId) => `widgets-inserter-${controlId}`;
|
|
6
|
+
function getSidebarControl() {
|
|
14
7
|
const {
|
|
15
|
-
wp: {
|
|
16
|
-
customize
|
|
17
|
-
}
|
|
8
|
+
wp: { customize }
|
|
18
9
|
} = window;
|
|
19
10
|
return class SidebarControl extends customize.Control {
|
|
20
11
|
constructor(...args) {
|
|
21
12
|
super(...args);
|
|
22
|
-
this.subscribers = new Set();
|
|
13
|
+
this.subscribers = /* @__PURE__ */ new Set();
|
|
23
14
|
}
|
|
24
15
|
ready() {
|
|
25
16
|
const InserterOuterSection = getInserterOuterSection();
|
|
26
|
-
this.inserter = new InserterOuterSection(
|
|
17
|
+
this.inserter = new InserterOuterSection(
|
|
18
|
+
getInserterId(this.id),
|
|
19
|
+
{}
|
|
20
|
+
);
|
|
27
21
|
customize.section.add(this.inserter);
|
|
28
22
|
this.sectionInstance = customize.section(this.section());
|
|
29
23
|
this.inspector = this.sectionInstance.inspector;
|
|
@@ -37,13 +31,19 @@ export default function getSidebarControl() {
|
|
|
37
31
|
}
|
|
38
32
|
onChangeSectionExpanded(expanded, args) {
|
|
39
33
|
if (!args.unchanged) {
|
|
40
|
-
// Close the inserter when the section collapses.
|
|
41
34
|
if (!expanded) {
|
|
42
|
-
dispatch(customizeWidgetsStore).setIsInserterOpened(
|
|
35
|
+
dispatch(customizeWidgetsStore).setIsInserterOpened(
|
|
36
|
+
false
|
|
37
|
+
);
|
|
43
38
|
}
|
|
44
|
-
this.subscribers.forEach(
|
|
39
|
+
this.subscribers.forEach(
|
|
40
|
+
(subscriber) => subscriber(expanded, args)
|
|
41
|
+
);
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
};
|
|
48
45
|
}
|
|
49
|
-
|
|
46
|
+
export {
|
|
47
|
+
getSidebarControl as default
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=sidebar-control.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/controls/sidebar-control.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\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": "AAGA,SAAS,gBAAgB;AAKzB,OAAO,oBAAoB;AAC3B,OAAO,6BAA6B;AACpC,SAAS,SAAS,6BAA6B;AAE/C,MAAM,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,34 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import getInspectorSection from './inspector-section';
|
|
10
|
-
const getInspectorSectionId = sidebarId => `widgets-inspector-${sidebarId}`;
|
|
11
|
-
export default function getSidebarSection() {
|
|
1
|
+
import { __ } from "@wordpress/i18n";
|
|
2
|
+
import getInspectorSection from "./inspector-section";
|
|
3
|
+
const getInspectorSectionId = (sidebarId) => `widgets-inspector-${sidebarId}`;
|
|
4
|
+
function getSidebarSection() {
|
|
12
5
|
const {
|
|
13
|
-
wp: {
|
|
14
|
-
customize
|
|
15
|
-
}
|
|
6
|
+
wp: { customize }
|
|
16
7
|
} = window;
|
|
17
|
-
const reduceMotionMediaQuery = window.matchMedia(
|
|
8
|
+
const reduceMotionMediaQuery = window.matchMedia(
|
|
9
|
+
"(prefers-reduced-motion: reduce)"
|
|
10
|
+
);
|
|
18
11
|
let isReducedMotion = reduceMotionMediaQuery.matches;
|
|
19
|
-
reduceMotionMediaQuery.addEventListener(
|
|
12
|
+
reduceMotionMediaQuery.addEventListener("change", (event) => {
|
|
20
13
|
isReducedMotion = event.matches;
|
|
21
14
|
});
|
|
22
15
|
return class SidebarSection extends customize.Section {
|
|
23
16
|
ready() {
|
|
24
17
|
const InspectorSection = getInspectorSection();
|
|
25
|
-
this.inspector = new InspectorSection(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
this.inspector = new InspectorSection(
|
|
19
|
+
getInspectorSectionId(this.id),
|
|
20
|
+
{
|
|
21
|
+
title: __("Block Settings"),
|
|
22
|
+
parentSection: this,
|
|
23
|
+
customizeAction: [
|
|
24
|
+
__("Customizing"),
|
|
25
|
+
__("Widgets"),
|
|
26
|
+
this.params.title
|
|
27
|
+
].join(" \u25B8 ")
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
30
|
customize.section.add(this.inspector);
|
|
31
|
-
this.contentContainer[0].classList.add(
|
|
31
|
+
this.contentContainer[0].classList.add(
|
|
32
|
+
"customize-widgets__sidebar-section"
|
|
33
|
+
);
|
|
32
34
|
}
|
|
33
35
|
hasSubSectionOpened() {
|
|
34
36
|
return this.inspector.expanded();
|
|
@@ -38,7 +40,7 @@ export default function getSidebarSection() {
|
|
|
38
40
|
const args = {
|
|
39
41
|
..._args,
|
|
40
42
|
completeCallback() {
|
|
41
|
-
controls.forEach(control => {
|
|
43
|
+
controls.forEach((control) => {
|
|
42
44
|
control.onChangeSectionExpanded?.(expanded, args);
|
|
43
45
|
});
|
|
44
46
|
_args.completeCallback?.();
|
|
@@ -46,22 +48,28 @@ export default function getSidebarSection() {
|
|
|
46
48
|
};
|
|
47
49
|
if (args.manualTransition) {
|
|
48
50
|
if (expanded) {
|
|
49
|
-
this.contentContainer.addClass([
|
|
50
|
-
this.contentContainer.removeClass(
|
|
51
|
-
this.contentContainer.closest(
|
|
51
|
+
this.contentContainer.addClass(["busy", "open"]);
|
|
52
|
+
this.contentContainer.removeClass("is-sub-section-open");
|
|
53
|
+
this.contentContainer.closest(".wp-full-overlay").addClass("section-open");
|
|
52
54
|
} else {
|
|
53
|
-
this.contentContainer.addClass([
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
this.contentContainer.addClass([
|
|
56
|
+
"busy",
|
|
57
|
+
"is-sub-section-open"
|
|
58
|
+
]);
|
|
59
|
+
this.contentContainer.closest(".wp-full-overlay").addClass("section-open");
|
|
60
|
+
this.contentContainer.removeClass("open");
|
|
56
61
|
}
|
|
57
62
|
const handleTransitionEnd = () => {
|
|
58
|
-
this.contentContainer.removeClass(
|
|
63
|
+
this.contentContainer.removeClass("busy");
|
|
59
64
|
args.completeCallback();
|
|
60
65
|
};
|
|
61
66
|
if (isReducedMotion) {
|
|
62
67
|
handleTransitionEnd();
|
|
63
68
|
} else {
|
|
64
|
-
this.contentContainer.one(
|
|
69
|
+
this.contentContainer.one(
|
|
70
|
+
"transitionend",
|
|
71
|
+
handleTransitionEnd
|
|
72
|
+
);
|
|
65
73
|
}
|
|
66
74
|
} else {
|
|
67
75
|
super.onChangeExpanded(expanded, args);
|
|
@@ -69,4 +77,7 @@ export default function getSidebarSection() {
|
|
|
69
77
|
}
|
|
70
78
|
};
|
|
71
79
|
}
|
|
72
|
-
|
|
80
|
+
export {
|
|
81
|
+
getSidebarSection as default
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=sidebar-section.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/controls/sidebar-section.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\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( ' \u25B8 ' ),\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": "AAGA,SAAS,UAAU;AAKnB,OAAO,yBAAyB;AAEhC,MAAM,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,UAAM;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,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import './replace-media-upload';
|
|
6
|
-
import './wide-widget-display';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./move-to-sidebar";
|
|
2
|
+
import "./replace-media-upload";
|
|
3
|
+
import "./wide-widget-display";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/filters/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport './move-to-sidebar';\nimport './replace-media-upload';\nimport './wide-widget-display';\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO;AACP,OAAO;AACP,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,77 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { useFocusControl } from
|
|
15
|
-
import { blockToWidget } from
|
|
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
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
BlockControls,
|
|
4
|
+
store as blockEditorStore
|
|
5
|
+
} from "@wordpress/block-editor";
|
|
6
|
+
import { createHigherOrderComponent } from "@wordpress/compose";
|
|
7
|
+
import { useSelect, useDispatch } from "@wordpress/data";
|
|
8
|
+
import { addFilter } from "@wordpress/hooks";
|
|
9
|
+
import { MoveToWidgetArea, getWidgetIdFromBlock } from "@wordpress/widgets";
|
|
10
|
+
import {
|
|
11
|
+
useSidebarControls,
|
|
12
|
+
useActiveSidebarControl
|
|
13
|
+
} from "../components/sidebar-controls";
|
|
14
|
+
import { useFocusControl } from "../components/focus-control";
|
|
15
|
+
import { blockToWidget } from "../utils";
|
|
16
|
+
const withMoveToSidebarToolbarItem = createHigherOrderComponent(
|
|
17
|
+
(BlockEdit) => (props) => {
|
|
18
|
+
let widgetId = getWidgetIdFromBlock(props);
|
|
19
|
+
const sidebarControls = useSidebarControls();
|
|
20
|
+
const activeSidebarControl = useActiveSidebarControl();
|
|
21
|
+
const hasMultipleSidebars = sidebarControls?.length > 1;
|
|
22
|
+
const blockName = props.name;
|
|
23
|
+
const clientId = props.clientId;
|
|
24
|
+
const canInsertBlockInSidebar = useSelect(
|
|
25
|
+
(select) => {
|
|
26
|
+
return select(blockEditorStore).canInsertBlockType(
|
|
27
|
+
blockName,
|
|
28
|
+
""
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
[blockName]
|
|
32
|
+
);
|
|
33
|
+
const block = useSelect(
|
|
34
|
+
(select) => select(blockEditorStore).getBlock(clientId),
|
|
35
|
+
[clientId]
|
|
36
|
+
);
|
|
37
|
+
const { removeBlock } = useDispatch(blockEditorStore);
|
|
38
|
+
const [, focusWidget] = useFocusControl();
|
|
39
|
+
function moveToSidebar(sidebarControlId) {
|
|
40
|
+
const newSidebarControl = sidebarControls.find(
|
|
41
|
+
(sidebarControl) => sidebarControl.id === sidebarControlId
|
|
42
|
+
);
|
|
43
|
+
if (widgetId) {
|
|
44
|
+
const oldSetting = activeSidebarControl.setting;
|
|
45
|
+
const newSetting = newSidebarControl.setting;
|
|
46
|
+
oldSetting(oldSetting().filter((id) => id !== widgetId));
|
|
47
|
+
newSetting([...newSetting(), widgetId]);
|
|
48
|
+
} else {
|
|
49
|
+
const sidebarAdapter = newSidebarControl.sidebarAdapter;
|
|
50
|
+
removeBlock(clientId);
|
|
51
|
+
const addedWidgetIds = sidebarAdapter.setWidgets([
|
|
52
|
+
...sidebarAdapter.getWidgets(),
|
|
53
|
+
blockToWidget(block)
|
|
54
|
+
]);
|
|
55
|
+
widgetId = addedWidgetIds.reverse().find((id) => !!id);
|
|
56
|
+
}
|
|
57
|
+
focusWidget(widgetId);
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
addFilter(
|
|
77
|
-
|
|
59
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx(BlockEdit, { ...props }, "edit"),
|
|
61
|
+
hasMultipleSidebars && canInsertBlockInSidebar && /* @__PURE__ */ jsx(BlockControls, { children: /* @__PURE__ */ jsx(
|
|
62
|
+
MoveToWidgetArea,
|
|
63
|
+
{
|
|
64
|
+
widgetAreas: sidebarControls.map(
|
|
65
|
+
(sidebarControl) => ({
|
|
66
|
+
id: sidebarControl.id,
|
|
67
|
+
name: sidebarControl.params.label,
|
|
68
|
+
description: sidebarControl.params.description
|
|
69
|
+
})
|
|
70
|
+
),
|
|
71
|
+
currentWidgetAreaId: activeSidebarControl?.id,
|
|
72
|
+
onSelect: moveToSidebar
|
|
73
|
+
}
|
|
74
|
+
) })
|
|
75
|
+
] });
|
|
76
|
+
},
|
|
77
|
+
"withMoveToSidebarToolbarItem"
|
|
78
|
+
);
|
|
79
|
+
addFilter(
|
|
80
|
+
"editor.BlockEdit",
|
|
81
|
+
"core/customize-widgets/block-edit",
|
|
82
|
+
withMoveToSidebarToolbarItem
|
|
83
|
+
);
|
|
84
|
+
//# sourceMappingURL=move-to-sidebar.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/filters/move-to-sidebar.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\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';\n\n/**\n * Internal dependencies\n */\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": "AAoFG,mBACC,KADD;AAjFH;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,kCAAkC;AAC3C,SAAS,WAAW,mBAAmB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB,4BAA4B;AAKvD;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAE9B,MAAM,+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,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { addFilter } from '@wordpress/hooks';
|
|
5
|
-
import { MediaUpload } from '@wordpress/media-utils';
|
|
1
|
+
import { addFilter } from "@wordpress/hooks";
|
|
2
|
+
import { MediaUpload } from "@wordpress/media-utils";
|
|
6
3
|
const replaceMediaUpload = () => MediaUpload;
|
|
7
|
-
addFilter(
|
|
8
|
-
|
|
4
|
+
addFilter(
|
|
5
|
+
"editor.MediaUpload",
|
|
6
|
+
"core/edit-widgets/replace-media-upload",
|
|
7
|
+
replaceMediaUpload
|
|
8
|
+
);
|
|
9
|
+
//# sourceMappingURL=replace-media-upload.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/filters/replace-media-upload.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { MediaUpload } from '@wordpress/media-utils';\n\nconst replaceMediaUpload = () => MediaUpload;\n\naddFilter(\n\t'editor.MediaUpload',\n\t'core/edit-widgets/replace-media-upload',\n\treplaceMediaUpload\n);\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAE5B,MAAM,qBAAqB,MAAM;AAEjC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|