@wordpress/editor 13.30.0 → 13.32.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 (219) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +857 -0
  3. package/build/bindings/index.js +3 -1
  4. package/build/bindings/index.js.map +1 -1
  5. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +107 -0
  6. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
  7. package/build/components/commands/index.js +1 -1
  8. package/build/components/commands/index.js.map +1 -1
  9. package/build/components/deprecated.js +158 -0
  10. package/build/components/deprecated.js.map +1 -1
  11. package/build/components/document-bar/index.js +7 -10
  12. package/build/components/document-bar/index.js.map +1 -1
  13. package/build/components/document-outline/index.js +1 -1
  14. package/build/components/document-outline/index.js.map +1 -1
  15. package/build/components/editor-canvas/edit-template-blocks-notification.js +2 -39
  16. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  17. package/build/components/editor-canvas/index.js +3 -0
  18. package/build/components/editor-canvas/index.js.map +1 -1
  19. package/build/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
  20. package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  21. package/build/components/entities-saved-states/index.js +28 -88
  22. package/build/components/entities-saved-states/index.js.map +1 -1
  23. package/build/components/error-boundary/index.native.js +133 -0
  24. package/build/components/error-boundary/index.native.js.map +1 -0
  25. package/build/components/index.js +33 -8
  26. package/build/components/index.js.map +1 -1
  27. package/build/components/index.native.js +9 -1
  28. package/build/components/index.native.js.map +1 -1
  29. package/build/components/inserter-sidebar/index.js +5 -1
  30. package/build/components/inserter-sidebar/index.js.map +1 -1
  31. package/build/components/list-view-sidebar/index.js +2 -1
  32. package/build/components/list-view-sidebar/index.js.map +1 -1
  33. package/build/components/pattern-overrides-panel/index.js +30 -0
  34. package/build/components/pattern-overrides-panel/index.js.map +1 -0
  35. package/build/components/plugin-document-setting-panel/index.js +123 -0
  36. package/build/components/plugin-document-setting-panel/index.js.map +1 -0
  37. package/build/components/plugin-post-publish-panel/index.js +68 -0
  38. package/build/components/plugin-post-publish-panel/index.js.map +1 -0
  39. package/build/components/plugin-pre-publish-panel/index.js +71 -0
  40. package/build/components/plugin-pre-publish-panel/index.js.map +1 -0
  41. package/build/components/post-actions/actions.js +455 -0
  42. package/build/components/post-actions/actions.js.map +1 -0
  43. package/build/components/post-card-panel/index.js +93 -0
  44. package/build/components/post-card-panel/index.js.map +1 -0
  45. package/build/components/post-featured-image/index.js +3 -8
  46. package/build/components/post-featured-image/index.js.map +1 -1
  47. package/build/components/post-featured-image/panel.js +7 -3
  48. package/build/components/post-featured-image/panel.js.map +1 -1
  49. package/build/components/post-sync-status/index.js +0 -72
  50. package/build/components/post-sync-status/index.js.map +1 -1
  51. package/build/components/post-taxonomies/flat-term-selector.js +7 -3
  52. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  53. package/build/components/post-title/index.native.js +1 -1
  54. package/build/components/post-title/index.native.js.map +1 -1
  55. package/build/components/provider/disable-non-page-content-blocks.js +36 -20
  56. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  57. package/build/components/provider/index.js +1 -1
  58. package/build/components/provider/index.js.map +1 -1
  59. package/build/components/provider/use-block-editor-settings.js +8 -9
  60. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  61. package/build/components/provider/use-hide-blocks-from-inserter.js +4 -3
  62. package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
  63. package/build/components/template-areas/index.js +70 -0
  64. package/build/components/template-areas/index.js.map +1 -0
  65. package/build/hooks/use-select-nearest-editable-block.js +87 -0
  66. package/build/hooks/use-select-nearest-editable-block.js.map +1 -0
  67. package/build/private-apis.js +6 -2
  68. package/build/private-apis.js.map +1 -1
  69. package/build/store/actions.js +46 -6
  70. package/build/store/actions.js.map +1 -1
  71. package/build/store/constants.js +3 -1
  72. package/build/store/constants.js.map +1 -1
  73. package/build/store/private-actions.js +80 -1
  74. package/build/store/private-actions.js.map +1 -1
  75. package/build/store/private-selectors.js +56 -3
  76. package/build/store/private-selectors.js.map +1 -1
  77. package/build/store/reducer.js +14 -1
  78. package/build/store/reducer.js.map +1 -1
  79. package/build/store/selectors.js +21 -11
  80. package/build/store/selectors.js.map +1 -1
  81. package/build/store/utils/get-filtered-template-parts.js +71 -0
  82. package/build/store/utils/get-filtered-template-parts.js.map +1 -0
  83. package/build-module/bindings/index.js +3 -1
  84. package/build-module/bindings/index.js.map +1 -1
  85. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +100 -0
  86. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
  87. package/build-module/components/commands/index.js +1 -1
  88. package/build-module/components/commands/index.js.map +1 -1
  89. package/build-module/components/deprecated.js +159 -0
  90. package/build-module/components/deprecated.js.map +1 -1
  91. package/build-module/components/document-bar/index.js +8 -11
  92. package/build-module/components/document-bar/index.js.map +1 -1
  93. package/build-module/components/document-outline/index.js +1 -1
  94. package/build-module/components/document-outline/index.js.map +1 -1
  95. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +4 -41
  96. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  97. package/build-module/components/editor-canvas/index.js +3 -0
  98. package/build-module/components/editor-canvas/index.js.map +1 -1
  99. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
  100. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  101. package/build-module/components/entities-saved-states/index.js +29 -89
  102. package/build-module/components/entities-saved-states/index.js.map +1 -1
  103. package/build-module/components/error-boundary/index.native.js +125 -0
  104. package/build-module/components/error-boundary/index.native.js.map +1 -0
  105. package/build-module/components/index.js +5 -1
  106. package/build-module/components/index.js.map +1 -1
  107. package/build-module/components/index.native.js +1 -0
  108. package/build-module/components/index.native.js.map +1 -1
  109. package/build-module/components/inserter-sidebar/index.js +5 -1
  110. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  111. package/build-module/components/list-view-sidebar/index.js +2 -1
  112. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  113. package/build-module/components/pattern-overrides-panel/index.js +23 -0
  114. package/build-module/components/pattern-overrides-panel/index.js.map +1 -0
  115. package/build-module/components/plugin-document-setting-panel/index.js +115 -0
  116. package/build-module/components/plugin-document-setting-panel/index.js.map +1 -0
  117. package/build-module/components/plugin-post-publish-panel/index.js +61 -0
  118. package/build-module/components/plugin-post-publish-panel/index.js.map +1 -0
  119. package/build-module/components/plugin-pre-publish-panel/index.js +64 -0
  120. package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -0
  121. package/build-module/components/post-actions/actions.js +444 -0
  122. package/build-module/components/post-actions/actions.js.map +1 -0
  123. package/build-module/components/post-card-panel/index.js +85 -0
  124. package/build-module/components/post-card-panel/index.js.map +1 -0
  125. package/build-module/components/post-featured-image/index.js +4 -9
  126. package/build-module/components/post-featured-image/index.js.map +1 -1
  127. package/build-module/components/post-featured-image/panel.js +6 -2
  128. package/build-module/components/post-featured-image/panel.js.map +1 -1
  129. package/build-module/components/post-sync-status/index.js +2 -73
  130. package/build-module/components/post-sync-status/index.js.map +1 -1
  131. package/build-module/components/post-taxonomies/flat-term-selector.js +7 -3
  132. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  133. package/build-module/components/post-title/index.native.js +1 -1
  134. package/build-module/components/post-title/index.native.js.map +1 -1
  135. package/build-module/components/provider/disable-non-page-content-blocks.js +36 -20
  136. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  137. package/build-module/components/provider/index.js +1 -1
  138. package/build-module/components/provider/index.js.map +1 -1
  139. package/build-module/components/provider/use-block-editor-settings.js +9 -10
  140. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  141. package/build-module/components/provider/use-hide-blocks-from-inserter.js +4 -3
  142. package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
  143. package/build-module/components/template-areas/index.js +63 -0
  144. package/build-module/components/template-areas/index.js.map +1 -0
  145. package/build-module/hooks/use-select-nearest-editable-block.js +80 -0
  146. package/build-module/hooks/use-select-nearest-editable-block.js.map +1 -0
  147. package/build-module/private-apis.js +6 -2
  148. package/build-module/private-apis.js.map +1 -1
  149. package/build-module/store/actions.js +37 -3
  150. package/build-module/store/actions.js.map +1 -1
  151. package/build-module/store/constants.js +2 -0
  152. package/build-module/store/constants.js.map +1 -1
  153. package/build-module/store/private-actions.js +78 -0
  154. package/build-module/store/private-actions.js.map +1 -1
  155. package/build-module/store/private-selectors.js +54 -3
  156. package/build-module/store/private-selectors.js.map +1 -1
  157. package/build-module/store/reducer.js +13 -1
  158. package/build-module/store/reducer.js.map +1 -1
  159. package/build-module/store/selectors.js +19 -10
  160. package/build-module/store/selectors.js.map +1 -1
  161. package/build-module/store/utils/get-filtered-template-parts.js +64 -0
  162. package/build-module/store/utils/get-filtered-template-parts.js.map +1 -0
  163. package/build-style/style-rtl.css +76 -33
  164. package/build-style/style.css +76 -33
  165. package/package.json +35 -33
  166. package/src/bindings/index.js +4 -1
  167. package/src/components/block-settings-menu/plugin-block-settings-menu-item.js +108 -0
  168. package/src/components/commands/index.js +1 -1
  169. package/src/components/deprecated.js +157 -0
  170. package/src/components/document-bar/index.js +12 -17
  171. package/src/components/document-bar/style.scss +9 -12
  172. package/src/components/document-outline/index.js +2 -1
  173. package/src/components/document-tools/style.scss +4 -11
  174. package/src/components/editor-canvas/edit-template-blocks-notification.js +6 -56
  175. package/src/components/editor-canvas/index.js +4 -0
  176. package/src/components/entities-saved-states/hooks/use-is-dirty.js +18 -22
  177. package/src/components/entities-saved-states/index.js +45 -121
  178. package/src/components/entities-saved-states/test/use-is-dirty.js +3 -0
  179. package/src/components/error-boundary/index.native.js +192 -0
  180. package/src/components/error-boundary/style.native.scss +116 -0
  181. package/src/components/index.js +5 -4
  182. package/src/components/index.native.js +1 -0
  183. package/src/components/inserter-sidebar/index.js +7 -1
  184. package/src/components/list-view-sidebar/index.js +1 -0
  185. package/src/components/list-view-sidebar/style.scss +1 -1
  186. package/src/components/pattern-overrides-panel/index.js +26 -0
  187. package/src/components/plugin-document-setting-panel/index.js +121 -0
  188. package/src/components/plugin-post-publish-panel/index.js +64 -0
  189. package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +39 -0
  190. package/src/components/plugin-post-publish-panel/test/index.js +33 -0
  191. package/src/components/plugin-pre-publish-panel/index.js +67 -0
  192. package/src/components/plugin-pre-publish-panel/test/index.js +33 -0
  193. package/src/components/post-actions/actions.js +582 -0
  194. package/src/components/post-card-panel/index.js +108 -0
  195. package/src/components/post-card-panel/style.scss +32 -0
  196. package/src/components/post-featured-image/index.js +6 -15
  197. package/src/components/post-featured-image/panel.js +9 -3
  198. package/src/components/post-featured-image/style.scss +9 -13
  199. package/src/components/post-sync-status/index.js +1 -94
  200. package/src/components/post-taxonomies/flat-term-selector.js +13 -8
  201. package/src/components/post-title/index.native.js +1 -1
  202. package/src/components/provider/disable-non-page-content-blocks.js +40 -20
  203. package/src/components/provider/index.js +1 -1
  204. package/src/components/provider/test/disable-non-page-content-blocks.js +35 -14
  205. package/src/components/provider/use-block-editor-settings.js +11 -11
  206. package/src/components/provider/use-hide-blocks-from-inserter.js +5 -3
  207. package/src/components/template-areas/index.js +85 -0
  208. package/src/components/template-areas/style.scss +23 -0
  209. package/src/hooks/use-select-nearest-editable-block.js +95 -0
  210. package/src/private-apis.js +6 -2
  211. package/src/store/actions.js +37 -3
  212. package/src/store/constants.js +2 -0
  213. package/src/store/private-actions.js +111 -0
  214. package/src/store/private-selectors.js +105 -17
  215. package/src/store/reducer.js +13 -0
  216. package/src/store/selectors.js +50 -40
  217. package/src/store/utils/get-filtered-template-parts.js +69 -0
  218. package/src/store/utils/test/get-filtered-template-parts.js +189 -0
  219. package/src/style.scss +2 -0
