@wordpress/edit-widgets 6.27.1-next.46f643fa0.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/CHANGELOG.md +2 -0
- 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/components/widget-areas-block-editor-provider/index.js +2 -2
- package/build/components/widget-areas-block-editor-provider/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/build-module/components/widget-areas-block-editor-provider/index.js +2 -2
- package/build-module/components/widget-areas-block-editor-provider/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
- package/src/components/widget-areas-block-editor-provider/index.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -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,MA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,kBAAS,EAAE,MAAM;IAChB,MAAM;MAAEqB;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,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":[]}
|
|
@@ -66,8 +66,8 @@ function WidgetAreasBlockEditorProvider({
|
|
|
66
66
|
}) ? getEntityRecord('root', 'site') : undefined;
|
|
67
67
|
return {
|
|
68
68
|
hasUploadPermissions: (_canUser = canUser('create', {
|
|
69
|
-
kind: '
|
|
70
|
-
name: '
|
|
69
|
+
kind: 'postType',
|
|
70
|
+
name: 'attachment'
|
|
71
71
|
})) !== null && _canUser !== void 0 ? _canUser : true,
|
|
72
72
|
reusableBlocks: _constants.ALLOW_REUSABLE_BLOCKS ? getEntityRecords('postType', 'wp_block') : EMPTY_ARRAY,
|
|
73
73
|
isFixedToolbarActive: !!select(_preferences.store).get('core/edit-widgets', 'fixedToolbar'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_compose","_mediaUtils","_data","_coreData","_element","_blockEditor","_patterns","_preferences","_blockLibrary","_keyboardShortcuts","_interopRequireDefault","_utils","_useLastSelectedWidgetArea","_store","_constants","_lockUnlock","_jsxRuntime","ExperimentalBlockEditorProvider","unlock","blockEditorPrivateApis","PatternsMenuItems","editPatternsPrivateApis","BlockKeyboardShortcuts","blockLibraryPrivateApis","EMPTY_ARRAY","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","isLargeViewport","useViewportMatch","hasUploadPermissions","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","pageOnFront","pageForPosts","useSelect","select","_canUser","canUser","getEntityRecord","getEntityRecords","coreStore","siteSettings","kind","name","undefined","ALLOW_REUSABLE_BLOCKS","preferencesStore","get","page_on_front","page_for_posts","setIsInserterOpened","useDispatch","editWidgetsStore","settings","useMemo","mediaUploadBlockEditor","onError","argumentsObject","uploadMedia","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","editorTool","widgetAreaId","useLastSelectedWidgetArea","blocks","onInput","onChange","useEntityBlockEditor","KIND","POST_TYPE","id","buildWidgetAreasPostId","jsxs","SlotFillProvider","jsx","default","Register","value","useSubRegistry","rootClientId"],"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: '
|
|
1
|
+
{"version":3,"names":["_components","require","_compose","_mediaUtils","_data","_coreData","_element","_blockEditor","_patterns","_preferences","_blockLibrary","_keyboardShortcuts","_interopRequireDefault","_utils","_useLastSelectedWidgetArea","_store","_constants","_lockUnlock","_jsxRuntime","ExperimentalBlockEditorProvider","unlock","blockEditorPrivateApis","PatternsMenuItems","editPatternsPrivateApis","BlockKeyboardShortcuts","blockLibraryPrivateApis","EMPTY_ARRAY","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","isLargeViewport","useViewportMatch","hasUploadPermissions","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","pageOnFront","pageForPosts","useSelect","select","_canUser","canUser","getEntityRecord","getEntityRecords","coreStore","siteSettings","kind","name","undefined","ALLOW_REUSABLE_BLOCKS","preferencesStore","get","page_on_front","page_for_posts","setIsInserterOpened","useDispatch","editWidgetsStore","settings","useMemo","mediaUploadBlockEditor","onError","argumentsObject","uploadMedia","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","editorTool","widgetAreaId","useLastSelectedWidgetArea","blocks","onInput","onChange","useEntityBlockEditor","KIND","POST_TYPE","id","buildWidgetAreasPostId","jsxs","SlotFillProvider","jsx","default","Register","value","useSubRegistry","rootClientId"],"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'attachment',\n\t\t\t\t} ) ?? true,\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: EMPTY_ARRAY,\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\teditorTool: 'edit',\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<BlockKeyboardShortcuts />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AAKA,IAAAU,kBAAA,GAAAC,sBAAA,CAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,0BAAA,GAAAF,sBAAA,CAAAX,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,UAAA,GAAAf,OAAA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EAAC,CAAC;EAEhD,MAAM,CAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,CAAE,GAAG,IAAAC,8BAAoB,EACzDC,WAAI,EACJC,gBAAS,EACT;IAAEC,EAAE,EAAE,IAAAC,6BAAsB,EAAC;EAAE,CAChC,CAAC;EAED,oBACC,IAAAhE,WAAA,CAAAiE,IAAA,EAACnF,WAAA,CAAAoF,gBAAgB;IAAAvD,QAAA,gBAChB,IAAAX,WAAA,CAAAmE,GAAA,EAAC1E,kBAAA,CAAA2E,OAAiB,CAACC,QAAQ,IAAE,CAAC,eAC9B,IAAArE,WAAA,CAAAmE,GAAA,EAAC7D,sBAAsB,IAAE,CAAC,eAC1B,IAAAN,WAAA,CAAAiE,IAAA,EAAChE,+BAA+B;MAC/BqE,KAAK,EAAGb,MAAQ;MAChBC,OAAO,EAAGA,OAAS;MACnBC,QAAQ,EAAGA,QAAU;MACrBnB,QAAQ,EAAGA,QAAU;MACrB+B,cAAc,EAAG,KAAO;MAAA,GACnB3D,KAAK;MAAAD,QAAA,GAERA,QAAQ,eACV,IAAAX,WAAA,CAAAmE,GAAA,EAAC/D,iBAAiB;QAACoE,YAAY,EAAGjB;MAAc,CAAE,CAAC;IAAA,CACnB,CAAC;EAAA,CACjB,CAAC;AAErB","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,QAA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Aa,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":[]}
|
|
@@ -58,8 +58,8 @@ export default function WidgetAreasBlockEditorProvider({
|
|
|
58
58
|
}) ? getEntityRecord('root', 'site') : undefined;
|
|
59
59
|
return {
|
|
60
60
|
hasUploadPermissions: (_canUser = canUser('create', {
|
|
61
|
-
kind: '
|
|
62
|
-
name: '
|
|
61
|
+
kind: 'postType',
|
|
62
|
+
name: 'attachment'
|
|
63
63
|
})) !== null && _canUser !== void 0 ? _canUser : true,
|
|
64
64
|
reusableBlocks: ALLOW_REUSABLE_BLOCKS ? getEntityRecords('postType', 'wp_block') : EMPTY_ARRAY,
|
|
65
65
|
isFixedToolbarActive: !!select(preferencesStore).get('core/edit-widgets', 'fixedToolbar'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SlotFillProvider","useViewportMatch","uploadMedia","useDispatch","useSelect","useEntityBlockEditor","store","coreStore","useMemo","privateApis","blockEditorPrivateApis","editPatternsPrivateApis","preferencesStore","blockLibraryPrivateApis","KeyboardShortcuts","buildWidgetAreasPostId","KIND","POST_TYPE","useLastSelectedWidgetArea","editWidgetsStore","ALLOW_REUSABLE_BLOCKS","unlock","jsx","_jsx","jsxs","_jsxs","ExperimentalBlockEditorProvider","PatternsMenuItems","BlockKeyboardShortcuts","EMPTY_ARRAY","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","isLargeViewport","hasUploadPermissions","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","pageOnFront","pageForPosts","select","_canUser","canUser","getEntityRecord","getEntityRecords","siteSettings","kind","name","undefined","get","page_on_front","page_for_posts","setIsInserterOpened","settings","mediaUploadBlockEditor","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","editorTool","widgetAreaId","blocks","onInput","onChange","id","Register","value","useSubRegistry","rootClientId"],"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: '
|
|
1
|
+
{"version":3,"names":["SlotFillProvider","useViewportMatch","uploadMedia","useDispatch","useSelect","useEntityBlockEditor","store","coreStore","useMemo","privateApis","blockEditorPrivateApis","editPatternsPrivateApis","preferencesStore","blockLibraryPrivateApis","KeyboardShortcuts","buildWidgetAreasPostId","KIND","POST_TYPE","useLastSelectedWidgetArea","editWidgetsStore","ALLOW_REUSABLE_BLOCKS","unlock","jsx","_jsx","jsxs","_jsxs","ExperimentalBlockEditorProvider","PatternsMenuItems","BlockKeyboardShortcuts","EMPTY_ARRAY","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","isLargeViewport","hasUploadPermissions","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","pageOnFront","pageForPosts","select","_canUser","canUser","getEntityRecord","getEntityRecords","siteSettings","kind","name","undefined","get","page_on_front","page_for_posts","setIsInserterOpened","settings","mediaUploadBlockEditor","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","editorTool","widgetAreaId","blocks","onInput","onChange","id","Register","value","useSubRegistry","rootClientId"],"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'attachment',\n\t\t\t\t} ) ?? true,\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: EMPTY_ARRAY,\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\teditorTool: 'edit',\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<BlockKeyboardShortcuts />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{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MACrBoB,cAAc,EAAG,KAAO;MAAA,GACnBzC,KAAK;MAAAD,QAAA,GAERA,QAAQ,eACVT,IAAA,CAACI,iBAAiB;QAACgD,YAAY,EAAGR;MAAc,CAAE,CAAC;IAAA,CACnB,CAAC;EAAA,CACjB,CAAC;AAErB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "6.
|
|
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.
|
|
33
|
-
"@wordpress/block-editor": "^15.
|
|
34
|
-
"@wordpress/block-library": "^9.
|
|
35
|
-
"@wordpress/blocks": "^15.
|
|
36
|
-
"@wordpress/components": "^30.
|
|
37
|
-
"@wordpress/compose": "^7.
|
|
38
|
-
"@wordpress/core-data": "^7.
|
|
39
|
-
"@wordpress/data": "^10.
|
|
40
|
-
"@wordpress/deprecated": "^4.
|
|
41
|
-
"@wordpress/dom": "^4.
|
|
42
|
-
"@wordpress/element": "^6.
|
|
43
|
-
"@wordpress/hooks": "^4.
|
|
44
|
-
"@wordpress/i18n": "^6.
|
|
45
|
-
"@wordpress/icons": "^10.
|
|
46
|
-
"@wordpress/interface": "^9.
|
|
47
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
48
|
-
"@wordpress/keycodes": "^4.
|
|
49
|
-
"@wordpress/media-utils": "^5.
|
|
50
|
-
"@wordpress/notices": "^5.
|
|
51
|
-
"@wordpress/patterns": "^2.
|
|
52
|
-
"@wordpress/plugins": "^7.
|
|
53
|
-
"@wordpress/preferences": "^4.
|
|
54
|
-
"@wordpress/private-apis": "^1.
|
|
55
|
-
"@wordpress/reusable-blocks": "^5.
|
|
56
|
-
"@wordpress/url": "^4.
|
|
57
|
-
"@wordpress/widgets": "^4.
|
|
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
|
|
|
@@ -53,8 +53,8 @@ export default function WidgetAreasBlockEditorProvider( {
|
|
|
53
53
|
return {
|
|
54
54
|
hasUploadPermissions:
|
|
55
55
|
canUser( 'create', {
|
|
56
|
-
kind: '
|
|
57
|
-
name: '
|
|
56
|
+
kind: 'postType',
|
|
57
|
+
name: 'attachment',
|
|
58
58
|
} ) ?? true,
|
|
59
59
|
reusableBlocks: ALLOW_REUSABLE_BLOCKS
|
|
60
60
|
? getEntityRecords( 'postType', 'wp_block' )
|