@wordpress/edit-widgets 7.1.0 → 7.3.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.cjs +10 -8
- package/build/blocks/widget-area/edit/index.cjs.map +1 -1
- package/build/blocks/widget-area/edit/inner-blocks.cjs +10 -8
- package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -1
- package/build/blocks/widget-area/index.cjs +9 -7
- package/build/blocks/widget-area/index.cjs.map +1 -1
- package/build/components/error-boundary/index.cjs +1 -1
- package/build/components/error-boundary/index.cjs.map +1 -1
- package/build/components/header/document-tools/index.cjs +20 -10
- package/build/components/header/document-tools/index.cjs.map +1 -1
- package/build/components/header/index.cjs +18 -11
- package/build/components/header/index.cjs.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.cjs +5 -0
- package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +9 -7
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.cjs +12 -11
- package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +35 -13
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -1
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
- package/build/components/layout/index.cjs +19 -13
- package/build/components/layout/index.cjs.map +1 -1
- package/build/components/layout/interface.cjs +27 -13
- package/build/components/layout/interface.cjs.map +1 -1
- package/build/components/layout/unsaved-changes-warning.cjs +3 -6
- package/build/components/layout/unsaved-changes-warning.cjs.map +1 -1
- package/build/components/more-menu/index.cjs +14 -10
- package/build/components/more-menu/index.cjs.map +1 -1
- package/build/components/secondary-sidebar/index.cjs +10 -8
- package/build/components/secondary-sidebar/index.cjs.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.cjs +9 -7
- package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -1
- package/build/components/sidebar/index.cjs +23 -15
- package/build/components/sidebar/index.cjs.map +1 -1
- package/build/components/welcome-guide/index.cjs +5 -1
- package/build/components/welcome-guide/index.cjs.map +1 -1
- package/build/components/widget-areas-block-editor-content/index.cjs +10 -8
- package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.cjs +10 -8
- package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -1
- package/build/constants.cjs +0 -2
- package/build/constants.cjs.map +1 -1
- package/build/index.cjs +12 -10
- package/build/index.cjs.map +1 -1
- package/build/store/actions.cjs +20 -9
- package/build/store/actions.cjs.map +1 -1
- package/build/store/index.cjs +14 -12
- package/build/store/index.cjs.map +1 -1
- package/build/store/selectors.cjs +3 -1
- package/build/store/selectors.cjs.map +1 -1
- package/build-module/blocks/widget-area/index.mjs.map +1 -1
- package/build-module/components/error-boundary/index.mjs +2 -2
- package/build-module/components/error-boundary/index.mjs.map +1 -1
- package/build-module/components/header/document-tools/index.mjs +10 -2
- package/build-module/components/header/document-tools/index.mjs.map +1 -1
- package/build-module/components/header/index.mjs +6 -2
- package/build-module/components/header/index.mjs.map +1 -1
- package/build-module/components/header/undo-redo/redo.mjs.map +1 -1
- package/build-module/components/header/undo-redo/undo.mjs.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs +5 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +35 -13
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -1
- package/build-module/components/layout/index.mjs +5 -1
- package/build-module/components/layout/index.mjs.map +1 -1
- package/build-module/components/layout/interface.mjs +16 -4
- package/build-module/components/layout/interface.mjs.map +1 -1
- package/build-module/components/layout/unsaved-changes-warning.mjs +3 -6
- package/build-module/components/layout/unsaved-changes-warning.mjs.map +1 -1
- package/build-module/components/more-menu/index.mjs +4 -2
- package/build-module/components/more-menu/index.mjs.map +1 -1
- package/build-module/components/sidebar/index.mjs +14 -8
- package/build-module/components/sidebar/index.mjs.map +1 -1
- package/build-module/components/welcome-guide/index.mjs +5 -1
- package/build-module/components/welcome-guide/index.mjs.map +1 -1
- package/build-module/constants.mjs +1 -2
- package/build-module/constants.mjs.map +1 -1
- package/build-module/index.mjs +2 -2
- package/build-module/index.mjs.map +1 -1
- package/build-module/store/actions.mjs +20 -9
- package/build-module/store/actions.mjs.map +1 -1
- package/build-module/store/selectors.mjs +3 -1
- package/build-module/store/selectors.mjs.map +1 -1
- package/build-style/style-rtl.css +72 -46
- package/build-style/style.css +72 -46
- package/build-types/blocks/widget-area/edit/index.d.ts +10 -0
- package/build-types/blocks/widget-area/edit/index.d.ts.map +1 -0
- package/build-types/blocks/widget-area/edit/inner-blocks.d.ts +4 -0
- package/build-types/blocks/widget-area/edit/inner-blocks.d.ts.map +1 -0
- package/build-types/blocks/widget-area/edit/use-is-dragging-within.d.ts +12 -0
- package/build-types/blocks/widget-area/edit/use-is-dragging-within.d.ts.map +1 -0
- package/build-types/blocks/widget-area/index.d.ts +14 -0
- package/build-types/blocks/widget-area/index.d.ts.map +1 -0
- package/build-types/components/error-boundary/index.d.ts +14 -0
- package/build-types/components/error-boundary/index.d.ts.map +1 -0
- package/build-types/components/header/document-tools/index.d.ts +3 -0
- package/build-types/components/header/document-tools/index.d.ts.map +1 -0
- package/build-types/components/header/index.d.ts +3 -0
- package/build-types/components/header/index.d.ts.map +1 -0
- package/build-types/components/header/undo-redo/redo.d.ts +3 -0
- package/build-types/components/header/undo-redo/redo.d.ts.map +1 -0
- package/build-types/components/header/undo-redo/undo.d.ts +3 -0
- package/build-types/components/header/undo-redo/undo.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +3 -0
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts +5 -0
- package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/index.d.ts +5 -0
- package/build-types/components/keyboard-shortcut-help-modal/index.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +25 -0
- package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcuts/index.d.ts +7 -0
- package/build-types/components/keyboard-shortcuts/index.d.ts.map +1 -0
- package/build-types/components/layout/index.d.ts +5 -0
- package/build-types/components/layout/index.d.ts.map +1 -0
- package/build-types/components/layout/interface.d.ts +5 -0
- package/build-types/components/layout/interface.d.ts.map +1 -0
- package/build-types/components/layout/unsaved-changes-warning.d.ts +10 -0
- package/build-types/components/layout/unsaved-changes-warning.d.ts.map +1 -0
- package/build-types/components/more-menu/index.d.ts +2 -0
- package/build-types/components/more-menu/index.d.ts.map +1 -0
- package/build-types/components/more-menu/tools-more-menu-group.d.ts +6 -0
- package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -0
- package/build-types/components/notices/index.d.ts +3 -0
- package/build-types/components/notices/index.d.ts.map +1 -0
- package/build-types/components/save-button/index.d.ts +3 -0
- package/build-types/components/save-button/index.d.ts.map +1 -0
- package/build-types/components/secondary-sidebar/index.d.ts +2 -0
- package/build-types/components/secondary-sidebar/index.d.ts.map +1 -0
- package/build-types/components/secondary-sidebar/inserter-sidebar.d.ts +2 -0
- package/build-types/components/secondary-sidebar/inserter-sidebar.d.ts.map +1 -0
- package/build-types/components/secondary-sidebar/list-view-sidebar.d.ts +2 -0
- package/build-types/components/secondary-sidebar/list-view-sidebar.d.ts.map +1 -0
- package/build-types/components/sidebar/index.d.ts +2 -0
- package/build-types/components/sidebar/index.d.ts.map +1 -0
- package/build-types/components/sidebar/widget-areas.d.ts +4 -0
- package/build-types/components/sidebar/widget-areas.d.ts.map +1 -0
- package/build-types/components/welcome-guide/index.d.ts +2 -0
- package/build-types/components/welcome-guide/index.d.ts.map +1 -0
- package/build-types/components/widget-areas-block-editor-content/index.d.ts +4 -0
- package/build-types/components/widget-areas-block-editor-content/index.d.ts.map +1 -0
- package/build-types/components/widget-areas-block-editor-provider/index.d.ts +6 -0
- package/build-types/components/widget-areas-block-editor-provider/index.d.ts.map +1 -0
- package/build-types/constants.d.ts +2 -0
- package/build-types/constants.d.ts.map +1 -0
- package/build-types/filters/index.d.ts +3 -0
- package/build-types/filters/index.d.ts.map +1 -0
- package/build-types/filters/move-to-widget-area.d.ts +2 -0
- package/build-types/filters/move-to-widget-area.d.ts.map +1 -0
- package/build-types/filters/replace-media-upload.d.ts +2 -0
- package/build-types/filters/replace-media-upload.d.ts.map +1 -0
- package/build-types/hooks/use-last-selected-widget-area.d.ts +9 -0
- package/build-types/hooks/use-last-selected-widget-area.d.ts.map +1 -0
- package/build-types/hooks/use-widget-library-insertion-point.d.ts +3 -0
- package/build-types/hooks/use-widget-library-insertion-point.d.ts.map +1 -0
- package/build-types/index.d.ts +16 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/store/actions.d.ts +144 -0
- package/build-types/store/actions.d.ts.map +1 -0
- package/build-types/store/constants.d.ts +5 -0
- package/build-types/store/constants.d.ts.map +1 -0
- package/build-types/store/index.d.ts +9 -0
- package/build-types/store/index.d.ts.map +1 -0
- package/build-types/store/private-selectors.d.ts +3 -0
- package/build-types/store/private-selectors.d.ts.map +1 -0
- package/build-types/store/reducer.d.ts +73 -0
- package/build-types/store/reducer.d.ts.map +1 -0
- package/build-types/store/resolvers.d.ts +17 -0
- package/build-types/store/resolvers.d.ts.map +1 -0
- package/build-types/store/selectors.d.ts +159 -0
- package/build-types/store/selectors.d.ts.map +1 -0
- package/build-types/store/transformers.d.ts +16 -0
- package/build-types/store/transformers.d.ts.map +1 -0
- package/build-types/store/utils.d.ts +53 -0
- package/build-types/store/utils.d.ts.map +1 -0
- package/package.json +33 -33
- package/src/components/error-boundary/index.jsx +2 -2
- package/src/components/header/index.jsx +11 -2
- package/src/components/header/style.scss +30 -3
- package/src/components/keyboard-shortcut-help-modal/config.js +3 -0
- package/src/components/keyboard-shortcut-help-modal/index.jsx +0 -2
- package/src/components/keyboard-shortcut-help-modal/shortcut.jsx +44 -29
- package/src/components/keyboard-shortcut-help-modal/style.scss +1 -1
- package/src/components/layout/style.scss +5 -9
- package/src/components/layout/unsaved-changes-warning.js +4 -9
- package/src/components/more-menu/index.jsx +0 -1
- package/src/components/sidebar/index.jsx +1 -1
- package/src/components/sidebar/style.scss +6 -0
- package/src/components/welcome-guide/style.scss +1 -1
- package/src/components/widget-areas-block-editor-content/style.scss +1 -1
- package/src/constants.js +0 -1
- package/src/index.jsx +2 -7
- package/src/store/actions.js +33 -14
- package/src/store/selectors.js +4 -1
- package/src/store/test/actions.jsdom.test.js +275 -0
|
@@ -10,6 +10,7 @@ let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
|
10
10
|
let __utils_js = require("./utils.cjs");
|
|
11
11
|
let __constants_js = require("./constants.cjs");
|
|
12
12
|
// packages/edit-widgets/src/store/selectors.js
|
|
13
|
+
/** @typedef {import('@wordpress/blocks').Block} Block */
|
|
13
14
|
const EMPTY_INSERTION_POINT = {
|
|
14
15
|
rootClientId: void 0,
|
|
15
16
|
insertionIndex: void 0
|
|
@@ -60,7 +61,8 @@ const getWidgetAreaForWidgetId = (0, _wordpress_data.createRegistrySelector)((se
|
|
|
60
61
|
*
|
|
61
62
|
* @param {string} clientId The client id of a block in a widget area.
|
|
62
63
|
*
|
|
63
|
-
* @return {
|
|
64
|
+
* @return {Block | null} The widget area block.
|
|
65
|
+
* @type {(state: Record<string, unknown>, clientId: string) => Block | null}
|
|
64
66
|
*/
|
|
65
67
|
const getParentWidgetAreaBlock = (0, _wordpress_data.createRegistrySelector)((select) => (state, clientId) => {
|
|
66
68
|
const { getBlock, getBlockName, getBlockParents } = select(_wordpress_block_editor.store);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.cjs","names":["createRegistrySelector","createSelector","coreStore","buildWidgetsQuery","editWidgetsStoreName","buildWidgetAreasQuery","KIND","WIDGET_AREA_ENTITY_TYPE","POST_TYPE","buildWidgetAreaPostId","getWidgetIdFromBlock","blockEditorStore"],"sources":["../../src/store/selectors.js"],"sourcesContent":["import { 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';\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\tif ( ! firstWidgetArea ) {\n\t\t\treturn false;\n\t\t}\n\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"],"mappings":";;;;;;;;;;;;AAcA,MAAM,wBAAwB;CAC7B,cAAc,KAAA;CACd,gBAAgB,KAAA;AACjB;;;;;;AAOA,MAAa,cAAA,GAAaA,gBAAAA,uBAAAA,EAA0B,YAAA,GACnDC,gBAAAA,eAAAA,OACO;CAOL,OANgB,OAAQC,qBAAAA,KAAU,CAAC,CAAC,iBACnC,QACA,WAAA,GACAC,WAAAA,kBAAAA,CAAkB,CAKZ,CAAC,EAAE,QACN,YAAY,YAAc;EAC3B,GAAG;GACD,OAAO,KAAM;CAChB,IACA,CAAC,CACF,KAAK,CAAC;AAER,SACM,CACL,OAAQD,qBAAAA,KAAU,CAAC,CAAC,iBACnB,QACA,WAAA,GACAC,WAAAA,kBAAAA,CAAkB,CACnB,CACD,CACD,CACD;;;;;;;;AASA,MAAa,aAAA,GAAYH,gBAAAA,uBAAAA,EACtB,YAAc,OAAO,OAAQ;CAE9B,OADgB,OAAQI,eAAAA,UAAqB,CAAC,CAAC,WAClC,CAAC,CAAE;AACjB,CACD;;;;;;AAOA,MAAa,kBAAA,GAAiBJ,gBAAAA,uBAAAA,EAA0B,iBAAkB;CACzE,MAAM,SAAA,GAAQK,WAAAA,sBAAAA,CAAsB;CACpC,OAAO,OAAQH,qBAAAA,KAAU,CAAC,CAAC,iBAC1BI,WAAAA,MACAC,WAAAA,yBACA,KACD;AACD,CAAE;;;;;;;AAQF,MAAa,4BAAA,GAA2BP,gBAAAA,uBAAAA,EACrC,YAAc,OAAO,aAAc;CAEpC,OADoB,OAAQI,eAAAA,UAAqB,CAAC,CAAC,eAClC,CAAC,CAAC,MAAQ,eAAgB;EAS1C,OARa,OAAQF,qBAAAA,KAAU,CAAC,CAAC,sBAChCI,WAAAA,MACAE,WAA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QACjB;AACD,CACD;;;;;;;;AASA,SAAgB,iBAAkB,OAAQ;CACzC,OAAO,MAAM;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,qBAAsB,OAAQ;CAC7C,OAAO,OAAO,KAAM,MAAM,gBAAiB,CAAC,CAAC,SAAS;AACvD"}
|
|
1
|
+
{"version":3,"file":"selectors.cjs","names":["createRegistrySelector","createSelector","coreStore","buildWidgetsQuery","editWidgetsStoreName","buildWidgetAreasQuery","KIND","WIDGET_AREA_ENTITY_TYPE","POST_TYPE","buildWidgetAreaPostId","getWidgetIdFromBlock","blockEditorStore"],"sources":["../../src/store/selectors.js"],"sourcesContent":["import { 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';\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\n/** @typedef {import('@wordpress/blocks').Block} Block */\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 {Block | null} The widget area block.\n * @type {(state: Record<string, unknown>, clientId: string) => Block | null}\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\tif ( ! firstWidgetArea ) {\n\t\t\treturn false;\n\t\t}\n\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"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,wBAAwB;CAC7B,cAAc,KAAA;CACd,gBAAgB,KAAA;AACjB;;;;;;AAOA,MAAa,cAAA,GAAaA,gBAAAA,uBAAAA,EAA0B,YAAA,GACnDC,gBAAAA,eAAAA,OACO;CAOL,OANgB,OAAQC,qBAAAA,KAAU,CAAC,CAAC,iBACnC,QACA,WAAA,GACAC,WAAAA,kBAAAA,CAAkB,CAKZ,CAAC,EAAE,QACN,YAAY,YAAc;EAC3B,GAAG;GACD,OAAO,KAAM;CAChB,IACA,CAAC,CACF,KAAK,CAAC;AAER,SACM,CACL,OAAQD,qBAAAA,KAAU,CAAC,CAAC,iBACnB,QACA,WAAA,GACAC,WAAAA,kBAAAA,CAAkB,CACnB,CACD,CACD,CACD;;;;;;;;AASA,MAAa,aAAA,GAAYH,gBAAAA,uBAAAA,EACtB,YAAc,OAAO,OAAQ;CAE9B,OADgB,OAAQI,eAAAA,UAAqB,CAAC,CAAC,WAClC,CAAC,CAAE;AACjB,CACD;;;;;;AAOA,MAAa,kBAAA,GAAiBJ,gBAAAA,uBAAAA,EAA0B,iBAAkB;CACzE,MAAM,SAAA,GAAQK,WAAAA,sBAAAA,CAAsB;CACpC,OAAO,OAAQH,qBAAAA,KAAU,CAAC,CAAC,iBAC1BI,WAAAA,MACAC,WAAAA,yBACA,KACD;AACD,CAAE;;;;;;;AAQF,MAAa,4BAAA,GAA2BP,gBAAAA,uBAAAA,EACrC,YAAc,OAAO,aAAc;CAEpC,OADoB,OAAQI,eAAAA,UAAqB,CAAC,CAAC,eAClC,CAAC,CAAC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AK,CAAE,iBACN,OAAO;CAGR,OAAO,OAAQA,wBAAAA,KAAiB,CAAC,CAAC,mBACjC,WACA,gBAAgB,QACjB;AACD,CACD;;;;;;;;AASA,SAAgB,iBAAkB,OAAQ;CACzC,OAAO,MAAM;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,qBAAsB,OAAQ;CAC7C,OAAO,OAAO,KAAM,MAAM,gBAAiB,CAAC,CAAC,SAAS;AACvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/blocks/widget-area/index.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { layout as icon } from '@wordpress/icons';\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\ticon,\n\tedit,\n};\n"],"mappings":";;;;;AAKA,MAAM,EAAE,SAAS;AAGjB,MAAa,WAAW;CACvB,OAAO,GAAI,aAAc;CACzB,aAAa,GAAI,0BAA2B;CAC5C,sBAAuB,EAAE,MAAM,YAAa;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["icon"],"sources":["../../../src/blocks/widget-area/index.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { layout as icon } from '@wordpress/icons';\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\ticon,\n\tedit,\n};\n"],"mappings":";;;;;AAKA,MAAM,EAAE,SAAS;AAGjB,MAAa,WAAW;CACvB,OAAO,GAAI,aAAc;CACzB,aAAa,GAAI,0BAA2B;CAC5C,sBAAuB,EAAE,MAAM,YAAa;CAC5CA,MAAAA;CACA;AACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from "@wordpress/element";
|
|
2
2
|
import { speak } from "@wordpress/a11y";
|
|
3
|
-
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { __, _x } from "@wordpress/i18n";
|
|
4
4
|
import { Card, CollapsibleCard, Notice, Stack, Text } from "@wordpress/ui";
|
|
5
5
|
import { useCopyToClipboard } from "@wordpress/compose";
|
|
6
6
|
import { doAction } from "@wordpress/hooks";
|
|
@@ -113,7 +113,7 @@ var ErrorBoundary = class extends Component {
|
|
|
113
113
|
/* @__PURE__ */ jsx(Notice.Actions, { children: /* @__PURE__ */ jsx(CopyButton, {
|
|
114
114
|
variant: "solid",
|
|
115
115
|
text: () => getErrorReport(error, componentStack),
|
|
116
|
-
children:
|
|
116
|
+
children: _x("Copy error", "button label")
|
|
117
117
|
}) })
|
|
118
118
|
]
|
|
119
119
|
}), globalThis.SCRIPT_DEBUG ? /* @__PURE__ */ jsx(ErrorDetails, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/error-boundary/index.jsx"],"sourcesContent":["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction getErrorNotice() {\n\treturn {\n\t\ttitle: __( 'The editor has crashed' ),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"edit-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"edit-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"edit-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\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\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tconst { title, description } = getErrorNotice();\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { title, description } = getErrorNotice();\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"edit-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/error-boundary/index.jsx"],"sourcesContent":["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { __, _x } from '@wordpress/i18n';\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction getErrorNotice() {\n\treturn {\n\t\ttitle: __( 'The editor has crashed' ),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"edit-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"edit-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"edit-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\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\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tconst { title, description } = getErrorNotice();\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { title, description } = getErrorNotice();\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"edit-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Copy error', 'button label' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null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AO,OAAR,EAAA,UAAgB,MAAqB,CAAA;KACrC,oBAAC,OAAO,aAAR,EAAA,UAAsB,YAAiC,CAAA;KACvD,oBAAC,OAAO,SAAR,EAAA,UACC,oBAAC,YAAD;MACC,SAAQ;MACR,YACC,eAAgB,OAAO,cAAe;MAGrC,UAAA,GAAI,cAAc,cAAe;KACxB,CAAA,EACG,CAAA;IACJ;GACX,CAAA,GAAA,WAAW,eACZ,oBAAC,cAAD;IACS;IACS;GACjB,CAAA,IACE,IACE;;CAET;AACD"}
|
|
@@ -40,7 +40,12 @@ function DocumentTools() {
|
|
|
40
40
|
},
|
|
41
41
|
onClick: toggleInserterSidebar,
|
|
42
42
|
icon: plus,
|
|
43
|
-
label: _x(
|
|
43
|
+
label: _x(
|
|
44
|
+
/** translators: button label text should, if possible, be under 16
|
|
45
|
+
characters. */
|
|
46
|
+
"Block Inserter",
|
|
47
|
+
"Generic label for block inserter button"
|
|
48
|
+
),
|
|
44
49
|
size: "compact"
|
|
45
50
|
}), isMediumViewport && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
46
51
|
/* @__PURE__ */ jsx(ToolbarItem, { as: UndoButton }),
|
|
@@ -50,7 +55,10 @@ function DocumentTools() {
|
|
|
50
55
|
className: "edit-widgets-header-toolbar__list-view-toggle",
|
|
51
56
|
icon: listView,
|
|
52
57
|
isPressed: isListViewOpen,
|
|
53
|
-
label: __(
|
|
58
|
+
label: __(
|
|
59
|
+
/** translators: button label text should, if possible, be under 16 characters. */
|
|
60
|
+
"List View"
|
|
61
|
+
),
|
|
54
62
|
onClick: toggleListView,
|
|
55
63
|
ref: listViewToggleRef,
|
|
56
64
|
size: "compact"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["editWidgetsStore"],"sources":["../../../../src/components/header/document-tools/index.jsx"],"sourcesContent":["import { 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';\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"],"mappings":";;;;;;;;;;;;;AAYA,SAAS,gBAAgB;CACxB,MAAM,mBAAmB,iBAAkB,QAAS;CAEpD,MAAM,EACL,gBACA,gBACA,0BACA,sBACG,WAAa,WAAY;EAC5B,MAAM,EACL,kBACA,6BACA,kBACA,yBACG,OAAQ,OAAQA,KAAiB,CAAE;EACvC,OAAO;GACN,gBAAgB,iBAAiB;GACjC,gBAAgB,iBAAiB;GACjC,0BAA0B,4BAA4B;GACtD,mBAAmB,qBAAqB;EACzC;CACD,GAAG,CAAC,CAAE;CACN,MAAM,EAAE,qBAAqB,wBAC5B,YAAaA,KAAiB;CAE/B,MAAM,iBAAiB,kBAChB,oBAAqB,CAAE,cAAe,GAC5C,CAAE,qBAAqB,cAAe,CACvC;CAEA,MAAM,wBAAwB,kBACvB,oBAAqB,CAAE,cAAe,GAC5C,CAAE,qBAAqB,cAAe,CACvC;CAEA,OACC,qBAAC,kBAAD;EACC,WAAU;EACV,cAAa,GAAI,gBAAiB;EAClC,SAAQ;EAHT,UAAA,CAKC,oBAAC,aAAD;GACC,KAAM;GACN,IAAK;GACL,WAAU;GACV,SAAQ;GACR,WAAY;GACZ,cAAgB,UAAW;IAC1B,MAAM,eAAe;GACtB;GACA,SAAU;GACV,MAAO;GAGP,OAAQ
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["editWidgetsStore"],"sources":["../../../../src/components/header/document-tools/index.jsx"],"sourcesContent":["import { 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';\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"],"mappings":";;;;;;;;;;;;;AAYA,SAAS,gBAAgB;CACxB,MAAM,mBAAmB,iBAAkB,QAAS;CAEpD,MAAM,EACL,gBACA,gBACA,0BACA,sBACG,WAAa,WAAY;EAC5B,MAAM,EACL,kBACA,6BACA,kBACA,yBACG,OAAQ,OAAQA,KAAiB,CAAE;EACvC,OAAO;GACN,gBAAgB,iBAAiB;GACjC,gBAAgB,iBAAiB;GACjC,0BAA0B,4BAA4B;GACtD,mBAAmB,qBAAqB;EACzC;CACD,GAAG,CAAC,CAAE;CACN,MAAM,EAAE,qBAAqB,wBAC5B,YAAaA,KAAiB;CAE/B,MAAM,iBAAiB,kBAChB,oBAAqB,CAAE,cAAe,GAC5C,CAAE,qBAAqB,cAAe,CACvC;CAEA,MAAM,wBAAwB,kBACvB,oBAAqB,CAAE,cAAe,GAC5C,CAAE,qBAAqB,cAAe,CACvC;CAEA,OACC,qBAAC,kBAAD;EACC,WAAU;EACV,cAAa,GAAI,gBAAiB;EAClC,SAAQ;EAHT,UAAA,CAKC,oBAAC,aAAD;GACC,KAAM;GACN,IAAK;GACL,WAAU;GACV,SAAQ;GACR,WAAY;GACZ,cAAgB,UAAW;IAC1B,MAAM,eAAe;GACtB;GACA,SAAU;GACV,MAAO;GAGP,OAAQ;;;IACP;IACA;GACD;GACA,MAAK;EACL,CAAA,GACC,oBACD,qBAAA,UAAA,EAAA,UAAA;GACC,oBAAC,aAAD,EAAa,IAAK,WAAc,CAAA;GAChC,oBAAC,aAAD,EAAa,IAAK,WAAc,CAAA;GAChC,oBAAC,aAAD;IACC,IAAK;IACL,WAAU;IACV,MAAO;IACP,WAAY;IAEZ,OAAQ;;KAAI;IAAY;IACxB,SAAU;IACV,KAAM;IACN,MAAK;GACL,CAAA;EACA,EAAA,CAAA,CAEc;;AAEpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
1
2
|
import { BlockToolbar } from "@wordpress/block-editor";
|
|
2
3
|
import { useSelect } from "@wordpress/data";
|
|
3
4
|
import { useRef } from "@wordpress/element";
|
|
@@ -15,9 +16,12 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
15
16
|
function Header() {
|
|
16
17
|
const isLargeViewport = useViewportMatch("medium");
|
|
17
18
|
const blockToolbarRef = useRef();
|
|
18
|
-
const { hasFixedToolbar } = useSelect((select) => ({
|
|
19
|
+
const { hasFixedToolbar, showIconLabels } = useSelect((select) => ({
|
|
20
|
+
hasFixedToolbar: !!select(store).get("core/edit-widgets", "fixedToolbar"),
|
|
21
|
+
showIconLabels: select(store).get("core", "showIconLabels")
|
|
22
|
+
}), []);
|
|
19
23
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", {
|
|
20
|
-
className: "edit-widgets-header",
|
|
24
|
+
className: clsx("edit-widgets-header", { "has-icon-labels": showIconLabels }),
|
|
21
25
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
22
26
|
className: "edit-widgets-header__navigable-toolbar-wrapper",
|
|
23
27
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["preferencesStore","WCPopover"],"sources":["../../../src/components/header/index.jsx"],"sourcesContent":["import { BlockToolbar } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Popover as WCPopover } from '@wordpress/components';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { VisuallyHidden } from '@wordpress/ui';\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
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["preferencesStore","WCPopover"],"sources":["../../../src/components/header/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { BlockToolbar } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Popover as WCPopover } from '@wordpress/components';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { VisuallyHidden } from '@wordpress/ui';\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, showIconLabels } = 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\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'edit-widgets-header', {\n\t\t\t\t\t'has-icon-labels': showIconLabels,\n\t\t\t\t} ) }\n\t\t\t>\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\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t\trender={ <h1 /> }\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<WCPopover.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"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,SAAS;CACjB,MAAM,kBAAkB,iBAAkB,QAAS;CACnD,MAAM,kBAAkB,OAAO;CAC/B,MAAM,EAAE,iBAAiB,mBAAmB,WACzC,YAAc;EACf,iBAAiB,CAAC,CAAE,OAAQA,KAAiB,CAAC,CAAC,IAC9C,qBACA,cACD;EACA,gBAAgB,OAAQA,KAAiB,CAAC,CAAC,IAC1C,QACA,gBACD;CACD,IACA,CAAC,CACF;CAEA,OACC,oBAAA,UAAA,EAAA,UACC,qBAAC,OAAD;EACC,WAAY,KAAM,uBAAuB,EACxC,mBAAmB,eACpB,CAAE;EAHH,UAAA,CAKC,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACG,mBACD,oBAAC,MAAD;KAAI,WAAU;KACX,UAAA,GAAI,SAAU;IACb,CAAA;IAEH,CAAE,mBACH,oBAAC,gBAAD;KACC,WAAU;KACV,QAAS,oBAAC,MAAD,CAAK,CAAA;KAEZ,UAAA,GAAI,SAAU;IACD,CAAA;IAEjB,oBAAC,eAAD,CAAgB,CAAA;IACd,mBAAmB,mBACpB,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,OAAD;KAAK,WAAU;KACd,UAAA,oBAAC,cAAD,EAAc,gBAAA,KAAgB,CAAA;IAC1B,CAAA,GACL,oBAACC,QAAU,MAAX;KACC,KAAM;KACN,MAAK;IACL,CAAA,CACA,EAAA,CAAA;GAEC;EACL,CAAA,GAAA,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACC,oBAAC,YAAY,MAAb,EAAkB,OAAM,oBAAqB,CAAA;IAC7C,oBAAC,YAAD,CAAa,CAAA;IACb,oBAAC,UAAD,CAAW,CAAA;GACP;EACD,CAAA,CAAA;CACJ,CAAA,EAAA,CAAA;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redo.mjs","names":["coreStore","
|
|
1
|
+
{"version":3,"file":"redo.mjs","names":["coreStore","redo","redoIcon","undoIcon"],"sources":["../../../../src/components/header/undo-redo/redo.jsx"],"sourcesContent":["import { __, 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"],"mappings":";;;;;;;;;AAQA,SAAS,WAAY,OAAO,KAAM;CACjC,MAAM,WAAW,UAAU,IACxB,gBAAgB,aAAc,GAAI,IAClC,gBAAgB,QAAS,GAAI;CAEhC,MAAM,UAAU,WACb,WAAY,OAAQA,KAAU,CAAC,CAAC,QAAQ,GAC1C,CAAC,CACF;CACA,MAAM,EAAEC,MAAAA,WAAS,YAAaD,KAAU;CACxC,OACC,oBAAC,QAAD;EACC,GAAK;EACC;EACN,MAAO,CAAE,MAAM,IAAIE,OAAWC;EAC9B,OAAQ,GAAI,MAAO;EACR;EAIX,iBAAgB,CAAE;EAClB,SAAU,UAAUF,SAAO,KAAA;EAC3B,MAAK;CACL,CAAA;AAEH;AAEA,IAAA,eAAe,WAAY,UAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undo.mjs","names":["coreStore","
|
|
1
|
+
{"version":3,"file":"undo.mjs","names":["coreStore","undo","undoIcon","redoIcon"],"sources":["../../../../src/components/header/undo-redo/undo.jsx"],"sourcesContent":["import { __, 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"],"mappings":";;;;;;;;;AAQA,SAAS,WAAY,OAAO,KAAM;CACjC,MAAM,UAAU,WACb,WAAY,OAAQA,KAAU,CAAC,CAAC,QAAQ,GAC1C,CAAC,CACF;CACA,MAAM,EAAEC,MAAAA,WAAS,YAAaD,KAAU;CACxC,OACC,oBAAC,QAAD;EACC,GAAK;EACC;EACN,MAAO,CAAE,MAAM,IAAIE,OAAWC;EAC9B,OAAQ,GAAI,MAAO;EACnB,UAAW,gBAAgB,QAAS,GAAI;EAIxC,iBAAgB,CAAE;EAClB,SAAU,UAAUF,SAAO,KAAA;EAC3B,MAAK;CACL,CAAA;AAEH;AAEA,IAAA,eAAe,WAAY,UAAW"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __ } from "@wordpress/i18n";
|
|
2
2
|
// packages/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js
|
|
3
|
+
/** @type {Array<import('react').ComponentProps<typeof import('./shortcut').default>>} */
|
|
3
4
|
const textFormattingShortcuts = [
|
|
4
5
|
{
|
|
5
6
|
keyCombination: {
|
|
@@ -31,6 +32,10 @@ const textFormattingShortcuts = [
|
|
|
31
32
|
},
|
|
32
33
|
{
|
|
33
34
|
keyCombination: { character: "[[" },
|
|
35
|
+
ariaLabel: __(
|
|
36
|
+
/** translators: The keyboard sequence [[, pressing the left bracket key twice. */
|
|
37
|
+
"Left bracket twice"
|
|
38
|
+
),
|
|
34
39
|
description: __("Insert a link to a post or page.")
|
|
35
40
|
},
|
|
36
41
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../../../src/components/keyboard-shortcut-help-modal/config.js"],"sourcesContent":["import { __ } 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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../../src/components/keyboard-shortcut-help-modal/config.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\n\n/** @type {Array<import('react').ComponentProps<typeof import('./shortcut').default>>} */\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\t/* translators: The keyboard sequence [[, pressing the left bracket key twice. */\n\t\tariaLabel: __( 'Left bracket twice' ),\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"],"mappings":";;;AAGA,MAAa,0BAA0B;CACtC;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,aAAa,GAAI,8BAA+B;CACjD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,aAAa,GAAI,gCAAiC;CACnD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,aAAa,GAAI,wCAAyC;CAC3D;CACA;EACC,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAI;EAC3D,aAAa,GAAI,gBAAiB;CACnC;CACA;EACC,gBAAgB,EAAE,WAAW,KAAK;EAElC,WAAW;;GAAI;EAAqB;EACpC,aAAa,GAAI,kCAAmC;CACrD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,aAAa,GAAI,8BAA+B;CACjD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAI;EACrD,aAAa,GAAI,kCAAmC;CACrD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAI;EACrD,aAAa,GAAI,qCAAsC;CACxD;CACA;EACC,gBAAgB;GACf,UAAU;GACV,WAAW;EACZ;EACA,SAAS,CACR;GACC,UAAU;GACV,WAAW;EACZ,CACD;EACA,aAAa,GAAI,6CAA8C;CAChE;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAM;EACvD,aAAa,GACZ,wEACD;CACD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAQ;EAC/D,aAAa,GAAI,yBAA0B;CAC5C;AACD"}
|
|
@@ -57,8 +57,7 @@ function KeyboardShortcutHelpModal({ isModalActive, toggleModal }) {
|
|
|
57
57
|
categoryName: "block",
|
|
58
58
|
additionalShortcuts: [{
|
|
59
59
|
keyCombination: { character: "/" },
|
|
60
|
-
description: __("Change the block type after adding a new paragraph.")
|
|
61
|
-
ariaLabel: __("Forward-slash")
|
|
60
|
+
description: __("Change the block type after adding a new paragraph.")
|
|
62
61
|
}]
|
|
63
62
|
}),
|
|
64
63
|
/* @__PURE__ */ jsx(ShortcutSection, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["keyboardShortcutsStore"],"sources":["../../../src/components/keyboard-shortcut-help-modal/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { useSelect } from '@wordpress/data';\nimport { textFormattingShortcuts } from './config';\nimport Shortcut from './shortcut';\nimport DynamicShortcut from './dynamic-shortcut';\n\nconst ShortcutList = ( { shortcuts } ) => (\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\t<ul\n\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal__shortcut-list\"\n\t\trole=\"list\"\n\t>\n\t\t{ shortcuts.map( ( shortcut, index ) => (\n\t\t\t<li\n\t\t\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal__shortcut\"\n\t\t\t\tkey={ index }\n\t\t\t>\n\t\t\t\t{ typeof shortcut === 'string' ? (\n\t\t\t\t\t<DynamicShortcut name={ shortcut } />\n\t\t\t\t) : (\n\t\t\t\t\t<Shortcut { ...shortcut } />\n\t\t\t\t) }\n\t\t\t</li>\n\t\t) ) }\n\t</ul>\n\t/* eslint-enable jsx-a11y/no-redundant-roles */\n);\n\nconst ShortcutSection = ( { title, shortcuts, className } ) => (\n\t<section\n\t\tclassName={ clsx(\n\t\t\t'edit-widgets-keyboard-shortcut-help-modal__section',\n\t\t\tclassName\n\t\t) }\n\t>\n\t\t{ !! title && (\n\t\t\t<h2 className=\"edit-widgets-keyboard-shortcut-help-modal__section-title\">\n\t\t\t\t{ title }\n\t\t\t</h2>\n\t\t) }\n\t\t<ShortcutList shortcuts={ shortcuts } />\n\t</section>\n);\n\nconst ShortcutCategorySection = ( {\n\ttitle,\n\tcategoryName,\n\tadditionalShortcuts = [],\n} ) => {\n\tconst categoryShortcuts = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( keyboardShortcutsStore ).getCategoryShortcuts(\n\t\t\t\tcategoryName\n\t\t\t);\n\t\t},\n\t\t[ categoryName ]\n\t);\n\n\treturn (\n\t\t<ShortcutSection\n\t\t\ttitle={ title }\n\t\t\tshortcuts={ categoryShortcuts.concat( additionalShortcuts ) }\n\t\t/>\n\t);\n};\n\nexport default function KeyboardShortcutHelpModal( {\n\tisModalActive,\n\ttoggleModal,\n} ) {\n\tuseShortcut( 'core/edit-widgets/keyboard-shortcuts', toggleModal, {\n\t\tbindGlobal: true,\n\t} );\n\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ toggleModal }\n\t\t>\n\t\t\t<ShortcutSection\n\t\t\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal__main-shortcuts\"\n\t\t\t\tshortcuts={ [ 'core/edit-widgets/keyboard-shortcuts' ] }\n\t\t\t/>\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Global shortcuts' ) }\n\t\t\t\tcategoryName=\"global\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Selection shortcuts' ) }\n\t\t\t\tcategoryName=\"selection\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Block shortcuts' ) }\n\t\t\t\tcategoryName=\"block\"\n\t\t\t\tadditionalShortcuts={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tkeyCombination: { character: '/' },\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Change the block type after adding a new paragraph.'\n\t\t\t\t\t\t),\n\t\t\t\t\t
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["keyboardShortcutsStore"],"sources":["../../../src/components/keyboard-shortcut-help-modal/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { useSelect } from '@wordpress/data';\nimport { textFormattingShortcuts } from './config';\nimport Shortcut from './shortcut';\nimport DynamicShortcut from './dynamic-shortcut';\n\nconst ShortcutList = ( { shortcuts } ) => (\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\t<ul\n\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal__shortcut-list\"\n\t\trole=\"list\"\n\t>\n\t\t{ shortcuts.map( ( shortcut, index ) => (\n\t\t\t<li\n\t\t\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal__shortcut\"\n\t\t\t\tkey={ index }\n\t\t\t>\n\t\t\t\t{ typeof shortcut === 'string' ? (\n\t\t\t\t\t<DynamicShortcut name={ shortcut } />\n\t\t\t\t) : (\n\t\t\t\t\t<Shortcut { ...shortcut } />\n\t\t\t\t) }\n\t\t\t</li>\n\t\t) ) }\n\t</ul>\n\t/* eslint-enable jsx-a11y/no-redundant-roles */\n);\n\nconst ShortcutSection = ( { title, shortcuts, className } ) => (\n\t<section\n\t\tclassName={ clsx(\n\t\t\t'edit-widgets-keyboard-shortcut-help-modal__section',\n\t\t\tclassName\n\t\t) }\n\t>\n\t\t{ !! title && (\n\t\t\t<h2 className=\"edit-widgets-keyboard-shortcut-help-modal__section-title\">\n\t\t\t\t{ title }\n\t\t\t</h2>\n\t\t) }\n\t\t<ShortcutList shortcuts={ shortcuts } />\n\t</section>\n);\n\nconst ShortcutCategorySection = ( {\n\ttitle,\n\tcategoryName,\n\tadditionalShortcuts = [],\n} ) => {\n\tconst categoryShortcuts = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( keyboardShortcutsStore ).getCategoryShortcuts(\n\t\t\t\tcategoryName\n\t\t\t);\n\t\t},\n\t\t[ categoryName ]\n\t);\n\n\treturn (\n\t\t<ShortcutSection\n\t\t\ttitle={ title }\n\t\t\tshortcuts={ categoryShortcuts.concat( additionalShortcuts ) }\n\t\t/>\n\t);\n};\n\nexport default function KeyboardShortcutHelpModal( {\n\tisModalActive,\n\ttoggleModal,\n} ) {\n\tuseShortcut( 'core/edit-widgets/keyboard-shortcuts', toggleModal, {\n\t\tbindGlobal: true,\n\t} );\n\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ toggleModal }\n\t\t>\n\t\t\t<ShortcutSection\n\t\t\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal__main-shortcuts\"\n\t\t\t\tshortcuts={ [ 'core/edit-widgets/keyboard-shortcuts' ] }\n\t\t\t/>\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Global shortcuts' ) }\n\t\t\t\tcategoryName=\"global\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Selection shortcuts' ) }\n\t\t\t\tcategoryName=\"selection\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Block shortcuts' ) }\n\t\t\t\tcategoryName=\"block\"\n\t\t\t\tadditionalShortcuts={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tkeyCombination: { character: '/' },\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Change the block type after adding a new paragraph.'\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\t<ShortcutSection\n\t\t\t\ttitle={ __( 'Text formatting' ) }\n\t\t\t\tshortcuts={ textFormattingShortcuts }\n\t\t\t/>\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'List View shortcuts' ) }\n\t\t\t\tcategoryName=\"list-view\"\n\t\t\t/>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAM,gBAAiB,EAAE,gBAMxB,oBAAC,MAAD;CACC,WAAU;CACV,MAAK;CAEH,UAAA,UAAU,KAAO,UAAU,UAC5B,oBAAC,MAAD;EACC,WAAU;EAGR,UAAA,OAAO,aAAa,WACrB,oBAAC,iBAAD,EAAiB,MAAO,SAAY,CAAA,IAEpC,oBAAC,UAAD,EAAU,GAAK,SAAY,CAAA;CAEzB,GAPG,KAOH,CACH;AACC,CAAA;AAIL,MAAM,mBAAoB,EAAE,OAAO,WAAW,gBAC7C,qBAAC,WAAD;CACC,WAAY,KACX,sDACA,SACD;CAJD,UAAA,CAMG,CAAC,CAAE,SACJ,oBAAC,MAAD;EAAI,WAAU;EACX,UAAA;CACC,CAAA,GAEL,oBAAC,cAAD,EAA0B,UAAa,CAAA,CAC/B;;AAGV,MAAM,2BAA4B,EACjC,OACA,cACA,sBAAsB,CAAC,QACjB;CACN,MAAM,oBAAoB,WACvB,WAAY;EACb,OAAO,OAAQA,KAAuB,CAAC,CAAC,qBACvC,YACD;CACD,GACA,CAAE,YAAa,CAChB;CAEA,OACC,oBAAC,iBAAD;EACS;EACR,WAAY,kBAAkB,OAAQ,mBAAoB;CAC1D,CAAA;AAEH;AAEA,SAAwB,0BAA2B,EAClD,eACA,eACG;CACH,YAAa,wCAAwC,aAAa,EACjE,YAAY,KACb,CAAE;CAEF,IAAK,CAAE,eACN,OAAO;CAGR,OACC,qBAAC,OAAD;EACC,WAAU;EACV,OAAQ,GAAI,oBAAqB;EACjC,gBAAiB;EAHlB,UAAA;GAKC,oBAAC,iBAAD;IACC,WAAU;IACV,WAAY,CAAE,sCAAuC;GACrD,CAAA;GACD,oBAAC,yBAAD;IACC,OAAQ,GAAI,kBAAmB;IAC/B,cAAa;GACb,CAAA;GAED,oBAAC,yBAAD;IACC,OAAQ,GAAI,qBAAsB;IAClC,cAAa;GACb,CAAA;GAED,oBAAC,yBAAD;IACC,OAAQ,GAAI,iBAAkB;IAC9B,cAAa;IACb,qBAAsB,CACrB;KACC,gBAAgB,EAAE,WAAW,IAAI;KACjC,aAAa,GACZ,qDACD;IACD,CACD;GACA,CAAA;GACD,oBAAC,iBAAD;IACC,OAAQ,GAAI,iBAAkB;IAC9B,WAAY;GACZ,CAAA;GACD,oBAAC,yBAAD;IACC,OAAQ,GAAI,qBAAsB;IAClC,cAAa;GACb,CAAA;EACK;;AAET"}
|
|
@@ -1,22 +1,44 @@
|
|
|
1
1
|
import { Fragment } from "@wordpress/element";
|
|
2
2
|
import { displayShortcutList, shortcutAriaLabel } from "@wordpress/keycodes";
|
|
3
|
+
import { VisuallyHidden } from "@wordpress/ui";
|
|
3
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
// packages/edit-widgets/src/components/keyboard-shortcut-help-modal/shortcut.jsx
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} ShortcutKeyCombination
|
|
8
|
+
* @property {string} character Shortcut key.
|
|
9
|
+
* @property {import('@wordpress/keycodes').WPKeycodeModifier | null} [modifier] Optional shortcut modifier.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @param {Object} props Component props.
|
|
13
|
+
* @param {ShortcutKeyCombination} props.keyCombination Shortcut to display.
|
|
14
|
+
* @param {string} [props.ariaLabel] Custom readable shortcut label.
|
|
15
|
+
*/
|
|
16
|
+
function KeyCombination({ keyCombination, ariaLabel }) {
|
|
17
|
+
const { character, modifier } = keyCombination;
|
|
18
|
+
const normalizedModifier = modifier ?? "undefined";
|
|
19
|
+
const keys = displayShortcutList[normalizedModifier](character);
|
|
20
|
+
return /* @__PURE__ */ jsxs("kbd", {
|
|
9
21
|
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination",
|
|
10
|
-
"
|
|
11
|
-
children:
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
dir: "ltr",
|
|
23
|
+
children: [/* @__PURE__ */ jsx(VisuallyHidden, {
|
|
24
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
25
|
+
children: ariaLabel || shortcutAriaLabel[normalizedModifier](character)
|
|
26
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
27
|
+
"aria-hidden": "true",
|
|
28
|
+
children: keys.map((key, index) => key === "+" && index < keys.length - 1 ? /* @__PURE__ */ jsx(Fragment, { children: key }, index) : /* @__PURE__ */ jsx("kbd", {
|
|
14
29
|
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key",
|
|
15
|
-
children:
|
|
16
|
-
}, index)
|
|
17
|
-
})
|
|
30
|
+
children: key
|
|
31
|
+
}, index))
|
|
32
|
+
})]
|
|
18
33
|
});
|
|
19
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @param {Object} props Component props.
|
|
37
|
+
* @param {string} props.description Description of the shortcut action.
|
|
38
|
+
* @param {ShortcutKeyCombination} props.keyCombination Primary shortcut.
|
|
39
|
+
* @param {ShortcutKeyCombination[]} [props.aliases] Alternative shortcuts.
|
|
40
|
+
* @param {string} [props.ariaLabel] Custom readable shortcut label.
|
|
41
|
+
*/
|
|
20
42
|
function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
|
|
21
43
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
22
44
|
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-description",
|
|
@@ -25,10 +47,10 @@ function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
|
|
|
25
47
|
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-term",
|
|
26
48
|
children: [/* @__PURE__ */ jsx(KeyCombination, {
|
|
27
49
|
keyCombination,
|
|
28
|
-
|
|
50
|
+
ariaLabel
|
|
29
51
|
}), aliases.map((alias, index) => /* @__PURE__ */ jsx(KeyCombination, {
|
|
30
52
|
keyCombination: alias,
|
|
31
|
-
|
|
53
|
+
ariaLabel
|
|
32
54
|
}, index))]
|
|
33
55
|
})] });
|
|
34
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shortcut.mjs","names":[],"sources":["../../../src/components/keyboard-shortcut-help-modal/shortcut.jsx"],"sourcesContent":["import { Fragment } from '@wordpress/element';\nimport { displayShortcutList, shortcutAriaLabel } from '@wordpress/keycodes';\n\
|
|
1
|
+
{"version":3,"file":"shortcut.mjs","names":[],"sources":["../../../src/components/keyboard-shortcut-help-modal/shortcut.jsx"],"sourcesContent":["import { Fragment } from '@wordpress/element';\nimport { displayShortcutList, shortcutAriaLabel } from '@wordpress/keycodes';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * @typedef {Object} ShortcutKeyCombination\n * @property {string} character Shortcut key.\n * @property {import('@wordpress/keycodes').WPKeycodeModifier | null} [modifier] Optional shortcut modifier.\n */\n\n/**\n * @param {Object} props Component props.\n * @param {ShortcutKeyCombination} props.keyCombination Shortcut to display.\n * @param {string} [props.ariaLabel] Custom readable shortcut label.\n */\nfunction KeyCombination( { keyCombination, ariaLabel } ) {\n\tconst { character, modifier } = keyCombination;\n\tconst normalizedModifier = modifier ?? 'undefined';\n\tconst keys = displayShortcutList[ normalizedModifier ]( character );\n\n\treturn (\n\t\t<kbd\n\t\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination\"\n\t\t\tdir=\"ltr\"\n\t\t>\n\t\t\t<VisuallyHidden render={ <span /> }>\n\t\t\t\t{ ariaLabel ||\n\t\t\t\t\tshortcutAriaLabel[ normalizedModifier ]( character ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t{ keys.map( ( key, index ) =>\n\t\t\t\t\tkey === '+' && index < keys.length - 1 ? (\n\t\t\t\t\t\t<Fragment key={ index }>{ key }</Fragment>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<kbd\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tclassName=\"edit-widgets-keyboard-shortcut-help-modal__shortcut-key\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ key }\n\t\t\t\t\t\t</kbd>\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</kbd>\n\t);\n}\n\n/**\n * @param {Object} props Component props.\n * @param {string} props.description Description of the shortcut action.\n * @param {ShortcutKeyCombination} props.keyCombination Primary shortcut.\n * @param {ShortcutKeyCombination[]} [props.aliases] Alternative shortcuts.\n * @param {string} [props.ariaLabel] Custom readable shortcut label.\n */\nfunction Shortcut( { description, keyCombination, aliases = [], ariaLabel } ) {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-keyboard-shortcut-help-modal__shortcut-description\">\n\t\t\t\t{ description }\n\t\t\t</div>\n\t\t\t<div className=\"edit-widgets-keyboard-shortcut-help-modal__shortcut-term\">\n\t\t\t\t<KeyCombination\n\t\t\t\t\tkeyCombination={ keyCombination }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t/>\n\t\t\t\t{ aliases.map( ( alias, index ) => (\n\t\t\t\t\t<KeyCombination\n\t\t\t\t\t\tkeyCombination={ alias }\n\t\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Shortcut;\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,eAAgB,EAAE,gBAAgB,aAAc;CACxD,MAAM,EAAE,WAAW,aAAa;CAChC,MAAM,qBAAqB,YAAY;CACvC,MAAM,OAAO,oBAAqB,mBAAoB,CAAE,SAAU;CAElE,OACC,qBAAC,OAAD;EACC,WAAU;EACV,KAAI;EAFL,UAAA,CAIC,oBAAC,gBAAD;GAAgB,QAAS,oBAAC,QAAD,CAAO,CAAA;GAC7B,UAAA,aACD,kBAAmB,mBAAoB,CAAE,SAAU;EACrC,CAAA,GAChB,oBAAC,QAAD;GAAM,eAAY;GACf,UAAA,KAAK,KAAO,KAAK,UAClB,QAAQ,OAAO,QAAQ,KAAK,SAAS,IACpC,oBAAC,UAAD,EAAA,UAA0B,IAAe,GAAzB,KAAyB,IAEzC,oBAAC,OAAD;IAEC,WAAU;IAER,UAAA;GACE,GAJE,KAIF,CAEP;EACK,CAAA,CACF;;AAEP;;;;;;;;AASA,SAAS,SAAU,EAAE,aAAa,gBAAgB,UAAU,CAAC,GAAG,aAAc;CAC7E,OACC,qBAAA,YAAA,EAAA,UAAA,CACC,oBAAC,OAAD;EAAK,WAAU;EACZ,UAAA;CACE,CAAA,GACL,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACC,oBAAC,gBAAD;GACkB;GACL;EACZ,CAAA,GACC,QAAQ,KAAO,OAAO,UACvB,oBAAC,gBAAD;GACC,gBAAiB;GACL;EAEZ,GADM,KACN,CACA,CACE;CACJ,CAAA,CAAA,EAAA,CAAA;AAEJ"}
|
|
@@ -17,7 +17,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
17
17
|
function Layout({ blockEditorSettings }) {
|
|
18
18
|
const { createErrorNotice } = useDispatch(store);
|
|
19
19
|
function onPluginAreaError(name) {
|
|
20
|
-
createErrorNotice(sprintf(
|
|
20
|
+
createErrorNotice(sprintf(
|
|
21
|
+
/** translators: %s: plugin name */
|
|
22
|
+
__("The \"%s\" plugin has encountered an error and cannot be rendered."),
|
|
23
|
+
name
|
|
24
|
+
));
|
|
21
25
|
}
|
|
22
26
|
const navigateRegionsProps = __unstableUseNavigateRegions();
|
|
23
27
|
const adminPrimary = useMemo(() => getAdminThemeColors().primary, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["noticesStore","useNavigateRegions"],"sources":["../../../src/components/layout/index.jsx"],"sourcesContent":["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { PluginArea } from '@wordpress/plugins';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport ErrorBoundary from '../error-boundary';\nimport WidgetAreasBlockEditorProvider from '../widget-areas-block-editor-provider';\nimport Sidebar from '../sidebar';\nimport Interface from './interface';\nimport UnsavedChangesWarning from './unsaved-changes-warning';\nimport WelcomeGuide from '../welcome-guide';\n\nfunction Layout( { blockEditorSettings } ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\treturn (\n\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t<ErrorBoundary>\n\t\t\t\t<div { ...navigateRegionsProps }>\n\t\t\t\t\t<WidgetAreasBlockEditorProvider\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Interface\n\t\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Sidebar />\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<WelcomeGuide />\n\t\t\t\t\t</WidgetAreasBlockEditorProvider>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</ThemeProvider>\n\t);\n}\n\nexport default Layout;\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAS,OAAQ,EAAE,uBAAwB;CAC1C,MAAM,EAAE,sBAAsB,YAAaA,KAAa;CAExD,SAAS,kBAAmB,MAAO;EAClC,kBACC,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["noticesStore","useNavigateRegions"],"sources":["../../../src/components/layout/index.jsx"],"sourcesContent":["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { PluginArea } from '@wordpress/plugins';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport ErrorBoundary from '../error-boundary';\nimport WidgetAreasBlockEditorProvider from '../widget-areas-block-editor-provider';\nimport Sidebar from '../sidebar';\nimport Interface from './interface';\nimport UnsavedChangesWarning from './unsaved-changes-warning';\nimport WelcomeGuide from '../welcome-guide';\n\nfunction Layout( { blockEditorSettings } ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\treturn (\n\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t<ErrorBoundary>\n\t\t\t\t<div { ...navigateRegionsProps }>\n\t\t\t\t\t<WidgetAreasBlockEditorProvider\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Interface\n\t\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Sidebar />\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<WelcomeGuide />\n\t\t\t\t\t</WidgetAreasBlockEditorProvider>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</ThemeProvider>\n\t);\n}\n\nexport default Layout;\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAS,OAAQ,EAAE,uBAAwB;CAC1C,MAAM,EAAE,sBAAsB,YAAaA,KAAa;CAExD,SAAS,kBAAmB,MAAO;EAClC,kBACC;;GAEC,GACC,oEACD;GACA;EACD,CACD;CACD;CAEA,MAAM,uBAAuBC,6BAAmB;CAChD,MAAM,eAAe,cAAe,oBAAoB,CAAC,CAAC,SAAS,CAAC,CAAE;CAEtE,OACC,oBAAC,eAAD;EAAe,QAAA;EAAO,OAAQ,EAAE,SAAS,aAAa;EACrD,UAAA,oBAAC,eAAD,EAAA,UACC,oBAAC,OAAD;GAAK,GAAK;GACT,UAAA,qBAAC,gCAAD;IACuB;IADvB,UAAA;KAGC,oBAAC,WAAD,EACuB,oBACtB,CAAA;KACD,oBAAC,SAAD,CAAU,CAAA;KACV,oBAAC,YAAD,EAAY,SAAU,kBAAqB,CAAA;KAC3C,oBAAC,uBAAD,CAAwB,CAAA;KACxB,oBAAC,cAAD,CAAe,CAAA;IACgB;;EAC5B,CAAA,EACS,CAAA;CACD,CAAA;AAEjB"}
|
|
@@ -12,10 +12,22 @@ import SecondarySidebar from "../secondary-sidebar/index.mjs";
|
|
|
12
12
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
13
13
|
// packages/edit-widgets/src/components/layout/interface.jsx
|
|
14
14
|
const interfaceLabels = {
|
|
15
|
-
header: __(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
header: __(
|
|
16
|
+
/** translators: accessibility text for the widgets screen top bar landmark region. */
|
|
17
|
+
"Widgets top bar"
|
|
18
|
+
),
|
|
19
|
+
body: __(
|
|
20
|
+
/** translators: accessibility text for the widgets screen content landmark region. */
|
|
21
|
+
"Widgets and blocks"
|
|
22
|
+
),
|
|
23
|
+
sidebar: __(
|
|
24
|
+
/** translators: accessibility text for the widgets screen settings landmark region. */
|
|
25
|
+
"Widgets settings"
|
|
26
|
+
),
|
|
27
|
+
footer: __(
|
|
28
|
+
/** translators: accessibility text for the widgets screen footer landmark region. */
|
|
29
|
+
"Widgets footer"
|
|
30
|
+
)
|
|
19
31
|
};
|
|
20
32
|
function Interface({ blockEditorSettings }) {
|
|
21
33
|
const isMobileViewport = useViewportMatch("medium", "<");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.mjs","names":["editWidgetsStore","interfaceStore","preferencesStore"],"sources":["../../../src/components/layout/interface.jsx"],"sourcesContent":["import { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={ <Header /> }\n\t\t\tsecondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }\n\t\t\tsidebar={ <ComplementaryArea.Slot scope=\"core/edit-widgets\" /> }\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<WidgetAreasBlockEditorContent\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\thasBlockBreadCrumbsEnabled &&\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<div className=\"edit-widgets-layout__footer\">\n\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\tclassName=\"edit-widgets-layout__breadcrumbs\"\n\t\t\t\t\t\t\trootLabelText={ __( 'Widgets' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport default Interface;\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,kBAAkB;CAEvB,QAAQ
|
|
1
|
+
{"version":3,"file":"interface.mjs","names":["editWidgetsStore","interfaceStore","preferencesStore"],"sources":["../../../src/components/layout/interface.jsx"],"sourcesContent":["import { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={ <Header /> }\n\t\t\tsecondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }\n\t\t\tsidebar={ <ComplementaryArea.Slot scope=\"core/edit-widgets\" /> }\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<WidgetAreasBlockEditorContent\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\thasBlockBreadCrumbsEnabled &&\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<div className=\"edit-widgets-layout__footer\">\n\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\tclassName=\"edit-widgets-layout__breadcrumbs\"\n\t\t\t\t\t\t\trootLabelText={ __( 'Widgets' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport default Interface;\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,kBAAkB;CAEvB,QAAQ;;EAAI;CAAkB;CAE9B,MAAM;;EAAI;CAAqB;CAE/B,SAAS;;EAAI;CAAmB;CAEhC,QAAQ;;EAAI;CAAiB;AAC9B;AAEA,SAAS,UAAW,EAAE,uBAAwB;CAC7C,MAAM,mBAAmB,iBAAkB,UAA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AA;AAEH"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __ } from "@wordpress/i18n";
|
|
2
1
|
import { useEffect } from "@wordpress/element";
|
|
3
2
|
import { useSelect } from "@wordpress/data";
|
|
4
3
|
import { store } from "../../store/index.mjs";
|
|
@@ -20,14 +19,12 @@ function UnsavedChangesWarning() {
|
|
|
20
19
|
/**
|
|
21
20
|
* Warns the user if there are unsaved changes before leaving the editor.
|
|
22
21
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
*
|
|
25
|
-
* @return {string | undefined} Warning prompt message, if unsaved changes exist.
|
|
22
|
+
* @param {BeforeUnloadEvent} event `beforeunload` event.
|
|
26
23
|
*/
|
|
27
24
|
const warnIfUnsavedChanges = (event) => {
|
|
28
25
|
if (isDirty) {
|
|
29
|
-
event.
|
|
30
|
-
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
event.returnValue = true;
|
|
31
28
|
}
|
|
32
29
|
};
|
|
33
30
|
window.addEventListener("beforeunload", warnIfUnsavedChanges);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsaved-changes-warning.mjs","names":["editWidgetsStore"],"sources":["../../../src/components/layout/unsaved-changes-warning.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"unsaved-changes-warning.mjs","names":["editWidgetsStore"],"sources":["../../../src/components/layout/unsaved-changes-warning.js"],"sourcesContent":["import { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as editWidgetsStore } from '../../store';\n\n/**\n * Warns the user if there are unsaved changes before leaving the editor.\n *\n * This is a duplicate of the component implemented in the editor package.\n * Duplicated here as edit-widgets doesn't depend on editor.\n *\n * @return {Component} The component.\n */\nexport default function UnsavedChangesWarning() {\n\tconst isDirty = useSelect( ( select ) => {\n\t\tconst { getEditedWidgetAreas } = select( editWidgetsStore );\n\t\tconst editedWidgetAreas = getEditedWidgetAreas();\n\n\t\treturn editedWidgetAreas?.length > 0;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Warns the user if there are unsaved changes before leaving the editor.\n\t\t *\n\t\t * @param {BeforeUnloadEvent} event `beforeunload` event.\n\t\t */\n\t\tconst warnIfUnsavedChanges = ( event ) => {\n\t\t\tif ( isDirty ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Chrome before 119 ignores `preventDefault()`.\n\t\t\t\tevent.returnValue = true;\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener( 'beforeunload', warnIfUnsavedChanges );\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'beforeunload', warnIfUnsavedChanges );\n\t\t};\n\t}, [ isDirty ] );\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAwB,wBAAwB;CAC/C,MAAM,UAAU,WAAa,WAAY;EACxC,MAAM,EAAE,yBAAyB,OAAQA,KAAiB;EAG1D,OAF0B,qBAEH,CAAC,EAAE,SAAS;CACpC,GAAG,CAAC,CAAE;CAEN,gBAAiB;;;;;;EAMhB,MAAM,wBAAyB,UAAW;GACzC,IAAK,SAAU;IACd,MAAM,eAAe;IAErB,MAAM,cAAc;GACrB;EACD;EAEA,OAAO,iBAAkB,gBAAgB,oBAAqB;EAC9D,aAAa;GACZ,OAAO,oBAAqB,gBAAgB,oBAAqB;EAClE;CACD,GAAG,CAAE,OAAQ,CAAE;CAEf,OAAO;AACR"}
|
|
@@ -61,10 +61,12 @@ function MoreMenu() {
|
|
|
61
61
|
icon: external,
|
|
62
62
|
href: __("https://wordpress.org/documentation/article/block-based-widgets-editor/"),
|
|
63
63
|
target: "_blank",
|
|
64
|
-
rel: "noopener",
|
|
65
64
|
children: [__("Help"), /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
66
65
|
render: /* @__PURE__ */ jsx("span", {}),
|
|
67
|
-
children: __(
|
|
66
|
+
children: __(
|
|
67
|
+
/** translators: accessibility text */
|
|
68
|
+
"(opens in a new tab)"
|
|
69
|
+
)
|
|
68
70
|
})]
|
|
69
71
|
}),
|
|
70
72
|
/* @__PURE__ */ jsx(ToolsMoreMenuGroup.Slot, { fillProps: { onClose } })
|