@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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 13.30.0 (2024-03-06)
6
+
7
+ ## 13.29.0 (2024-02-21)
8
+
5
9
  ## 13.28.0 (2024-02-09)
6
10
 
7
11
  ## 13.27.0 (2024-01-24)
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = BlockRemovalWarnings;
7
+ var _react = require("react");
8
+ var _i18n = require("@wordpress/i18n");
9
+ var _blockEditor = require("@wordpress/block-editor");
10
+ var _data = require("@wordpress/data");
11
+ var _element = require("@wordpress/element");
12
+ var _lockUnlock = require("../../lock-unlock");
13
+ var _store = require("../../store");
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+ const {
23
+ BlockRemovalWarningModal
24
+ } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
25
+
26
+ // Prevent accidental removal of certain blocks, asking the user for confirmation first.
27
+ const TEMPLATE_BLOCKS = ['core/post-content', 'core/post-template', 'core/query'];
28
+ const BLOCK_REMOVAL_RULES = [{
29
+ // Template blocks.
30
+ // The warning is only shown when a user manipulates templates or template parts.
31
+ postTypes: ['wp_template', 'wp_template_part'],
32
+ callback(removedBlocks) {
33
+ const removedTemplateBlocks = removedBlocks.filter(({
34
+ name
35
+ }) => TEMPLATE_BLOCKS.includes(name));
36
+ if (removedTemplateBlocks.length) {
37
+ return (0, _i18n._n)('Deleting this block will stop your post or page content from displaying on this template. It is not recommended.', 'Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.', removedBlocks.length);
38
+ }
39
+ }
40
+ }, {
41
+ // Pattern overrides.
42
+ // The warning is only shown when the user edits a pattern.
43
+ postTypes: ['wp_block'],
44
+ callback(removedBlocks) {
45
+ const removedBlocksWithOverrides = removedBlocks.filter(({
46
+ attributes
47
+ }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(binding => binding.source === 'core/pattern-overrides'));
48
+ if (removedBlocksWithOverrides.length) {
49
+ return (0, _i18n._n)('The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?', 'Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?', removedBlocks.length);
50
+ }
51
+ }
52
+ }];
53
+ function BlockRemovalWarnings() {
54
+ const currentPostType = (0, _data.useSelect)(select => select(_store.store).getCurrentPostType(), []);
55
+ const removalRulesForPostType = (0, _element.useMemo)(() => BLOCK_REMOVAL_RULES.filter(rule => rule.postTypes.includes(currentPostType)), [currentPostType]);
56
+
57
+ // `BlockRemovalWarnings` is rendered in the editor provider, a shared component
58
+ // across react native and web. However, `BlockRemovalWarningModal` is web only.
59
+ // Check it exists before trying to render it.
60
+ if (!BlockRemovalWarningModal) {
61
+ return null;
62
+ }
63
+ if (!removalRulesForPostType) {
64
+ return null;
65
+ }
66
+ return (0, _react.createElement)(BlockRemovalWarningModal, {
67
+ rules: removalRulesForPostType
68
+ });
69
+ }
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_i18n","require","_blockEditor","_data","_element","_lockUnlock","_store","BlockRemovalWarningModal","unlock","blockEditorPrivateApis","TEMPLATE_BLOCKS","BLOCK_REMOVAL_RULES","postTypes","callback","removedBlocks","removedTemplateBlocks","filter","name","includes","length","_n","removedBlocksWithOverrides","attributes","metadata","bindings","Object","values","some","binding","source","BlockRemovalWarnings","currentPostType","useSelect","select","editorStore","getCurrentPostType","removalRulesForPostType","useMemo","rule","_react","createElement","rules"],"sources":["@wordpress/editor/src/components/block-removal-warnings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { _n } from '@wordpress/i18n';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );\n\n// Prevent accidental removal of certain blocks, asking the user for confirmation first.\nconst TEMPLATE_BLOCKS = [\n\t'core/post-content',\n\t'core/post-template',\n\t'core/query',\n];\nconst BLOCK_REMOVAL_RULES = [\n\t{\n\t\t// Template blocks.\n\t\t// The warning is only shown when a user manipulates templates or template parts.\n\t\tpostTypes: [ 'wp_template', 'wp_template_part' ],\n\t\tcallback( removedBlocks ) {\n\t\t\tconst removedTemplateBlocks = removedBlocks.filter( ( { name } ) =>\n\t\t\t\tTEMPLATE_BLOCKS.includes( name )\n\t\t\t);\n\t\t\tif ( removedTemplateBlocks.length ) {\n\t\t\t\treturn _n(\n\t\t\t\t\t'Deleting this block will stop your post or page content from displaying on this template. It is not recommended.',\n\t\t\t\t\t'Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.',\n\t\t\t\t\tremovedBlocks.length\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t},\n\t{\n\t\t// Pattern overrides.\n\t\t// The warning is only shown when the user edits a pattern.\n\t\tpostTypes: [ 'wp_block' ],\n\t\tcallback( removedBlocks ) {\n\t\t\tconst removedBlocksWithOverrides = removedBlocks.filter(\n\t\t\t\t( { attributes } ) =>\n\t\t\t\t\tattributes?.metadata?.bindings &&\n\t\t\t\t\tObject.values( attributes.metadata.bindings ).some(\n\t\t\t\t\t\t( binding ) =>\n\t\t\t\t\t\t\tbinding.source === 'core/pattern-overrides'\n\t\t\t\t\t)\n\t\t\t);\n\t\t\tif ( removedBlocksWithOverrides.length ) {\n\t\t\t\treturn _n(\n\t\t\t\t\t'The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?',\n\t\t\t\t\t'Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?',\n\t\t\t\t\tremovedBlocks.length\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t},\n];\n\nexport default function BlockRemovalWarnings() {\n\tconst currentPostType = useSelect(\n\t\t( select ) => select( editorStore ).getCurrentPostType(),\n\t\t[]\n\t);\n\n\tconst removalRulesForPostType = useMemo(\n\t\t() =>\n\t\t\tBLOCK_REMOVAL_RULES.filter( ( rule ) =>\n\t\t\t\trule.postTypes.includes( currentPostType )\n\t\t\t),\n\t\t[ currentPostType ]\n\t);\n\n\t// `BlockRemovalWarnings` is rendered in the editor provider, a shared component\n\t// across react native and web. However, `BlockRemovalWarningModal` is web only.\n\t// Check it exists before trying to render it.\n\tif ( ! BlockRemovalWarningModal ) {\n\t\treturn null;\n\t}\n\n\tif ( ! removalRulesForPostType ) {\n\t\treturn null;\n\t}\n\n\treturn <BlockRemovalWarningModal rules={ removalRulesForPostType } />;\n}\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EAAEM;AAAyB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;;AAErE;AACA,MAAMC,eAAe,GAAG,CACvB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,CACZ;AACD,MAAMC,mBAAmB,GAAG,CAC3B;EACC;EACA;EACAC,SAAS,EAAE,CAAE,aAAa,EAAE,kBAAkB,CAAE;EAChDC,QAAQA,CAAEC,aAAa,EAAG;IACzB,MAAMC,qBAAqB,GAAGD,aAAa,CAACE,MAAM,CAAE,CAAE;MAAEC;IAAK,CAAC,KAC7DP,eAAe,CAACQ,QAAQ,CAAED,IAAK,CAChC,CAAC;IACD,IAAKF,qBAAqB,CAACI,MAAM,EAAG;MACnC,OAAO,IAAAC,QAAE,EACR,kHAAkH,EAClH,yHAAyH,EACzHN,aAAa,CAACK,MACf,CAAC;IACF;EACD;AACD,CAAC,EACD;EACC;EACA;EACAP,SAAS,EAAE,CAAE,UAAU,CAAE;EACzBC,QAAQA,CAAEC,aAAa,EAAG;IACzB,MAAMO,0BAA0B,GAAGP,aAAa,CAACE,MAAM,CACtD,CAAE;MAAEM;IAAW,CAAC,KACfA,UAAU,EAAEC,QAAQ,EAAEC,QAAQ,IAC9BC,MAAM,CAACC,MAAM,CAAEJ,UAAU,CAACC,QAAQ,CAACC,QAAS,CAAC,CAACG,IAAI,CAC/CC,OAAO,IACRA,OAAO,CAACC,MAAM,KAAK,wBACrB,CACF,CAAC;IACD,IAAKR,0BAA0B,CAACF,MAAM,EAAG;MACxC,OAAO,IAAAC,QAAE,EACR,6JAA6J,EAC7J,uKAAuK,EACvKN,aAAa,CAACK,MACf,CAAC;IACF;EACD;AACD,CAAC,CACD;AAEc,SAASW,oBAAoBA,CAAA,EAAG;EAC9C,MAAMC,eAAe,GAAG,IAAAC,eAAS,EAC9BC,MAAM,IAAMA,MAAM,CAAEC,YAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC,EACxD,EACD,CAAC;EAED,MAAMC,uBAAuB,GAAG,IAAAC,gBAAO,EACtC,MACC1B,mBAAmB,CAACK,MAAM,CAAIsB,IAAI,IACjCA,IAAI,CAAC1B,SAAS,CAACM,QAAQ,CAAEa,eAAgB,CAC1C,CAAC,EACF,CAAEA,eAAe,CAClB,CAAC;;EAED;EACA;EACA;EACA,IAAK,CAAExB,wBAAwB,EAAG;IACjC,OAAO,IAAI;EACZ;EAEA,IAAK,CAAE6B,uBAAuB,EAAG;IAChC,OAAO,IAAI;EACZ;EAEA,OAAO,IAAAG,MAAA,CAAAC,aAAA,EAACjC,wBAAwB;IAACkC,KAAK,EAAGL;EAAyB,CAAE,CAAC;AACtE"}
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useCommands;
7
+ var _data = require("@wordpress/data");
8
+ var _i18n = require("@wordpress/i18n");
9
+ var _icons = require("@wordpress/icons");
10
+ var _commands = require("@wordpress/commands");
11
+ var _preferences = require("@wordpress/preferences");
12
+ var _notices = require("@wordpress/notices");
13
+ var _blockEditor = require("@wordpress/block-editor");
14
+ var _coreData = require("@wordpress/core-data");
15
+ var _store = require("../../store");
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+
24
+ function useEditorCommandLoader() {
25
+ const {
26
+ editorMode,
27
+ isListViewOpen,
28
+ showBlockBreadcrumbs,
29
+ isDistractionFree,
30
+ isTopToolbar,
31
+ isFocusMode,
32
+ isPreviewMode,
33
+ isViewable,
34
+ isCodeEditingEnabled,
35
+ isRichEditingEnabled
36
+ } = (0, _data.useSelect)(select => {
37
+ var _get, _getPostType$viewable;
38
+ const {
39
+ get
40
+ } = select(_preferences.store);
41
+ const {
42
+ isListViewOpened,
43
+ getCurrentPostType,
44
+ getEditorSettings
45
+ } = select(_store.store);
46
+ const {
47
+ getSettings
48
+ } = select(_blockEditor.store);
49
+ const {
50
+ getPostType
51
+ } = select(_coreData.store);
52
+ return {
53
+ editorMode: (_get = get('core', 'editorMode')) !== null && _get !== void 0 ? _get : 'visual',
54
+ isListViewOpen: isListViewOpened(),
55
+ showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
56
+ isDistractionFree: get('core', 'distractionFree'),
57
+ isFocusMode: get('core', 'focusMode'),
58
+ isTopToolbar: get('core', 'fixedToolbar'),
59
+ isPreviewMode: getSettings().__unstableIsPreviewMode,
60
+ isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
61
+ isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
62
+ isRichEditingEnabled: getEditorSettings().richEditingEnabled
63
+ };
64
+ }, []);
65
+ const {
66
+ toggle
67
+ } = (0, _data.useDispatch)(_preferences.store);
68
+ const {
69
+ createInfoNotice
70
+ } = (0, _data.useDispatch)(_notices.store);
71
+ const {
72
+ __unstableSaveForPreview,
73
+ setIsListViewOpened,
74
+ switchEditorMode,
75
+ toggleDistractionFree
76
+ } = (0, _data.useDispatch)(_store.store);
77
+ const {
78
+ getCurrentPostId
79
+ } = (0, _data.useSelect)(_store.store);
80
+ const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
81
+ if (isPreviewMode) {
82
+ return {
83
+ commands: [],
84
+ isLoading: false
85
+ };
86
+ }
87
+ const commands = [];
88
+ commands.push({
89
+ name: 'core/toggle-distraction-free',
90
+ label: isDistractionFree ? (0, _i18n.__)('Exit Distraction Free') : (0, _i18n.__)('Enter Distraction Free '),
91
+ callback: ({
92
+ close
93
+ }) => {
94
+ toggleDistractionFree();
95
+ close();
96
+ }
97
+ });
98
+ commands.push({
99
+ name: 'core/toggle-spotlight-mode',
100
+ label: (0, _i18n.__)('Toggle spotlight'),
101
+ callback: ({
102
+ close
103
+ }) => {
104
+ toggle('core', 'focusMode');
105
+ close();
106
+ createInfoNotice(isFocusMode ? (0, _i18n.__)('Spotlight off.') : (0, _i18n.__)('Spotlight on.'), {
107
+ id: 'core/editor/toggle-spotlight-mode/notice',
108
+ type: 'snackbar',
109
+ actions: [{
110
+ label: (0, _i18n.__)('Undo'),
111
+ onClick: () => {
112
+ toggle('core', 'focusMode');
113
+ }
114
+ }]
115
+ });
116
+ }
117
+ });
118
+ commands.push({
119
+ name: 'core/toggle-list-view',
120
+ label: isListViewOpen ? (0, _i18n.__)('Close List View') : (0, _i18n.__)('Open List View'),
121
+ icon: _icons.listView,
122
+ callback: ({
123
+ close
124
+ }) => {
125
+ setIsListViewOpened(!isListViewOpen);
126
+ close();
127
+ createInfoNotice(isListViewOpen ? (0, _i18n.__)('List View off.') : (0, _i18n.__)('List View on.'), {
128
+ id: 'core/editor/toggle-list-view/notice',
129
+ type: 'snackbar'
130
+ });
131
+ }
132
+ });
133
+ commands.push({
134
+ name: 'core/toggle-top-toolbar',
135
+ label: (0, _i18n.__)('Toggle top toolbar'),
136
+ callback: ({
137
+ close
138
+ }) => {
139
+ toggle('core', 'fixedToolbar');
140
+ if (isDistractionFree) {
141
+ toggleDistractionFree();
142
+ }
143
+ close();
144
+ createInfoNotice(isTopToolbar ? (0, _i18n.__)('Top toolbar off.') : (0, _i18n.__)('Top toolbar on.'), {
145
+ id: 'core/editor/toggle-top-toolbar/notice',
146
+ type: 'snackbar',
147
+ actions: [{
148
+ label: (0, _i18n.__)('Undo'),
149
+ onClick: () => {
150
+ toggle('core', 'fixedToolbar');
151
+ }
152
+ }]
153
+ });
154
+ }
155
+ });
156
+ if (allowSwitchEditorMode) {
157
+ commands.push({
158
+ name: 'core/toggle-code-editor',
159
+ label: editorMode === 'visual' ? (0, _i18n.__)('Open code editor') : (0, _i18n.__)('Exit code editor'),
160
+ icon: _icons.code,
161
+ callback: ({
162
+ close
163
+ }) => {
164
+ switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
165
+ close();
166
+ }
167
+ });
168
+ }
169
+ commands.push({
170
+ name: 'core/toggle-breadcrumbs',
171
+ label: showBlockBreadcrumbs ? (0, _i18n.__)('Hide block breadcrumbs') : (0, _i18n.__)('Show block breadcrumbs'),
172
+ callback: ({
173
+ close
174
+ }) => {
175
+ toggle('core', 'showBlockBreadcrumbs');
176
+ close();
177
+ createInfoNotice(showBlockBreadcrumbs ? (0, _i18n.__)('Breadcrumbs hidden.') : (0, _i18n.__)('Breadcrumbs visible.'), {
178
+ id: 'core/editor/toggle-breadcrumbs/notice',
179
+ type: 'snackbar'
180
+ });
181
+ }
182
+ });
183
+ if (isViewable) {
184
+ commands.push({
185
+ name: 'core/preview-link',
186
+ label: (0, _i18n.__)('Preview in a new tab'),
187
+ icon: _icons.external,
188
+ callback: async ({
189
+ close
190
+ }) => {
191
+ close();
192
+ const postId = getCurrentPostId();
193
+ const link = await __unstableSaveForPreview();
194
+ window.open(link, `wp-preview-${postId}`);
195
+ }
196
+ });
197
+ }
198
+ return {
199
+ commands,
200
+ isLoading: false
201
+ };
202
+ }
203
+ function useCommands() {
204
+ (0, _commands.useCommandLoader)({
205
+ name: 'core/editor/edit-ui',
206
+ hook: useEditorCommandLoader
207
+ });
208
+ }
209
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","_i18n","_icons","_commands","_preferences","_notices","_blockEditor","_coreData","_store","useEditorCommandLoader","editorMode","isListViewOpen","showBlockBreadcrumbs","isDistractionFree","isTopToolbar","isFocusMode","isPreviewMode","isViewable","isCodeEditingEnabled","isRichEditingEnabled","useSelect","select","_get","_getPostType$viewable","get","preferencesStore","isListViewOpened","getCurrentPostType","getEditorSettings","editorStore","getSettings","blockEditorStore","getPostType","coreStore","__unstableIsPreviewMode","viewable","codeEditingEnabled","richEditingEnabled","toggle","useDispatch","createInfoNotice","noticesStore","__unstableSaveForPreview","setIsListViewOpened","switchEditorMode","toggleDistractionFree","getCurrentPostId","allowSwitchEditorMode","commands","isLoading","push","name","label","__","callback","close","id","type","actions","onClick","icon","listView","code","external","postId","link","window","open","useCommands","useCommandLoader","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":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA,SAASS,sBAAsBA,CAAA,EAAG;EACjC,MAAM;IACLC,UAAU;IACVC,cAAc;IACdC,oBAAoB;IACpBC,iBAAiB;IACjBC,YAAY;IACZC,WAAW;IACXC,aAAa;IACbC,UAAU;IACVC,oBAAoB;IACpBC;EACD,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAC,IAAA,EAAAC,qBAAA;IAC5B,MAAM;MAAEC;IAAI,CAAC,GAAGH,MAAM,CAAEI,kBAAiB,CAAC;IAC1C,MAAM;MAAEC,gBAAgB;MAAEC,kBAAkB;MAAEC;IAAkB,CAAC,GAChEP,MAAM,CAAEQ,YAAY,CAAC;IACtB,MAAM;MAAEC;IAAY,CAAC,GAAGT,MAAM,CAAEU,kBAAiB,CAAC;IAClD,MAAM;MAAEC;IAAY,CAAC,GAAGX,MAAM,CAAEY,eAAU,CAAC;IAE3C,OAAO;MACNvB,UAAU,GAAAY,IAAA,GAAEE,GAAG,CAAE,MAAM,EAAE,YAAa,CAAC,cAAAF,IAAA,cAAAA,IAAA,GAAI,QAAQ;MACnDX,cAAc,EAAEe,gBAAgB,CAAC,CAAC;MAClCd,oBAAoB,EAAEY,GAAG,CAAE,MAAM,EAAE,sBAAuB,C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9B,IAAAA,QAAE,EAAE,wBAAyB,CAAC;IACjCC,QAAQ,EAAEA,CAAE;MAAEC;IAAM,CAAC,KAAM;MAC1BjB,MAAM,CAAE,MAAM,EAAE,sBAAuB,CAAC;MACxCiB,KAAK,CAAC,CAAC;MACPf,gBAAgB,CACf5B,oBAAoB,GACjB,IAAAyC,QAAE,EAAE,qBAAsB,CAAC,GAC3B,IAAAA,QAAE,EAAE,sBAAuB,CAAC,EAC/B;QACCG,EAAE,EAAE,uCAAuC;QAC3CC,IAAI,EAAE;MACP,CACD,CAAC;IACF;EACD,CAAE,CAAC;EAEH,IAAKxC,UAAU,EAAG;IACjB+B,QAAQ,CAACE,IAAI,CAAE;MACdC,IAAI,EAAE,mBAAmB;MACzBC,KAAK,EAAE,IAAAC,QAAE,EAAE,sBAAuB,CAAC;MACnCO,IAAI,EAAEG,eAAQ;MACdT,QAAQ,EAAE,MAAAA,CAAQ;QAAEC;MAAM,CAAC,KAAM;QAChCA,KAAK,CAAC,CAAC;QACP,MAAMS,MAAM,GAAGlB,gBAAgB,CAAC,CAAC;QACjC,MAAMmB,IAAI,GAAG,MAAMvB,wBAAwB,CAAC,CAAC;QAC7CwB,MAAM,CAACC,IAAI,CAAEF,IAAI,EAAG,cAAcD,MAAQ,EAAE,CAAC;MAC9C;IACD,CAAE,CAAC;EACJ;EAEA,OAAO;IACNhB,QAAQ;IACRC,SAAS,EAAE;EACZ,CAAC;AACF;AAEe,SAASmB,WAAWA,CAAA,EAAG;EACrC,IAAAC,0BAAgB,EAAE;IACjBlB,IAAI,EAAE,qBAAqB;IAC3BmB,IAAI,EAAE7D;EACP,CAAE,CAAC;AACJ"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useCommands;
7
+ // Commands are disabled in the mobile native version.
8
+ function useCommands() {}
9
+ //# 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;AACe,SAASA,WAAWA,CAAA,EAAG,CAAC"}
@@ -16,6 +16,7 @@ var _keycodes = require("@wordpress/keycodes");
16
16
  var _coreData = require("@wordpress/core-data");
