@wordpress/edit-site 6.0.1 → 6.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.
Files changed (133) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-page/index.js +2 -1
  3. package/build/components/add-new-page/index.js.map +1 -1
  4. package/build/components/app/index.js +17 -1
  5. package/build/components/app/index.js.map +1 -1
  6. package/build/components/editor/index.js +3 -10
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/global-styles/font-library-modal/installed-fonts.js +1 -0
  9. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  10. package/build/components/global-styles/screen-revisions/index.js +4 -23
  11. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  12. package/build/components/global-styles/shadows-edit-panel.js +1 -0
  13. package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
  14. package/build/components/global-styles/variations/variation.js +11 -16
  15. package/build/components/global-styles/variations/variation.js.map +1 -1
  16. package/build/components/global-styles/variations/variations-color.js +1 -0
  17. package/build/components/global-styles/variations/variations-color.js.map +1 -1
  18. package/build/components/global-styles/variations/variations-typography.js +1 -0
  19. package/build/components/global-styles/variations/variations-typography.js.map +1 -1
  20. package/build/components/layout/index.js +8 -37
  21. package/build/components/layout/index.js.map +1 -1
  22. package/build/components/page/header.js +1 -0
  23. package/build/components/page/header.js.map +1 -1
  24. package/build/components/page-patterns/header.js +2 -1
  25. package/build/components/page-patterns/header.js.map +1 -1
  26. package/build/components/posts-app/index.js +50 -0
  27. package/build/components/posts-app/index.js.map +1 -0
  28. package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
  29. package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -1
  30. package/build/hooks/commands/use-set-command-context.js +53 -0
  31. package/build/hooks/commands/use-set-command-context.js.map +1 -0
  32. package/build/hooks/push-changes-to-global-styles/index.js +2 -2
  33. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  34. package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +20 -88
  35. package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
  36. package/build/index.js +15 -2
  37. package/build/index.js.map +1 -1
  38. package/build/posts.js +34 -0
  39. package/build/posts.js.map +1 -0
  40. package/build-module/components/add-new-page/index.js +2 -1
  41. package/build-module/components/add-new-page/index.js.map +1 -1
  42. package/build-module/components/app/index.js +17 -1
  43. package/build-module/components/app/index.js.map +1 -1
  44. package/build-module/components/editor/index.js +3 -10
  45. package/build-module/components/editor/index.js.map +1 -1
  46. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +1 -0
  47. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  48. package/build-module/components/global-styles/screen-revisions/index.js +4 -23
  49. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  50. package/build-module/components/global-styles/shadows-edit-panel.js +1 -0
  51. package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
  52. package/build-module/components/global-styles/variations/variation.js +11 -16
  53. package/build-module/components/global-styles/variations/variation.js.map +1 -1
  54. package/build-module/components/global-styles/variations/variations-color.js +1 -0
  55. package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
  56. package/build-module/components/global-styles/variations/variations-typography.js +1 -0
  57. package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
  58. package/build-module/components/layout/index.js +10 -39
  59. package/build-module/components/layout/index.js.map +1 -1
  60. package/build-module/components/page/header.js +1 -0
  61. package/build-module/components/page/header.js.map +1 -1
  62. package/build-module/components/page-patterns/header.js +2 -1
  63. package/build-module/components/page-patterns/header.js.map +1 -1
  64. package/build-module/components/posts-app/index.js +43 -0
  65. package/build-module/components/posts-app/index.js.map +1 -0
  66. package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
  67. package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -1
  68. package/build-module/hooks/commands/use-set-command-context.js +46 -0
  69. package/build-module/hooks/commands/use-set-command-context.js.map +1 -0
  70. package/build-module/hooks/push-changes-to-global-styles/index.js +2 -2
  71. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  72. package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +19 -86
  73. package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
  74. package/build-module/index.js +8 -2
  75. package/build-module/index.js.map +1 -1
  76. package/build-module/posts.js +27 -0
  77. package/build-module/posts.js.map +1 -0
  78. package/build-style/posts-rtl.css +1707 -0
  79. package/build-style/posts.css +1707 -0
  80. package/build-style/style-rtl.css +16 -19
  81. package/build-style/style.css +16 -19
  82. package/package.json +41 -41
  83. package/src/components/add-new-page/index.js +2 -1
  84. package/src/components/app/index.js +17 -1
  85. package/src/components/editor/index.js +2 -8
  86. package/src/components/global-styles/font-library-modal/installed-fonts.js +1 -0
  87. package/src/components/global-styles/screen-revisions/index.js +4 -24
  88. package/src/components/global-styles/shadows-edit-panel.js +1 -0
  89. package/src/components/global-styles/style.scss +1 -7
  90. package/src/components/global-styles/variations/variation.js +14 -19
  91. package/src/components/global-styles/variations/variations-color.js +6 -1
  92. package/src/components/global-styles/variations/variations-typography.js +5 -1
  93. package/src/components/global-styles-sidebar/style.scss +0 -1
  94. package/src/components/layout/index.js +24 -70
  95. package/src/components/page/header.js +1 -0
  96. package/src/components/page/style.scss +6 -0
  97. package/src/components/page-patterns/header.js +8 -2
  98. package/src/components/page-patterns/style.scss +6 -0
  99. package/src/components/posts-app/index.js +39 -0
  100. package/src/components/sidebar/style.scss +4 -4
  101. package/src/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
  102. package/src/hooks/commands/use-set-command-context.js +37 -0
  103. package/src/hooks/push-changes-to-global-styles/index.js +2 -2
  104. package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +1 -875
  105. package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +29 -117
  106. package/src/index.js +10 -2
  107. package/src/posts.js +29 -0
  108. package/src/posts.scss +46 -0
  109. package/build/components/block-editor/block-inspector-button.js +0 -57
  110. package/build/components/block-editor/block-inspector-button.js.map +0 -1
  111. package/build/components/block-editor/inserter-media-categories.js +0 -183
  112. package/build/components/block-editor/inserter-media-categories.js.map +0 -1
  113. package/build/components/template-part-converter/convert-to-regular.js +0 -38
  114. package/build/components/template-part-converter/convert-to-regular.js.map +0 -1
  115. package/build/components/template-part-converter/convert-to-template-part.js +0 -84
  116. package/build/components/template-part-converter/convert-to-template-part.js.map +0 -1
  117. package/build/components/template-part-converter/index.js +0 -67
  118. package/build/components/template-part-converter/index.js.map +0 -1
  119. package/build-module/components/block-editor/block-inspector-button.js +0 -50
  120. package/build-module/components/block-editor/block-inspector-button.js.map +0 -1
  121. package/build-module/components/block-editor/inserter-media-categories.js +0 -177
  122. package/build-module/components/block-editor/inserter-media-categories.js.map +0 -1
  123. package/build-module/components/template-part-converter/convert-to-regular.js +0 -31
  124. package/build-module/components/template-part-converter/convert-to-regular.js.map +0 -1
  125. package/build-module/components/template-part-converter/convert-to-template-part.js +0 -79
  126. package/build-module/components/template-part-converter/convert-to-template-part.js.map +0 -1
  127. package/build-module/components/template-part-converter/index.js +0 -59
  128. package/build-module/components/template-part-converter/index.js.map +0 -1
  129. package/src/components/block-editor/block-inspector-button.js +0 -60
  130. package/src/components/block-editor/inserter-media-categories.js +0 -225
  131. package/src/components/template-part-converter/convert-to-regular.js +0 -32
  132. package/src/components/template-part-converter/convert-to-template-part.js +0 -78
  133. package/src/components/template-part-converter/index.js +0 -59
