@wordpress/editor 13.28.5 → 13.30.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 (144) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/block-removal-warnings/index.js +70 -0
  3. package/build/components/block-removal-warnings/index.js.map +1 -0
  4. package/build/components/commands/index.js +209 -0
  5. package/build/components/commands/index.js.map +1 -0
  6. package/build/components/commands/index.native.js +9 -0
  7. package/build/components/commands/index.native.js.map +1 -0
  8. package/build/components/document-bar/index.js +78 -67
  9. package/build/components/document-bar/index.js.map +1 -1
  10. package/build/components/document-outline/check.js +8 -7
  11. package/build/components/document-outline/check.js.map +1 -1
  12. package/build/components/document-outline/index.js +26 -27
  13. package/build/components/document-outline/index.js.map +1 -1
  14. package/build/components/document-tools/index.js +5 -3
  15. package/build/components/document-tools/index.js.map +1 -1
  16. package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
  17. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  18. package/build/components/global-keyboard-shortcuts/index.js +20 -2
  19. package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
  20. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
  21. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  22. package/build/components/list-view-sidebar/index.js +1 -1
  23. package/build/components/list-view-sidebar/index.js.map +1 -1
  24. package/build/components/mode-switcher/index.js +86 -0
  25. package/build/components/mode-switcher/index.js.map +1 -0
  26. package/build/components/post-locked-modal/index.js.map +1 -1
  27. package/build/components/post-preview-button/index.js +2 -1
  28. package/build/components/post-preview-button/index.js.map +1 -1
  29. package/build/components/post-publish-button/index.js +2 -1
  30. package/build/components/post-publish-button/index.js.map +1 -1
  31. package/build/components/post-publish-panel/index.js.map +1 -1
  32. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  33. package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  34. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  35. package/build/components/post-title/index.js +0 -5
  36. package/build/components/post-title/index.js.map +1 -1
  37. package/build/components/post-title/index.native.js.map +1 -1
  38. package/build/components/post-title/post-title-raw.js.map +1 -1
  39. package/build/components/post-view-link/index.js +2 -1
  40. package/build/components/post-view-link/index.js.map +1 -1
  41. package/build/components/provider/index.js +8 -1
  42. package/build/components/provider/index.js.map +1 -1
  43. package/build/components/provider/index.native.js +4 -9
  44. package/build/components/provider/index.native.js.map +1 -1
  45. package/build/components/provider/use-block-editor-settings.js +1 -1
  46. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  47. package/build/components/provider/use-hide-blocks-from-inserter.js +53 -0
  48. package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
  49. package/build/private-apis.js +2 -0
  50. package/build/private-apis.js.map +1 -1
  51. package/build/store/actions.js +69 -2
  52. package/build/store/actions.js.map +1 -1
  53. package/build/store/selectors.js +13 -1
  54. package/build/store/selectors.js.map +1 -1
  55. package/build-module/components/block-removal-warnings/index.js +64 -0
  56. package/build-module/components/block-removal-warnings/index.js.map +1 -0
  57. package/build-module/components/commands/index.js +202 -0
  58. package/build-module/components/commands/index.js.map +1 -0
  59. package/build-module/components/commands/index.native.js +3 -0
  60. package/build-module/components/commands/index.native.js.map +1 -0
  61. package/build-module/components/document-bar/index.js +81 -70
  62. package/build-module/components/document-bar/index.js.map +1 -1
  63. package/build-module/components/document-outline/check.js +9 -8
  64. package/build-module/components/document-outline/check.js.map +1 -1
  65. package/build-module/components/document-outline/index.js +26 -26
  66. package/build-module/components/document-outline/index.js.map +1 -1
  67. package/build-module/components/document-tools/index.js +5 -3
  68. package/build-module/components/document-tools/index.js.map +1 -1
  69. package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
  70. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  71. package/build-module/components/global-keyboard-shortcuts/index.js +20 -2
  72. package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
  73. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
  74. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  75. package/build-module/components/list-view-sidebar/index.js +1 -1
  76. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  77. package/build-module/components/mode-switcher/index.js +80 -0
  78. package/build-module/components/mode-switcher/index.js.map +1 -0
  79. package/build-module/components/post-locked-modal/index.js.map +1 -1
  80. package/build-module/components/post-preview-button/index.js +2 -1
  81. package/build-module/components/post-preview-button/index.js.map +1 -1
  82. package/build-module/components/post-publish-button/index.js +2 -1
  83. package/build-module/components/post-publish-button/index.js.map +1 -1
  84. package/build-module/components/post-publish-panel/index.js.map +1 -1
  85. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  86. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  87. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  88. package/build-module/components/post-title/index.js +0 -5
  89. package/build-module/components/post-title/index.js.map +1 -1
  90. package/build-module/components/post-title/index.native.js.map +1 -1
  91. package/build-module/components/post-title/post-title-raw.js.map +1 -1
  92. package/build-module/components/post-view-link/index.js +2 -1
  93. package/build-module/components/post-view-link/index.js.map +1 -1
  94. package/build-module/components/provider/index.js +8 -1
  95. package/build-module/components/provider/index.js.map +1 -1
  96. package/build-module/components/provider/index.native.js +4 -10
  97. package/build-module/components/provider/index.native.js.map +1 -1
  98. package/build-module/components/provider/use-block-editor-settings.js +1 -1
  99. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  100. package/build-module/components/provider/use-hide-blocks-from-inserter.js +47 -0
  101. package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
  102. package/build-module/private-apis.js +2 -0
  103. package/build-module/private-apis.js.map +1 -1
  104. package/build-module/store/actions.js +66 -0
  105. package/build-module/store/actions.js.map +1 -1
  106. package/build-module/store/selectors.js +12 -0
  107. package/build-module/store/selectors.js.map +1 -1
  108. package/build-style/style-rtl.css +4 -47
  109. package/build-style/style.css +4 -47
  110. package/package.json +32 -32
  111. package/src/components/block-removal-warnings/index.js +92 -0
  112. package/src/components/commands/index.js +210 -0
  113. package/src/components/commands/index.native.js +2 -0
  114. package/src/components/document-bar/index.js +115 -94
  115. package/src/components/document-bar/style.scss +4 -37
  116. package/src/components/document-outline/check.js +8 -10
  117. package/src/components/document-outline/index.js +18 -23
  118. package/src/components/document-outline/test/index.js +26 -7
  119. package/src/components/document-tools/index.js +3 -3
  120. package/src/components/editor-help/intro-to-blocks.native.js +1 -1
  121. package/src/components/entities-saved-states/entity-type-list.js +1 -1
  122. package/src/components/global-keyboard-shortcuts/index.js +35 -4
  123. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +20 -0
  124. package/src/components/list-view-sidebar/index.js +1 -1
  125. package/src/components/mode-switcher/index.js +90 -0
  126. package/src/components/post-locked-modal/index.js +1 -1
  127. package/src/components/post-preview-button/index.js +1 -0
  128. package/src/components/post-publish-button/index.js +1 -0
  129. package/src/components/post-publish-panel/index.js +1 -1
  130. package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
  131. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +3 -3
  132. package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  133. package/src/components/post-title/index.js +0 -3
  134. package/src/components/post-title/index.native.js +2 -2
  135. package/src/components/post-title/post-title-raw.js +1 -1
  136. package/src/components/post-view-link/index.js +1 -0
  137. package/src/components/provider/index.js +9 -0
  138. package/src/components/provider/index.native.js +7 -6
  139. package/src/components/provider/use-block-editor-settings.js +0 -3
  140. package/src/components/provider/use-hide-blocks-from-inserter.js +81 -0
  141. package/src/private-apis.js +2 -0
  142. package/src/store/actions.js +95 -0
  143. package/src/store/selectors.js +12 -0
  144. package/src/store/test/actions.js +82 -0
