@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,116 @@
1
+ .error-boundary__scroll {
2
+ height: 100%;
3
+ width: 100%;
4
+ }
5
+
6
+ .error-boundary__scroll-container {
7
+ flex-grow: 1;
8
+ max-height: 580px;
9
+ align-items: center;
10
+ justify-content: center;
11
+ }
12
+
13
+
14
+ .error-boundary__container {
15
+ width: 100%;
16
+ max-width: 600px;
17
+ justify-content: center;
18
+ align-items: center;
19
+ padding: 0 24px;
20
+ }
21
+
22
+ .error-boundary__icon-container {
23
+ $size: 40px;
24
+
25
+ width: $size;
26
+ height: $size;
27
+ align-items: center;
28
+ justify-content: center;
29
+ margin-bottom: 8px;
30
+ background-color: rgba(60, 60, 67, 0.3);
31
+ border-radius: $size/2;
32
+ }
33
+
34
+ .error-boundary__icon-container--dark {
35
+ background-color: rgba(235, 235, 245, 0.3);
36
+ }
37
+
38
+ .error-boundary__icon {
39
+ width: 24px;
40
+ height: 24px;
41
+ fill: $white;
42
+ }
43
+
44
+ .error-boundary__title {
45
+ font-size: 20px;
46
+ font-weight: 600;
47
+ line-height: 25px;
48
+ color: $black;
49
+ text-align: center;
50
+ margin-bottom: 8px;
51
+ }
52
+
53
+ .error-boundary__title--dark {
54
+ color: $white;
55
+ }
56
+
57
+ .error-boundary__message {
58
+ font-size: 16px;
59
+ font-weight: 400;
60
+ line-height: 21px;
61
+ color: rgba(60, 60, 67, 0.6);
62
+ text-align: center;
63
+ margin-bottom: 16px;
64
+ }
65
+
66
+ .error-boundary__message--dark {
67
+ color: rgba(235, 235, 245, 0.6);
68
+ }
69
+
70
+ .error-boundary__actions-container {
71
+ width: 100%;
72
+ max-width: 400px;
73
+ justify-content: center;
74
+ gap: 12px;
75
+ padding-top: 16px;
76
+ }
77
+
78
+ .copy-button__container {
79
+ border-radius: 5px;
80
+ padding: $grid-unit $grid-unit-20;
81
+ background-color: $light-primary;
82
+ }
83
+
84
+ .copy-button__container--dark {
85
+ background-color: $white;
86
+ }
87
+
88
+ .copy-button__container--secondary {
89
+ border: 1px #c6c6c8;
90
+ background-color: $white;
91
+ }
92
+
93
+ .copy-button__container--secondary-dark {
94
+ border-color: rgba(255, 255, 255, 0.3);
95
+ background-color: $black;
96
+ }
97
+
98
+ .copy-button__text {
99
+ font-size: 17px;
100
+ font-weight: 400;
101
+ line-height: 22px;
102
+ text-align: center;
103
+ color: $white;
104
+ }
105
+
106
+ .copy-button__text--dark {
107
+ color: $background-dark-secondary;
108
+ }
109
+
110
+ .copy-button__text--secondary {
111
+ color: $black;
112
+ }
113
+
114
+ .copy-button__text--secondary-dark {
115
+ color: $white;
116
+ }
@@ -26,6 +26,10 @@ export { default as PageAttributesOrder } from './page-attributes/order';
26
26
  export { default as PageAttributesPanel } from './page-attributes/panel';
27
27
  export { default as PageAttributesParent } from './page-attributes/parent';
28
28
  export { default as PageTemplate } from './post-template/classic-theme';
29
+ export { default as PluginDocumentSettingPanel } from './plugin-document-setting-panel';
30
+ export { default as PluginBlockSettingsMenuItem } from './block-settings-menu/plugin-block-settings-menu-item';
31
+ export { default as PluginPostPublishPanel } from './plugin-post-publish-panel';
32
+ export { default as PluginPrePublishPanel } from './plugin-pre-publish-panel';
29
33
  export { default as PostTemplatePanel } from './post-template/panel';
30
34
  export { default as PostAuthor } from './post-author';
31
35
  export { default as PostAuthorCheck } from './post-author/check';
@@ -64,10 +68,7 @@ export { default as PostSlugCheck } from './post-slug/check';
64
68
  export { default as PostSticky } from './post-sticky';
65
69
  export { default as PostStickyCheck } from './post-sticky/check';
