@wordpress/editor 13.26.1-next.79a6196f.0 → 13.27.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 (132) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/bindings/index.js +20 -0
  3. package/build/bindings/index.js.map +1 -0
  4. package/build/bindings/post-meta.js +52 -0
  5. package/build/bindings/post-meta.js.map +1 -0
  6. package/build/components/block-manager/category.js +106 -0
  7. package/build/components/block-manager/category.js.map +1 -0
  8. package/build/components/block-manager/checklist.js +35 -0
  9. package/build/components/block-manager/checklist.js.map +1 -0
  10. package/build/components/block-manager/index.js +130 -0
  11. package/build/components/block-manager/index.js.map +1 -0
  12. package/build/components/document-tools/index.js +58 -52
  13. package/build/components/document-tools/index.js.map +1 -1
  14. package/build/components/editor-canvas/index.js +4 -4
  15. package/build/components/editor-canvas/index.js.map +1 -1
  16. package/build/components/editor-notices/index.js +11 -11
  17. package/build/components/editor-notices/index.js.map +1 -1
  18. package/build/components/entities-saved-states/entity-type-list.js +38 -7
  19. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  20. package/build/components/offline-status/index.native.js +1 -3
  21. package/build/components/offline-status/index.native.js.map +1 -1
  22. package/build/components/post-locked-modal/index.js +1 -1
  23. package/build/components/post-locked-modal/index.js.map +1 -1
  24. package/build/components/post-saved-state/index.js +10 -24
  25. package/build/components/post-saved-state/index.js.map +1 -1
  26. package/build/components/post-schedule/check.js +5 -16
  27. package/build/components/post-schedule/check.js.map +1 -1
  28. package/build/components/preferences-modal/enable-panel.js +42 -0
  29. package/build/components/preferences-modal/enable-panel.js.map +1 -0
  30. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js +33 -0
  31. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -0
  32. package/build/components/preferences-modal/index.js +186 -0
  33. package/build/components/preferences-modal/index.js.map +1 -0
  34. package/build/components/provider/disable-non-page-content-blocks.js +1 -4
  35. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  36. package/build/components/provider/use-block-editor-settings.js +34 -8
  37. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  38. package/build/hooks/pattern-partial-syncing.js +12 -6
  39. package/build/hooks/pattern-partial-syncing.js.map +1 -1
  40. package/build/index.js +1 -0
  41. package/build/index.js.map +1 -1
  42. package/build/private-apis.js +6 -2
  43. package/build/private-apis.js.map +1 -1
  44. package/build/store/defaults.js +2 -0
  45. package/build/store/defaults.js.map +1 -1
  46. package/build/store/private-actions.js +33 -1
  47. package/build/store/private-actions.js.map +1 -1
  48. package/build/store/private-selectors.js +1 -1
  49. package/build/store/private-selectors.js.map +1 -1
  50. package/build-module/bindings/index.js +15 -0
  51. package/build-module/bindings/index.js.map +1 -0
  52. package/build-module/bindings/post-meta.js +45 -0
  53. package/build-module/bindings/post-meta.js.map +1 -0
  54. package/build-module/components/block-manager/category.js +97 -0
  55. package/build-module/components/block-manager/category.js.map +1 -0
  56. package/build-module/components/block-manager/checklist.js +27 -0
  57. package/build-module/components/block-manager/checklist.js.map +1 -0
  58. package/build-module/components/block-manager/index.js +121 -0
  59. package/build-module/components/block-manager/index.js.map +1 -0
  60. package/build-module/components/document-tools/index.js +58 -52
  61. package/build-module/components/document-tools/index.js.map +1 -1
  62. package/build-module/components/editor-canvas/index.js +4 -4
  63. package/build-module/components/editor-canvas/index.js.map +1 -1
  64. package/build-module/components/editor-notices/index.js +12 -12
  65. package/build-module/components/editor-notices/index.js.map +1 -1
  66. package/build-module/components/entities-saved-states/entity-type-list.js +39 -8
  67. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  68. package/build-module/components/offline-status/index.native.js +1 -3
  69. package/build-module/components/offline-status/index.native.js.map +1 -1
  70. package/build-module/components/post-locked-modal/index.js +1 -1
  71. package/build-module/components/post-locked-modal/index.js.map +1 -1
  72. package/build-module/components/post-saved-state/index.js +11 -25
  73. package/build-module/components/post-saved-state/index.js.map +1 -1
  74. package/build-module/components/post-schedule/check.js +6 -15
  75. package/build-module/components/post-schedule/check.js.map +1 -1
  76. package/build-module/components/preferences-modal/enable-panel.js +34 -0
  77. package/build-module/components/preferences-modal/enable-panel.js.map +1 -0
  78. package/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js +24 -0
  79. package/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -0
  80. package/build-module/components/preferences-modal/index.js +179 -0
  81. package/build-module/components/preferences-modal/index.js.map +1 -0
  82. package/build-module/components/provider/disable-non-page-content-blocks.js +1 -4
  83. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  84. package/build-module/components/provider/use-block-editor-settings.js +35 -9
  85. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  86. package/build-module/hooks/pattern-partial-syncing.js +12 -6
  87. package/build-module/hooks/pattern-partial-syncing.js.map +1 -1
  88. package/build-module/index.js +1 -0
  89. package/build-module/index.js.map +1 -1
  90. package/build-module/private-apis.js +6 -2
  91. package/build-module/private-apis.js.map +1 -1
  92. package/build-module/store/defaults.js +2 -0
  93. package/build-module/store/defaults.js.map +1 -1
  94. package/build-module/store/private-actions.js +29 -0
  95. package/build-module/store/private-actions.js.map +1 -1
  96. package/build-module/store/private-selectors.js +1 -1
  97. package/build-module/store/private-selectors.js.map +1 -1
  98. package/build-style/style-rtl.css +80 -12
  99. package/build-style/style.css +80 -12
  100. package/package.json +33 -33
  101. package/src/bindings/index.js +13 -0
  102. package/src/bindings/post-meta.js +42 -0
  103. package/src/components/block-manager/category.js +96 -0
  104. package/src/components/block-manager/checklist.js +30 -0
  105. package/src/components/block-manager/index.js +160 -0
  106. package/src/components/block-manager/style.scss +82 -0
  107. package/src/components/document-tools/index.js +9 -1
  108. package/src/components/editor-canvas/index.js +3 -2
  109. package/src/components/editor-notices/index.js +11 -12
  110. package/src/components/editor-notices/style.scss +0 -1
  111. package/src/components/entities-saved-states/entity-type-list.js +47 -5
  112. package/src/components/entities-saved-states/style.scss +4 -0
  113. package/src/components/offline-status/index.native.js +2 -4
  114. package/src/components/post-locked-modal/index.js +1 -1
  115. package/src/components/post-locked-modal/style.scss +0 -6
  116. package/src/components/post-saved-state/index.js +30 -47
  117. package/src/components/post-schedule/check.js +10 -14
  118. package/src/components/post-schedule/test/check.js +24 -9
  119. package/src/components/preferences-modal/enable-panel.js +30 -0
  120. package/src/components/preferences-modal/enable-plugin-document-setting-panel.js +23 -0
  121. package/src/components/preferences-modal/index.js +269 -0
  122. package/src/components/preferences-modal/test/index.js +28 -0
  123. package/src/components/provider/disable-non-page-content-blocks.js +3 -3
  124. package/src/components/provider/use-block-editor-settings.js +45 -17
  125. package/src/hooks/pattern-partial-syncing.js +26 -22
  126. package/src/index.js +1 -0
  127. package/src/private-apis.js +6 -2
  128. package/src/store/defaults.js +2 -0
  129. package/src/store/private-actions.js +49 -0
  130. package/src/store/private-selectors.js +1 -1
  131. package/src/style.scss +1 -1
  132. package/src/components/editor-canvas/style.scss +0 -5