17
17
  var _commands = require("@wordpress/commands");
18
18
  var _element = require("@wordpress/element");
19
+ var _compose = require("@wordpress/compose");
19
20
  var _store = require("../../store");
20
21
  /**
21
22
  * External dependencies
@@ -29,7 +30,7 @@ var _store = require("../../store");
29
30
  * Internal dependencies
30
31
  */
31
32
 
32
- const typeLabels = {
33
+ const TYPE_LABELS = {
33
34
  // translators: 1: Pattern title.
34
35
  wp_pattern: (0, _i18n.__)('Editing pattern: %s'),
35
36
  // translators: 1: Navigation menu title.
@@ -39,108 +40,118 @@ const typeLabels = {
39
40
  // translators: 1: Template part title.
40
41
  wp_template_part: (0, _i18n.__)('Editing template part: %s')
41
42
  };
42
- const icons = {
43
+ const ICONS = {
43
44
  wp_block: _icons.symbol,
44
45
  wp_navigation: _icons.navigation
45
46
  };
47
+ const TEMPLATE_POST_TYPES = ['wp_template', 'wp_template_part'];
48
+ const GLOBAL_POST_TYPES = [...TEMPLATE_POST_TYPES, 'wp_block', 'wp_navigation'];
49
+ const MotionButton = (0, _components.__unstableMotion)(_components.Button);
46
50
  function DocumentBar() {
51
+ var _ICONS$postType;
47
52
  const {
48
53
  postType,
49
- postId,
54
+ document,
55
+ isResolving,
56
+ templateIcon,
57
+ templateTitle,
50
58
  onNavigateToPreviousEntityRecord
51
59
  } = (0, _data.useSelect)(select => {
52
60
  const {
53
- getCurrentPostId,
54
61
  getCurrentPostType,
55
- getEditorSettings: getSettings
62
+ getCurrentPostId,
63
+ getEditorSettings,
64
+ __experimentalGetTemplateInfo: getTemplateInfo
56
65
  } = select(_store.store);
66
+ const {
67
+ getEditedEntityRecord,
68
+ getIsResolving
69
+ } = select(_coreData.store);
70
+ const _postType = getCurrentPostType();
71
+ const _postId = getCurrentPostId();
72
+ const _document = getEditedEntityRecord('postType', _postType, _postId);
73
+ const _templateInfo = getTemplateInfo(_document);
57
74
  return {
58
- postType: getCurrentPostType(),
59
- postId: getCurrentPostId(),
60
- onNavigateToPreviousEntityRecord: getSettings().onNavigateToPreviousEntityRecord,
61
- getEditorSettings: getSettings
75
+ postType: _postType,
76
+ document: _document,
77
+ isResolving: getIsResolving('getEditedEntityRecord', 'postType', _postType, _postId),
78
+ templateIcon: _templateInfo.icon,
79
+ templateTitle: _templateInfo.title,
80
+ onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
62
81
  };
63
82
  }, []);
64
- const handleOnBack = () => {
65
- if (onNavigateToPreviousEntityRecord) {
66
- onNavigateToPreviousEntityRecord();
67
- }
68
- };
69
- return (0, _react.createElement)(BaseDocumentActions, {
70
- postType: postType,
71
- postId: postId,
72
- onBack: onNavigateToPreviousEntityRecord ? handleOnBack : undefined
73
- });
74
- }
75
- function BaseDocumentActions({
76
- postType,
77
- postId,
78
- onBack
79
- }) {
80
- var _icons$postType;
81
83
  const {
82
84
  open: openCommandCenter
83
85
  } = (0, _data.useDispatch)(_commands.store);
84
- const {
85
- editedRecord: doc,
86
- isResolving
87
- } = (0, _coreData.useEntityRecord)('postType', postType, postId);
88
- const {
89
- templateIcon,
90
- templateTitle
91
- } = (0, _data.useSelect)(select => {
92
- const {
93
- __experimentalGetTemplateInfo: getTemplateInfo
94
- } = select(_store.store);
95
- const templateInfo = getTemplateInfo(doc);
96
- return {
97
- templateIcon: templateInfo.icon,
98
- templateTitle: templateInfo.title
99
- };
100
- });
101
- const isNotFound = !doc && !isResolving;
102
- const icon = (_icons$postType = icons[postType]) !== null && _icons$postType !== void 0 ? _icons$postType : _icons.page;
103
- const [isAnimated, setIsAnimated] = (0, _element.useState)(false);
104
- const isMounting = (0, _element.useRef)(true);
105
- const isTemplate = ['wp_template', 'wp_template_part'].includes(postType);
106
- const isGlobalEntity = ['wp_template', 'wp_navigation', 'wp_template_part', 'wp_block'].includes(postType);
86
+ const isReducedMotion = (0, _compose.useReducedMotion)();
87
+ const isNotFound = !document && !isResolving;
88
+ const icon = (_ICONS$postType = ICONS[postType]) !== null && _ICONS$postType !== void 0 ? _ICONS$postType : _icons.page;
89
+ const isTemplate = TEMPLATE_POST_TYPES.includes(postType);
90
+ const isGlobalEntity = GLOBAL_POST_TYPES.includes(postType);
91
+ const hasBackButton = !!onNavigateToPreviousEntityRecord;
92
+ const title = isTemplate ? templateTitle : document.title;
93
+ const mounted = (0, _element.useRef)(false);
107
94
  (0, _element.useEffect)(() => {
108
- if (!isMounting.current) {
109
- setIsAnimated(true);
110
- }
111
- isMounting.current = false;
112
- }, [postType, postId]);
113
- const title = isTemplate ? templateTitle : doc.title;
95
+ mounted.current = true;
96
+ }, []);
114
97
  return (0, _react.createElement)("div", {
115
98
  className: (0, _classnames.default)('editor-document-bar', {
116
- 'has-back-button': !!onBack,
117
- 'is-animated': isAnimated,
99
+ 'has-back-button': hasBackButton,
118
100
  'is-global': isGlobalEntity
119
101
  })
120
- }, onBack && (0, _react.createElement)(_components.Button, {
102
+ }, (0, _react.createElement)(_components.__unstableAnimatePresence, null, hasBackButton && (0, _react.createElement)(MotionButton, {
121
103
  className: "editor-document-bar__back",
122
104
  icon: (0, _i18n.isRTL)() ? _icons.chevronRightSmall : _icons.chevronLeftSmall,
123
105
  onClick: event => {
124
106
  event.stopPropagation();
125
- onBack();
107
+ onNavigateToPreviousEntityRecord();
126
108
  },
127
- size: "compact"
128
- }, (0, _i18n.__)('Back')), isNotFound && (0, _react.createElement)(_components.__experimentalText, null, (0, _i18n.__)('Document not found')), !isNotFound && (0, _react.createElement)(_components.Button, {
109
+ size: "compact",
110
+ initial: mounted.current ? {
111
+ opacity: 0,
112
+ transform: 'translateX(15%)'
113
+ } : false // Don't show entry animation when DocumentBar mounts.
114
+ ,
115
+ animate: {
116
+ opacity: 1,
117
+ transform: 'translateX(0%)'
118
+ },
119
+ exit: {
120
+ opacity: 0,
121
+ transform: 'translateX(15%)'
122
+ },
123
+ transition: isReducedMotion ? {
124
+ duration: 0
125
+ } : undefined
126
+ }, (0, _i18n.__)('Back'))), isNotFound ? (0, _react.createElement)(_components.__experimentalText, null, (0, _i18n.__)('Document not found')) : (0, _react.createElement)(_components.Button, {
129
127
  className: "editor-document-bar__command",
130
128
  onClick: () => openCommandCenter(),
131
129
  size: "compact"
132
- }, (0, _react.createElement)(_components.__experimentalHStack, {
133
- className: "editor-document-bar__title",
134
- spacing: 1,
135
- justify: "center"
130
+ }, (0, _react.createElement)(_components.__unstableMotion.div, {
131
+ className: "editor-document-bar__title"
132
+ // Force entry animation when the back button is added or removed.
133
+ ,
134
+ key: hasBackButton,
135
+ initial: mounted.current ? {
136
+ opacity: 0,
137
+ transform: hasBackButton ? 'translateX(15%)' : 'translateX(-15%)'
138
+ } : false // Don't show entry animation when DocumentBar mounts.
139
+ ,
140
+ animate: {
141
+ opacity: 1,
142
+ transform: 'translateX(0%)'
143
+ },
144
+ transition: isReducedMotion ? {
145
+ duration: 0
146
+ } : undefined
136
147
  }, (0, _react.createElement)(_blockEditor.BlockIcon, {
137
148
  icon: isTemplate ? templateIcon : icon
138
149
  }), (0, _react.createElement)(_components.__experimentalText, {
139
150
  size: "body",
140
151
  as: "h1",
141
- "aria-label": typeLabels[postType] ?
152
+ "aria-label": TYPE_LABELS[postType] ?
142
153
  // eslint-disable-next-line @wordpress/valid-sprintf
143
- (0, _i18n.sprintf)(typeLabels[postType], title) : undefined
154
+ (0, _i18n.sprintf)(TYPE_LABELS[postType], title) : undefined
144
155
  }, title)), (0, _react.createElement)("span", {
145
156
  className: "editor-document-bar__shortcut"
146
157
  }, _keycodes.displayShortcut.primary('k'))));
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_data","_components","_blockEditor","_icons","_keycodes","_coreData","_commands","_element","_store","typeLabels","wp_pattern","__","wp_navigation","wp_template","wp_template_part","icons","wp_block","symbol","navigationIcon","DocumentBar","postType","postId","onNavigateToPreviousEntityRecord","useSelect","select","getCurrentPostId","getCurrentPostType","getEditorSettings","getSettings","editorStore","handleOnBack","_react","createElement","BaseDocumentActions","onBack","undefined","_icons$postType","open","openCommandCenter","useDispatch","commandsStore","editedRecord","doc","isResolving","useEntityRecord","templateIcon","templateTitle","__experimentalGetTemplateInfo","getTemplateInfo","templateInfo","icon","title","isNotFound","pageIcon","isAnimated","setIsAnimated","useState","isMounting","useRef","isTemplate","includes","isGlobalEntity","useEffect","current","className","classnames","Button","isRTL","chevronRightSmall","chevronLeftSmall","onClick","event","stopPropagation","size","__experimentalText","__experimentalHStack","spacing","justify","BlockIcon","as","sprintf","displayShortcut","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":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAOA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,GAAAV,OAAA;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAqBA;AACA;AACA;;AAGA,MAAMW,UAAU,GAAG;EAClB;EACAC,UAAU,EAAE,IAAAC,QAAE,EAAE,qBAAsB,CAAC;EACvC;EACAC,aAAa,EAAE,IAAAD,QAAE,EAAE,6BAA8B,CAAC;EAClD;EACAE,WAAW,EAAE,IAAAF,QAAE,EAAE,sBAAuB,CAAC;EACzC;EACAG,gBAAgB,EAAE,IAAAH,QAAE,EAAE,2BAA4B;AACnD,CAAC;AAED,MAAMI,KAAK,GAAG;EACbC,QAAQ,EAAEC,aAAM;EAChBL,aAAa,EAAEM;AAChB,CAAC;AAEc,SAASC,WAAWA,CAAA,EAAG;EACrC,MAAM;IAAEC,QAAQ;IAAEC,MAA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_components","_blockEditor","_icons","_keycodes","_coreData","_commands","_element","_compose","_store","TYPE_LABELS","wp_pattern","__","wp_navigation","wp_template","wp_template_part","ICONS","wp_block","symbol","navigationIcon","TEMPLATE_POST_TYPES","GLOBAL_POST_TYPES","MotionButton","motion","Button","DocumentBar","_ICONS$postType","postType","document","isResolving","templateIcon","templateTitle","onNavigateToPreviousEntityRecord","useSelect","select","getCurrentPostType","getCurrentPostId","getEditorSettings","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","getEditedEntityRecord","getIsResolving","coreStore","_postType","_postId","_document","_templateInfo","icon","title","open","openCommandCenter","useDispatch","commandsStore","isReducedMotion","useReducedMotion","isNotFound","pageIcon","isTemplate","includes","isGlobalEntity","hasBackButton","mounted","useRef","useEffect","current","_react","createElement","className","classnames","__unstableAnimatePresence","isRTL","chevronRightSmall","chevronLeftSmall","onClick","event","stopPropagation","size","initial","opacity","transform","animate","exit","transition","duration","undefined","__experimentalText","__unstableMotion","div","key","BlockIcon","as","sprintf","displayShortcut","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":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAOA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAKA,IAAAW,MAAA,GAAAX,OAAA;AAjCA;AACA;AACA;;AAGA;AACA;AACA;;AAuBA;AACA;AACA;;AAGA,MAAMY,WAAW,GAAG;EACnB;EACAC,UAAU,EAAE,IAAAC,QAAE,EAAE,qBAAsB,CAAC;EACvC;EACAC,aAAa,EAAE,IAAAD,QAAE,EAAE,6BAA8B,CAAC;EAClD;EACAE,WAAW,EAAE,IAAAF,QAAE,EAAE,sBAAuB,CAAC;EACzC;EACAG,gBAAgB,EAAE,IAAAH,QAAE,EAAE,2BAA4B;AACnD,CAAC;AAED,MAAMI,KAAK,GAAG;EACbC,QAAQ,EAAEC,aAAM;EAChBL,aAAa,EAAEM;AAChB,CAAC;AAED,MAAMC,mBAAmB,GAAG,CAAE,aAAa,EAAE,kBAAkB,CAAE;AAEjE,MAAMC,iBAAiB,GAAG,CACzB,GAAGD,mBAAmB,EACtB,UAAU,EACV,eAAe,CACf;AAED,MAAME,YAAY,GAAG,IAAAC,4BAAM,EAAEC,kBAAO,CAAC;AAEtB,SAASC,WAAWA,CAAA,EAAG;EAAA,IAA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CAAAC,aAAA;IAAMC,SAAS,EAAC;EAA+B,GAC5CyB,yBAAe,CAACC,OAAO,CAAE,GAAI,CAC1B,CACC,CAEL,CAAC;AAER"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = DocumentOutlineCheck;
7
7
  var _data = require("@wordpress/data");
8
8
  var _blockEditor = require("@wordpress/block-editor");
9
9
  /**
@@ -11,16 +11,17 @@ var _blockEditor = require("@wordpress/block-editor");
11
11
  */
12
12
 
13
13
  function DocumentOutlineCheck({
14
- blocks,
15
14
  children
16
15
  }) {
17
- const headings = blocks.filter(block => block.name === 'core/heading');
18
- if (headings.length < 1) {
16
+ const hasHeadings = (0, _data.useSelect)(select => {
17
+ const {
18
+ getGlobalBlockCount
19
+ } = select(_blockEditor.store);
20
+ return getGlobalBlockCount('core/heading') > 0;
21
+ });
22
+ if (hasHeadings) {
19
23
  return null;
20
24
  }
21
25
  return children;
22
26
  }
23
- var _default = exports.default = (0, _data.withSelect)(select => ({
24
- blocks: select(_blockEditor.store).getBlocks()
25
- }))(DocumentOutlineCheck);
26
27
  //# sourceMappingURL=check.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_blockEditor","DocumentOutlineCheck","blocks","children","headings","filter","block","name","length","_default","exports","default","withSelect","select","blockEditorStore","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":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA,SAASE,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;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,gBAAU,EAAIC,MAAM,KAAQ;EAC1CX,MAAM,EAAEW,MAAM,CAAEC,kBAAiB,CAAC,CAACC,SAAS,CAAC;AAC9C,CAAC,CAAG,CAAC,CAAEd,oBAAqB,CAAC"}
1
+ {"version":3,"names":["_data","require","_blockEditor","DocumentOutlineCheck","children","hasHeadings","useSelect","select","getGlobalBlockCount","blockEditorStore"],"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":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIe,SAASE,oBAAoBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC5D,MAAMC,WAAW,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC5C,MAAM;MAAEC;IAAoB,CAAC,GAAGD,MAAM,CAAEE,kBAAiB,CAAC;IAE1D,OAAOD,mBAAmB,CAAE,cAAe,CAAC,GAAG,CAAC;EACjD,CAAE,CAAC;EAEH,IAAKH,WAAW,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB"}