@wordpress/edit-site 6.0.4 → 6.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 (135) hide show
  1. package/CHANGELOG.md +10 -6
  2. package/build/components/add-new-page/index.js +2 -0
  3. package/build/components/add-new-page/index.js.map +1 -1
  4. package/build/components/add-new-pattern/index.js +1 -0
  5. package/build/components/add-new-pattern/index.js.map +1 -1
  6. package/build/components/app/index.js +17 -1
  7. package/build/components/app/index.js.map +1 -1
  8. package/build/components/editor/index.js +12 -13
  9. package/build/components/editor/index.js.map +1 -1
  10. package/build/components/editor-canvas-container/index.js +18 -7
  11. package/build/components/editor-canvas-container/index.js.map +1 -1
  12. package/build/components/global-styles/font-families.js +17 -17
  13. package/build/components/global-styles/font-families.js.map +1 -1
  14. package/build/components/global-styles/font-library-modal/context.js +2 -2
  15. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  16. package/build/components/global-styles/variations/variation.js +25 -19
  17. package/build/components/global-styles/variations/variation.js.map +1 -1
  18. package/build/components/global-styles/variations/variations-color.js +1 -0
  19. package/build/components/global-styles/variations/variations-color.js.map +1 -1
  20. package/build/components/global-styles/variations/variations-typography.js +1 -0
  21. package/build/components/global-styles/variations/variations-typography.js.map +1 -1
  22. package/build/components/layout/index.js +8 -37
  23. package/build/components/layout/index.js.map +1 -1
  24. package/build/components/page/header.js +1 -0
  25. package/build/components/page/header.js.map +1 -1
  26. package/build/components/page-patterns/header.js +2 -1
  27. package/build/components/page-patterns/header.js.map +1 -1
  28. package/build/components/page-patterns/rename-category-menu-item.js +3 -1
  29. package/build/components/page-patterns/rename-category-menu-item.js.map +1 -1
  30. package/build/components/posts-app/index.js +50 -0
  31. package/build/components/posts-app/index.js.map +1 -0
  32. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +2 -0
  33. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  34. package/build/hooks/commands/use-set-command-context.js +64 -0
  35. package/build/hooks/commands/use-set-command-context.js.map +1 -0
  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 -0
  41. package/build-module/components/add-new-page/index.js.map +1 -1
  42. package/build-module/components/add-new-pattern/index.js +1 -0
  43. package/build-module/components/add-new-pattern/index.js.map +1 -1
  44. package/build-module/components/app/index.js +17 -1
  45. package/build-module/components/app/index.js.map +1 -1
  46. package/build-module/components/editor/index.js +13 -14
  47. package/build-module/components/editor/index.js.map +1 -1
  48. package/build-module/components/editor-canvas-container/index.js +19 -8
  49. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  50. package/build-module/components/global-styles/font-families.js +18 -18
  51. package/build-module/components/global-styles/font-families.js.map +1 -1
  52. package/build-module/components/global-styles/font-library-modal/context.js +2 -2
  53. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  54. package/build-module/components/global-styles/variations/variation.js +25 -19
  55. package/build-module/components/global-styles/variations/variation.js.map +1 -1
  56. package/build-module/components/global-styles/variations/variations-color.js +1 -0
  57. package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
  58. package/build-module/components/global-styles/variations/variations-typography.js +1 -0
  59. package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
  60. package/build-module/components/layout/index.js +10 -39
  61. package/build-module/components/layout/index.js.map +1 -1
  62. package/build-module/components/page/header.js +1 -0
  63. package/build-module/components/page/header.js.map +1 -1
  64. package/build-module/components/page-patterns/header.js +2 -1
  65. package/build-module/components/page-patterns/header.js.map +1 -1
  66. package/build-module/components/page-patterns/rename-category-menu-item.js +3 -1
  67. package/build-module/components/page-patterns/rename-category-menu-item.js.map +1 -1
  68. package/build-module/components/posts-app/index.js +43 -0
  69. package/build-module/components/posts-app/index.js.map +1 -0
  70. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +2 -0
  71. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  72. package/build-module/hooks/commands/use-set-command-context.js +57 -0
  73. package/build-module/hooks/commands/use-set-command-context.js.map +1 -0
  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 +18 -20
  81. package/build-style/style.css +18 -20
  82. package/lib/inflate.js +3188 -3937
  83. package/lib/lib-font.browser.js +32 -2
  84. package/lib/unbrotli.js +1818 -2458
  85. package/package.json +41 -41
  86. package/src/components/add-new-page/index.js +6 -1
  87. package/src/components/add-new-pattern/index.js +1 -0
  88. package/src/components/app/index.js +17 -1
  89. package/src/components/editor/index.js +13 -22
  90. package/src/components/editor-canvas-container/index.js +20 -8
  91. package/src/components/global-styles/font-families.js +28 -19
  92. package/src/components/global-styles/font-library-modal/context.js +2 -2
  93. package/src/components/global-styles/style.scss +3 -8
  94. package/src/components/global-styles/variations/variation.js +37 -22
  95. package/src/components/global-styles/variations/variations-color.js +1 -0
  96. package/src/components/global-styles/variations/variations-typography.js +1 -0
  97. package/src/components/global-styles-sidebar/style.scss +0 -1
  98. package/src/components/layout/index.js +24 -70
  99. package/src/components/page/header.js +1 -0
  100. package/src/components/page/style.scss +6 -0
  101. package/src/components/page-patterns/header.js +8 -2
  102. package/src/components/page-patterns/rename-category-menu-item.js +2 -0
  103. package/src/components/page-patterns/style.scss +6 -0
  104. package/src/components/posts-app/index.js +39 -0
  105. package/src/components/sidebar/style.scss +4 -4
  106. package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +6 -1
  107. package/src/hooks/commands/use-set-command-context.js +49 -0
  108. package/src/index.js +10 -2
  109. package/src/posts.js +29 -0
  110. package/src/posts.scss +46 -0
  111. package/build/components/block-editor/block-inspector-button.js +0 -57
  112. package/build/components/block-editor/block-inspector-button.js.map +0 -1
  113. package/build/components/block-editor/inserter-media-categories.js +0 -183
  114. package/build/components/block-editor/inserter-media-categories.js.map +0 -1
  115. package/build/components/template-part-converter/convert-to-regular.js +0 -38
  116. package/build/components/template-part-converter/convert-to-regular.js.map +0 -1
  117. package/build/components/template-part-converter/convert-to-template-part.js +0 -84
  118. package/build/components/template-part-converter/convert-to-template-part.js.map +0 -1
  119. package/build/components/template-part-converter/index.js +0 -67
  120. package/build/components/template-part-converter/index.js.map +0 -1
  121. package/build-module/components/block-editor/block-inspector-button.js +0 -50
  122. package/build-module/components/block-editor/block-inspector-button.js.map +0 -1
  123. package/build-module/components/block-editor/inserter-media-categories.js +0 -177
  124. package/build-module/components/block-editor/inserter-media-categories.js.map +0 -1
  125. package/build-module/components/template-part-converter/convert-to-regular.js +0 -31
  126. package/build-module/components/template-part-converter/convert-to-regular.js.map +0 -1
  127. package/build-module/components/template-part-converter/convert-to-template-part.js +0 -79
  128. package/build-module/components/template-part-converter/convert-to-template-part.js.map +0 -1
  129. package/build-module/components/template-part-converter/index.js +0 -59
  130. package/build-module/components/template-part-converter/index.js.map +0 -1
  131. package/src/components/block-editor/block-inspector-button.js +0 -60
  132. package/src/components/block-editor/inserter-media-categories.js +0 -225
  133. package/src/components/template-part-converter/convert-to-regular.js +0 -32
  134. package/src/components/template-part-converter/convert-to-template-part.js +0 -78
  135. package/src/components/template-part-converter/index.js +0 -59
