@wordpress/block-editor 12.3.4 → 12.3.6

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 (78) hide show
  1. package/README.md +4 -0
  2. package/build/components/block-edit/edit.js +25 -13
  3. package/build/components/block-edit/edit.js.map +1 -1
  4. package/build/components/block-parent-selector/index.js +8 -5
  5. package/build/components/block-parent-selector/index.js.map +1 -1
  6. package/build/components/block-removal-warning-modal/index.js +4 -1
  7. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  8. package/build/components/block-tools/block-contextual-toolbar.js +7 -11
  9. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  10. package/build/components/iframe/index.js +21 -46
  11. package/build/components/iframe/index.js.map +1 -1
  12. package/build/components/index.js +10 -1
  13. package/build/components/index.js.map +1 -1
  14. package/build/components/inserter/reusable-block-rename-hint.js +62 -0
  15. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
  16. package/build/components/inserter/reusable-blocks-tab.js +5 -1
  17. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  18. package/build/components/list-view/use-list-view-client-ids.js +2 -2
  19. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  20. package/build/components/rich-text/content.js +0 -36
  21. package/build/components/rich-text/content.js.map +1 -1
  22. package/build/components/rich-text/get-rich-text-values.js +112 -0
  23. package/build/components/rich-text/get-rich-text-values.js.map +1 -0
  24. package/build/private-apis.js +2 -2
  25. package/build/private-apis.js.map +1 -1
  26. package/build/store/private-selectors.js +5 -6
  27. package/build/store/private-selectors.js.map +1 -1
  28. package/build/store/selectors.js +6 -4
  29. package/build/store/selectors.js.map +1 -1
  30. package/build-module/components/block-edit/edit.js +27 -10
  31. package/build-module/components/block-edit/edit.js.map +1 -1
  32. package/build-module/components/block-parent-selector/index.js +7 -5
  33. package/build-module/components/block-parent-selector/index.js.map +1 -1
  34. package/build-module/components/block-removal-warning-modal/index.js +4 -1
  35. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  36. package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
  37. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  38. package/build-module/components/iframe/index.js +22 -47
  39. package/build-module/components/iframe/index.js.map +1 -1
  40. package/build-module/components/index.js +5 -0
  41. package/build-module/components/index.js.map +1 -1
  42. package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
  43. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
  44. package/build-module/components/inserter/reusable-blocks-tab.js +4 -1
  45. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  46. package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
  47. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  48. package/build-module/components/rich-text/content.js +1 -36
  49. package/build-module/components/rich-text/content.js.map +1 -1
  50. package/build-module/components/rich-text/get-rich-text-values.js +99 -0
  51. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
  52. package/build-module/private-apis.js +1 -1
  53. package/build-module/private-apis.js.map +1 -1
  54. package/build-module/store/private-selectors.js +3 -3
  55. package/build-module/store/private-selectors.js.map +1 -1
  56. package/build-module/store/selectors.js +6 -4
  57. package/build-module/store/selectors.js.map +1 -1
  58. package/build-style/style-rtl.css +71 -20
  59. package/build-style/style.css +71 -20
  60. package/package.json +9 -9
  61. package/src/components/block-edit/edit.js +26 -9
  62. package/src/components/block-edit/test/edit.js +1 -1
  63. package/src/components/block-parent-selector/index.js +13 -8
  64. package/src/components/block-removal-warning-modal/index.js +3 -0
  65. package/src/components/block-tools/block-contextual-toolbar.js +5 -11
  66. package/src/components/block-tools/style.scss +69 -26
  67. package/src/components/iframe/index.js +16 -47
  68. package/src/components/index.js +5 -0
  69. package/src/components/inserter/reusable-block-rename-hint.js +52 -0
  70. package/src/components/inserter/reusable-blocks-tab.js +4 -0
  71. package/src/components/inserter/style.scss +28 -0
  72. package/src/components/list-view/use-list-view-client-ids.js +2 -2
  73. package/src/components/rich-text/content.js +1 -46
  74. package/src/components/rich-text/get-rich-text-values.js +95 -0
  75. package/src/private-apis.js +1 -1
  76. package/src/store/private-selectors.js +3 -6
  77. package/src/store/selectors.js +9 -6
  78. package/src/store/test/private-selectors.js +5 -5