@@ -98,7 +98,7 @@
98
98
  --wp-block-synced-color: #7a00df;
99
99
  --wp-block-synced-color--rgb: 122, 0, 223;
100
100
  }
101
- @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
101
+ @media (min-resolution: 192dpi) {
102
102
  :root {
103
103
  --wp-admin-border-width-focus: 1.5px;
104
104
  }
@@ -142,6 +142,81 @@
142
142
  color: var(--wp-admin-theme-color);
143
143
  }
144
144
 
145
+ .editor-block-manager__no-results {
146
+ font-style: italic;
147
+ padding: 24px 0;
148
+ text-align: center;
149
+ }
150
+
151
+ .editor-block-manager__search {
152
+ margin: 16px 0;
153
+ }
154
+
155
+ .editor-block-manager__disabled-blocks-count {
156
+ border: 1px solid #ddd;
157
+ border-width: 1px 0;
158
+ box-shadow: -32px 0 0 0 #fff, 32px 0 0 0 #fff;
159
+ padding: 8px;
160
+ background-color: #fff;
161
+ text-align: center;
162
+ position: sticky;
163
+ top: -5px;
164
+ z-index: 2;
165
+ }
166
+ .editor-block-manager__disabled-blocks-count ~ .editor-block-manager__results .editor-block-manager__category-title {
167
+ top: 31px;
168
+ }
169
+ .editor-block-manager__disabled-blocks-count .is-link {
170
+ margin-left: 12px;
171
+ }
172
+
173
+ .editor-block-manager__category {
174
+ margin: 0 0 24px 0;
175
+ }
176
+
177
+ .editor-block-manager__category-title {
178
+ position: sticky;
179
+ top: -4px;
180
+ padding: 16px 0;
181
+ background-color: #fff;
182
+ z-index: 1;
183
+ }
184
+ .editor-block-manager__category-title .components-checkbox-control__label {
185
+ font-weight: 600;
186
+ }
187
+
188
+ .editor-block-manager__checklist {
189
+ margin-top: 0;
190
+ }
191
+
192
+ .editor-block-manager__category-title,
193
+ .editor-block-manager__checklist-item {
194
+ border-bottom: 1px solid #ddd;
195
+ }
196
+
197
+ .editor-block-manager__checklist-item {
198
+ display: flex;
199
+ justify-content: space-between;
200
+ align-items: center;
201
+ margin-bottom: 0;
202
+ padding: 8px 0 8px 16px;
203
+ }
204
+ .components-modal__content .editor-block-manager__checklist-item.components-checkbox-control__input-container {
205
+ margin: 0 8px;
206
+ }
207
+ .editor-block-manager__checklist-item .block-editor-block-icon {
208
+ margin-right: 10px;
209
+ fill: #1e1e1e;
210
+ }
211
+
212
+ .editor-block-manager__results {
213
+ border-top: 1px solid #ddd;
214
+ }
215
+
216
+ .editor-block-manager__disabled-blocks-count + .editor-block-manager__results {
217
+ border-top-width: 0;
218
+ }
219
+
145
220
  .editor-document-bar {
146
221
  display: flex;
147
222
  align-items: center;
@@ -456,7 +531,6 @@
456
531
  .components-editor-notices__dismissible .components-notice,
457
532
  .components-editor-notices__pinned .components-notice {
458
533
  box-sizing: border-box;
459
- margin: 0;
460
534
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
461
535
  padding: 0 12px;
462
536
  min-height: 60px;
@@ -484,6 +558,10 @@
484
558
  margin-bottom: 12px;
485
559
  }
486
560
 
561
+ .entities-saved-states__description-heading {
562
+ font-size: 13px;
563
+ }
564
+
487
565
  .editor-error-boundary {
488
566
  margin: auto;
489
567
  max-width: 780px;
@@ -753,12 +831,6 @@
753
831
  padding: 16px;
754
832
  }
755
833
 
756
- @media (min-width: 600px) {
757
- .editor-post-locked-modal {
758
- max-width: 480px;
759
- }
760
- }
761
-
762
834
  .editor-post-locked-modal__buttons {
763
835
  margin-top: 24px;
764
836
  }
@@ -1419,8 +1491,4 @@
1419
1491
  }
