@wordpress/edit-post 7.30.0 → 7.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 (129) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +6 -185
  3. package/build/components/header/index.js +1 -1
  4. package/build/components/header/index.js.map +1 -1
  5. package/build/components/header/post-publish-button-or-toggle.js +2 -7
  6. package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
  7. package/build/components/init-pattern-modal/index.js +99 -0
  8. package/build/components/init-pattern-modal/index.js.map +1 -0
  9. package/build/components/keyboard-shortcut-help-modal/config.js +6 -0
  10. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  11. package/build/components/keyboard-shortcut-help-modal/index.js +3 -0
  12. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  13. package/build/components/layout/actions-panel.js +4 -7
  14. package/build/components/layout/actions-panel.js.map +1 -1
  15. package/build/components/layout/index.js +7 -3
  16. package/build/components/layout/index.js.map +1 -1
  17. package/build/components/sidebar/plugin-post-publish-panel/index.js +16 -64
  18. package/build/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  19. package/build/components/sidebar/plugin-pre-publish-panel/index.js +16 -63
  20. package/build/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  21. package/build/components/sidebar/post-status/index.js +3 -1
  22. package/build/components/sidebar/post-status/index.js.map +1 -1
  23. package/build/components/sidebar/settings-sidebar/index.js +8 -4
  24. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  25. package/build/editor.js +7 -2
  26. package/build/editor.js.map +1 -1
  27. package/build/editor.native.js +2 -2
  28. package/build/editor.native.js.map +1 -1
  29. package/build/hooks/commands/use-common-commands.js +2 -2
  30. package/build/hooks/commands/use-common-commands.js.map +1 -1
  31. package/build/hooks/use-navigate-to-entity-record.js +36 -19
  32. package/build/hooks/use-navigate-to-entity-record.js.map +1 -1
  33. package/build/index.js +4 -6
  34. package/build/index.js.map +1 -1
  35. package/build/index.native.js +2 -4
  36. package/build/index.native.js.map +1 -1
  37. package/build/store/actions.js +36 -23
  38. package/build/store/actions.js.map +1 -1
  39. package/build/store/reducer.js +1 -15
  40. package/build/store/reducer.js.map +1 -1
  41. package/build/store/selectors.js +10 -5
  42. package/build/store/selectors.js.map +1 -1
  43. package/build-module/components/header/index.js +1 -1
  44. package/build-module/components/header/index.js.map +1 -1
  45. package/build-module/components/header/post-publish-button-or-toggle.js +2 -7
  46. package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
  47. package/build-module/components/init-pattern-modal/index.js +93 -0
  48. package/build-module/components/init-pattern-modal/index.js.map +1 -0
  49. package/build-module/components/keyboard-shortcut-help-modal/config.js +6 -0
  50. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  51. package/build-module/components/keyboard-shortcut-help-modal/index.js +3 -0
  52. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  53. package/build-module/components/layout/actions-panel.js +4 -5
  54. package/build-module/components/layout/actions-panel.js.map +1 -1
  55. package/build-module/components/layout/index.js +8 -4
  56. package/build-module/components/layout/index.js.map +1 -1
  57. package/build-module/components/sidebar/plugin-post-publish-panel/index.js +14 -62
  58. package/build-module/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  59. package/build-module/components/sidebar/plugin-pre-publish-panel/index.js +14 -61
  60. package/build-module/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  61. package/build-module/components/sidebar/post-status/index.js +4 -2
  62. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  63. package/build-module/components/sidebar/settings-sidebar/index.js +9 -5
  64. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  65. package/build-module/editor.js +7 -2
  66. package/build-module/editor.js.map +1 -1
  67. package/build-module/editor.native.js +3 -3
  68. package/build-module/editor.native.js.map +1 -1
  69. package/build-module/hooks/commands/use-common-commands.js +2 -2
  70. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  71. package/build-module/hooks/use-navigate-to-entity-record.js +37 -20
  72. package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -1
  73. package/build-module/index.js +5 -5
  74. package/build-module/index.js.map +1 -1
  75. package/build-module/index.native.js +2 -4
  76. package/build-module/index.native.js.map +1 -1
  77. package/build-module/store/actions.js +30 -15
  78. package/build-module/store/actions.js.map +1 -1
  79. package/build-module/store/reducer.js +1 -13
  80. package/build-module/store/reducer.js.map +1 -1
  81. package/build-module/store/selectors.js +9 -3
  82. package/build-module/store/selectors.js.map +1 -1
  83. package/build-style/classic-rtl.css +1 -1
  84. package/build-style/classic.css +1 -1
  85. package/build-style/style-rtl.css +1 -7
  86. package/build-style/style.css +1 -7
  87. package/package.json +32 -32
  88. package/src/classic.scss +2 -1
  89. package/src/components/header/index.js +1 -1
  90. package/src/components/header/post-publish-button-or-toggle.js +2 -8
  91. package/src/components/init-pattern-modal/index.js +117 -0
  92. package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
  93. package/src/components/keyboard-shortcut-help-modal/index.js +4 -0
  94. package/src/components/layout/actions-panel.js +5 -4
  95. package/src/components/layout/index.js +9 -4
  96. package/src/components/meta-boxes/meta-boxes-area/style.scss +1 -1
  97. package/src/components/sidebar/plugin-post-publish-panel/index.js +12 -67
  98. package/src/components/sidebar/plugin-pre-publish-panel/index.js +12 -66
  99. package/src/components/sidebar/post-status/index.js +2 -0
  100. package/src/components/sidebar/settings-sidebar/index.js +7 -5
  101. package/src/editor.js +12 -2
  102. package/src/editor.native.js +8 -2
  103. package/src/hooks/commands/use-common-commands.js +2 -2
  104. package/src/hooks/use-navigate-to-entity-record.js +37 -24
  105. package/src/index.js +5 -3
  106. package/src/index.native.js +1 -4
  107. package/src/store/actions.js +27 -12
  108. package/src/store/reducer.js +0 -13
  109. package/src/store/selectors.js +11 -3
  110. package/src/style.scss +0 -1
  111. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -107
  112. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +0 -1
  113. package/build/components/sidebar/plugin-document-setting-panel/index.js +0 -126
  114. package/build/components/sidebar/plugin-document-setting-panel/index.js.map +0 -1
  115. package/build/components/sidebar/template-summary/index.js +0 -36
  116. package/build/components/sidebar/template-summary/index.js.map +0 -1
  117. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -100
  118. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +0 -1
  119. package/build-module/components/sidebar/plugin-document-setting-panel/index.js +0 -118
  120. package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +0 -1
  121. package/build-module/components/sidebar/template-summary/index.js +0 -29
  122. package/build-module/components/sidebar/template-summary/index.js.map +0 -1
  123. package/src/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -108
  124. package/src/components/sidebar/plugin-document-setting-panel/index.js +0 -125
  125. package/src/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap +0 -39
  126. package/src/components/sidebar/plugin-post-publish-panel/test/index.js +0 -33
  127. package/src/components/sidebar/plugin-pre-publish-panel/test/index.js +0 -33
  128. package/src/components/sidebar/template-summary/index.js +0 -37
  129. package/src/components/sidebar/template-summary/style.scss +0 -5
