@wordpress/edit-widgets 7.0.0 → 7.2.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.
Files changed (199) hide show
  1. package/build/blocks/widget-area/edit/index.cjs +106 -116
  2. package/build/blocks/widget-area/edit/index.cjs.map +1 -7
  3. package/build/blocks/widget-area/edit/inner-blocks.cjs +44 -62
  4. package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -7
  5. package/build/blocks/widget-area/edit/use-is-dragging-within.cjs +41 -53
  6. package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -7
  7. package/build/blocks/widget-area/index.cjs +40 -44
  8. package/build/blocks/widget-area/index.cjs.map +1 -7
  9. package/build/components/error-boundary/index.cjs +115 -155
  10. package/build/components/error-boundary/index.cjs.map +1 -7
  11. package/build/components/header/document-tools/index.cjs +80 -115
  12. package/build/components/header/document-tools/index.cjs.map +1 -7
  13. package/build/components/header/index.cjs +77 -80
  14. package/build/components/header/index.cjs.map +1 -7
  15. package/build/components/header/undo-redo/redo.cjs +30 -52
  16. package/build/components/header/undo-redo/redo.cjs.map +1 -7
  17. package/build/components/header/undo-redo/undo.cjs +29 -51
  18. package/build/components/header/undo-redo/undo.cjs.map +1 -7
  19. package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
  20. package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
  21. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
  22. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
  23. package/build/components/keyboard-shortcut-help-modal/index.cjs +94 -161
  24. package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
  25. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +38 -75
  26. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
  27. package/build/components/keyboard-shortcuts/index.cjs +107 -140
  28. package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
  29. package/build/components/layout/index.cjs +65 -74
  30. package/build/components/layout/index.cjs.map +1 -7
  31. package/build/components/layout/interface.cjs +82 -108
  32. package/build/components/layout/interface.cjs.map +1 -7
  33. package/build/components/layout/unsaved-changes-warning.cjs +41 -48
  34. package/build/components/layout/unsaved-changes-warning.cjs.map +1 -7
  35. package/build/components/more-menu/index.cjs +124 -191
  36. package/build/components/more-menu/index.cjs.map +1 -7
  37. package/build/components/more-menu/tools-more-menu-group.cjs +9 -29
  38. package/build/components/more-menu/tools-more-menu-group.cjs.map +1 -7
  39. package/build/components/notices/index.cjs +19 -39
  40. package/build/components/notices/index.cjs.map +1 -7
  41. package/build/components/save-button/index.cjs +31 -58
  42. package/build/components/save-button/index.cjs.map +1 -7
  43. package/build/components/secondary-sidebar/index.cjs +38 -45
  44. package/build/components/secondary-sidebar/index.cjs.map +1 -7
  45. package/build/components/secondary-sidebar/inserter-sidebar.cjs +50 -51
  46. package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -7
  47. package/build/components/secondary-sidebar/list-view-sidebar.cjs +51 -82
  48. package/build/components/secondary-sidebar/list-view-sidebar.cjs.map +1 -7
  49. package/build/components/sidebar/index.cjs +117 -180
  50. package/build/components/sidebar/index.cjs.map +1 -7
  51. package/build/components/sidebar/widget-areas.cjs +43 -85
  52. package/build/components/sidebar/widget-areas.cjs.map +1 -7
  53. package/build/components/welcome-guide/index.cjs +110 -186
  54. package/build/components/welcome-guide/index.cjs.map +1 -7
  55. package/build/components/widget-areas-block-editor-content/index.cjs +59 -64
  56. package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -7
  57. package/build/components/widget-areas-block-editor-provider/index.cjs +105 -140
  58. package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -7
  59. package/build/constants.cjs +11 -32
  60. package/build/constants.cjs.map +1 -7
  61. package/build/filters/index.cjs +7 -4
  62. package/build/filters/move-to-widget-area.cjs +38 -53
  63. package/build/filters/move-to-widget-area.cjs.map +1 -7
  64. package/build/filters/replace-media-upload.cjs +11 -9
  65. package/build/filters/replace-media-upload.cjs.map +1 -7
  66. package/build/hooks/use-last-selected-widget-area.cjs +28 -49
  67. package/build/hooks/use-last-selected-widget-area.cjs.map +1 -7
  68. package/build/hooks/use-widget-library-insertion-point.cjs +33 -67
  69. package/build/hooks/use-widget-library-insertion-point.cjs.map +1 -7
  70. package/build/index.cjs +96 -97
  71. package/build/index.cjs.map +1 -7
  72. package/build/lock-unlock.cjs +10 -35
  73. package/build/lock-unlock.cjs.map +1 -7
  74. package/build/store/actions.cjs +276 -278
  75. package/build/store/actions.cjs.map +1 -7
  76. package/build/store/constants.cjs +12 -29
  77. package/build/store/constants.cjs.map +1 -7
  78. package/build/store/index.cjs +61 -52
  79. package/build/store/index.cjs.map +1 -7
  80. package/build/store/private-selectors.cjs +11 -32
  81. package/build/store/private-selectors.cjs.map +1 -7
  82. package/build/store/reducer.cjs +107 -88
  83. package/build/store/reducer.cjs.map +1 -7
  84. package/build/store/resolvers.cjs +60 -91
  85. package/build/store/resolvers.cjs.map +1 -7
  86. package/build/store/selectors.cjs +196 -229
  87. package/build/store/selectors.cjs.map +1 -7
  88. package/build/store/transformers.cjs +51 -82
  89. package/build/store/transformers.cjs.map +1 -7
  90. package/build/store/utils.cjs +76 -63
  91. package/build/store/utils.cjs.map +1 -7
  92. package/build-module/blocks/widget-area/edit/index.mjs +82 -94
  93. package/build-module/blocks/widget-area/edit/index.mjs.map +1 -7
  94. package/build-module/blocks/widget-area/edit/inner-blocks.mjs +19 -35
  95. package/build-module/blocks/widget-area/edit/inner-blocks.mjs.map +1 -7
  96. package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs +36 -33
  97. package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs.map +1 -7
  98. package/build-module/blocks/widget-area/index.mjs +12 -15
  99. package/build-module/blocks/widget-area/index.mjs.map +1 -7
  100. package/build-module/components/error-boundary/index.mjs +104 -129
  101. package/build-module/components/error-boundary/index.mjs.map +1 -7
  102. package/build-module/components/header/document-tools/index.mjs +51 -84
  103. package/build-module/components/header/document-tools/index.mjs.map +1 -7
  104. package/build-module/components/header/index.mjs +44 -47
  105. package/build-module/components/header/index.mjs.map +1 -7
  106. package/build-module/components/header/undo-redo/redo.mjs +20 -27
  107. package/build-module/components/header/undo-redo/redo.mjs.map +1 -7
  108. package/build-module/components/header/undo-redo/undo.mjs +19 -26
  109. package/build-module/components/header/undo-redo/undo.mjs.map +1 -7
  110. package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
  111. package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
  112. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
  113. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
  114. package/build-module/components/keyboard-shortcut-help-modal/index.mjs +67 -136
  115. package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
  116. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +32 -54
  117. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
  118. package/build-module/components/keyboard-shortcuts/index.mjs +99 -119
  119. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
  120. package/build-module/components/layout/index.mjs +29 -40
  121. package/build-module/components/layout/index.mjs.map +1 -7
  122. package/build-module/components/layout/interface.mjs +53 -82
  123. package/build-module/components/layout/interface.mjs.map +1 -7
  124. package/build-module/components/layout/unsaved-changes-warning.mjs +35 -27
  125. package/build-module/components/layout/unsaved-changes-warning.mjs.map +1 -7
  126. package/build-module/components/more-menu/index.mjs +94 -162
  127. package/build-module/components/more-menu/index.mjs.map +1 -7
  128. package/build-module/components/more-menu/tools-more-menu-group.mjs +5 -9
  129. package/build-module/components/more-menu/tools-more-menu-group.mjs.map +1 -7
  130. package/build-module/components/notices/index.mjs +12 -17
  131. package/build-module/components/notices/index.mjs.map +1 -7
  132. package/build-module/components/save-button/index.mjs +23 -35
  133. package/build-module/components/save-button/index.mjs.map +1 -7
  134. package/build-module/components/secondary-sidebar/index.mjs +15 -20
  135. package/build-module/components/secondary-sidebar/index.mjs.map +1 -7
  136. package/build-module/components/secondary-sidebar/inserter-sidebar.mjs +27 -25
  137. package/build-module/components/secondary-sidebar/inserter-sidebar.mjs.map +1 -7
  138. package/build-module/components/secondary-sidebar/list-view-sidebar.mjs +39 -55
  139. package/build-module/components/secondary-sidebar/list-view-sidebar.mjs.map +1 -7
  140. package/build-module/components/sidebar/index.mjs +96 -162
  141. package/build-module/components/sidebar/index.mjs.map +1 -7
  142. package/build-module/components/sidebar/widget-areas.mjs +30 -57
  143. package/build-module/components/sidebar/widget-areas.mjs.map +1 -7
  144. package/build-module/components/welcome-guide/index.mjs +103 -164
  145. package/build-module/components/welcome-guide/index.mjs.map +1 -7
  146. package/build-module/components/widget-areas-block-editor-content/index.mjs +34 -44
  147. package/build-module/components/widget-areas-block-editor-content/index.mjs.map +1 -7
  148. package/build-module/components/widget-areas-block-editor-provider/index.mjs +76 -109
  149. package/build-module/components/widget-areas-block-editor-provider/index.mjs.map +1 -7
  150. package/build-module/constants.mjs +5 -7
  151. package/build-module/constants.mjs.map +1 -7
  152. package/build-module/filters/index.mjs +0 -2
  153. package/build-module/filters/move-to-widget-area.mjs +28 -48
  154. package/build-module/filters/move-to-widget-area.mjs.map +1 -7
  155. package/build-module/filters/replace-media-upload.mjs +5 -8
  156. package/build-module/filters/replace-media-upload.mjs.map +1 -7
  157. package/build-module/hooks/use-last-selected-widget-area.mjs +23 -29
  158. package/build-module/hooks/use-last-selected-widget-area.mjs.map +1 -7
  159. package/build-module/hooks/use-widget-library-insertion-point.mjs +28 -47
  160. package/build-module/hooks/use-widget-library-insertion-point.mjs.map +1 -7
  161. package/build-module/index.mjs +62 -79
  162. package/build-module/index.mjs.map +1 -7
  163. package/build-module/lock-unlock.mjs +5 -10
  164. package/build-module/lock-unlock.mjs.map +1 -7
  165. package/build-module/store/actions.mjs +257 -247
  166. package/build-module/store/actions.mjs.map +1 -7
  167. package/build-module/store/constants.mjs +7 -5
  168. package/build-module/store/constants.mjs.map +1 -7
  169. package/build-module/store/index.mjs +18 -16
  170. package/build-module/store/index.mjs.map +1 -7
  171. package/build-module/store/private-selectors.mjs +5 -7
  172. package/build-module/store/private-selectors.mjs.map +1 -7
  173. package/build-module/store/reducer.mjs +95 -58
  174. package/build-module/store/reducer.mjs.map +1 -7
  175. package/build-module/store/resolvers.mjs +52 -71
  176. package/build-module/store/resolvers.mjs.map +1 -7
  177. package/build-module/store/selectors.mjs +178 -199
  178. package/build-module/store/selectors.mjs.map +1 -7
  179. package/build-module/store/transformers.mjs +44 -56
  180. package/build-module/store/transformers.mjs.map +1 -7
  181. package/build-module/store/utils.mjs +64 -32
  182. package/build-module/store/utils.mjs.map +1 -7
  183. package/build-style/style-rtl.css +32 -11
  184. package/build-style/style.css +32 -11
  185. package/package.json +33 -33
  186. package/src/components/error-boundary/index.jsx +2 -2
  187. package/src/components/header/index.jsx +13 -4
  188. package/src/components/header/style.scss +30 -3
  189. package/src/components/keyboard-shortcut-help-modal/shortcut.jsx +1 -0
  190. package/src/components/keyboard-shortcut-help-modal/style.scss +1 -1
  191. package/src/components/layout/style.scss +5 -9
  192. package/src/components/layout/unsaved-changes-warning.js +4 -9
  193. package/src/components/more-menu/index.jsx +0 -1
  194. package/src/components/sidebar/index.jsx +18 -18
  195. package/src/components/welcome-guide/index.jsx +4 -2
  196. package/src/store/actions.js +25 -2
  197. package/src/store/test/actions.jsdom.test.js +230 -0
  198. package/build/filters/index.cjs.map +0 -7
  199. 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 { useEntityBlockEditor, store as coreStore } from "@wordpress/core-data";
