@wordpress/customize-widgets 5.57.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-appender/index.cjs +24 -41
- package/build/components/block-appender/index.cjs.map +1 -7
- package/build/components/block-inspector-button/index.cjs +24 -52
- package/build/components/block-inspector-button/index.cjs.map +1 -7
- package/build/components/customize-widgets/index.cjs +76 -95
- package/build/components/customize-widgets/index.cjs.map +1 -7
- package/build/components/customize-widgets/use-clear-selected-block.cjs +58 -67
- package/build/components/customize-widgets/use-clear-selected-block.cjs.map +1 -7
- package/build/components/error-boundary/index.cjs +115 -155
- package/build/components/error-boundary/index.cjs.map +1 -7
- package/build/components/focus-control/index.cjs +44 -84
- package/build/components/focus-control/index.cjs.map +1 -7
- package/build/components/focus-control/use-blocks-focus-control.cjs +28 -49
- package/build/components/focus-control/use-blocks-focus-control.cjs.map +1 -7
- package/build/components/header/index.cjs +84 -122
- package/build/components/header/index.cjs.map +1 -7
- package/build/components/inserter/index.cjs +43 -78
- package/build/components/inserter/index.cjs.map +1 -7
- package/build/components/inserter/use-inserter.cjs +22 -54
- package/build/components/inserter/use-inserter.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
- package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/index.cjs +103 -165
- package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -76
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcuts/index.cjs +70 -100
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
- package/build/components/more-menu/index.cjs +103 -151
- package/build/components/more-menu/index.cjs.map +1 -7
- package/build/components/sidebar-block-editor/index.cjs +122 -155
- package/build/components/sidebar-block-editor/index.cjs.map +1 -7
- package/build/components/sidebar-block-editor/sidebar-adapter.cjs +207 -270
- package/build/components/sidebar-block-editor/sidebar-adapter.cjs.map +1 -7
- package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs +40 -50
- package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs.map +1 -7
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs +75 -110
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs.map +1 -7
- package/build/components/sidebar-controls/index.cjs +27 -53
- package/build/components/sidebar-controls/index.cjs.map +1 -7
- package/build/components/welcome-guide/index.cjs +70 -94
- package/build/components/welcome-guide/index.cjs.map +1 -7
- package/build/controls/inserter-outer-section.cjs +68 -110
- package/build/controls/inserter-outer-section.cjs.map +1 -7
- package/build/controls/inspector-section.cjs +57 -90
- package/build/controls/inspector-section.cjs.map +1 -7
- package/build/controls/sidebar-control.cjs +55 -69
- package/build/controls/sidebar-control.cjs.map +1 -7
- package/build/controls/sidebar-section.cjs +79 -103
- package/build/controls/sidebar-section.cjs.map +1 -7
- package/build/filters/index.cjs +8 -5
- package/build/filters/move-to-sidebar.cjs +62 -78
- package/build/filters/move-to-sidebar.cjs.map +1 -7
- package/build/filters/replace-media-upload.cjs +11 -9
- package/build/filters/replace-media-upload.cjs.map +1 -7
- package/build/filters/wide-widget-display.cjs +20 -20
- package/build/filters/wide-widget-display.cjs.map +1 -7
- package/build/index.cjs +84 -91
- package/build/index.cjs.map +1 -7
- package/build/lock-unlock.cjs +10 -35
- package/build/lock-unlock.cjs.map +1 -7
- package/build/store/actions.cjs +49 -32
- package/build/store/actions.cjs.map +1 -7
- package/build/store/constants.cjs +12 -29
- package/build/store/constants.cjs.map +1 -7
- package/build/store/index.cjs +49 -41
- package/build/store/index.cjs.map +1 -7
- package/build/store/reducer.cjs +20 -33
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/selectors.cjs +47 -38
- package/build/store/selectors.cjs.map +1 -7
- package/build/utils.cjs +81 -108
- package/build/utils.cjs.map +1 -7
- package/build-module/components/block-appender/index.mjs +18 -23
- package/build-module/components/block-appender/index.mjs.map +1 -7
- package/build-module/components/block-inspector-button/index.mjs +15 -28
- package/build-module/components/block-inspector-button/index.mjs.map +1 -7
- package/build-module/components/customize-widgets/index.mjs +46 -72
- package/build-module/components/customize-widgets/index.mjs.map +1 -7
- package/build-module/components/customize-widgets/use-clear-selected-block.mjs +52 -46
- package/build-module/components/customize-widgets/use-clear-selected-block.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +103 -128
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/focus-control/index.mjs +37 -66
- package/build-module/components/focus-control/index.mjs.map +1 -7
- package/build-module/components/focus-control/use-blocks-focus-control.mjs +21 -27
- package/build-module/components/focus-control/use-blocks-focus-control.mjs.map +1 -7
- package/build-module/components/header/index.mjs +55 -92
- package/build-module/components/header/index.mjs.map +1 -7
- package/build-module/components/inserter/index.mjs +33 -53
- package/build-module/components/inserter/index.mjs.map +1 -7
- package/build-module/components/inserter/use-inserter.mjs +17 -34
- package/build-module/components/inserter/use-inserter.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs +75 -139
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -55
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcuts/index.mjs +62 -79
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
- package/build-module/components/more-menu/index.mjs +76 -128
- package/build-module/components/more-menu/index.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/index.mjs +86 -128
- package/build-module/components/sidebar-block-editor/index.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs +202 -250
- package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs +17 -25
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs +54 -86
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs.map +1 -7
- package/build-module/components/sidebar-controls/index.mjs +19 -27
- package/build-module/components/sidebar-controls/index.mjs.map +1 -7
- package/build-module/components/welcome-guide/index.mjs +62 -71
- package/build-module/components/welcome-guide/index.mjs.map +1 -7
- package/build-module/controls/inserter-outer-section.mjs +61 -88
- package/build-module/controls/inserter-outer-section.mjs.map +1 -7
- package/build-module/controls/inspector-section.mjs +52 -70
- package/build-module/controls/inspector-section.mjs.map +1 -7
- package/build-module/controls/sidebar-control.mjs +33 -45
- package/build-module/controls/sidebar-control.mjs.map +1 -7
- package/build-module/controls/sidebar-section.mjs +59 -80
- package/build-module/controls/sidebar-section.mjs.map +1 -7
- package/build-module/filters/index.mjs +0 -2
- package/build-module/filters/move-to-sidebar.mjs +52 -79
- package/build-module/filters/move-to-sidebar.mjs.map +1 -7
- package/build-module/filters/replace-media-upload.mjs +5 -8
- package/build-module/filters/replace-media-upload.mjs.map +1 -7
- package/build-module/filters/wide-widget-display.mjs +13 -18
- package/build-module/filters/wide-widget-display.mjs.map +1 -7
- package/build-module/index.mjs +53 -71
- package/build-module/index.mjs.map +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +44 -8
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/constants.mjs +7 -5
- package/build-module/store/constants.mjs.map +1 -7
- package/build-module/store/index.mjs +15 -11
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +15 -13
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +41 -13
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/utils.mjs +74 -82
- package/build-module/utils.mjs.map +1 -7
- package/package.json +30 -31
- package/src/components/customize-widgets/index.jsx +5 -2
- package/src/components/customize-widgets/use-clear-selected-block.js +2 -1
- package/src/components/welcome-guide/index.jsx +6 -2
- package/CHANGELOG.md +0 -289
- package/build/filters/index.cjs.map +0 -7
- package/build-module/filters/index.mjs.map +0 -7
package/build/store/reducer.cjs
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/customize-widgets/src/store/reducer.js
|
|
20
|
-
var reducer_exports = {};
|
|
21
|
-
__export(reducer_exports, {
|
|
22
|
-
default: () => reducer_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
let _wordpress_data = require("@wordpress/data");
|
|
7
|
+
// packages/customize-widgets/src/store/reducer.js
|
|
8
|
+
/**
|
|
9
|
+
* Reducer tracking whether the inserter is open.
|
|
10
|
+
*
|
|
11
|
+
* @param {boolean|Object} state
|
|
12
|
+
* @param {Object} action
|
|
13
|
+
*/
|
|
26
14
|
function blockInserterPanel(state = false, action) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return state;
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case "SET_IS_INSERTER_OPENED": return action.value;
|
|
17
|
+
}
|
|
18
|
+
return state;
|
|
32
19
|
}
|
|
33
|
-
var reducer_default = (0,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=reducer.cjs.map
|
|
20
|
+
var reducer_default = (0, _wordpress_data.combineReducers)({ blockInserterPanel });
|
|
21
|
+
exports.default = reducer_default;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=reducer.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/store/reducer.js"],
|
|
4
|
-
"sourcesContent": ["import { combineReducers } from '@wordpress/data';\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\nexport default combineReducers( {\n\tblockInserterPanel,\n} );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAQhC,SAAS,mBAAoB,QAAQ,OAAO,QAAS;AACpD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACR;AAEA,IAAO,sBAAQ,6BAAiB;AAAA,EAC/B;AACD,CAAE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"reducer.cjs","names":["combineReducers"],"sources":["../../src/store/reducer.js"],"sourcesContent":["import { combineReducers } from '@wordpress/data';\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\nexport default combineReducers( {\n\tblockInserterPanel,\n} );\n"],"mappings":";;;;;;;;;;;;;AAQA,SAAS,mBAAoB,QAAQ,OAAO,QAAS;CACpD,QAAS,OAAO,MAAhB;EACC,KAAK,0BACJ,OAAO,OAAO;CAChB;CACA,OAAO;AACR;AAEA,IAAA,mBAAA,GAAeA,gBAAAA,gBAAAA,CAAiB,EAC/B,mBACD,CAAE"}
|
|
@@ -1,44 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/customize-widgets/src/store/selectors.js
|
|
20
|
-
var selectors_exports = {};
|
|
21
|
-
__export(selectors_exports, {
|
|
22
|
-
__experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
|
|
23
|
-
isInserterOpened: () => isInserterOpened
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
5
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
// packages/customize-widgets/src/store/selectors.js
|
|
7
|
+
const EMPTY_INSERTION_POINT = {
|
|
8
|
+
rootClientId: void 0,
|
|
9
|
+
insertionIndex: void 0
|
|
29
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Returns true if the inserter is opened.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} state Global application state.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```js
|
|
18
|
+
* import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
|
|
19
|
+
* import { __ } from '@wordpress/i18n';
|
|
20
|
+
* import { useSelect } from '@wordpress/data';
|
|
21
|
+
*
|
|
22
|
+
* const ExampleComponent = () => {
|
|
23
|
+
* const { isInserterOpened } = useSelect(
|
|
24
|
+
* ( select ) => select( customizeWidgetsStore ),
|
|
25
|
+
* []
|
|
26
|
+
* );
|
|
27
|
+
*
|
|
28
|
+
* return isInserterOpened()
|
|
29
|
+
* ? __( 'Inserter is open' )
|
|
30
|
+
* : __( 'Inserter is closed.' );
|
|
31
|
+
* };
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @return {boolean} Whether the inserter is opened.
|
|
35
|
+
*/
|
|
30
36
|
function isInserterOpened(state) {
|
|
31
|
-
|
|
37
|
+
return !!state.blockInserterPanel;
|
|
32
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the insertion point for the inserter.
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} state Global application state.
|
|
43
|
+
*
|
|
44
|
+
* @return {Object} The root client ID and index to insert at.
|
|
45
|
+
*/
|
|
33
46
|
function __experimentalGetInsertionPoint(state) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
return state.blockInserterPanel;
|
|
47
|
+
if (typeof state.blockInserterPanel === "boolean") return EMPTY_INSERTION_POINT;
|
|
48
|
+
return state.blockInserterPanel;
|
|
38
49
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=selectors.cjs.map
|
|
50
|
+
exports.__experimentalGetInsertionPoint = __experimentalGetInsertionPoint;
|
|
51
|
+
exports.isInserterOpened = isInserterOpened;
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=selectors.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/store/selectors.js"],
|
|
4
|
-
"sourcesContent": ["const EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```js\n * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';\n * import { __ } from '@wordpress/i18n';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const { isInserterOpened } = useSelect(\n * ( select ) => select( customizeWidgetsStore ),\n * []\n * );\n *\n * return isInserterOpened()\n * ? __( 'Inserter is open' )\n * : __( 'Inserter is closed.' );\n * };\n * ```\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\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,wBAAwB;AAAA,EAC7B,cAAc;AAAA,EACd,gBAAgB;AACjB;AA2BO,SAAS,iBAAkB,OAAQ;AACzC,SAAO,CAAC,CAAE,MAAM;AACjB;AASO,SAAS,gCAAiC,OAAQ;AACxD,MAAK,OAAO,MAAM,uBAAuB,WAAY;AACpD,WAAO;AAAA,EACR;AAEA,SAAO,MAAM;AACd;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"selectors.cjs","names":[],"sources":["../../src/store/selectors.js"],"sourcesContent":["const EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```js\n * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';\n * import { __ } from '@wordpress/i18n';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const { isInserterOpened } = useSelect(\n * ( select ) => select( customizeWidgetsStore ),\n * []\n * );\n *\n * return isInserterOpened()\n * ? __( 'Inserter is open' )\n * : __( 'Inserter is closed.' );\n * };\n * ```\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\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n"],"mappings":";;;;;;AAAA,MAAM,wBAAwB;CAC7B,cAAc,KAAA;CACd,gBAAgB,KAAA;AACjB;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,iBAAkB,OAAQ;CACzC,OAAO,CAAC,CAAE,MAAM;AACjB;;;;;;;;AASA,SAAgB,gCAAiC,OAAQ;CACxD,IAAK,OAAO,MAAM,uBAAuB,WACxC,OAAO;CAGR,OAAO,MAAM;AACd"}
|
package/build/utils.cjs
CHANGED
|
@@ -1,115 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/customize-widgets/src/utils.js
|
|
20
|
-
var utils_exports = {};
|
|
21
|
-
__export(utils_exports, {
|
|
22
|
-
blockToWidget: () => blockToWidget,
|
|
23
|
-
settingIdToWidgetId: () => settingIdToWidgetId,
|
|
24
|
-
widgetToBlock: () => widgetToBlock
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
25
5
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
let _wordpress_blocks = require("@wordpress/blocks");
|
|
7
|
+
let _wordpress_widgets = require("@wordpress/widgets");
|
|
8
|
+
// packages/customize-widgets/src/utils.js
|
|
9
|
+
/**
|
|
10
|
+
* Convert settingId to widgetId.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} settingId The setting id.
|
|
13
|
+
* @return {string} The widget id.
|
|
14
|
+
*/
|
|
29
15
|
function settingIdToWidgetId(settingId) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const number = parseInt(matches[2], 10);
|
|
34
|
-
return `${idBase}-${number}`;
|
|
35
|
-
}
|
|
36
|
-
return settingId;
|
|
16
|
+
const matches = settingId.match(/^widget_(.+)(?:\[(\d+)\])$/);
|
|
17
|
+
if (matches) return `${matches[1]}-${parseInt(matches[2], 10)}`;
|
|
18
|
+
return settingId;
|
|
37
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Transform a block to a customizable widget.
|
|
22
|
+
*
|
|
23
|
+
* @param {WPBlock} block The block to be transformed from.
|
|
24
|
+
* @param {Object} existingWidget The widget to be extended from.
|
|
25
|
+
* @return {Object} The transformed widget.
|
|
26
|
+
*/
|
|
38
27
|
function blockToWidget(block, existingWidget = null) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
idBase: "block",
|
|
67
|
-
widgetClass: "WP_Widget_Block",
|
|
68
|
-
instance: {
|
|
69
|
-
raw_instance: instance
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
const { form, rendered, ...restExistingWidget } = existingWidget || {};
|
|
74
|
-
return {
|
|
75
|
-
...restExistingWidget,
|
|
76
|
-
...widget
|
|
77
|
-
};
|
|
28
|
+
let widget;
|
|
29
|
+
if (block.name === "core/legacy-widget" && (block.attributes.id || block.attributes.instance)) {
|
|
30
|
+
if (block.attributes.id) widget = { id: block.attributes.id };
|
|
31
|
+
else {
|
|
32
|
+
const { encoded, hash, raw, ...rest } = block.attributes.instance;
|
|
33
|
+
widget = {
|
|
34
|
+
idBase: block.attributes.idBase,
|
|
35
|
+
instance: {
|
|
36
|
+
...existingWidget?.instance,
|
|
37
|
+
is_widget_customizer_js_value: true,
|
|
38
|
+
encoded_serialized_instance: encoded,
|
|
39
|
+
instance_hash_key: hash,
|
|
40
|
+
raw_instance: raw,
|
|
41
|
+
...rest
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
} else widget = {
|
|
46
|
+
idBase: "block",
|
|
47
|
+
widgetClass: "WP_Widget_Block",
|
|
48
|
+
instance: { raw_instance: { content: (0, _wordpress_blocks.serialize)(block) } }
|
|
49
|
+
};
|
|
50
|
+
const { form, rendered, ...restExistingWidget } = existingWidget || {};
|
|
51
|
+
return {
|
|
52
|
+
...restExistingWidget,
|
|
53
|
+
...widget
|
|
54
|
+
};
|
|
78
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Transform a widget to a block.
|
|
58
|
+
*
|
|
59
|
+
* @param {Object} widget The widget to be transformed from.
|
|
60
|
+
* @param {string} widget.id The widget id.
|
|
61
|
+
* @param {string} widget.idBase The id base of the widget.
|
|
62
|
+
* @param {number} widget.number The number/index of the widget.
|
|
63
|
+
* @param {Object} widget.instance The instance of the widget.
|
|
64
|
+
* @return {WPBlock} The transformed block.
|
|
65
|
+
*/
|
|
79
66
|
function widgetToBlock({ id, idBase, number, instance }) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
encoded,
|
|
97
|
-
hash,
|
|
98
|
-
raw,
|
|
99
|
-
...rest
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
block = (0, import_blocks.createBlock)("core/legacy-widget", {
|
|
104
|
-
id
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return (0, import_widgets.addWidgetIdToBlock)(block, id);
|
|
67
|
+
let block;
|
|
68
|
+
const { encoded_serialized_instance: encoded, instance_hash_key: hash, raw_instance: raw, ...rest } = instance;
|
|
69
|
+
if (idBase === "block") {
|
|
70
|
+
const parsedBlocks = (0, _wordpress_blocks.parse)(raw.content ?? "", { __unstableSkipAutop: true });
|
|
71
|
+
block = parsedBlocks.length ? parsedBlocks[0] : (0, _wordpress_blocks.createBlock)("core/paragraph", {});
|
|
72
|
+
} else if (number) block = (0, _wordpress_blocks.createBlock)("core/legacy-widget", {
|
|
73
|
+
idBase,
|
|
74
|
+
instance: {
|
|
75
|
+
encoded,
|
|
76
|
+
hash,
|
|
77
|
+
raw,
|
|
78
|
+
...rest
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
else block = (0, _wordpress_blocks.createBlock)("core/legacy-widget", { id });
|
|
82
|
+
return (0, _wordpress_widgets.addWidgetIdToBlock)(block, id);
|
|
108
83
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
//# sourceMappingURL=utils.cjs.map
|
|
84
|
+
exports.blockToWidget = blockToWidget;
|
|
85
|
+
exports.settingIdToWidgetId = settingIdToWidgetId;
|
|
86
|
+
exports.widgetToBlock = widgetToBlock;
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=utils.cjs.map
|
package/build/utils.cjs.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/utils.js"],
|
|
4
|
-
"sourcesContent": ["// @ts-check\nimport { serialize, parse, createBlock } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Convert settingId to widgetId.\n *\n * @param {string} settingId The setting id.\n * @return {string} The widget id.\n */\nexport function settingIdToWidgetId( settingId ) {\n\tconst matches = settingId.match( /^widget_(.+)(?:\\[(\\d+)\\])$/ );\n\n\tif ( matches ) {\n\t\tconst idBase = matches[ 1 ];\n\t\tconst number = parseInt( matches[ 2 ], 10 );\n\n\t\treturn `${ idBase }-${ number }`;\n\t}\n\n\treturn settingId;\n}\n\n/**\n * Transform a block to a customizable widget.\n *\n * @param {WPBlock} block The block to be transformed from.\n * @param {Object} existingWidget The widget to be extended from.\n * @return {Object} The transformed widget.\n */\nexport function blockToWidget( block, existingWidget = null ) {\n\tlet widget;\n\n\tconst isValidLegacyWidgetBlock =\n\t\tblock.name === 'core/legacy-widget' &&\n\t\t( block.attributes.id || block.attributes.instance );\n\n\tif ( isValidLegacyWidgetBlock ) {\n\t\tif ( block.attributes.id ) {\n\t\t\t// Widget that does not extend WP_Widget.\n\t\t\twidget = {\n\t\t\t\tid: block.attributes.id,\n\t\t\t};\n\t\t} else {\n\t\t\tconst { encoded, hash, raw, ...rest } = block.attributes.instance;\n\n\t\t\t// Widget that extends WP_Widget.\n\t\t\twidget = {\n\t\t\t\tidBase: block.attributes.idBase,\n\t\t\t\tinstance: {\n\t\t\t\t\t...existingWidget?.instance,\n\t\t\t\t\t// Required only for the customizer.\n\t\t\t\t\tis_widget_customizer_js_value: true,\n\t\t\t\t\tencoded_serialized_instance: encoded,\n\t\t\t\t\tinstance_hash_key: hash,\n\t\t\t\t\traw_instance: raw,\n\t\t\t\t\t...rest,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t} else {\n\t\tconst instance = {\n\t\t\tcontent: serialize( block ),\n\t\t};\n\t\twidget = {\n\t\t\tidBase: 'block',\n\t\t\twidgetClass: 'WP_Widget_Block',\n\t\t\tinstance: {\n\t\t\t\traw_instance: instance,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst { form, rendered, ...restExistingWidget } = existingWidget || {};\n\n\treturn {\n\t\t...restExistingWidget,\n\t\t...widget,\n\t};\n}\n\n/**\n * Transform a widget to a block.\n *\n * @param {Object} widget The widget to be transformed from.\n * @param {string} widget.id The widget id.\n * @param {string} widget.idBase The id base of the widget.\n * @param {number} widget.number The number/index of the widget.\n * @param {Object} widget.instance The instance of the widget.\n * @return {WPBlock} The transformed block.\n */\nexport function widgetToBlock( { id, idBase, number, instance } ) {\n\tlet block;\n\n\tconst {\n\t\tencoded_serialized_instance: encoded,\n\t\tinstance_hash_key: hash,\n\t\traw_instance: raw,\n\t\t...rest\n\t} = instance;\n\n\tif ( idBase === 'block' ) {\n\t\tconst parsedBlocks = parse( raw.content ?? '', {\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tblock = parsedBlocks.length\n\t\t\t? parsedBlocks[ 0 ]\n\t\t\t: createBlock( 'core/paragraph', {} );\n\t} else if ( number ) {\n\t\t// Widget that extends WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tidBase,\n\t\t\tinstance: {\n\t\t\t\tencoded,\n\t\t\t\thash,\n\t\t\t\traw,\n\t\t\t\t...rest,\n\t\t\t},\n\t\t} );\n\t} else {\n\t\t// Widget that does not extend WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tid,\n\t\t} );\n\t}\n\n\treturn addWidgetIdToBlock( block, id );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8C;AAC9C,qBAAmC;AAQ5B,SAAS,oBAAqB,WAAY;AAChD,QAAM,UAAU,UAAU,MAAO,4BAA6B;AAE9D,MAAK,SAAU;AACd,UAAM,SAAS,QAAS,CAAE;AAC1B,UAAM,SAAS,SAAU,QAAS,CAAE,GAAG,EAAG;AAE1C,WAAO,GAAI,MAAO,IAAK,MAAO;AAAA,EAC/B;AAEA,SAAO;AACR;AASO,SAAS,cAAe,OAAO,iBAAiB,MAAO;AAC7D,MAAI;AAEJ,QAAM,2BACL,MAAM,SAAS,yBACb,MAAM,WAAW,MAAM,MAAM,WAAW;AAE3C,MAAK,0BAA2B;AAC/B,QAAK,MAAM,WAAW,IAAK;AAE1B,eAAS;AAAA,QACR,IAAI,MAAM,WAAW;AAAA,MACtB;AAAA,IACD,OAAO;AACN,YAAM,EAAE,SAAS,MAAM,KAAK,GAAG,KAAK,IAAI,MAAM,WAAW;AAGzD,eAAS;AAAA,QACR,QAAQ,MAAM,WAAW;AAAA,QACzB,UAAU;AAAA,UACT,GAAG,gBAAgB;AAAA;AAAA,UAEnB,+BAA+B;AAAA,UAC/B,6BAA6B;AAAA,UAC7B,mBAAmB;AAAA,UACnB,cAAc;AAAA,UACd,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,EACD,OAAO;AACN,UAAM,WAAW;AAAA,MAChB,aAAS,yBAAW,KAAM;AAAA,IAC3B;AACA,aAAS;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,UAAU;AAAA,QACT,cAAc;AAAA,MACf;AAAA,IACD;AAAA,EACD;AAEA,QAAM,EAAE,MAAM,UAAU,GAAG,mBAAmB,IAAI,kBAAkB,CAAC;AAErE,SAAO;AAAA,IACN,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AACD;AAYO,SAAS,cAAe,EAAE,IAAI,QAAQ,QAAQ,SAAS,GAAI;AACjE,MAAI;AAEJ,QAAM;AAAA,IACL,6BAA6B;AAAA,IAC7B,mBAAmB;AAAA,IACnB,cAAc;AAAA,IACd,GAAG;AAAA,EACJ,IAAI;AAEJ,MAAK,WAAW,SAAU;AACzB,UAAM,mBAAe,qBAAO,IAAI,WAAW,IAAI;AAAA,MAC9C,qBAAqB;AAAA,IACtB,CAAE;AACF,YAAQ,aAAa,SAClB,aAAc,CAAE,QAChB,2BAAa,kBAAkB,CAAC,CAAE;AAAA,EACtC,WAAY,QAAS;AAEpB,gBAAQ,2BAAa,sBAAsB;AAAA,MAC1C;AAAA,MACA,UAAU;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACJ;AAAA,IACD,CAAE;AAAA,EACH,OAAO;AAEN,gBAAQ,2BAAa,sBAAsB;AAAA,MAC1C;AAAA,IACD,CAAE;AAAA,EACH;AAEA,aAAO,mCAAoB,OAAO,EAAG;AACtC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["serialize","parse","createBlock","addWidgetIdToBlock"],"sources":["../src/utils.js"],"sourcesContent":["// @ts-check\nimport { serialize, parse, createBlock } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Convert settingId to widgetId.\n *\n * @param {string} settingId The setting id.\n * @return {string} The widget id.\n */\nexport function settingIdToWidgetId( settingId ) {\n\tconst matches = settingId.match( /^widget_(.+)(?:\\[(\\d+)\\])$/ );\n\n\tif ( matches ) {\n\t\tconst idBase = matches[ 1 ];\n\t\tconst number = parseInt( matches[ 2 ], 10 );\n\n\t\treturn `${ idBase }-${ number }`;\n\t}\n\n\treturn settingId;\n}\n\n/**\n * Transform a block to a customizable widget.\n *\n * @param {WPBlock} block The block to be transformed from.\n * @param {Object} existingWidget The widget to be extended from.\n * @return {Object} The transformed widget.\n */\nexport function blockToWidget( block, existingWidget = null ) {\n\tlet widget;\n\n\tconst isValidLegacyWidgetBlock =\n\t\tblock.name === 'core/legacy-widget' &&\n\t\t( block.attributes.id || block.attributes.instance );\n\n\tif ( isValidLegacyWidgetBlock ) {\n\t\tif ( block.attributes.id ) {\n\t\t\t// Widget that does not extend WP_Widget.\n\t\t\twidget = {\n\t\t\t\tid: block.attributes.id,\n\t\t\t};\n\t\t} else {\n\t\t\tconst { encoded, hash, raw, ...rest } = block.attributes.instance;\n\n\t\t\t// Widget that extends WP_Widget.\n\t\t\twidget = {\n\t\t\t\tidBase: block.attributes.idBase,\n\t\t\t\tinstance: {\n\t\t\t\t\t...existingWidget?.instance,\n\t\t\t\t\t// Required only for the customizer.\n\t\t\t\t\tis_widget_customizer_js_value: true,\n\t\t\t\t\tencoded_serialized_instance: encoded,\n\t\t\t\t\tinstance_hash_key: hash,\n\t\t\t\t\traw_instance: raw,\n\t\t\t\t\t...rest,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t} else {\n\t\tconst instance = {\n\t\t\tcontent: serialize( block ),\n\t\t};\n\t\twidget = {\n\t\t\tidBase: 'block',\n\t\t\twidgetClass: 'WP_Widget_Block',\n\t\t\tinstance: {\n\t\t\t\traw_instance: instance,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst { form, rendered, ...restExistingWidget } = existingWidget || {};\n\n\treturn {\n\t\t...restExistingWidget,\n\t\t...widget,\n\t};\n}\n\n/**\n * Transform a widget to a block.\n *\n * @param {Object} widget The widget to be transformed from.\n * @param {string} widget.id The widget id.\n * @param {string} widget.idBase The id base of the widget.\n * @param {number} widget.number The number/index of the widget.\n * @param {Object} widget.instance The instance of the widget.\n * @return {WPBlock} The transformed block.\n */\nexport function widgetToBlock( { id, idBase, number, instance } ) {\n\tlet block;\n\n\tconst {\n\t\tencoded_serialized_instance: encoded,\n\t\tinstance_hash_key: hash,\n\t\traw_instance: raw,\n\t\t...rest\n\t} = instance;\n\n\tif ( idBase === 'block' ) {\n\t\tconst parsedBlocks = parse( raw.content ?? '', {\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tblock = parsedBlocks.length\n\t\t\t? parsedBlocks[ 0 ]\n\t\t\t: createBlock( 'core/paragraph', {} );\n\t} else if ( number ) {\n\t\t// Widget that extends WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tidBase,\n\t\t\tinstance: {\n\t\t\t\tencoded,\n\t\t\t\thash,\n\t\t\t\traw,\n\t\t\t\t...rest,\n\t\t\t},\n\t\t} );\n\t} else {\n\t\t// Widget that does not extend WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tid,\n\t\t} );\n\t}\n\n\treturn addWidgetIdToBlock( block, id );\n}\n"],"mappings":";;;;;;;;;;;;;;AAUA,SAAgB,oBAAqB,WAAY;CAChD,MAAM,UAAU,UAAU,MAAO,4BAA6B;CAE9D,IAAK,SAIJ,OAAO,GAHQ,QAAS,GAGL,GAFJ,SAAU,QAAS,IAAK,EAEX;CAG7B,OAAO;AACR;;;;;;;;AASA,SAAgB,cAAe,OAAO,iBAAiB,MAAO;CAC7D,IAAI;CAMJ,IAHC,MAAM,SAAS,yBACb,MAAM,WAAW,MAAM,MAAM,WAAW,WAEX;EAC/B,IAAK,MAAM,WAAW,IAErB,SAAS,EACR,IAAI,MAAM,WAAW,GACtB;OACM;GACN,MAAM,EAAE,SAAS,MAAM,KAAK,GAAG,SAAS,MAAM,WAAW;GAGzD,SAAS;IACR,QAAQ,MAAM,WAAW;IACzB,UAAU;KACT,GAAG,gBAAgB;KAEnB,+BAA+B;KAC/B,6BAA6B;KAC7B,mBAAmB;KACnB,cAAc;KACd,GAAG;IACJ;GACD;EACD;CACD,OAIC,SAAS;EACR,QAAQ;EACR,aAAa;EACb,UAAU,EACT,cAAc,EANf,UAAA,GAASA,kBAAAA,UAAAA,CAAW,KAAM,EAMJ,EACtB;CACD;CAGD,MAAM,EAAE,MAAM,UAAU,GAAG,uBAAuB,kBAAkB,CAAC;CAErE,OAAO;EACN,GAAG;EACH,GAAG;CACJ;AACD;;;;;;;;;;;AAYA,SAAgB,cAAe,EAAE,IAAI,QAAQ,QAAQ,YAAa;CACjE,IAAI;CAEJ,MAAM,EACL,6BAA6B,SAC7B,mBAAmB,MACnB,cAAc,KACd,GAAG,SACA;CAEJ,IAAK,WAAW,SAAU;EACzB,MAAM,gBAAA,GAAeC,kBAAAA,MAAAA,CAAO,IAAI,WAAW,IAAI,EAC9C,qBAAqB,KACtB,CAAE;EACF,QAAQ,aAAa,SAClB,aAAc,MAAA,GACdC,kBAAAA,YAAAA,CAAa,kBAAkB,CAAC,CAAE;CACtC,OAAO,IAAK,QAEX,SAAA,GAAQA,kBAAAA,YAAAA,CAAa,sBAAsB;EAC1C;EACA,UAAU;GACT;GACA;GACA;GACA,GAAG;EACJ;CACD,CAAE;MAGF,SAAA,GAAQA,kBAAAA,YAAAA,CAAa,sBAAsB,EAC1C,GACD,CAAE;CAGH,QAAA,GAAOC,mBAAAA,mBAAAA,CAAoB,OAAO,EAAG;AACtC"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
ButtonBlockAppender,
|
|
5
|
-
store as blockEditorStore
|
|
6
|
-
} from "@wordpress/block-editor";
|
|
1
|
+
import { useEffect, useRef } from "@wordpress/element";
|
|
2
|
+
import { ButtonBlockAppender, store } from "@wordpress/block-editor";
|
|
7
3
|
import { useSelect } from "@wordpress/data";
|
|
8
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// packages/customize-widgets/src/components/block-appender/index.jsx
|
|
9
6
|
function BlockAppender(props) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return /* @__PURE__ */ jsx(ButtonBlockAppender, { ...props, ref });
|
|
7
|
+
const ref = useRef();
|
|
8
|
+
const isBlocksListEmpty = useSelect((select) => select(store).getBlockCount() === 0);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (isBlocksListEmpty && ref.current) {
|
|
11
|
+
const { ownerDocument } = ref.current;
|
|
12
|
+
if (!ownerDocument.activeElement || ownerDocument.activeElement === ownerDocument.body) ref.current.focus();
|
|
13
|
+
}
|
|
14
|
+
}, [isBlocksListEmpty]);
|
|
15
|
+
return /* @__PURE__ */ jsx(ButtonBlockAppender, {
|
|
16
|
+
...props,
|
|
17
|
+
ref
|
|
18
|
+
});
|
|
23
19
|
}
|
|
24
|
-
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=index.mjs.map
|
|
20
|
+
export { BlockAppender as default };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-appender/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { useRef, useEffect } from '@wordpress/element';\nimport {\n\tButtonBlockAppender,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function BlockAppender( props ) {\n\tconst ref = useRef();\n\tconst isBlocksListEmpty = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockCount() === 0\n\t);\n\n\t// Move the focus to the block appender to prevent focus from\n\t// being lost when emptying the widget area.\n\tuseEffect( () => {\n\t\tif ( isBlocksListEmpty && ref.current ) {\n\t\t\tconst { ownerDocument } = ref.current;\n\n\t\t\tif (\n\t\t\t\t! ownerDocument.activeElement ||\n\t\t\t\townerDocument.activeElement === ownerDocument.body\n\t\t\t) {\n\t\t\t\tref.current.focus();\n\t\t\t}\n\t\t}\n\t}, [ isBlocksListEmpty ] );\n\n\treturn <ButtonBlockAppender { ...props } ref={ ref } />;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,QAAQ,iBAAiB;AAClC;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAuBlB;AArBO,SAAR,cAAgC,OAAQ;AAC9C,QAAM,MAAM,OAAO;AACnB,QAAM,oBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,cAAc,MAAM;AAAA,EAC9D;AAIA,YAAW,MAAM;AAChB,QAAK,qBAAqB,IAAI,SAAU;AACvC,YAAM,EAAE,cAAc,IAAI,IAAI;AAE9B,UACC,CAAE,cAAc,iBAChB,cAAc,kBAAkB,cAAc,MAC7C;AACD,YAAI,QAAQ,MAAM;AAAA,MACnB;AAAA,IACD;AAAA,EACD,GAAG,CAAE,iBAAkB,CAAE;AAEzB,SAAO,oBAAC,uBAAsB,GAAG,OAAQ,KAAY;AACtD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["blockEditorStore"],"sources":["../../../src/components/block-appender/index.jsx"],"sourcesContent":["import { useRef, useEffect } from '@wordpress/element';\nimport {\n\tButtonBlockAppender,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function BlockAppender( props ) {\n\tconst ref = useRef();\n\tconst isBlocksListEmpty = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockCount() === 0\n\t);\n\n\t// Move the focus to the block appender to prevent focus from\n\t// being lost when emptying the widget area.\n\tuseEffect( () => {\n\t\tif ( isBlocksListEmpty && ref.current ) {\n\t\t\tconst { ownerDocument } = ref.current;\n\n\t\t\tif (\n\t\t\t\t! ownerDocument.activeElement ||\n\t\t\t\townerDocument.activeElement === ownerDocument.body\n\t\t\t) {\n\t\t\t\tref.current.focus();\n\t\t\t}\n\t\t}\n\t}, [ isBlocksListEmpty ] );\n\n\treturn <ButtonBlockAppender { ...props } ref={ ref } />;\n}\n"],"mappings":";;;;;AAOA,SAAwB,cAAe,OAAQ;CAC9C,MAAM,MAAM,OAAO;CACnB,MAAM,oBAAoB,WACvB,WAAY,OAAQA,KAAiB,CAAC,CAAC,cAAc,MAAM,CAC9D;CAIA,gBAAiB;EAChB,IAAK,qBAAqB,IAAI,SAAU;GACvC,MAAM,EAAE,kBAAkB,IAAI;GAE9B,IACC,CAAE,cAAc,iBAChB,cAAc,kBAAkB,cAAc,MAE9C,IAAI,QAAQ,MAAM;EAEpB;CACD,GAAG,CAAE,iBAAkB,CAAE;CAEzB,OAAO,oBAAC,qBAAD;EAAqB,GAAK;EAAc;CAAO,CAAA;AACvD"}
|
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
// packages/customize-widgets/src/components/block-inspector-button/index.jsx
|
|
2
1
|
import { useMemo } from "@wordpress/element";
|
|
3
2
|
import { __ } from "@wordpress/i18n";
|
|
4
3
|
import { MenuItem } from "@wordpress/components";
|
|
5
4
|
import { useSelect } from "@wordpress/data";
|
|
6
|
-
import { store
|
|
5
|
+
import { store } from "@wordpress/block-editor";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// packages/customize-widgets/src/components/block-inspector-button/index.jsx
|
|
8
8
|
function BlockInspectorButton({ inspector, closeMenu, ...props }) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
onClick: () => {
|
|
21
|
-
inspector.open({
|
|
22
|
-
returnFocusWhenClose: selectedBlock
|
|
23
|
-
});
|
|
24
|
-
closeMenu();
|
|
25
|
-
},
|
|
26
|
-
...props,
|
|
27
|
-
children: __("Show more settings")
|
|
28
|
-
}
|
|
29
|
-
);
|
|
9
|
+
const selectedBlockClientId = useSelect((select) => select(store).getSelectedBlockClientId(), []);
|
|
10
|
+
const selectedBlock = useMemo(() => document.getElementById(`block-${selectedBlockClientId}`), [selectedBlockClientId]);
|
|
11
|
+
return /* @__PURE__ */ jsx(MenuItem, {
|
|
12
|
+
onClick: () => {
|
|
13
|
+
inspector.open({ returnFocusWhenClose: selectedBlock });
|
|
14
|
+
closeMenu();
|
|
15
|
+
},
|
|
16
|
+
...props,
|
|
17
|
+
children: __("Show more settings")
|
|
18
|
+
});
|
|
30
19
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=index.mjs.map
|
|
20
|
+
export { BlockInspectorButton as default };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-inspector-button/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction BlockInspectorButton( { inspector, closeMenu, ...props } ) {\n\tconst selectedBlockClientId = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSelectedBlockClientId(),\n\t\t[]\n\t);\n\n\tconst selectedBlock = useMemo(\n\t\t() => document.getElementById( `block-${ selectedBlockClientId }` ),\n\t\t[ selectedBlockClientId ]\n\t);\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\t// Open the inspector.\n\t\t\t\tinspector.open( {\n\t\t\t\t\treturnFocusWhenClose: selectedBlock,\n\t\t\t\t} );\n\t\t\t\t// Then close the dropdown menu.\n\t\t\t\tcloseMenu();\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ __( 'Show more settings' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default BlockInspectorButton;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAcxC;AAZF,SAAS,qBAAsB,EAAE,WAAW,WAAW,GAAG,MAAM,GAAI;AACnE,QAAM,wBAAwB;AAAA,IAC7B,CAAE,WAAY,OAAQ,gBAAiB,EAAE,yBAAyB;AAAA,IAClE,CAAC;AAAA,EACF;AAEA,QAAM,gBAAgB;AAAA,IACrB,MAAM,SAAS,eAAgB,SAAU,qBAAsB,EAAG;AAAA,IAClE,CAAE,qBAAsB;AAAA,EACzB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM;AAEf,kBAAU,KAAM;AAAA,UACf,sBAAsB;AAAA,QACvB,CAAE;AAEF,kBAAU;AAAA,MACX;AAAA,MACE,GAAG;AAAA,MAEH,aAAI,oBAAqB;AAAA;AAAA,EAC5B;AAEF;AAEA,IAAO,iCAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["blockEditorStore"],"sources":["../../../src/components/block-inspector-button/index.jsx"],"sourcesContent":["import { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction BlockInspectorButton( { inspector, closeMenu, ...props } ) {\n\tconst selectedBlockClientId = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSelectedBlockClientId(),\n\t\t[]\n\t);\n\n\tconst selectedBlock = useMemo(\n\t\t() => document.getElementById( `block-${ selectedBlockClientId }` ),\n\t\t[ selectedBlockClientId ]\n\t);\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\t// Open the inspector.\n\t\t\t\tinspector.open( {\n\t\t\t\t\treturnFocusWhenClose: selectedBlock,\n\t\t\t\t} );\n\t\t\t\t// Then close the dropdown menu.\n\t\t\t\tcloseMenu();\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ __( 'Show more settings' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default BlockInspectorButton;\n"],"mappings":";;;;;;;AAMA,SAAS,qBAAsB,EAAE,WAAW,WAAW,GAAG,SAAU;CACnE,MAAM,wBAAwB,WAC3B,WAAY,OAAQA,KAAiB,CAAC,CAAC,yBAAyB,GAClE,CAAC,CACF;CAEA,MAAM,gBAAgB,cACf,SAAS,eAAgB,SAAU,uBAAyB,GAClE,CAAE,qBAAsB,CACzB;CAEA,OACC,oBAAC,UAAD;EACC,eAAgB;GAEf,UAAU,KAAM,EACf,sBAAsB,cACvB,CAAE;GAEF,UAAU;EACX;EACA,GAAK;EAEH,UAAA,GAAI,oBAAqB;CAClB,CAAA;AAEZ"}
|