66
70
  export { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';
67
- export {
68
- default as PostSyncStatus,
69
- PostSyncStatusModal,
70
- } from './post-sync-status';
71
+ export { default as PostSyncStatus } from './post-sync-status';
71
72
  export { default as PostTaxonomies } from './post-taxonomies';
72
73
  export { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';
73
74
  export { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';
@@ -10,5 +10,6 @@ export { default as EditorProvider } from './provider';
10
10
  // Other Components.
11
11
  export { default as EditorHelpTopics } from './editor-help';
12
12
  export { default as OfflineStatus } from './offline-status';
13
+ export { default as ErrorBoundary } from './error-boundary';
13
14
 
14
15
  export * from './deprecated';
@@ -19,7 +19,10 @@ import { store as preferencesStore } from '@wordpress/preferences';
19
19
  import { unlock } from '../../lock-unlock';
20
20
  import { store as editorStore } from '../../store';
21
21
 
22
- export default function InserterSidebar() {
22
+ export default function InserterSidebar( {
23
+ closeGeneralSidebar,
24
+ isRightSidebarOpen,
25
+ } ) {
23
26
  const { insertionPoint, showMostUsedBlocks } = useSelect( ( select ) => {
24
27
  const { getInsertionPoint } = unlock( select( editorStore ) );
25
28
  const { get } = select( preferencesStore );
@@ -65,6 +68,9 @@ export default function InserterSidebar() {
65
68
  insertionPoint.insertionIndex
66
69
  }
67
70
  __experimentalFilterValue={ insertionPoint.filterValue }
71
+ __experimentalOnPatternCategorySelection={
72
+ isRightSidebarOpen ? closeGeneralSidebar : undefined
73
+ }
68
74
  ref={ libraryRef }
69
75
  />
70
76
  </div>
@@ -135,6 +135,7 @@ export default function ListViewSidebar() {
135
135
  icon={ closeSmall }
136
136
  label={ __( 'Close' ) }
137
137
  onClick={ closeListView }
138
+ size="small"
138
139
  />
139
140
  <Tabs.TabList
140
141
  className="editor-list-view-sidebar__tabs-tablist"
@@ -16,7 +16,7 @@
16
16
  background: $white;
17
17
  order: 1;
18
18
  align-self: center;
19
- margin-right: $grid-unit-10;
19
+ margin-right: $grid-unit-15;
20
20
  }
21
21
  }
22
22
 
@@ -0,0 +1,26 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { store as editorStore } from '../../store';
11
+ import { unlock } from '../../lock-unlock';
12
+
13
+ const { OverridesPanel } = unlock( patternsPrivateApis );
14
+
15
+ export default function PatternOverridesPanel() {
16
+ const supportsPatternOverridesPanel = useSelect(
17
+ ( select ) => select( editorStore ).getCurrentPostType() === 'wp_block',
18
+ []
19
+ );
20
+
21
+ if ( ! supportsPatternOverridesPanel ) {
22
+ return null;
23
+ }
24
+
25
+ return <OverridesPanel />;
26
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createSlotFill, PanelBody } from '@wordpress/components';
5
+ import { usePluginContext } from '@wordpress/plugins';
6
+ import { useDispatch, useSelect } from '@wordpress/data';
7
+ import warning from '@wordpress/warning';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import EnablePluginDocumentSettingPanelOption from '../preferences-modal/enable-plugin-document-setting-panel';
13
+ import { store as editorStore } from '../../store';
14
+
15
+ const { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' );
16
+
17
+ /**
18
+ * Renders items below the Status & Availability panel in the Document Sidebar.
19
+ *
20
+ * @param {Object} props Component properties.
21
+ * @param {string} props.name Required. A machine-friendly name for the panel.
22
+ * @param {string} [props.className] An optional class name added to the row.
23
+ * @param {string} [props.title] The title of the panel
24
+ * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
25
+ * @param {Element} props.children Children to be rendered
26
+ *
27
+ * @example
28
+ * ```js
29
+ * // Using ES5 syntax
30
+ * var el = React.createElement;
31
+ * var __ = wp.i18n.__;
32
+ * var registerPlugin = wp.plugins.registerPlugin;
33
+ * var PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;
34
+ *
35
+ * function MyDocumentSettingPlugin() {
36
+ * return el(
37
+ * PluginDocumentSettingPanel,
38
+ * {
39
+ * className: 'my-document-setting-plugin',
40
+ * title: 'My Panel',
41
+ * name: 'my-panel',
42
+ * },
43
+ * __( 'My Document Setting Panel' )
44
+ * );
45
+ * }
46
+ *
47
+ * registerPlugin( 'my-document-setting-plugin', {
48
+ * render: MyDocumentSettingPlugin
49
+ * } );
50
+ * ```
51
+ *
52
+ * @example
53
+ * ```jsx
54
+ * // Using ESNext syntax
55
+ * import { registerPlugin } from '@wordpress/plugins';
56
+ * import { PluginDocumentSettingPanel } from '@wordpress/editor';
57
+ *
58
+ * const MyDocumentSettingTest = () => (
59
+ * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
60
+ * <p>My Document Setting Panel</p>
61
+ * </PluginDocumentSettingPanel>
62
+ * );
63
+ *
64
+ * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
65
+ * ```
66
+ *
67
+ * @return {Component} The component to be rendered.
68
+ */
69
+ const PluginDocumentSettingPanel = ( {
70
+ name,
71
+ className,
72
+ title,
73
+ icon,
74
+ children,
75
+ } ) => {
76
+ const { name: pluginName } = usePluginContext();
77
+ const panelName = `${ pluginName }/${ name }`;
78
+ const { opened, isEnabled } = useSelect(
79
+ ( select ) => {
80
+ const { isEditorPanelOpened, isEditorPanelEnabled } =
81
+ select( editorStore );
82
+
83
+ return {
84
+ opened: isEditorPanelOpened( panelName ),
85
+ isEnabled: isEditorPanelEnabled( panelName ),
86
+ };
87
+ },
88
+ [ panelName ]
89
+ );
90
+ const { toggleEditorPanelOpened } = useDispatch( editorStore );
91
+
92
+ if ( undefined === name ) {
93
+ warning( 'PluginDocumentSettingPanel requires a name property.' );
94
+ }
95
+
96
+ return (
97
+ <>
98
+ <EnablePluginDocumentSettingPanelOption
99
+ label={ title }
100
+ panelName={ panelName }
101
+ />
102
+ <Fill>
103
+ { isEnabled && (
104
+ <PanelBody
105
+ className={ className }
106
+ title={ title }
107
+ icon={ icon }
108
+ opened={ opened }
109
+ onToggle={ () => toggleEditorPanelOpened( panelName ) }
110
+ >
111
+ { children }
112
+ </PanelBody>
113
+ ) }
114
+ </Fill>
115
+ </>
116
+ );
117
+ };
118
+
119
+ PluginDocumentSettingPanel.Slot = Slot;
120
+
121
+ export default PluginDocumentSettingPanel;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { usePluginContext } from '@wordpress/plugins';
5
+ import { createSlotFill, PanelBody } from '@wordpress/components';
6
+
7
+ const { Fill, Slot } = createSlotFill( 'PluginPostPublishPanel' );
8
+
9
+ /**
10
+ * Renders provided content to the post-publish panel in the publish flow
11
+ * (side panel that opens after a user publishes the post).
12
+ *
13
+ * @param {Object} props Component properties.
14
+ * @param {string} [props.className] An optional class name added to the panel.
15
+ * @param {string} [props.title] Title displayed at the top of the panel.
16
+ * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
17
+ * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
18
+ * @param {Element} props.children Children to be rendered
19
+ *
20
+ * @example
21
+ * ```jsx
22
+ * // Using ESNext syntax
23
+ * import { __ } from '@wordpress/i18n';
24
+ * import { PluginPostPublishPanel } from '@wordpress/edit-post';
25
+ *
26
+ * const MyPluginPostPublishPanel = () => (
27
+ * <PluginPostPublishPanel
28
+ * className="my-plugin-post-publish-panel"
29
+ * title={ __( 'My panel title' ) }
30
+ * initialOpen={ true }
31
+ * >
32
+ * { __( 'My panel content' ) }
33
+ * </PluginPostPublishPanel>
34
+ * );
35
+ * ```
36
+ *
37
+ * @return {Component} The component to be rendered.
38
+ */
39
+ const PluginPostPublishPanel = ( {
40
+ children,
41
+ className,
42
+ title,
43
+ initialOpen = false,
44
+ icon,
45
+ } ) => {
46
+ const { icon: pluginIcon } = usePluginContext();
47
+
48
+ return (
49
+ <Fill>
50
+ <PanelBody
51
+ className={ className }
52
+ initialOpen={ initialOpen || ! title }
53
+ title={ title }
54
+ icon={ icon ?? pluginIcon }
55
+ >
56
+ { children }
57
+ </PanelBody>
58
+ </Fill>
59
+ );
60
+ };
61
+
62
+ PluginPostPublishPanel.Slot = Slot;
63
+
64
+ export default PluginPostPublishPanel;
@@ -0,0 +1,39 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`PluginPostPublishPanel renders fill properly 1`] = `
4
+ <div>
5
+ <div
6
+ class="components-panel__body my-plugin-post-publish-panel is-opened"
7
+ >
8
+ <h2
9
+ class="components-panel__body-title"
10
+ >
11
+ <button
12
+ aria-expanded="true"
13
+ class="components-button components-panel__body-toggle"
14
+ type="button"
15
+ >
16
+ <span
17
+ aria-hidden="true"
18
+ >
19
+ <svg
20
+ aria-hidden="true"
21
+ class="components-panel__arrow"
22
+ focusable="false"
23
+ height="24"
24
+ viewBox="0 0 24 24"
25
+ width="24"
26
+ xmlns="http://www.w3.org/2000/svg"
27
+ >
28
+ <path
29
+ d="M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
30
+ />
31
+ </svg>
32
+ </span>
33
+ My panel title
34
+ </button>
35
+ </h2>
36
+ My panel content
37
+ </div>
38
+ </div>
39
+ `;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render } from '@testing-library/react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { SlotFillProvider } from '@wordpress/components';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import PluginPostPublishPanel from '../';
15
+
16
+ describe( 'PluginPostPublishPanel', () => {
17
+ test( 'renders fill properly', () => {
18
+ const { container } = render(
19
+ <SlotFillProvider>
20
+ <PluginPostPublishPanel
21
+ className="my-plugin-post-publish-panel"
22
+ title="My panel title"
23
+ initialOpen
24
+ >
25
+ My panel content
26
+ </PluginPostPublishPanel>
27
+ <PluginPostPublishPanel.Slot />
28
+ </SlotFillProvider>
29
+ );
30
+
31
+ expect( container ).toMatchSnapshot();
32
+ } );
33
+ } );
@@ -0,0 +1,67 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createSlotFill, PanelBody } from '@wordpress/components';
5
+ import { usePluginContext } from '@wordpress/plugins';
6
+
7
+ const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' );
8
+
9
+ /**
10
+ * Renders provided content to the pre-publish side panel in the publish flow
11
+ * (side panel that opens when a user first pushes "Publish" from the main editor).
12
+ *
13
+ * @param {Object} props Component props.
14
+ * @param {string} [props.className] An optional class name added to the panel.
15
+ * @param {string} [props.title] Title displayed at the top of the panel.
16
+ * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened.
17
+ * When no title is provided it is always opened.
18
+ * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
19
+ * icon slug string, or an SVG WP element, to be rendered when
20
+ * the sidebar is pinned to toolbar.
21
+ * @param {Element} props.children Children to be rendered
22
+ *
23
+ * @example
24
+ * ```jsx
25
+ * // Using ESNext syntax
26
+ * import { __ } from '@wordpress/i18n';
27
+ * import { PluginPrePublishPanel } from '@wordpress/edit-post';
28
+ *
29
+ * const MyPluginPrePublishPanel = () => (
30
+ * <PluginPrePublishPanel
31
+ * className="my-plugin-pre-publish-panel"
32
+ * title={ __( 'My panel title' ) }
33
+ * initialOpen={ true }
34
+ * >
35
+ * { __( 'My panel content' ) }
36
+ * </PluginPrePublishPanel>
37
+ * );
38
+ * ```
39
+ *
40
+ * @return {Component} The component to be rendered.
41
+ */
42
+ const PluginPrePublishPanel = ( {
43
+ children,
44
+ className,
45
+ title,
46
+ initialOpen = false,
47
+ icon,
48
+ } ) => {
49
+ const { icon: pluginIcon } = usePluginContext();
50
+
51
+ return (
52
+ <Fill>
53
+ <PanelBody
54
+ className={ className }
55
+ initialOpen={ initialOpen || ! title }
56
+ title={ title }
57
+ icon={ icon ?? pluginIcon }
58
+ >
59
+ { children }
60
+ </PanelBody>
61
+ </Fill>
62
+ );
63
+ };
64
+
65
+ PluginPrePublishPanel.Slot = Slot;
66
+
67
+ export default PluginPrePublishPanel;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render, screen } from '@testing-library/react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { SlotFillProvider } from '@wordpress/components';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import PluginPrePublishPanel from '../';
15
+
16
+ describe( 'PluginPrePublishPanel', () => {
17
+ test( 'renders fill properly', () => {
18
+ render(
19
+ <SlotFillProvider>
20
+ <PluginPrePublishPanel
21
+ className="my-plugin-pre-publish-panel"
22
+ title="My panel title"
23
+ initialOpen
24
+ >
25
+ My panel content
26
+ </PluginPrePublishPanel>
27
+ <PluginPrePublishPanel.Slot />
28
+ </SlotFillProvider>
29
+ );
30
+
31
+ expect( screen.getByText( 'My panel title' ) ).toBeVisible();
32
+ } );
33
+ } );