@wordpress/edit-widgets 6.57.0 → 7.1.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 +106 -116
- package/build/blocks/widget-area/edit/index.cjs.map +1 -7
- package/build/blocks/widget-area/edit/inner-blocks.cjs +44 -62
- package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -7
- package/build/blocks/widget-area/edit/use-is-dragging-within.cjs +41 -53
- package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -7
- package/build/blocks/widget-area/index.cjs +40 -44
- package/build/blocks/widget-area/index.cjs.map +1 -7
- package/build/components/error-boundary/index.cjs +115 -155
- package/build/components/error-boundary/index.cjs.map +1 -7
- package/build/components/header/document-tools/index.cjs +80 -115
- package/build/components/header/document-tools/index.cjs.map +1 -7
- package/build/components/header/index.cjs +72 -80
- package/build/components/header/index.cjs.map +1 -7
- package/build/components/header/undo-redo/redo.cjs +30 -52
- package/build/components/header/undo-redo/redo.cjs.map +1 -7
- package/build/components/header/undo-redo/undo.cjs +29 -51
- package/build/components/header/undo-redo/undo.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
- package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/index.cjs +94 -161
- package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -75
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcuts/index.cjs +107 -140
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
- package/build/components/layout/index.cjs +65 -74
- package/build/components/layout/index.cjs.map +1 -7
- package/build/components/layout/interface.cjs +82 -102
- package/build/components/layout/interface.cjs.map +1 -7
- package/build/components/layout/unsaved-changes-warning.cjs +44 -48
- package/build/components/layout/unsaved-changes-warning.cjs.map +1 -7
- package/build/components/more-menu/index.cjs +125 -191
- package/build/components/more-menu/index.cjs.map +1 -7
- package/build/components/more-menu/tools-more-menu-group.cjs +9 -29
- package/build/components/more-menu/tools-more-menu-group.cjs.map +1 -7
- package/build/components/notices/index.cjs +19 -39
- package/build/components/notices/index.cjs.map +1 -7
- package/build/components/save-button/index.cjs +31 -58
- package/build/components/save-button/index.cjs.map +1 -7
- package/build/components/secondary-sidebar/index.cjs +38 -45
- package/build/components/secondary-sidebar/index.cjs.map +1 -7
- package/build/components/secondary-sidebar/inserter-sidebar.cjs +50 -51
- package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -7
- package/build/components/secondary-sidebar/list-view-sidebar.cjs +51 -82
- package/build/components/secondary-sidebar/list-view-sidebar.cjs.map +1 -7
- package/build/components/sidebar/index.cjs +117 -180
- package/build/components/sidebar/index.cjs.map +1 -7
- package/build/components/sidebar/widget-areas.cjs +43 -85
- package/build/components/sidebar/widget-areas.cjs.map +1 -7
- package/build/components/welcome-guide/index.cjs +110 -186
- package/build/components/welcome-guide/index.cjs.map +1 -7
- package/build/components/widget-areas-block-editor-content/index.cjs +59 -63
- package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -7
- package/build/components/widget-areas-block-editor-provider/index.cjs +105 -140
- package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -7
- package/build/constants.cjs +11 -32
- package/build/constants.cjs.map +1 -7
- package/build/filters/index.cjs +7 -4
- package/build/filters/move-to-widget-area.cjs +38 -53
- package/build/filters/move-to-widget-area.cjs.map +1 -7
- package/build/filters/replace-media-upload.cjs +11 -9
- package/build/filters/replace-media-upload.cjs.map +1 -7
- package/build/hooks/use-last-selected-widget-area.cjs +28 -49
- package/build/hooks/use-last-selected-widget-area.cjs.map +1 -7
- package/build/hooks/use-widget-library-insertion-point.cjs +33 -67
- package/build/hooks/use-widget-library-insertion-point.cjs.map +1 -7
- package/build/index.cjs +96 -97
- package/build/index.cjs.map +1 -7
- package/build/lock-unlock.cjs +10 -35
- package/build/lock-unlock.cjs.map +1 -7
- package/build/store/actions.cjs +269 -278
- package/build/store/actions.cjs.map +1 -7
- package/build/store/constants.cjs +12 -29
- package/build/store/constants.cjs.map +1 -7
- package/build/store/index.cjs +61 -52
- package/build/store/index.cjs.map +1 -7
- package/build/store/private-selectors.cjs +11 -32
- package/build/store/private-selectors.cjs.map +1 -7
- package/build/store/reducer.cjs +107 -88
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/resolvers.cjs +60 -91
- package/build/store/resolvers.cjs.map +1 -7
- package/build/store/selectors.cjs +196 -229
- package/build/store/selectors.cjs.map +1 -7
- package/build/store/transformers.cjs +51 -82
- package/build/store/transformers.cjs.map +1 -7
- package/build/store/utils.cjs +76 -63
- package/build/store/utils.cjs.map +1 -7
- package/build-module/blocks/widget-area/edit/index.mjs +82 -94
- package/build-module/blocks/widget-area/edit/index.mjs.map +1 -7
- package/build-module/blocks/widget-area/edit/inner-blocks.mjs +19 -35
- package/build-module/blocks/widget-area/edit/inner-blocks.mjs.map +1 -7
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs +36 -33
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs.map +1 -7
- package/build-module/blocks/widget-area/index.mjs +12 -15
- package/build-module/blocks/widget-area/index.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +103 -128
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/header/document-tools/index.mjs +51 -84
- package/build-module/components/header/document-tools/index.mjs.map +1 -7
- package/build-module/components/header/index.mjs +40 -47
- package/build-module/components/header/index.mjs.map +1 -7
- package/build-module/components/header/undo-redo/redo.mjs +20 -27
- package/build-module/components/header/undo-redo/redo.mjs.map +1 -7
- package/build-module/components/header/undo-redo/undo.mjs +19 -26
- package/build-module/components/header/undo-redo/undo.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs +67 -136
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -54
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcuts/index.mjs +99 -119
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
- package/build-module/components/layout/index.mjs +29 -40
- package/build-module/components/layout/index.mjs.map +1 -7
- package/build-module/components/layout/interface.mjs +53 -76
- package/build-module/components/layout/interface.mjs.map +1 -7
- package/build-module/components/layout/unsaved-changes-warning.mjs +37 -26
- package/build-module/components/layout/unsaved-changes-warning.mjs.map +1 -7
- package/build-module/components/more-menu/index.mjs +95 -162
- package/build-module/components/more-menu/index.mjs.map +1 -7
- package/build-module/components/more-menu/tools-more-menu-group.mjs +5 -9
- package/build-module/components/more-menu/tools-more-menu-group.mjs.map +1 -7
- package/build-module/components/notices/index.mjs +12 -17
- package/build-module/components/notices/index.mjs.map +1 -7
- package/build-module/components/save-button/index.mjs +23 -35
- package/build-module/components/save-button/index.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/index.mjs +15 -20
- package/build-module/components/secondary-sidebar/index.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/inserter-sidebar.mjs +27 -25
- package/build-module/components/secondary-sidebar/inserter-sidebar.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/list-view-sidebar.mjs +39 -55
- package/build-module/components/secondary-sidebar/list-view-sidebar.mjs.map +1 -7
- package/build-module/components/sidebar/index.mjs +96 -162
- package/build-module/components/sidebar/index.mjs.map +1 -7
- package/build-module/components/sidebar/widget-areas.mjs +30 -57
- package/build-module/components/sidebar/widget-areas.mjs.map +1 -7
- package/build-module/components/welcome-guide/index.mjs +103 -164
- package/build-module/components/welcome-guide/index.mjs.map +1 -7
- package/build-module/components/widget-areas-block-editor-content/index.mjs +35 -44
- package/build-module/components/widget-areas-block-editor-content/index.mjs.map +1 -7
- package/build-module/components/widget-areas-block-editor-provider/index.mjs +76 -109
- package/build-module/components/widget-areas-block-editor-provider/index.mjs.map +1 -7
- package/build-module/constants.mjs +5 -7
- package/build-module/constants.mjs.map +1 -7
- package/build-module/filters/index.mjs +0 -2
- package/build-module/filters/move-to-widget-area.mjs +28 -48
- package/build-module/filters/move-to-widget-area.mjs.map +1 -7
- package/build-module/filters/replace-media-upload.mjs +5 -8
- package/build-module/filters/replace-media-upload.mjs.map +1 -7
- package/build-module/hooks/use-last-selected-widget-area.mjs +23 -29
- package/build-module/hooks/use-last-selected-widget-area.mjs.map +1 -7
- package/build-module/hooks/use-widget-library-insertion-point.mjs +28 -47
- package/build-module/hooks/use-widget-library-insertion-point.mjs.map +1 -7
- package/build-module/index.mjs +62 -79
- package/build-module/index.mjs.map +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +250 -247
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/constants.mjs +7 -5
- package/build-module/store/constants.mjs.map +1 -7
- package/build-module/store/index.mjs +18 -16
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/private-selectors.mjs +5 -7
- package/build-module/store/private-selectors.mjs.map +1 -7
- package/build-module/store/reducer.mjs +95 -58
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/resolvers.mjs +52 -71
- package/build-module/store/resolvers.mjs.map +1 -7
- package/build-module/store/selectors.mjs +178 -199
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/transformers.mjs +44 -56
- package/build-module/store/transformers.mjs.map +1 -7
- package/build-module/store/utils.mjs +64 -32
- package/build-module/store/utils.mjs.map +1 -7
- package/build-style/style-rtl.css +12 -12
- package/build-style/style.css +12 -12
- package/package.json +35 -36
- package/src/components/header/index.jsx +2 -2
- package/src/components/layout/interface.jsx +4 -1
- package/src/components/layout/style.scss +11 -0
- package/src/components/notices/style.scss +2 -2
- package/src/components/sidebar/index.jsx +18 -18
- package/src/components/welcome-guide/index.jsx +4 -2
- package/src/components/widget-areas-block-editor-content/index.jsx +4 -3
- package/CHANGELOG.md +0 -325
- package/build/filters/index.cjs.map +0 -7
- package/build-module/filters/index.mjs.map +0 -7
|
@@ -1,120 +1,87 @@
|
|
|
1
|
-
// packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.jsx
|
|
2
1
|
import { SlotFillProvider } from "@wordpress/components";
|
|
3
2
|
import { useViewportMatch } from "@wordpress/compose";
|
|
4
3
|
import { uploadMedia } from "@wordpress/media-utils";
|
|
5
4
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
6
|
-
import {
|
|
5
|
+
import { store, useEntityBlockEditor } from "@wordpress/core-data";
|
|
7
6
|
import { useMemo } from "@wordpress/element";
|
|
8
|
-
import { privateApis
|
|
9
|
-
import { privateApis as
|
|
10
|
-
import { store as
|
|
7
|
+
import { privateApis } from "@wordpress/block-editor";
|
|
8
|
+
import { privateApis as privateApis$1 } from "@wordpress/patterns";
|
|
9
|
+
import { store as store$1 } from "@wordpress/preferences";
|
|
11
10
|
import KeyboardShortcuts from "../keyboard-shortcuts/index.mjs";
|
|
12
|
-
import {
|
|
11
|
+
import { KIND, POST_TYPE, buildWidgetAreasPostId } from "../../store/utils.mjs";
|
|
13
12
|
import useLastSelectedWidgetArea from "../../hooks/use-last-selected-widget-area.mjs";
|
|
14
|
-
import { store as
|
|
13
|
+
import { store as store$2 } from "../../store/index.mjs";
|
|
15
14
|
import { ALLOW_REUSABLE_BLOCKS } from "../../constants.mjs";
|
|
16
15
|
import { unlock } from "../../lock-unlock.mjs";
|
|
17
16
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
isLargeViewport,
|
|
86
|
-
keepCaretInsideBlock,
|
|
87
|
-
reusableBlocks,
|
|
88
|
-
setIsInserterOpened,
|
|
89
|
-
pageOnFront,
|
|
90
|
-
pageForPosts
|
|
91
|
-
]);
|
|
92
|
-
const widgetAreaId = useLastSelectedWidgetArea();
|
|
93
|
-
const [blocks, onInput, onChange] = useEntityBlockEditor(
|
|
94
|
-
KIND,
|
|
95
|
-
POST_TYPE,
|
|
96
|
-
{ id: buildWidgetAreasPostId() }
|
|
97
|
-
);
|
|
98
|
-
return /* @__PURE__ */ jsxs(SlotFillProvider, { children: [
|
|
99
|
-
/* @__PURE__ */ jsx(KeyboardShortcuts.Register, {}),
|
|
100
|
-
/* @__PURE__ */ jsxs(
|
|
101
|
-
ExperimentalBlockEditorProvider,
|
|
102
|
-
{
|
|
103
|
-
value: blocks,
|
|
104
|
-
onInput,
|
|
105
|
-
onChange,
|
|
106
|
-
settings,
|
|
107
|
-
useSubRegistry: false,
|
|
108
|
-
...props,
|
|
109
|
-
children: [
|
|
110
|
-
children,
|
|
111
|
-
/* @__PURE__ */ jsx(PatternsMenuItems, { rootClientId: widgetAreaId })
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
] });
|
|
17
|
+
// packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.jsx
|
|
18
|
+
const { ExperimentalBlockEditorProvider } = unlock(privateApis);
|
|
19
|
+
const { PatternsMenuItems } = unlock(privateApis$1);
|
|
20
|
+
const EMPTY_ARRAY = [];
|
|
21
|
+
function WidgetAreasBlockEditorProvider({ blockEditorSettings, children, ...props }) {
|
|
22
|
+
const isLargeViewport = useViewportMatch("medium");
|
|
23
|
+
const { hasUploadPermissions, reusableBlocks, isFixedToolbarActive, keepCaretInsideBlock, pageOnFront, pageForPosts } = useSelect((select) => {
|
|
24
|
+
const { canUser, getEntityRecord, getEntityRecords } = select(store);
|
|
25
|
+
const siteSettings = canUser("read", {
|
|
26
|
+
kind: "root",
|
|
27
|
+
name: "site"
|
|
28
|
+
}) ? getEntityRecord("root", "site") : void 0;
|
|
29
|
+
return {
|
|
30
|
+
hasUploadPermissions: canUser("create", {
|
|
31
|
+
kind: "postType",
|
|
32
|
+
name: "attachment"
|
|
33
|
+
}) ?? true,
|
|
34
|
+
reusableBlocks: ALLOW_REUSABLE_BLOCKS ? getEntityRecords("postType", "wp_block") : EMPTY_ARRAY,
|
|
35
|
+
isFixedToolbarActive: !!select(store$1).get("core/edit-widgets", "fixedToolbar"),
|
|
36
|
+
keepCaretInsideBlock: !!select(store$1).get("core/edit-widgets", "keepCaretInsideBlock"),
|
|
37
|
+
pageOnFront: siteSettings?.page_on_front,
|
|
38
|
+
pageForPosts: siteSettings?.page_for_posts
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
const { setIsInserterOpened } = useDispatch(store$2);
|
|
42
|
+
const settings = useMemo(() => {
|
|
43
|
+
let mediaUploadBlockEditor;
|
|
44
|
+
if (hasUploadPermissions) mediaUploadBlockEditor = ({ onError, ...argumentsObject }) => {
|
|
45
|
+
uploadMedia({
|
|
46
|
+
wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
|
|
47
|
+
onError: ({ message }) => onError(message),
|
|
48
|
+
...argumentsObject
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
...blockEditorSettings,
|
|
53
|
+
__experimentalReusableBlocks: reusableBlocks,
|
|
54
|
+
hasFixedToolbar: isFixedToolbarActive || !isLargeViewport,
|
|
55
|
+
keepCaretInsideBlock,
|
|
56
|
+
mediaUpload: mediaUploadBlockEditor,
|
|
57
|
+
templateLock: "all",
|
|
58
|
+
__experimentalSetIsInserterOpened: setIsInserterOpened,
|
|
59
|
+
pageOnFront,
|
|
60
|
+
pageForPosts
|
|
61
|
+
};
|
|
62
|
+
}, [
|
|
63
|
+
hasUploadPermissions,
|
|
64
|
+
blockEditorSettings,
|
|
65
|
+
isFixedToolbarActive,
|
|
66
|
+
isLargeViewport,
|
|
67
|
+
keepCaretInsideBlock,
|
|
68
|
+
reusableBlocks,
|
|
69
|
+
setIsInserterOpened,
|
|
70
|
+
pageOnFront,
|
|
71
|
+
pageForPosts
|
|
72
|
+
]);
|
|
73
|
+
const widgetAreaId = useLastSelectedWidgetArea();
|
|
74
|
+
const [blocks, onInput, onChange] = useEntityBlockEditor(KIND, POST_TYPE, { id: buildWidgetAreasPostId() });
|
|
75
|
+
return /* @__PURE__ */ jsxs(SlotFillProvider, { children: [/* @__PURE__ */ jsx(KeyboardShortcuts.Register, {}), /* @__PURE__ */ jsxs(ExperimentalBlockEditorProvider, {
|
|
76
|
+
value: blocks,
|
|
77
|
+
onInput,
|
|
78
|
+
onChange,
|
|
79
|
+
settings,
|
|
80
|
+
useSubRegistry: false,
|
|
81
|
+
...props,
|
|
82
|
+
children: [children, /* @__PURE__ */ jsx(PatternsMenuItems, { rootClientId: widgetAreaId })]
|
|
83
|
+
})] });
|
|
116
84
|
}
|
|
117
|
-
export {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//# sourceMappingURL=index.mjs.map
|
|
85
|
+
export { WidgetAreasBlockEditorProvider as default };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/widget-areas-block-editor-provider/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { 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 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 );\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};\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<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"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,aAAa,iBAAiB;AACvC,SAAS,sBAAsB,SAAS,iBAAiB;AACzD,SAAS,eAAe;AACxB,SAAS,eAAe,8BAA8B;AACtD,SAAS,eAAe,+BAA+B;AACvD,SAAS,SAAS,wBAAwB;AAC1C,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB,MAAM,iBAAiB;AACxD,OAAO,+BAA+B;AACtC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,6BAA6B;AACtC,SAAS,cAAc;AAgGpB,cACA,YADA;AA9FH,IAAM,EAAE,gCAAgC,IAAI,OAAQ,sBAAuB;AAC3E,IAAM,EAAE,kBAAkB,IAAI,OAAQ,uBAAwB;AAE9D,IAAM,cAAc,CAAC;AAEN,SAAR,+BAAiD;AAAA,EACvD;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,kBAAkB,iBAAkB,QAAS;AACnD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,UAAW,CAAE,WAAY;AAC5B,UAAM,EAAE,SAAS,iBAAiB,iBAAiB,IAClD,OAAQ,SAAU;AACnB,UAAM,eAAe,QAAS,QAAQ;AAAA,MACrC,MAAM;AAAA,MACN,MAAM;AAAA,IACP,CAAE,IACC,gBAAiB,QAAQ,MAAO,IAChC;AACH,WAAO;AAAA,MACN,sBACC,QAAS,UAAU;AAAA,QAClB,MAAM;AAAA,QACN,MAAM;AAAA,MACP,CAAE,KAAK;AAAA,MACR,gBAAgB,wBACb,iBAAkB,YAAY,UAAW,IACzC;AAAA,MACH,sBAAsB,CAAC,CAAE,OAAQ,gBAAiB,EAAE;AAAA,QACnD;AAAA,QACA;AAAA,MACD;AAAA,MACA,sBAAsB,CAAC,CAAE,OAAQ,gBAAiB,EAAE;AAAA,QACnD;AAAA,QACA;AAAA,MACD;AAAA,MACA,aAAa,cAAc;AAAA,MAC3B,cAAc,cAAc;AAAA,IAC7B;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,oBAAoB,IAAI,YAAa,gBAAiB;AAE9D,QAAM,WAAW,QAAS,MAAM;AAC/B,QAAI;AACJ,QAAK,sBAAuB;AAC3B,+BAAyB,CAAE,EAAE,SAAS,GAAG,gBAAgB,MAAO;AAC/D,oBAAa;AAAA,UACZ,oBAAoB,oBAAoB;AAAA,UACxC,SAAS,CAAE,EAAE,QAAQ,MAAO,QAAS,OAAQ;AAAA,UAC7C,GAAG;AAAA,QACJ,CAAE;AAAA,MACH;AAAA,IACD;AACA,WAAO;AAAA,MACN,GAAG;AAAA,MACH,8BAA8B;AAAA,MAC9B,iBAAiB,wBAAwB,CAAE;AAAA,MAC3C;AAAA,MACA,aAAa;AAAA,MACb,cAAc;AAAA,MACd,mCAAmC;AAAA,MACnC;AAAA,MACA;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,QAAM,eAAe,0BAA0B;AAE/C,QAAM,CAAE,QAAQ,SAAS,QAAS,IAAI;AAAA,IACrC;AAAA,IACA;AAAA,IACA,EAAE,IAAI,uBAAuB,EAAE;AAAA,EAChC;AAEA,SACC,qBAAC,oBACA;AAAA,wBAAC,kBAAkB,UAAlB,EAA2B;AAAA,IAC5B;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAiB;AAAA,QACf,GAAG;AAAA,QAEH;AAAA;AAAA,UACF,oBAAC,qBAAkB,cAAe,cAAe;AAAA;AAAA;AAAA,IAClD;AAAA,KACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["blockEditorPrivateApis","editPatternsPrivateApis","coreStore","preferencesStore","editWidgetsStore"],"sources":["../../../src/components/widget-areas-block-editor-provider/index.jsx"],"sourcesContent":["import { 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 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 );\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};\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<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":";;;;;;;;;;;;;;;;;AAgBA,MAAM,EAAE,oCAAoC,OAAQA,WAAuB;AAC3E,MAAM,EAAE,sBAAsB,OAAQC,aAAwB;AAE9D,MAAM,cAAc,CAAC;AAErB,SAAwB,+BAAgC,EACvD,qBACA,UACA,GAAG,SACA;CACH,MAAM,kBAAkB,iBAAkB,QAAS;CACnD,MAAM,EACL,sBACA,gBACA,sBACA,sBACA,aACA,iBACG,WAAa,WAAY;EAC5B,MAAM,EAAE,SAAS,iBAAiB,qBACjC,OAAQC,KAAU;EACnB,MAAM,eAAe,QAAS,QAAQ;GACrC,MAAM;GACN,MAAM;EACP,CAAE,IACC,gBAAiB,QAAQ,MAAO,IAChC,KAAA;EACH,OAAO;GACN,sBACC,QAAS,UAAU;IAClB,MAAM;IACN,MAAM;GACP,CAAE,KAAK;GACR,gBAAgB,wBACb,iBAAkB,YAAY,UAAW,IACzC;GACH,sBAAsB,CAAC,CAAE,OAAQC,OAAiB,CAAC,CAAC,IACnD,qBACA,cACD;GACA,sBAAsB,CAAC,CAAE,OAAQA,OAAiB,CAAC,CAAC,IACnD,qBACA,sBACD;GACA,aAAa,cAAc;GAC3B,cAAc,cAAc;EAC7B;CACD,GAAG,CAAC,CAAE;CACN,MAAM,EAAE,wBAAwB,YAAaC,OAAiB;CAE9D,MAAM,WAAW,cAAe;EAC/B,IAAI;EACJ,IAAK,sBACJ,0BAA2B,EAAE,SAAS,GAAG,sBAAuB;GAC/D,YAAa;IACZ,oBAAoB,oBAAoB;IACxC,UAAW,EAAE,cAAe,QAAS,OAAQ;IAC7C,GAAG;GACJ,CAAE;EACH;EAED,OAAO;GACN,GAAG;GACH,8BAA8B;GAC9B,iBAAiB,wBAAwB,CAAE;GAC3C;GACA,aAAa;GACb,cAAc;GACd,mCAAmC;GACnC;GACA;EACD;CACD,GAAG;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAE;CAEF,MAAM,eAAe,0BAA0B;CAE/C,MAAM,CAAE,QAAQ,SAAS,YAAa,qBACrC,MACA,WACA,EAAE,IAAI,uBAAuB,EAAE,CAChC;CAEA,OACC,qBAAC,kBAAD,EAAA,UAAA,CACC,oBAAC,kBAAkB,UAAnB,CAA6B,CAAA,GAC7B,qBAAC,iCAAD;EACC,OAAQ;EACE;EACC;EACA;EACX,gBAAiB;EACjB,GAAK;EANN,UAAA,CAQG,UACF,oBAAC,mBAAD,EAAmB,cAAe,aAAgB,CAAA,CAClB;CAChB,CAAA,CAAA,EAAA,CAAA;AAEpB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// packages/edit-widgets/src/constants.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=constants.mjs.map
|
|
2
|
+
const ALLOW_REUSABLE_BLOCKS = false;
|
|
3
|
+
const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
|
|
4
|
+
export { ALLOW_REUSABLE_BLOCKS, ENABLE_EXPERIMENTAL_FSE_BLOCKS };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/constants.js"],
|
|
4
|
-
"sourcesContent": ["export const ALLOW_REUSABLE_BLOCKS = false;\nexport const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;\n"],
|
|
5
|
-
"mappings": ";AAAO,IAAM,wBAAwB;AAC9B,IAAM,iCAAiC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.js"],"sourcesContent":["export const ALLOW_REUSABLE_BLOCKS = false;\nexport const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;\n"],"mappings":";AAAA,MAAa,wBAAwB;AACrC,MAAa,iCAAiC"}
|
|
@@ -1,54 +1,34 @@
|
|
|
1
|
-
// packages/edit-widgets/src/filters/move-to-widget-area.jsx
|
|
2
1
|
import { BlockControls } from "@wordpress/block-editor";
|
|
3
2
|
import { createHigherOrderComponent } from "@wordpress/compose";
|
|
4
3
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
5
4
|
import { addFilter } from "@wordpress/hooks";
|
|
6
5
|
import { MoveToWidgetArea } from "@wordpress/widgets";
|
|
7
|
-
import { store
|
|
6
|
+
import { store } from "../store/index.mjs";
|
|
8
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
currentWidgetAreaId,
|
|
37
|
-
onSelect: (widgetAreaId) => {
|
|
38
|
-
moveBlockToWidgetArea(
|
|
39
|
-
props.clientId,
|
|
40
|
-
widgetAreaId
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
) })
|
|
45
|
-
] });
|
|
46
|
-
},
|
|
47
|
-
"withMoveToWidgetAreaToolbarItem"
|
|
48
|
-
);
|
|
49
|
-
addFilter(
|
|
50
|
-
"editor.BlockEdit",
|
|
51
|
-
"core/edit-widgets/block-edit",
|
|
52
|
-
withMoveToWidgetAreaToolbarItem
|
|
53
|
-
);
|
|
54
|
-
//# sourceMappingURL=move-to-widget-area.mjs.map
|
|
8
|
+
// packages/edit-widgets/src/filters/move-to-widget-area.jsx
|
|
9
|
+
const withMoveToWidgetAreaToolbarItem = createHigherOrderComponent((BlockEdit) => (props) => {
|
|
10
|
+
const { clientId, name: blockName } = props;
|
|
11
|
+
const { widgetAreas, currentWidgetAreaId, canInsertBlockInWidgetArea } = useSelect((select) => {
|
|
12
|
+
if (blockName === "core/widget-area") return {};
|
|
13
|
+
const selectors = select(store);
|
|
14
|
+
const widgetAreaBlock = selectors.getParentWidgetAreaBlock(clientId);
|
|
15
|
+
return {
|
|
16
|
+
widgetAreas: selectors.getWidgetAreas(),
|
|
17
|
+
currentWidgetAreaId: widgetAreaBlock?.attributes?.id,
|
|
18
|
+
canInsertBlockInWidgetArea: selectors.canInsertBlockInWidgetArea(blockName)
|
|
19
|
+
};
|
|
20
|
+
}, [clientId, blockName]);
|
|
21
|
+
const { moveBlockToWidgetArea } = useDispatch(store);
|
|
22
|
+
const hasMultipleWidgetAreas = widgetAreas?.length > 1;
|
|
23
|
+
const isMoveToWidgetAreaVisible = blockName !== "core/widget-area" && hasMultipleWidgetAreas && canInsertBlockInWidgetArea;
|
|
24
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(BlockEdit, { ...props }, "edit"), isMoveToWidgetAreaVisible && /* @__PURE__ */ jsx(BlockControls, { children: /* @__PURE__ */ jsx(MoveToWidgetArea, {
|
|
25
|
+
widgetAreas,
|
|
26
|
+
currentWidgetAreaId,
|
|
27
|
+
onSelect: (widgetAreaId) => {
|
|
28
|
+
moveBlockToWidgetArea(props.clientId, widgetAreaId);
|
|
29
|
+
}
|
|
30
|
+
}) })] });
|
|
31
|
+
}, "withMoveToWidgetAreaToolbarItem");
|
|
32
|
+
addFilter("editor.BlockEdit", "core/edit-widgets/block-edit", withMoveToWidgetAreaToolbarItem);
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=move-to-widget-area.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/filters/move-to-widget-area.jsx"],
|
|
4
|
-
"sourcesContent": ["import { BlockControls } from '@wordpress/block-editor';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { MoveToWidgetArea } from '@wordpress/widgets';\nimport { store as editWidgetsStore } from '../store';\n\nconst withMoveToWidgetAreaToolbarItem = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name: blockName } = props;\n\t\tconst { widgetAreas, currentWidgetAreaId, canInsertBlockInWidgetArea } =\n\t\t\tuseSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\t// Component won't display for a widget area, so don't run selectors.\n\t\t\t\t\tif ( blockName === 'core/widget-area' ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst selectors = select( editWidgetsStore );\n\n\t\t\t\t\tconst widgetAreaBlock =\n\t\t\t\t\t\tselectors.getParentWidgetAreaBlock( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\twidgetAreas: selectors.getWidgetAreas(),\n\t\t\t\t\t\tcurrentWidgetAreaId: widgetAreaBlock?.attributes?.id,\n\t\t\t\t\t\tcanInsertBlockInWidgetArea:\n\t\t\t\t\t\t\tselectors.canInsertBlockInWidgetArea( blockName ),\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ clientId, blockName ]\n\t\t\t);\n\n\t\tconst { moveBlockToWidgetArea } = useDispatch( editWidgetsStore );\n\t\tconst hasMultipleWidgetAreas = widgetAreas?.length > 1;\n\t\tconst isMoveToWidgetAreaVisible =\n\t\t\tblockName !== 'core/widget-area' &&\n\t\t\thasMultipleWidgetAreas &&\n\t\t\tcanInsertBlockInWidgetArea;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t{ isMoveToWidgetAreaVisible && (\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<MoveToWidgetArea\n\t\t\t\t\t\t\twidgetAreas={ widgetAreas }\n\t\t\t\t\t\t\tcurrentWidgetAreaId={ currentWidgetAreaId }\n\t\t\t\t\t\t\tonSelect={ ( widgetAreaId ) => {\n\t\t\t\t\t\t\t\tmoveBlockToWidgetArea(\n\t\t\t\t\t\t\t\t\tprops.clientId,\n\t\t\t\t\t\t\t\t\twidgetAreaId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withMoveToWidgetAreaToolbarItem'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-widgets/block-edit',\n\twithMoveToWidgetAreaToolbarItem\n);\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAC3C,SAAS,aAAa,iBAAiB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,SAAS,wBAAwB;AAoCvC,mBACC,KADD;AAlCH,IAAM,kCAAkC;AAAA,EACvC,CAAE,cAAe,CAAE,UAAW;AAC7B,UAAM,EAAE,UAAU,MAAM,UAAU,IAAI;AACtC,UAAM,EAAE,aAAa,qBAAqB,2BAA2B,IACpE;AAAA,MACC,CAAE,WAAY;AAEb,YAAK,cAAc,oBAAqB;AACvC,iBAAO,CAAC;AAAA,QACT;AAEA,cAAM,YAAY,OAAQ,gBAAiB;AAE3C,cAAM,kBACL,UAAU,yBAA0B,QAAS;AAE9C,eAAO;AAAA,UACN,aAAa,UAAU,eAAe;AAAA,UACtC,qBAAqB,iBAAiB,YAAY;AAAA,UAClD,4BACC,UAAU,2BAA4B,SAAU;AAAA,QAClD;AAAA,MACD;AAAA,MACA,CAAE,UAAU,SAAU;AAAA,IACvB;AAED,UAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAChE,UAAM,yBAAyB,aAAa,SAAS;AACrD,UAAM,4BACL,cAAc,sBACd,0BACA;AAED,WACC,iCACC;AAAA,0BAAC,aAAuB,GAAG,SAAZ,MAAoB;AAAA,MACjC,6BACD,oBAAC,iBACA;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA,UAAW,CAAE,iBAAkB;AAC9B;AAAA,cACC,MAAM;AAAA,cACN;AAAA,YACD;AAAA,UACD;AAAA;AAAA,MACD,GACD;AAAA,OAEF;AAAA,EAEF;AAAA,EACA;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"move-to-widget-area.mjs","names":["editWidgetsStore"],"sources":["../../src/filters/move-to-widget-area.jsx"],"sourcesContent":["import { BlockControls } from '@wordpress/block-editor';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { MoveToWidgetArea } from '@wordpress/widgets';\nimport { store as editWidgetsStore } from '../store';\n\nconst withMoveToWidgetAreaToolbarItem = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name: blockName } = props;\n\t\tconst { widgetAreas, currentWidgetAreaId, canInsertBlockInWidgetArea } =\n\t\t\tuseSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\t// Component won't display for a widget area, so don't run selectors.\n\t\t\t\t\tif ( blockName === 'core/widget-area' ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst selectors = select( editWidgetsStore );\n\n\t\t\t\t\tconst widgetAreaBlock =\n\t\t\t\t\t\tselectors.getParentWidgetAreaBlock( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\twidgetAreas: selectors.getWidgetAreas(),\n\t\t\t\t\t\tcurrentWidgetAreaId: widgetAreaBlock?.attributes?.id,\n\t\t\t\t\t\tcanInsertBlockInWidgetArea:\n\t\t\t\t\t\t\tselectors.canInsertBlockInWidgetArea( blockName ),\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ clientId, blockName ]\n\t\t\t);\n\n\t\tconst { moveBlockToWidgetArea } = useDispatch( editWidgetsStore );\n\t\tconst hasMultipleWidgetAreas = widgetAreas?.length > 1;\n\t\tconst isMoveToWidgetAreaVisible =\n\t\t\tblockName !== 'core/widget-area' &&\n\t\t\thasMultipleWidgetAreas &&\n\t\t\tcanInsertBlockInWidgetArea;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t{ isMoveToWidgetAreaVisible && (\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<MoveToWidgetArea\n\t\t\t\t\t\t\twidgetAreas={ widgetAreas }\n\t\t\t\t\t\t\tcurrentWidgetAreaId={ currentWidgetAreaId }\n\t\t\t\t\t\t\tonSelect={ ( widgetAreaId ) => {\n\t\t\t\t\t\t\t\tmoveBlockToWidgetArea(\n\t\t\t\t\t\t\t\t\tprops.clientId,\n\t\t\t\t\t\t\t\t\twidgetAreaId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withMoveToWidgetAreaToolbarItem'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-widgets/block-edit',\n\twithMoveToWidgetAreaToolbarItem\n);\n"],"mappings":";;;;;;;;AAOA,MAAM,kCAAkC,4BACrC,eAAiB,UAAW;CAC7B,MAAM,EAAE,UAAU,MAAM,cAAc;CACtC,MAAM,EAAE,aAAa,qBAAqB,+BACzC,WACG,WAAY;EAEb,IAAK,cAAc,oBAClB,OAAO,CAAC;EAGT,MAAM,YAAY,OAAQA,KAAiB;EAE3C,MAAM,kBACL,UAAU,yBAA0B,QAAS;EAE9C,OAAO;GACN,aAAa,UAAU,eAAe;GACtC,qBAAqB,iBAAiB,YAAY;GAClD,4BACC,UAAU,2BAA4B,SAAU;EAClD;CACD,GACA,CAAE,UAAU,SAAU,CACvB;CAED,MAAM,EAAE,0BAA0B,YAAaA,KAAiB;CAChE,MAAM,yBAAyB,aAAa,SAAS;CACrD,MAAM,4BACL,cAAc,sBACd,0BACA;CAED,OACC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,WAAD,EAAsB,GAAK,MAAS,GAArB,MAAqB,GAClC,6BACD,oBAAC,eAAD,EAAA,UACC,oBAAC,kBAAD;EACe;EACQ;EACtB,WAAa,iBAAkB;GAC9B,sBACC,MAAM,UACN,YACD;EACD;CACA,CAAA,EACa,CAAA,CAEf,EAAA,CAAA;AAEJ,GACA,iCACD;AAEA,UACC,oBACA,gCACA,+BACD"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
// packages/edit-widgets/src/filters/replace-media-upload.js
|
|
2
1
|
import { addFilter } from "@wordpress/hooks";
|
|
3
2
|
import { MediaUpload } from "@wordpress/media-utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
);
|
|
10
|
-
//# sourceMappingURL=replace-media-upload.mjs.map
|
|
3
|
+
// packages/edit-widgets/src/filters/replace-media-upload.js
|
|
4
|
+
const replaceMediaUpload = () => MediaUpload;
|
|
5
|
+
addFilter("editor.MediaUpload", "core/edit-widgets/replace-media-upload", replaceMediaUpload);
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=replace-media-upload.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/filters/replace-media-upload.js"],
|
|
4
|
-
"sourcesContent": ["import { addFilter } from '@wordpress/hooks';\nimport { MediaUpload } from '@wordpress/media-utils';\n\nconst replaceMediaUpload = () => MediaUpload;\n\naddFilter(\n\t'editor.MediaUpload',\n\t'core/edit-widgets/replace-media-upload',\n\treplaceMediaUpload\n);\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAE5B,IAAM,qBAAqB,MAAM;AAEjC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"replace-media-upload.mjs","names":[],"sources":["../../src/filters/replace-media-upload.js"],"sourcesContent":["import { addFilter } from '@wordpress/hooks';\nimport { MediaUpload } from '@wordpress/media-utils';\n\nconst replaceMediaUpload = () => MediaUpload;\n\naddFilter(\n\t'editor.MediaUpload',\n\t'core/edit-widgets/replace-media-upload',\n\treplaceMediaUpload\n);\n"],"mappings":";;;AAGA,MAAM,2BAA2B;AAEjC,UACC,sBACA,0CACA,kBACD"}
|
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
// packages/edit-widgets/src/hooks/use-last-selected-widget-area.js
|
|
2
1
|
import { useSelect } from "@wordpress/data";
|
|
3
|
-
import { store
|
|
4
|
-
import { store as
|
|
5
|
-
import { store as
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
buildWidgetAreasPostId()
|
|
24
|
-
);
|
|
25
|
-
return widgetAreasPost?.blocks[0]?.clientId;
|
|
2
|
+
import { store } from "@wordpress/block-editor";
|
|
3
|
+
import { store as store$1 } from "@wordpress/core-data";
|
|
4
|
+
import { store as store$2 } from "../store/index.mjs";
|
|
5
|
+
import { KIND, POST_TYPE, buildWidgetAreasPostId } from "../store/utils.mjs";
|
|
6
|
+
// packages/edit-widgets/src/hooks/use-last-selected-widget-area.js
|
|
7
|
+
/**
|
|
8
|
+
* A react hook that returns the client id of the last widget area to have
|
|
9
|
+
* been selected, or to have a selected block within it.
|
|
10
|
+
*
|
|
11
|
+
* @return {string} clientId of the widget area last selected.
|
|
12
|
+
*/
|
|
13
|
+
const useLastSelectedWidgetArea = () => useSelect((select) => {
|
|
14
|
+
const { getBlockSelectionEnd, getBlockName } = select(store);
|
|
15
|
+
const selectionEndClientId = getBlockSelectionEnd();
|
|
16
|
+
if (getBlockName(selectionEndClientId) === "core/widget-area") return selectionEndClientId;
|
|
17
|
+
const { getParentWidgetAreaBlock } = select(store$2);
|
|
18
|
+
const widgetAreaBlockClientId = getParentWidgetAreaBlock(selectionEndClientId)?.clientId;
|
|
19
|
+
if (widgetAreaBlockClientId) return widgetAreaBlockClientId;
|
|
20
|
+
const { getEntityRecord } = select(store$1);
|
|
21
|
+
return getEntityRecord(KIND, POST_TYPE, buildWidgetAreasPostId())?.blocks[0]?.clientId;
|
|
26
22
|
}, []);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=use-last-selected-widget-area.mjs.map
|
|
23
|
+
export { useLastSelectedWidgetArea as default };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=use-last-selected-widget-area.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/use-last-selected-widget-area.js"],
|
|
4
|
-
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as widgetsEditorStore } from '../store';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../store/utils';\n\n/**\n * A react hook that returns the client id of the last widget area to have\n * been selected, or to have a selected block within it.\n *\n * @return {string} clientId of the widget area last selected.\n */\nconst useLastSelectedWidgetArea = () =>\n\tuseSelect( ( select ) => {\n\t\tconst { getBlockSelectionEnd, getBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionEndClientId = getBlockSelectionEnd();\n\n\t\t// If the selected block is a widget area, return its clientId.\n\t\tif ( getBlockName( selectionEndClientId ) === 'core/widget-area' ) {\n\t\t\treturn selectionEndClientId;\n\t\t}\n\n\t\tconst { getParentWidgetAreaBlock } = select( widgetsEditorStore );\n\t\tconst widgetAreaBlock =\n\t\t\tgetParentWidgetAreaBlock( selectionEndClientId );\n\t\tconst widgetAreaBlockClientId = widgetAreaBlock?.clientId;\n\n\t\tif ( widgetAreaBlockClientId ) {\n\t\t\treturn widgetAreaBlockClientId;\n\t\t}\n\n\t\t// If no widget area has been selected, return the clientId of the first\n\t\t// area.\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst widgetAreasPost = getEntityRecord(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tbuildWidgetAreasPostId()\n\t\t);\n\t\treturn widgetAreasPost?.blocks[ 0 ]?.clientId;\n\t}, [] );\n\nexport default useLastSelectedWidgetArea;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,0BAA0B;AAC5C,SAAS,wBAAwB,MAAM,iBAAiB;AAQxD,IAAM,4BAA4B,MACjC,UAAW,CAAE,WAAY;AACxB,QAAM,EAAE,sBAAsB,aAAa,IAC1C,OAAQ,gBAAiB;AAC1B,QAAM,uBAAuB,qBAAqB;AAGlD,MAAK,aAAc,oBAAqB,MAAM,oBAAqB;AAClE,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,yBAAyB,IAAI,OAAQ,kBAAmB;AAChE,QAAM,kBACL,yBAA0B,oBAAqB;AAChD,QAAM,0BAA0B,iBAAiB;AAEjD,MAAK,yBAA0B;AAC9B,WAAO;AAAA,EACR;AAIA,QAAM,EAAE,gBAAgB,IAAI,OAAQ,SAAU;AAC9C,QAAM,kBAAkB;AAAA,IACvB;AAAA,IACA;AAAA,IACA,uBAAuB;AAAA,EACxB;AACA,SAAO,iBAAiB,OAAQ,CAAE,GAAG;AACtC,GAAG,CAAC,CAAE;AAEP,IAAO,wCAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"use-last-selected-widget-area.mjs","names":["blockEditorStore","widgetsEditorStore","coreStore"],"sources":["../../src/hooks/use-last-selected-widget-area.js"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as widgetsEditorStore } from '../store';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../store/utils';\n\n/**\n * A react hook that returns the client id of the last widget area to have\n * been selected, or to have a selected block within it.\n *\n * @return {string} clientId of the widget area last selected.\n */\nconst useLastSelectedWidgetArea = () =>\n\tuseSelect( ( select ) => {\n\t\tconst { getBlockSelectionEnd, getBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionEndClientId = getBlockSelectionEnd();\n\n\t\t// If the selected block is a widget area, return its clientId.\n\t\tif ( getBlockName( selectionEndClientId ) === 'core/widget-area' ) {\n\t\t\treturn selectionEndClientId;\n\t\t}\n\n\t\tconst { getParentWidgetAreaBlock } = select( widgetsEditorStore );\n\t\tconst widgetAreaBlock =\n\t\t\tgetParentWidgetAreaBlock( selectionEndClientId );\n\t\tconst widgetAreaBlockClientId = widgetAreaBlock?.clientId;\n\n\t\tif ( widgetAreaBlockClientId ) {\n\t\t\treturn widgetAreaBlockClientId;\n\t\t}\n\n\t\t// If no widget area has been selected, return the clientId of the first\n\t\t// area.\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst widgetAreasPost = getEntityRecord(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tbuildWidgetAreasPostId()\n\t\t);\n\t\treturn widgetAreasPost?.blocks[ 0 ]?.clientId;\n\t}, [] );\n\nexport default useLastSelectedWidgetArea;\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,kCACL,WAAa,WAAY;CACxB,MAAM,EAAE,sBAAsB,iBAC7B,OAAQA,KAAiB;CAC1B,MAAM,uBAAuB,qBAAqB;CAGlD,IAAK,aAAc,oBAAqB,MAAM,oBAC7C,OAAO;CAGR,MAAM,EAAE,6BAA6B,OAAQC,OAAmB;CAGhE,MAAM,0BADL,yBAA0B,oBACmB,CAAC,EAAE;CAEjD,IAAK,yBACJ,OAAO;CAKR,MAAM,EAAE,oBAAoB,OAAQC,OAAU;CAM9C,OALwB,gBACvB,MACA,WACA,uBAAuB,CAEH,CAAC,EAAE,OAAQ,EAAG,EAAE;AACtC,GAAG,CAAC,CAAE"}
|
|
@@ -1,49 +1,30 @@
|
|
|
1
|
-
// packages/edit-widgets/src/hooks/use-widget-library-insertion-point.js
|
|
2
1
|
import { useSelect } from "@wordpress/data";
|
|
3
|
-
import { store
|
|
4
|
-
import { store as
|
|
5
|
-
import { store as
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
const clientId = getBlockSelectionEnd() || firstRootId;
|
|
30
|
-
const rootClientId = getBlockRootClientId(clientId);
|
|
31
|
-
if (clientId && rootClientId === "") {
|
|
32
|
-
return {
|
|
33
|
-
rootClientId: clientId,
|
|
34
|
-
insertionIndex: getBlockOrder(clientId).length
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
rootClientId,
|
|
39
|
-
insertionIndex: getBlockIndex(clientId) + 1
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
[firstRootId]
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
var use_widget_library_insertion_point_default = useWidgetLibraryInsertionPoint;
|
|
46
|
-
export {
|
|
47
|
-
use_widget_library_insertion_point_default as default
|
|
2
|
+
import { store } from "@wordpress/block-editor";
|
|
3
|
+
import { store as store$1 } from "@wordpress/core-data";
|
|
4
|
+
import { store as store$2 } from "../store/index.mjs";
|
|
5
|
+
import { KIND, POST_TYPE, buildWidgetAreasPostId } from "../store/utils.mjs";
|
|
6
|
+
// packages/edit-widgets/src/hooks/use-widget-library-insertion-point.js
|
|
7
|
+
const useWidgetLibraryInsertionPoint = () => {
|
|
8
|
+
const firstRootId = useSelect((select) => {
|
|
9
|
+
const { getEntityRecord } = select(store$1);
|
|
10
|
+
return getEntityRecord(KIND, POST_TYPE, buildWidgetAreasPostId())?.blocks[0]?.clientId;
|
|
11
|
+
}, []);
|
|
12
|
+
return useSelect((select) => {
|
|
13
|
+
const { getBlockRootClientId, getBlockSelectionEnd, getBlockOrder, getBlockIndex } = select(store);
|
|
14
|
+
const insertionPoint = select(store$2).__experimentalGetInsertionPoint();
|
|
15
|
+
if (insertionPoint.rootClientId) return insertionPoint;
|
|
16
|
+
const clientId = getBlockSelectionEnd() || firstRootId;
|
|
17
|
+
const rootClientId = getBlockRootClientId(clientId);
|
|
18
|
+
if (clientId && rootClientId === "") return {
|
|
19
|
+
rootClientId: clientId,
|
|
20
|
+
insertionIndex: getBlockOrder(clientId).length
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
rootClientId,
|
|
24
|
+
insertionIndex: getBlockIndex(clientId) + 1
|
|
25
|
+
};
|
|
26
|
+
}, [firstRootId]);
|
|
48
27
|
};
|
|
49
|
-
|
|
28
|
+
export { useWidgetLibraryInsertionPoint as default };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=use-widget-library-insertion-point.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/use-widget-library-insertion-point.js"],
|
|
4
|
-
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editWidgetsStore } from '../store';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../store/utils';\n\nconst useWidgetLibraryInsertionPoint = () => {\n\tconst firstRootId = useSelect( ( select ) => {\n\t\t// Default to the first widget area\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst widgetAreasPost = getEntityRecord(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tbuildWidgetAreasPostId()\n\t\t);\n\t\treturn widgetAreasPost?.blocks[ 0 ]?.clientId;\n\t}, [] );\n\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockIndex,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst insertionPoint =\n\t\t\t\tselect( editWidgetsStore ).__experimentalGetInsertionPoint();\n\n\t\t\t// \"Browse all\" in the quick inserter will set the rootClientId to the current block.\n\t\t\t// Otherwise, it will just be undefined, and we'll have to handle it differently below.\n\t\t\tif ( insertionPoint.rootClientId ) {\n\t\t\t\treturn insertionPoint;\n\t\t\t}\n\n\t\t\tconst clientId = getBlockSelectionEnd() || firstRootId;\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t// If the selected block is at the root level, it's a widget area and\n\t\t\t// blocks can't be inserted here. Return this block as the root and the\n\t\t\t// last child clientId indicating insertion at the end.\n\t\t\tif ( clientId && rootClientId === '' ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: clientId,\n\t\t\t\t\tinsertionIndex: getBlockOrder( clientId ).length,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trootClientId,\n\t\t\t\tinsertionIndex: getBlockIndex( clientId ) + 1,\n\t\t\t};\n\t\t},\n\t\t[ firstRootId ]\n\t);\n};\n\nexport default useWidgetLibraryInsertionPoint;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB,MAAM,iBAAiB;AAExD,IAAM,iCAAiC,MAAM;AAC5C,QAAM,cAAc,UAAW,CAAE,WAAY;AAE5C,UAAM,EAAE,gBAAgB,IAAI,OAAQ,SAAU;AAC9C,UAAM,kBAAkB;AAAA,MACvB;AAAA,MACA;AAAA,MACA,uBAAuB;AAAA,IACxB;AACA,WAAO,iBAAiB,OAAQ,CAAE,GAAG;AAAA,EACtC,GAAG,CAAC,CAAE;AAEN,SAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,gBAAiB;AAE7B,YAAM,iBACL,OAAQ,gBAAiB,EAAE,gCAAgC;AAI5D,UAAK,eAAe,cAAe;AAClC,eAAO;AAAA,MACR;AAEA,YAAM,WAAW,qBAAqB,KAAK;AAC3C,YAAM,eAAe,qBAAsB,QAAS;AAKpD,UAAK,YAAY,iBAAiB,IAAK;AACtC,eAAO;AAAA,UACN,cAAc;AAAA,UACd,gBAAgB,cAAe,QAAS,EAAE;AAAA,QAC3C;AAAA,MACD;AAEA,aAAO;AAAA,QACN;AAAA,QACA,gBAAgB,cAAe,QAAS,IAAI;AAAA,MAC7C;AAAA,IACD;AAAA,IACA,CAAE,WAAY;AAAA,EACf;AACD;AAEA,IAAO,6CAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"use-widget-library-insertion-point.mjs","names":["coreStore","blockEditorStore","editWidgetsStore"],"sources":["../../src/hooks/use-widget-library-insertion-point.js"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editWidgetsStore } from '../store';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../store/utils';\n\nconst useWidgetLibraryInsertionPoint = () => {\n\tconst firstRootId = useSelect( ( select ) => {\n\t\t// Default to the first widget area\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst widgetAreasPost = getEntityRecord(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tbuildWidgetAreasPostId()\n\t\t);\n\t\treturn widgetAreasPost?.blocks[ 0 ]?.clientId;\n\t}, [] );\n\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockIndex,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst insertionPoint =\n\t\t\t\tselect( editWidgetsStore ).__experimentalGetInsertionPoint();\n\n\t\t\t// \"Browse all\" in the quick inserter will set the rootClientId to the current block.\n\t\t\t// Otherwise, it will just be undefined, and we'll have to handle it differently below.\n\t\t\tif ( insertionPoint.rootClientId ) {\n\t\t\t\treturn insertionPoint;\n\t\t\t}\n\n\t\t\tconst clientId = getBlockSelectionEnd() || firstRootId;\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t// If the selected block is at the root level, it's a widget area and\n\t\t\t// blocks can't be inserted here. Return this block as the root and the\n\t\t\t// last child clientId indicating insertion at the end.\n\t\t\tif ( clientId && rootClientId === '' ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: clientId,\n\t\t\t\t\tinsertionIndex: getBlockOrder( clientId ).length,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trootClientId,\n\t\t\t\tinsertionIndex: getBlockIndex( clientId ) + 1,\n\t\t\t};\n\t\t},\n\t\t[ firstRootId ]\n\t);\n};\n\nexport default useWidgetLibraryInsertionPoint;\n"],"mappings":";;;;;;AAMA,MAAM,uCAAuC;CAC5C,MAAM,cAAc,WAAa,WAAY;EAE5C,MAAM,EAAE,oBAAoB,OAAQA,OAAU;EAM9C,OALwB,gBACvB,MACA,WACA,uBAAuB,CAEH,CAAC,EAAE,OAAQ,EAAG,EAAE;CACtC,GAAG,CAAC,CAAE;CAEN,OAAO,WACJ,WAAY;EACb,MAAM,EACL,sBACA,sBACA,eACA,kBACG,OAAQC,KAAiB;EAE7B,MAAM,iBACL,OAAQC,OAAiB,CAAC,CAAC,gCAAgC;EAI5D,IAAK,eAAe,cACnB,OAAO;EAGR,MAAM,WAAW,qBAAqB,KAAK;EAC3C,MAAM,eAAe,qBAAsB,QAAS;EAKpD,IAAK,YAAY,iBAAiB,IACjC,OAAO;GACN,cAAc;GACd,gBAAgB,cAAe,QAAS,CAAC,CAAC;EAC3C;EAGD,OAAO;GACN;GACA,gBAAgB,cAAe,QAAS,IAAI;EAC7C;CACD,GACA,CAAE,WAAY,CACf;AACD"}
|