1420
1492
  .editor-template-validation-notice .components-button {
1421
1493
  margin-left: 5px;
1422
- }
1423
-
1424
- .editor-canvas__iframe.has-history {
1425
- padding: 48px 48px 0;
1426
1494
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "13.26.1-next.79a6196f.0",
3
+ "version": "13.27.0",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,40 +27,40 @@
27
27
  "sideEffects": [
28
28
  "build-style/**",
29
29
  "src/**/*.scss",
30
- "{src,build,build-module}/{index.js,store/index.js,hooks/**}"
30
+ "{src,build,build-module}/{index.js,store/index.js,hooks/**,bindings/**}"
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.48.1-next.79a6196f.0",
35
- "@wordpress/api-fetch": "^6.45.1-next.79a6196f.0",
36
- "@wordpress/blob": "^3.48.1-next.79a6196f.0",
37
- "@wordpress/block-editor": "^12.16.1-next.79a6196f.0",
38
- "@wordpress/blocks": "^12.25.1-next.79a6196f.0",
39
- "@wordpress/commands": "^0.19.1-next.79a6196f.0",
40
- "@wordpress/components": "^25.15.1-next.79a6196f.0",
41
- "@wordpress/compose": "^6.25.1-next.79a6196f.0",
42
- "@wordpress/core-data": "^6.25.1-next.79a6196f.0",
43
- "@wordpress/data": "^9.18.1-next.79a6196f.0",
44
- "@wordpress/date": "^4.48.1-next.79a6196f.0",
45
- "@wordpress/deprecated": "^3.48.1-next.79a6196f.0",
46
- "@wordpress/dom": "^3.48.1-next.79a6196f.0",
47
- "@wordpress/element": "^5.25.1-next.79a6196f.0",
48
- "@wordpress/hooks": "^3.48.1-next.79a6196f.0",
49
- "@wordpress/html-entities": "^3.48.1-next.79a6196f.0",
50
- "@wordpress/i18n": "^4.48.1-next.79a6196f.0",
51
- "@wordpress/icons": "^9.39.1-next.79a6196f.0",
52
- "@wordpress/keyboard-shortcuts": "^4.25.1-next.79a6196f.0",
53
- "@wordpress/keycodes": "^3.48.1-next.79a6196f.0",
54
- "@wordpress/media-utils": "^4.39.1-next.79a6196f.0",
55
- "@wordpress/notices": "^4.16.1-next.79a6196f.0",
56
- "@wordpress/patterns": "^1.9.1-next.79a6196f.0",
57
- "@wordpress/preferences": "^3.25.1-next.79a6196f.0",
58
- "@wordpress/private-apis": "^0.30.1-next.79a6196f.0",
59
- "@wordpress/reusable-blocks": "^4.25.1-next.79a6196f.0",
60
- "@wordpress/rich-text": "^6.25.1-next.79a6196f.0",
61
- "@wordpress/server-side-render": "^4.25.1-next.79a6196f.0",
62
- "@wordpress/url": "^3.49.1-next.79a6196f.0",
63
- "@wordpress/wordcount": "^3.48.1-next.79a6196f.0",
34
+ "@wordpress/a11y": "^3.50.0",
35
+ "@wordpress/api-fetch": "^6.47.0",
36
+ "@wordpress/blob": "^3.50.0",
37
+ "@wordpress/block-editor": "^12.18.0",
38
+ "@wordpress/blocks": "^12.27.0",
39
+ "@wordpress/commands": "^0.21.0",
40
+ "@wordpress/components": "^25.16.0",
41
+ "@wordpress/compose": "^6.27.0",
42
+ "@wordpress/core-data": "^6.27.0",
43
+ "@wordpress/data": "^9.20.0",
44
+ "@wordpress/date": "^4.50.0",
45
+ "@wordpress/deprecated": "^3.50.0",
46
+ "@wordpress/dom": "^3.50.0",
47
+ "@wordpress/element": "^5.27.0",
48
+ "@wordpress/hooks": "^3.50.0",
49
+ "@wordpress/html-entities": "^3.50.0",
50
+ "@wordpress/i18n": "^4.50.0",
51
+ "@wordpress/icons": "^9.41.0",
52
+ "@wordpress/keyboard-shortcuts": "^4.27.0",
53
+ "@wordpress/keycodes": "^3.50.0",
54
+ "@wordpress/media-utils": "^4.41.0",
55
+ "@wordpress/notices": "^4.18.0",
56
+ "@wordpress/patterns": "^1.11.0",
57
+ "@wordpress/preferences": "^3.27.0",
58
+ "@wordpress/private-apis": "^0.32.0",
59
+ "@wordpress/reusable-blocks": "^4.27.0",
60
+ "@wordpress/rich-text": "^6.27.0",
61
+ "@wordpress/server-side-render": "^4.27.0",
62
+ "@wordpress/url": "^3.51.0",
63
+ "@wordpress/wordcount": "^3.50.0",
64
64
  "classnames": "^2.3.1",
65
65
  "date-fns": "^2.28.0",
66
66
  "memize": "^2.1.0",
@@ -75,5 +75,5 @@
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  },
78
- "gitHead": "1e74b942ac0119a22ceaaf5c9594263f3ec516ab"
78
+ "gitHead": "45de2cb4212fed7f2763e95f10300d1ff9d0ec08"
79
79
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as blockEditorStore } from '@wordpress/block-editor';
5
+ import { dispatch } from '@wordpress/data';
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { unlock } from '../lock-unlock';
10
+ import postMeta from './post-meta';
11
+
12
+ const { registerBlockBindingsSource } = unlock( dispatch( blockEditorStore ) );
13
+ registerBlockBindingsSource( postMeta );
@@ -0,0 +1,42 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEntityProp } from '@wordpress/core-data';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { __ } from '@wordpress/i18n';
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { store as editorStore } from '../store';
11
+
12
+ export default {
13
+ name: 'post_meta',
14
+ label: __( 'Post Meta' ),
15
+ useSource( props, sourceAttributes ) {
16
+ const { getCurrentPostType } = useSelect( editorStore );
17
+ const { context } = props;
18
+ const { value: metaKey } = sourceAttributes;
19
+ const postType = context.postType
20
+ ? context.postType
21
+ : getCurrentPostType();
22
+ const [ meta, setMeta ] = useEntityProp(
23
+ 'postType',
24
+ context.postType,
25
+ 'meta',
26
+ context.postId
27
+ );
28
+
29
+ if ( postType === 'wp_template' ) {
30
+ return { placeholder: metaKey };
31
+ }
32
+ const metaValue = meta[ metaKey ];
33
+ const updateMetaValue = ( newValue ) => {
34
+ setMeta( { ...meta, [ metaKey ]: newValue } );
35
+ };
36
+ return {
37
+ placeholder: metaKey,
38
+ useValue: [ metaValue, updateMetaValue ],
39
+ };
40
+ },
41
+ lockAttributesEditing: true,
42
+ };
@@ -0,0 +1,96 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMemo, useCallback } from '@wordpress/element';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
6
+ import { useInstanceId } from '@wordpress/compose';
7
+ import { CheckboxControl } from '@wordpress/components';
8
+ import { store as preferencesStore } from '@wordpress/preferences';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import BlockTypesChecklist from './checklist';
14
+ import { store as editorStore } from '../../store';
15
+ import { unlock } from '../../lock-unlock';
16
+
17
+ function BlockManagerCategory( { title, blockTypes } ) {
18
+ const instanceId = useInstanceId( BlockManagerCategory );
19
+ const { allowedBlockTypes, hiddenBlockTypes } = useSelect( ( select ) => {
20
+ const { getEditorSettings } = select( editorStore );
21
+ const { get } = select( preferencesStore );
22
+ return {
23
+ allowedBlockTypes: getEditorSettings().allowedBlockTypes,
24
+ hiddenBlockTypes: get( 'core', 'hiddenBlockTypes' ),
25
+ };
26
+ }, [] );
27
+ const filteredBlockTypes = useMemo( () => {
28
+ if ( allowedBlockTypes === true ) {
29
+ return blockTypes;
30
+ }
31
+ return blockTypes.filter( ( { name } ) => {
32
+ return allowedBlockTypes?.includes( name );
33
+ } );
34
+ }, [ allowedBlockTypes, blockTypes ] );
35
+ const { showBlockTypes, hideBlockTypes } = unlock(
36
+ useDispatch( editorStore )
37
+ );
38
+ const toggleVisible = useCallback(
39
+ ( blockName, nextIsChecked ) => {
40
+ if ( nextIsChecked ) {
41
+ showBlockTypes( blockName );
42
+ } else {
43
+ hideBlockTypes( blockName );
44
+ }
45
+ },
46
+ [ showBlockTypes, hideBlockTypes ]
47
+ );
48
+ const toggleAllVisible = useCallback(
49
+ ( nextIsChecked ) => {
50
+ const blockNames = blockTypes.map( ( { name } ) => name );
51
+ if ( nextIsChecked ) {
52
+ showBlockTypes( blockNames );
53
+ } else {
54
+ hideBlockTypes( blockNames );
55
+ }
56
+ },
57
+ [ blockTypes, showBlockTypes, hideBlockTypes ]
58
+ );
59
+
60
+ if ( ! filteredBlockTypes.length ) {
61
+ return null;
62
+ }
63
+
64
+ const checkedBlockNames = filteredBlockTypes
65
+ .map( ( { name } ) => name )
66
+ .filter( ( type ) => ! ( hiddenBlockTypes ?? [] ).includes( type ) );
67
+
68
+ const titleId = 'editor-block-manager__category-title-' + instanceId;
69
+
70
+ const isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;
71
+ const isIndeterminate = ! isAllChecked && checkedBlockNames.length > 0;
72
+
73
+ return (
74
+ <div
75
+ role="group"
76
+ aria-labelledby={ titleId }
77
+ className="editor-block-manager__category"
78
+ >
79
+ <CheckboxControl
80
+ __nextHasNoMarginBottom
81
+ checked={ isAllChecked }
82
+ onChange={ toggleAllVisible }
83
+ className="editor-block-manager__category-title"
84
+ indeterminate={ isIndeterminate }
85
+ label={ <span id={ titleId }>{ title }</span> }
86
+ />
87
+ <BlockTypesChecklist
88
+ blockTypes={ filteredBlockTypes }
89
+ value={ checkedBlockNames }
90
+ onItemChange={ toggleVisible }
91
+ />
92
+ </div>
93
+ );
94
+ }
95
+
96
+ export default BlockManagerCategory;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { BlockIcon } from '@wordpress/block-editor';
5
+ import { CheckboxControl } from '@wordpress/components';
6
+
7
+ function BlockTypesChecklist( { blockTypes, value, onItemChange } ) {
8
+ return (
9
+ <ul className="editor-block-manager__checklist">
10
+ { blockTypes.map( ( blockType ) => (
11
+ <li
12
+ key={ blockType.name }
13
+ className="editor-block-manager__checklist-item"
14
+ >
15
+ <CheckboxControl
16
+ __nextHasNoMarginBottom
17
+ label={ blockType.title }
18
+ checked={ value.includes( blockType.name ) }
19
+ onChange={ ( ...args ) =>
20
+ onItemChange( blockType.name, ...args )
21
+ }
22
+ />
23
+ <BlockIcon icon={ blockType.icon } />
24
+ </li>
25
+ ) ) }
26
+ </ul>
27
+ );
28
+ }
29
+
30
+ export default BlockTypesChecklist;
@@ -0,0 +1,160 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as blocksStore } from '@wordpress/blocks';
5
+ import { withSelect, withDispatch } from '@wordpress/data';
6
+ import { SearchControl, Button } from '@wordpress/components';
7
+ import { __, _n, sprintf } from '@wordpress/i18n';
8
+ import { useEffect, useState } from '@wordpress/element';
9
+ import { useDebounce, compose } from '@wordpress/compose';
10
+ import { speak } from '@wordpress/a11y';
11
+ import { store as preferencesStore } from '@wordpress/preferences';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { unlock } from '../../lock-unlock';
17
+ import { store as editorStore } from '../../store';
18
+ import BlockManagerCategory from './category';
19
+
20
+ function BlockManager( {
21
+ blockTypes,
22
+ categories,
23
+ hasBlockSupport,
24
+ isMatchingSearchTerm,
25
+ numberOfHiddenBlocks,
26
+ enableAllBlockTypes,
27
+ } ) {
28
+ const debouncedSpeak = useDebounce( speak, 500 );
29
+ const [ search, setSearch ] = useState( '' );
30
+
31
+ // Filtering occurs here (as opposed to `withSelect`) to avoid
32
+ // wasted renders by consequence of `Array#filter` producing
33
+ // a new value reference on each call.
34
+ blockTypes = blockTypes.filter(
35
+ ( blockType ) =>
36
+ hasBlockSupport( blockType, 'inserter', true ) &&
37
+ ( ! search || isMatchingSearchTerm( blockType, search ) ) &&
38
+ ( ! blockType.parent ||
39
+ blockType.parent.includes( 'core/post-content' ) )
40
+ );
41
+
42
+ // Announce search results on change
43
+ useEffect( () => {
44
+ if ( ! search ) {
45
+ return;
46
+ }
47
+ const count = blockTypes.length;
48
+ const resultsFoundMessage = sprintf(
49
+ /* translators: %d: number of results. */
50
+ _n( '%d result found.', '%d results found.', count ),
51
+ count
52
+ );
53
+ debouncedSpeak( resultsFoundMessage );
54
+ }, [ blockTypes.length, search, debouncedSpeak ] );
55
+
56
+ return (
57
+ <div className="editor-block-manager__content">
58
+ { !! numberOfHiddenBlocks && (
59
+ <div className="editor-block-manager__disabled-blocks-count">
60
+ { sprintf(
61
+ /* translators: %d: number of blocks. */
62
+ _n(
63
+ '%d block is hidden.',
64
+ '%d blocks are hidden.',
65
+ numberOfHiddenBlocks
66
+ ),
67
+ numberOfHiddenBlocks
68
+ ) }
69
+ <Button
70
+ variant="link"
71
+ onClick={ () => enableAllBlockTypes( blockTypes ) }
72
+ >
73
+ { __( 'Reset' ) }
74
+ </Button>
75
+ </div>
76
+ ) }
77
+ <SearchControl
78
+ __nextHasNoMarginBottom
79
+ label={ __( 'Search for a block' ) }
80
+ placeholder={ __( 'Search for a block' ) }
81
+ value={ search }
82
+ onChange={ ( nextSearch ) => setSearch( nextSearch ) }
83
+ className="editor-block-manager__search"
84
+ />
85
+ <div
86
+ tabIndex="0"
87
+ role="region"
88
+ aria-label={ __( 'Available block types' ) }
89
+ className="editor-block-manager__results"
90
+ >
91
+ { blockTypes.length === 0 && (
92
+ <p className="editor-block-manager__no-results">
93
+ { __( 'No blocks found.' ) }
94
+ </p>
95
+ ) }
96
+ { categories.map( ( category ) => (
97
+ <BlockManagerCategory
98
+ key={ category.slug }
99
+ title={ category.title }
100
+ blockTypes={ blockTypes.filter(
101
+ ( blockType ) =>
102
+ blockType.category === category.slug
103
+ ) }
104
+ />
105
+ ) ) }
106
+ <BlockManagerCategory
107
+ title={ __( 'Uncategorized' ) }
108
+ blockTypes={ blockTypes.filter(
109
+ ( { category } ) => ! category
110
+ ) }
111
+ />
112
+ </div>
113
+ </div>
114
+ );
115
+ }
116
+
117
+ export default compose( [
118
+ withSelect( ( select ) => {
119
+ const {
120
+ getBlockTypes,
121
+ getCategories,
122
+ hasBlockSupport,
123
+ isMatchingSearchTerm,
124
+ } = select( blocksStore );
125
+ const { get } = select( preferencesStore );
126
+
127
+ // Some hidden blocks become unregistered
128
+ // by removing for instance the plugin that registered them, yet
129
+ // they're still remain as hidden by the user's action.
130
+ // We consider "hidden", blocks which were hidden and
131
+ // are still registered.
132
+ const blockTypes = getBlockTypes();
133
+ const hiddenBlockTypes = (
134
+ get( 'core', 'hiddenBlockTypes' ) ?? []
135
+ ).filter( ( hiddenBlock ) => {
136
+ return blockTypes.some(
137
+ ( registeredBlock ) => registeredBlock.name === hiddenBlock
138
+ );
139
+ } );
140
+ const numberOfHiddenBlocks =
141
+ Array.isArray( hiddenBlockTypes ) && hiddenBlockTypes.length;
142
+
143
+ return {
144
+ blockTypes,
145
+ categories: getCategories(),
146
+ hasBlockSupport,
147
+ isMatchingSearchTerm,
148
+ numberOfHiddenBlocks,
149
+ };
150
+ } ),
151
+ withDispatch( ( dispatch ) => {
152
+ const { showBlockTypes } = unlock( dispatch( editorStore ) );
153
+ return {
154
+ enableAllBlockTypes: ( blockTypes ) => {
155
+ const blockNames = blockTypes.map( ( { name } ) => name );
156
+ showBlockTypes( blockNames );
157
+ },
158
+ };
159
+ } ),
160
+ ] )( BlockManager );
@@ -0,0 +1,82 @@
1
+ .editor-block-manager__no-results {
2
+ font-style: italic;
3
+ padding: $grid-unit-30 0;
4
+ text-align: center;
5
+ }
6
+
7
+ .editor-block-manager__search {
8
+ margin: $grid-unit-20 0;
9
+ }
10
+
11
+ .editor-block-manager__disabled-blocks-count {
12
+ border: 1px solid $gray-300;
13
+ border-width: 1px 0;
14
+ // Cover up horizontal areas off the sides of the box rectangle
15
+ box-shadow: -$grid-unit-40 0 0 0 $white, $grid-unit-40 0 0 0 $white;
16
+ padding: $grid-unit-10;
17
+ background-color: $white;
18
+ text-align: center;
19
+ position: sticky;
20
+ // When sticking, tuck the top border beneath the modal header border
21
+ top: ($grid-unit-05 + 1) * -1;
22
+ z-index: z-index(".editor-block-manager__disabled-blocks-count");
23
+
24
+ // Stick the category titles to the bottom
25
+ ~ .editor-block-manager__results .editor-block-manager__category-title {
26
+ top: $grid-unit-40 - 1;
27
+ }
28
+ .is-link {
29
+ margin-left: 12px;
30
+ }
31
+ }
32
+
33
+ .editor-block-manager__category {
34
+ margin: 0 0 $grid-unit-30 0;
35
+ }
36
+
37
+ .editor-block-manager__category-title {
38
+ position: sticky;
39
+ top: - $grid-unit-05; // Offsets the top padding on the modal content container
40
+ padding: $grid-unit-20 0;
41
+ background-color: $white;
42
+ z-index: z-index(".editor-block-manager__category-title");
43
+
44
+ .components-checkbox-control__label {
45
+ font-weight: 600;
46
+ }
47
+ }
48
+
49
+ .editor-block-manager__checklist {
50
+ margin-top: 0;
51
+ }
52
+
53
+ .editor-block-manager__category-title,
54
+ .editor-block-manager__checklist-item {
55
+ border-bottom: 1px solid $gray-300;
56
+ }
57
+
58
+ .editor-block-manager__checklist-item {
59
+ display: flex;
60
+ justify-content: space-between;
61
+ align-items: center;
62
+ margin-bottom: 0;
63
+ padding: $grid-unit-10 0 $grid-unit-10 $grid-unit-20;
64
+
65
+ .components-modal__content &.components-checkbox-control__input-container {
66
+ margin: 0 $grid-unit-10;
67
+ }
68
+
69
+ .block-editor-block-icon {
70
+ margin-right: 10px;
71
+ fill: $gray-900;
72
+ }
73
+ }
74
+
75
+ .editor-block-manager__results {
76
+ border-top: $border-width solid $gray-300;
77
+ }
78
+
79
+ // Remove the top border from results when adjacent to the disabled block count
80
+ .editor-block-manager__disabled-blocks-count + .editor-block-manager__results {
81
+ border-top-width: 0;
82
+ }
@@ -104,8 +104,16 @@ function DocumentTools( {
104
104
  const shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );
105
105
 
106
106
  return (
107
+ // Some plugins expect and use the `edit-post-header-toolbar` CSS class to
108
+ // find the toolbar and inject UI elements into it. This is not officially
109
+ // supported, but we're keeping it in the list of class names for backwards
110
+ // compatibility.
107
111
  <NavigableToolbar
108
- className={ classnames( 'editor-document-tools', className ) }
112
+ className={ classnames(
113
+ 'editor-document-tools',
114
+ 'edit-post-header-toolbar',
115
+ className
116
+ ) }
109
117
  aria-label={ toolbarAriaLabel }
110
118
  shouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }
111
119
  variant="unstyled"
@@ -12,7 +12,7 @@ import {
12
12
  __unstableUseTypewriter as useTypewriter,
13
13
  __unstableUseTypingObserver as useTypingObserver,
14
14
  useSettings,
15
- __experimentalRecursionProvider as RecursionProvider,
15
+ RecursionProvider,
16
16
  privateApis as blockEditorPrivateApis,
17
17
  __experimentalUseResizeCanvas as useResizeCanvas,
18
18
  } from '@wordpress/block-editor';
@@ -364,7 +364,8 @@ function EditorCanvas( {
364
364
  'is-' + deviceType.toLowerCase() + '-preview',
365
365
  renderingMode !== 'post-only'
366
366
  ? 'wp-site-blocks'
367
- : `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
367
+ : `${ blockListLayoutClass } wp-block-post-content`, // Ensure root level blocks receive default/flow blockGap styling rules.
368
+ renderingMode !== 'all' && 'is-' + renderingMode
368
369
  ) }
369
370
  layout={ blockListLayout }
370
371
  dropZoneElement={