@@ -1,177 +0,0 @@
1
- /**
2
- * The `edit-site` settings here need to be in sync with the corresponding ones in `site-editor` package.
3
- * See `packages/edit-site/src/components/block-editor/inserter-media-categories.js`.
4
- *
5
- * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.
6
- * The rest of the settings would still need to be in sync though.
7
- */
8
-
9
- /**
10
- * WordPress dependencies
11
- */
12
- import { __, sprintf, _x } from '@wordpress/i18n';
13
- import { resolveSelect } from '@wordpress/data';
14
- import { decodeEntities } from '@wordpress/html-entities';
15
-
16
- /**
17
- * Internal dependencies
18
- */
19
- import { store as coreStore } from '@wordpress/core-data';
20
-
21
- /** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */
22
- /** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */
23
- /** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */
24
-
25
- const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
26
- const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`;
27
- const getOpenverseLicense = (license, licenseVersion) => {
28
- let licenseName = license.trim();
29
- // PDM has no abbreviation
30
- if (license !== 'pdm') {
31
- licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling');
32
- }
33
- // If version is known, append version to the name.
34
- // The license has to have a version to be valid. Only
35
- // PDM (public domain mark) doesn't have a version.
36
- if (licenseVersion) {
37
- licenseName += ` ${licenseVersion}`;
38
- }
39
- // For licenses other than public-domain marks, prepend 'CC' to the name.
40
- if (!['pdm', 'cc0'].includes(license)) {
41
- licenseName = `CC ${licenseName}`;
42
- }
43
- return licenseName;
44
- };
45
- const getOpenverseCaption = item => {
46
- const {
47
- title,
48
- foreign_landing_url: foreignLandingUrl,
49
- creator,
50
- creator_url: creatorUrl,
51
- license,
52
- license_version: licenseVersion,
53
- license_url: licenseUrl
54
- } = item;
55
- const fullLicense = getOpenverseLicense(license, licenseVersion);
56
- const _creator = decodeEntities(creator);
57
- let _caption;
58
- if (_creator) {
59
- _caption = title ? sprintf(
60
- // 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".
61
- _x('"%1$s" by %2$s/ %3$s', 'caption'), getExternalLink(foreignLandingUrl, decodeEntities(title)), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : sprintf(
62
- // 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".
63
- _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);
64
- } else {
65
- _caption = title ? sprintf(
66
- // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
67
- _x('"%1$s"/ %2$s', 'caption'), getExternalLink(foreignLandingUrl, decodeEntities(title)), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : sprintf(
68
- // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
69
- _x('<a %1$s>Work</a>/ %3$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
70
- }
71
- return _caption.replace(/\s{2}/g, ' ');
72
- };
73
- const coreMediaFetch = async (query = {}) => {
74
- const mediaItems = await resolveSelect(coreStore).getMediaItems({
75
- ...query,
76
- orderBy: !!query?.search ? 'relevance' : 'date'
77
- });
78
- return mediaItems.map(mediaItem => ({
79
- ...mediaItem,
80
- alt: mediaItem.alt_text,
81
- url: mediaItem.source_url,
82
- previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
83
- caption: mediaItem.caption?.raw
84
- }));
85
- };
86
-
87
- /** @type {InserterMediaCategory[]} */
88
- const inserterMediaCategories = [{
89
- name: 'images',
90
- labels: {
91
- name: __('Images'),
92
- search_items: __('Search images')
93
- },
94
- mediaType: 'image',
95
- async fetch(query = {}) {
96
- return coreMediaFetch({
97
- ...query,
98
- media_type: 'image'
99
- });
100
- }
101
- }, {
102
- name: 'videos',
103
- labels: {
104
- name: __('Videos'),
105
- search_items: __('Search videos')
106
- },
107
- mediaType: 'video',
108
- async fetch(query = {}) {
109
- return coreMediaFetch({
110
- ...query,
111
- media_type: 'video'
112
- });
113
- }
114
- }, {
115
- name: 'audio',
116
- labels: {
117
- name: __('Audio'),
118
- search_items: __('Search audio')
119
- },
120
- mediaType: 'audio',
121
- async fetch(query = {}) {
122
- return coreMediaFetch({
123
- ...query,
124
- media_type: 'audio'
125
- });
126
- }
127
- }, {
128
- name: 'openverse',
129
- labels: {
130
- name: __('Openverse'),
131
- search_items: __('Search Openverse')
132
- },
133
- mediaType: 'image',
134
- async fetch(query = {}) {
135
- const defaultArgs = {
136
- mature: false,
137
- excluded_source: 'flickr,inaturalist,wikimedia',
138
- license: 'pdm,cc0'
139
- };
140
- const finalQuery = {
141
- ...query,
142
- ...defaultArgs
143
- };
144
- const mapFromInserterMediaRequest = {
145
- per_page: 'page_size',
146
- search: 'q'
147
- };
148
- const url = new URL('https://api.openverse.org/v1/images/');
149
- Object.entries(finalQuery).forEach(([key, value]) => {
150
- const queryKey = mapFromInserterMediaRequest[key] || key;
151
- url.searchParams.set(queryKey, value);
152
- });
153
- const response = await window.fetch(url, {
154
- headers: {
155
- 'User-Agent': 'WordPress/inserter-media-fetch'
156
- }
157
- });
158
- const jsonResponse = await response.json();
159
- const results = jsonResponse.results;
160
- return results.map(result => ({
161
- ...result,
162
- // This is a temp solution for better titles, until Openverse API
163
- // completes the cleaning up of some titles of their upstream data.
164
- title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
165
- sourceId: result.id,
166
- id: undefined,
167
- caption: getOpenverseCaption(result),
168
- previewUrl: result.thumbnail
169
- }));
170
- },
171
- getReportUrl: ({
172
- sourceId
173
- }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
174
- isExternalResource: true
175
- }];
176
- export default inserterMediaCategories;
177
- //# sourceMappingURL=inserter-media-categories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__","sprintf","_x","resolveSelect","decodeEntities","store","coreStore","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","_caption","coreMediaFetch","query","mediaItems","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"],"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":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;;AAEA,MAAMC,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,IAA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,EAAE7B,mBAAmB,CAAE2D,MAAO,CAAC;MACtClC,UAAU,EAAEkC,MAAM,CAACO;IACpB,CAAC,CAAG,CAAC;EACN,CAAC;EACDC,YAAY,EAAEA,CAAE;IAAEJ;EAAS,CAAC,KAC1B,yCAAyCA,QAAU,UAAS;EAC9DK,kBAAkB,EAAE;AACrB,CAAC,CACD;AAED,eAAerC,uBAAuB","ignoreList":[]}
@@ -1,31 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect, useDispatch } from '@wordpress/data';
5
- import { store as blockEditorStore } from '@wordpress/block-editor';
6
- import { MenuItem } from '@wordpress/components';
7
- import { __ } from '@wordpress/i18n';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- export default function ConvertToRegularBlocks({
10
- clientId,
11
- onClose
12
- }) {
13
- const {
14
- getBlocks
15
- } = useSelect(blockEditorStore);
16
- const {
17
- replaceBlocks
18
- } = useDispatch(blockEditorStore);
19
- const canRemove = useSelect(select => select(blockEditorStore).canRemoveBlock(clientId), [clientId]);
20
- if (!canRemove) {
21
- return null;
22
- }
23
- return /*#__PURE__*/_jsx(MenuItem, {
24
- onClick: () => {
25
- replaceBlocks(clientId, getBlocks(clientId));
26
- onClose();
27
- },
28
- children: __('Detach')
29
- });
30
- }
31
- //# sourceMappingURL=convert-to-regular.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useSelect","useDispatch","store","blockEditorStore","MenuItem","__","jsx","_jsx","ConvertToRegularBlocks","clientId","onClose","getBlocks","replaceBlocks","canRemove","select","canRemoveBlock","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":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAErC,eAAe,SAASC,sBAAsBA,CAAE;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,EAAG;EACvE,MAAM;IAAEC;EAAU,CAAC,GAAGX,SAAS,CAAEG,gBAAiB,CAAC;EACnD,MAAM;IAAES;EAAc,CAAC,GAAGX,WAAW,CAAEE,gBAAiB,CAAC;EAEzD,MAAMU,SAAS,GAAGb,SAAS,CACxBc,MAAM,IAAMA,MAAM,CAAEX,gBAAiB,CAAC,CAACY,cAAc,CAAEN,QAAS,CAAC,EACnE,CAAEA,QAAQ,CACX,CAAC;EAED,IAAK,CAAEI,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,oBACCN,IAAA,CAACH,QAAQ;IACRY,OAAO,EAAGA,CAAA,KAAM;MACfJ,aAAa,CAAEH,QAAQ,EAAEE,SAAS,CAAEF,QAAS,CAAE,CAAC;MAChDC,OAAO,CAAC,CAAC;IACV,CAAG;IAAAO,QAAA,EAEDZ,EAAE,CAAE,QAAS;EAAC,CACP,CAAC;AAEb","ignoreList":[]}
@@ -1,79 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useDispatch, useSelect } from '@wordpress/data';
5
- import { store as blockEditorStore } from '@wordpress/block-editor';
6
- import { MenuItem } from '@wordpress/components';
7
- import { createBlock } from '@wordpress/blocks';
8
- import { __ } from '@wordpress/i18n';
9
- import { useState } from '@wordpress/element';
10
- import { store as noticesStore } from '@wordpress/notices';
11
- import { symbolFilled } from '@wordpress/icons';
12
- import { privateApis as editorPrivateApis } from '@wordpress/editor';
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
- import { unlock } from '../../lock-unlock';
18
- import { store as editSiteStore } from '../../store';
19
- import { jsx as _jsx } from "react/jsx-runtime";
20
- import { Fragment as _Fragment } from "react/jsx-runtime";
21
- import { jsxs as _jsxs } from "react/jsx-runtime";
22
- const {
23
- CreateTemplatePartModal
24
- } = unlock(editorPrivateApis);
25
- export default function ConvertToTemplatePart({
26
- clientIds,
27
- blocks
28
- }) {
29
- const [isModalOpen, setIsModalOpen] = useState(false);
30
- const {
31
- replaceBlocks
32
- } = useDispatch(blockEditorStore);
33
- const {
34
- createSuccessNotice
35
- } = useDispatch(noticesStore);
36
- const {
37
- canCreate
38
- } = useSelect(select => {
39
- const {
40
- supportsTemplatePartsMode
41
- } = select(editSiteStore).getSettings();
42
- return {
43
- canCreate: !supportsTemplatePartsMode
44
- };
45
- }, []);
46
- if (!canCreate) {
47
- return null;
48
- }
49
- const onConvert = async templatePart => {
50
- replaceBlocks(clientIds, createBlock('core/template-part', {
51
- slug: templatePart.slug,
52
- theme: templatePart.theme
53
- }));
54
- createSuccessNotice(__('Template part created.'), {
55
- type: 'snackbar'
56
- });
57
-
58
- // The modal and this component will be unmounted because of `replaceBlocks` above,
59
- // so no need to call `closeModal` or `onClose`.
60
- };
61
- return /*#__PURE__*/_jsxs(_Fragment, {
62
- children: [/*#__PURE__*/_jsx(MenuItem, {
63
- icon: symbolFilled,
64
- onClick: () => {
65
- setIsModalOpen(true);
66
- },
67
- "aria-expanded": isModalOpen,
68
- "aria-haspopup": "dialog",
69
- children: __('Create template part')
70
- }), isModalOpen && /*#__PURE__*/_jsx(CreateTemplatePartModal, {
71
- closeModal: () => {
72
- setIsModalOpen(false);
73
- },
74
- blocks: blocks,
75
- onCreate: onConvert
76
- })]
77
- });
78
- }
79
- //# sourceMappingURL=convert-to-template-part.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useDispatch","useSelect","store","blockEditorStore","MenuItem","createBlock","__","useState","noticesStore","symbolFilled","privateApis","editorPrivateApis","unlock","editSiteStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","CreateTemplatePartModal","ConvertToTemplatePart","clientIds","blocks","isModalOpen","setIsModalOpen","replaceBlocks","createSuccessNotice","canCreate","select","supportsTemplatePartsMode","getSettings","onConvert","templatePart","slug","theme","type","children","icon","onClick","closeModal","onCreate"],"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-template-part.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { symbolFilled } from '@wordpress/icons';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\n\nconst { CreateTemplatePartModal } = unlock( editorPrivateApis );\n\nexport default function ConvertToTemplatePart( { clientIds, blocks } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst { canCreate } = useSelect( ( select ) => {\n\t\tconst { supportsTemplatePartsMode } =\n\t\t\tselect( editSiteStore ).getSettings();\n\t\treturn {\n\t\t\tcanCreate: ! supportsTemplatePartsMode,\n\t\t};\n\t}, [] );\n\n\tif ( ! canCreate ) {\n\t\treturn null;\n\t}\n\n\tconst onConvert = async ( templatePart ) => {\n\t\treplaceBlocks(\n\t\t\tclientIds,\n\t\t\tcreateBlock( 'core/template-part', {\n\t\t\t\tslug: templatePart.slug,\n\t\t\t\ttheme: templatePart.theme,\n\t\t\t} )\n\t\t);\n\t\tcreateSuccessNotice( __( 'Template part created.' ), {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\n\t\t// The modal and this component will be unmounted because of `replaceBlocks` above,\n\t\t// so no need to call `closeModal` or `onClose`.\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\ticon={ symbolFilled }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t} }\n\t\t\t\taria-expanded={ isModalOpen }\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t>\n\t\t\t\t{ __( 'Create template part' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tonCreate={ onConvert }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASL,KAAK,IAAIM,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAm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;MACRkC,IAAI,EAAG7B,YAAc;MACrB8B,OAAO,EAAGA,CAAA,KAAM;QACfd,cAAc,CAAE,IAAK,CAAC;MACvB,CAAG;MACH,iBAAgBD,WAAa;MAC7B,iBAAc,QAAQ;MAAAa,QAAA,EAEpB/B,EAAE,CAAE,sBAAuB;IAAC,CACrB,CAAC,EACTkB,WAAW,iBACZT,IAAA,CAACK,uBAAuB;MACvBoB,UAAU,EAAGA,CAAA,KAAM;QAClBf,cAAc,CAAE,KAAM,CAAC;MACxB,CAAG;MACHF,MAAM,EAAGA,MAAQ;MACjBkB,QAAQ,EAAGT;IAAW,CACtB,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
@@ -1,59 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect } from '@wordpress/data';
5
- import { BlockSettingsMenuControls, store as blockEditorStore } from '@wordpress/block-editor';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import ConvertToRegularBlocks from './convert-to-regular';
11
- import ConvertToTemplatePart from './convert-to-template-part';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- export default function TemplatePartConverter() {
14
- return /*#__PURE__*/_jsx(BlockSettingsMenuControls, {
15
- children: ({
16
- selectedClientIds,
17
- onClose
18
- }) => /*#__PURE__*/_jsx(TemplatePartConverterMenuItem, {
19
- clientIds: selectedClientIds,
20
- onClose: onClose
21
- })
22
- });
23
- }
24
- function TemplatePartConverterMenuItem({
25
- clientIds,
26
- onClose
27
- }) {
28
- const {
29
- isContentOnly,
30
- blocks
31
- } = useSelect(select => {
32
- const {
33
- getBlocksByClientId,
34
- getBlockEditingMode
35
- } = select(blockEditorStore);
36
- return {
37
- blocks: getBlocksByClientId(clientIds),
38
- isContentOnly: clientIds.length === 1 && getBlockEditingMode(clientIds[0]) === 'contentOnly'
39
- };
40
- }, [clientIds]);
41
-
42
- // Do not show the convert button if the block is in content-only mode.
43
- if (isContentOnly) {
44
- return null;
45
- }
46
-
47
- // Allow converting a single template part to standard blocks.
48
- if (blocks.length === 1 && blocks[0]?.name === 'core/template-part') {
49
- return /*#__PURE__*/_jsx(ConvertToRegularBlocks, {
50
- clientId: clientIds[0],
51
- onClose: onClose
52
- });
53
- }
54
- return /*#__PURE__*/_jsx(ConvertToTemplatePart, {
55
- clientIds: clientIds,
56
- blocks: blocks
57
- });
58
- }
59
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useSelect","BlockSettingsMenuControls","store","blockEditorStore","ConvertToRegularBlocks","ConvertToTemplatePart","jsx","_jsx","TemplatePartConverter","children","selectedClientIds","onClose","TemplatePartConverterMenuItem","clientIds","isContentOnly","blocks","select","getBlocksByClientId","getBlockEditingMode","length","name","clientId"],"sources":["@wordpress/edit-site/src/components/template-part-converter/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport ConvertToRegularBlocks from './convert-to-regular';\nimport ConvertToTemplatePart from './convert-to-template-part';\n\nexport default function TemplatePartConverter() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<TemplatePartConverterMenuItem\n\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n\nfunction TemplatePartConverterMenuItem( { clientIds, onClose } ) {\n\tconst { isContentOnly, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlocksByClientId, getBlockEditingMode } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tblocks: getBlocksByClientId( clientIds ),\n\t\t\t\tisContentOnly:\n\t\t\t\t\tclientIds.length === 1 &&\n\t\t\t\t\tgetBlockEditingMode( clientIds[ 0 ] ) === 'contentOnly',\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\t// Do not show the convert button if the block is in content-only mode.\n\tif ( isContentOnly ) {\n\t\treturn null;\n\t}\n\n\t// Allow converting a single template part to standard blocks.\n\tif ( blocks.length === 1 && blocks[ 0 ]?.name === 'core/template-part' ) {\n\t\treturn (\n\t\t\t<ConvertToRegularBlocks\n\t\t\t\tclientId={ clientIds[ 0 ] }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\treturn <ConvertToTemplatePart clientIds={ clientIds } blocks={ blocks } />;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,yBAAyB,EACzBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;;AAEhC;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,sBAAsB;AACzD,OAAOC,qBAAqB,MAAM,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE/D,eAAe,SAASC,qBAAqBA,CAAA,EAAG;EAC/C,oBACCD,IAAA,CAACN,yBAAyB;IAAAQ,QAAA,EACvBA,CAAE;MAAEC,iBAAiB;MAAEC;IAAQ,CAAC,kBACjCJ,IAAA,CAACK,6BAA6B;MAC7BC,SAAS,EAAGH,iBAAmB;MAC/BC,OAAO,EAAGA;IAAS,CACnB;EACD,CACyB,CAAC;AAE9B;AAEA,SAASC,6BAA6BA,CAAE;EAAEC,SAAS;EAAEF;AAAQ,CAAC,EAAG;EAChE,MAAM;IAAEG,aAAa;IAAEC;EAAO,CAAC,GAAGf,SAAS,CACxCgB,MAAM,IAAM;IACb,MAAM;MAAEC,mBAAmB;MAAEC;IAAoB,CAAC,GACjDF,MAAM,CAAEb,gBAAiB,CAAC;IAC3B,OAAO;MACNY,MAAM,EAAEE,mBAAmB,CAAEJ,SAAU,CAAC;MACxCC,aAAa,EACZD,SAAS,CAACM,MAAM,KAAK,CAAC,IACtBD,mBAAmB,CAAEL,SAAS,CAAE,CAAC,CAAG,CAAC,KAAK;IAC5C,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,CACZ,CAAC;;EAED;EACA,IAAKC,aAAa,EAAG;IACpB,OAAO,IAAI;EACZ;;EAEA;EACA,IAAKC,MAAM,CAACI,MAAM,KAAK,CAAC,IAAIJ,MAAM,CAAE,CAAC,CAAE,EAAEK,IAAI,KAAK,oBAAoB,EAAG;IACxE,oBACCb,IAAA,CAACH,sBAAsB;MACtBiB,QAAQ,EAAGR,SAAS,CAAE,CAAC,CAAI;MAC3BF,OAAO,EAAGA;IAAS,CACnB,CAAC;EAEJ;EACA,oBAAOJ,IAAA,CAACF,qBAAqB;IAACQ,SAAS,EAAGA,SAAW;IAACE,MAAM,EAAGA;EAAQ,CAAE,CAAC;AAC3E","ignoreList":[]}
@@ -1,60 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { speak } from '@wordpress/a11y';
6
- import { MenuItem } from '@wordpress/components';
7
- import { useSelect, useDispatch } from '@wordpress/data';
8
- import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
9
- import { privateApis as editorPrivateApis } from '@wordpress/editor';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { unlock } from '../../lock-unlock';
15
-
16
- const { interfaceStore } = unlock( editorPrivateApis );
17
-
18
- export default function BlockInspectorButton( { onClick = () => {} } ) {
19
- const { shortcut, isBlockInspectorOpen } = useSelect(
20
- ( select ) => ( {
21
- shortcut: select(
22
- keyboardShortcutsStore
23
- ).getShortcutRepresentation( 'core/editor/toggle-sidebar' ),
24
- isBlockInspectorOpen:
25
- select( interfaceStore ).getActiveComplementaryArea(
26
- 'core'
27
- ) === 'edit-post/block',
28
- } ),
29
- []
30
- );
31
- const { enableComplementaryArea, disableComplementaryArea } =
32
- useDispatch( interfaceStore );
33
-
34
- const label = isBlockInspectorOpen
35
- ? __( 'Hide more settings' )
36
- : __( 'Show more settings' );
37
-
38
- return (
39
- <MenuItem
40
- onClick={ () => {
41
- if ( isBlockInspectorOpen ) {
42
- disableComplementaryArea( 'core' );
43
- speak( __( 'Block settings closed' ) );
44
- } else {
45
- enableComplementaryArea( 'core', 'edit-post/block' );
46
- speak(
47
- __(
48
- 'Additional settings are now available in the Editor block settings sidebar'
49
- )
50
- );
51
- }
52
- // Close dropdown menu.
53
- onClick();
54
- } }
55
- shortcut={ shortcut }
56
- >
57
- { label }
58
- </MenuItem>
59
- );
60
- }