5
+ import { store, useEntityBlockEditor } from "@wordpress/core-data";
7
6
  import { useMemo } from "@wordpress/element";
8
- import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
9
- import { privateApis as editPatternsPrivateApis } from "@wordpress/patterns";
10
- import { store as preferencesStore } from "@wordpress/preferences";
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 { buildWidgetAreasPostId, KIND, POST_TYPE } from "../../store/utils.mjs";
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 editWidgetsStore } from "../../store/index.mjs";
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
- var { ExperimentalBlockEditorProvider } = unlock(blockEditorPrivateApis);
19
- var { PatternsMenuItems } = unlock(editPatternsPrivateApis);
20
- var EMPTY_ARRAY = [];
21
- function WidgetAreasBlockEditorProvider({
22
- blockEditorSettings,
23
- children,
24
- ...props
25
- }) {
26
- const isLargeViewport = useViewportMatch("medium");
27
- const {
28
- hasUploadPermissions,
29
- reusableBlocks,
30
- isFixedToolbarActive,
31
- keepCaretInsideBlock,
32
- pageOnFront,
33
- pageForPosts
34
- } = useSelect((select) => {
35
- const { canUser, getEntityRecord, getEntityRecords } = select(coreStore);
36
- const siteSettings = canUser("read", {
37
- kind: "root",
38
- name: "site"
39
- }) ? getEntityRecord("root", "site") : void 0;
40
- return {
41
- hasUploadPermissions: canUser("create", {
42
- kind: "postType",
43
- name: "attachment"
44
- }) ?? true,
45
- reusableBlocks: ALLOW_REUSABLE_BLOCKS ? getEntityRecords("postType", "wp_block") : EMPTY_ARRAY,
46
- isFixedToolbarActive: !!select(preferencesStore).get(
47
- "core/edit-widgets",
48
- "fixedToolbar"
49
- ),
50
- keepCaretInsideBlock: !!select(preferencesStore).get(
51
- "core/edit-widgets",
52
- "keepCaretInsideBlock"
53
- ),
54
- pageOnFront: siteSettings?.page_on_front,
55
- pageForPosts: siteSettings?.page_for_posts
56
- };
57
- }, []);
58
- const { setIsInserterOpened } = useDispatch(editWidgetsStore);
59
- const settings = useMemo(() => {
60
- let mediaUploadBlockEditor;
61
- if (hasUploadPermissions) {
62
- mediaUploadBlockEditor = ({ onError, ...argumentsObject }) => {
63
- uploadMedia({
64
- wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
65
- onError: ({ message }) => onError(message),
66
- ...argumentsObject
67
- });
68
- };
69
- }
70
- return {
71
- ...blockEditorSettings,
72
- __experimentalReusableBlocks: reusableBlocks,
73
- hasFixedToolbar: isFixedToolbarActive || !isLargeViewport,
74
- keepCaretInsideBlock,
75
- mediaUpload: mediaUploadBlockEditor,
76
- templateLock: "all",
77
- __experimentalSetIsInserterOpened: setIsInserterOpened,
78
- pageOnFront,
79
- pageForPosts
80
- };
81
- }, [
82
- hasUploadPermissions,
83
- blockEditorSettings,
84
- isFixedToolbarActive,
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
- WidgetAreasBlockEditorProvider as default
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
- var ALLOW_REUSABLE_BLOCKS = false;
3
- var ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
4
- export {
5
- ALLOW_REUSABLE_BLOCKS,
6
- ENABLE_EXPERIMENTAL_FSE_BLOCKS
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,4 +1,2 @@
1
- // packages/edit-widgets/src/filters/index.js
2
1
  import "./move-to-widget-area.mjs";
3
2
  import "./replace-media-upload.mjs";
4
- //# sourceMappingURL=index.mjs.map
@@ -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 as editWidgetsStore } from "../store/index.mjs";
6
+ import { store } from "../store/index.mjs";
8
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
- var withMoveToWidgetAreaToolbarItem = createHigherOrderComponent(
10
- (BlockEdit) => (props) => {
11
- const { clientId, name: blockName } = props;
12
- const { widgetAreas, currentWidgetAreaId, canInsertBlockInWidgetArea } = useSelect(
13
- (select) => {
14
- if (blockName === "core/widget-area") {
15
- return {};
16
- }
17
- const selectors = select(editWidgetsStore);
18
- const widgetAreaBlock = selectors.getParentWidgetAreaBlock(clientId);
19
- return {
20
- widgetAreas: selectors.getWidgetAreas(),
21
- currentWidgetAreaId: widgetAreaBlock?.attributes?.id,
22
- canInsertBlockInWidgetArea: selectors.canInsertBlockInWidgetArea(blockName)
23
- };
24
- },
25
- [clientId, blockName]
26
- );
27
- const { moveBlockToWidgetArea } = useDispatch(editWidgetsStore);
28
- const hasMultipleWidgetAreas = widgetAreas?.length > 1;
29
- const isMoveToWidgetAreaVisible = blockName !== "core/widget-area" && hasMultipleWidgetAreas && canInsertBlockInWidgetArea;
30
- return /* @__PURE__ */ jsxs(Fragment, { children: [
31
- /* @__PURE__ */ jsx(BlockEdit, { ...props }, "edit"),
32
- isMoveToWidgetAreaVisible && /* @__PURE__ */ jsx(BlockControls, { children: /* @__PURE__ */ jsx(
33
- MoveToWidgetArea,
34
- {
35
- widgetAreas,
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
- var replaceMediaUpload = () => MediaUpload;
5
- addFilter(
6
- "editor.MediaUpload",
7
- "core/edit-widgets/replace-media-upload",
8
- replaceMediaUpload
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 as blockEditorStore } from "@wordpress/block-editor";
4
- import { store as coreStore } from "@wordpress/core-data";
5
- import { store as widgetsEditorStore } from "../store/index.mjs";
6
- import { buildWidgetAreasPostId, KIND, POST_TYPE } from "../store/utils.mjs";
7
- var useLastSelectedWidgetArea = () => useSelect((select) => {
8
- const { getBlockSelectionEnd, getBlockName } = select(blockEditorStore);
9
- const selectionEndClientId = getBlockSelectionEnd();
10
- if (getBlockName(selectionEndClientId) === "core/widget-area") {
11
- return selectionEndClientId;
12
- }
13
- const { getParentWidgetAreaBlock } = select(widgetsEditorStore);
14
- const widgetAreaBlock = getParentWidgetAreaBlock(selectionEndClientId);
15
- const widgetAreaBlockClientId = widgetAreaBlock?.clientId;
16
- if (widgetAreaBlockClientId) {
17
- return widgetAreaBlockClientId;
18
- }
19
- const { getEntityRecord } = select(coreStore);
20
- const widgetAreasPost = getEntityRecord(
21
- KIND,
22
- POST_TYPE,
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
- var use_last_selected_widget_area_default = useLastSelectedWidgetArea;
28
- export {
29
- use_last_selected_widget_area_default as default
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 as blockEditorStore } from "@wordpress/block-editor";
4
- import { store as coreStore } from "@wordpress/core-data";
5
- import { store as editWidgetsStore } from "../store/index.mjs";
6
- import { buildWidgetAreasPostId, KIND, POST_TYPE } from "../store/utils.mjs";
7
- var useWidgetLibraryInsertionPoint = () => {
8
- const firstRootId = useSelect((select) => {
9
- const { getEntityRecord } = select(coreStore);
10
- const widgetAreasPost = getEntityRecord(
11
- KIND,
12
- POST_TYPE,
13
- buildWidgetAreasPostId()
14
- );
15
- return widgetAreasPost?.blocks[0]?.clientId;
16
- }, []);
17
- return useSelect(
18
- (select) => {
19
- const {
20
- getBlockRootClientId,
21
- getBlockSelectionEnd,
22
- getBlockOrder,
23
- getBlockIndex
24
- } = select(blockEditorStore);
25
- const insertionPoint = select(editWidgetsStore).__experimentalGetInsertionPoint();
26
- if (insertionPoint.rootClientId) {
27
- return insertionPoint;
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
- //# sourceMappingURL=use-widget-library-insertion-point.mjs.map
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"}