@wordpress/edit-widgets 6.34.0 → 6.34.1-next.2f1c7c01b.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/blocks/widget-area/edit/index.js +4 -2
- package/build/blocks/widget-area/edit/index.js.map +1 -1
- package/build/blocks/widget-area/edit/inner-blocks.js +3 -1
- package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js +3 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
- package/build/blocks/widget-area/index.js +4 -2
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build/components/error-boundary/index.js +5 -3
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/header/document-tools/index.js +3 -1
- package/build/components/header/document-tools/index.js.map +1 -1
- package/build/components/header/index.js +3 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +3 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +3 -1
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +3 -1
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +3 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +6 -4
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +3 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +3 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/interface.js +4 -2
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/layout/unsaved-changes-warning.js +2 -0
- package/build/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build/components/more-menu/index.js +3 -1
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/more-menu/tools-more-menu-group.js +4 -2
- package/build/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build/components/notices/index.js +4 -2
- package/build/components/notices/index.js.map +1 -1
- package/build/components/save-button/index.js +3 -1
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/index.js +3 -1
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +3 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +3 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +7 -5
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/widget-areas.js +3 -1
- package/build/components/sidebar/widget-areas.js.map +1 -1
- package/build/components/welcome-guide/index.js +3 -1
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-content/index.js +3 -1
- package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +7 -5
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build/constants.js +4 -2
- package/build/constants.js.map +1 -1
- package/build/filters/index.js +1 -0
- package/build/filters/index.js.map +1 -1
- package/build/filters/move-to-widget-area.js +3 -2
- package/build/filters/move-to-widget-area.js.map +1 -1
- package/build/filters/replace-media-upload.js +3 -2
- package/build/filters/replace-media-upload.js.map +1 -1
- package/build/hooks/use-last-selected-widget-area.js +3 -1
- package/build/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build/hooks/use-widget-library-insertion-point.js +3 -1
- package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build/index.js +6 -4
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +9 -7
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +3 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +4 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-selectors.js +2 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +2 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +4 -2
- package/build/store/resolvers.js.map +1 -1
- package/build/store/selectors.js +13 -11
- package/build/store/selectors.js.map +1 -1
- package/build/store/transformers.js +2 -0
- package/build/store/transformers.js.map +1 -1
- package/build/store/utils.js +8 -6
- package/build/store/utils.js.map +1 -1
- package/build-module/blocks/widget-area/edit/index.js +3 -2
- package/build-module/blocks/widget-area/edit/index.js.map +1 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js +2 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +2 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +3 -2
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +4 -3
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/header/document-tools/index.js +2 -1
- package/build-module/components/header/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +2 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +2 -1
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +2 -1
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +2 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +2 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -4
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +5 -4
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +2 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/interface.js +3 -2
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/layout/unsaved-changes-warning.js +1 -0
- package/build-module/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build-module/components/more-menu/index.js +2 -1
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/more-menu/tools-more-menu-group.js +3 -2
- package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build-module/components/notices/index.js +3 -2
- package/build-module/components/notices/index.js.map +1 -1
- package/build-module/components/save-button/index.js +2 -1
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js +2 -1
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +9 -8
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/widget-areas.js +2 -1
- package/build-module/components/sidebar/widget-areas.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +2 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +2 -1
- package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +6 -5
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/constants.js +3 -2
- package/build-module/constants.js.map +1 -1
- package/build-module/filters/index.js +1 -0
- package/build-module/filters/index.js.map +1 -1
- package/build-module/filters/move-to-widget-area.js +3 -2
- package/build-module/filters/move-to-widget-area.js.map +1 -1
- package/build-module/filters/replace-media-upload.js +3 -2
- package/build-module/filters/replace-media-upload.js.map +1 -1
- package/build-module/hooks/use-last-selected-widget-area.js +2 -1
- package/build-module/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build-module/hooks/use-widget-library-insertion-point.js +2 -1
- package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build-module/index.js +6 -5
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +8 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +2 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +3 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +3 -2
- package/build-module/store/resolvers.js.map +1 -1
- package/build-module/store/selectors.js +12 -11
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/transformers.js +1 -0
- package/build-module/store/transformers.js.map +1 -1
- package/build-module/store/utils.js +7 -6
- package/build-module/store/utils.js.map +1 -1
- package/package.json +29 -29
package/build/store/resolvers.js
CHANGED
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/edit-widgets/src/store/resolvers.js
|
|
18
20
|
var resolvers_exports = {};
|
|
19
21
|
__export(resolvers_exports, {
|
|
20
22
|
getWidgetAreas: () => getWidgetAreas,
|
|
@@ -26,7 +28,7 @@ var import_core_data = require("@wordpress/core-data");
|
|
|
26
28
|
var import_actions = require("./actions");
|
|
27
29
|
var import_utils = require("./utils");
|
|
28
30
|
var import_transformers = require("./transformers");
|
|
29
|
-
|
|
31
|
+
var getWidgetAreas = () => async ({ dispatch, registry }) => {
|
|
30
32
|
const query = (0, import_utils.buildWidgetAreasQuery)();
|
|
31
33
|
const widgetAreas = await registry.resolveSelect(import_core_data.store).getEntityRecords(import_utils.KIND, import_utils.WIDGET_AREA_ENTITY_TYPE, query);
|
|
32
34
|
const widgetAreaBlocks = [];
|
|
@@ -64,7 +66,7 @@ const getWidgetAreas = () => async ({ dispatch, registry }) => {
|
|
|
64
66
|
(0, import_actions.persistStubPost)((0, import_utils.buildWidgetAreasPostId)(), widgetAreaBlocks)
|
|
65
67
|
);
|
|
66
68
|
};
|
|
67
|
-
|
|
69
|
+
var getWidgets = () => async ({ dispatch, registry }) => {
|
|
68
70
|
const query = (0, import_utils.buildWidgetsQuery)();
|
|
69
71
|
const widgets = await registry.resolveSelect(import_core_data.store).getEntityRecords("root", "widget", query);
|
|
70
72
|
const groupedBySidebar = {};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/resolvers.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { persistStubPost, setWidgetAreasOpenState } from './actions';\nimport {\n\tKIND,\n\tWIDGET_AREA_ENTITY_TYPE,\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasPostId,\n} from './utils';\nimport { transformWidgetToBlock } from './transformers';\n\n/**\n * Creates a \"stub\" widgets post reflecting all available widget areas. The\n * post is meant as a convenient to only exists in runtime and should never be saved. It\n * enables a convenient way of editing the widgets by using a regular post editor.\n *\n * Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgetAreas =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetAreasQuery();\n\t\tconst widgetAreas = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( KIND, WIDGET_AREA_ENTITY_TYPE, query );\n\n\t\tconst widgetAreaBlocks = [];\n\t\tconst sortedWidgetAreas = widgetAreas.sort( ( a, b ) => {\n\t\t\tif ( a.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif ( b.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t} );\n\t\tfor ( const widgetArea of sortedWidgetAreas ) {\n\t\t\twidgetAreaBlocks.push(\n\t\t\t\tcreateBlock( 'core/widget-area', {\n\t\t\t\t\tid: widgetArea.id,\n\t\t\t\t\tname: widgetArea.name,\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif ( ! widgetArea.widgets.length ) {\n\t\t\t\t// If this widget area has no widgets, it won't get a post setup by\n\t\t\t\t// the getWidgets resolver.\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( widgetArea.id ),\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\n\t\tconst widgetAreasOpenState = {};\n\t\twidgetAreaBlocks.forEach( ( widgetAreaBlock, index ) => {\n\t\t\t// Defaults to open the first widget area.\n\t\t\twidgetAreasOpenState[ widgetAreaBlock.clientId ] = index === 0;\n\t\t} );\n\t\tdispatch( setWidgetAreasOpenState( widgetAreasOpenState ) );\n\n\t\tdispatch(\n\t\t\tpersistStubPost( buildWidgetAreasPostId(), widgetAreaBlocks )\n\t\t);\n\t};\n\n/**\n * Fetches all widgets from all widgets ares, and groups them by widget area Id.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgets =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetsQuery();\n\t\tconst widgets = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( 'root', 'widget', query );\n\n\t\tconst groupedBySidebar = {};\n\n\t\tfor ( const widget of widgets ) {\n\t\t\tconst block = transformWidgetToBlock( widget );\n\t\t\tgroupedBySidebar[ widget.sidebar ] =\n\t\t\t\tgroupedBySidebar[ widget.sidebar ] || [];\n\t\t\tgroupedBySidebar[ widget.sidebar ].push( block );\n\t\t}\n\n\t\tfor ( const sidebarId in groupedBySidebar ) {\n\t\t\tif ( groupedBySidebar.hasOwnProperty( sidebarId ) ) {\n\t\t\t\t// Persist the actual post containing the widget block\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( sidebarId ),\n\t\t\t\t\t\tgroupedBySidebar[ sidebarId ]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAC5B,uBAAmC;AAKnC,qBAAyD;AACzD,mBAOO;AACP,0BAAuC;AAWhC,IAAM,iBACZ,MACA,OAAQ,EAAE,UAAU,SAAS,MAAO;AACnC,QAAM,YAAQ,oCAAsB;AACpC,QAAM,cAAc,MAAM,SACxB,cAAe,iBAAAA,KAAU,EACzB,iBAAkB,mBAAM,sCAAyB,KAAM;AAEzD,QAAM,mBAAmB,CAAC;AAC1B,QAAM,oBAAoB,YAAY,KAAM,CAAE,GAAG,MAAO;AACvD,QAAK,EAAE,OAAO,uBAAwB;AACrC,aAAO;AAAA,IACR;AACA,QAAK,EAAE,OAAO,uBAAwB;AACrC,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR,CAAE;AACF,aAAY,cAAc,mBAAoB;AAC7C,qBAAiB;AAAA,UAChB,2BAAa,oBAAoB;AAAA,QAChC,IAAI,WAAW;AAAA,QACf,MAAM,WAAW;AAAA,MAClB,CAAE;AAAA,IACH;AAEA,QAAK,CAAE,WAAW,QAAQ,QAAS;AAGlC;AAAA,YACC;AAAA,cACC,oCAAuB,WAAW,EAAG;AAAA,UACrC,CAAC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,QAAM,uBAAuB,CAAC;AAC9B,mBAAiB,QAAS,CAAE,iBAAiB,UAAW;AAEvD,yBAAsB,gBAAgB,QAAS,IAAI,UAAU;AAAA,EAC9D,CAAE;AACF,eAAU,wCAAyB,oBAAqB,CAAE;AAE1D;AAAA,QACC,oCAAiB,qCAAuB,GAAG,gBAAiB;AAAA,EAC7D;AACD;AAOM,IAAM,aACZ,MACA,OAAQ,EAAE,UAAU,SAAS,MAAO;AACnC,QAAM,YAAQ,gCAAkB;AAChC,QAAM,UAAU,MAAM,SACpB,cAAe,iBAAAA,KAAU,EACzB,iBAAkB,QAAQ,UAAU,KAAM;AAE5C,QAAM,mBAAmB,CAAC;AAE1B,aAAY,UAAU,SAAU;AAC/B,UAAM,YAAQ,4CAAwB,MAAO;AAC7C,qBAAkB,OAAO,OAAQ,IAChC,iBAAkB,OAAO,OAAQ,KAAK,CAAC;AACxC,qBAAkB,OAAO,OAAQ,EAAE,KAAM,KAAM;AAAA,EAChD;AAEA,aAAY,aAAa,kBAAmB;AAC3C,QAAK,iBAAiB,eAAgB,SAAU,GAAI;AAEnD;AAAA,YACC;AAAA,cACC,oCAAuB,SAAU;AAAA,UACjC,iBAAkB,SAAU;AAAA,QAC7B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["coreStore"]
|
|
7
7
|
}
|
package/build/store/selectors.js
CHANGED
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/edit-widgets/src/store/selectors.js
|
|
18
20
|
var selectors_exports = {};
|
|
19
21
|
__export(selectors_exports, {
|
|
20
22
|
__experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
|
|
@@ -39,11 +41,11 @@ var import_core_data = require("@wordpress/core-data");
|
|
|
39
41
|
var import_block_editor = require("@wordpress/block-editor");
|
|
40
42
|
var import_utils = require("./utils");
|
|
41
43
|
var import_constants = require("./constants");
|
|
42
|
-
|
|
44
|
+
var EMPTY_INSERTION_POINT = {
|
|
43
45
|
rootClientId: void 0,
|
|
44
46
|
insertionIndex: void 0
|
|
45
47
|
};
|
|
46
|
-
|
|
48
|
+
var getWidgets = (0, import_data.createRegistrySelector)(
|
|
47
49
|
(select) => (0, import_data.createSelector)(
|
|
48
50
|
() => {
|
|
49
51
|
const widgets = select(import_core_data.store).getEntityRecords(
|
|
@@ -71,13 +73,13 @@ const getWidgets = (0, import_data.createRegistrySelector)(
|
|
|
71
73
|
]
|
|
72
74
|
)
|
|
73
75
|
);
|
|
74
|
-
|
|
76
|
+
var getWidget = (0, import_data.createRegistrySelector)(
|
|
75
77
|
(select) => (state, id) => {
|
|
76
78
|
const widgets = select(import_constants.STORE_NAME).getWidgets();
|
|
77
79
|
return widgets[id];
|
|
78
80
|
}
|
|
79
81
|
);
|
|
80
|
-
|
|
82
|
+
var getWidgetAreas = (0, import_data.createRegistrySelector)((select) => () => {
|
|
81
83
|
const query = (0, import_utils.buildWidgetAreasQuery)();
|
|
82
84
|
return select(import_core_data.store).getEntityRecords(
|
|
83
85
|
import_utils.KIND,
|
|
@@ -85,7 +87,7 @@ const getWidgetAreas = (0, import_data.createRegistrySelector)((select) => () =>
|
|
|
85
87
|
query
|
|
86
88
|
);
|
|
87
89
|
});
|
|
88
|
-
|
|
90
|
+
var getWidgetAreaForWidgetId = (0, import_data.createRegistrySelector)(
|
|
89
91
|
(select) => (state, widgetId) => {
|
|
90
92
|
const widgetAreas = select(import_constants.STORE_NAME).getWidgetAreas();
|
|
91
93
|
return widgetAreas.find((widgetArea) => {
|
|
@@ -101,7 +103,7 @@ const getWidgetAreaForWidgetId = (0, import_data.createRegistrySelector)(
|
|
|
101
103
|
});
|
|
102
104
|
}
|
|
103
105
|
);
|
|
104
|
-
|
|
106
|
+
var getParentWidgetAreaBlock = (0, import_data.createRegistrySelector)(
|
|
105
107
|
(select) => (state, clientId) => {
|
|
106
108
|
const { getBlock, getBlockName, getBlockParents } = select(import_block_editor.store);
|
|
107
109
|
const blockParents = getBlockParents(clientId);
|
|
@@ -111,7 +113,7 @@ const getParentWidgetAreaBlock = (0, import_data.createRegistrySelector)(
|
|
|
111
113
|
return getBlock(widgetAreaClientId);
|
|
112
114
|
}
|
|
113
115
|
);
|
|
114
|
-
|
|
116
|
+
var getEditedWidgetAreas = (0, import_data.createRegistrySelector)(
|
|
115
117
|
(select) => (state, ids) => {
|
|
116
118
|
let widgetAreas = select(import_constants.STORE_NAME).getWidgetAreas();
|
|
117
119
|
if (!widgetAreas) {
|
|
@@ -137,7 +139,7 @@ const getEditedWidgetAreas = (0, import_data.createRegistrySelector)(
|
|
|
137
139
|
);
|
|
138
140
|
}
|
|
139
141
|
);
|
|
140
|
-
|
|
142
|
+
var getReferenceWidgetBlocks = (0, import_data.createRegistrySelector)(
|
|
141
143
|
(select) => (state, referenceWidgetName = null) => {
|
|
142
144
|
const results = [];
|
|
143
145
|
const widgetAreas = select(import_constants.STORE_NAME).getWidgetAreas();
|
|
@@ -156,7 +158,7 @@ const getReferenceWidgetBlocks = (0, import_data.createRegistrySelector)(
|
|
|
156
158
|
return results;
|
|
157
159
|
}
|
|
158
160
|
);
|
|
159
|
-
|
|
161
|
+
var isSavingWidgetAreas = (0, import_data.createRegistrySelector)((select) => () => {
|
|
160
162
|
const widgetAreasIds = select(import_constants.STORE_NAME).getWidgetAreas()?.map(({ id }) => id);
|
|
161
163
|
if (!widgetAreasIds) {
|
|
162
164
|
return false;
|
|
@@ -188,7 +190,7 @@ const isSavingWidgetAreas = (0, import_data.createRegistrySelector)((select) =>
|
|
|
188
190
|
}
|
|
189
191
|
return false;
|
|
190
192
|
});
|
|
191
|
-
|
|
193
|
+
var getIsWidgetAreaOpen = (state, clientId) => {
|
|
192
194
|
const { widgetAreasOpenState } = state;
|
|
193
195
|
return !!widgetAreasOpenState[clientId];
|
|
194
196
|
};
|
|
@@ -201,7 +203,7 @@ function __experimentalGetInsertionPoint(state) {
|
|
|
201
203
|
}
|
|
202
204
|
return state.blockInserterPanel;
|
|
203
205
|
}
|
|
204
|
-
|
|
206
|
+
var canInsertBlockInWidgetArea = (0, import_data.createRegistrySelector)(
|
|
205
207
|
(select) => (state, blockName) => {
|
|
206
208
|
const widgetAreas = select(import_block_editor.store).getBlocks();
|
|
207
209
|
const [firstWidgetArea] = widgetAreas;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/selectors.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t// Key widgets by their ID.\n\t\t\t\twidgets?.reduce(\n\t\t\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t\t\t...allWidgets,\n\t\t\t\t\t\t[ widget.id ]: widget,\n\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\t() => [\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t),\n\t\t]\n\t)\n);\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID.\n *\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\n/**\n * Returns all API widget areas.\n *\n * @return {Object[]} API List of widget areas.\n */\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( coreStore ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } =\n\t\t\tselect( blockEditorStore );\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\n/**\n * Returns all edited widget area entity records.\n *\n * @return {Object[]} List of edited widget area entity records.\n */\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) =>\n\t\t( state, referenceWidgetName = null ) => {\n\t\t\tconst results = [];\n\t\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t\t);\n\t\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresults.push( block );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n);\n\n/**\n * Returns true if any widget area is currently being saved.\n *\n * @return {boolean} True if any widget area is currently being saved. False otherwise.\n */\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n *\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\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\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( blockEditorStore ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns whether widget saving is locked.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```jsx\n * import { __ } from '@wordpress/i18n';\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst isSavingLocked = useSelect(\n * \t\t( select ) => select( widgetStore ).isWidgetSavingLocked(),\n * \t\t[]\n * \t);\n *\n * \treturn isSavingLocked ? (\n * \t\t<p>{ __( 'Widget saving is locked' ) }</p>\n * \t) : (\n * \t\t<p>{ __( 'Widget saving is not locked' ) }</p>\n * \t);\n * };\n * ```\n *\n * @return {boolean} Is locked.\n */\nexport function isWidgetSavingLocked( state ) {\n\treturn Object.keys( state.widgetSavingLock ).length > 0;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["coreStore", "editWidgetsStoreName", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/edit-widgets/src/store/transformers.js
|
|
18
20
|
var transformers_exports = {};
|
|
19
21
|
__export(transformers_exports, {
|
|
20
22
|
transformBlockToWidget: () => transformBlockToWidget,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/transformers.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock, parse, serialize } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Converts a widget entity record into a block.\n *\n * @param {Object} widget The widget entity record.\n * @return {Object} a block (converted from the entity record).\n */\nexport function transformWidgetToBlock( widget ) {\n\tif ( widget.id_base === 'block' ) {\n\t\tconst parsedBlocks = parse( widget.instance.raw.content, {\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tif ( ! parsedBlocks.length ) {\n\t\t\treturn addWidgetIdToBlock(\n\t\t\t\tcreateBlock( 'core/paragraph', {}, [] ),\n\t\t\t\twidget.id\n\t\t\t);\n\t\t}\n\t\treturn addWidgetIdToBlock( parsedBlocks[ 0 ], widget.id );\n\t}\n\n\tlet attributes;\n\tif ( widget._embedded.about[ 0 ].is_multi ) {\n\t\tattributes = {\n\t\t\tidBase: widget.id_base,\n\t\t\tinstance: widget.instance,\n\t\t};\n\t} else {\n\t\tattributes = {\n\t\t\tid: widget.id,\n\t\t};\n\t}\n\n\treturn addWidgetIdToBlock(\n\t\tcreateBlock( 'core/legacy-widget', attributes, [] ),\n\t\twidget.id\n\t);\n}\n\n/**\n * Converts a block to a widget entity record.\n *\n * @param {Object} block The block.\n * @param {?Object} relatedWidget A related widget entity record from the API (optional).\n * @return {Object} the widget object (converted from block).\n */\nexport function transformBlockToWidget( block, relatedWidget = {} ) {\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\twidget = {\n\t\t\t...relatedWidget,\n\t\t\tid: block.attributes.id ?? relatedWidget.id,\n\t\t\tid_base: block.attributes.idBase ?? relatedWidget.id_base,\n\t\t\tinstance: block.attributes.instance ?? relatedWidget.instance,\n\t\t};\n\t} else {\n\t\twidget = {\n\t\t\t...relatedWidget,\n\t\t\tid_base: 'block',\n\t\t\tinstance: {\n\t\t\t\traw: {\n\t\t\t\t\tcontent: serialize( block ),\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Delete read-only properties.\n\tdelete widget.rendered;\n\tdelete widget.rendered_form;\n\n\treturn widget;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA8C;AAC9C,qBAAmC;AAQ5B,SAAS,uBAAwB,QAAS;AAChD,MAAK,OAAO,YAAY,SAAU;AACjC,UAAM,mBAAe,qBAAO,OAAO,SAAS,IAAI,SAAS;AAAA,MACxD,qBAAqB;AAAA,IACtB,CAAE;AACF,QAAK,CAAE,aAAa,QAAS;AAC5B,iBAAO;AAAA,YACN,2BAAa,kBAAkB,CAAC,GAAG,CAAC,CAAE;AAAA,QACtC,OAAO;AAAA,MACR;AAAA,IACD;AACA,eAAO,mCAAoB,aAAc,CAAE,GAAG,OAAO,EAAG;AAAA,EACzD;AAEA,MAAI;AACJ,MAAK,OAAO,UAAU,MAAO,CAAE,EAAE,UAAW;AAC3C,iBAAa;AAAA,MACZ,QAAQ,OAAO;AAAA,MACf,UAAU,OAAO;AAAA,IAClB;AAAA,EACD,OAAO;AACN,iBAAa;AAAA,MACZ,IAAI,OAAO;AAAA,IACZ;AAAA,EACD;AAEA,aAAO;AAAA,QACN,2BAAa,sBAAsB,YAAY,CAAC,CAAE;AAAA,IAClD,OAAO;AAAA,EACR;AACD;AASO,SAAS,uBAAwB,OAAO,gBAAgB,CAAC,GAAI;AACnE,MAAI;AAEJ,QAAM,2BACL,MAAM,SAAS,yBACb,MAAM,WAAW,MAAM,MAAM,WAAW;AAE3C,MAAK,0BAA2B;AAC/B,aAAS;AAAA,MACR,GAAG;AAAA,MACH,IAAI,MAAM,WAAW,MAAM,cAAc;AAAA,MACzC,SAAS,MAAM,WAAW,UAAU,cAAc;AAAA,MAClD,UAAU,MAAM,WAAW,YAAY,cAAc;AAAA,IACtD;AAAA,EACD,OAAO;AACN,aAAS;AAAA,MACR,GAAG;AAAA,MACH,SAAS;AAAA,MACT,UAAU;AAAA,QACT,KAAK;AAAA,UACJ,aAAS,yBAAW,KAAM;AAAA,QAC3B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAGA,SAAO,OAAO;AACd,SAAO,OAAO;AAEd,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/store/utils.js
CHANGED
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/edit-widgets/src/store/utils.js
|
|
18
20
|
var utils_exports = {};
|
|
19
21
|
__export(utils_exports, {
|
|
20
22
|
KIND: () => KIND,
|
|
@@ -27,11 +29,11 @@ __export(utils_exports, {
|
|
|
27
29
|
createStubPost: () => createStubPost
|
|
28
30
|
});
|
|
29
31
|
module.exports = __toCommonJS(utils_exports);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
var KIND = "root";
|
|
33
|
+
var WIDGET_AREA_ENTITY_TYPE = "sidebar";
|
|
34
|
+
var POST_TYPE = "postType";
|
|
35
|
+
var buildWidgetAreaPostId = (widgetAreaId) => `widget-area-${widgetAreaId}`;
|
|
36
|
+
var buildWidgetAreasPostId = () => `widget-areas`;
|
|
35
37
|
function buildWidgetAreasQuery() {
|
|
36
38
|
return {
|
|
37
39
|
per_page: -1
|
|
@@ -43,7 +45,7 @@ function buildWidgetsQuery() {
|
|
|
43
45
|
_embed: "about"
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
var createStubPost = (id, blocks) => ({
|
|
47
49
|
id,
|
|
48
50
|
slug: id,
|
|
49
51
|
status: "draft",
|
package/build/store/utils.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/utils.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * \"Kind\" of the navigation post.\n *\n * @type {string}\n */\nexport const KIND = 'root';\n\n/**\n * \"post type\" of the navigation post.\n *\n * @type {string}\n */\nexport const WIDGET_AREA_ENTITY_TYPE = 'sidebar';\n\n/**\n * \"post type\" of the widget area post.\n *\n * @type {string}\n */\nexport const POST_TYPE = 'postType';\n\n/**\n * Builds an ID for a new widget area post.\n *\n * @param {number} widgetAreaId Widget area id.\n * @return {string} An ID.\n */\nexport const buildWidgetAreaPostId = ( widgetAreaId ) =>\n\t`widget-area-${ widgetAreaId }`;\n\n/**\n * Builds an ID for a global widget areas post.\n *\n * @return {string} An ID.\n */\nexport const buildWidgetAreasPostId = () => `widget-areas`;\n\n/**\n * Builds a query to resolve sidebars.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetAreasQuery() {\n\treturn {\n\t\tper_page: -1,\n\t};\n}\n\n/**\n * Builds a query to resolve widgets.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetsQuery() {\n\treturn {\n\t\tper_page: -1,\n\t\t_embed: 'about',\n\t};\n}\n\n/**\n * Creates a stub post with given id and set of blocks. Used as a governing entity records\n * for all widget areas.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks The list of blocks.\n * @return {Object} A stub post object formatted in compliance with the data layer.\n */\nexport const createStubPost = ( id, blocks ) => ( {\n\tid,\n\tslug: id,\n\tstatus: 'draft',\n\ttype: 'page',\n\tblocks,\n\tmeta: {\n\t\twidgetAreaId: id,\n\t},\n} );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,IAAM,OAAO;AAOb,IAAM,0BAA0B;AAOhC,IAAM,YAAY;AAQlB,IAAM,wBAAwB,CAAE,iBACtC,eAAgB,YAAa;AAOvB,IAAM,yBAAyB,MAAM;AAOrC,SAAS,wBAAwB;AACvC,SAAO;AAAA,IACN,UAAU;AAAA,EACX;AACD;AAOO,SAAS,oBAAoB;AACnC,SAAO;AAAA,IACN,UAAU;AAAA,IACV,QAAQ;AAAA,EACT;AACD;AAUO,IAAM,iBAAiB,CAAE,IAAI,YAAc;AAAA,EACjD;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN;AAAA,EACA,MAAM;AAAA,IACL,cAAc;AAAA,EACf;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/edit-widgets/src/blocks/widget-area/edit/index.js
|
|
2
2
|
import { useEffect, useState, useCallback, useRef } from "@wordpress/element";
|
|
3
3
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
4
4
|
import { EntityProvider } from "@wordpress/core-data";
|
|
@@ -11,6 +11,7 @@ import { useBlockProps } from "@wordpress/block-editor";
|
|
|
11
11
|
import WidgetAreaInnerBlocks from "./inner-blocks";
|
|
12
12
|
import { store as editWidgetsStore } from "../../../store";
|
|
13
13
|
import useIsDraggingWithin from "./use-is-dragging-within";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
15
|
function WidgetAreaEdit({
|
|
15
16
|
clientId,
|
|
16
17
|
attributes: { id, name }
|
|
@@ -75,7 +76,7 @@ function WidgetAreaEdit({
|
|
|
75
76
|
}
|
|
76
77
|
) }) });
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
var useIsDragging = (elementRef) => {
|
|
79
80
|
const [isDragging, setIsDragging] = useState(false);
|
|
80
81
|
useEffect(() => {
|
|
81
82
|
const { ownerDocument } = elementRef.current;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/blocks/widget-area/edit/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\nimport { useBlockProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Panel ref={ wrapper }>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ name }\n\t\t\t\t\topened={ isOpen }\n\t\t\t\t\tonToggle={ () => {\n\t\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t\t} }\n\t\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t\t>\n\t\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t\t</DisclosureContent>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</Panel>\n\t\t</div>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,UAAU,aAAa,cAAc;AACzD,SAAS,WAAW,mBAAmB;AACvC,SAAS,sBAAsB;AAC/B;AAAA,EACC,+BAA+B;AAAA,EAC/B;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAK9B,OAAO,2BAA2B;AAClC,SAAS,SAAS,wBAAwB;AAC1C,OAAO,yBAAyB;AAiExB;AA7DO,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA,YAAY,EAAE,IAAI,KAAK;AACxB,GAAI;AACH,QAAM,SAAS;AAAA,IACd,CAAE,WACD,OAAQ,gBAAiB,EAAE,oBAAqB,QAAS;AAAA,IAC1D,CAAE,QAAS;AAAA,EACZ;AACA,QAAM,EAAE,oBAAoB,IAAI,YAAa,gBAAiB;AAE9D,QAAM,UAAU,OAAO;AACvB,QAAM,UAAU;AAAA,IACf,CAAE,cAAe,oBAAqB,UAAU,SAAU;AAAA,IAC1D,CAAE,QAAS;AAAA,EACZ;AACA,QAAM,aAAa,cAAe,OAAQ;AAC1C,QAAM,mBAAmB,oBAAqB,OAAQ;AAEtD,QAAM,CAAE,qBAAqB,sBAAuB,IAAI,SAAU,KAAM;AACxE,YAAW,MAAM;AAChB,QAAK,CAAE,YAAa;AACnB,6BAAwB,KAAM;AAC9B;AAAA,IACD;AAEA,QAAK,oBAAoB,CAAE,QAAS;AACnC,cAAS,IAAK;AACd,6BAAwB,IAAK;AAAA,IAC9B,WAAY,CAAE,oBAAoB,UAAU,qBAAsB;AACjE,cAAS,KAAM;AAAA,IAChB;AAAA,EACD,GAAG,CAAE,QAAQ,YAAY,kBAAkB,mBAAoB,CAAE;AAEjE,QAAM,aAAa,cAAc;AAEjC,SACC,oBAAC,SAAM,GAAG,YACT,8BAAC,SAAM,KAAM,SACZ;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ;AAAA,MACR,QAAS;AAAA,MACT,UAAW,MAAM;AAChB,4BAAqB,UAAU,CAAE,MAAO;AAAA,MACzC;AAAA,MACA,iBAAkB,CAAE;AAAA,MAElB,WAAE,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,QAKZ;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,SAAU;AAAA,YAEV;AAAA,cAAC;AAAA;AAAA,gBACA,MAAK;AAAA,gBACL,MAAK;AAAA,gBACL,IAAK,eAAgB,EAAG;AAAA,gBAExB,8BAAC,yBAAsB,IAAU;AAAA;AAAA,YAClC;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF,GACD,GACD;AAEF;AASA,IAAM,gBAAgB,CAAE,eAAgB;AACvC,QAAM,CAAE,YAAY,aAAc,IAAI,SAAU,KAAM;AAEtD,YAAW,MAAM;AAChB,UAAM,EAAE,cAAc,IAAI,WAAW;AAErC,aAAS,kBAAkB;AAC1B,oBAAe,IAAK;AAAA,IACrB;AAEA,aAAS,gBAAgB;AACxB,oBAAe,KAAM;AAAA,IACtB;AAEA,kBAAc,iBAAkB,aAAa,eAAgB;AAC7D,kBAAc,iBAAkB,WAAW,aAAc;AAEzD,WAAO,MAAM;AACZ,oBAAc,oBAAqB,aAAa,eAAgB;AAChE,oBAAc,oBAAqB,WAAW,aAAc;AAAA,IAC7D;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/edit-widgets/src/blocks/widget-area/edit/inner-blocks.js
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { useEntityBlockEditor } from "@wordpress/core-data";
|
|
4
4
|
import { InnerBlocks, useInnerBlocksProps } from "@wordpress/block-editor";
|
|
5
5
|
import { useRef } from "@wordpress/element";
|
|
6
6
|
import useIsDraggingWithin from "./use-is-dragging-within";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
function WidgetAreaInnerBlocks({ id }) {
|
|
8
9
|
const [blocks, onInput, onChange] = useEntityBlockEditor(
|
|
9
10
|
"root",
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/blocks/widget-area/edit/inner-blocks.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport { InnerBlocks, useInnerBlocksProps } from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useIsDraggingWithin from './use-is-dragging-within';\n\nexport default function WidgetAreaInnerBlocks( { id } ) {\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'root',\n\t\t'postType'\n\t);\n\tconst innerBlocksRef = useRef();\n\tconst isDraggingWithinInnerBlocks = useIsDraggingWithin( innerBlocksRef );\n\tconst shouldHighlightDropZone = isDraggingWithinInnerBlocks;\n\t// Using the experimental hook so that we can control the className of the element.\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ ref: innerBlocksRef },\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplateLock: false,\n\t\t\trenderAppender: InnerBlocks.ButtonBlockAppender,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tdata-widget-area-id={ id }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',\n\t\t\t\t{\n\t\t\t\t\t'wp-block-widget-area__highlight-drop-zone':\n\t\t\t\t\t\tshouldHighlightDropZone,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,4BAA4B;AACrC,SAAS,aAAa,2BAA2B;AACjD,SAAS,cAAc;AAKvB,OAAO,yBAAyB;AAiC7B;AA/BY,SAAR,sBAAwC,EAAE,GAAG,GAAI;AACvD,QAAM,CAAE,QAAQ,SAAS,QAAS,IAAI;AAAA,IACrC;AAAA,IACA;AAAA,EACD;AACA,QAAM,iBAAiB,OAAO;AAC9B,QAAM,8BAA8B,oBAAqB,cAAe;AACxE,QAAM,0BAA0B;AAEhC,QAAM,mBAAmB;AAAA,IACxB,EAAE,KAAK,eAAe;AAAA,IACtB;AAAA,MACC,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,gBAAgB,YAAY;AAAA,IAC7B;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAsB;AAAA,MACtB,WAAY;AAAA,QACX;AAAA,QACA;AAAA,UACC,6CACC;AAAA,QACF;AAAA,MACD;AAAA,MAEA,8BAAC,SAAM,GAAG,kBAAmB;AAAA;AAAA,EAC9B;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// packages/edit-widgets/src/blocks/widget-area/edit/use-is-dragging-within.js
|
|
1
2
|
import { useState, useEffect } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
+
var useIsDraggingWithin = (elementRef) => {
|
|
3
4
|
const [isDraggingWithin, setIsDraggingWithin] = useState(false);
|
|
4
5
|
useEffect(() => {
|
|
5
6
|
const { ownerDocument } = elementRef.current;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/blocks/widget-area/edit/use-is-dragging-within.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\nexport default useIsDraggingWithin;\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,UAAU,iBAAiB;AAWpC,
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU,iBAAiB;AAWpC,IAAM,sBAAsB,CAAE,eAAgB;AAC7C,QAAM,CAAE,kBAAkB,mBAAoB,IAAI,SAAU,KAAM;AAElE,YAAW,MAAM;AAChB,UAAM,EAAE,cAAc,IAAI,WAAW;AAErC,aAAS,gBAAiB,OAAQ;AAEjC,sBAAiB,KAAM;AAAA,IACxB;AAGA,aAAS,gBAAgB;AACxB,0BAAqB,KAAM;AAAA,IAC5B;AAEA,aAAS,gBAAiB,OAAQ;AAEjC,UAAK,WAAW,QAAQ,SAAU,MAAM,MAAO,GAAI;AAClD,4BAAqB,IAAK;AAAA,MAC3B,OAAO;AACN,4BAAqB,KAAM;AAAA,MAC5B;AAAA,IACD;AAIA,kBAAc,iBAAkB,aAAa,eAAgB;AAC7D,kBAAc,iBAAkB,WAAW,aAAc;AACzD,kBAAc,iBAAkB,aAAa,eAAgB;AAE7D,WAAO,MAAM;AACZ,oBAAc,oBAAqB,aAAa,eAAgB;AAChE,oBAAc,oBAAqB,WAAW,aAAc;AAC5D,oBAAc,oBAAqB,aAAa,eAAgB;AAAA,IACjE;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SAAO;AACR;AAEA,IAAO,iCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
// packages/edit-widgets/src/blocks/widget-area/index.js
|
|
1
2
|
import { __ } from "@wordpress/i18n";
|
|
2
3
|
import metadata from "./block.json";
|
|
3
4
|
import edit from "./edit";
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
var { name } = metadata;
|
|
6
|
+
var settings = {
|
|
6
7
|
title: __("Widget Area"),
|
|
7
8
|
description: __("A widget area container."),
|
|
8
9
|
__experimentalLabel: ({ name: label }) => label,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/blocks/widget-area/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,UAAU;AAKnB,OAAO,cAAc;AACrB,OAAO,UAAU;AAEjB,
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AAKnB,OAAO,cAAc;AACrB,OAAO,UAAU;AAEjB,IAAM,EAAE,KAAK,IAAI;AAGV,IAAM,WAAW;AAAA,EACvB,OAAO,GAAI,aAAc;AAAA,EACzB,aAAa,GAAI,0BAA2B;AAAA,EAC5C,qBAAqB,CAAE,EAAE,MAAM,MAAM,MAAO;AAAA,EAC5C;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/edit-widgets/src/components/error-boundary/index.js
|
|
2
2
|
import { Component } from "@wordpress/element";
|
|
3
3
|
import { __ } from "@wordpress/i18n";
|
|
4
4
|
import { Button } from "@wordpress/components";
|
|
5
5
|
import { Warning } from "@wordpress/block-editor";
|
|
6
6
|
import { useCopyToClipboard } from "@wordpress/compose";
|
|
7
7
|
import { doAction } from "@wordpress/hooks";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
9
|
function CopyButton({ text, children }) {
|
|
9
10
|
const ref = useCopyToClipboard(text);
|
|
10
11
|
return /* @__PURE__ */ jsx(Button, { __next40pxDefaultSize: true, variant: "secondary", ref, children });
|
|
@@ -15,7 +16,7 @@ function ErrorBoundaryWarning({ message, error }) {
|
|
|
15
16
|
];
|
|
16
17
|
return /* @__PURE__ */ jsx(Warning, { className: "edit-widgets-error-boundary", actions, children: message });
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
var ErrorBoundary = class extends Component {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments);
|
|
21
22
|
this.state = {
|
|
@@ -42,7 +43,7 @@ class ErrorBoundary extends Component {
|
|
|
42
43
|
}
|
|
43
44
|
);
|
|
44
45
|
}
|
|
45
|
-
}
|
|
46
|
+
};
|
|
46
47
|
export {
|
|
47
48
|
ErrorBoundary as default
|
|
48
49
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/error-boundary/index.js"],
|
|
4
4
|
"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';\nimport { doAction } from '@wordpress/hooks';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button __next40pxDefaultSize variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nfunction ErrorBoundaryWarning( { message, error } ) {\n\tconst actions = [\n\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t{ __( 'Copy Error' ) }\n\t\t</CopyButton>,\n\t];\n\n\treturn (\n\t\t<Warning className=\"edit-widgets-error-boundary\" actions={ actions }>\n\t\t\t{ message }\n\t\t</Warning>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tif ( ! this.state.error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<ErrorBoundaryWarning\n\t\t\t\tmessage={ __(\n\t\t\t\t\t'The editor has encountered an unexpected error.'\n\t\t\t\t) }\n\t\t\t\terror={ this.state.error }\n\t\t\t/>\n\t\t);\n\t}\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AAKvB;AAHF,SAAS,WAAY,EAAE,MAAM,SAAS,GAAI;AACzC,QAAM,MAAM,mBAAoB,IAAK;AACrC,SACC,oBAAC,UAAO,uBAAqB,MAAC,SAAQ,aAAY,KAC/C,UACH;AAEF;AAEA,SAAS,qBAAsB,EAAE,SAAS,MAAM,GAAI;AACnD,QAAM,UAAU;AAAA,IACf,oBAAC,cAA4B,MAAO,MAAM,OACvC,aAAI,YAAa,KADJ,YAEhB;AAAA,EACD;AAEA,SACC,oBAAC,WAAQ,WAAU,+BAA8B,SAC9C,mBACH;AAEF;AAEA,IAAqB,gBAArB,cAA2C,UAAU;AAAA,EACpD,cAAc;AACb,UAAO,GAAG,SAAU;AAEpB,SAAK,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EAEA,kBAAmB,OAAQ;AAC1B,aAAU,oCAAoC,KAAM;AAAA,EACrD;AAAA,EAEA,OAAO,yBAA0B,OAAQ;AACxC,WAAO,EAAE,MAAM;AAAA,EAChB;AAAA,EAEA,SAAS;AACR,QAAK,CAAE,KAAK,MAAM,OAAQ;AACzB,aAAO,KAAK,MAAM;AAAA,IACnB;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,SAAU;AAAA,UACT;AAAA,QACD;AAAA,QACA,OAAQ,KAAK,MAAM;AAAA;AAAA,IACpB;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/edit-widgets/src/components/header/document-tools/index.js
|
|
2
2
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
3
3
|
import { __, _x } from "@wordpress/i18n";
|
|
4
4
|
import { Button, ToolbarItem } from "@wordpress/components";
|
|
@@ -10,6 +10,7 @@ import UndoButton from "../undo-redo/undo";
|
|
|
10
10
|
import RedoButton from "../undo-redo/redo";
|
|
11
11
|
import { store as editWidgetsStore } from "../../../store";
|
|
12
12
|
import { unlock } from "../../../lock-unlock";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
function DocumentTools() {
|
|
14
15
|
const isMediumViewport = useViewportMatch("medium");
|
|
15
16
|
const {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/header/document-tools/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { NavigableToolbar } from '@wordpress/block-editor';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport UndoButton from '../undo-redo/undo';\nimport RedoButton from '../undo-redo/redo';\nimport { store as editWidgetsStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction DocumentTools() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\n\tconst {\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisInserterOpened,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tisListViewOpened,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editWidgetsStore ) );\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserterSidebar = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpen ),\n\t\t[ setIsInserterOpened, isInserterOpen ]\n\t);\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<ToolbarItem\n\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t\tonClick={ toggleInserterSidebar }\n\t\t\t\ticon={ plus }\n\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\tlabel={ _x(\n\t\t\t\t\t'Block Inserter',\n\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t) }\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t\t{ isMediumViewport && (\n\t\t\t\t<>\n\t\t\t\t\t<ToolbarItem as={ UndoButton } />\n\t\t\t\t\t<ToolbarItem as={ RedoButton } />\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,IAAI,UAAU;AACvB,SAAS,QAAQ,mBAAmB;AACpC,SAAS,wBAAwB;AACjC,SAAS,UAAU,YAAY;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AAKjC,OAAO,gBAAgB;AACvB,OAAO,gBAAgB;AACvB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AA2CpB,SAoBC,UApBD,KAoBC,YApBD;AAzCH,SAAS,gBAAgB;AACxB,QAAM,mBAAmB,iBAAkB,QAAS;AAEpD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,UAAW,CAAE,WAAY;AAC5B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,OAAQ,OAAQ,gBAAiB,CAAE;AACvC,WAAO;AAAA,MACN,gBAAgB,iBAAiB;AAAA,MACjC,gBAAgB,iBAAiB;AAAA,MACjC,0BAA0B,4BAA4B;AAAA,MACtD,mBAAmB,qBAAqB;AAAA,IACzC;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,qBAAqB,oBAAoB,IAChD,YAAa,gBAAiB;AAE/B,QAAM,iBAAiB;AAAA,IACtB,MAAM,oBAAqB,CAAE,cAAe;AAAA,IAC5C,CAAE,qBAAqB,cAAe;AAAA,EACvC;AAEA,QAAM,wBAAwB;AAAA,IAC7B,MAAM,oBAAqB,CAAE,cAAe;AAAA,IAC5C,CAAE,qBAAqB,cAAe;AAAA,EACvC;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,cAAa,GAAI,gBAAiB;AAAA,MAClC,SAAQ;AAAA,MAER;AAAA;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN,IAAK;AAAA,YACL,WAAU;AAAA,YACV,SAAQ;AAAA,YACR,WAAY;AAAA,YACZ,aAAc,CAAE,UAAW;AAC1B,oBAAM,eAAe;AAAA,YACtB;AAAA,YACA,SAAU;AAAA,YACV,MAAO;AAAA,YAGP,OAAQ;AAAA,cACP;AAAA,cACA;AAAA,YACD;AAAA,YACA,MAAK;AAAA;AAAA,QACN;AAAA,QACE,oBACD,iCACC;AAAA,8BAAC,eAAY,IAAK,YAAa;AAAA,UAC/B,oBAAC,eAAY,IAAK,YAAa;AAAA,UAC/B;AAAA,YAAC;AAAA;AAAA,cACA,IAAK;AAAA,cACL,WAAU;AAAA,cACV,MAAO;AAAA,cACP,WAAY;AAAA,cAEZ,OAAQ,GAAI,WAAY;AAAA,cACxB,SAAU;AAAA,cACV,KAAM;AAAA,cACN,MAAK;AAAA;AAAA,UACN;AAAA,WACD;AAAA;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/edit-widgets/src/components/header/index.js
|
|
2
2
|
import { BlockToolbar } from "@wordpress/block-editor";
|
|
3
3
|
import { useSelect } from "@wordpress/data";
|
|
4
4
|
import { useRef } from "@wordpress/element";
|
|
@@ -10,6 +10,7 @@ import { store as preferencesStore } from "@wordpress/preferences";
|
|
|
10
10
|
import DocumentTools from "./document-tools";
|
|
11
11
|
import SaveButton from "../save-button";
|
|
12
12
|
import MoreMenu from "../more-menu";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
function Header() {
|
|
14
15
|
const isLargeViewport = useViewportMatch("medium");
|
|
15
16
|
const blockToolbarRef = useRef();
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/header/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BlockToolbar } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Popover, VisuallyHidden } from '@wordpress/components';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport DocumentTools from './document-tools';\nimport SaveButton from '../save-button';\nimport MoreMenu from '../more-menu';\n\nfunction Header() {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst blockToolbarRef = useRef();\n\tconst { hasFixedToolbar } = useSelect(\n\t\t( select ) => ( {\n\t\t\thasFixedToolbar: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isLargeViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<DocumentTools />\n\t\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<div className=\"selected-block-tools-wrapper\">\n\t\t\t\t\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t\t\t\tname=\"block-toolbar\"\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</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,SAAS,sBAAsB;AACxC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,SAAS,wBAAwB;AAK1C,OAAO,mBAAmB;AAC1B,OAAO,gBAAgB;AACvB,OAAO,cAAc;AAoBf,SAcA,UAdA,KAcA,YAdA;AAlBN,SAAS,SAAS;AACjB,QAAM,kBAAkB,iBAAkB,QAAS;AACnD,QAAM,kBAAkB,OAAO;AAC/B,QAAM,EAAE,gBAAgB,IAAI;AAAA,IAC3B,CAAE,YAAc;AAAA,MACf,iBAAiB,CAAC,CAAE,OAAQ,gBAAiB,EAAE;AAAA,QAC9C;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAEA,SACC,gCACC,+BAAC,SAAI,WAAU,uBACd;AAAA,yBAAC,SAAI,WAAU,kDACZ;AAAA,yBACD,oBAAC,QAAG,WAAU,8BACX,aAAI,SAAU,GACjB;AAAA,MAEC,CAAE,mBACH;AAAA,QAAC;AAAA;AAAA,UACA,IAAG;AAAA,UACH,WAAU;AAAA,UAER,aAAI,SAAU;AAAA;AAAA,MACjB;AAAA,MAED,oBAAC,iBAAc;AAAA,MACb,mBAAmB,mBACpB,iCACC;AAAA,4BAAC,SAAI,WAAU,gCACd,8BAAC,gBAAa,gBAAc,MAAC,GAC9B;AAAA,QACA;AAAA,UAAC,QAAQ;AAAA,UAAR;AAAA,YACA,KAAM;AAAA,YACN,MAAK;AAAA;AAAA,QACN;AAAA,SACD;AAAA,OAEF;AAAA,IACA,qBAAC,SAAI,WAAU,gCACd;AAAA,0BAAC,YAAY,MAAZ,EAAiB,OAAM,qBAAoB;AAAA,MAC5C,oBAAC,cAAW;AAAA,MACZ,oBAAC,YAAS;AAAA,OACX;AAAA,KACD,GACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/edit-widgets/src/components/header/undo-redo/redo.js
|
|
2
2
|
import { __, isRTL } from "@wordpress/i18n";
|
|
3
3
|
import { Button } from "@wordpress/components";
|
|
4
4
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
@@ -6,6 +6,7 @@ import { redo as redoIcon, undo as undoIcon } from "@wordpress/icons";
|
|
|
6
6
|
import { displayShortcut, isAppleOS } from "@wordpress/keycodes";
|
|
7
7
|
import { store as coreStore } from "@wordpress/core-data";
|
|
8
8
|
import { forwardRef } from "@wordpress/element";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
10
|
function RedoButton(props, ref) {
|
|
10
11
|
const shortcut = isAppleOS() ? displayShortcut.primaryShift("z") : displayShortcut.primary("y");
|
|
11
12
|
const hasRedo = useSelect(
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/header/undo-redo/redo.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';\nimport { displayShortcut, isAppleOS } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { forwardRef } from '@wordpress/element';\n\nfunction RedoButton( props, ref ) {\n\tconst shortcut = isAppleOS()\n\t\t? displayShortcut.primaryShift( 'z' )\n\t\t: displayShortcut.primary( 'y' );\n\n\tconst hasRedo = useSelect(\n\t\t( select ) => select( coreStore ).hasRedo(),\n\t\t[]\n\t);\n\tconst { redo } = useDispatch( coreStore );\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t\ticon={ ! isRTL() ? redoIcon : undoIcon }\n\t\t\tlabel={ __( 'Redo' ) }\n\t\t\tshortcut={ shortcut }\n\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\taria-disabled={ ! hasRedo }\n\t\t\tonClick={ hasRedo ? redo : undefined }\n\t\t\tsize=\"compact\"\n\t\t/>\n\t);\n}\n\nexport default forwardRef( RedoButton );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,IAAI,aAAa;AAC1B,SAAS,cAAc;AACvB,SAAS,WAAW,mBAAmB;AACvC,SAAS,QAAQ,UAAU,QAAQ,gBAAgB;AACnD,SAAS,iBAAiB,iBAAiB;AAC3C,SAAS,SAAS,iBAAiB;AACnC,SAAS,kBAAkB;AAazB;AAXF,SAAS,WAAY,OAAO,KAAM;AACjC,QAAM,WAAW,UAAU,IACxB,gBAAgB,aAAc,GAAI,IAClC,gBAAgB,QAAS,GAAI;AAEhC,QAAM,UAAU;AAAA,IACf,CAAE,WAAY,OAAQ,SAAU,EAAE,QAAQ;AAAA,IAC1C,CAAC;AAAA,EACF;AACA,QAAM,EAAE,KAAK,IAAI,YAAa,SAAU;AACxC,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL;AAAA,MACA,MAAO,CAAE,MAAM,IAAI,WAAW;AAAA,MAC9B,OAAQ,GAAI,MAAO;AAAA,MACnB;AAAA,MAIA,iBAAgB,CAAE;AAAA,MAClB,SAAU,UAAU,OAAO;AAAA,MAC3B,MAAK;AAAA;AAAA,EACN;AAEF;AAEA,IAAO,eAAQ,WAAY,UAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/edit-widgets/src/components/header/undo-redo/undo.js
|
|
2
2
|
import { __, isRTL } from "@wordpress/i18n";
|
|
3
3
|
import { Button } from "@wordpress/components";
|
|
4
4
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
@@ -6,6 +6,7 @@ import { undo as undoIcon, redo as redoIcon } from "@wordpress/icons";
|
|
|
6
6
|
import { displayShortcut } from "@wordpress/keycodes";
|
|
7
7
|
import { store as coreStore } from "@wordpress/core-data";
|
|
8
8
|
import { forwardRef } from "@wordpress/element";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
10
|
function UndoButton(props, ref) {
|
|
10
11
|
const hasUndo = useSelect(
|
|
11
12
|
(select) => select(coreStore).hasUndo(),
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/header/undo-redo/undo.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { undo as undoIcon, redo as redoIcon } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { forwardRef } from '@wordpress/element';\n\nfunction UndoButton( props, ref ) {\n\tconst hasUndo = useSelect(\n\t\t( select ) => select( coreStore ).hasUndo(),\n\t\t[]\n\t);\n\tconst { undo } = useDispatch( coreStore );\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t\ticon={ ! isRTL() ? undoIcon : redoIcon }\n\t\t\tlabel={ __( 'Undo' ) }\n\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\taria-disabled={ ! hasUndo }\n\t\t\tonClick={ hasUndo ? undo : undefined }\n\t\t\tsize=\"compact\"\n\t\t/>\n\t);\n}\n\nexport default forwardRef( UndoButton );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,IAAI,aAAa;AAC1B,SAAS,cAAc;AACvB,SAAS,WAAW,mBAAmB;AACvC,SAAS,QAAQ,UAAU,QAAQ,gBAAgB;AACnD,SAAS,uBAAuB;AAChC,SAAS,SAAS,iBAAiB;AACnC,SAAS,kBAAkB;AASzB;AAPF,SAAS,WAAY,OAAO,KAAM;AACjC,QAAM,UAAU;AAAA,IACf,CAAE,WAAY,OAAQ,SAAU,EAAE,QAAQ;AAAA,IAC1C,CAAC;AAAA,EACF;AACA,QAAM,EAAE,KAAK,IAAI,YAAa,SAAU;AACxC,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL;AAAA,MACA,MAAO,CAAE,MAAM,IAAI,WAAW;AAAA,MAC9B,OAAQ,GAAI,MAAO;AAAA,MACnB,UAAW,gBAAgB,QAAS,GAAI;AAAA,MAIxC,iBAAgB,CAAE;AAAA,MAClB,SAAU,UAAU,OAAO;AAAA,MAC3B,MAAK;AAAA;AAAA,EACN;AAEF;AAEA,IAAO,eAAQ,WAAY,UAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// packages/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js
|
|
1
2
|
import { __ } from "@wordpress/i18n";
|
|
2
|
-
|
|
3
|
+
var textFormattingShortcuts = [
|
|
3
4
|
{
|
|
4
5
|
keyCombination: { modifier: "primary", character: "b" },
|
|
5
6
|
description: __("Make the selected text bold.")
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/keyboard-shortcut-help-modal/config.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const textFormattingShortcuts = [\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'b' },\n\t\tdescription: __( 'Make the selected text bold.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'i' },\n\t\tdescription: __( 'Make the selected text italic.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'k' },\n\t\tdescription: __( 'Convert the selected text into a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'k' },\n\t\tdescription: __( 'Remove a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { character: '[[' },\n\t\tdescription: __( 'Insert a link to a post or page.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'u' },\n\t\tdescription: __( 'Underline the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'd' },\n\t\tdescription: __( 'Strikethrough the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'x' },\n\t\tdescription: __( 'Make the selected text inline code.' ),\n\t},\n\t{\n\t\tkeyCombination: {\n\t\t\tmodifier: 'access',\n\t\t\tcharacter: '0',\n\t\t},\n\t\taliases: [\n\t\t\t{\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: '7',\n\t\t\t},\n\t\t],\n\t\tdescription: __( 'Convert the current heading to a paragraph.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: '1-6' },\n\t\tdescription: __(\n\t\t\t'Convert the current paragraph or heading to a heading of level 1 to 6.'\n\t\t),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'SPACE' },\n\t\tdescription: __( 'Add non breaking space.' ),\n\t},\n];\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,UAAU;AAEZ,
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AAEZ,IAAM,0BAA0B;AAAA,EACtC;AAAA,IACC,gBAAgB,EAAE,UAAU,WAAW,WAAW,IAAI;AAAA,IACtD,aAAa,GAAI,8BAA+B;AAAA,EACjD;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,UAAU,WAAW,WAAW,IAAI;AAAA,IACtD,aAAa,GAAI,gCAAiC;AAAA,EACnD;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,UAAU,WAAW,WAAW,IAAI;AAAA,IACtD,aAAa,GAAI,wCAAyC;AAAA,EAC3D;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,UAAU,gBAAgB,WAAW,IAAI;AAAA,IAC3D,aAAa,GAAI,gBAAiB;AAAA,EACnC;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,WAAW,KAAK;AAAA,IAClC,aAAa,GAAI,kCAAmC;AAAA,EACrD;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,UAAU,WAAW,WAAW,IAAI;AAAA,IACtD,aAAa,GAAI,8BAA+B;AAAA,EACjD;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,UAAU,UAAU,WAAW,IAAI;AAAA,IACrD,aAAa,GAAI,kCAAmC;AAAA,EACrD;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,UAAU,UAAU,WAAW,IAAI;AAAA,IACrD,aAAa,GAAI,qCAAsC;AAAA,EACxD;AAAA,EACA;AAAA,IACC,gBAAgB;AAAA,MACf,UAAU;AAAA,MACV,WAAW;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACR;AAAA,QACC,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA,IACD;AAAA,IACA,aAAa,GAAI,6CAA8C;AAAA,EAChE;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,UAAU,UAAU,WAAW,MAAM;AAAA,IACvD,aAAa;AAAA,MACZ;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,gBAAgB,EAAE,UAAU,gBAAgB,WAAW,QAAQ;AAAA,IAC/D,aAAa,GAAI,yBAA0B;AAAA,EAC5C;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|