package/src/editor.js CHANGED
@@ -32,11 +32,14 @@ function Editor( {
32
32
  ...props
33
33
  } ) {
34
34
  const {
35
- initialPost,
36
35
  currentPost,
37
36
  onNavigateToEntityRecord,
38
37
  onNavigateToPreviousEntityRecord,
39
- } = useNavigateToEntityRecord( initialPostId, initialPostType );
38
+ } = useNavigateToEntityRecord(
39
+ initialPostId,
40
+ initialPostType,
41
+ 'post-only'
42
+ );
40
43
 
41
44
  const { post, template } = useSelect(
42
45
  ( select ) => {
@@ -80,6 +83,13 @@ function Editor( {
80
83
  [ settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord ]
81
84
  );
82
85
 
86
+ const initialPost = useMemo( () => {
87
+ return {
88
+ type: initialPostType,
89
+ id: initialPostId,
90
+ };
91
+ }, [ initialPostType, initialPostId ] );
92
+
83
93
  if ( ! post ) {
84
94
  return null;
85
95
  }
@@ -9,7 +9,11 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
9
9
  * WordPress dependencies
10
10
  */
11
11
  import { Component } from '@wordpress/element';
12
- import { EditorProvider, store as editorStore } from '@wordpress/editor';
12
+ import {
13
+ EditorProvider,
14
+ ErrorBoundary,
15
+ store as editorStore,
16
+ } from '@wordpress/editor';
13
17
  import { parse, serialize } from '@wordpress/blocks';
14
18
  import { withDispatch, withSelect } from '@wordpress/data';
15
19
  import { compose } from '@wordpress/compose';
@@ -143,7 +147,9 @@ class Editor extends Component {
143
147
  useSubRegistry={ false }
144
148
  { ...props }
145
149
  >
146
- <Layout setTitleRef={ this.setTitleRef } />
150
+ <ErrorBoundary>
151
+ <Layout setTitleRef={ this.setTitleRef } />
152
+ </ErrorBoundary>
147
153
  </EditorProvider>
148
154
  </SlotFillProvider>
149
155
  </GestureHandlerRootView>
@@ -126,13 +126,13 @@ export default function useCommonCommands() {
126
126
  icon: formatListBullets,
127
127
  callback: ( { close } ) => {
128
128
  close();
129
- toggle( 'core/edit-post', 'isPublishSidebarEnabled' );
129
+ toggle( 'core', 'isPublishSidebarEnabled' );
130
130
  createInfoNotice(
131
131
  isPublishSidebarEnabled
132
132
  ? __( 'Pre-publish checks disabled.' )
133
133
  : __( 'Pre-publish checks enabled.' ),
134
134
  {
135
- id: 'core/edit-post/publish-sidebar/notice',
135
+ id: 'core/editor/publish-sidebar/notice',
136
136
  type: 'snackbar',
137
137
  }
138
138
  );
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useCallback, useReducer, useMemo } from '@wordpress/element';
4
+ import { useCallback, useReducer } from '@wordpress/element';
5
+ import { useSelect, useDispatch } from '@wordpress/data';
6
+ import { store as editorStore } from '@wordpress/editor';
5
7
 
6
8
  /**
7
9
  * A hook that records the 'entity' history in the post editor as a user
@@ -11,20 +13,22 @@ import { useCallback, useReducer, useMemo } from '@wordpress/element';
11
13
  *
12
14
  * Used to control displaying UI elements like the back button.
13
15
  *
14
- * @param {number} initialPostId The post id of the post when the editor loaded.
15
- * @param {string} initialPostType The post type of the post when the editor loaded.
16
+ * @param {number} initialPostId The post id of the post when the editor loaded.
17
+ * @param {string} initialPostType The post type of the post when the editor loaded.
18
+ * @param {string} defaultRenderingMode The rendering mode to switch to when navigating.
16
19
  *
17
20
  * @return {Object} An object containing the `currentPost` variable and
18
21
  * `onNavigateToEntityRecord` and `onNavigateToPreviousEntityRecord` functions.
19
22
  */
20
23
  export default function useNavigateToEntityRecord(
21
24
  initialPostId,
22
- initialPostType
25
+ initialPostType,
26
+ defaultRenderingMode
23
27
  ) {
24
28
  const [ postHistory, dispatch ] = useReducer(
25
- ( historyState, { type, post } ) => {
29
+ ( historyState, { type, post, previousRenderingMode } ) => {
26
30
  if ( type === 'push' ) {
27
- return [ ...historyState, post ];
31
+ return [ ...historyState, { post, previousRenderingMode } ];
28
32
  }
29
33
  if ( type === 'pop' ) {
30
34
  // Try to leave one item in the history.
@@ -34,32 +38,41 @@ export default function useNavigateToEntityRecord(
34
38
  }
35
39
  return historyState;
36
40
  },
37
- [ { postId: initialPostId, postType: initialPostType } ]
41
+ [
42
+ {
43
+ post: { postId: initialPostId, postType: initialPostType },
44
+ },
45
+ ]
38
46
  );
39
47
 
40
- const initialPost = useMemo( () => {
41
- return {
42
- type: initialPostType,
43
- id: initialPostId,
44
- };
45
- }, [ initialPostType, initialPostId ] );
48
+ const { post, previousRenderingMode } =
49
+ postHistory[ postHistory.length - 1 ];
46
50
 
47
- const onNavigateToEntityRecord = useCallback( ( params ) => {
48
- dispatch( {
49
- type: 'push',
50
- post: { postId: params.postId, postType: params.postType },
51
- } );
52
- }, [] );
51
+ const { getRenderingMode } = useSelect( editorStore );
52
+ const { setRenderingMode } = useDispatch( editorStore );
53
+
54
+ const onNavigateToEntityRecord = useCallback(
55
+ ( params ) => {
56
+ dispatch( {
57
+ type: 'push',
58
+ post: { postId: params.postId, postType: params.postType },
59
+ // Save the current rendering mode so we can restore it when navigating back.
60
+ previousRenderingMode: getRenderingMode(),
61
+ } );
62
+ setRenderingMode( defaultRenderingMode );
63
+ },
64
+ [ getRenderingMode, setRenderingMode, defaultRenderingMode ]
65
+ );
53
66
 
54
67
  const onNavigateToPreviousEntityRecord = useCallback( () => {
55
68
  dispatch( { type: 'pop' } );
56
- }, [] );
57
-
58
- const currentPost = postHistory[ postHistory.length - 1 ];
69
+ if ( previousRenderingMode ) {
70
+ setRenderingMode( previousRenderingMode );
71
+ }
72
+ }, [ setRenderingMode, previousRenderingMode ] );
59
73
 
60
74
  return {
61
- currentPost,
62
- initialPost,
75
+ currentPost: post,
63
76
  onNavigateToEntityRecord,
64
77
  onNavigateToPreviousEntityRecord:
65
78
  postHistory.length > 1
package/src/index.js CHANGED
@@ -15,6 +15,8 @@ import {
15
15
  registerWidgetGroupBlock,
16
16
  } from '@wordpress/widgets';
17
17
  import {
18
+ PluginBlockSettingsMenuItem,
19
+ PluginDocumentSettingPanel,
18
20
  privateApis as editorPrivateApis,
19
21
  store as editorStore,
20
22
  } from '@wordpress/editor';
@@ -54,7 +56,6 @@ export function initializeEditor(
54
56
 
55
57
  dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
56
58
  fullscreenMode: true,
57
- isPublishSidebarEnabled: true,
58
59
  themeStyles: true,
59
60
  welcomeGuide: true,
60
61
  welcomeGuideTemplate: true,
@@ -70,6 +71,7 @@ export function initializeEditor(
70
71
  showBlockBreadcrumbs: true,
71
72
  showIconLabels: false,
72
73
  showListViewByDefault: false,
74
+ isPublishSidebarEnabled: true,
73
75
  } );
74
76
 
75
77
  dispatch( blocksStore ).reapplyBlockTypeFilters();
@@ -160,8 +162,8 @@ export function reinitializeEditor() {
160
162
  } );
161
163
  }
162
164
 
163
- export { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';
164
- export { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';
165
+ export { PluginBlockSettingsMenuItem };
166
+ export { PluginDocumentSettingPanel };
165
167
  export { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';
166
168
  export { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';
167
169
  export { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';
@@ -25,7 +25,6 @@ export function initializeEditor( id, postType, postId ) {
25
25
  editorMode: 'visual',
26
26
  fullscreenMode: true,
27
27
  inactivePanels: [],
28
- isPublishSidebarEnabled: true,
29
28
  openPanels: [ 'post-status' ],
30
29
  welcomeGuide: true,
31
30
  } );
@@ -33,9 +32,7 @@ export function initializeEditor( id, postType, postId ) {
33
32
  hiddenBlockTypes: [],
34
33
  inactivePanels: [],
35
34
  openPanels: [ 'post-status' ],
36
- } );
37
-
38
- dispatch( preferencesStore ).setDefaults( 'core', {
35
+ isPublishSidebarEnabled: true,
39
36
  fixedToolbar: false,
40
37
  } );
41
38
 
@@ -78,37 +78,52 @@ export const closeModal =
78
78
  /**
79
79
  * Returns an action object used in signalling that the user opened the publish
80
80
  * sidebar.
81
+ * @deprecated
81
82
  *
82
83
  * @return {Object} Action object
83
84
  */
84
- export function openPublishSidebar() {
85
- return {
86
- type: 'OPEN_PUBLISH_SIDEBAR',
85
+ export const openPublishSidebar =
86
+ () =>
87
+ ( { registry } ) => {
88
+ deprecated( "dispatch( 'core/edit-post' ).openPublishSidebar", {
89
+ since: '6.6',
90
+ alternative: "dispatch( 'core/editor').openPublishSidebar",
91
+ } );
92
+ registry.dispatch( editorStore ).openPublishSidebar();
87
93
  };
88
- }
89
94
 
90
95
  /**
91
96
  * Returns an action object used in signalling that the user closed the
92
97
  * publish sidebar.
98
+ * @deprecated
93
99
  *
94
100
  * @return {Object} Action object.
95
101
  */
96
- export function closePublishSidebar() {
97
- return {
98
- type: 'CLOSE_PUBLISH_SIDEBAR',
102
+ export const closePublishSidebar =
103
+ () =>
104
+ ( { registry } ) => {
105
+ deprecated( "dispatch( 'core/edit-post' ).closePublishSidebar", {
106
+ since: '6.6',
107
+ alternative: "dispatch( 'core/editor').closePublishSidebar",
108
+ } );
109
+ registry.dispatch( editorStore ).closePublishSidebar();
99
110
  };
100
- }
101
111
 
102
112
  /**
103
113
  * Returns an action object used in signalling that the user toggles the publish sidebar.
114
+ * @deprecated
104
115
  *
105
116
  * @return {Object} Action object
106
117
  */
107
- export function togglePublishSidebar() {
108
- return {
109
- type: 'TOGGLE_PUBLISH_SIDEBAR',
118
+ export const togglePublishSidebar =
119
+ () =>
120
+ ( { registry } ) => {
121
+ deprecated( "dispatch( 'core/edit-post' ).togglePublishSidebar", {
122
+ since: '6.6',
123
+ alternative: "dispatch( 'core/editor').togglePublishSidebar",
124
+ } );
125
+ registry.dispatch( editorStore ).togglePublishSidebar();
110
126
  };
111
- }
112
127
 
113
128
  /**
114
129
  * Returns an action object used to enable or disable a panel in the editor.
@@ -3,18 +3,6 @@
3
3
  */
4
4
  import { combineReducers } from '@wordpress/data';
5
5
 
6
- export function publishSidebarActive( state = false, action ) {
7
- switch ( action.type ) {
8
- case 'OPEN_PUBLISH_SIDEBAR':
9
- return true;
10
- case 'CLOSE_PUBLISH_SIDEBAR':
11
- return false;
12
- case 'TOGGLE_PUBLISH_SIDEBAR':
13
- return ! state;
14
- }
15
- return state;
16
- }
17
-
18
6
  /**
19
7
  * Reducer keeping track of the meta boxes isSaving state.
20
8
  * A "true" value means the meta boxes saving request is in-flight.
@@ -103,5 +91,4 @@ const metaBoxes = combineReducers( {
103
91
 
104
92
  export default combineReducers( {
105
93
  metaBoxes,
106
- publishSidebarActive,
107
94
  } );
@@ -228,13 +228,21 @@ export const getHiddenBlockTypes = createRegistrySelector( ( select ) => () => {
228
228
  /**
229
229
  * Returns true if the publish sidebar is opened.
230
230
  *
231
+ * @deprecated
232
+ *
231
233
  * @param {Object} state Global application state
232
234
  *
233
235
  * @return {boolean} Whether the publish sidebar is open.
234
236
  */
235
- export function isPublishSidebarOpened( state ) {
236
- return state.publishSidebarActive;
237
- }
237
+ export const isPublishSidebarOpened = createRegistrySelector(
238
+ ( select ) => () => {
239
+ deprecated( `select( 'core/edit-post' ).isPublishSidebarOpened`, {
240
+ since: '6.6',
241
+ alternative: `select( 'core/editor' ).isPublishSidebarOpened`,
242
+ } );
243
+ return select( editorStore ).isPublishSidebarOpened();
244
+ }
245
+ );
238
246
 
239
247
  /**
240
248
  * Returns true if the given panel was programmatically removed, or false otherwise.
package/src/style.scss CHANGED
@@ -8,7 +8,6 @@
8
8
  @import "./components/sidebar/post-format/style.scss";
9
9
  @import "./components/sidebar/post-slug/style.scss";
10
10
  @import "./components/sidebar/post-visibility/style.scss";
11
- @import "./components/sidebar/template-summary/style.scss";
12
11
  @import "./components/text-editor/style.scss";
13
12
  @import "./components/visual-editor/style.scss";
14
13
  @import "./components/welcome-guide/style.scss";
@@ -1,107 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- var _blockEditor = require("@wordpress/block-editor");
9
- var _components = require("@wordpress/components");
10
- var _compose = require("@wordpress/compose");
11
- /**
12
- * WordPress dependencies
13
- */
14
-
15
- const isEverySelectedBlockAllowed = (selected, allowed) => selected.filter(id => !allowed.includes(id)).length === 0;
16
-
17
- /**
18
- * Plugins may want to add an item to the menu either for every block
19
- * or only for the specific ones provided in the `allowedBlocks` component property.
20
- *
21
- * If there are multiple blocks selected the item will be rendered if every block
22
- * is of one allowed type (not necessarily the same).
23
- *
24
- * @param {string[]} selectedBlocks Array containing the names of the blocks selected
25
- * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
26
- * @return {boolean} Whether the item will be rendered or not.
27
- */
28
- const shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
29
-
30
- /**
31
- * Renders a new item in the block settings menu.
32
- *
33
- * @param {Object} props Component props.
34
- * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.
35
- * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
36
- * @param {string} props.label The menu item text.
37
- * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
38
- * @param {boolean} [props.small] Whether to render the label or not.
39
- * @param {string} [props.role] The ARIA role for the menu item.
40
- *
41
- * @example
42
- * ```js
43
- * // Using ES5 syntax
44
- * var __ = wp.i18n.__;
45
- * var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;
46
- *
47
- * function doOnClick(){
48
- * // To be called when the user clicks the menu item.
49
- * }
50
- *
51
- * function MyPluginBlockSettingsMenuItem() {
52
- * return React.createElement(
53
- * PluginBlockSettingsMenuItem,
54
- * {
55
- * allowedBlocks: [ 'core/paragraph' ],
56
- * icon: 'dashicon-name',
57
- * label: __( 'Menu item text' ),
58
- * onClick: doOnClick,
59
- * }
60
- * );
61
- * }
62
- * ```
63
- *
64
- * @example
65
- * ```jsx
66
- * // Using ESNext syntax
67
- * import { __ } from '@wordpress/i18n';
68
- * import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';
69
- *
70
- * const doOnClick = ( ) => {
71
- * // To be called when the user clicks the menu item.
72
- * };
73
- *
74
- * const MyPluginBlockSettingsMenuItem = () => (
75
- * <PluginBlockSettingsMenuItem
76
- * allowedBlocks={ [ 'core/paragraph' ] }
77
- * icon='dashicon-name'
78
- * label={ __( 'Menu item text' ) }
79
- * onClick={ doOnClick } />
80
- * );
81
- * ```
82
- *
83
- * @return {Component} The component to be rendered.
84
- */
85
- const PluginBlockSettingsMenuItem = ({
86
- allowedBlocks,
87
- icon,
88
- label,
89
- onClick,
90
- small,
91
- role
92
- }) => (0, _react.createElement)(_blockEditor.BlockSettingsMenuControls, null, ({
93
- selectedBlocks,
94
- onClose
95
- }) => {
96
- if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
97
- return null;
98
- }
99
- return (0, _react.createElement)(_components.MenuItem, {
100
- onClick: (0, _compose.compose)(onClick, onClose),
101
- icon: icon,
102
- label: small ? label : undefined,
103
- role: role
104
- }, !small && label);
105
- });
106
- var _default = exports.default = PluginBlockSettingsMenuItem;
107
- //# sourceMappingURL=plugin-block-settings-menu-item.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_blockEditor","require","_components","_compose","isEverySelectedBlockAllowed","selected","allowed","filter","id","includes","length","shouldRenderItem","selectedBlocks","allowedBlocks","Array","isArray","PluginBlockSettingsMenuItem","icon","label","onClick","small","role","_react","createElement","BlockSettingsMenuControls","onClose","MenuItem","compose","undefined","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-item.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockSettingsMenuControls } from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\n\nconst isEverySelectedBlockAllowed = ( selected, allowed ) =>\n\tselected.filter( ( id ) => ! allowed.includes( id ) ).length === 0;\n\n/**\n * Plugins may want to add an item to the menu either for every block\n * or only for the specific ones provided in the `allowedBlocks` component property.\n *\n * If there are multiple blocks selected the item will be rendered if every block\n * is of one allowed type (not necessarily the same).\n *\n * @param {string[]} selectedBlocks Array containing the names of the blocks selected\n * @param {string[]} allowedBlocks Array containing the names of the blocks allowed\n * @return {boolean} Whether the item will be rendered or not.\n */\nconst shouldRenderItem = ( selectedBlocks, allowedBlocks ) =>\n\t! Array.isArray( allowedBlocks ) ||\n\tisEverySelectedBlockAllowed( selectedBlocks, allowedBlocks );\n\n/**\n * Renders a new item in the block settings menu.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.\n * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.\n * @param {string} props.label The menu item text.\n * @param {Function} props.onClick Callback function to be executed when the user click the menu item.\n * @param {boolean} [props.small] Whether to render the label or not.\n * @param {string} [props.role] The ARIA role for the menu item.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var __ = wp.i18n.__;\n * var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;\n *\n * function doOnClick(){\n * \t// To be called when the user clicks the menu item.\n * }\n *\n * function MyPluginBlockSettingsMenuItem() {\n * \treturn React.createElement(\n * \t\tPluginBlockSettingsMenuItem,\n * \t\t{\n * \t\t\tallowedBlocks: [ 'core/paragraph' ],\n * \t\t\ticon: 'dashicon-name',\n * \t\t\tlabel: __( 'Menu item text' ),\n * \t\t\tonClick: doOnClick,\n * \t\t}\n * \t);\n * }\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { __ } from '@wordpress/i18n';\n * import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';\n *\n * const doOnClick = ( ) => {\n * // To be called when the user clicks the menu item.\n * };\n *\n * const MyPluginBlockSettingsMenuItem = () => (\n * <PluginBlockSettingsMenuItem\n * \t\tallowedBlocks={ [ 'core/paragraph' ] }\n * \t\ticon='dashicon-name'\n * \t\tlabel={ __( 'Menu item text' ) }\n * \t\tonClick={ doOnClick } />\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nconst PluginBlockSettingsMenuItem = ( {\n\tallowedBlocks,\n\ticon,\n\tlabel,\n\tonClick,\n\tsmall,\n\trole,\n} ) => (\n\t<BlockSettingsMenuControls>\n\t\t{ ( { selectedBlocks, onClose } ) => {\n\t\t\tif ( ! shouldRenderItem( selectedBlocks, allowedBlocks ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ compose( onClick, onClose ) }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ small ? label : undefined }\n\t\t\t\t\trole={ role }\n\t\t\t\t>\n\t\t\t\t\t{ ! small && label }\n\t\t\t\t</MenuItem>\n\t\t\t);\n\t\t} }\n\t</BlockSettingsMenuControls>\n);\n\nexport default PluginBlockSettingsMenuItem;\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA,MAAMG,2BAA2B,GAAGA,CAAEC,QAAQ,EAAEC,OAAO,KACtDD,QAAQ,CAACE,MAAM,CAAIC,EAAE,IAAM,CAAEF,OAAO,CAACG,QAAQ,CAAED,EAAG,CAAE,CAAC,CAACE,MAAM,KAAK,CAAC;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAGA,CAAEC,cAAc,EAAEC,aAAa,KACvD,CAAEC,KAAK,CAACC,OAAO,CAAEF,aAAc,CAAC,IAChCT,2BAA2B,CAAEQ,cAAc,EAAEC,aAAc,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,2BAA2B,GAAGA,CAAE;EACrCH,aAAa;EACbI,IAAI;EACJC,KAAK;EACLC,OAAO;EACPC,KAAK;EACLC;AACD,CAAC,KACA,IAAAC,MAAA,CAAAC,aAAA,EAACvB,YAAA,CAAAwB,yBAAyB,QACvB,CAAE;EAAEZ,cAAc;EAAEa;AAAQ,CAAC,KAAM;EACpC,IAAK,CAAEd,gBAAgB,CAAEC,cAAc,EAAEC,aAAc,CAAC,EAAG;IAC1D,OAAO,IAAI;EACZ;EACA,OACC,IAAAS,MAAA,CAAAC,aAAA,EAACrB,WAAA,CAAAwB,QAAQ;IACRP,OAAO,EAAG,IAAAQ,gBAAO,EAAER,OAAO,EAAEM,OAAQ,CAAG;IACvCR,IAAI,EAAGA,IAAM;IACbC,KAAK,EAAGE,KAAK,GAAGF,KAAK,GAAGU,SAAW;IACnCP,IAAI,EAAGA;EAAM,GAEX,CAAED,KAAK,IAAIF,KACJ,CAAC;AAEb,CAC0B,CAC3B;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaf,2BAA2B"}
@@ -1,126 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = require("react");
9
- var _components = require("@wordpress/components");
10
- var _plugins = require("@wordpress/plugins");
11
- var _data = require("@wordpress/data");
12
- var _warning = _interopRequireDefault(require("@wordpress/warning"));
13
- var _editor = require("@wordpress/editor");
14
- var _lockUnlock = require("../../../lock-unlock");
15
- /**
16
- * WordPress dependencies
17
- */
18
-
19
- /**
20
- * Internal dependencies
21
- */
22
-
23
- const {
24
- Fill,
25
- Slot
26
- } = (0, _components.createSlotFill)('PluginDocumentSettingPanel');
27
- const {
28
- EnablePluginDocumentSettingPanelOption
29
- } = (0, _lockUnlock.unlock)(_editor.privateApis);
30
-
31
- /**
32
- * Renders items below the Status & Availability panel in the Document Sidebar.
33
- *
34
- * @param {Object} props Component properties.
35
- * @param {string} props.name Required. A machine-friendly name for the panel.
36
- * @param {string} [props.className] An optional class name added to the row.
37
- * @param {string} [props.title] The title of the panel
38
- * @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.
39
- * @param {Element} props.children Children to be rendered
40
- *
41
- * @example
42
- * ```js
43
- * // Using ES5 syntax
44
- * var el = React.createElement;
45
- * var __ = wp.i18n.__;
46
- * var registerPlugin = wp.plugins.registerPlugin;
47
- * var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
48
- *
49
- * function MyDocumentSettingPlugin() {
50
- * return el(
51
- * PluginDocumentSettingPanel,
52
- * {
53
- * className: 'my-document-setting-plugin',
54
- * title: 'My Panel',
55
- * name: 'my-panel',
56
- * },
57
- * __( 'My Document Setting Panel' )
58
- * );
59
- * }
60
- *
61
- * registerPlugin( 'my-document-setting-plugin', {
62
- * render: MyDocumentSettingPlugin
63
- * } );
64
- * ```
65
- *
66
- * @example
67
- * ```jsx
68
- * // Using ESNext syntax
69
- * import { registerPlugin } from '@wordpress/plugins';
70
- * import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
71
- *
72
- * const MyDocumentSettingTest = () => (
73
- * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
74
- * <p>My Document Setting Panel</p>
75
- * </PluginDocumentSettingPanel>
76
- * );
77
- *
78
- * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
79
- * ```
80
- *
81
- * @return {Component} The component to be rendered.
82
- */
83
- const PluginDocumentSettingPanel = ({
84
- name,
85
- className,
86
- title,
87
- icon,
88
- children
89
- }) => {
90
- const {
91
- name: pluginName
92
- } = (0, _plugins.usePluginContext)();
93
- const panelName = `${pluginName}/${name}`;
94
- const {
95
- opened,
96
- isEnabled
97
- } = (0, _data.useSelect)(select => {
98
- const {
99
- isEditorPanelOpened,
100
- isEditorPanelEnabled
101
- } = select(_editor.store);
102
- return {
103
- opened: isEditorPanelOpened(panelName),
104
- isEnabled: isEditorPanelEnabled(panelName)
105
- };
106
- }, [panelName]);
107
- const {
108
- toggleEditorPanelOpened
109
- } = (0, _data.useDispatch)(_editor.store);
110
- if (undefined === name) {
111
- typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('PluginDocumentSettingPanel requires a name property.') : void 0;
112
- }
113
- return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(EnablePluginDocumentSettingPanelOption, {
114
- label: title,
115
- panelName: panelName
116
- }), (0, _react.createElement)(Fill, null, isEnabled && (0, _react.createElement)(_components.PanelBody, {
117
- className: className,
118
- title: title,
119
- icon: icon,
120
- opened: opened,
121
- onToggle: () => toggleEditorPanelOpened(panelName)
122
- }, children)));
123
- };
124
- PluginDocumentSettingPanel.Slot = Slot;
125
- var _default = exports.default = PluginDocumentSettingPanel;
126
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_components","require","_plugins","_data","_warning","_interopRequireDefault","_editor","_lockUnlock","Fill","Slot","createSlotFill","EnablePluginDocumentSettingPanelOption","unlock","editorPrivateApis","PluginDocumentSettingPanel","name","className","title","icon","children","pluginName","usePluginContext","panelName","opened","isEnabled","useSelect","select","isEditorPanelOpened","isEditorPanelEnabled","editorStore","toggleEditorPanelOpened","useDispatch","undefined","SCRIPT_DEBUG","warning","_react","createElement","Fragment","label","PanelBody","onToggle","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelBody } from '@wordpress/components';\nimport { usePluginContext } from '@wordpress/plugins';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport warning from '@wordpress/warning';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' );\nconst { EnablePluginDocumentSettingPanelOption } = unlock( editorPrivateApis );\n\n/**\n * Renders items below the Status & Availability panel in the Document Sidebar.\n *\n * @param {Object} props Component properties.\n * @param {string} props.name Required. A machine-friendly name for the panel.\n * @param {string} [props.className] An optional class name added to the row.\n * @param {string} [props.title] The title of the panel\n * @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.\n * @param {Element} props.children Children to be rendered\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var __ = wp.i18n.__;\n * var registerPlugin = wp.plugins.registerPlugin;\n * var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;\n *\n * function MyDocumentSettingPlugin() {\n * \treturn el(\n * \t\tPluginDocumentSettingPanel,\n * \t\t{\n * \t\t\tclassName: 'my-document-setting-plugin',\n * \t\t\ttitle: 'My Panel',\n * \t\t\tname: 'my-panel',\n * \t\t},\n * \t\t__( 'My Document Setting Panel' )\n * \t);\n * }\n *\n * registerPlugin( 'my-document-setting-plugin', {\n * \t\trender: MyDocumentSettingPlugin\n * } );\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { registerPlugin } from '@wordpress/plugins';\n * import { PluginDocumentSettingPanel } from '@wordpress/edit-post';\n *\n * const MyDocumentSettingTest = () => (\n * \t\t<PluginDocumentSettingPanel className=\"my-document-setting-plugin\" title=\"My Panel\" name=\"my-panel\">\n *\t\t\t<p>My Document Setting Panel</p>\n *\t\t</PluginDocumentSettingPanel>\n *\t);\n *\n * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nconst PluginDocumentSettingPanel = ( {\n\tname,\n\tclassName,\n\ttitle,\n\ticon,\n\tchildren,\n} ) => {\n\tconst { name: pluginName } = usePluginContext();\n\tconst panelName = `${ pluginName }/${ name }`;\n\tconst { opened, isEnabled } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorPanelOpened, isEditorPanelEnabled } =\n\t\t\t\tselect( editorStore );\n\n\t\t\treturn {\n\t\t\t\topened: isEditorPanelOpened( panelName ),\n\t\t\t\tisEnabled: isEditorPanelEnabled( panelName ),\n\t\t\t};\n\t\t},\n\t\t[ panelName ]\n\t);\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( undefined === name ) {\n\t\twarning( 'PluginDocumentSettingPanel requires a name property.' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<EnablePluginDocumentSettingPanelOption\n\t\t\t\tlabel={ title }\n\t\t\t\tpanelName={ panelName }\n\t\t\t/>\n\t\t\t<Fill>\n\t\t\t\t{ isEnabled && (\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\topened={ opened }\n\t\t\t\t\t\tonToggle={ () => toggleEditorPanelOpened( panelName ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t) }\n\t\t\t</Fill>\n\t\t</>\n\t);\n};\n\nPluginDocumentSettingPanel.Slot = Slot;\n\nexport default PluginDocumentSettingPanel;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAQA,IAAAM,WAAA,GAAAN,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA,MAAM;EAAEO,IAAI;EAAEC;AAAK,CAAC,GAAG,IAAAC,0BAAc,EAAE,4BAA6B,CAAC;AACrE,MAAM;EAAEC;AAAuC,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGA,CAAE;EACpCC,IAAI;EACJC,SAAS;EACTC,KAAK;EACLC,IAAI;EACJC;AACD,CAAC,KAAM;EACN,MAAM;IAAEJ,IAAI,EAAEK;EAAW,CAAC,GAAG,IAAAC,yBAAgB,EAAC,CAAC;EAC/C,MAAMC,SAAS,GAAI,GAAGF,UAAY,IAAIL,IAAM,EAAC;EAC7C,MAAM;IAAEQ,MAAM;IAAEC;EAAU,CAAC,GAAG,IAAAC,eAAS,EACpCC,MAAM,IAAM;IACb,MAAM;MAAEC,mBAAmB;MAAEC;IAAqB,CAAC,GAClDF,MAAM,CAAEG,aAAY,CAAC;IAEtB,OAAO;MACNN,MAAM,EAAEI,mBAAmB,CAAEL,SAAU,CAAC;MACxCE,SAAS,EAAEI,oBAAoB,CAAEN,SAAU;IAC5C,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,CACZ,CAAC;EACD,MAAM;IAAEQ;EAAwB,CAAC,GAAG,IAAAC,iBAAW,EAAEF,aAAY,CAAC;EAE9D,IAAKG,SAAS,KAAKjB,IAAI,EAAG;IACzB,OAAAkB,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EAAE,sDAAuD,CAAC;EAClE;EAEA,OACC,IAAAC,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAACzB,sCAAsC;IACtC2B,KAAK,EAAGrB,KAAO;IACfK,SAAS,EAAGA;EAAW,CACvB,CAAC,EACF,IAAAa,MAAA,CAAAC,aAAA,EAAC5B,IAAI,QACFgB,SAAS,IACV,IAAAW,MAAA,CAAAC,aAAA,EAACpC,WAAA,CAAAuC,SAAS;IACTvB,SAAS,EAAGA,SAAW;IACvBC,KAAK,EAAGA,KAAO;IACfC,IAAI,EAAGA,IAAM;IACbK,MAAM,EAAGA,MAAQ;IACjBiB,QAAQ,EAAGA,CAAA,KAAMV,uBAAuB,CAAER,SAAU;EAAG,GAErDH,QACQ,CAEP,CACL,CAAC;AAEL,CAAC;AAEDL,0BAA0B,CAACL,IAAI,GAAGA,IAAI;AAAC,IAAAgC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAExB7B,0BAA0B"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- var _icons = require("@wordpress/icons");
9
- var _data = require("@wordpress/data");
10
- var _components = require("@wordpress/components");
11
- var _editor = require("@wordpress/editor");
12
- /**
13
- * WordPress dependencies
14
- */
15
-
16
- function TemplateSummary() {
17
- const template = (0, _data.useSelect)(select => {
18
- const {
19
- getCurrentPost
20
- } = select(_editor.store);
21
- return getCurrentPost();
22
- }, []);
23
- if (!template) {
24
- return null;
25
- }
26
- return (0, _react.createElement)(_components.PanelBody, null, (0, _react.createElement)(_components.Flex, {
27
- align: "flex-start",
28
- gap: "3"
29
- }, (0, _react.createElement)(_components.FlexItem, null, (0, _react.createElement)(_icons.Icon, {
30
- icon: _icons.layout
31
- })), (0, _react.createElement)(_components.FlexBlock, null, (0, _react.createElement)("h2", {
32
- className: "edit-post-template-summary__title"
33
- }, template?.title || template?.slug), (0, _react.createElement)("p", null, template?.description))));
34
- }
35
- var _default = exports.default = TemplateSummary;
36
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_icons","require","_data","_components","_editor","TemplateSummary","template","useSelect","select","getCurrentPost","editorStore","_react","createElement","PanelBody","Flex","align","gap","FlexItem","Icon","icon","layout","FlexBlock","className","title","slug","description","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/sidebar/template-summary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon, layout } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { Flex, FlexItem, FlexBlock, PanelBody } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\n\nfunction TemplateSummary() {\n\tconst template = useSelect( ( select ) => {\n\t\tconst { getCurrentPost } = select( editorStore );\n\t\treturn getCurrentPost();\n\t}, [] );\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody>\n\t\t\t<Flex align=\"flex-start\" gap=\"3\">\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Icon icon={ layout } />\n\t\t\t\t</FlexItem>\n\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<h2 className=\"edit-post-template-summary__title\">\n\t\t\t\t\t\t{ template?.title || template?.slug }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p>{ template?.description }</p>\n\t\t\t\t</FlexBlock>\n\t\t\t</Flex>\n\t\t</PanelBody>\n\t);\n}\n\nexport default TemplateSummary;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMA,SAASI,eAAeA,CAAA,EAAG;EAC1B,MAAMC,QAAQ,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACzC,MAAM;MAAEC;IAAe,CAAC,GAAGD,MAAM,CAAEE,aAAY,CAAC;IAChD,OAAOD,cAAc,CAAC,CAAC;EACxB,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEH,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OACC,IAAAK,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAU,SAAS,QACT,IAAAF,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAW,IAAI;IAACC,KAAK,EAAC,YAAY;IAACC,GAAG,EAAC;EAAG,GAC/B,IAAAL,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAc,QAAQ,QACR,IAAAN,MAAA,CAAAC,aAAA,EAACZ,MAAA,CAAAkB,IAAI;IAACC,IAAI,EAAGC;EAAQ,CAAE,CACd,CAAC,EAEX,IAAAT,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAkB,SAAS,QACT,IAAAV,MAAA,CAAAC,aAAA;IAAIU,SAAS,EAAC;EAAmC,GAC9ChB,QAAQ,EAAEiB,KAAK,IAAIjB,QAAQ,EAAEkB,IAC5B,CAAC,EACL,IAAAb,MAAA,CAAAC,aAAA,aAAKN,QAAQ,EAAEmB,WAAgB,CACrB,CACN,CACI,CAAC;AAEd;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcvB,eAAe"}