@@ -0,0 +1,69 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import memoize from 'memize';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { isTemplatePart } from '@wordpress/blocks';
10
+
11
+ const EMPTY_ARRAY = [];
12
+
13
+ /**
14
+ * Get a flattened and filtered list of template parts and the matching block for that template part.
15
+ *
16
+ * Takes a list of blocks defined within a template, and a list of template parts, and returns a
17
+ * flattened list of template parts and the matching block for that template part.
18
+ *
19
+ * @param {Array} blocks Blocks to flatten.
20
+ * @param {?Array} templateParts Available template parts.
21
+ * @return {Array} An array of template parts and their blocks.
22
+ */
23
+ function getFilteredTemplatePartBlocks( blocks = EMPTY_ARRAY, templateParts ) {
24
+ const templatePartsById = templateParts
25
+ ? // Key template parts by their ID.
26
+ templateParts.reduce(
27
+ ( newTemplateParts, part ) => ( {
28
+ ...newTemplateParts,
29
+ [ part.id ]: part,
30
+ } ),
31
+ {}
32
+ )
33
+ : {};
34
+
35
+ const result = [];
36
+
37
+ // Iterate over all blocks, recursing into inner blocks.
38
+ // Output will be based on a depth-first traversal.
39
+ const stack = [ ...blocks ];
40
+ while ( stack.length ) {
41
+ const { innerBlocks, ...block } = stack.shift();
42
+ // Place inner blocks at the beginning of the stack to preserve order.
43
+ stack.unshift( ...innerBlocks );
44
+
45
+ if ( isTemplatePart( block ) ) {
46
+ const {
47
+ attributes: { theme, slug },
48
+ } = block;
49
+ const templatePartId = `${ theme }//${ slug }`;
50
+ const templatePart = templatePartsById[ templatePartId ];
51
+
52
+ // Only add to output if the found template part block is in the list of available template parts.
53
+ if ( templatePart ) {
54
+ result.push( {
55
+ templatePart,
56
+ block,
57
+ } );
58
+ }
59
+ }
60
+ }
61
+
62
+ return result;
63
+ }
64
+
65
+ const memoizedGetFilteredTemplatePartBlocks = memoize(
66
+ getFilteredTemplatePartBlocks
67
+ );
68
+
69
+ export { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { getFilteredTemplatePartBlocks } from '../get-filtered-template-parts';
5
+
6
+ const NESTED_BLOCKS = [
7
+ {
8
+ clientId: '1',
9
+ name: 'core/group',
10
+ innerBlocks: [
11
+ {
12
+ clientId: '2',
13
+ name: 'core/template-part',
14
+ attributes: {
15
+ slug: 'header',
16
+ theme: 'my-theme',
17
+ },
18
+ innerBlocks: [
19
+ {
20
+ clientId: '3',
21
+ name: 'core/group',
22
+ innerBlocks: [],
23
+ },
24
+ ],
25
+ },
26
+ {
27
+ clientId: '4',
28
+ name: 'core/template-part',
29
+ attributes: {
30
+ slug: 'aside',
31
+ theme: 'my-theme',
32
+ },
33
+ innerBlocks: [],
34
+ },
35
+ ],
36
+ },
37
+ {
38
+ clientId: '5',
39
+ name: 'core/paragraph',
40
+ innerBlocks: [],
41
+ },
42
+ {
43
+ clientId: '6',
44
+ name: 'core/template-part',
45
+ attributes: {
46
+ slug: 'footer',
47
+ theme: 'my-theme',
48
+ },
49
+ innerBlocks: [],
50
+ },
51
+ ];
52
+
53
+ const FLATTENED_BLOCKS = [
54
+ {
55
+ block: {
56
+ clientId: '2',
57
+ name: 'core/template-part',
58
+ attributes: {
59
+ slug: 'header',
60
+ theme: 'my-theme',
61
+ },
62
+ },
63
+ templatePart: {
64
+ id: 'my-theme//header',
65
+ slug: 'header',
66
+ theme: 'my-theme',
67
+ },
68
+ },
69
+ {
70
+ block: {
71
+ clientId: '4',
72
+ name: 'core/template-part',
73
+ attributes: {
74
+ slug: 'aside',
75
+ theme: 'my-theme',
76
+ },
77
+ },
78
+ templatePart: {
79
+ id: 'my-theme//aside',
80
+ slug: 'aside',
81
+ theme: 'my-theme',
82
+ },
83
+ },
84
+ {
85
+ block: {
86
+ clientId: '6',
87
+ name: 'core/template-part',
88
+ attributes: {
89
+ slug: 'footer',
90
+ theme: 'my-theme',
91
+ },
92
+ },
93
+ templatePart: {
94
+ id: 'my-theme//footer',
95
+ slug: 'footer',
96
+ theme: 'my-theme',
97
+ },
98
+ },
99
+ ];
100
+
101
+ const SINGLE_TEMPLATE_PART_BLOCK = {
102
+ clientId: '1',
103
+ name: 'core/template-part',
104
+ innerBlocks: [],
105
+ attributes: {
106
+ slug: 'aside',
107
+ theme: 'my-theme',
108
+ },
109
+ };
110
+
111
+ const TEMPLATE_PARTS = [
112
+ {
113
+ id: 'my-theme//header',
114
+ slug: 'header',
115
+ theme: 'my-theme',
116
+ },
117
+ {
118
+ id: 'my-theme//aside',
119
+ slug: 'aside',
120
+ theme: 'my-theme',
121
+ },
122
+ {
123
+ id: 'my-theme//footer',
124
+ slug: 'footer',
125
+ theme: 'my-theme',
126
+ },
127
+ ];
128
+
129
+ describe( 'getFilteredTemplatePartBlocks', () => {
130
+ it( 'returns a flattened list of filtered template parts preserving a depth-first order', () => {
131
+ const flattenedFilteredTemplateParts = getFilteredTemplatePartBlocks(
132
+ NESTED_BLOCKS,
133
+ TEMPLATE_PARTS
134
+ );
135
+ expect( flattenedFilteredTemplateParts ).toEqual( FLATTENED_BLOCKS );
136
+ } );
137
+
138
+ it( 'returns a cached result when passed the same params', () => {
139
+ // Clear the cache and call the function twice.
140
+ getFilteredTemplatePartBlocks.clear();
141
+ getFilteredTemplatePartBlocks( NESTED_BLOCKS, TEMPLATE_PARTS );
142
+ expect(
143
+ getFilteredTemplatePartBlocks( NESTED_BLOCKS, TEMPLATE_PARTS )
144
+ ).toEqual( FLATTENED_BLOCKS );
145
+
146
+ // The function has been called twice with the same params, so the cache size should be 1.
147
+ /**
148
+ * TODO what should be done about this?
149
+ * Can it be tested another way?
150
+ * Is it necessary?
151
+ */
152
+ // const [ , , originalSize ] =
153
+ // getFilteredTemplatePartBlocks.getCache();
154
+ // expect( originalSize ).toBe( 1 );
155
+
156
+ // Call the function again, with different params.
157
+ expect(
158
+ getFilteredTemplatePartBlocks(
159
+ [ SINGLE_TEMPLATE_PART_BLOCK ],
160
+ TEMPLATE_PARTS
161
+ )
162
+ ).toEqual( [
163
+ {
164
+ block: {
165
+ clientId: '1',
166
+ name: 'core/template-part',
167
+ attributes: {
168
+ slug: 'aside',
169
+ theme: 'my-theme',
170
+ },
171
+ },
172
+ templatePart: {
173
+ id: 'my-theme//aside',
174
+ slug: 'aside',
175
+ theme: 'my-theme',
176
+ },
177
+ },
178
+ ] );
179
+
180
+ // The function has been called with different params, so the cache size should now be 2.
181
+ /**
182
+ * TODO what should be done about this?
183
+ * Can it be tested another way?
184
+ * Is it necessary?
185
+ */
186
+ // const [ , , finalSize ] = getFilteredTemplatePartBlocks.getCache();
187
+ // expect( finalSize ).toBe( 2 );
188
+ } );
189
+ } );
package/src/style.scss CHANGED
@@ -9,6 +9,7 @@
9
9
  @import "./components/inserter-sidebar/style.scss";
10
10
  @import "./components/list-view-sidebar/style.scss";
11
11
  @import "./components/post-author/style.scss";
12
+ @import "./components/post-card-panel/style.scss";
12
13
  @import "./components/post-excerpt/style.scss";
13
14
  @import "./components/post-featured-image/style.scss";
14
15
  @import "./components/post-format/style.scss";
@@ -29,4 +30,5 @@
29
30
  @import "./components/post-trash/style.scss";
30
31
  @import "./components/preview-dropdown/style.scss";
31
32
  @import "./components/table-of-contents/style.scss";
33
+ @import "./components/template-areas/style.scss";
32
34
  @import "./components/template-validation-notice/style.scss";