@@ -48,17 +48,15 @@ export function removePropertyFromObject( object, property ) {
48
48
  }
49
49
 
50
50
  /**
51
- * A convenience wrapper for `useThemeStyleVariationsByProperty()` that fetches the current theme style variations,
52
- * and user-defined global style/settings object.
51
+ * Fetches the current theme style variations that contain only the specified property
52
+ * and merges them with the user config.
53
53
  *
54
- * @param {Object} props Object of hook args.
55
- * @param {string} props.property The property to filter by.
56
- * @param {Function} props.filter Optional. The filter function to apply to the variations.
54
+ * @param {Object} props Object of hook args.
55
+ * @param {string} props.property The property to filter by.
57
56
  * @return {Object[]|*} The merged object.
58
57
  */
59
58
  export function useCurrentMergeThemeStyleVariationsWithUserConfig( {
60
59
  property,
61
- filter,
62
60
  } ) {
63
61
  const { variationsFromTheme } = useSelect( ( select ) => {
64
62
  const _variationsFromTheme =
@@ -70,28 +68,34 @@ export function useCurrentMergeThemeStyleVariationsWithUserConfig( {
70
68
  variationsFromTheme: _variationsFromTheme || [],
71
69
  };
72
70
  }, [] );
73
- const { user: baseVariation } = useContext( GlobalStylesContext );
71
+ const { user: userVariation } = useContext( GlobalStylesContext );
74
72
 
75
- const variations = useMemo( () => {
76
- return [
77
- {
78
- title: __( 'Default' ),
79
- settings: {},
80
- styles: {},
81
- },
82
- ...variationsFromTheme,
83
- ];
84
- }, [ variationsFromTheme ] );
73
+ return useMemo( () => {
74
+ const clonedUserVariation = cloneDeep( userVariation );
85
75
 
86
- return useThemeStyleVariationsByProperty( {
87
- variations,
88
- property,
89
- filter,
90
- baseVariation: removePropertyFromObject(
91
- cloneDeep( baseVariation ),
76
+ // Get user variation and remove the settings for the given property.
77
+ const userVariationWithoutProperty = removePropertyFromObject(
78
+ clonedUserVariation,
92
79
  property
93
- ),
94
- } );
80
+ );
81
+ userVariationWithoutProperty.title = __( 'Default' );
82
+
83
+ const variationsWithSinglePropertyAndBase = variationsFromTheme
84
+ .filter( ( variation ) => {
85
+ return isVariationWithSingleProperty( variation, property );
86
+ } )
87
+ .map( ( variation ) => {
88
+ return mergeBaseAndUserConfigs(
89
+ userVariationWithoutProperty,
90
+ variation
91
+ );
92
+ } );
93
+
94
+ return [
95
+ userVariationWithoutProperty,
96
+ ...variationsWithSinglePropertyAndBase,
97
+ ];
98
+ }, [ property, userVariation, variationsFromTheme ] );
95
99
  }
96
100
 
97
101
  /**
@@ -123,98 +127,6 @@ export const filterObjectByProperty = ( object, property ) => {
123
127
  return newObject;
124
128
  };
125
129
 
126
- /**
127
- * Returns a new object with only the properties specified in `property`.
128
- * Optional merges the baseVariation object with the variation object.
129
- * Note: this function will only overwrite the specified property in baseVariation if it exists.
130
- * The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.
131
- * See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.
132
- *
133
- * @param {Object} props Object of hook args.
134
- * @param {Object[]} props.variations The theme style variations to filter.
135
- * @param {string} props.property The property to filter by.
136
- * @param {Function} props.filter Optional. The filter function to apply to the variations.
137
- * @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.
138
- * @return {Object[]|*} The merged object.
139
- */
140
- export default function useThemeStyleVariationsByProperty( {
141
- variations,
142
- property,
143
- filter,
144
- baseVariation,
145
- } ) {
146
- return useMemo( () => {
147
- if ( ! property || ! variations || variations?.length === 0 ) {
148
- return variations;
149
- }
150
-
151
- const clonedBaseVariation =
152
- typeof baseVariation === 'object' &&
153
- Object.keys( baseVariation ).length > 0
154
- ? cloneDeep( baseVariation )
155
- : null;
156
-
157
- let processedStyleVariations = variations.reduce(
158
- ( accumulator, variation ) => {
159
- const variationFilteredByProperty = filterObjectByProperty(
160
- cloneDeep( variation ),
161
- property
162
- );
163
-
164
- // Remove variations that are empty once the property is filtered out.
165
- if (
166
- variation.title !== __( 'Default' ) &&
167
- Object.keys( variationFilteredByProperty ).length === 0
168
- ) {
169
- return accumulator;
170
- }
171
-
172
- let result = {
173
- ...variationFilteredByProperty,
174
- title: variation?.title,
175
- description: variation?.description,
176
- };
177
-
178
- if ( clonedBaseVariation ) {
179
- /*
180
- * Overwrites all baseVariation object `styleProperty` properties
181
- * with the theme variation `styleProperty` properties.
182
- */
183
- result = mergeBaseAndUserConfigs(
184
- clonedBaseVariation,
185
- result
186
- );
187
- }
188
-
189
- // Detect if this is a duplicate variation.
190
- const isDuplicate = accumulator.some( ( item ) => {
191
- return (
192
- JSON.stringify( item.styles ) ===
193
- JSON.stringify( result?.styles ) &&
194
- JSON.stringify( item.settings ) ===
195
- JSON.stringify( result?.settings )
196
- );
197
- } );
198
- if ( isDuplicate ) {
199
- return accumulator;
200
- }
201
-
202
- // If the variation is not a duplicate, add it to the accumulator.
203
- accumulator.push( result );
204
- return accumulator;
205
- },
206
- [] // Initial accumulator value.
207
- );
208
-
209
- if ( 'function' === typeof filter ) {
210
- processedStyleVariations =
211
- processedStyleVariations.filter( filter );
212
- }
213
-
214
- return processedStyleVariations;
215
- }, [ variations, property, baseVariation, filter ] );
216
- }
217
-
218
130
  /**
219
131
  * Compares a style variation to the same variation filtered by a single property.
220
132
  * Returns true if the variation contains only the property specified.
package/src/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  } from '@wordpress/block-library';
10
10
  import { dispatch } from '@wordpress/data';
11
11
  import deprecated from '@wordpress/deprecated';
12
- import { createRoot } from '@wordpress/element';
12
+ import { createRoot, StrictMode } from '@wordpress/element';
13
13
  import { store as editorStore } from '@wordpress/editor';
14
14
  import { store as preferencesStore } from '@wordpress/preferences';
15
15
  import {
@@ -85,7 +85,11 @@ export function initializeEditor( id, settings ) {
85
85
  window.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );
86
86
  window.addEventListener( 'drop', ( e ) => e.preventDefault(), false );
87
87
 
88
- root.render( <App /> );
88
+ root.render(
89
+ <StrictMode>
90
+ <App />
91
+ </StrictMode>
92
+ );
89
93
 
90
94
  return root;
91
95
  }
@@ -100,3 +104,7 @@ export function reinitializeEditor() {
100
104
  export { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';
101
105
  export { store } from './store';
102
106
  export * from './deprecated';
107
+
108
+ // Temporary: While the posts dashboard is being iterated on
109
+ // it's being built in the same package as the site editor.
110
+ export { initializePostsDashboard } from './posts';
package/src/posts.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createRoot, StrictMode } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import PostsApp from './components/posts-app';
10
+
11
+ /**
12
+ * Initializes the "Posts Dashboard"
13
+ * @param {string} id DOM element id.
14
+ */
15
+ export function initializePostsDashboard( id ) {
16
+ if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {
17
+ return;
18
+ }
19
+ const target = document.getElementById( id );
20
+ const root = createRoot( target );
21
+
22
+ root.render(
23
+ <StrictMode>
24
+ <PostsApp />
25
+ </StrictMode>
26
+ );
27
+
28
+ return root;
29
+ }
package/src/posts.scss ADDED
@@ -0,0 +1,46 @@
1
+ @import "../../dataviews/src/style.scss";
2
+ @import "./components/layout/style.scss";
3
+ @import "./components/page/style.scss";
4
+ @import "./components/save-hub/style.scss";
5
+ @import "./components/save-panel/style.scss";
6
+ @import "./components/sidebar/style.scss";
7
+ @import "./components/site-hub/style.scss";
8
+ @import "./components/site-icon/style.scss";
9
+ @import "./components/editor-canvas-container/style.scss";
10
+ @import "./components/resizable-frame/style.scss";
11
+
12
+ @include wordpress-admin-schemes();
13
+
14
+ #wpadminbar,
15
+ #adminmenumain {
16
+ display: none;
17
+ }
18
+ #wpcontent {
19
+ margin-left: 0;
20
+ }
21
+ body.js #wpbody {
22
+ padding-top: 0;
23
+ }
24
+ body {
25
+ @include wp-admin-reset("#gutenberg-posts-dashboard");
26
+ }
27
+ #gutenberg-posts-dashboard {
28
+ @include reset;
29
+ height: 100vh;
30
+
31
+ // On mobile the main content area has to scroll, otherwise you can invoke
32
+ // the over-scroll bounce on the non-scrolling container, for a bad experience.
33
+ @include break-small {
34
+ bottom: 0;
35
+ left: 0;
36
+ min-height: 100vh;
37
+ position: fixed;
38
+ right: 0;
39
+ top: 0;
40
+ }
41
+
42
+ .no-js & {
43
+ min-height: 0;
44
+ position: static;
45
+ }
46
+ }
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = BlockInspectorButton;
7
- var _i18n = require("@wordpress/i18n");
8
- var _a11y = require("@wordpress/a11y");
9
- var _components = require("@wordpress/components");
10
- var _data = require("@wordpress/data");
11
- var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
12
- var _editor = require("@wordpress/editor");
13
- var _lockUnlock = require("../../lock-unlock");
14
- var _jsxRuntime = require("react/jsx-runtime");
15
- /**
16
- * WordPress dependencies
17
- */
18
-
19
- /**
20
- * Internal dependencies
21
- */
22
-
23
- const {
24
- interfaceStore
25
- } = (0, _lockUnlock.unlock)(_editor.privateApis);
26
- function BlockInspectorButton({
27
- onClick = () => {}
28
- }) {
29
- const {
30
- shortcut,
31
- isBlockInspectorOpen
32
- } = (0, _data.useSelect)(select => ({
33
- shortcut: select(_keyboardShortcuts.store).getShortcutRepresentation('core/editor/toggle-sidebar'),
34
- isBlockInspectorOpen: select(interfaceStore).getActiveComplementaryArea('core') === 'edit-post/block'
35
- }), []);
36
- const {
37
- enableComplementaryArea,
38
- disableComplementaryArea
39
- } = (0, _data.useDispatch)(interfaceStore);
40
- const label = isBlockInspectorOpen ? (0, _i18n.__)('Hide more settings') : (0, _i18n.__)('Show more settings');
41
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
42
- onClick: () => {
43
- if (isBlockInspectorOpen) {
44
- disableComplementaryArea('core');
45
- (0, _a11y.speak)((0, _i18n.__)('Block settings closed'));
46
- } else {
47
- enableComplementaryArea('core', 'edit-post/block');
48
- (0, _a11y.speak)((0, _i18n.__)('Additional settings are now available in the Editor block settings sidebar'));
49
- }
50
- // Close dropdown menu.
51
- onClick();
52
- },
53
- shortcut: shortcut,
54
- children: label
55
- });
56
- }
57
- //# sourceMappingURL=block-inspector-button.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_i18n","require","_a11y","_components","_data","_keyboardShortcuts","_editor","_lockUnlock","_jsxRuntime","interfaceStore","unlock","editorPrivateApis","BlockInspectorButton","onClick","shortcut","isBlockInspectorOpen","useSelect","select","keyboardShortcutsStore","getShortcutRepresentation","getActiveComplementaryArea","enableComplementaryArea","disableComplementaryArea","useDispatch","label","__","jsx","MenuItem","speak","children"],"sources":["@wordpress/edit-site/src/components/block-editor/block-inspector-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { interfaceStore } = unlock( editorPrivateApis );\n\nexport default function BlockInspectorButton( { onClick = () => {} } ) {\n\tconst { shortcut, isBlockInspectorOpen } = useSelect(\n\t\t( select ) => ( {\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/editor/toggle-sidebar' ),\n\t\t\tisBlockInspectorOpen:\n\t\t\t\tselect( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\t\t'core'\n\t\t\t\t) === 'edit-post/block',\n\t\t} ),\n\t\t[]\n\t);\n\tconst { enableComplementaryArea, disableComplementaryArea } =\n\t\tuseDispatch( interfaceStore );\n\n\tconst label = isBlockInspectorOpen\n\t\t? __( 'Hide more settings' )\n\t\t: __( 'Show more settings' );\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\tif ( isBlockInspectorOpen ) {\n\t\t\t\t\tdisableComplementaryArea( 'core' );\n\t\t\t\t\tspeak( __( 'Block settings closed' ) );\n\t\t\t\t} else {\n\t\t\t\t\tenableComplementaryArea( 'core', 'edit-post/block' );\n\t\t\t\t\tspeak(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Additional settings are now available in the Editor block settings sidebar'\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Close dropdown menu.\n\t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,WAAK,EAAE,IAAAH,QAAE,EAAE,uBAAwB,CAAE,CAAC;MACvC,CAAC,MAAM;QACNJ,uBAAuB,CAAE,MAAM,EAAE,iBAAkB,CAAC;QACpD,IAAAO,WAAK,EACJ,IAAAH,QAAE,EACD,4EACD,CACD,CAAC;MACF;MACA;MACAZ,OAAO,CAAC,CAAC;IACV,CAAG;IACHC,QAAQ,EAAGA,QAAU;IAAAe,QAAA,EAEnBL;EAAK,CACE,CAAC;AAEb","ignoreList":[]}
@@ -1,183 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _i18n = require("@wordpress/i18n");
8
- var _data = require("@wordpress/data");
9
- var _htmlEntities = require("@wordpress/html-entities");
10
- var _coreData = require("@wordpress/core-data");
11
- /**
12
- * The `edit-site` settings here need to be in sync with the corresponding ones in `site-editor` package.
13
- * See `packages/edit-site/src/components/block-editor/inserter-media-categories.js`.
14
- *
15
- * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.
16
- * The rest of the settings would still need to be in sync though.
17
- */
18
-
19
- /**
20
- * WordPress dependencies
21
- */
22
-
23
- /**
24
- * Internal dependencies
25
- */
26
-
27
- /** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */
28
- /** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */
29
- /** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */
30
-
31
- const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
32
- const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`;
33
- const getOpenverseLicense = (license, licenseVersion) => {
34
- let licenseName = license.trim();
35
- // PDM has no abbreviation
36
- if (license !== 'pdm') {
37
- licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling');
38
- }
39
- // If version is known, append version to the name.
40
- // The license has to have a version to be valid. Only
41
- // PDM (public domain mark) doesn't have a version.
42
- if (licenseVersion) {
43
- licenseName += ` ${licenseVersion}`;
44
- }
45
- // For licenses other than public-domain marks, prepend 'CC' to the name.
46
- if (!['pdm', 'cc0'].includes(license)) {
47
- licenseName = `CC ${licenseName}`;
48
- }
49
- return licenseName;
50
- };
51
- const getOpenverseCaption = item => {
52
- const {
53
- title,
54
- foreign_landing_url: foreignLandingUrl,
55
- creator,
56
- creator_url: creatorUrl,
57
- license,
58
- license_version: licenseVersion,
59
- license_url: licenseUrl
60
- } = item;
61
- const fullLicense = getOpenverseLicense(license, licenseVersion);
62
- const _creator = (0, _htmlEntities.decodeEntities)(creator);
63
- let _caption;
64
- if (_creator) {
65
- _caption = title ? (0, _i18n.sprintf)(
66
- // translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0".
67
- (0, _i18n._x)('"%1$s" by %2$s/ %3$s', 'caption'), getExternalLink(foreignLandingUrl, (0, _htmlEntities.decodeEntities)(title)), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : (0, _i18n.sprintf)(
68
- // translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0".
69
- (0, _i18n._x)('<a %1$s>Work</a> by %2$s/ %3$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
70
- } else {
71
- _caption = title ? (0, _i18n.sprintf)(
72
- // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
73
- (0, _i18n._x)('"%1$s"/ %2$s', 'caption'), getExternalLink(foreignLandingUrl, (0, _htmlEntities.decodeEntities)(title)), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : (0, _i18n.sprintf)(
74
- // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
75
- (0, _i18n._x)('<a %1$s>Work</a>/ %3$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
76
- }
77
- return _caption.replace(/\s{2}/g, ' ');
78
- };
79
- const coreMediaFetch = async (query = {}) => {
80
- const mediaItems = await (0, _data.resolveSelect)(_coreData.store).getMediaItems({
81
- ...query,
82
- orderBy: !!query?.search ? 'relevance' : 'date'
83
- });
84
- return mediaItems.map(mediaItem => ({
85
- ...mediaItem,
86
- alt: mediaItem.alt_text,
87
- url: mediaItem.source_url,
88
- previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
89
- caption: mediaItem.caption?.raw
90
- }));
91
- };
92
-
93
- /** @type {InserterMediaCategory[]} */
94
- const inserterMediaCategories = [{
95
- name: 'images',
96
- labels: {
97
- name: (0, _i18n.__)('Images'),
98
- search_items: (0, _i18n.__)('Search images')
99
- },
100
- mediaType: 'image',
101
- async fetch(query = {}) {
102
- return coreMediaFetch({
103
- ...query,
104
- media_type: 'image'
105
- });
106
- }
107
- }, {
108
- name: 'videos',
109
- labels: {
110
- name: (0, _i18n.__)('Videos'),
111
- search_items: (0, _i18n.__)('Search videos')
112
- },
113
- mediaType: 'video',
114
- async fetch(query = {}) {
115
- return coreMediaFetch({
116
- ...query,
117
- media_type: 'video'
118
- });
119
- }
120
- }, {
121
- name: 'audio',
122
- labels: {
123
- name: (0, _i18n.__)('Audio'),
124
- search_items: (0, _i18n.__)('Search audio')
125
- },
126
- mediaType: 'audio',
127
- async fetch(query = {}) {
128
- return coreMediaFetch({
129
- ...query,
130
- media_type: 'audio'
131
- });
132
- }
133
- }, {
134
- name: 'openverse',
135
- labels: {
136
- name: (0, _i18n.__)('Openverse'),
137
- search_items: (0, _i18n.__)('Search Openverse')
138
- },
139
- mediaType: 'image',
140
- async fetch(query = {}) {
141
- const defaultArgs = {
142
- mature: false,
143
- excluded_source: 'flickr,inaturalist,wikimedia',
144
- license: 'pdm,cc0'
145
- };
146
- const finalQuery = {
147
- ...query,
148
- ...defaultArgs
149
- };
150
- const mapFromInserterMediaRequest = {
151
- per_page: 'page_size',
152
- search: 'q'
153
- };
154
- const url = new URL('https://api.openverse.org/v1/images/');
155
- Object.entries(finalQuery).forEach(([key, value]) => {
156
- const queryKey = mapFromInserterMediaRequest[key] || key;
157
- url.searchParams.set(queryKey, value);
158
- });
159
- const response = await window.fetch(url, {
160
- headers: {
161
- 'User-Agent': 'WordPress/inserter-media-fetch'
162
- }
163
- });
164
- const jsonResponse = await response.json();
165
- const results = jsonResponse.results;
166
- return results.map(result => ({
167
- ...result,
168
- // This is a temp solution for better titles, until Openverse API
169
- // completes the cleaning up of some titles of their upstream data.
170
- title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
171
- sourceId: result.id,
172
- id: undefined,
173
- caption: getOpenverseCaption(result),
174
- previewUrl: result.thumbnail
175
- }));
176
- },
177
- getReportUrl: ({
178
- sourceId
179
- }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
180
- isExternalResource: true
181
- }];
182
- var _default = exports.default = inserterMediaCategories;
183
- //# sourceMappingURL=inserter-media-categories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_i18n","require","_data","_htmlEntities","_coreData","getExternalLink","url","text","getExternalLinkAttributes","getOpenverseLicense","license","licenseVersion","licenseName","trim","toUpperCase","replace","includes","getOpenverseCaption","item","title","foreign_landing_url","foreignLandingUrl","creator","creator_url","creatorUrl","license_version","license_url","licenseUrl","fullLicense","_creator","decodeEntities","_caption","sprintf","_x","coreMediaFetch","query","mediaItems","resolveSelect","coreStore","getMediaItems","orderBy","search","map","mediaItem","alt","alt_text","source_url","previewUrl","media_details","sizes","medium","caption","raw","inserterMediaCategories","name","labels","__","search_items","mediaType","fetch","media_type","defaultArgs","mature","excluded_source","finalQuery","mapFromInserterMediaRequest","per_page","URL","Object","entries","forEach","key","value","queryKey","searchParams","set","response","window","headers","jsonResponse","json","results","result","toLowerCase","startsWith","slice","sourceId","id","undefined","thumbnail","getReportUrl","isExternalResource","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/block-editor/inserter-media-categories.js"],"sourcesContent":["/**\n * The `edit-site` settings here need to be in sync with the corresponding ones in `site-editor` package.\n * See `packages/edit-site/src/components/block-editor/inserter-media-categories.js`.\n *\n * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.\n * The rest of the settings would still need to be in sync though.\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\n\n/** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */\n/** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */\n\nconst getExternalLink = ( url, text ) =>\n\t`<a ${ getExternalLinkAttributes( url ) }>${ text }</a>`;\n\nconst getExternalLinkAttributes = ( url ) =>\n\t`href=\"${ url }\" target=\"_blank\" rel=\"noreferrer noopener\"`;\n\nconst getOpenverseLicense = ( license, licenseVersion ) => {\n\tlet licenseName = license.trim();\n\t// PDM has no abbreviation\n\tif ( license !== 'pdm' ) {\n\t\tlicenseName = license.toUpperCase().replace( 'SAMPLING', 'Sampling' );\n\t}\n\t// If version is known, append version to the name.\n\t// The license has to have a version to be valid. Only\n\t// PDM (public domain mark) doesn't have a version.\n\tif ( licenseVersion ) {\n\t\tlicenseName += ` ${ licenseVersion }`;\n\t}\n\t// For licenses other than public-domain marks, prepend 'CC' to the name.\n\tif ( ! [ 'pdm', 'cc0' ].includes( license ) ) {\n\t\tlicenseName = `CC ${ licenseName }`;\n\t}\n\treturn licenseName;\n};\n\nconst getOpenverseCaption = ( item ) => {\n\tconst {\n\t\ttitle,\n\t\tforeign_landing_url: foreignLandingUrl,\n\t\tcreator,\n\t\tcreator_url: creatorUrl,\n\t\tlicense,\n\t\tlicense_version: licenseVersion,\n\t\tlicense_url: licenseUrl,\n\t} = item;\n\tconst fullLicense = getOpenverseLicense( license, licenseVersion );\n\tconst _creator = decodeEntities( creator );\n\tlet _caption;\n\tif ( _creator ) {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\" by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a> by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t} else {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\"/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a>/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t}\n\treturn _caption.replace( /\\s{2}/g, ' ' );\n};\n\nconst coreMediaFetch = async ( query = {} ) => {\n\tconst mediaItems = await resolveSelect( coreStore ).getMediaItems( {\n\t\t...query,\n\t\torderBy: !! query?.search ? 'relevance' : 'date',\n\t} );\n\treturn mediaItems.map( ( mediaItem ) => ( {\n\t\t...mediaItem,\n\t\talt: mediaItem.alt_text,\n\t\turl: mediaItem.source_url,\n\t\tpreviewUrl: mediaItem.media_details?.sizes?.medium?.source_url,\n\t\tcaption: mediaItem.caption?.raw,\n\t} ) );\n};\n\n/** @type {InserterMediaCategory[]} */\nconst inserterMediaCategories = [\n\t{\n\t\tname: 'images',\n\t\tlabels: {\n\t\t\tname: __( 'Images' ),\n\t\t\tsearch_items: __( 'Search images' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'image' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'videos',\n\t\tlabels: {\n\t\t\tname: __( 'Videos' ),\n\t\t\tsearch_items: __( 'Search videos' ),\n\t\t},\n\t\tmediaType: 'video',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'video' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'audio',\n\t\tlabels: {\n\t\t\tname: __( 'Audio' ),\n\t\t\tsearch_items: __( 'Search audio' ),\n\t\t},\n\t\tmediaType: 'audio',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'audio' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'openverse',\n\t\tlabels: {\n\t\t\tname: __( 'Openverse' ),\n\t\t\tsearch_items: __( 'Search Openverse' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\tconst defaultArgs = {\n\t\t\t\tmature: false,\n\t\t\t\texcluded_source: 'flickr,inaturalist,wikimedia',\n\t\t\t\tlicense: 'pdm,cc0',\n\t\t\t};\n\t\t\tconst finalQuery = { ...query, ...defaultArgs };\n\t\t\tconst mapFromInserterMediaRequest = {\n\t\t\t\tper_page: 'page_size',\n\t\t\t\tsearch: 'q',\n\t\t\t};\n\t\t\tconst url = new URL( 'https://api.openverse.org/v1/images/' );\n\t\t\tObject.entries( finalQuery ).forEach( ( [ key, value ] ) => {\n\t\t\t\tconst queryKey = mapFromInserterMediaRequest[ key ] || key;\n\t\t\t\turl.searchParams.set( queryKey, value );\n\t\t\t} );\n\t\t\tconst response = await window.fetch( url, {\n\t\t\t\theaders: {\n\t\t\t\t\t'User-Agent': 'WordPress/inserter-media-fetch',\n\t\t\t\t},\n\t\t\t} );\n\t\t\tconst jsonResponse = await response.json();\n\t\t\tconst results = jsonResponse.results;\n\t\t\treturn results.map( ( result ) => ( {\n\t\t\t\t...result,\n\t\t\t\t// This is a temp solution for better titles, until Openverse API\n\t\t\t\t// completes the cleaning up of some titles of their upstream data.\n\t\t\t\ttitle: result.title?.toLowerCase().startsWith( 'file:' )\n\t\t\t\t\t? result.title.slice( 5 )\n\t\t\t\t\t: result.title,\n\t\t\t\tsourceId: result.id,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: getOpenverseCaption( result ),\n\t\t\t\tpreviewUrl: result.thumbnail,\n\t\t\t} ) );\n\t\t},\n\t\tgetReportUrl: ( { sourceId } ) =>\n\t\t\t`https://wordpress.org/openverse/image/${ sourceId }/report/`,\n\t\tisExternalResource: true,\n\t},\n];\n\nexport default inserterMediaCategories;\n"],"mappings":";;;;;;AAWA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,SAAA,GAAAH,OAAA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,MAAMI,eAAe,GAAGA,CAAEC,GAAG,EAAEC,IAAI,KACjC,MAAMC,yBAAyB,CAAEF,GAAI,CAAG,IAAIC,IAAM,MAAK;AAEzD,MAAMC,yBAAyB,GAAKF,GAAG,IACrC,SAASA,GAAK,6CAA4C;AAE5D,MAAMG,mBAAmB,GAAGA,CAAEC,OAAO,EAAEC,cAAc,KAAM;EAC1D,IAAIC,WAAW,GAAGF,OAAO,CAACG,IAAI,CAAC,CAAC;EAChC;EACA,IAAKH,OAAO,KAAK,KAAK,EAAG;IACxBE,WAAW,GAAGF,OAAO,CAACI,WAAW,CAAC,CAAC,CAACC,OAAO,CAAE,UAAU,EAAE,UAAW,CAAC;EACtE;EACA;EACA;EACA;EACA,IAAKJ,cAAc,EAAG;IACrBC,WAAW,IAAK,IAAID,cAAgB,EAAC;EACtC;EACA;EACA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AAC,KAC1B,yCAAyCA,QAAU,UAAS;EAC9DK,kBAAkB,EAAE;AACrB,CAAC,CACD;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEazC,uBAAuB","ignoreList":[]}
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = ConvertToRegularBlocks;
7
- var _data = require("@wordpress/data");
8
- var _blockEditor = require("@wordpress/block-editor");
9
- var _components = require("@wordpress/components");
10
- var _i18n = require("@wordpress/i18n");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- /**
13
- * WordPress dependencies
14
- */
15
-
16
- function ConvertToRegularBlocks({
17
- clientId,
18
- onClose
19
- }) {
20
- const {
21
- getBlocks
22
- } = (0, _data.useSelect)(_blockEditor.store);
23
- const {
24
- replaceBlocks
25
- } = (0, _data.useDispatch)(_blockEditor.store);
26
- const canRemove = (0, _data.useSelect)(select => select(_blockEditor.store).canRemoveBlock(clientId), [clientId]);
27
- if (!canRemove) {
28
- return null;
29
- }
30
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
31
- onClick: () => {
32
- replaceBlocks(clientId, getBlocks(clientId));
33
- onClose();
34
- },
35
- children: (0, _i18n.__)('Detach')
36
- });
37
- }
38
- //# sourceMappingURL=convert-to-regular.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_data","require","_blockEditor","_components","_i18n","_jsxRuntime","ConvertToRegularBlocks","clientId","onClose","getBlocks","useSelect","blockEditorStore","replaceBlocks","useDispatch","canRemove","select","canRemoveBlock","jsx","MenuItem","onClick","children","__"],"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-regular.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function ConvertToRegularBlocks( { clientId, onClose } ) {\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\n\tconst canRemove = useSelect(\n\t\t( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\n\tif ( ! canRemove ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\treplaceBlocks( clientId, getBlocks( clientId ) );\n\t\t\t\tonClose();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Detach' ) }\n\t\t</MenuItem>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAqC,IAAAI,WAAA,GAAAJ,OAAA;AANrC;AACA;AACA;;AAMe,SAASK,sBAAsBA,CAAE;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,EAAG;EACvE,MAAM;IAAEC;EAAU,CAAC,GAAG,IAAAC,eAAS,EAAEC,kBAAiB,CAAC;EACnD,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAC,iBAAW,EAAEF,kBAAiB,CAAC;EAEzD,MAAMG,SAAS,GAAG,IAAAJ,eAAS,EACxBK,MAAM,IAAMA,MAAM,CAAEJ,kBAAiB,CAAC,CAACK,cAAc,CAAET,QAAS,CAAC,EACnE,CAAEA,QAAQ,CACX,CAAC;EAED,IAAK,CAAEO,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAT,WAAA,CAAAY,GAAA,EAACd,WAAA,CAAAe,QAAQ;IACRC,OAAO,EAAGA,CAAA,KAAM;MACfP,aAAa,CAAEL,QAAQ,EAAEE,SAAS,CAAEF,QAAS,CAAE,CAAC;MAChDC,OAAO,CAAC,CAAC;IACV,CAAG;IAAAY,QAAA,EAED,IAAAC,QAAE,EAAE,QAAS;EAAC,CACP,CAAC;AAEb","ignoreList":[]}