@@ -0,0 +1,202 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect, useDispatch } from '@wordpress/data';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { code, listView, external } from '@wordpress/icons';
7
+ import { useCommandLoader } from '@wordpress/commands';
8
+ import { store as preferencesStore } from '@wordpress/preferences';
9
+ import { store as noticesStore } from '@wordpress/notices';
10
+ import { store as blockEditorStore } from '@wordpress/block-editor';
11
+ import { store as coreStore } from '@wordpress/core-data';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { store as editorStore } from '../../store';
17
+ function useEditorCommandLoader() {
18
+ const {
19
+ editorMode,
20
+ isListViewOpen,
21
+ showBlockBreadcrumbs,
22
+ isDistractionFree,
23
+ isTopToolbar,
24
+ isFocusMode,
25
+ isPreviewMode,
26
+ isViewable,
27
+ isCodeEditingEnabled,
28
+ isRichEditingEnabled
29
+ } = useSelect(select => {
30
+ var _get, _getPostType$viewable;
31
+ const {
32
+ get
33
+ } = select(preferencesStore);
34
+ const {
35
+ isListViewOpened,
36
+ getCurrentPostType,
37
+ getEditorSettings
38
+ } = select(editorStore);
39
+ const {
40
+ getSettings
41
+ } = select(blockEditorStore);
42
+ const {
43
+ getPostType
44
+ } = select(coreStore);
45
+ return {
46
+ editorMode: (_get = get('core', 'editorMode')) !== null && _get !== void 0 ? _get : 'visual',
47
+ isListViewOpen: isListViewOpened(),
48
+ showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
49
+ isDistractionFree: get('core', 'distractionFree'),
50
+ isFocusMode: get('core', 'focusMode'),
51
+ isTopToolbar: get('core', 'fixedToolbar'),
52
+ isPreviewMode: getSettings().__unstableIsPreviewMode,
53
+ isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
54
+ isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
55
+ isRichEditingEnabled: getEditorSettings().richEditingEnabled
56
+ };
57
+ }, []);
58
+ const {
59
+ toggle
60
+ } = useDispatch(preferencesStore);
61
+ const {
62
+ createInfoNotice
63
+ } = useDispatch(noticesStore);
64
+ const {
65
+ __unstableSaveForPreview,
66
+ setIsListViewOpened,
67
+ switchEditorMode,
68
+ toggleDistractionFree
69
+ } = useDispatch(editorStore);
70
+ const {
71
+ getCurrentPostId
72
+ } = useSelect(editorStore);
73
+ const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
74
+ if (isPreviewMode) {
75
+ return {
76
+ commands: [],
77
+ isLoading: false
78
+ };
79
+ }
80
+ const commands = [];
81
+ commands.push({
82
+ name: 'core/toggle-distraction-free',
83
+ label: isDistractionFree ? __('Exit Distraction Free') : __('Enter Distraction Free '),
84
+ callback: ({
85
+ close
86
+ }) => {
87
+ toggleDistractionFree();
88
+ close();
89
+ }
90
+ });
91
+ commands.push({
92
+ name: 'core/toggle-spotlight-mode',
93
+ label: __('Toggle spotlight'),
94
+ callback: ({
95
+ close
96
+ }) => {
97
+ toggle('core', 'focusMode');
98
+ close();
99
+ createInfoNotice(isFocusMode ? __('Spotlight off.') : __('Spotlight on.'), {
100
+ id: 'core/editor/toggle-spotlight-mode/notice',
101
+ type: 'snackbar',
102
+ actions: [{
103
+ label: __('Undo'),
104
+ onClick: () => {
105
+ toggle('core', 'focusMode');
106
+ }
107
+ }]
108
+ });
109
+ }
110
+ });
111
+ commands.push({
112
+ name: 'core/toggle-list-view',
113
+ label: isListViewOpen ? __('Close List View') : __('Open List View'),
114
+ icon: listView,
115
+ callback: ({
116
+ close
117
+ }) => {
118
+ setIsListViewOpened(!isListViewOpen);
119
+ close();
120
+ createInfoNotice(isListViewOpen ? __('List View off.') : __('List View on.'), {
121
+ id: 'core/editor/toggle-list-view/notice',
122
+ type: 'snackbar'
123
+ });
124
+ }
125
+ });
126
+ commands.push({
127
+ name: 'core/toggle-top-toolbar',
128
+ label: __('Toggle top toolbar'),
129
+ callback: ({
130
+ close
131
+ }) => {
132
+ toggle('core', 'fixedToolbar');
133
+ if (isDistractionFree) {
134
+ toggleDistractionFree();
135
+ }
136
+ close();
137
+ createInfoNotice(isTopToolbar ? __('Top toolbar off.') : __('Top toolbar on.'), {
138
+ id: 'core/editor/toggle-top-toolbar/notice',
139
+ type: 'snackbar',
140
+ actions: [{
141
+ label: __('Undo'),
142
+ onClick: () => {
143
+ toggle('core', 'fixedToolbar');
144
+ }
145
+ }]
146
+ });
147
+ }
148
+ });
149
+ if (allowSwitchEditorMode) {
150
+ commands.push({
151
+ name: 'core/toggle-code-editor',
152
+ label: editorMode === 'visual' ? __('Open code editor') : __('Exit code editor'),
153
+ icon: code,
154
+ callback: ({
155
+ close
156
+ }) => {
157
+ switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
158
+ close();
159
+ }
160
+ });
161
+ }
162
+ commands.push({
163
+ name: 'core/toggle-breadcrumbs',
164
+ label: showBlockBreadcrumbs ? __('Hide block breadcrumbs') : __('Show block breadcrumbs'),
165
+ callback: ({
166
+ close
167
+ }) => {
168
+ toggle('core', 'showBlockBreadcrumbs');
169
+ close();
170
+ createInfoNotice(showBlockBreadcrumbs ? __('Breadcrumbs hidden.') : __('Breadcrumbs visible.'), {
171
+ id: 'core/editor/toggle-breadcrumbs/notice',
172
+ type: 'snackbar'
173
+ });
174
+ }
175
+ });
176
+ if (isViewable) {
177
+ commands.push({
178
+ name: 'core/preview-link',
179
+ label: __('Preview in a new tab'),
180
+ icon: external,
181
+ callback: async ({
182
+ close
183
+ }) => {
184
+ close();
185
+ const postId = getCurrentPostId();
186
+ const link = await __unstableSaveForPreview();
187
+ window.open(link, `wp-preview-${postId}`);
188
+ }
189
+ });
190
+ }
191
+ return {
192
+ commands,
193
+ isLoading: false
194
+ };
195
+ }
196
+ export default function useCommands() {
197
+ useCommandLoader({
198
+ name: 'core/editor/edit-ui',
199
+ hook: useEditorCommandLoader
200
+ });
201
+ }
202
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","useDispatch","__","code","listView","external","useCommandLoader","store","preferencesStore","noticesStore","blockEditorStore","coreStore","editorStore","useEditorCommandLoader","editorMode","isListViewOpen","showBlockBreadcrumbs","isDistractionFree","isTopToolbar","isFocusMode","isPreviewMode","isViewable","isCodeEditingEnabled","isRichEditingEnabled","select","_get","_getPostType$viewable","get","isListViewOpened","getCurrentPostType","getEditorSettings","getSettings","getPostType","__unstableIsPreviewMode","viewable","codeEditingEnabled","richEditingEnabled","toggle","createInfoNotice","__unstableSaveForPreview","setIsListViewOpened","switchEditorMode","toggleDistractionFree","getCurrentPostId","allowSwitchEditorMode","commands","isLoading","push","name","label","callback","close","id","type","actions","onClick","icon","postId","link","window","open","useCommands","hook"],"sources":["@wordpress/editor/src/components/commands/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { code, listView, external } from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction useEditorCommandLoader() {\n\tconst {\n\t\teditorMode,\n\t\tisListViewOpen,\n\t\tshowBlockBreadcrumbs,\n\t\tisDistractionFree,\n\t\tisTopToolbar,\n\t\tisFocusMode,\n\t\tisPreviewMode,\n\t\tisViewable,\n\t\tisCodeEditingEnabled,\n\t\tisRichEditingEnabled,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isListViewOpened, getCurrentPostType, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\teditorMode: get( 'core', 'editorMode' ) ?? 'visual',\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisFocusMode: get( 'core', 'focusMode' ),\n\t\t\tisTopToolbar: get( 'core', 'fixedToolbar' ),\n\t\t\tisPreviewMode: getSettings().__unstableIsPreviewMode,\n\t\t\tisViewable: getPostType( getCurrentPostType() )?.viewable ?? false,\n\t\t\tisCodeEditingEnabled: getEditorSettings().codeEditingEnabled,\n\t\t\tisRichEditingEnabled: getEditorSettings().richEditingEnabled,\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst {\n\t\t__unstableSaveForPreview,\n\t\tsetIsListViewOpened,\n\t\tswitchEditorMode,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editorStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\tconst allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;\n\n\tif ( isPreviewMode ) {\n\t\treturn { commands: [], isLoading: false };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/toggle-distraction-free',\n\t\tlabel: isDistractionFree\n\t\t\t? __( 'Exit Distraction Free' )\n\t\t\t: __( 'Enter Distraction Free ' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggleDistractionFree();\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFocusMode ? __( 'Spotlight off.' ) : __( 'Spotlight on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-spotlight-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-list-view',\n\t\tlabel: isListViewOpen\n\t\t\t? __( 'Close List View' )\n\t\t\t: __( 'Open List View' ),\n\t\ticon: listView,\n\t\tcallback: ( { close } ) => {\n\t\t\tsetIsListViewOpened( ! isListViewOpen );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisListViewOpen ? __( 'List View off.' ) : __( 'List View on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-list-view/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\ttoggleDistractionFree();\n\t\t\t}\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisTopToolbar\n\t\t\t\t\t? __( 'Top toolbar off.' )\n\t\t\t\t\t: __( 'Top toolbar on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-top-toolbar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( allowSwitchEditorMode ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/toggle-code-editor',\n\t\t\tlabel:\n\t\t\t\teditorMode === 'visual'\n\t\t\t\t\t? __( 'Open code editor' )\n\t\t\t\t\t: __( 'Exit code editor' ),\n\t\t\ticon: code,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tcommands.push( {\n\t\tname: 'core/toggle-breadcrumbs',\n\t\tlabel: showBlockBreadcrumbs\n\t\t\t? __( 'Hide block breadcrumbs' )\n\t\t\t: __( 'Show block breadcrumbs' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'showBlockBreadcrumbs' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tshowBlockBreadcrumbs\n\t\t\t\t\t? __( 'Breadcrumbs hidden.' )\n\t\t\t\t\t: __( 'Breadcrumbs visible.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-breadcrumbs/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( isViewable ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/preview-link',\n\t\t\tlabel: __( 'Preview in a new tab' ),\n\t\t\ticon: external,\n\t\t\tcallback: async ( { close } ) => {\n\t\t\t\tclose();\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst link = await __unstableSaveForPreview();\n\t\t\t\twindow.open( link, `wp-preview-${ postId }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport default function useCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/editor/edit-ui',\n\t\thook: useEditorCommandLoader,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,kBAAkB;AAC3D,SAASC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AuC;QAC3CC,IAAI,EAAE;MACP,CACD,CAAC;IACF;EACD,CAAE,CAAC;EAEH,IAAKhC,UAAU,EAAG;IACjBwB,QAAQ,CAACE,IAAI,CAAE;MACdC,IAAI,EAAE,mBAAmB;MACzBC,KAAK,EAAE/C,EAAE,CAAE,sBAAuB,CAAC;MACnCsD,IAAI,EAAEnD,QAAQ;MACd6C,QAAQ,EAAE,MAAAA,CAAQ;QAAEC;MAAM,CAAC,KAAM;QAChCA,KAAK,CAAC,CAAC;QACP,MAAMM,MAAM,GAAGd,gBAAgB,CAAC,CAAC;QACjC,MAAMe,IAAI,GAAG,MAAMnB,wBAAwB,CAAC,CAAC;QAC7CoB,MAAM,CAACC,IAAI,CAAEF,IAAI,EAAG,cAAcD,MAAQ,EAAE,CAAC;MAC9C;IACD,CAAE,CAAC;EACJ;EAEA,OAAO;IACNZ,QAAQ;IACRC,SAAS,EAAE;EACZ,CAAC;AACF;AAEA,eAAe,SAASe,WAAWA,CAAA,EAAG;EACrCvD,gBAAgB,CAAE;IACjB0C,IAAI,EAAE,qBAAqB;IAC3Bc,IAAI,EAAEjD;EACP,CAAE,CAAC;AACJ"}
@@ -0,0 +1,3 @@
1
+ // Commands are disabled in the mobile native version.
2
+ export default function useCommands() {}
3
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCommands"],"sources":["@wordpress/editor/src/components/commands/index.native.js"],"sourcesContent":["// Commands are disabled in the mobile native version.\nexport default function useCommands() {}\n"],"mappings":"AAAA;AACA,eAAe,SAASA,WAAWA,CAAA,EAAG,CAAC"}
@@ -9,19 +9,20 @@ import classnames from 'classnames';
9
9
  */
10
10
  import { __, isRTL, sprintf } from '@wordpress/i18n';
11
11
  import { useSelect, useDispatch } from '@wordpress/data';
12
- import { Button, __experimentalText as Text, __experimentalHStack as HStack } from '@wordpress/components';
12
+ import { Button, __experimentalText as Text, __unstableMotion as motion, __unstableAnimatePresence as AnimatePresence } from '@wordpress/components';
13
13
  import { BlockIcon } from '@wordpress/block-editor';
14
14
  import { chevronLeftSmall, chevronRightSmall, page as pageIcon, navigation as navigationIcon, symbol } from '@wordpress/icons';
15
15
  import { displayShortcut } from '@wordpress/keycodes';
16
- import { useEntityRecord } from '@wordpress/core-data';
16
+ import { store as coreStore } from '@wordpress/core-data';
17
17
  import { store as commandsStore } from '@wordpress/commands';
18
- import { useState, useEffect, useRef } from '@wordpress/element';
18
+ import { useRef, useEffect } from '@wordpress/element';
19
+ import { useReducedMotion } from '@wordpress/compose';
19
20
 
20
21
  /**
21
22
  * Internal dependencies
22
23
  */
23
24
  import { store as editorStore } from '../../store';
24
- const typeLabels = {
25
+ const TYPE_LABELS = {
25
26
  // translators: 1: Pattern title.
26
27
  wp_pattern: __('Editing pattern: %s'),
27
28
  // translators: 1: Navigation menu title.
@@ -31,108 +32,118 @@ const typeLabels = {
31
32
  // translators: 1: Template part title.
32
33
  wp_template_part: __('Editing template part: %s')
33
34
  };
34
- const icons = {
35
+ const ICONS = {
35
36
  wp_block: symbol,
36
37
  wp_navigation: navigationIcon
37
38
  };
39
+ const TEMPLATE_POST_TYPES = ['wp_template', 'wp_template_part'];
40
+ const GLOBAL_POST_TYPES = [...TEMPLATE_POST_TYPES, 'wp_block', 'wp_navigation'];
41
+ const MotionButton = motion(Button);
38
42
  export default function DocumentBar() {
43
+ var _ICONS$postType;
39
44
  const {
40
45
  postType,
41
- postId,
46
+ document,
47
+ isResolving,
48
+ templateIcon,
49
+ templateTitle,
42
50
  onNavigateToPreviousEntityRecord
43
51
  } = useSelect(select => {
44
52
  const {
45
- getCurrentPostId,
46
53
  getCurrentPostType,
47
- getEditorSettings: getSettings
54
+ getCurrentPostId,
55
+ getEditorSettings,
56
+ __experimentalGetTemplateInfo: getTemplateInfo
48
57
  } = select(editorStore);
58
+ const {
59
+ getEditedEntityRecord,
60
+ getIsResolving
61
+ } = select(coreStore);
62
+ const _postType = getCurrentPostType();
63
+ const _postId = getCurrentPostId();
64
+ const _document = getEditedEntityRecord('postType', _postType, _postId);
65
+ const _templateInfo = getTemplateInfo(_document);
49
66
  return {
50
- postType: getCurrentPostType(),
51
- postId: getCurrentPostId(),
52
- onNavigateToPreviousEntityRecord: getSettings().onNavigateToPreviousEntityRecord,
53
- getEditorSettings: getSettings
67
+ postType: _postType,
68
+ document: _document,
69
+ isResolving: getIsResolving('getEditedEntityRecord', 'postType', _postType, _postId),
70
+ templateIcon: _templateInfo.icon,
71
+ templateTitle: _templateInfo.title,
72
+ onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
54
73
  };
55
74
  }, []);
56
- const handleOnBack = () => {
57
- if (onNavigateToPreviousEntityRecord) {
58
- onNavigateToPreviousEntityRecord();
59
- }
60
- };
61
- return createElement(BaseDocumentActions, {
62
- postType: postType,
63
- postId: postId,
64
- onBack: onNavigateToPreviousEntityRecord ? handleOnBack : undefined
65
- });
66
- }
67
- function BaseDocumentActions({
68
- postType,
69
- postId,
70
- onBack
71
- }) {
72
- var _icons$postType;
73
75
  const {
74
76
  open: openCommandCenter
75
77
  } = useDispatch(commandsStore);
76
- const {
77
- editedRecord: doc,
78
- isResolving
79
- } = useEntityRecord('postType', postType, postId);
80
- const {
81
- templateIcon,
82
- templateTitle
83
- } = useSelect(select => {
84
- const {
85
- __experimentalGetTemplateInfo: getTemplateInfo
86
- } = select(editorStore);
87
- const templateInfo = getTemplateInfo(doc);
88
- return {
89
- templateIcon: templateInfo.icon,
90
- templateTitle: templateInfo.title
91
- };
92
- });
93
- const isNotFound = !doc && !isResolving;
94
- const icon = (_icons$postType = icons[postType]) !== null && _icons$postType !== void 0 ? _icons$postType : pageIcon;
95
- const [isAnimated, setIsAnimated] = useState(false);
96
- const isMounting = useRef(true);
97
- const isTemplate = ['wp_template', 'wp_template_part'].includes(postType);
98
- const isGlobalEntity = ['wp_template', 'wp_navigation', 'wp_template_part', 'wp_block'].includes(postType);
78
+ const isReducedMotion = useReducedMotion();
79
+ const isNotFound = !document && !isResolving;
80
+ const icon = (_ICONS$postType = ICONS[postType]) !== null && _ICONS$postType !== void 0 ? _ICONS$postType : pageIcon;
81
+ const isTemplate = TEMPLATE_POST_TYPES.includes(postType);
82
+ const isGlobalEntity = GLOBAL_POST_TYPES.includes(postType);
83
+ const hasBackButton = !!onNavigateToPreviousEntityRecord;
84
+ const title = isTemplate ? templateTitle : document.title;
85
+ const mounted = useRef(false);
99
86
  useEffect(() => {
100
- if (!isMounting.current) {
101
- setIsAnimated(true);
102
- }
103
- isMounting.current = false;
104
- }, [postType, postId]);
105
- const title = isTemplate ? templateTitle : doc.title;
87
+ mounted.current = true;
88
+ }, []);
106
89
  return createElement("div", {
107
90
  className: classnames('editor-document-bar', {
108
- 'has-back-button': !!onBack,
109
- 'is-animated': isAnimated,
91
+ 'has-back-button': hasBackButton,
110
92
  'is-global': isGlobalEntity
111
93
  })
112
- }, onBack && createElement(Button, {
94
+ }, createElement(AnimatePresence, null, hasBackButton && createElement(MotionButton, {
113
95
  className: "editor-document-bar__back",
114
96
  icon: isRTL() ? chevronRightSmall : chevronLeftSmall,
115
97
  onClick: event => {
116
98
  event.stopPropagation();
117
- onBack();
99
+ onNavigateToPreviousEntityRecord();
118
100
  },
119
- size: "compact"
120
- }, __('Back')), isNotFound && createElement(Text, null, __('Document not found')), !isNotFound && createElement(Button, {
101
+ size: "compact",
102
+ initial: mounted.current ? {
103
+ opacity: 0,
104
+ transform: 'translateX(15%)'
105
+ } : false // Don't show entry animation when DocumentBar mounts.
106
+ ,
107
+ animate: {
108
+ opacity: 1,
109
+ transform: 'translateX(0%)'
110
+ },
111
+ exit: {
112
+ opacity: 0,
113
+ transform: 'translateX(15%)'
114
+ },
115
+ transition: isReducedMotion ? {
116
+ duration: 0
117
+ } : undefined
118
+ }, __('Back'))), isNotFound ? createElement(Text, null, __('Document not found')) : createElement(Button, {
121
119
  className: "editor-document-bar__command",
122
120
  onClick: () => openCommandCenter(),
123
121
  size: "compact"
124
- }, createElement(HStack, {
125
- className: "editor-document-bar__title",
126
- spacing: 1,
127
- justify: "center"
122
+ }, createElement(motion.div, {
123
+ className: "editor-document-bar__title"
124
+ // Force entry animation when the back button is added or removed.
125
+ ,
126
+ key: hasBackButton,
127
+ initial: mounted.current ? {
128
+ opacity: 0,
129
+ transform: hasBackButton ? 'translateX(15%)' : 'translateX(-15%)'
130
+ } : false // Don't show entry animation when DocumentBar mounts.
131
+ ,
132
+ animate: {
133
+ opacity: 1,
134
+ transform: 'translateX(0%)'
135
+ },
136
+ transition: isReducedMotion ? {
137
+ duration: 0
138
+ } : undefined
128
139
  }, createElement(BlockIcon, {
129
140
  icon: isTemplate ? templateIcon : icon
130
141
  }), createElement(Text, {
131
142
  size: "body",
132
143
  as: "h1",
133
- "aria-label": typeLabels[postType] ?
144
+ "aria-label": TYPE_LABELS[postType] ?
134
145
  // eslint-disable-next-line @wordpress/valid-sprintf
135
- sprintf(typeLabels[postType], title) : undefined
146
+ sprintf(TYPE_LABELS[postType], title) : undefined
136
147
  }, title)), createElement("span", {
137
148
  className: "editor-document-bar__shortcut"
138
149
  }, displayShortcut.primary('k'))));
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","__","isRTL","sprintf","useSelect","useDispatch","Button","__experimentalText","Text","__experimentalHStack","HStack","BlockIcon","chevronLeftSmall","chevronRightSmall","page","pageIcon","navigation","navigationIcon","symbol","displayShortcut","useEntityRecord","store","commandsStore","useState","useEffect","useRef","editorStore","typeLabels","wp_pattern","wp_navigation","wp_template","wp_template_part","icons","wp_block","DocumentBar","postType","postId","onNavigateToPreviousEntityRecord","select","getCurrentPostId","getCurrentPostType","getEditorSettings","getSettings","handleOnBack","createElement","BaseDocumentActions","onBack","undefined","_icons$postType","open","openCommandCenter","editedRecord","doc","isResolving","templateIcon","templateTitle","__experimentalGetTemplateInfo","getTemplateInfo","templateInfo","icon","title","isNotFound","isAnimated","setIsAnimated","isMounting","isTemplate","includes","isGlobalEntity","current","className","onClick","event","stopPropagation","size","spacing","justify","as","primary"],"sources":["@wordpress/editor/src/components/document-bar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport {\n\tchevronLeftSmall,\n\tchevronRightSmall,\n\tpage as pageIcon,\n\tnavigation as navigationIcon,\n\tsymbol,\n} from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useEntityRecord } from '@wordpress/core-data';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { useState, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nconst typeLabels = {\n\t// translators: 1: Pattern title.\n\twp_pattern: __( 'Editing pattern: %s' ),\n\t// translators: 1: Navigation menu title.\n\twp_navigation: __( 'Editing navigation menu: %s' ),\n\t// translators: 1: Template title.\n\twp_template: __( 'Editing template: %s' ),\n\t// translators: 1: Template part title.\n\twp_template_part: __( 'Editing template part: %s' ),\n};\n\nconst icons = {\n\twp_block: symbol,\n\twp_navigation: navigationIcon,\n};\n\nexport default function DocumentBar() {\n\tconst { postType, postId, onNavigateToPreviousEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetEditorSettings: getSettings,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t\tpostId: getCurrentPostId(),\n\t\t\t\tonNavigateToPreviousEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToPreviousEntityRecord,\n\t\t\t\tgetEditorSettings: getSettings,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst handleOnBack = () => {\n\t\tif ( onNavigateToPreviousEntityRecord ) {\n\t\t\tonNavigateToPreviousEntityRecord();\n\t\t}\n\t};\n\n\treturn (\n\t\t<BaseDocumentActions\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t\tonBack={\n\t\t\t\tonNavigateToPreviousEntityRecord ? handleOnBack : undefined\n\t\t\t}\n\t\t/>\n\t);\n}\n\nfunction BaseDocumentActions( { postType, postId, onBack } ) {\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\tconst { editedRecord: doc, isResolving } = useEntityRecord(\n\t\t'postType',\n\t\tpostType,\n\t\tpostId\n\t);\n\tconst { templateIcon, templateTitle } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\t\tconst templateInfo = getTemplateInfo( doc );\n\t\treturn {\n\t\t\ttemplateIcon: templateInfo.icon,\n\t\t\ttemplateTitle: templateInfo.title,\n\t\t};\n\t} );\n\tconst isNotFound = ! doc && ! isResolving;\n\tconst icon = icons[ postType ] ?? pageIcon;\n\tconst [ isAnimated, setIsAnimated ] = useState( false );\n\tconst isMounting = useRef( true );\n\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\tpostType\n\t);\n\tconst isGlobalEntity = [\n\t\t'wp_template',\n\t\t'wp_navigation',\n\t\t'wp_template_part',\n\t\t'wp_block',\n\t].includes( postType );\n\n\tuseEffect( () => {\n\t\tif ( ! isMounting.current ) {\n\t\t\tsetIsAnimated( true );\n\t\t}\n\t\tisMounting.current = false;\n\t}, [ postType, postId ] );\n\n\tconst title = isTemplate ? templateTitle : doc.title;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'editor-document-bar', {\n\t\t\t\t'has-back-button': !! onBack,\n\t\t\t\t'is-animated': isAnimated,\n\t\t\t\t'is-global': isGlobalEntity,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ onBack && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__back\"\n\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tonBack();\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ isNotFound && <Text>{ __( 'Document not found' ) }</Text> }\n\t\t\t{ ! isNotFound && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__command\"\n\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tclassName=\"editor-document-bar__title\"\n\t\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockIcon icon={ isTemplate ? templateIcon : icon } />\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\ttypeLabels[ postType ]\n\t\t\t\t\t\t\t\t\t? // eslint-disable-next-line @wordpress/valid-sprintf\n\t\t\t\t\t\t\t\t\t sprintf( typeLabels[ postType ], title )\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<span className=\"editor-document-bar__shortcut\">\n\t\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,EAAEC,KAAK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,KAAMpB,iBAAiB,CAAC,CAAG;IACrCuB,IAAI,EAAC;EAAS,GAEd7B,aAAA,CAAClC,MAAM;IACN2D,SAAS,EAAC,4BAA4B;IACtCK,OAAO,EAAG,CAAG;IACbC,OAAO,EAAC;EAAQ,GAEhB/B,aAAA,CAACjC,SAAS;IAACgD,IAAI,EAAGM,UAAU,GAAGX,YAAY,GAAGK;EAAM,CAAE,CAAC,EACvDf,aAAA,CAACpC,IAAI;IACJiE,IAAI,EAAC,MAAM;IACXG,EAAE,EAAC,IAAI;IACP,cACCjD,UAAU,CAAEQ,QAAQ,CAAE;IACnB;IACAhC,OAAO,CAAEwB,UAAU,CAAEQ,QAAQ,CAAE,EAAEyB,KAAM,CAAC,GACxCb;EACH,GAECa,KACG,CACC,CAAC,EACThB,aAAA;IAAMyB,SAAS,EAAC;EAA+B,GAC5ClD,eAAe,CAAC0D,OAAO,CAAE,GAAI,CAC1B,CACC,CAEL,CAAC;AAER"}
1
+ {"version":3,"names":["classnames","__","isRTL","sprintf","useSelect","useDispatch","Button","__experimentalText","Text","__unstableMotion","motion","__unstableAnimatePresence","AnimatePresence","BlockIcon","chevronLeftSmall","chevronRightSmall","page","pageIcon","navigation","navigationIcon","symbol","displayShortcut","store","coreStore","commandsStore","useRef","useEffect","useReducedMotion","editorStore","TYPE_LABELS","wp_pattern","wp_navigation","wp_template","wp_template_part","ICONS","wp_block","TEMPLATE_POST_TYPES","GLOBAL_POST_TYPES","MotionButton","DocumentBar","_ICONS$postType","postType","document","isResolving","templateIcon","templateTitle","onNavigateToPreviousEntityRecord","select","getCurrentPostType","getCurrentPostId","getEditorSettings","__experimentalGetTemplateInfo","getTemplateInfo","getEditedEntityRecord","getIsResolving","_postType","_postId","_document","_templateInfo","icon","title","open","openCommandCenter","isReducedMotion","isNotFound","isTemplate","includes","isGlobalEntity","hasBackButton","mounted","current","createElement","className","onClick","event","stopPropagation","size","initial","opacity","transform","animate","exit","transition","duration","undefined","div","key","as","primary"],"sources":["@wordpress/editor/src/components/document-bar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport {\n\tchevronLeftSmall,\n\tchevronRightSmall,\n\tpage as pageIcon,\n\tnavigation as navigationIcon,\n\tsymbol,\n} from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nconst TYPE_LABELS = {\n\t// translators: 1: Pattern title.\n\twp_pattern: __( 'Editing pattern: %s' ),\n\t// translators: 1: Navigation menu title.\n\twp_navigation: __( 'Editing navigation menu: %s' ),\n\t// translators: 1: Template title.\n\twp_template: __( 'Editing template: %s' ),\n\t// translators: 1: Template part title.\n\twp_template_part: __( 'Editing template part: %s' ),\n};\n\nconst ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigationIcon,\n};\n\nconst TEMPLATE_POST_TYPES = [ 'wp_template', 'wp_template_part' ];\n\nconst GLOBAL_POST_TYPES = [\n\t...TEMPLATE_POST_TYPES,\n\t'wp_block',\n\t'wp_navigation',\n];\n\nconst MotionButton = motion( Button );\n\nexport default function DocumentBar() {\n\tconst {\n\t\tpostType,\n\t\tdocument,\n\t\tisResolving,\n\t\ttemplateIcon,\n\t\ttemplateTitle,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t\tgetEditorSettings,\n\t\t\t__experimentalGetTemplateInfo: getTemplateInfo,\n\t\t} = select( editorStore );\n\t\tconst { getEditedEntityRecord, getIsResolving } = select( coreStore );\n\t\tconst _postType = getCurrentPostType();\n\t\tconst _postId = getCurrentPostId();\n\t\tconst _document = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\t_postId\n\t\t);\n\t\tconst _templateInfo = getTemplateInfo( _document );\n\t\treturn {\n\t\t\tpostType: _postType,\n\t\t\tdocument: _document,\n\t\t\tisResolving: getIsResolving(\n\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\t_postId\n\t\t\t),\n\t\t\ttemplateIcon: _templateInfo.icon,\n\t\t\ttemplateTitle: _templateInfo.title,\n\t\t\tonNavigateToPreviousEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t};\n\t}, [] );\n\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\tconst isReducedMotion = useReducedMotion();\n\n\tconst isNotFound = ! document && ! isResolving;\n\tconst icon = ICONS[ postType ] ?? pageIcon;\n\tconst isTemplate = TEMPLATE_POST_TYPES.includes( postType );\n\tconst isGlobalEntity = GLOBAL_POST_TYPES.includes( postType );\n\tconst hasBackButton = !! onNavigateToPreviousEntityRecord;\n\tconst title = isTemplate ? templateTitle : document.title;\n\n\tconst mounted = useRef( false );\n\tuseEffect( () => {\n\t\tmounted.current = true;\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'editor-document-bar', {\n\t\t\t\t'has-back-button': hasBackButton,\n\t\t\t\t'is-global': isGlobalEntity,\n\t\t\t} ) }\n\t\t>\n\t\t\t<AnimatePresence>\n\t\t\t\t{ hasBackButton && (\n\t\t\t\t\t<MotionButton\n\t\t\t\t\t\tclassName=\"editor-document-bar__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\tonNavigateToPreviousEntityRecord();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmounted.current\n\t\t\t\t\t\t\t\t? { opacity: 0, transform: 'translateX(15%)' }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ { opacity: 1, transform: 'translateX(0%)' } }\n\t\t\t\t\t\texit={ { opacity: 0, transform: 'translateX(15%)' } }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</MotionButton>\n\t\t\t\t) }\n\t\t\t</AnimatePresence>\n\t\t\t{ isNotFound ? (\n\t\t\t\t<Text>{ __( 'Document not found' ) }</Text>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__command\"\n\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName=\"editor-document-bar__title\"\n\t\t\t\t\t\t// Force entry animation when the back button is added or removed.\n\t\t\t\t\t\tkey={ hasBackButton }\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmounted.current\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t\t\t\ttransform: hasBackButton\n\t\t\t\t\t\t\t\t\t\t\t? 'translateX(15%)'\n\t\t\t\t\t\t\t\t\t\t\t: 'translateX(-15%)',\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t\ttransform: 'translateX(0%)',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockIcon icon={ isTemplate ? templateIcon : icon } />\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\tTYPE_LABELS[ postType ]\n\t\t\t\t\t\t\t\t\t? // eslint-disable-next-line @wordpress/valid-sprintf\n\t\t\t\t\t\t\t\t\t sprintf( TYPE_LABELS[ postType ], title )\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</motion.div>\n\t\t\t\t\t<span className=\"editor-document-bar__shortcut\">\n\t\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,EAAEC,KAAK,EAAEC,OAAO,QAAQ,iBAAiB;AACpD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,MAAM,EACNC,kBAAkB,IAAIC,IAAI,EAC1BC,gBAAgB,IAAIC,MAAM,EAC1BC,yBAAyB,IAAIC,eAAe,QACtC,uBAAuB;AAC9B,SAASC,SAAS,QAAQ,yBAAyB;AACnD,SACCC,gBAAgB,EAChBC,iBAAiB,EACjBC,IAAI,IAAIC,QAAQ,EAChBC,UAAU,IAAIC,cAAc,EAC5BC,MAAM,QACA,kBAAkB;AACzB,SAASC,eAAe,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jB;IACH,CAAC,GACD,KAAK,CAAC;IACT;IACDY,OAAO,EAAG;MACTF,OAAO,EAAE,CAAC;MACVC,SAAS,EAAE;IACZ,CAAG;IACHG,UAAU,EACTnB,eAAe,GAAG;MAAEoB,QAAQ,EAAE;IAAE,CAAC,GAAGC;EACpC,GAEDb,aAAA,CAAC1D,SAAS;IAAC8C,IAAI,EAAGM,UAAU,GAAGrB,YAAY,GAAGe;EAAM,CAAE,CAAC,EACvDY,aAAA,CAAC/D,IAAI;IACJoE,IAAI,EAAC,MAAM;IACXW,EAAE,EAAC,IAAI;IACP,cACC1D,WAAW,CAAEY,QAAQ,CAAE;IACpB;IACAtC,OAAO,CAAE0B,WAAW,CAAEY,QAAQ,CAAE,EAAEmB,KAAM,CAAC,GACzCwB;EACH,GAECxB,KACG,CACK,CAAC,EACbW,aAAA;IAAMC,SAAS,EAAC;EAA+B,GAC5CnD,eAAe,CAACmE,OAAO,CAAE,GAAI,CAC1B,CACC,CAEL,CAAC;AAER"}
@@ -1,19 +1,20 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { withSelect } from '@wordpress/data';
4
+ import { useSelect } from '@wordpress/data';
5
5
  import { store as blockEditorStore } from '@wordpress/block-editor';
6
- function DocumentOutlineCheck({
7
- blocks,
6
+ export default function DocumentOutlineCheck({
8
7
  children
9
8
  }) {
10
- const headings = blocks.filter(block => block.name === 'core/heading');
11
- if (headings.length < 1) {
9
+ const hasHeadings = useSelect(select => {
10
+ const {
11
+ getGlobalBlockCount
12
+ } = select(blockEditorStore);
13
+ return getGlobalBlockCount('core/heading') > 0;
14
+ });
15
+ if (hasHeadings) {
12
16
  return null;
13
17
  }
14
18
  return children;
15
19
  }
16
- export default withSelect(select => ({
17
- blocks: select(blockEditorStore).getBlocks()
18
- }))(DocumentOutlineCheck);
19
20
  //# sourceMappingURL=check.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withSelect","store","blockEditorStore","DocumentOutlineCheck","blocks","children","headings","filter","block","name","length","select","getBlocks"],"sources":["@wordpress/editor/src/components/document-outline/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction DocumentOutlineCheck( { blocks, children } ) {\n\tconst headings = blocks.filter(\n\t\t( block ) => block.name === 'core/heading'\n\t);\n\n\tif ( headings.length < 1 ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => ( {\n\tblocks: select( blockEditorStore ).getBlocks(),\n} ) )( DocumentOutlineCheck );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAEnE,SAASC,oBAAoBA,CAAE;EAAEC,MAAM;EAAEC;AAAS,CAAC,EAAG;EACrD,MAAMC,QAAQ,GAAGF,MAAM,CAACG,MAAM,CAC3BC,KAAK,IAAMA,KAAK,CAACC,IAAI,KAAK,cAC7B,CAAC;EAED,IAAKH,QAAQ,CAACI,MAAM,GAAG,CAAC,EAAG;IAC1B,OAAO,IAAI;EACZ;EAEA,OAAOL,QAAQ;AAChB;AAEA,eAAeL,UAAU,CAAIW,MAAM,KAAQ;EAC1CP,MAAM,EAAEO,MAAM,CAAET,gBAAiB,CAAC,CAACU,SAAS,CAAC;AAC9C,CAAC,CAAG,CAAC,CAAET,oBAAqB,CAAC"}
1
+ {"version":3,"names":["useSelect","store","blockEditorStore","DocumentOutlineCheck","children","hasHeadings","select","getGlobalBlockCount"],"sources":["@wordpress/editor/src/components/document-outline/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nexport default function DocumentOutlineCheck( { children } ) {\n\tconst hasHeadings = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount } = select( blockEditorStore );\n\n\t\treturn getGlobalBlockCount( 'core/heading' ) > 0;\n\t} );\n\n\tif ( hasHeadings ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAEnE,eAAe,SAASC,oBAAoBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC5D,MAAMC,WAAW,GAAGL,SAAS,CAAIM,MAAM,IAAM;IAC5C,MAAM;MAAEC;IAAoB,CAAC,GAAGD,MAAM,CAAEJ,gBAAiB,CAAC;IAE1D,OAAOK,mBAAmB,CAAE,cAAe,CAAC,GAAG,CAAC;EACjD,CAAE,CAAC;EAEH,IAAKF,WAAW,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB"}
@@ -3,8 +3,7 @@ import { createElement } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { __ } from '@wordpress/i18n';
6
- import { compose } from '@wordpress/compose';
7
- import { withSelect, useDispatch } from '@wordpress/data';
6
+ import { useDispatch, useSelect } from '@wordpress/data';
8
7
  import { create, getTextContent } from '@wordpress/rich-text';
9
8
  import { store as blockEditorStore } from '@wordpress/block-editor';
10
9
  import { store as coreStore } from '@wordpress/core-data';
@@ -136,17 +135,36 @@ const computeOutlineHeadings = (blocks = []) => {
136
135
  });
137
136
  };
138
137
  const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.length === 0;
139
- export const DocumentOutline = ({
140
- blocks = [],
141
- title,
138
+ export default function DocumentOutline({
142
139
  onSelect,
143
140
  isTitleSupported,
144
141
  hasOutlineItemsDisabled
145
- }) => {
146
- const headings = computeOutlineHeadings(blocks);
142
+ }) {
147
143
  const {
148
144
  selectBlock
149
145
  } = useDispatch(blockEditorStore);
146
+ const {
147
+ blocks,
148
+ title
149
+ } = useSelect(select => {
150
+ var _postType$supports$ti;
151
+ const {
152
+ getBlocks
153
+ } = select(blockEditorStore);
154
+ const {
155
+ getEditedPostAttribute
156
+ } = select(editorStore);
157
+ const {
158
+ getPostType
159
+ } = select(coreStore);
160
+ const postType = getPostType(getEditedPostAttribute('type'));
161
+ return {
162
+ title: getEditedPostAttribute('title'),
163
+ blocks: getBlocks(),
164
+ isTitleSupported: (_postType$supports$ti = postType?.supports?.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
165
+ };
166
+ });
167
+ const headings = computeOutlineHeadings(blocks);
150
168
  if (headings.length < 1) {
151
169
  return createElement("div", {
152
170
  className: "editor-document-outline has-no-headings"
@@ -190,23 +208,5 @@ export const DocumentOutline = ({
190
208
  html: item.attributes.content
191
209
  })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings);
192
210
  })));
193
- };
194
- export default compose(withSelect(select => {
195
- var _postType$supports$ti;
196
- const {
197
- getBlocks
198
- } = select(blockEditorStore);
199
- const {
200
- getEditedPostAttribute
201
- } = select(editorStore);
202
- const {
203
- getPostType
204
- } = select(coreStore);
205
- const postType = getPostType(getEditedPostAttribute('type'));
206
- return {
207
- title: getEditedPostAttribute('title'),
208
- blocks: getBlocks(),
209
- isTitleSupported: (_postType$supports$ti = postType?.supports?.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
210
- };
211
- }))(DocumentOutline);
211
+ }
212
212
  //# sourceMappingURL=index.js.map