@wordpress/edit-widgets 6.28.0 → 6.28.1-next.0f6f9d12c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/blocks/widget-area/edit/index.js +31 -28
- package/build/blocks/widget-area/edit/index.js.map +1 -1
- package/build/blocks/widget-area/index.js +1 -0
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build-module/blocks/widget-area/edit/index.js +31 -28
- package/build-module/blocks/widget-area/edit/index.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +1 -0
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/package.json +28 -28
- package/src/blocks/widget-area/block.json +1 -0
- package/src/blocks/widget-area/edit/index.js +33 -29
|
@@ -9,6 +9,7 @@ var _element = require("@wordpress/element");
|
|
|
9
9
|
var _data = require("@wordpress/data");
|
|
10
10
|
var _coreData = require("@wordpress/core-data");
|
|
11
11
|
var _components = require("@wordpress/components");
|
|
12
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
12
13
|
var _innerBlocks = _interopRequireDefault(require("./inner-blocks"));
|
|
13
14
|
var _store = require("../../../store");
|
|
14
15
|
var _useIsDraggingWithin = _interopRequireDefault(require("./use-is-dragging-within"));
|
|
@@ -23,7 +24,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
23
24
|
|
|
24
25
|
/** @typedef {import('@wordpress/element').RefObject} RefObject */function WidgetAreaEdit({
|
|
25
26
|
clientId,
|
|
26
|
-
className,
|
|
27
27
|
attributes: {
|
|
28
28
|
id,
|
|
29
29
|
name
|
|
@@ -50,33 +50,36 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
50
50
|
setOpen(false);
|
|
51
51
|
}
|
|
52
52
|
}, [isOpen, isDragging, isDraggingWithin, openedWhileDragging]);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
id: id
|
|
53
|
+
const blockProps = (0, _blockEditor.useBlockProps)();
|
|
54
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
55
|
+
...blockProps,
|
|
56
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Panel, {
|
|
57
|
+
ref: wrapper,
|
|
58
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PanelBody, {
|
|
59
|
+
title: name,
|
|
60
|
+
opened: isOpen,
|
|
61
|
+
onToggle: () => {
|
|
62
|
+
setIsWidgetAreaOpen(clientId, !isOpen);
|
|
63
|
+
},
|
|
64
|
+
scrollAfterOpen: !isDragging,
|
|
65
|
+
children: ({
|
|
66
|
+
opened
|
|
67
|
+
}) =>
|
|
68
|
+
/*#__PURE__*/
|
|
69
|
+
// This is required to ensure LegacyWidget blocks are not
|
|
70
|
+
// unmounted when the panel is collapsed. Unmounting legacy
|
|
71
|
+
// widgets may have unintended consequences (e.g. TinyMCE
|
|
72
|
+
// not being properly reinitialized)
|
|
73
|
+
(0, _jsxRuntime.jsx)(_components.__unstableDisclosureContent, {
|
|
74
|
+
className: "wp-block-widget-area__panel-body-content",
|
|
75
|
+
visible: opened,
|
|
76
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_coreData.EntityProvider, {
|
|
77
|
+
kind: "root",
|
|
78
|
+
type: "postType",
|
|
79
|
+
id: `widget-area-${id}`,
|
|
80
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_innerBlocks.default, {
|
|
81
|
+
id: id
|
|
82
|
+
})
|
|
80
83
|
})
|
|
81
84
|
})
|
|
82
85
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_coreData","_components","_innerBlocks","_interopRequireDefault","_store","_useIsDraggingWithin","_jsxRuntime","WidgetAreaEdit","clientId","
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_coreData","_components","_blockEditor","_innerBlocks","_interopRequireDefault","_store","_useIsDraggingWithin","_jsxRuntime","WidgetAreaEdit","clientId","attributes","id","name","isOpen","useSelect","select","editWidgetsStore","getIsWidgetAreaOpen","setIsWidgetAreaOpen","useDispatch","wrapper","useRef","setOpen","useCallback","openState","isDragging","useIsDragging","isDraggingWithin","useIsDraggingWithin","openedWhileDragging","setOpenedWhileDragging","useState","useEffect","blockProps","useBlockProps","jsx","children","Panel","ref","PanelBody","title","opened","onToggle","scrollAfterOpen","__unstableDisclosureContent","className","visible","EntityProvider","kind","type","default","elementRef","setIsDragging","ownerDocument","current","handleDragStart","handleDragEnd","addEventListener","removeEventListener"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\nimport { useBlockProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Panel ref={ wrapper }>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ name }\n\t\t\t\t\topened={ isOpen }\n\t\t\t\t\tonToggle={ () => {\n\t\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t\t} }\n\t\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t\t>\n\t\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t\t</DisclosureContent>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</Panel>\n\t\t</div>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,YAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAF,sBAAA,CAAAN,OAAA;AAA2D,IAAAS,WAAA,GAAAT,OAAA;AAlB3D;AACA;AACA;;AAWA;AACA;AACA;;AAKA,kEAEe,SAASU,cAAcA,CAAE;EACvCC,QAAQ;EACRC,UAAU,EAAE;IAAEC,EAAE;IAAEC;EAAK;AACxB,CAAC,EAAG;EAC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CAAE,WAAW,EAAEF,eAAgB,CAAC;IAC9DF,aAAa,CAACI,gBAAgB,CAAE,SAAS,EAAED,aAAc,CAAC;IAE1D,OAAO,MAAM;MACZH,aAAa,CAACK,mBAAmB,CAAE,WAAW,EAAEH,eAAgB,CAAC;MACjEF,aAAa,CAACK,mBAAmB,CAAE,SAAS,EAAEF,aAAc,CAAC;IAC9D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,OAAO/B,UAAU;AAClB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_edit","_interopRequireDefault","metadata","exports","$schema","name","title","category","attributes","id","type","supports","html","inserter","customClassName","reusable","__experimentalToolbar","__experimentalParentSelector","__experimentalDisableBlockOverlay","editorStyle","style","settings","__","description","__experimentalLabel","label","edit"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AATA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAG,QAAA,GAAAC,OAAA,CAAAD,QAAA;EAAAE,OAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,UAAA;IAAAC,EAAA;MAAAC,IAAA;IAAA;IAAAL,IAAA;MAAAK,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,eAAA;IAAAC,QAAA;IAAAC,qBAAA;IAAAC,4BAAA;IAAAC,iCAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAMA,MAAM;EAAEf;AAAK,CAAC,
|
|
1
|
+
{"version":3,"names":["_i18n","require","_edit","_interopRequireDefault","metadata","exports","$schema","apiVersion","name","title","category","attributes","id","type","supports","html","inserter","customClassName","reusable","__experimentalToolbar","__experimentalParentSelector","__experimentalDisableBlockOverlay","editorStyle","style","settings","__","description","__experimentalLabel","label","edit"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AATA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAG,QAAA,GAAAC,OAAA,CAAAD,QAAA;EAAAE,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,UAAA;IAAAC,EAAA;MAAAC,IAAA;IAAA;IAAAL,IAAA;MAAAK,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,eAAA;IAAAC,QAAA;IAAAC,qBAAA;IAAAC,4BAAA;IAAAC,iCAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAMA,MAAM;EAAEf;AAAK,CAAC,GAAGJ,QAAQ;AAACC,OAAA,CAAAG,IAAA,GAAAA,IAAA;AAGnB,MAAMgB,QAAQ,GAAAnB,OAAA,CAAAmB,QAAA,GAAG;EACvBf,KAAK,EAAE,IAAAgB,QAAE,EAAE,aAAc,CAAC;EAC1BC,WAAW,EAAE,IAAAD,QAAE,EAAE,0BAA2B,CAAC;EAC7CE,mBAAmB,EAAEA,CAAE;IAAEnB,IAAI,EAAEoB;EAAM,CAAC,KAAMA,KAAK;EACjDC,IAAI,EAAJA;AACD,CAAC","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ import { useEffect, useState, useCallback, useRef } from '@wordpress/element';
|
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
6
|
import { EntityProvider } from '@wordpress/core-data';
|
|
7
7
|
import { __unstableDisclosureContent as DisclosureContent, Panel, PanelBody } from '@wordpress/components';
|
|
8
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -17,7 +18,6 @@ import useIsDraggingWithin from './use-is-dragging-within';
|
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
export default function WidgetAreaEdit({
|
|
19
20
|
clientId,
|
|
20
|
-
className,
|
|
21
21
|
attributes: {
|
|
22
22
|
id,
|
|
23
23
|
name
|
|
@@ -44,33 +44,36 @@ export default function WidgetAreaEdit({
|
|
|
44
44
|
setOpen(false);
|
|
45
45
|
}
|
|
46
46
|
}, [isOpen, isDragging, isDraggingWithin, openedWhileDragging]);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
children: /*#__PURE__*/_jsx(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
id: id
|
|
47
|
+
const blockProps = useBlockProps();
|
|
48
|
+
return /*#__PURE__*/_jsx("div", {
|
|
49
|
+
...blockProps,
|
|
50
|
+
children: /*#__PURE__*/_jsx(Panel, {
|
|
51
|
+
ref: wrapper,
|
|
52
|
+
children: /*#__PURE__*/_jsx(PanelBody, {
|
|
53
|
+
title: name,
|
|
54
|
+
opened: isOpen,
|
|
55
|
+
onToggle: () => {
|
|
56
|
+
setIsWidgetAreaOpen(clientId, !isOpen);
|
|
57
|
+
},
|
|
58
|
+
scrollAfterOpen: !isDragging,
|
|
59
|
+
children: ({
|
|
60
|
+
opened
|
|
61
|
+
}) =>
|
|
62
|
+
/*#__PURE__*/
|
|
63
|
+
// This is required to ensure LegacyWidget blocks are not
|
|
64
|
+
// unmounted when the panel is collapsed. Unmounting legacy
|
|
65
|
+
// widgets may have unintended consequences (e.g. TinyMCE
|
|
66
|
+
// not being properly reinitialized)
|
|
67
|
+
_jsx(DisclosureContent, {
|
|
68
|
+
className: "wp-block-widget-area__panel-body-content",
|
|
69
|
+
visible: opened,
|
|
70
|
+
children: /*#__PURE__*/_jsx(EntityProvider, {
|
|
71
|
+
kind: "root",
|
|
72
|
+
type: "postType",
|
|
73
|
+
id: `widget-area-${id}`,
|
|
74
|
+
children: /*#__PURE__*/_jsx(WidgetAreaInnerBlocks, {
|
|
75
|
+
id: id
|
|
76
|
+
})
|
|
74
77
|
})
|
|
75
78
|
})
|
|
76
79
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","useCallback","useRef","useSelect","useDispatch","EntityProvider","__unstableDisclosureContent","DisclosureContent","Panel","PanelBody","WidgetAreaInnerBlocks","store","editWidgetsStore","useIsDraggingWithin","jsx","_jsx","WidgetAreaEdit","clientId","
|
|
1
|
+
{"version":3,"names":["useEffect","useState","useCallback","useRef","useSelect","useDispatch","EntityProvider","__unstableDisclosureContent","DisclosureContent","Panel","PanelBody","useBlockProps","WidgetAreaInnerBlocks","store","editWidgetsStore","useIsDraggingWithin","jsx","_jsx","WidgetAreaEdit","clientId","attributes","id","name","isOpen","select","getIsWidgetAreaOpen","setIsWidgetAreaOpen","wrapper","setOpen","openState","isDragging","useIsDragging","isDraggingWithin","openedWhileDragging","setOpenedWhileDragging","blockProps","children","ref","title","opened","onToggle","scrollAfterOpen","className","visible","kind","type","elementRef","setIsDragging","ownerDocument","current","handleDragStart","handleDragEnd","addEventListener","removeEventListener"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\nimport { useBlockProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Panel ref={ wrapper }>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ name }\n\t\t\t\t\topened={ isOpen }\n\t\t\t\t\tonToggle={ () => {\n\t\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t\t} }\n\t\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t\t>\n\t\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t\t</DisclosureContent>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</Panel>\n\t\t</div>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AAC7E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SACCC,2BAA2B,IAAIC,iBAAiB,EAChDC,KAAK,EACLC,SAAS,QACH,uBAAuB;AAC9B,SAASC,aAAa,QAAQ,yBAAyB;;AAEvD;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,gBAAgB;AAClD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,gBAAgB;AAC1D,OAAOC,mBAAmB,MAAM,0BAA0B;;AAE1D;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEA,eAAe,SAASC,cAAcA,CAAE;EACvCC,QAAQ;EACRC,UAAU,EAAE;IAAEC,EAAE;IAAEC;EAAK;AACxB,CAAC,EAAG;EACH,MAAMC,MAAM,GAAGnB,SAAS,CACrBoB,MAAM,IACPA,MAAM,CAAEV,gBAAiB,CAAC,CAACW,mBAAmB,CAAEN,QAAS,CAAC,EAC3D,CAAEA,QAAQ,CACX,CAAC;EACD,MAAM;IAAEO;EAAoB,CAAC,GAAGrB,WAAW,CAAES,gBAAiB,CAAC;EAE/D,MAAMa,OAAO,GAAGxB,MAAM,CAAC,CAAC;EACxB,MAAMyB,OAAO,GAAG1B,WAAW,CACxB2B,SAAS,IAAMH,mBAAmB,CAAEP,QAAQ,EAAEU,SAAU,CAAC,EA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,EAAC,MAAM;YACXC,IAAI,EAAC,UAAU;YACfxB,EAAE,EAAG,eAAgBA,EAAE,EAAK;YAAAe,QAAA,eAE5BnB,IAAA,CAACL,qBAAqB;cAACS,EAAE,EAAGA;YAAI,CAAE;UAAC,CACpB;QAAC,CACC;MACnB,CACS;IAAC,CACN;EAAC,CACJ,CAAC;AAER;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMU,aAAa,GAAKe,UAAU,IAAM;EACvC,MAAM,CAAEhB,UAAU,EAAEiB,aAAa,CAAE,GAAG9C,QAAQ,CAAE,KAAM,CAAC;EAEvDD,SAAS,CAAE,MAAM;IAChB,MAAM;MAAEgD;IAAc,CAAC,GAAGF,UAAU,CAACG,OAAO;IAE5C,SAASC,eAAeA,CAAA,EAAG;MAC1BH,aAAa,CAAE,IAAK,CAAC;IACtB;IAEA,SAASI,aAAaA,CAAA,EAAG;MACxBJ,aAAa,CAAE,KAAM,CAAC;IACvB;IAEAC,aAAa,CAACI,gBAAgB,CAAE,WAAW,EAAEF,eAAgB,CAAC;IAC9DF,aAAa,CAACI,gBAAgB,CAAE,SAAS,EAAED,aAAc,CAAC;IAE1D,OAAO,MAAM;MACZH,aAAa,CAACK,mBAAmB,CAAE,WAAW,EAAEH,eAAgB,CAAC;MACjEF,aAAa,CAACK,mBAAmB,CAAE,SAAS,EAAEF,aAAc,CAAC;IAC9D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,OAAOrB,UAAU;AAClB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","metadata","$schema","name","title","category","attributes","id","type","supports","html","inserter","customClassName","reusable","__experimentalToolbar","__experimentalParentSelector","__experimentalDisableBlockOverlay","editorStyle","style","edit","settings","description","__experimentalLabel","label"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,MAAAC,QAAA;EAAAC,OAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,UAAA;IAAAC,EAAA;MAAAC,IAAA;IAAA;IAAAL,IAAA;MAAAK,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,eAAA;IAAAC,QAAA;IAAAC,qBAAA;IAAAC,4BAAA;IAAAC,iCAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAIA,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAEhB;AAAK,CAAC,
|
|
1
|
+
{"version":3,"names":["__","metadata","$schema","apiVersion","name","title","category","attributes","id","type","supports","html","inserter","customClassName","reusable","__experimentalToolbar","__experimentalParentSelector","__experimentalDisableBlockOverlay","editorStyle","style","edit","settings","description","__experimentalLabel","label"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,UAAA;IAAAC,EAAA;MAAAC,IAAA;IAAA;IAAAL,IAAA;MAAAK,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,eAAA;IAAAC,QAAA;IAAAC,qBAAA;IAAAC,4BAAA;IAAAC,iCAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAIA,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAEhB;AAAK,CAAC,GAAGH,QAAQ;AACzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAMiB,QAAQ,GAAG;EACvBhB,KAAK,EAAEL,EAAE,CAAE,aAAc,CAAC;EAC1BsB,WAAW,EAAEtB,EAAE,CAAE,0BAA2B,CAAC;EAC7CuB,mBAAmB,EAAEA,CAAE;IAAEnB,IAAI,EAAEoB;EAAM,CAAC,KAAMA,KAAK;EACjDJ;AACD,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "6.28.0",
|
|
3
|
+
"version": "6.28.1-next.0f6f9d12c.0",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,32 +29,32 @@
|
|
|
29
29
|
"wpScript": true,
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "7.25.7",
|
|
32
|
-
"@wordpress/api-fetch": "^7.28.0",
|
|
33
|
-
"@wordpress/block-editor": "^15.1.0",
|
|
34
|
-
"@wordpress/block-library": "^9.28.0",
|
|
35
|
-
"@wordpress/blocks": "^15.1.0",
|
|
36
|
-
"@wordpress/components": "^30.1.0",
|
|
37
|
-
"@wordpress/compose": "^7.28.0",
|
|
38
|
-
"@wordpress/core-data": "^7.28.0",
|
|
39
|
-
"@wordpress/data": "^10.28.0",
|
|
40
|
-
"@wordpress/deprecated": "^4.28.0",
|
|
41
|
-
"@wordpress/dom": "^4.28.0",
|
|
42
|
-
"@wordpress/element": "^6.28.0",
|
|
43
|
-
"@wordpress/hooks": "^4.28.0",
|
|
44
|
-
"@wordpress/i18n": "^6.1.0",
|
|
45
|
-
"@wordpress/icons": "^10.28.0",
|
|
46
|
-
"@wordpress/interface": "^9.13.0",
|
|
47
|
-
"@wordpress/keyboard-shortcuts": "^5.28.0",
|
|
48
|
-
"@wordpress/keycodes": "^4.28.0",
|
|
49
|
-
"@wordpress/media-utils": "^5.28.0",
|
|
50
|
-
"@wordpress/notices": "^5.28.0",
|
|
51
|
-
"@wordpress/patterns": "^2.28.0",
|
|
52
|
-
"@wordpress/plugins": "^7.28.0",
|
|
53
|
-
"@wordpress/preferences": "^4.28.0",
|
|
54
|
-
"@wordpress/private-apis": "^1.28.0",
|
|
55
|
-
"@wordpress/reusable-blocks": "^5.28.0",
|
|
56
|
-
"@wordpress/url": "^4.28.0",
|
|
57
|
-
"@wordpress/widgets": "^4.28.0",
|
|
32
|
+
"@wordpress/api-fetch": "^7.28.1-next.0f6f9d12c.0",
|
|
33
|
+
"@wordpress/block-editor": "^15.1.1-next.0f6f9d12c.0",
|
|
34
|
+
"@wordpress/block-library": "^9.28.1-next.0f6f9d12c.0",
|
|
35
|
+
"@wordpress/blocks": "^15.1.1-next.0f6f9d12c.0",
|
|
36
|
+
"@wordpress/components": "^30.2.1-next.0f6f9d12c.0",
|
|
37
|
+
"@wordpress/compose": "^7.28.1-next.0f6f9d12c.0",
|
|
38
|
+
"@wordpress/core-data": "^7.28.1-next.0f6f9d12c.0",
|
|
39
|
+
"@wordpress/data": "^10.28.1-next.0f6f9d12c.0",
|
|
40
|
+
"@wordpress/deprecated": "^4.28.1-next.0f6f9d12c.0",
|
|
41
|
+
"@wordpress/dom": "^4.28.1-next.0f6f9d12c.0",
|
|
42
|
+
"@wordpress/element": "^6.28.1-next.0f6f9d12c.0",
|
|
43
|
+
"@wordpress/hooks": "^4.28.1-next.0f6f9d12c.0",
|
|
44
|
+
"@wordpress/i18n": "^6.1.1-next.0f6f9d12c.0",
|
|
45
|
+
"@wordpress/icons": "^10.28.2-next.0f6f9d12c.0",
|
|
46
|
+
"@wordpress/interface": "^9.13.1-next.0f6f9d12c.0",
|
|
47
|
+
"@wordpress/keyboard-shortcuts": "^5.28.1-next.0f6f9d12c.0",
|
|
48
|
+
"@wordpress/keycodes": "^4.28.1-next.0f6f9d12c.0",
|
|
49
|
+
"@wordpress/media-utils": "^5.28.1-next.0f6f9d12c.0",
|
|
50
|
+
"@wordpress/notices": "^5.28.1-next.0f6f9d12c.0",
|
|
51
|
+
"@wordpress/patterns": "^2.28.1-next.0f6f9d12c.0",
|
|
52
|
+
"@wordpress/plugins": "^7.28.1-next.0f6f9d12c.0",
|
|
53
|
+
"@wordpress/preferences": "^4.28.1-next.0f6f9d12c.0",
|
|
54
|
+
"@wordpress/private-apis": "^1.28.1-next.0f6f9d12c.0",
|
|
55
|
+
"@wordpress/reusable-blocks": "^5.28.1-next.0f6f9d12c.0",
|
|
56
|
+
"@wordpress/url": "^4.28.1-next.0f6f9d12c.0",
|
|
57
|
+
"@wordpress/widgets": "^4.28.1-next.0f6f9d12c.0",
|
|
58
58
|
"clsx": "^2.1.1"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "7d4f4367e2f76deddf4a09b540e6b2f9f4c3fe9f"
|
|
68
68
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Panel,
|
|
10
10
|
PanelBody,
|
|
11
11
|
} from '@wordpress/components';
|
|
12
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
@@ -21,7 +22,6 @@ import useIsDraggingWithin from './use-is-dragging-within';
|
|
|
21
22
|
|
|
22
23
|
export default function WidgetAreaEdit( {
|
|
23
24
|
clientId,
|
|
24
|
-
className,
|
|
25
25
|
attributes: { id, name },
|
|
26
26
|
} ) {
|
|
27
27
|
const isOpen = useSelect(
|
|
@@ -54,36 +54,40 @@ export default function WidgetAreaEdit( {
|
|
|
54
54
|
}
|
|
55
55
|
}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );
|
|
56
56
|
|
|
57
|
+
const blockProps = useBlockProps();
|
|
58
|
+
|
|
57
59
|
return (
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<EntityProvider
|
|
77
|
-
kind="root"
|
|
78
|
-
type="postType"
|
|
79
|
-
id={ `widget-area-${ id }` }
|
|
60
|
+
<div { ...blockProps }>
|
|
61
|
+
<Panel ref={ wrapper }>
|
|
62
|
+
<PanelBody
|
|
63
|
+
title={ name }
|
|
64
|
+
opened={ isOpen }
|
|
65
|
+
onToggle={ () => {
|
|
66
|
+
setIsWidgetAreaOpen( clientId, ! isOpen );
|
|
67
|
+
} }
|
|
68
|
+
scrollAfterOpen={ ! isDragging }
|
|
69
|
+
>
|
|
70
|
+
{ ( { opened } ) => (
|
|
71
|
+
// This is required to ensure LegacyWidget blocks are not
|
|
72
|
+
// unmounted when the panel is collapsed. Unmounting legacy
|
|
73
|
+
// widgets may have unintended consequences (e.g. TinyMCE
|
|
74
|
+
// not being properly reinitialized)
|
|
75
|
+
<DisclosureContent
|
|
76
|
+
className="wp-block-widget-area__panel-body-content"
|
|
77
|
+
visible={ opened }
|
|
80
78
|
>
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
<EntityProvider
|
|
80
|
+
kind="root"
|
|
81
|
+
type="postType"
|
|
82
|
+
id={ `widget-area-${ id }` }
|
|
83
|
+
>
|
|
84
|
+
<WidgetAreaInnerBlocks id={ id } />
|
|
85
|
+
</EntityProvider>
|
|
86
|
+
</DisclosureContent>
|
|
87
|
+
) }
|
|
88
|
+
</PanelBody>
|
|
89
|
+
</Panel>
|
|
90
|
+
</div>
|
|
87
91
|
);
|
|
88
92
|
}
|
|
89
93
|
|