@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
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -30,11 +32,11 @@ let _wordpress_core_data = require("@wordpress/core-data");
|
|
|
30
32
|
let _wordpress_components = require("@wordpress/components");
|
|
31
33
|
let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
32
34
|
let __inner_blocks_jsx = require("./inner-blocks.cjs");
|
|
33
|
-
__inner_blocks_jsx = __toESM(__inner_blocks_jsx);
|
|
34
35
|
let _________store_index_js = require("../../../store/index.cjs");
|
|
35
36
|
let __use_is_dragging_within_js = require("./use-is-dragging-within.cjs");
|
|
36
|
-
__use_is_dragging_within_js = __toESM(__use_is_dragging_within_js);
|
|
37
37
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
__inner_blocks_jsx = __toESM(__inner_blocks_jsx);
|
|
39
|
+
__use_is_dragging_within_js = __toESM(__use_is_dragging_within_js);
|
|
38
40
|
// packages/edit-widgets/src/blocks/widget-area/edit/index.jsx
|
|
39
41
|
/** @typedef {import('@wordpress/element').RefObject} RefObject */
|
|
40
42
|
function WidgetAreaEdit({ clientId, attributes: { id, name } }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useSelect","editWidgetsStore","useDispatch","useRef","useCallback","useIsDraggingWithin","useState","useBlockProps","Panel","PanelBody","DisclosureContent","EntityProvider","WidgetAreaInnerBlocks"],"sources":["../../../../src/blocks/widget-area/edit/index.jsx"],"sourcesContent":["import { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Panel ref={ wrapper }>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ name }\n\t\t\t\t\topened={ isOpen }\n\t\t\t\t\tonToggle={ () => {\n\t\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t\t} }\n\t\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t\t>\n\t\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t\t</DisclosureContent>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</Panel>\n\t\t</div>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useSelect","editWidgetsStore","useDispatch","useRef","useCallback","useIsDraggingWithin","useState","useEffect","useBlockProps","Panel","PanelBody","DisclosureContent","EntityProvider","WidgetAreaInnerBlocks"],"sources":["../../../../src/blocks/widget-area/edit/index.jsx"],"sourcesContent":["import { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Panel ref={ wrapper }>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ name }\n\t\t\t\t\topened={ isOpen }\n\t\t\t\t\tonToggle={ () => {\n\t\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t\t} }\n\t\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t\t>\n\t\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t\t</DisclosureContent>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</Panel>\n\t\t</div>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"],"mappings":";;;;;;;;;;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L,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,6BAAD;KACC,WAAU;KACV,SAAU;KAEV,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,gBAAD;MACC,MAAK;MACL,MAAK;MACL,IAAK,eAAgB;MAErB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,SAAD,EAA4B,GAAM,CAAA;KACnB,CAAA;IACE,CAAA;GAEV,CAAA;EACL,CAAA;CACH,CAAA;AAEP;;;;;;;;AASA,MAAM,iBAAkB,eAAgB;CACvC,MAAM,CAAE,YAAY,kBAAA,GAAkBP,mBAAAA,SAAAA,CAAU,KAAM;CAEtDC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,MAAM,EAAE,kBAAkB,WAAW;EAErC,SAAS,kBAAkB;GAC1B,cAAe,IAAK;EACrB;EAEA,SAAS,gBAAgB;GACxB,cAAe,KAAM;EACtB;EAEA,cAAc,iBAAkB,aAAa,eAAgB;EAC7D,cAAc,iBAAkB,WAAW,aAAc;EAEzD,aAAa;GACZ,cAAc,oBAAqB,aAAa,eAAgB;GAChE,cAAc,oBAAqB,WAAW,aAAc;EAC7D;CACD,GAAG,CAAC,CAAE;CAEN,OAAO;AACR"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -25,13 +27,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
27
|
enumerable: true
|
|
26
28
|
}) : target, mod));
|
|
27
29
|
let clsx = require("clsx");
|
|
28
|
-
clsx = __toESM(clsx);
|
|
29
30
|
let _wordpress_core_data = require("@wordpress/core-data");
|
|
30
31
|
let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
31
32
|
let _wordpress_element = require("@wordpress/element");
|
|
32
33
|
let __use_is_dragging_within_js = require("./use-is-dragging-within.cjs");
|
|
33
|
-
__use_is_dragging_within_js = __toESM(__use_is_dragging_within_js);
|
|
34
34
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
clsx = __toESM(clsx);
|
|
36
|
+
__use_is_dragging_within_js = __toESM(__use_is_dragging_within_js);
|
|
35
37
|
// packages/edit-widgets/src/blocks/widget-area/edit/inner-blocks.jsx
|
|
36
38
|
function WidgetAreaInnerBlocks({ id }) {
|
|
37
39
|
const [blocks, onInput, onChange] = (0, _wordpress_core_data.useEntityBlockEditor)("root", "postType");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inner-blocks.cjs","names":["useEntityBlockEditor","useRef","useIsDraggingWithin","useInnerBlocksProps","InnerBlocks"],"sources":["../../../../src/blocks/widget-area/edit/inner-blocks.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport { InnerBlocks, useInnerBlocksProps } from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\nexport default function WidgetAreaInnerBlocks( { id } ) {\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'root',\n\t\t'postType'\n\t);\n\tconst innerBlocksRef = useRef();\n\tconst isDraggingWithinInnerBlocks = useIsDraggingWithin( innerBlocksRef );\n\tconst shouldHighlightDropZone = isDraggingWithinInnerBlocks;\n\t// Using the experimental hook so that we can control the className of the element.\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ ref: innerBlocksRef },\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplateLock: false,\n\t\t\trenderAppender: InnerBlocks.ButtonBlockAppender,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tdata-widget-area-id={ id }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',\n\t\t\t\t{\n\t\t\t\t\t'wp-block-widget-area__highlight-drop-zone':\n\t\t\t\t\t\tshouldHighlightDropZone,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"inner-blocks.cjs","names":["useEntityBlockEditor","useRef","useIsDraggingWithin","useInnerBlocksProps","InnerBlocks","clsx"],"sources":["../../../../src/blocks/widget-area/edit/inner-blocks.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport { InnerBlocks, useInnerBlocksProps } from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\nexport default function WidgetAreaInnerBlocks( { id } ) {\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'root',\n\t\t'postType'\n\t);\n\tconst innerBlocksRef = useRef();\n\tconst isDraggingWithinInnerBlocks = useIsDraggingWithin( innerBlocksRef );\n\tconst shouldHighlightDropZone = isDraggingWithinInnerBlocks;\n\t// Using the experimental hook so that we can control the className of the element.\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ ref: innerBlocksRef },\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplateLock: false,\n\t\t\trenderAppender: InnerBlocks.ButtonBlockAppender,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tdata-widget-area-id={ id }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',\n\t\t\t\t{\n\t\t\t\t\t'wp-block-widget-area__highlight-drop-zone':\n\t\t\t\t\t\tshouldHighlightDropZone,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAwB,sBAAuB,EAAE,MAAO;CACvD,MAAM,CAAE,QAAQ,SAAS,aAAA,GAAaA,qBAAAA,qBAAAA,CACrC,QACA,UACD;CACA,MAAM,kBAAA,GAAiBC,mBAAAA,OAAAA,CAAO;CAE9B,MAAM,2BAAA,GAD8BC,4BAAAA,QAAAA,CAAqB,cACC;CAE1D,MAAM,oBAAA,GAAmBC,wBAAAA,oBAAAA,CACxB,EAAE,KAAK,eAAe,GACtB;EACC,OAAO;EACP;EACA;EACA,cAAc;EACd,gBAAgBC,wBAAAA,YAAY;CAC7B,CACD;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACC,uBAAsB;EACtB,YAAA,GAAYC,KAAAA,QAAAA,CACX,sFACA,EACC,6CACC,wBACF,CACD;EAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAK,GAAK,iBAAoB,CAAA;CAC1B,CAAA;AAEP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-is-dragging-within.cjs","names":["useState"],"sources":["../../../../src/blocks/widget-area/edit/use-is-dragging-within.js"],"sourcesContent":["import { useState, useEffect } from '@wordpress/element';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\nexport default useIsDraggingWithin;\n"],"mappings":";;;;;;;;;;;;;;;AAWA,MAAM,uBAAwB,eAAgB;CAC7C,MAAM,CAAE,kBAAkB,wBAAA,GAAwBA,mBAAAA,SAAAA,CAAU,KAAM;
|
|
1
|
+
{"version":3,"file":"use-is-dragging-within.cjs","names":["useState","useEffect"],"sources":["../../../../src/blocks/widget-area/edit/use-is-dragging-within.js"],"sourcesContent":["import { useState, useEffect } from '@wordpress/element';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\nexport default useIsDraggingWithin;\n"],"mappings":";;;;;;;;;;;;;;;AAWA,MAAM,uBAAwB,eAAgB;CAC7C,MAAM,CAAE,kBAAkB,wBAAA,GAAwBA,mBAAAA,SAAAA,CAAU,KAAM;CAElEC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,MAAM,EAAE,kBAAkB,WAAW;EAErC,SAAS,gBAAiB,OAAQ;GAEjC,gBAAiB,KAAM;EACxB;EAGA,SAAS,gBAAgB;GACxB,oBAAqB,KAAM;EAC5B;EAEA,SAAS,gBAAiB,OAAQ;GAEjC,IAAK,WAAW,QAAQ,SAAU,MAAM,MAAO,GAC9C,oBAAqB,IAAK;QAE1B,oBAAqB,KAAM;EAE7B;EAIA,cAAc,iBAAkB,aAAa,eAAgB;EAC7D,cAAc,iBAAkB,WAAW,aAAc;EACzD,cAAc,iBAAkB,aAAa,eAAgB;EAE7D,aAAa;GACZ,cAAc,oBAAqB,aAAa,eAAgB;GAChE,cAAc,oBAAqB,WAAW,aAAc;GAC5D,cAAc,oBAAqB,aAAa,eAAgB;EACjE;CACD,GAAG,CAAC,CAAE;CAEN,OAAO;AACR"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -27,8 +29,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
29
|
let _wordpress_i18n = require("@wordpress/i18n");
|
|
28
30
|
let _wordpress_icons = require("@wordpress/icons");
|
|
29
31
|
let __block_json = require("./block.json");
|
|
30
|
-
__block_json = __toESM(__block_json);
|
|
31
32
|
let __edit_index_jsx = require("./edit/index.cjs");
|
|
33
|
+
__block_json = __toESM(__block_json);
|
|
32
34
|
__edit_index_jsx = __toESM(__edit_index_jsx);
|
|
33
35
|
// packages/edit-widgets/src/blocks/widget-area/index.js
|
|
34
36
|
const { name } = __block_json.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["metadata","__"],"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":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["metadata","__","icon","edit"],"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,SAASA,aAAAA;AAGjB,MAAa,WAAW;CACvB,QAAA,GAAOC,gBAAAA,GAAAA,CAAI,aAAc;CACzB,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,0BAA2B;CAC5C,sBAAuB,EAAE,MAAM,YAAa;CAC5CC,MAAAA,iBAAAA;CACAC,MAAAA,iBAAAA;AACD"}
|
|
@@ -118,7 +118,7 @@ var ErrorBoundary = class extends _wordpress_element.Component {
|
|
|
118
118
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.Actions, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, {
|
|
119
119
|
variant: "solid",
|
|
120
120
|
text: () => getErrorReport(error, componentStack),
|
|
121
|
-
children: (0, _wordpress_i18n.
|
|
121
|
+
children: (0, _wordpress_i18n._x)("Copy error", "button label")
|
|
122
122
|
}) })
|
|
123
123
|
]
|
|
124
124
|
}), globalThis.SCRIPT_DEBUG ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorDetails, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["__","useCopyToClipboard","Notice","Stack","Text","CollapsibleCard","Card","Component"],"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.cjs","names":["__","useCopyToClipboard","Notice","Stack","Text","CollapsibleCard","Card","Component","speak","doAction","_x"],"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 }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAS,iB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eAAe,CAAE;EAC7DC,CAAAA,GAAAA,iBAAAA,SAAAA,CAAU,oCAAoC,OAAO,SAAU;CAChE;CAEA,OAAO,yBAA0B,OAAQ;EACxC,OAAO,EAAE,MAAM;CAChB;CAEA,SAAS;EACR,MAAM,EAAE,OAAO,mBAAmB,KAAK;EACvC,IAAK,CAAE,OACN,OAAO,KAAK,MAAM;EAGnB,MAAM,EAAE,OAAO,gBAAgB,eAAe;EAE9C,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACN,cAAAA,OAAD;GACC,WAAU;GACV,WAAU;GACV,KAAI;GAHL,UAAA,CAKC,iBAAA,GAAA,kBAAA,KAAA,CAACD,cAAAA,OAAO,MAAR;IAAa,QAAO;IAApB,UAAA;KACC,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,OAAR,EAAA,UAAgB,MAAqB,CAAA;KACrC,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,aAAR,EAAA,UAAsB,YAAiC,CAAA;KACvD,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,SAAR,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,YAAD;MACC,SAAQ;MACR,YACC,eAAgB,OAAO,cAAe;MAGrCQ,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,cAAc,cAAe;KACxB,CAAA,EACG,CAAA;IACJ;GACX,CAAA,GAAA,WAAW,eACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;IACS;IACS;GACjB,CAAA,IACE,IACE;;CAET;AACD"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -32,12 +34,12 @@ let _wordpress_icons = require("@wordpress/icons");
|
|
|
32
34
|
let _wordpress_element = require("@wordpress/element");
|
|
33
35
|
let _wordpress_compose = require("@wordpress/compose");
|
|
34
36
|
let ___undo_redo_undo_jsx = require("../undo-redo/undo.cjs");
|
|
35
|
-
___undo_redo_undo_jsx = __toESM(___undo_redo_undo_jsx);
|
|
36
37
|
let ___undo_redo_redo_jsx = require("../undo-redo/redo.cjs");
|
|
37
|
-
___undo_redo_redo_jsx = __toESM(___undo_redo_redo_jsx);
|
|
38
38
|
let _________store_index_js = require("../../../store/index.cjs");
|
|
39
39
|
let _________lock_unlock_js = require("../../../lock-unlock.cjs");
|
|
40
40
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
+
___undo_redo_undo_jsx = __toESM(___undo_redo_undo_jsx);
|
|
42
|
+
___undo_redo_redo_jsx = __toESM(___undo_redo_redo_jsx);
|
|
41
43
|
// packages/edit-widgets/src/components/header/document-tools/index.jsx
|
|
42
44
|
function DocumentTools() {
|
|
43
45
|
const isMediumViewport = (0, _wordpress_compose.useViewportMatch)("medium");
|
|
@@ -68,7 +70,12 @@ function DocumentTools() {
|
|
|
68
70
|
},
|
|
69
71
|
onClick: toggleInserterSidebar,
|
|
70
72
|
icon: _wordpress_icons.plus,
|
|
71
|
-
label: (0, _wordpress_i18n._x)(
|
|
73
|
+
label: (0, _wordpress_i18n._x)(
|
|
74
|
+
/** translators: button label text should, if possible, be under 16
|
|
75
|
+
characters. */
|
|
76
|
+
"Block Inserter",
|
|
77
|
+
"Generic label for block inserter button"
|
|
78
|
+
),
|
|
72
79
|
size: "compact"
|
|
73
80
|
}), isMediumViewport && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
74
81
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.ToolbarItem, { as: ___undo_redo_undo_jsx.default }),
|
|
@@ -78,7 +85,10 @@ function DocumentTools() {
|
|
|
78
85
|
className: "edit-widgets-header-toolbar__list-view-toggle",
|
|
79
86
|
icon: _wordpress_icons.listView,
|
|
80
87
|
isPressed: isListViewOpen,
|
|
81
|
-
label: (0, _wordpress_i18n.__)(
|
|
88
|
+
label: (0, _wordpress_i18n.__)(
|
|
89
|
+
/** translators: button label text should, if possible, be under 16 characters. */
|
|
90
|
+
"List View"
|
|
91
|
+
),
|
|
82
92
|
onClick: toggleListView,
|
|
83
93
|
ref: listViewToggleRef,
|
|
84
94
|
size: "compact"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useViewportMatch","useSelect","unlock","editWidgetsStore","useDispatch","useCallback","NavigableToolbar","__","ToolbarItem","Button","plus","_x","UndoButton","RedoButton","listView"],"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":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useViewportMatch","useSelect","unlock","editWidgetsStore","useDispatch","useCallback","NavigableToolbar","__","ToolbarItem","Button","plus","_x","UndoButton","RedoButton","listView"],"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,oBAAA,GAAmBA,mBAAAA,iBAAAA,CAAkB,QAAS;CAEpD,MAAM,EACL,gBACA,gBACA,0BACA,uBAAA,GACGC,gBAAAA,UAAAA,EAAa,WAAY;EAC5B,MAAM,EACL,kBACA,6BACA,kBACA,0BAAA,GACGC,wBAAAA,OAAAA,CAAQ,OAAQC,wBAAAA,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,yBAAA,GAC5BC,gBAAAA,YAAAA,CAAaD,wBAAAA,KAAiB;CAE/B,MAAM,kBAAA,GAAiBE,mBAAAA,YAAAA,OAChB,oBAAqB,CAAE,cAAe,GAC5C,CAAE,qBAAqB,cAAe,CACvC;CAEA,MAAM,yBAAA,GAAwBA,mBAAAA,YAAAA,OACvB,oBAAqB,CAAE,cAAe,GAC5C,CAAE,qBAAqB,cAAe,CACvC;CAEA,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,wBAAAA,kBAAD;EACC,WAAU;EACV,eAAA,GAAaC,gBAAAA,GAAAA,CAAI,gBAAiB;EAClC,SAAQ;EAHT,UAAA,CAKC,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,aAAD;GACC,KAAM;GACN,IAAKC,sBAAAA;GACL,WAAU;GACV,SAAQ;GACR,WAAY;GACZ,cAAgB,UAAW;IAC1B,MAAM,eAAe;GACtB;GACA,SAAU;GACV,MAAOC,iBAAAA;GAGP,QAAA,GAAQC,gBAAAA,GAAAA;;;IACP;IACA;GACD;GACA,MAAK;EACL,CAAA,GACC,oBACD,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;GACC,iBAAA,GAAA,kBAAA,IAAA,CAACH,sBAAAA,aAAD,EAAa,IAAKI,sBAAAA,QAAc,CAAA;GAChC,iBAAA,GAAA,kBAAA,IAAA,CAACJ,sBAAAA,aAAD,EAAa,IAAKK,sBAAAA,QAAc,CAAA;GAChC,iBAAA,GAAA,kBAAA,IAAA,CAACL,sBAAAA,aAAD;IACC,IAAKC,sBAAAA;IACL,WAAU;IACV,MAAOK,iBAAAA;IACP,WAAY;IAEZ,QAAA,GAAQP,gBAAAA,GAAAA;;KAAI;IAAY;IACxB,SAAU;IACV,KAAM;IACN,MAAK;GACL,CAAA;EACA,EAAA,CAAA,CAEc;;AAEpB"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -24,6 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
26
|
value: mod,
|
|
25
27
|
enumerable: true
|
|
26
28
|
}) : target, mod));
|
|
29
|
+
let clsx = require("clsx");
|
|
27
30
|
let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
28
31
|
let _wordpress_data = require("@wordpress/data");
|
|
29
32
|
let _wordpress_element = require("@wordpress/element");
|
|
@@ -34,19 +37,23 @@ let _wordpress_compose = require("@wordpress/compose");
|
|
|
34
37
|
let _wordpress_preferences = require("@wordpress/preferences");
|
|
35
38
|
let _wordpress_ui = require("@wordpress/ui");
|
|
36
39
|
let __document_tools_index_jsx = require("./document-tools/index.cjs");
|
|
37
|
-
__document_tools_index_jsx = __toESM(__document_tools_index_jsx);
|
|
38
40
|
let ___save_button_index_jsx = require("../save-button/index.cjs");
|
|
39
|
-
___save_button_index_jsx = __toESM(___save_button_index_jsx);
|
|
40
41
|
let ___more_menu_index_jsx = require("../more-menu/index.cjs");
|
|
41
|
-
___more_menu_index_jsx = __toESM(___more_menu_index_jsx);
|
|
42
42
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
clsx = __toESM(clsx);
|
|
44
|
+
__document_tools_index_jsx = __toESM(__document_tools_index_jsx);
|
|
45
|
+
___save_button_index_jsx = __toESM(___save_button_index_jsx);
|
|
46
|
+
___more_menu_index_jsx = __toESM(___more_menu_index_jsx);
|
|
43
47
|
// packages/edit-widgets/src/components/header/index.jsx
|
|
44
48
|
function Header() {
|
|
45
49
|
const isLargeViewport = (0, _wordpress_compose.useViewportMatch)("medium");
|
|
46
50
|
const blockToolbarRef = (0, _wordpress_element.useRef)();
|
|
47
|
-
const { hasFixedToolbar } = (0, _wordpress_data.useSelect)((select) => ({
|
|
51
|
+
const { hasFixedToolbar, showIconLabels } = (0, _wordpress_data.useSelect)((select) => ({
|
|
52
|
+
hasFixedToolbar: !!select(_wordpress_preferences.store).get("core/edit-widgets", "fixedToolbar"),
|
|
53
|
+
showIconLabels: select(_wordpress_preferences.store).get("core", "showIconLabels")
|
|
54
|
+
}), []);
|
|
48
55
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
49
|
-
className: "edit-widgets-header",
|
|
56
|
+
className: (0, clsx.default)("edit-widgets-header", { "has-icon-labels": showIconLabels }),
|
|
50
57
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
51
58
|
className: "edit-widgets-header__navigable-toolbar-wrapper",
|
|
52
59
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useViewportMatch","useRef","useSelect","preferencesStore","__","VisuallyHidden","DocumentTools","BlockToolbar","WCPopover","PinnedItems","SaveButton","MoreMenu"],"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.cjs","names":["useViewportMatch","useRef","useSelect","preferencesStore","clsx","__","VisuallyHidden","DocumentTools","BlockToolbar","WCPopover","PinnedItems","SaveButton","MoreMenu"],"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,mBAAA,GAAkBA,mBAAAA,iBAAAA,CAAkB,QAAS;CACnD,MAAM,mBAAA,GAAkBC,mBAAAA,OAAAA,CAAO;CAC/B,MAAM,EAAE,iBAAiB,oBAAA,GAAmBC,gBAAAA,UAAAA,EACzC,YAAc;EACf,iBAAiB,CAAC,CAAE,OAAQC,uBAAAA,KAAiB,CAAC,CAAC,IAC9C,qBACA,cACD;EACA,gBAAgB,OAAQA,uBAAAA,KAAiB,CAAC,CAAC,IAC1C,QACA,gBACD;CACD,IACA,CAAC,CACF;CAEA,OACC,iBAAA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A,CAACC,uBAAAA,SAAD,CAAW,CAAA;GACP;EACD,CAAA,CAAA;CACJ,CAAA,EAAA,CAAA;AAEJ"}
|
|
@@ -5,6 +5,7 @@ Object.defineProperties(exports, {
|
|
|
5
5
|
});
|
|
6
6
|
let _wordpress_i18n = require("@wordpress/i18n");
|
|
7
7
|
// packages/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js
|
|
8
|
+
/** @type {Array<import('react').ComponentProps<typeof import('./shortcut').default>>} */
|
|
8
9
|
const textFormattingShortcuts = [
|
|
9
10
|
{
|
|
10
11
|
keyCombination: {
|
|
@@ -36,6 +37,10 @@ const textFormattingShortcuts = [
|
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
keyCombination: { character: "[[" },
|
|
40
|
+
ariaLabel: (0, _wordpress_i18n.__)(
|
|
41
|
+
/** translators: The keyboard sequence [[, pressing the left bracket key twice. */
|
|
42
|
+
"Left bracket twice"
|
|
43
|
+
),
|
|
39
44
|
description: (0, _wordpress_i18n.__)("Insert a link to a post or page.")
|
|
40
45
|
},
|
|
41
46
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","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.cjs","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,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,8BAA+B;CACjD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,gCAAiC;CACnD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,wCAAyC;CAC3D;CACA;EACC,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAI;EAC3D,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,gBAAiB;CACnC;CACA;EACC,gBAAgB,EAAE,WAAW,KAAK;EAElC,YAAA,GAAWA,gBAAAA,GAAAA;;GAAI;EAAqB;EACpC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,kCAAmC;CACrD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,8BAA+B;CACjD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAI;EACrD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,kCAAmC;CACrD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAI;EACrD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,qCAAsC;CACxD;CACA;EACC,gBAAgB;GACf,UAAU;GACV,WAAW;EACZ;EACA,SAAS,CACR;GACC,UAAU;GACV,WAAW;EACZ,CACD;EACA,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,6CAA8C;CAChE;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAM;EACvD,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,wEACD;CACD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAQ;EAC/D,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,yBAA0B;CAC5C;AACD"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -27,8 +29,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
29
|
let _wordpress_data = require("@wordpress/data");
|
|
28
30
|
let _wordpress_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
|
|
29
31
|
let __shortcut_jsx = require("./shortcut.cjs");
|
|
30
|
-
__shortcut_jsx = __toESM(__shortcut_jsx);
|
|
31
32
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
__shortcut_jsx = __toESM(__shortcut_jsx);
|
|
32
34
|
// packages/edit-widgets/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.jsx
|
|
33
35
|
function DynamicShortcut({ name }) {
|
|
34
36
|
const { keyCombination, description, aliases } = (0, _wordpress_data.useSelect)((select) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-shortcut.cjs","names":["useSelect","keyboardShortcutsStore","Shortcut"],"sources":["../../../src/components/keyboard-shortcut-help-modal/dynamic-shortcut.jsx"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport Shortcut from './shortcut';\n\nfunction DynamicShortcut( { name } ) {\n\tconst { keyCombination, description, aliases } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetShortcutKeyCombination,\n\t\t\t\tgetShortcutDescription,\n\t\t\t\tgetShortcutAliases,\n\t\t\t} = select( keyboardShortcutsStore );\n\n\t\t\treturn {\n\t\t\t\tkeyCombination: getShortcutKeyCombination( name ),\n\t\t\t\taliases: getShortcutAliases( name ),\n\t\t\t\tdescription: getShortcutDescription( name ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\n\tif ( ! keyCombination ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Shortcut\n\t\t\tkeyCombination={ keyCombination }\n\t\t\tdescription={ description }\n\t\t\taliases={ aliases }\n\t\t/>\n\t);\n}\n\nexport default DynamicShortcut;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamic-shortcut.cjs","names":["useSelect","keyboardShortcutsStore","Shortcut"],"sources":["../../../src/components/keyboard-shortcut-help-modal/dynamic-shortcut.jsx"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport Shortcut from './shortcut';\n\nfunction DynamicShortcut( { name } ) {\n\tconst { keyCombination, description, aliases } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetShortcutKeyCombination,\n\t\t\t\tgetShortcutDescription,\n\t\t\t\tgetShortcutAliases,\n\t\t\t} = select( keyboardShortcutsStore );\n\n\t\t\treturn {\n\t\t\t\tkeyCombination: getShortcutKeyCombination( name ),\n\t\t\t\taliases: getShortcutAliases( name ),\n\t\t\t\tdescription: getShortcutDescription( name ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\n\tif ( ! keyCombination ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Shortcut\n\t\t\tkeyCombination={ keyCombination }\n\t\t\tdescription={ description }\n\t\t\taliases={ aliases }\n\t\t/>\n\t);\n}\n\nexport default DynamicShortcut;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,gBAAiB,EAAE,QAAS;CACpC,MAAM,EAAE,gBAAgB,aAAa,aAAA,GAAYA,gBAAAA,UAAAA,EAC9C,WAAY;EACb,MAAM,EACL,2BACA,wBACA,uBACG,OAAQC,8BAAAA,KAAuB;EAEnC,OAAO;GACN,gBAAgB,0BAA2B,IAAK;GAChD,SAAS,mBAAoB,IAAK;GAClC,aAAa,uBAAwB,IAAK;EAC3C;CACD,GACA,CAAE,IAAK,CACR;CAEA,IAAK,CAAE,gBACN,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,SAAD;EACkB;EACH;EACJ;CACV,CAAA;AAEH"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -25,17 +27,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
27
|
enumerable: true
|
|
26
28
|
}) : target, mod));
|
|
27
29
|
let clsx = require("clsx");
|
|
28
|
-
clsx = __toESM(clsx);
|
|
29
30
|
let _wordpress_components = require("@wordpress/components");
|
|
30
31
|
let _wordpress_i18n = require("@wordpress/i18n");
|
|
31
32
|
let _wordpress_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
|
|
32
33
|
let _wordpress_data = require("@wordpress/data");
|
|
33
34
|
let __config_js = require("./config.cjs");
|
|
34
35
|
let __shortcut_jsx = require("./shortcut.cjs");
|
|
35
|
-
__shortcut_jsx = __toESM(__shortcut_jsx);
|
|
36
36
|
let __dynamic_shortcut_jsx = require("./dynamic-shortcut.cjs");
|
|
37
|
-
__dynamic_shortcut_jsx = __toESM(__dynamic_shortcut_jsx);
|
|
38
37
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
clsx = __toESM(clsx);
|
|
39
|
+
__shortcut_jsx = __toESM(__shortcut_jsx);
|
|
40
|
+
__dynamic_shortcut_jsx = __toESM(__dynamic_shortcut_jsx);
|
|
39
41
|
// packages/edit-widgets/src/components/keyboard-shortcut-help-modal/index.jsx
|
|
40
42
|
const ShortcutList = ({ shortcuts }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
41
43
|
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-list",
|
|
@@ -86,8 +88,7 @@ function KeyboardShortcutHelpModal({ isModalActive, toggleModal }) {
|
|
|
86
88
|
categoryName: "block",
|
|
87
89
|
additionalShortcuts: [{
|
|
88
90
|
keyCombination: { character: "/" },
|
|
89
|
-
description: (0, _wordpress_i18n.__)("Change the block type after adding a new paragraph.")
|
|
90
|
-
ariaLabel: (0, _wordpress_i18n.__)("Forward-slash")
|
|
91
|
+
description: (0, _wordpress_i18n.__)("Change the block type after adding a new paragraph.")
|
|
91
92
|
}]
|
|
92
93
|
}),
|
|
93
94
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShortcutSection, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DynamicShortcut","Shortcut","useSelect","keyboardShortcutsStore","Modal","__","textFormattingShortcuts"],"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.cjs","names":["DynamicShortcut","Shortcut","clsx","useSelect","keyboardShortcutsStore","useShortcut","Modal","__","textFormattingShortcuts"],"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,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;CACC,WAAU;CACV,MAAK;CAEH,UAAA,UAAU,KAAO,UAAU,UAC5B,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAA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