@wordpress/customize-widgets 1.0.18 → 1.0.21
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/customize-widgets/index.js +4 -2
- package/build/components/customize-widgets/index.js.map +1 -1
- package/build/components/error-boundary/index.js +67 -0
- package/build/components/error-boundary/index.js.map +1 -0
- package/build/components/inserter/index.js +11 -0
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/use-inserter.js +21 -10
- package/build/components/inserter/use-inserter.js.map +1 -1
- package/build/components/more-menu/index.js +1 -1
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/sidebar-block-editor/index.js +1 -1
- package/build/components/sidebar-block-editor/index.js.map +1 -1
- package/build/controls/inserter-outer-section.js +25 -13
- package/build/controls/inserter-outer-section.js.map +1 -1
- package/build/controls/sidebar-control.js +9 -1
- package/build/controls/sidebar-control.js.map +1 -1
- package/build/controls/sidebar-section.js +3 -1
- package/build/controls/sidebar-section.js.map +1 -1
- package/build/store/actions.js +21 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +17 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +33 -0
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/customize-widgets/index.js +3 -2
- package/build-module/components/customize-widgets/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +56 -0
- package/build-module/components/error-boundary/index.js.map +1 -0
- package/build-module/components/inserter/index.js +9 -0
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/use-inserter.js +20 -11
- package/build-module/components/inserter/use-inserter.js.map +1 -1
- package/build-module/components/more-menu/index.js +1 -1
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/sidebar-block-editor/index.js +1 -1
- package/build-module/components/sidebar-block-editor/index.js.map +1 -1
- package/build-module/controls/inserter-outer-section.js +22 -12
- package/build-module/controls/inserter-outer-section.js.map +1 -1
- package/build-module/controls/sidebar-control.js +7 -1
- package/build-module/controls/sidebar-control.js.map +1 -1
- package/build-module/controls/sidebar-section.js +3 -1
- package/build-module/controls/sidebar-section.js.map +1 -1
- package/build-module/store/actions.js +19 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +17 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +29 -0
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +18 -18
- package/src/components/customize-widgets/index.js +10 -7
- package/src/components/error-boundary/index.js +50 -0
- package/src/components/inserter/index.js +13 -0
- package/src/components/inserter/use-inserter.js +21 -12
- package/src/components/more-menu/index.js +1 -1
- package/src/components/sidebar-block-editor/index.js +1 -0
- package/src/controls/inserter-outer-section.js +29 -12
- package/src/controls/sidebar-control.js +9 -1
- package/src/controls/sidebar-section.js +1 -1
- package/src/store/actions.js +19 -0
- package/src/store/reducer.js +15 -0
- package/src/store/selectors.js +23 -0
package/build/store/reducer.js
CHANGED
|
@@ -34,6 +34,22 @@ var _defaults = require("./defaults");
|
|
|
34
34
|
const createWithInitialState = initialState => reducer => {
|
|
35
35
|
return (state = initialState, action) => reducer(state, action);
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Reducer tracking whether the inserter is open.
|
|
39
|
+
*
|
|
40
|
+
* @param {boolean|Object} state
|
|
41
|
+
* @param {Object} action
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function blockInserterPanel(state = false, action) {
|
|
46
|
+
switch (action.type) {
|
|
47
|
+
case 'SET_IS_INSERTER_OPENED':
|
|
48
|
+
return action.value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return state;
|
|
52
|
+
}
|
|
37
53
|
/**
|
|
38
54
|
* Reducer returning the user preferences.
|
|
39
55
|
*
|
|
@@ -59,6 +75,7 @@ const preferences = (0, _lodash.flow)([_data.combineReducers, createWithInitialS
|
|
|
59
75
|
exports.preferences = preferences;
|
|
60
76
|
|
|
61
77
|
var _default = (0, _data.combineReducers)({
|
|
78
|
+
blockInserterPanel,
|
|
62
79
|
preferences
|
|
63
80
|
});
|
|
64
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/store/reducer.js"],"names":["createWithInitialState","initialState","reducer","state","action","preferences","combineReducers","PREFERENCES_DEFAULTS","features","
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/store/reducer.js"],"names":["createWithInitialState","initialState","reducer","state","action","blockInserterPanel","type","value","preferences","combineReducers","PREFERENCES_DEFAULTS","features","feature"],"mappings":";;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,sBAAsB,GAAKC,YAAF,IAAsBC,OAAF,IAAe;AACjE,SAAO,CAAEC,KAAK,GAAGF,YAAV,EAAwBG,MAAxB,KAAoCF,OAAO,CAAEC,KAAF,EAASC,MAAT,CAAlD;AACA,CAFD;AAIA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,kBAAT,CAA6BF,KAAK,GAAG,KAArC,EAA4CC,MAA5C,EAAqD;AACpD,UAASA,MAAM,CAACE,IAAhB;AACC,SAAK,wBAAL;AACC,aAAOF,MAAM,CAACG,KAAd;AAFF;;AAIA,SAAOJ,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMK,WAAW,GAAG,kBAAM,CAChCC,qBADgC,EAEhCT,sBAAsB,CAAEU,8BAAF,CAFU,CAAN,EAGtB;AACJC,EAAAA,QAAQ,CAAER,KAAF,EAASC,MAAT,EAAkB;AACzB,QAAKA,MAAM,CAACE,IAAP,KAAgB,gBAArB,EAAwC;AACvC,aAAO,EACN,GAAGH,KADG;AAEN,SAAEC,MAAM,CAACQ,OAAT,GAAoB,CAAET,KAAK,CAAEC,MAAM,CAACQ,OAAT;AAFrB,OAAP;AAIA;;AAED,WAAOT,KAAP;AACA;;AAVG,CAHsB,CAApB;;;eAgBQ,2BAAiB;AAC/BE,EAAAA,kBAD+B;AAE/BG,EAAAA;AAF+B,CAAjB,C","sourcesContent":["/**\n * External dependencies\n */\nimport { flow } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { PREFERENCES_DEFAULTS } from './defaults';\n\n/**\n * Higher-order reducer creator which provides the given initial state for the\n * original reducer.\n *\n * @param {*} initialState Initial state to provide to reducer.\n *\n * @return {Function} Higher-order reducer.\n */\nconst createWithInitialState = ( initialState ) => ( reducer ) => {\n\treturn ( state = initialState, action ) => reducer( state, action );\n};\n\n/**\n * Reducer tracking whether the inserter is open.\n *\n * @param {boolean|Object} state\n * @param {Object} action\n */\nfunction blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferences = flow( [\n\tcombineReducers,\n\tcreateWithInitialState( PREFERENCES_DEFAULTS ),\n] )( {\n\tfeatures( state, action ) {\n\t\tif ( action.type === 'TOGGLE_FEATURE' ) {\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.feature ]: ! state[ action.feature ],\n\t\t\t};\n\t\t}\n\n\t\treturn state;\n\t},\n} );\n\nexport default combineReducers( {\n\tblockInserterPanel,\n\tpreferences,\n} );\n"]}
|
package/build/store/selectors.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.__unstableIsFeatureActive = __unstableIsFeatureActive;
|
|
7
|
+
exports.isInserterOpened = isInserterOpened;
|
|
8
|
+
exports.__experimentalGetInsertionPoint = __experimentalGetInsertionPoint;
|
|
7
9
|
|
|
8
10
|
var _lodash = require("lodash");
|
|
9
11
|
|
|
@@ -26,4 +28,35 @@ var _lodash = require("lodash");
|
|
|
26
28
|
function __unstableIsFeatureActive(state, feature) {
|
|
27
29
|
return (0, _lodash.get)(state.preferences.features, [feature], false);
|
|
28
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if the inserter is opened.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} state Global application state.
|
|
35
|
+
*
|
|
36
|
+
* @return {boolean} Whether the inserter is opened.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function isInserterOpened(state) {
|
|
41
|
+
return !!state.blockInserterPanel;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get the insertion point for the inserter.
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} state Global application state.
|
|
47
|
+
*
|
|
48
|
+
* @return {Object} The root client ID and index to insert at.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
function __experimentalGetInsertionPoint(state) {
|
|
53
|
+
const {
|
|
54
|
+
rootClientId,
|
|
55
|
+
insertionIndex
|
|
56
|
+
} = state.blockInserterPanel;
|
|
57
|
+
return {
|
|
58
|
+
rootClientId,
|
|
59
|
+
insertionIndex
|
|
60
|
+
};
|
|
61
|
+
}
|
|
29
62
|
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/store/selectors.js"],"names":["__unstableIsFeatureActive","state","feature","preferences","features"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/store/selectors.js"],"names":["__unstableIsFeatureActive","state","feature","preferences","features","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,yBAAT,CAAoCC,KAApC,EAA2CC,OAA3C,EAAqD;AAC3D,SAAO,iBAAKD,KAAK,CAACE,WAAN,CAAkBC,QAAvB,EAAiC,CAAEF,OAAF,CAAjC,EAA8C,KAA9C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,gBAAT,CAA2BJ,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAACK,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,+BAAT,CAA0CN,KAA1C,EAAkD;AACxD,QAAM;AAAEO,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmCR,KAAK,CAACK,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * This function is unstable, as it is mostly copied from the edit-post\n * package. Editor features and preferences have a lot of scope for\n * being generalized and refactored.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function __unstableIsFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\n}\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n"]}
|
|
@@ -9,6 +9,7 @@ import { SlotFillProvider, Popover } from '@wordpress/components';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import ErrorBoundary from '../error-boundary';
|
|
12
13
|
import SidebarBlockEditor from '../sidebar-block-editor';
|
|
13
14
|
import FocusControl from '../focus-control';
|
|
14
15
|
import SidebarControls from '../sidebar-controls';
|
|
@@ -32,13 +33,13 @@ export default function CustomizeWidgets({
|
|
|
32
33
|
unsubscribers.forEach(unsubscriber => unsubscriber());
|
|
33
34
|
};
|
|
34
35
|
}, [sidebarControls]);
|
|
35
|
-
const activeSidebar = activeSidebarControl && createPortal(createElement(SidebarBlockEditor, {
|
|
36
|
+
const activeSidebar = activeSidebarControl && createPortal(createElement(ErrorBoundary, null, createElement(SidebarBlockEditor, {
|
|
36
37
|
key: activeSidebarControl.id,
|
|
37
38
|
blockEditorSettings: blockEditorSettings,
|
|
38
39
|
sidebar: activeSidebarControl.sidebarAdapter,
|
|
39
40
|
inserter: activeSidebarControl.inserter,
|
|
40
41
|
inspector: activeSidebarControl.inspector
|
|
41
|
-
}), activeSidebarControl.container[0]); // We have to portal this to the parent of both the editor and the inspector,
|
|
42
|
+
})), activeSidebarControl.container[0]); // We have to portal this to the parent of both the editor and the inspector,
|
|
42
43
|
// so that the popovers will appear above both of them.
|
|
43
44
|
|
|
44
45
|
const popover = parentContainer && createPortal(createElement("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/components/customize-widgets/index.js"],"names":["useState","useEffect","useRef","createPortal","SlotFillProvider","Popover","SidebarBlockEditor","FocusControl","SidebarControls","useClearSelectedBlock","CustomizeWidgets","api","sidebarControls","blockEditorSettings","activeSidebarControl","setActiveSidebarControl","parentContainer","document","getElementById","popoverRef","unsubscribers","map","sidebarControl","subscribe","expanded","forEach","unsubscriber","activeSidebar","id","sidebarAdapter","inserter","inspector","container","popover"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,MAA9B,EAAsCC,YAAtC,QAA0D,oBAA1D;AACA,SAASC,gBAAT,EAA2BC,OAA3B,QAA0C,uBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,eAAe,SAASC,gBAAT,CAA2B;AACzCC,EAAAA,GADyC;AAEzCC,EAAAA,eAFyC;AAGzCC,EAAAA;AAHyC,CAA3B,EAIX;AACH,QAAM,CAAEC,oBAAF,EAAwBC,uBAAxB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/components/customize-widgets/index.js"],"names":["useState","useEffect","useRef","createPortal","SlotFillProvider","Popover","ErrorBoundary","SidebarBlockEditor","FocusControl","SidebarControls","useClearSelectedBlock","CustomizeWidgets","api","sidebarControls","blockEditorSettings","activeSidebarControl","setActiveSidebarControl","parentContainer","document","getElementById","popoverRef","unsubscribers","map","sidebarControl","subscribe","expanded","forEach","unsubscriber","activeSidebar","id","sidebarAdapter","inserter","inspector","container","popover"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,MAA9B,EAAsCC,YAAtC,QAA0D,oBAA1D;AACA,SAASC,gBAAT,EAA2BC,OAA3B,QAA0C,uBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,eAAe,SAASC,gBAAT,CAA2B;AACzCC,EAAAA,GADyC;AAEzCC,EAAAA,eAFyC;AAGzCC,EAAAA;AAHyC,CAA3B,EAIX;AACH,QAAM,CAAEC,oBAAF,EAAwBC,uBAAxB,IAAoDhB,QAAQ,CAAE,IAAF,CAAlE;AACA,QAAMiB,eAAe,GAAGC,QAAQ,CAACC,cAAT,CACvB,0BADuB,CAAxB;AAGA,QAAMC,UAA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H,EAEGM,OAFH,CAJD,CADD,CADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef, createPortal } from '@wordpress/element';\nimport { SlotFillProvider, Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ErrorBoundary from '../error-boundary';\nimport SidebarBlockEditor from '../sidebar-block-editor';\nimport FocusControl from '../focus-control';\nimport SidebarControls from '../sidebar-controls';\nimport useClearSelectedBlock from './use-clear-selected-block';\n\nexport default function CustomizeWidgets( {\n\tapi,\n\tsidebarControls,\n\tblockEditorSettings,\n} ) {\n\tconst [ activeSidebarControl, setActiveSidebarControl ] = useState( null );\n\tconst parentContainer = document.getElementById(\n\t\t'customize-theme-controls'\n\t);\n\tconst popoverRef = useRef();\n\n\tuseClearSelectedBlock( activeSidebarControl, popoverRef );\n\n\tuseEffect( () => {\n\t\tconst unsubscribers = sidebarControls.map( ( sidebarControl ) =>\n\t\t\tsidebarControl.subscribe( ( expanded ) => {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tsetActiveSidebarControl( sidebarControl );\n\t\t\t\t}\n\t\t\t} )\n\t\t);\n\n\t\treturn () => {\n\t\t\tunsubscribers.forEach( ( unsubscriber ) => unsubscriber() );\n\t\t};\n\t}, [ sidebarControls ] );\n\n\tconst activeSidebar =\n\t\tactiveSidebarControl &&\n\t\tcreatePortal(\n\t\t\t<ErrorBoundary>\n\t\t\t\t<SidebarBlockEditor\n\t\t\t\t\tkey={ activeSidebarControl.id }\n\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\tsidebar={ activeSidebarControl.sidebarAdapter }\n\t\t\t\t\tinserter={ activeSidebarControl.inserter }\n\t\t\t\t\tinspector={ activeSidebarControl.inspector }\n\t\t\t\t/>\n\t\t\t</ErrorBoundary>,\n\t\t\tactiveSidebarControl.container[ 0 ]\n\t\t);\n\n\t// We have to portal this to the parent of both the editor and the inspector,\n\t// so that the popovers will appear above both of them.\n\tconst popover =\n\t\tparentContainer &&\n\t\tcreatePortal(\n\t\t\t<div className=\"customize-widgets-popover\" ref={ popoverRef }>\n\t\t\t\t<Popover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<SidebarControls\n\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\tactiveSidebarControl={ activeSidebarControl }\n\t\t\t>\n\t\t\t\t<FocusControl api={ api } sidebarControls={ sidebarControls }>\n\t\t\t\t\t{ activeSidebar }\n\t\t\t\t\t{ popover }\n\t\t\t\t</FocusControl>\n\t\t\t</SidebarControls>\n\t\t</SlotFillProvider>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Component } from '@wordpress/element';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { Button } from '@wordpress/components';
|
|
9
|
+
import { Warning } from '@wordpress/block-editor';
|
|
10
|
+
import { useCopyToClipboard } from '@wordpress/compose';
|
|
11
|
+
|
|
12
|
+
function CopyButton({
|
|
13
|
+
text,
|
|
14
|
+
children
|
|
15
|
+
}) {
|
|
16
|
+
const ref = useCopyToClipboard(text);
|
|
17
|
+
return createElement(Button, {
|
|
18
|
+
variant: "secondary",
|
|
19
|
+
ref: ref
|
|
20
|
+
}, children);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default class ErrorBoundary extends Component {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.state = {
|
|
27
|
+
error: null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
componentDidCatch(error) {
|
|
32
|
+
this.setState({
|
|
33
|
+
error
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
render() {
|
|
38
|
+
const {
|
|
39
|
+
error
|
|
40
|
+
} = this.state;
|
|
41
|
+
|
|
42
|
+
if (!error) {
|
|
43
|
+
return this.props.children;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return createElement(Warning, {
|
|
47
|
+
className: "customize-widgets-error-boundary",
|
|
48
|
+
actions: [createElement(CopyButton, {
|
|
49
|
+
key: "copy-error",
|
|
50
|
+
text: error.stack
|
|
51
|
+
}, __('Copy Error'))]
|
|
52
|
+
}, __('The editor has encountered an unexpected error.'));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/components/error-boundary/index.js"],"names":["Component","__","Button","Warning","useCopyToClipboard","CopyButton","text","children","ref","ErrorBoundary","constructor","arguments","state","error","componentDidCatch","setState","render","props","stack"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,OAAT,QAAwB,yBAAxB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;;AAEA,SAASC,UAAT,CAAqB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAArB,EAA0C;AACzC,QAAMC,GAAG,GAAGJ,kBAAkB,CAAEE,IAAF,CAA9B;AACA,SACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAED,eAAe,MAAME,aAAN,SAA4BT,SAA5B,CAAsC;AACpDU,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AACA,SAAKC,KAAL,GAAa;AACZC,MAAAA,KAAK,EAAE;AADK,KAAb;AAGA;;AAEDC,EAAAA,iBAAiB,CAAED,KAAF,EAAU;AAC1B,SAAKE,QAAL,CAAe;AAAEF,MAAAA;AAAF,KAAf;AACA;;AAEDG,EAAAA,MAAM,GAAG;AACR,UAAM;AAAEH,MAAAA;AAAF,QAAY,KAAKD,KAAvB;;AACA,QAAK,CAAEC,KAAP,EAAe;AACd,aAAO,KAAKI,KAAL,CAAWV,QAAlB;AACA;;AAED,WACC,cAAC,OAAD;AACC,MAAA,SAAS,EAAC,kCADX;AAEC,MAAA,OAAO,EAAG,CACT,cAAC,UAAD;AAAY,QAAA,GAAG,EAAC,YAAhB;AAA6B,QAAA,IAAI,EAAGM,KAAK,CAACK;AAA1C,SACGjB,EAAE,CAAE,YAAF,CADL,CADS;AAFX,OAQGA,EAAE,CAAE,iDAAF,CARL,CADD;AAYA;;AA9BmD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tthis.setState( { error } );\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tclassName=\"customize-widgets-error-boundary\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ __( 'The editor has encountered an unexpected error.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n}\n"]}
|
|
@@ -7,12 +7,19 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
import { __experimentalLibrary as Library } from '@wordpress/block-editor';
|
|
8
8
|
import { Button } from '@wordpress/components';
|
|
9
9
|
import { useInstanceId } from '@wordpress/compose';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
10
11
|
import { closeSmall } from '@wordpress/icons';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { store as customizeWidgetsStore } from '../../store';
|
|
11
17
|
|
|
12
18
|
function Inserter({
|
|
13
19
|
setIsOpened
|
|
14
20
|
}) {
|
|
15
21
|
const inserterTitleId = useInstanceId(Inserter, 'customize-widget-layout__inserter-panel-title');
|
|
22
|
+
const insertionPoint = useSelect(select => select(customizeWidgetsStore).__experimentalGetInsertionPoint());
|
|
16
23
|
return createElement("div", {
|
|
17
24
|
className: "customize-widgets-layout__inserter-panel",
|
|
18
25
|
"aria-labelledby": inserterTitleId
|
|
@@ -29,6 +36,8 @@ function Inserter({
|
|
|
29
36
|
})), createElement("div", {
|
|
30
37
|
className: "customize-widgets-layout__inserter-panel-content"
|
|
31
38
|
}, createElement(Library, {
|
|
39
|
+
rootClientId: insertionPoint.rootClientId,
|
|
40
|
+
__experimentalInsertionIndex: insertionPoint.insertionIndex,
|
|
32
41
|
showInserterHelpPanel: true,
|
|
33
42
|
onSelect: () => setIsOpened(false)
|
|
34
43
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/components/inserter/index.js"],"names":["__","__experimentalLibrary","Library","Button","useInstanceId","closeSmall","Inserter","setIsOpened","inserterTitleId"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,qBAAqB,IAAIC,OAAlC,QAAiD,yBAAjD;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,UAAT,QAA2B,kBAA3B;;AAEA,SAASC,QAAT,CAAmB;AAAEC,EAAAA;AAAF,CAAnB,EAAqC;AACpC,QAAMC,eAAe,
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/components/inserter/index.js"],"names":["__","__experimentalLibrary","Library","Button","useInstanceId","useSelect","closeSmall","store","customizeWidgetsStore","Inserter","setIsOpened","inserterTitleId","insertionPoint","select","__experimentalGetInsertionPoint","rootClientId","insertionIndex"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,qBAAqB,IAAIC,OAAlC,QAAiD,yBAAjD;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,QAA2B,kBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,qBAAlB,QAA+C,aAA/C;;AAEA,SAASC,QAAT,CAAmB;AAAEC,EAAAA;AAAF,CAAnB,EAAqC;AACpC,QAAMC,eAAe,GAAGP,aAAa,CACpCK,QADoC,EAEpC,+CAFoC,CAArC;AAIA,QAAMG,cAAc,GAAGP,SAAS,CAAIQ,MAAF,IACjCA,MAAM,CAAEL,qBAAF,CAAN,CAAgCM,+BAAhC,EAD+B,CAAhC;AAIA,SACC;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,uBAAkBH;AAFnB,KAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AACC,IAAA,EAAE,EAAGA,eADN;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGX,EAAE,CAAE,aAAF,CAJL,CADD,EAOC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,8DADX;AAEC,IAAA,IAAI,EAAGM,UAFR;AAGC,IAAA,OAAO,EAAG,MAAMI,WAAW,CAAE,KAAF,CAH5B;AAIC,kBAAaV,EAAE,CAAE,gBAAF;AAJhB,IAPD,CAJD,EAkBC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,OAAD;AACC,IAAA,YAAY,EAAGY,cAAc,CAACG,YAD/B;AAEC,IAAA,4BAA4B,EAC3BH,cAAc,CAACI,cAHjB;AAKC,IAAA,qBAAqB,MALtB;AAMC,IAAA,QAAQ,EAAG,MAAMN,WAAW,CAAE,KAAF;AAN7B,IADD,CAlBD,CADD;AA+BA;;AAED,eAAeD,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../../store';\n\nfunction Inserter( { setIsOpened } ) {\n\tconst inserterTitleId = useInstanceId(\n\t\tInserter,\n\t\t'customize-widget-layout__inserter-panel-title'\n\t);\n\tconst insertionPoint = useSelect( ( select ) =>\n\t\tselect( customizeWidgetsStore ).__experimentalGetInsertionPoint()\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"customize-widgets-layout__inserter-panel\"\n\t\t\taria-labelledby={ inserterTitleId }\n\t\t>\n\t\t\t<div className=\"customize-widgets-layout__inserter-panel-header\">\n\t\t\t\t<h2\n\t\t\t\t\tid={ inserterTitleId }\n\t\t\t\t\tclassName=\"customize-widgets-layout__inserter-panel-header-title\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add a block' ) }\n\t\t\t\t</h2>\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"customize-widgets-layout__inserter-panel-header-close-button\"\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tonClick={ () => setIsOpened( false ) }\n\t\t\t\t\taria-label={ __( 'Close inserter' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div className=\"customize-widgets-layout__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\trootClientId={ insertionPoint.rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\tinsertionPoint.insertionIndex\n\t\t\t\t\t}\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tonSelect={ () => setIsOpened( false ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default Inserter;\n"]}
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useEffect, useCallback } from '@wordpress/element';
|
|
5
|
+
import { useSelect, useDispatch, select as selectStore } from '@wordpress/data';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { store as customizeWidgetsStore } from '../../store';
|
|
5
11
|
export default function useInserter(inserter) {
|
|
6
|
-
const
|
|
12
|
+
const isInserterOpened = useSelect(select => select(customizeWidgetsStore).isInserterOpened());
|
|
13
|
+
const {
|
|
14
|
+
setIsInserterOpened
|
|
15
|
+
} = useDispatch(customizeWidgetsStore);
|
|
7
16
|
useEffect(() => {
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
if (isInserterOpened) {
|
|
18
|
+
inserter.open();
|
|
19
|
+
} else {
|
|
20
|
+
inserter.close();
|
|
21
|
+
}
|
|
22
|
+
}, [inserter, isInserterOpened]);
|
|
10
23
|
return [isInserterOpened, useCallback(updater => {
|
|
11
24
|
let isOpen = updater;
|
|
12
25
|
|
|
13
26
|
if (typeof updater === 'function') {
|
|
14
|
-
isOpen = updater(
|
|
27
|
+
isOpen = updater(selectStore(customizeWidgetsStore).isInserterOpened());
|
|
15
28
|
}
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} else {
|
|
20
|
-
inserter.close();
|
|
21
|
-
}
|
|
22
|
-
}, [inserter])];
|
|
30
|
+
setIsInserterOpened(isOpen);
|
|
31
|
+
}, [setIsInserterOpened])];
|
|
23
32
|
}
|
|
24
33
|
//# sourceMappingURL=use-inserter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/components/inserter/use-inserter.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/components/inserter/use-inserter.js"],"names":["useEffect","useCallback","useSelect","useDispatch","select","selectStore","store","customizeWidgetsStore","useInserter","inserter","isInserterOpened","setIsInserterOpened","open","close","updater","isOpen"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,oBAAvC;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,MAAM,IAAIC,WAA3C,QAA8D,iBAA9D;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,qBAAlB,QAA+C,aAA/C;AAEA,eAAe,SAASC,WAAT,CAAsBC,QAAtB,EAAiC;AAC/C,QAAMC,gBAAgB,GAAGR,SAAS,CAAIE,MAAF,IACnCA,MAAM,CAAEG,qBAAF,CAAN,CAAgCG,gBAAhC,EADiC,CAAlC;AAGA,QAAM;AAAEC,IAAAA;AAAF,MAA0BR,WAAW,CAAEI,qBAAF,CAA3C;AAEAP,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKU,gBAAL,EAAwB;AACvBD,MAAAA,QAAQ,CAACG,IAAT;AACA,KAFD,MAEO;AACNH,MAAAA,QAAQ,CAACI,KAAT;AACA;AACD,GANQ,EAMN,CAAEJ,QAAF,EAAYC,gBAAZ,CANM,CAAT;AAQA,SAAO,CACNA,gBADM,EAENT,WAAW,CACRa,OAAF,IAAe;AACd,QAAIC,MAAM,GAAGD,OAAb;;AACA,QAAK,OAAOA,OAAP,KAAmB,UAAxB,EAAqC;AACpCC,MAAAA,MAAM,GAAGD,OAAO,CACfT,WAAW,CAAEE,qBAAF,CAAX,CAAqCG,gBAArC,EADe,CAAhB;AAGA;;AAEDC,IAAAA,mBAAmB,CAAEI,MAAF,CAAnB;AACA,GAVS,EAWV,CAAEJ,mBAAF,CAXU,CAFL,CAAP;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch, select as selectStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../../store';\n\nexport default function useInserter( inserter ) {\n\tconst isInserterOpened = useSelect( ( select ) =>\n\t\tselect( customizeWidgetsStore ).isInserterOpened()\n\t);\n\tconst { setIsInserterOpened } = useDispatch( customizeWidgetsStore );\n\n\tuseEffect( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\tinserter.open();\n\t\t} else {\n\t\t\tinserter.close();\n\t\t}\n\t}, [ inserter, isInserterOpened ] );\n\n\treturn [\n\t\tisInserterOpened,\n\t\tuseCallback(\n\t\t\t( updater ) => {\n\t\t\t\tlet isOpen = updater;\n\t\t\t\tif ( typeof updater === 'function' ) {\n\t\t\t\t\tisOpen = updater(\n\t\t\t\t\t\tselectStore( customizeWidgetsStore ).isInserterOpened()\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsetIsInserterOpened( isOpen );\n\t\t\t},\n\t\t\t[ setIsInserterOpened ]\n\t\t),\n\t];\n}\n"]}
|
|
@@ -59,7 +59,7 @@ export default function MoreMenu() {
|
|
|
59
59
|
}), createElement(MenuItem, {
|
|
60
60
|
role: "menuitem",
|
|
61
61
|
icon: external,
|
|
62
|
-
href: __('https://wordpress.org/support/article/
|
|
62
|
+
href: __('https://wordpress.org/support/article/block-based-widgets-editor/'),
|
|
63
63
|
target: "_blank",
|
|
64
64
|
rel: "noopener noreferrer"
|
|
65
65
|
}, __('Help'), createElement(VisuallyHidden, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/components/more-menu/index.js"],"names":["ToolbarDropdownMenu","MenuGroup","MenuItem","VisuallyHidden","useState","__","_x","external","moreVertical","displayShortcut","useShortcut","FeatureToggle","KeyboardShortcutHelpModal","POPOVER_PROPS","className","position","TOGGLE_PROPS","tooltipPosition","MoreMenu","isKeyboardShortcutsModalActive","setIsKeyboardShortcutsModalVisible","toggleKeyboardShortcutsModal","bindGlobal","access"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,mBADD,EAECC,SAFD,EAGCC,QAHD,EAICC,cAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,EAAmBC,YAAnB,QAAuC,kBAAvC;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,WAAT,QAA4B,+BAA5B;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,sCADU;AAErBC,EAAAA,QAAQ,EAAE;AAFW,CAAtB;AAIA,MAAMC,YAAY,GAAG;AACpBC,EAAAA,eAAe,EAAE;AADG,CAArB;AAIA,eAAe,SAASC,QAAT,GAAoB;AAClC,QAAM,CACLC,8BADK,EAELC,kCAFK,IAGFhB,QAAQ,CAAE,KAAF,CAHZ;;AAIA,QAAMiB,4BAA4B,GAAG,MACpCD,kCAAkC,CAAE,CAAED,8BAAJ,CADnC;;AAGAT,EAAAA,WAAW,CACV,2CADU,EAEVW,4BAFU,EAGV;AACCC,IAAAA,UAAU,EAAE;AADb,GAHU,CAAX;AAQA,SACC,8BACC,cAAC,mBAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,IAAA,IAAI,EAAGd;AACP;AAHD;AAIC,IAAA,KAAK,EAAGH,EAAE,CAAE,SAAF,CAJX;AAKC,IAAA,YAAY,EAAGQ,aALhB;AAMC,IAAA,WAAW,EAAGG;AANf,KAQG,MACD,8BACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGV,EAAE,CAAE,MAAF,EAAU,MAAV;AAArB,KACC,cAAC,aAAD;AACC,IAAA,OAAO,EAAC,cADT;AAEC,IAAA,KAAK,EAAGD,EAAE,CAAE,aAAF,CAFX;AAGC,IAAA,IAAI,EAAGA,EAAE,CACR,uDADQ,CAHV;AAMC,IAAA,gBAAgB,EAAGA,EAAE,CACpB,uBADoB,CANtB;AASC,IAAA,kBAAkB,EAAGA,EAAE,CACtB,yBADsB;AATxB,IADD,CADD,EAgBC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGA,EAAE,CAAE,OAAF;AAArB,KACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfe,MAAAA,kCAAkC,CAAE,IAAF,CAAlC;AACA,KAHF;AAIC,IAAA,QAAQ,EAAGX,eAAe,CAACc,MAAhB,CAAwB,GAAxB;AAJZ,KAMGlB,EAAE,CAAE,oBAAF,CANL,CADD,EASC,cAAC,aAAD;AACC,IAAA,OAAO,EAAC,cADT;AAEC,IAAA,KAAK,EAAGA,EAAE,CAAE,eAAF;AAFX,IATD,EAaC,cAAC,QAAD;AACC,IAAA,IAAI,EAAC,UADN;AAEC,IAAA,IAAI,EAAGE,QAFR;AAGC,IAAA,IAAI,EAAGF,EAAE,CACR,
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/components/more-menu/index.js"],"names":["ToolbarDropdownMenu","MenuGroup","MenuItem","VisuallyHidden","useState","__","_x","external","moreVertical","displayShortcut","useShortcut","FeatureToggle","KeyboardShortcutHelpModal","POPOVER_PROPS","className","position","TOGGLE_PROPS","tooltipPosition","MoreMenu","isKeyboardShortcutsModalActive","setIsKeyboardShortcutsModalVisible","toggleKeyboardShortcutsModal","bindGlobal","access"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,mBADD,EAECC,SAFD,EAGCC,QAHD,EAICC,cAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB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AAE,CAAE,OAAF;AAArB,KACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfe,MAAAA,kCAAkC,CAAE,IAAF,CAAlC;AACA,KAHF;AAIC,IAAA,QAAQ,EAAGX,eAAe,CAACc,MAAhB,CAAwB,GAAxB;AAJZ,KAMGlB,EAAE,CAAE,oBAAF,CANL,CADD,EASC,cAAC,aAAD;AACC,IAAA,OAAO,EAAC,cADT;AAEC,IAAA,KAAK,EAAGA,EAAE,CAAE,eAAF;AAFX,IATD,EAaC,cAAC,QAAD;AACC,IAAA,IAAI,EAAC,UADN;AAEC,IAAA,IAAI,EAAGE,QAFR;AAGC,IAAA,IAAI,EAAGF,EAAE,CACR,mEADQ,CAHV;AAMC,IAAA,MAAM,EAAC,QANR;AAOC,IAAA,GAAG,EAAC;AAPL,KASGA,EAAE,CAAE,MAAF,CATL,EAUC,cAAC,cAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB;AAEE;AACAA,EAAAA,EAAE,CAAE,sBAAF,CAHJ,CAVD,CAbD,CAhBD,EA+CC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGA,EAAE,CAAE,aAAF;AAArB,KACC,cAAC,aAAD;AACC,IAAA,OAAO,EAAC,sBADT;AAEC,IAAA,KAAK,EAAGA,EAAE,CACT,kCADS,CAFX;AAKC,IAAA,IAAI,EAAGA,EAAE,CACR,iEADQ,CALV;AAQC,IAAA,gBAAgB,EAAGA,EAAE,CACpB,4CADoB,CARtB;AAWC,IAAA,kBAAkB,EAAGA,EAAE,CACtB,8CADsB;AAXxB,IADD,CA/CD,CATF,CADD,EA6EC,cAAC,yBAAD;AACC,IAAA,aAAa,EAAGc,8BADjB;AAEC,IAAA,WAAW,EAAGE;AAFf,IA7ED,CADD;AAoFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { external, moreVertical } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport FeatureToggle from './feature-toggle';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\n\nconst POPOVER_PROPS = {\n\tclassName: 'customize-widgets-more-menu__content',\n\tposition: 'bottom left',\n};\nconst TOGGLE_PROPS = {\n\ttooltipPosition: 'bottom',\n};\n\nexport default function MoreMenu() {\n\tconst [\n\t\tisKeyboardShortcutsModalActive,\n\t\tsetIsKeyboardShortcutsModalVisible,\n\t] = useState( false );\n\tconst toggleKeyboardShortcutsModal = () =>\n\t\tsetIsKeyboardShortcutsModalVisible( ! isKeyboardShortcutsModalActive );\n\n\tuseShortcut(\n\t\t'core/customize-widgets/keyboard-shortcuts',\n\t\ttoggleKeyboardShortcutsModal,\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarDropdownMenu\n\t\t\t\tclassName=\"customize-widgets-more-menu\"\n\t\t\t\ticon={ moreVertical }\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\ttoggleProps={ TOGGLE_PROPS }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"fixedToolbar\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar deactivated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsKeyboardShortcutsModalVisible( true );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"welcomeGuide\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Welcome Guide' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/block-based-widgets-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Preferences' ) }>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"keepCaretInsideBlock\"\n\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Aids screen readers by stopping text caret from leaving blocks.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block deactivated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</ToolbarDropdownMenu>\n\t\t\t<KeyboardShortcutHelpModal\n\t\t\t\tisModalActive={ isKeyboardShortcutsModalActive }\n\t\t\t\ttoggleModal={ toggleKeyboardShortcutsModal }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -70,7 +70,7 @@ export default function SidebarBlockEditor({
|
|
|
70
70
|
keepCaretInsideBlock,
|
|
71
71
|
__unstableHasCustomAppender: true
|
|
72
72
|
};
|
|
73
|
-
}, [hasUploadPermissions, blockEditorSettings, isFixedToolbarActive, keepCaretInsideBlock]);
|
|
73
|
+
}, [hasUploadPermissions, blockEditorSettings, isFixedToolbarActive, keepCaretInsideBlock, setIsInserterOpened]);
|
|
74
74
|
|
|
75
75
|
if (isWelcomeGuideActive) {
|
|
76
76
|
return createElement(WelcomeGuide, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/index.js"],"names":["defaultTo","store","coreStore","useSelect","useMemo","createPortal","BlockList","BlockTools","BlockSelectionClearer","BlockInspector","CopyHandler","ObserveTyping","WritingFlow","BlockEditorKeyboardShortcuts","__unstableBlockSettingsMenuFirstItem","uploadMedia","BlockInspectorButton","Header","useInserter","SidebarEditorProvider","customizeWidgetsStore","WelcomeGuide","KeyboardShortcuts","BlockAppender","SidebarBlockEditor","blockEditorSettings","sidebar","inserter","inspector","isInserterOpened","setIsInserterOpened","hasUploadPermissions","isFixedToolbarActive","keepCaretInsideBlock","isWelcomeGuideActive","select","canUser","__unstableIsFeatureActive","settings","mediaUploadBlockEditor","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalSetIsInserterOpened","mediaUpload","hasFixedToolbar","__unstableHasCustomAppender","undo","redo","save","event","preventDefault","contentContainer","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,EAAkBC,YAAlB,QAAsC,oBAAtC;AACA,SACCC,SADD,EAECC,UAFD,EAGCC,qBAHD,EAICC,cAJD,EAKCC,WALD,EAMCC,aAND,EAOCC,WAPD,EAQCC,4BARD,EASCC,oCATD,QAUO,yBAVP;AAWA,SAASC,WAAT,QAA4B,wBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,SAASlB,KAAK,IAAImB,qBAAlB,QAA+C,aAA/C;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA,eAAe,SAASC,kBAAT,CAA6B;AAC3CC,EAAAA,mBAD2C;AAE3CC,EAAAA,OAF2C;AAG3CC,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;AAGNgB,MAAAA,WAAW,EAAEP,sBAHP;AAINQ,MAAAA,eAAe,EAAEf,oBAJX;AAKNC,MAAAA,oBALM;AAMNe,MAAAA,2BAA2B,EAAE;AANvB,KAAP;AAQA,GApBuB,EAoBrB,CACFjB,oBADE,EAEFN,mBAFE,EAGFO,oBAHE,EAIFC,oBAJE,CApBqB,CAAxB;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/index.js"],"names":["defaultTo","store","coreStore","useSelect","useMemo","createPortal","BlockList","BlockTools","BlockSelectionClearer","BlockInspector","CopyHandler","ObserveTyping","WritingFlow","BlockEditorKeyboardShortcuts","__unstableBlockSettingsMenuFirstItem","uploadMedia","BlockInspectorButton","Header","useInserter","SidebarEditorProvider","customizeWidgetsStore","WelcomeGuide","KeyboardShortcuts","BlockAppender","SidebarBlockEditor","blockEditorSettings","sidebar","inserter","inspector","isInserterOpened","setIsInserterOpened","hasUploadPermissions","isFixedToolbarActive","keepCaretInsideBlock","isWelcomeGuideActive","select","canUser","__unstableIsFeatureActive","settings","mediaUploadBlockEditor","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalSetIsInserterOpened","mediaUpload","hasFixedToolbar","__unstableHasCustomAppender","undo","redo","save","event","preventDefault","contentContainer","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,EAAkBC,YAAlB,QAAsC,oBAAtC;AACA,SACCC,SADD,EAECC,UAFD,EAGCC,qBAHD,EAICC,cAJD,EAKCC,WALD,EAMCC,aAND,EAOCC,WAPD,EAQCC,4BARD,EASCC,oCATD,QAUO,yBAVP;AAWA,SAASC,WAAT,QAA4B,wBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA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gBC,cAAC,WAAD,QACC,cAAC,UAAD,QACC,cAAC,qBAAD,QACC,cAAC,WAAD,QACC,cAAC,aAAD,QACC,cAAC,SAAD;AACC,IAAA,cAAc,EAAGT;AADlB,IADD,CADD,CADD,CADD,CADD,CAhBD,EA8BGlB,YAAY,EACb;AACA;AACA;AAAM,IAAA,QAAQ,EAAK+C,KAAF,IAAaA,KAAK,CAACC,cAAN;AAA9B,KACC,cAAC,cAAD,OADD,CAHa,EAMbzB,SAAS,CAAC0B,gBAAV,CAA4B,CAA5B,CANa,CA9Bf,CAJD,EA4CC,cAAC,oCAAD,QACG,CAAE;AAAEC,IAAAA;AAAF,GAAF,KACD,cAAC,oBAAD;AACC,IAAA,SAAS,EAAG3B,SADb;AAEC,IAAA,SAAS,EAAG2B;AAFb,IAFF,CA5CD,CADD;AAuDA","sourcesContent":["/**\n * External dependencies\n */\nimport { defaultTo } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, createPortal } from '@wordpress/element';\nimport {\n\tBlockList,\n\tBlockTools,\n\tBlockSelectionClearer,\n\tBlockInspector,\n\tCopyHandler,\n\tObserveTyping,\n\tWritingFlow,\n\tBlockEditorKeyboardShortcuts,\n\t__unstableBlockSettingsMenuFirstItem,\n} from '@wordpress/block-editor';\nimport { uploadMedia } from '@wordpress/media-utils';\n\n/**\n * Internal dependencies\n */\nimport BlockInspectorButton from '../block-inspector-button';\nimport Header from '../header';\nimport useInserter from '../inserter/use-inserter';\nimport SidebarEditorProvider from './sidebar-editor-provider';\nimport { store as customizeWidgetsStore } from '../../store';\nimport WelcomeGuide from '../welcome-guide';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport BlockAppender from '../block-appender';\n\nexport default function SidebarBlockEditor( {\n\tblockEditorSettings,\n\tsidebar,\n\tinserter,\n\tinspector,\n} ) {\n\tconst [ isInserterOpened, setIsInserterOpened ] = useInserter( inserter );\n\tconst {\n\t\thasUploadPermissions,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tisWelcomeGuideActive,\n\t} = useSelect( ( select ) => {\n\t\treturn {\n\t\t\thasUploadPermissions: defaultTo(\n\t\t\t\tselect( coreStore ).canUser( 'create', 'media' ),\n\t\t\t\ttrue\n\t\t\t),\n\t\t\tisFixedToolbarActive: select(\n\t\t\t\tcustomizeWidgetsStore\n\t\t\t).__unstableIsFeatureActive( 'fixedToolbar' ),\n\t\t\tkeepCaretInsideBlock: select(\n\t\t\t\tcustomizeWidgetsStore\n\t\t\t).__unstableIsFeatureActive( 'keepCaretInsideBlock' ),\n\t\t\tisWelcomeGuideActive: select(\n\t\t\t\tcustomizeWidgetsStore\n\t\t\t).__unstableIsFeatureActive( 'welcomeGuide' ),\n\t\t};\n\t}, [] );\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\thasFixedToolbar: isFixedToolbarActive,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t__unstableHasCustomAppender: true,\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tsetIsInserterOpened,\n\t] );\n\n\tif ( isWelcomeGuideActive ) {\n\t\treturn <WelcomeGuide sidebar={ sidebar } />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t<KeyboardShortcuts.Register />\n\n\t\t\t<SidebarEditorProvider sidebar={ sidebar } settings={ settings }>\n\t\t\t\t<BlockEditorKeyboardShortcuts />\n\t\t\t\t<KeyboardShortcuts\n\t\t\t\t\tundo={ sidebar.undo }\n\t\t\t\t\tredo={ sidebar.redo }\n\t\t\t\t\tsave={ sidebar.save }\n\t\t\t\t/>\n\n\t\t\t\t<Header\n\t\t\t\t\tsidebar={ sidebar }\n\t\t\t\t\tinserter={ inserter }\n\t\t\t\t\tisInserterOpened={ isInserterOpened }\n\t\t\t\t\tsetIsInserterOpened={ setIsInserterOpened }\n\t\t\t\t\tisFixedToolbarActive={ isFixedToolbarActive }\n\t\t\t\t/>\n\n\t\t\t\t<CopyHandler>\n\t\t\t\t\t<BlockTools>\n\t\t\t\t\t\t<BlockSelectionClearer>\n\t\t\t\t\t\t\t<WritingFlow>\n\t\t\t\t\t\t\t\t<ObserveTyping>\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\trenderAppender={ BlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ObserveTyping>\n\t\t\t\t\t\t\t</WritingFlow>\n\t\t\t\t\t\t</BlockSelectionClearer>\n\t\t\t\t\t</BlockTools>\n\t\t\t\t</CopyHandler>\n\n\t\t\t\t{ createPortal(\n\t\t\t\t\t// This is a temporary hack to prevent button component inside <BlockInspector>\n\t\t\t\t\t// from submitting form when type=\"button\" is not specified.\n\t\t\t\t\t<form onSubmit={ ( event ) => event.preventDefault() }>\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t</form>,\n\t\t\t\t\tinspector.contentContainer[ 0 ]\n\t\t\t\t) }\n\t\t\t</SidebarEditorProvider>\n\n\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<BlockInspectorButton\n\t\t\t\t\t\tinspector={ inspector }\n\t\t\t\t\t\tcloseMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
5
5
|
import { focus } from '@wordpress/dom';
|
|
6
|
+
import { dispatch } from '@wordpress/data';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { store as customizeWidgetsStore } from '../store';
|
|
6
12
|
export default function getInserterOuterSection() {
|
|
7
13
|
const {
|
|
8
14
|
wp: {
|
|
@@ -41,28 +47,31 @@ export default function getInserterOuterSection() {
|
|
|
41
47
|
const ownerWindow = this.contentContainer[0].ownerDocument.defaultView; // Handle closing the inserter when pressing the Escape key.
|
|
42
48
|
|
|
43
49
|
ownerWindow.addEventListener('keydown', event => {
|
|
44
|
-
if (this.
|
|
50
|
+
if (this.expanded() && (event.keyCode === ESCAPE || event.code === 'Escape')) {
|
|
45
51
|
event.stopPropagation();
|
|
46
|
-
|
|
52
|
+
dispatch(customizeWidgetsStore).setIsInserterOpened(false);
|
|
47
53
|
}
|
|
48
54
|
}, // Use capture mode to make this run before other event listeners.
|
|
49
55
|
true);
|
|
50
|
-
this.contentContainer.addClass('widgets-inserter');
|
|
51
|
-
|
|
56
|
+
this.contentContainer.addClass('widgets-inserter'); // Set a flag if the state is being changed from open() or close().
|
|
57
|
+
// Don't propagate the event if it's an internal action to prevent infinite loop.
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
this.isFromInternalAction = false;
|
|
60
|
+
this.expanded.bind(() => {
|
|
61
|
+
if (!this.isFromInternalAction) {
|
|
62
|
+
// Propagate the event to React to sync the state.
|
|
63
|
+
dispatch(customizeWidgetsStore).setIsInserterOpened(this.expanded());
|
|
64
|
+
}
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return () => this.expanded.unbind(handler);
|
|
66
|
+
this.isFromInternalAction = false;
|
|
67
|
+
});
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
open() {
|
|
63
|
-
if (!this.
|
|
71
|
+
if (!this.expanded()) {
|
|
64
72
|
const contentContainer = this.contentContainer[0];
|
|
65
73
|
this.activeElementBeforeExpanded = contentContainer.ownerDocument.activeElement;
|
|
74
|
+
this.isFromInternalAction = true;
|
|
66
75
|
this.expand({
|
|
67
76
|
completeCallback() {
|
|
68
77
|
// We have to do this in a "completeCallback" or else the elements will not yet be visible/tabbable.
|
|
@@ -80,9 +89,10 @@ export default function getInserterOuterSection() {
|
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
close() {
|
|
83
|
-
if (this.
|
|
92
|
+
if (this.expanded()) {
|
|
84
93
|
const contentContainer = this.contentContainer[0];
|
|
85
94
|
const activeElement = contentContainer.ownerDocument.activeElement;
|
|
95
|
+
this.isFromInternalAction = true;
|
|
86
96
|
this.collapse({
|
|
87
97
|
completeCallback() {
|
|
88
98
|
// Return back the focus when closing the inserter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/controls/inserter-outer-section.js"],"names":["ESCAPE","focus","getInserterOuterSection","wp","customize","window","OuterSection","onChangeExpanded","expanded","args","section","each","params","type","id","collapse","sectionConstructor","outer","InserterOuterSection","constructor","activeElementBeforeExpanded","ownerWindow","contentContainer","ownerDocument","defaultView","addEventListener","event","
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/controls/inserter-outer-section.js"],"names":["ESCAPE","focus","dispatch","store","customizeWidgetsStore","getInserterOuterSection","wp","customize","window","OuterSection","onChangeExpanded","expanded","args","section","each","params","type","id","collapse","sectionConstructor","outer","InserterOuterSection","constructor","activeElementBeforeExpanded","ownerWindow","contentContainer","ownerDocument","defaultView","addEventListener","event","keyCode","code","stopPropagation","setIsInserterOpened","addClass","isFromInternalAction","bind","open","activeElement","expand","completeCallback","searchBox","tabbable","find","close","contains"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,qBAAvB;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,qBAAlB,QAA+C,UAA/C;AAEA,eAAe,SAASC,uBAAT,GAAmC;AACjD,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;AAIA,QAAMC,YAAY,GAAGF,SAAS,CAACE,YAA/B,CALiD,CAMjD;AACA;AACA;;AACAF,EAAAA,SAAS,CAACE,YAAV,GAAyB,cAAcA,YAAd,CAA2B;AACnDC,IAAAA,gBAAgB,CAAEC,QAAF,EAAYC,IAAZ,EAAmB;AAClC,UAAKD,QAAL,EAAgB;AACfJ,QAAAA,SAAS,CAACM,OAAV,CAAkBC,IAAlB,CAA0BD,OAAF,IAAe;AACtC,cACCA,OAAO,CAACE,MAAR,CAAeC,IAAf,KAAwB,OAAxB,IACAH,OAAO,CAACI,EAAR,KAAe,KAAKA,EAFrB,EAGE;AACD,gBAAKJ,OAAO,CAACF,QAAR,EAAL,EAA0B;AACzBE,cAAAA,OAAO,CAACK,QAAR;AACA;AACD;AACD,SATD;AAUA;;AAED,aAAO,MAAMR,gBAAN,CAAwBC,QAAxB,EAAkCC,IAAlC,CAAP;AACA;;AAhBkD,GAApD,CATiD,CA2BjD;;AACAL,EAAAA,SAAS,CAACY,kBAAV,CAA6BC,KAA7B,GAAqCb,SAAS,CAACE,YAA/C;AAEA,SAAO,MAAMY,oBAAN,SAAmCd,SAAS,CAACE,YAA7C,CAA0D;AAChEa,IAAAA,WAAW,CAAE,GAAGV,IAAL,EAAY;AACtB,YAAO,GAAGA,IAAV,EADsB,CAGtB;AACA;;AACA,WAAKG,MAAL,CAAYC,IAAZ,GAAmB,OAAnB;AAEA,WAAKO,2BAAL,GAA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ACD;;AAXW,SAAb;AAaA;AACD;;AACD2C,IAAAA,KAAK,GAAG;AACP,UAAK,KAAKjC,QAAL,EAAL,EAAuB;AACtB,cAAMc,gBAAgB,GAAG,KAAKA,gBAAL,CAAuB,CAAvB,CAAzB;AACA,cAAMa,aAAa,GAClBb,gBAAgB,CAACC,aAAjB,CAA+BY,aADhC;AAGA,aAAKH,oBAAL,GAA4B,IAA5B;AAEA,aAAKjB,QAAL,CAAe;AACdsB,UAAAA,gBAAgB,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA,gBAAKf,gBAAgB,CAACoB,QAAjB,CAA2BP,aAA3B,CAAL,EAAkD;AACjD;AACA,kBAAK,KAAKf,2BAAV,EAAwC;AACvC,qBAAKA,2BAAL,CAAiCtB,KAAjC;AACA;AACD;AACD;;AAba,SAAf;AAeA;AACD;;AA7F+D,GAAjE;AA+FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../store';\n\nexport default function getInserterOuterSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst OuterSection = customize.OuterSection;\n\t// Override the OuterSection class to handle multiple outer sections.\n\t// It closes all the other outer sections whenever one is opened.\n\t// The result is that at most one outer section can be opened at the same time.\n\tcustomize.OuterSection = class extends OuterSection {\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tif ( expanded ) {\n\t\t\t\tcustomize.section.each( ( section ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tsection.params.type === 'outer' &&\n\t\t\t\t\t\tsection.id !== this.id\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ( section.expanded() ) {\n\t\t\t\t\t\t\tsection.collapse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn super.onChangeExpanded( expanded, args );\n\t\t}\n\t};\n\t// Handle constructor so that \"params.type\" can be correctly pointed to \"outer\".\n\tcustomize.sectionConstructor.outer = customize.OuterSection;\n\n\treturn class InserterOuterSection extends customize.OuterSection {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\t// This is necessary since we're creating a new class which is not identical to the original OuterSection.\n\t\t\t// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436\n\t\t\tthis.params.type = 'outer';\n\n\t\t\tthis.activeElementBeforeExpanded = null;\n\n\t\t\tconst ownerWindow = this.contentContainer[ 0 ].ownerDocument\n\t\t\t\t.defaultView;\n\n\t\t\t// Handle closing the inserter when pressing the Escape key.\n\t\t\townerWindow.addEventListener(\n\t\t\t\t'keydown',\n\t\t\t\t( event ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.expanded() &&\n\t\t\t\t\t\t( event.keyCode === ESCAPE || event.code === 'Escape' )\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t// Use capture mode to make this run before other event listeners.\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tthis.contentContainer.addClass( 'widgets-inserter' );\n\n\t\t\t// Set a flag if the state is being changed from open() or close().\n\t\t\t// Don't propagate the event if it's an internal action to prevent infinite loop.\n\t\t\tthis.isFromInternalAction = false;\n\t\t\tthis.expanded.bind( () => {\n\t\t\t\tif ( ! this.isFromInternalAction ) {\n\t\t\t\t\t// Propagate the event to React to sync the state.\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tthis.expanded()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isFromInternalAction = false;\n\t\t\t} );\n\t\t}\n\t\topen() {\n\t\t\tif ( ! this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tthis.activeElementBeforeExpanded =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.expand( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// We have to do this in a \"completeCallback\" or else the elements will not yet be visible/tabbable.\n\t\t\t\t\t\t// The first one should be the close button,\n\t\t\t\t\t\t// we want to skip it and choose the second one instead, which is the search box.\n\t\t\t\t\t\tconst searchBox = focus.tabbable.find(\n\t\t\t\t\t\t\tcontentContainer\n\t\t\t\t\t\t)[ 1 ];\n\t\t\t\t\t\tif ( searchBox ) {\n\t\t\t\t\t\t\tsearchBox.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t\tclose() {\n\t\t\tif ( this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tconst activeElement =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.collapse( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t// Only do this if the active element which triggers the action is inside the inserter,\n\t\t\t\t\t\t// (the close button for instance). In that case the focus will be lost.\n\t\t\t\t\t\t// Otherwise, we don't hijack the focus when the user is focusing on other elements\n\t\t\t\t\t\t// (like the quick inserter).\n\t\t\t\t\t\tif ( contentContainer.contains( activeElement ) ) {\n\t\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t\tif ( this.activeElementBeforeExpanded ) {\n\t\t\t\t\t\t\t\tthis.activeElementBeforeExpanded.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};\n}\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { dispatch } from '@wordpress/data';
|
|
1
5
|
/**
|
|
2
6
|
* Internal dependencies
|
|
3
7
|
*/
|
|
8
|
+
|
|
4
9
|
import SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';
|
|
5
10
|
import getInserterOuterSection from './inserter-outer-section';
|
|
11
|
+
import { store as customizeWidgetsStore } from '../store';
|
|
6
12
|
|
|
7
13
|
const getInserterId = controlId => `widgets-inserter-${controlId}`;
|
|
8
14
|
|
|
@@ -38,7 +44,7 @@ export default function getSidebarControl() {
|
|
|
38
44
|
if (!args.unchanged) {
|
|
39
45
|
// Close the inserter when the section collapses.
|
|
40
46
|
if (!expanded) {
|
|
41
|
-
|
|
47
|
+
dispatch(customizeWidgetsStore).setIsInserterOpened(false);
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
this.subscribers.forEach(subscriber => subscriber(expanded, args));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/controls/sidebar-control.js"],"names":["SidebarAdapter","getInserterOuterSection","getInserterId","controlId","getSidebarControl","wp","customize","window","SidebarControl","Control","constructor","args","subscribers","Set","ready","InserterOuterSection","inserter","id","section","add","sectionInstance","inspector","sidebarAdapter","setting","subscribe","callback","delete","onChangeSectionExpanded","expanded","unchanged","
|
|
1
|
+
{"version":3,"sources":["@wordpress/customize-widgets/src/controls/sidebar-control.js"],"names":["dispatch","SidebarAdapter","getInserterOuterSection","store","customizeWidgetsStore","getInserterId","controlId","getSidebarControl","wp","customize","window","SidebarControl","Control","constructor","args","subscribers","Set","ready","InserterOuterSection","inserter","id","section","add","sectionInstance","inspector","sidebarAdapter","setting","subscribe","callback","delete","onChangeSectionExpanded","expanded","unchanged","setIsInserterOpened","forEach","subscriber"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QA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A,IAAI,CAACkB,SAAZ,EAAwB;AACvB;AACA,YAAK,CAAED,QAAP,EAAkB;AACjB/B,UAAAA,QAAQ,CAAEI,qBAAF,CAAR,CAAkC6B,mBAAlC,CACC,KADD;AAGA;;AAED,aAAKlB,WAAL,CAAiBmB,OAAjB,CAA4BC,UAAF,IACzBA,UAAU,CAAEJ,QAAF,EAAYjB,IAAZ,CADX;AAGA;AACD;;AA3CoD,GAAtD;AA6CA","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"]}
|
|
@@ -40,7 +40,9 @@ export default function getSidebarSection() {
|
|
|
40
40
|
var _args$completeCallbac;
|
|
41
41
|
|
|
42
42
|
controls.forEach(control => {
|
|
43
|
-
|
|
43
|
+
var _control$onChangeSect;
|
|
44
|
+
|
|
45
|
+
(_control$onChangeSect = control.onChangeSectionExpanded) === null || _control$onChangeSect === void 0 ? void 0 : _control$onChangeSect.call(control, expanded, args);
|
|
44
46
|
});
|
|
45
47
|
(_args$completeCallbac = _args.completeCallback) === null || _args$completeCallbac === void 0 ? void 0 : _args$completeCallbac.call(_args);
|
|
46
48
|
}
|