@@ -131,11 +131,11 @@
131
131
  @include break-medium() {
132
132
  &.is-fixed {
133
133
 
134
- // leave room for block inserter
135
- margin-left: $grid-unit-80;
134
+ // leave room for block inserter, undo and redo, list view
135
+ margin-left: $grid-unit-80 * 3 - 2 * $grid-unit + $grid-unit-05;
136
136
  // position on top of interface header
137
137
  position: fixed;
138
- top: $admin-bar-height + $grid-unit;
138
+ top: $admin-bar-height + $grid-unit - $border-width;
139
139
  // Don't fill up when empty
140
140
  min-height: initial;
141
141
  // remove the border
@@ -145,32 +145,63 @@
145
145
 
146
146
  &.is-collapsed {
147
147
  width: initial;
148
- margin-left: $grid-unit-80 * 3 + $grid-unit-30;
149
148
  }
150
149
 
151
150
  .is-fullscreen-mode & {
152
- // leave room for block inserter
153
- margin-left: $grid-unit-80 + $grid-unit-70;
154
- top: $grid-unit;
151
+ // leave room for block inserter, undo and redo, list view
152
+ // and some margin left
153
+ margin-left: $grid-unit-80 * 4 - 2 * $grid-unit;
154
+ top: $grid-unit - $border-width;
155
155
  &.is-collapsed {
156
156
  width: initial;
157
- margin-left: $grid-unit-80 * 4 + $grid-unit-30;
157
+ }
158
+ }
159
+
160
+ & > .block-editor-block-toolbar.is-showing-movers {
161
+ flex-grow: initial;
162
+ width: initial;
163
+
164
+ // Add a border as separator in the block toolbar.
165
+ &::before {
166
+ content: "";
167
+ width: $border-width;
168
+ height: 3 * $grid-unit;
169
+ margin-top: $grid-unit + $grid-unit-05;
170
+ margin-right: 0;
171
+ background-color: $gray-300;
172
+ position: relative;
173
+ left: math.div(-$grid-unit-05, 2);
174
+ top: -1px;
158
175
  }
159
176
  }
160
177
 
161
178
  & > .block-editor-block-toolbar__group-collapse-fixed-toolbar {
162
179
  border: none;
163
180
 
181
+ .show-icon-labels & {
182
+ .components-button.has-icon {
183
+ // Hide the button icons when labels are set to display...
184
+ svg {
185
+ display: none;
186
+ }
187
+ // ... and display labels.
188
+ &::after {
189
+ content: attr(aria-label);
190
+ font-size: $helptext-font-size;
191
+ }
192
+ }
193
+ }
194
+
164
195
  // Add a border as separator in the block toolbar.
165
- &::after {
196
+ &::before {
166
197
  content: "";
167
198
  width: $border-width;
168
- height: 24px;
199
+ height: 3 * $grid-unit;
169
200
  margin-top: $grid-unit + $grid-unit-05;
170
- margin-bottom: $grid-unit + $grid-unit-05;
201
+ margin-right: $grid-unit-10;
171
202
  background-color: $gray-300;
172
- position: absolute;
173
- left: 44px;
203
+ position: relative;
204
+ left: 0;
174
205
  top: -1px;
175
206
  }
176
207
  }
@@ -178,6 +209,21 @@
178
209
  & > .block-editor-block-toolbar__group-expand-fixed-toolbar {
179
210
  border: none;
180
211
 
212
+ .show-icon-labels & {
213
+ width: $grid-unit-80 * 4;
214
+ .components-button.has-icon {
215
+ // Hide the button icons when labels are set to display...
216
+ svg {
217
+ display: none;
218
+ }
219
+ // ... and display labels.
220
+ &::after {
221
+ content: attr(aria-label);
222
+ font-size: $helptext-font-size;
223
+ }
224
+ }
225
+ }
226
+
181
227
  // Add a border as separator in the block toolbar.
182
228
  &::before {
183
229
  content: "";
@@ -186,27 +232,20 @@
186
232
  margin-bottom: $grid-unit + $grid-unit-05;
187
233
  background-color: $gray-300;
188
234
  position: relative;
189
- left: -12px; //the padding of buttons
190
- height: 24px;
235
+ left: -8px;
236
+ height: 3 * $grid-unit;
237
+ top: -1px;
191
238
  }
192
239
  }
193
240
 
194
241
  .show-icon-labels & {
195
242
 
196
- margin-left: $grid-unit-80;
197
-
198
- &.is-collapsed {
199
- margin-left: $grid-unit-80 * 6;
200
- }
243
+ margin-left: $grid-unit-80 + 2 * $grid-unit; // inserter and margin ;
201
244
 
202
245
  .is-fullscreen-mode & {
203
- margin-left: $grid-unit-80 + $grid-unit-80;
204
- &.is-collapsed {
205
- margin-left: $grid-unit-80 * 7;
206
- }
246
+ margin-left: $grid-unit * 18; // site hub, inserter and margin
207
247
  }
208
248
 
209
-
210
249
  .block-editor-block-parent-selector .block-editor-block-parent-selector__button::after {
211
250
  left: 0;
212
251
  }
@@ -234,12 +273,14 @@
234
273
  }
235
274
 
236
275
  &.is-fixed .block-editor-block-parent-selector {
276
+
237
277
  .block-editor-block-parent-selector__button {
238
278
  position: relative;
239
279
  top: -1px;
240
280
  border: 0;
241
281
  padding-right: 6px;
242
282
  padding-left: 6px;
283
+
243
284
  &::after {
244
285
  content: "\00B7";
245
286
  font-size: 16px;
@@ -281,7 +322,9 @@
281
322
  // for the block inserter the publish button
282
323
  @include break-large() {
283
324
  &.is-fixed {
284
- width: initial;
325
+ // the combined with of the tools at the right of the header and the margin left
326
+ // of the toolbar which includes four buttons
327
+ width: calc(100% - 240px - #{4 * $grid-unit-80});
285
328
  }
286
329
  }
287
330
 
@@ -11,7 +11,6 @@ import {
11
11
  createPortal,
12
12
  forwardRef,
13
13
  useMemo,
14
- useReducer,
15
14
  useEffect,
16
15
  } from '@wordpress/element';
17
16
  import { __ } from '@wordpress/i18n';
@@ -78,29 +77,6 @@ function bubbleEvents( doc ) {
78
77
  }
79
78
  }
80
79
 
81
- function useParsedAssets( html ) {
82
- return useMemo( () => {
83
- const doc = document.implementation.createHTMLDocument( '' );
84
- doc.body.innerHTML = html;
85
- return Array.from( doc.body.children );
86
- }, [ html ] );
87
- }
88
-
89
- async function loadScript( head, { id, src } ) {
90
- return new Promise( ( resolve, reject ) => {
91
- const script = head.ownerDocument.createElement( 'script' );
92
- script.id = id;
93
- if ( src ) {
94
- script.src = src;
95
- script.onload = () => resolve();
96
- script.onerror = () => reject();
97
- } else {
98
- resolve();
99
- }
100
- head.appendChild( script );
101
- } );
102
- }
103
-
104
80
  function Iframe( {
105
81
  contentRef,
106
82
  children,
@@ -112,21 +88,22 @@ function Iframe( {
112
88
  forwardedRef: ref,
113
89
  ...props
114
90
  } ) {
115
- const assets = useSelect(
91
+ const { styles = '', scripts = '' } = useSelect(
116
92
  ( select ) =>
117
93
  select( blockEditorStore ).getSettings().__unstableResolvedAssets,
118
94
  []
119
95
  );
120
- const [ , forceRender ] = useReducer( () => ( {} ) );
121
96
  const [ iframeDocument, setIframeDocument ] = useState();
122
97
  const [ bodyClasses, setBodyClasses ] = useState( [] );
123
98
  const compatStyles = useCompatibilityStyles();
124
- const scripts = useParsedAssets( assets?.scripts );
125
99
  const clearerRef = useBlockSelectionClearer();
126
100
  const [ before, writingFlowRef, after ] = useWritingFlow();
127
101
  const [ contentResizeListener, { height: contentHeight } ] =
128
102
  useResizeObserver();
129
103
  const setRef = useRefEffect( ( node ) => {
104
+ node._load = () => {
105
+ setIframeDocument( node.contentDocument );
106
+ };
130
107
  let iFrameDocument;
131
108
  // Prevent the default browser action for files dropped outside of dropzones.
132
109
  function preventFileDropDefault( event ) {
@@ -138,7 +115,6 @@ function Iframe( {
138
115
  iFrameDocument = contentDocument;
139
116
 
140
117
  bubbleEvents( contentDocument );
141
- setIframeDocument( contentDocument );
142
118
  clearerRef( documentElement );
143
119
 
144
120
  // Ideally ALL classes that are added through get_body_class should
@@ -154,7 +130,6 @@ function Iframe( {
154
130
  );
155
131
 
156
132
  contentDocument.dir = ownerDocument.dir;
157
- documentElement.removeChild( contentDocument.body );
158
133
 
159
134
  for ( const compatStyle of compatStyles ) {
160
135
  if ( contentDocument.getElementById( compatStyle.id ) ) {
@@ -199,35 +174,29 @@ function Iframe( {
199
174
  };
200
175
  }, [] );
201
176
 
202
- const headRef = useRefEffect( ( element ) => {
203
- scripts
204
- .reduce(
205
- ( promise, script ) =>
206
- promise.then( () => loadScript( element, script ) ),
207
- Promise.resolve()
208
- )
209
- .finally( () => {
210
- // When script are loaded, re-render blocks to allow them
211
- // to initialise.
212
- forceRender();
213
- } );
214
- }, [] );
215
177
  const disabledRef = useDisabled( { isDisabled: ! readonly } );
216
178
  const bodyRef = useMergeRefs( [
217
179
  contentRef,
218
180
  clearerRef,
219
181
  writingFlowRef,
220
182
  disabledRef,
221
- headRef,
222
183
  ] );
223
184
 
224
185
  // Correct doctype is required to enable rendering in standards
225
186
  // mode. Also preload the styles to avoid a flash of unstyled
226
187
  // content.
227
- const html =
228
- '<!doctype html>' +
229
- '<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>' +
230
- ( assets?.styles ?? '' );
188
+ const html = `<!doctype html>
189
+ <html>
190
+ <head>
191
+ <script>window.frameElement._load()</script>
192
+ <style>html{height:auto!important;min-height:100%;}body{margin:0}</style>
193
+ ${ styles }
194
+ ${ scripts }
195
+ </head>
196
+ <body>
197
+ <script>document.currentScript.parentElement.remove()</script>
198
+ </body>
199
+ </html>`;
231
200
 
232
201
  const [ src, cleanup ] = useMemo( () => {
233
202
  const _src = URL.createObjectURL(
@@ -164,3 +164,8 @@ export { default as __experimentalInspectorPopoverHeader } from './inspector-pop
164
164
 
165
165
  export { default as BlockEditorProvider } from './provider';
166
166
  export { default as useSetting } from './use-setting';
167
+
168
+ /*
169
+ * The following rename hint component can be removed in 6.4.
170
+ */
171
+ export { default as ReusableBlocksRenameHint } from './inserter/reusable-block-rename-hint';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Button } from '@wordpress/components';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
6
+ import { focus } from '@wordpress/dom';
7
+ import { useRef } from '@wordpress/element';
8
+ import { __ } from '@wordpress/i18n';
9
+ import { close } from '@wordpress/icons';
10
+ import { store as preferencesStore } from '@wordpress/preferences';
11
+
12
+ const PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';
13
+
14
+ export default function ReusableBlocksRenameHint() {
15
+ const isReusableBlocksRenameHint = useSelect(
16
+ ( select ) =>
17
+ select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,
18
+ []
19
+ );
20
+
21
+ const ref = useRef();
22
+
23
+ const { set: setPreference } = useDispatch( preferencesStore );
24
+ if ( ! isReusableBlocksRenameHint ) {
25
+ return null;
26
+ }
27
+
28
+ return (
29
+ <div ref={ ref } className="reusable-blocks-menu-items__rename-hint">
30
+ <div className="reusable-blocks-menu-items__rename-hint-content">
31
+ { __(
32
+ 'Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.'
33
+ ) }
34
+ </div>
35
+ <Button
36
+ className="reusable-blocks-menu-items__rename-hint-dismiss"
37
+ icon={ close }
38
+ iconSize="16"
39
+ label={ __( 'Dismiss hint' ) }
40
+ onClick={ () => {
41
+ // Retain focus when dismissing the element.
42
+ const previousElement = focus.tabbable.findPrevious(
43
+ ref.current
44
+ );
45
+ previousElement?.focus();
46
+ setPreference( 'core', PREFERENCE_NAME, false );
47
+ } }
48
+ showTooltip={ false }
49
+ />
50
+ </div>
51
+ );
52
+ }
@@ -13,6 +13,7 @@ import BlockTypesList from '../block-types-list';
13
13
  import InserterPanel from './panel';
14
14
  import InserterNoResults from './no-results';
15
15
  import useBlockTypesState from './hooks/use-block-types-state';
16
+ import ReusableBlocksRenameHint from './reusable-block-rename-hint';
16
17
 
17
18
  function ReusableBlocksList( { onHover, onInsert, rootClientId } ) {
18
19
  const [ items, , , onSelectItem ] = useBlockTypesState(
@@ -54,6 +55,9 @@ function ReusableBlocksList( { onHover, onInsert, rootClientId } ) {
54
55
  export function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {
55
56
  return (
56
57
  <>
58
+ <div className="block-editor-inserter__hint">
59
+ <ReusableBlocksRenameHint />
60
+ </div>
57
61
  <ReusableBlocksList
58
62
  onHover={ onHover }
59
63
  onInsert={ onInsert }
@@ -711,3 +711,31 @@ $block-inserter-tabs-height: 44px;
711
711
  margin: 0;
712
712
  }
713
713
  }
714
+
715
+ .block-editor-inserter__hint {
716
+ margin: $grid-unit-20 $grid-unit-20 0;
717
+ }
718
+
719
+ .reusable-blocks-menu-items__rename-hint {
720
+ align-items: top;
721
+ background: $gray-100;
722
+ border-radius: $radius-block-ui;
723
+ color: $gray-900;
724
+ display: flex;
725
+ flex-direction: row;
726
+ max-width: 380px;
727
+ }
728
+
729
+ .reusable-blocks-menu-items__rename-hint-content {
730
+ margin: $grid-unit-15 0 $grid-unit-15 $grid-unit-15;
731
+ }
732
+
733
+ .reusable-blocks-menu-items__rename-hint-dismiss {
734
+ // The dismiss button has a lot of empty space through its padding.
735
+ // Apply margin to visually align the icon with the top of the text to its left.
736
+ margin: $grid-unit-05 $grid-unit-05 $grid-unit-05 0;
737
+ }
738
+
739
+ .components-menu-group .reusable-blocks-menu-items__rename-hint {
740
+ margin: 0;
741
+ }
@@ -16,14 +16,14 @@ export default function useListViewClientIds( { blocks, rootClientId } ) {
16
16
  const {
17
17
  getDraggedBlockClientIds,
18
18
  getSelectedBlockClientIds,
19
- getListViewClientIdsTree,
19
+ getEnabledClientIdsTree,
20
20
  } = unlock( select( blockEditorStore ) );
21
21
 
22
22
  return {
23
23
  selectedClientIds: getSelectedBlockClientIds(),
24
24
  draggedClientIds: getDraggedBlockClientIds(),
25
25
  clientIdsTree:
26
- blocks ?? getListViewClientIdsTree( rootClientId ),
26
+ blocks ?? getEnabledClientIdsTree( rootClientId ),
27
27
  };
28
28
  },
29
29
  [ blocks, rootClientId ]
@@ -2,11 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { RawHTML } from '@wordpress/element';
5
- import {
6
- children as childrenSource,
7
- getSaveElement,
8
- __unstableGetBlockProps as getBlockProps,
9
- } from '@wordpress/blocks';
5
+ import { children as childrenSource } from '@wordpress/blocks';
10
6
  import deprecated from '@wordpress/deprecated';
11
7
 
12
8
  /**
@@ -42,44 +38,3 @@ export const Content = ( { value, tagName: Tag, multiline, ...props } ) => {
42
38
 
43
39
  return content;
44
40
  };
45
-
46
- Content.__unstableIsRichTextContent = {};
47
-
48
- function findContent( blocks, richTextValues = [] ) {
49
- if ( ! Array.isArray( blocks ) ) {
50
- blocks = [ blocks ];
51
- }
52
-
53
- for ( const block of blocks ) {
54
- if (
55
- block?.type?.__unstableIsRichTextContent ===
56
- Content.__unstableIsRichTextContent
57
- ) {
58
- richTextValues.push( block.props.value );
59
- continue;
60
- }
61
-
62
- if ( block?.props?.children ) {
63
- findContent( block.props.children, richTextValues );
64
- }
65
- }
66
-
67
- return richTextValues;
68
- }
69
-
70
- function _getSaveElement( { name, attributes, innerBlocks } ) {
71
- return getSaveElement(
72
- name,
73
- attributes,
74
- innerBlocks.map( _getSaveElement )
75
- );
76
- }
77
-
78
- export function getRichTextValues( blocks = [] ) {
79
- getBlockProps.skipFilters = true;
80
- const values = findContent(
81
- ( Array.isArray( blocks ) ? blocks : [ blocks ] ).map( _getSaveElement )
82
- );
83
- getBlockProps.skipFilters = false;
84
- return values;
85
- }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { RawHTML, StrictMode, Fragment } from '@wordpress/element';
5
+ import {
6
+ getSaveElement,
7
+ __unstableGetBlockProps as getBlockProps,
8
+ } from '@wordpress/blocks';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import InnerBlocks from '../inner-blocks';
14
+ import { Content } from './content';
15
+
16
+ /*
17
+ * This function is similar to `@wordpress/element`'s `renderToString` function,
18
+ * except that it does not render the elements to a string, but instead collects
19
+ * the values of all rich text `Content` elements.
20
+ */
21
+ function addValuesForElement( element, ...args ) {
22
+ if ( null === element || undefined === element || false === element ) {
23
+ return;
24
+ }
25
+
26
+ if ( Array.isArray( element ) ) {
27
+ return addValuesForElements( element, ...args );
28
+ }
29
+
30
+ switch ( typeof element ) {
31
+ case 'string':
32
+ case 'number':
33
+ return;
34
+ }
35
+
36
+ const { type, props } = element;
37
+
38
+ switch ( type ) {
39
+ case StrictMode:
40
+ case Fragment:
41
+ return addValuesForElements( props.children, ...args );
42
+ case RawHTML:
43
+ return;
44
+ case InnerBlocks.Content:
45
+ return addValuesForBlocks( ...args );
46
+ case Content:
47
+ const [ values ] = args;
48
+ values.push( props.value );
49
+ return;
50
+ }
51
+
52
+ switch ( typeof type ) {
53
+ case 'string':
54
+ if ( typeof props.children !== 'undefined' ) {
55
+ return addValuesForElements( props.children, ...args );
56
+ }
57
+ return;
58
+ case 'function':
59
+ if (
60
+ type.prototype &&
61
+ typeof type.prototype.render === 'function'
62
+ ) {
63
+ return addValuesForElement(
64
+ new type( props ).render(),
65
+ ...args
66
+ );
67
+ }
68
+
69
+ return addValuesForElement( type( props ), ...args );
70
+ }
71
+ }
72
+
73
+ function addValuesForElements( children, ...args ) {
74
+ children = Array.isArray( children ) ? children : [ children ];
75
+
76
+ for ( let i = 0; i < children.length; i++ ) {
77
+ addValuesForElement( children[ i ], ...args );
78
+ }
79
+ }
80
+
81
+ function addValuesForBlocks( values, blocks ) {
82
+ for ( let i = 0; i < blocks.length; i++ ) {
83
+ const { name, attributes, innerBlocks } = blocks[ i ];
84
+ const saveElement = getSaveElement( name, attributes );
85
+ addValuesForElement( saveElement, values, innerBlocks );
86
+ }
87
+ }
88
+
89
+ export function getRichTextValues( blocks = [] ) {
90
+ getBlockProps.skipFilters = true;
91
+ const values = [];
92
+ addValuesForBlocks( values, blocks );
93
+ getBlockProps.skipFilters = false;
94
+ return values;
95
+ }
@@ -4,7 +4,7 @@
4
4
  import * as globalStyles from './components/global-styles';
5
5
  import { ExperimentalBlockEditorProvider } from './components/provider';
6
6
  import { lock } from './lock-unlock';
7
- import { getRichTextValues } from './components/rich-text/content';
7
+ import { getRichTextValues } from './components/rich-text/get-rich-text-values';
8
8
  import ResizableBoxPopover from './components/resizable-box-popover';
9
9
  import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
10
10
  import { PrivateListView } from './components/list-view';
@@ -136,21 +136,18 @@ export const isBlockSubtreeDisabled = createSelector(
136
136
  *
137
137
  * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
138
138
  */
139
- export const getListViewClientIdsTree = createSelector(
139
+ export const getEnabledClientIdsTree = createSelector(
140
140
  ( state, rootClientId = '' ) => {
141
141
  return getBlockOrder( state, rootClientId ).flatMap( ( clientId ) => {
142
142
  if ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {
143
143
  return [
144
144
  {
145
145
  clientId,
146
- innerBlocks: getListViewClientIdsTree(
147
- state,
148
- clientId
149
- ),
146
+ innerBlocks: getEnabledClientIdsTree( state, clientId ),
150
147
  },
151
148
  ];
152
149
  }
153
- return getListViewClientIdsTree( state, clientId );
150
+ return getEnabledClientIdsTree( state, clientId );
154
151
  } );
155
152
  },
156
153
  ( state ) => [
@@ -2034,11 +2034,13 @@ export const getInserterItems = createSelector(
2034
2034
  ? getReusableBlocks( state )
2035
2035
  .filter(
2036
2036
  ( reusableBlock ) =>
2037
- // Filter to either fully synced patterns (sync_status === 'fully'),
2038
- // or old school reusable blocks (sync_status === '').
2039
- reusableBlock.meta?.sync_status === 'fully' ||
2040
- reusableBlock.meta?.sync_status === '' ||
2041
- ! reusableBlock.meta?.sync_status
2037
+ // Reusable blocks that are fully synced should have no sync status set
2038
+ // for backwards compat between patterns and old reusable blocks, but
2039
+ // some in release 16.1 may have had sync status inadvertantly set to
2040
+ // 'fully' if created in the site editor.
2041
+ reusableBlock.wp_pattern_sync_status === 'fully' ||
2042
+ reusableBlock.wp_pattern_sync_status === '' ||
2043
+ ! reusableBlock.wp_pattern_sync_status
2042
2044
  )
2043
2045
  .map( buildReusableBlockInserterItem )
2044
2046
  : [];
@@ -2313,7 +2315,8 @@ function getUnsyncedPatterns( state ) {
2313
2315
 
2314
2316
  return reusableBlocks
2315
2317
  .filter(
2316
- ( reusableBlock ) => reusableBlock.meta?.sync_status === 'unsynced'
2318
+ ( reusableBlock ) =>
2319
+ reusableBlock.wp_pattern_sync_status === 'unsynced'
2317
2320
  )
2318
2321
  .map( ( reusableBlock ) => {
2319
2322
  return {
@@ -11,7 +11,7 @@ import {
11
11
  getLastInsertedBlocksClientIds,
12
12
  getBlockEditingMode,
13
13
  isBlockSubtreeDisabled,
14
- getListViewClientIdsTree,
14
+ getEnabledClientIdsTree,
15
15
  getEnabledBlockParents,
16
16
  } from '../private-selectors';
17
17
 
@@ -391,7 +391,7 @@ describe( 'private selectors', () => {
391
391
  } );
392
392
  } );
393
393
 
394
- describe( 'getListViewClientIdsTree', () => {
394
+ describe( 'getEnabledClientIdsTree', () => {
395
395
  const baseState = {
396
396
  settings: {},
397
397
  blocks: {
@@ -462,7 +462,7 @@ describe( 'private selectors', () => {
462
462
  ...baseState,
463
463
  blockEditingModes: new Map( [] ),
464
464
  };
465
- expect( getListViewClientIdsTree( state ) ).toEqual( [
465
+ expect( getEnabledClientIdsTree( state ) ).toEqual( [
466
466
  {
467
467
  clientId: '6cf70164-9097-4460-bcbf-200560546988',
468
468
  innerBlocks: [],
@@ -500,7 +500,7 @@ describe( 'private selectors', () => {
500
500
  blockEditingModes: new Map( [] ),
501
501
  };
502
502
  expect(
503
- getListViewClientIdsTree(
503
+ getEnabledClientIdsTree(
504
504
  state,
505
505
  'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337'
506
506
  )
@@ -534,7 +534,7 @@ describe( 'private selectors', () => {
534
534
  [ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'contentOnly' ],
535
535
  ] ),
536
536
  };
537
- expect( getListViewClientIdsTree( state ) ).toEqual( [
537
+ expect( getEnabledClientIdsTree( state ) ).toEqual( [
538
538
  {
539
539
  clientId: 'b26fc763-417d-4f01-b81c-2ec61e14a972',
540
540
  innerBlocks: [],