@wordpress/edit-post 7.27.1 → 7.28.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 (169) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +1 -2
  3. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -1
  4. package/build/components/browser-url/index.js +1 -2
  5. package/build/components/browser-url/index.js.map +1 -1
  6. package/build/components/header/fullscreen-mode-close/index.js +11 -8
  7. package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
  8. package/build/components/header/header-toolbar/index.native.js +1 -2
  9. package/build/components/header/header-toolbar/index.native.js.map +1 -1
  10. package/build/components/header/index.js +8 -9
  11. package/build/components/header/index.js.map +1 -1
  12. package/build/components/header/main-dashboard-button/index.js +1 -2
  13. package/build/components/header/main-dashboard-button/index.js.map +1 -1
  14. package/build/components/header/mode-switcher/index.js +1 -7
  15. package/build/components/header/mode-switcher/index.js.map +1 -1
  16. package/build/components/header/more-menu/index.js +1 -2
  17. package/build/components/header/more-menu/index.js.map +1 -1
  18. package/build/components/header/plugin-more-menu-item/index.js +1 -2
  19. package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
  20. package/build/components/header/post-publish-button-or-toggle.js +1 -2
  21. package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
  22. package/build/components/header/tools-more-menu-group/index.js +1 -2
  23. package/build/components/header/tools-more-menu-group/index.js.map +1 -1
  24. package/build/components/header/writing-menu/index.js +4 -18
  25. package/build/components/header/writing-menu/index.js.map +1 -1
  26. package/build/components/keyboard-shortcut-help-modal/config.js +1 -2
  27. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  28. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -2
  29. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  30. package/build/components/keyboard-shortcut-help-modal/index.js +2 -5
  31. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  32. package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -2
  33. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  34. package/build/components/keyboard-shortcuts/index.js +1 -2
  35. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  36. package/build/components/layout/actions-panel.js +1 -2
  37. package/build/components/layout/actions-panel.js.map +1 -1
  38. package/build/components/layout/index.js +7 -5
  39. package/build/components/layout/index.js.map +1 -1
  40. package/build/components/layout/index.native.js +1 -2
  41. package/build/components/layout/index.native.js.map +1 -1
  42. package/build/components/meta-boxes/meta-box-visibility.js +1 -2
  43. package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
  44. package/build/components/meta-boxes/meta-boxes-area/index.js +1 -2
  45. package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  46. package/build/components/preferences-modal/enable-custom-fields.js +1 -2
  47. package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
  48. package/build/components/preferences-modal/enable-panel.js +1 -2
  49. package/build/components/preferences-modal/enable-panel.js.map +1 -1
  50. package/build/components/preferences-modal/enable-publish-sidebar.js +1 -2
  51. package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -1
  52. package/build/components/preferences-modal/index.js +1 -2
  53. package/build/components/preferences-modal/index.js.map +1 -1
  54. package/build/components/preferences-modal/meta-boxes-section.js +1 -2
  55. package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
  56. package/build/components/sidebar/plugin-document-setting-panel/index.js +1 -2
  57. package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
  58. package/build/components/sidebar/plugin-post-publish-panel/index.js +1 -2
  59. package/build/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  60. package/build/components/sidebar/plugin-post-status-info/index.js +1 -2
  61. package/build/components/sidebar/plugin-post-status-info/index.js.map +1 -1
  62. package/build/components/sidebar/plugin-pre-publish-panel/index.js +1 -2
  63. package/build/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  64. package/build/components/sidebar/post-format/index.js +1 -2
  65. package/build/components/sidebar/post-format/index.js.map +1 -1
  66. package/build/components/sidebar/post-pending-status/index.js +1 -2
  67. package/build/components/sidebar/post-pending-status/index.js.map +1 -1
  68. package/build/components/sidebar/post-slug/index.js +1 -2
  69. package/build/components/sidebar/post-slug/index.js.map +1 -1
  70. package/build/components/sidebar/post-sticky/index.js +1 -2
  71. package/build/components/sidebar/post-sticky/index.js.map +1 -1
  72. package/build/components/sidebar/post-visibility/index.js +2 -2
  73. package/build/components/sidebar/post-visibility/index.js.map +1 -1
  74. package/build/components/sidebar/settings-header/index.js +16 -11
  75. package/build/components/sidebar/settings-header/index.js.map +1 -1
  76. package/build/components/sidebar/settings-sidebar/index.js +34 -12
  77. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  78. package/build/components/sidebar/template-summary/index.js +5 -10
  79. package/build/components/sidebar/template-summary/index.js.map +1 -1
  80. package/build/components/visual-editor/block-inspector-button.js +1 -2
  81. package/build/components/visual-editor/block-inspector-button.js.map +1 -1
  82. package/build/components/visual-editor/header.native.js +1 -2
  83. package/build/components/visual-editor/header.native.js.map +1 -1
  84. package/build/components/visual-editor/index.js +5 -4
  85. package/build/components/visual-editor/index.js.map +1 -1
  86. package/build/components/welcome-guide/index.js +6 -6
  87. package/build/components/welcome-guide/index.js.map +1 -1
  88. package/build/editor.js +35 -34
  89. package/build/editor.js.map +1 -1
  90. package/build/editor.native.js +1 -2
  91. package/build/editor.native.js.map +1 -1
  92. package/build/hooks/{use-post-history.js → use-navigate-to-entity-record.js} +20 -26
  93. package/build/hooks/use-navigate-to-entity-record.js.map +1 -0
  94. package/build/hooks/validate-multiple-use/index.js +25 -4
  95. package/build/hooks/validate-multiple-use/index.js.map +1 -1
  96. package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +1 -2
  97. package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
  98. package/build/plugins/welcome-guide-menu-item/index.js +2 -2
  99. package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
  100. package/build/store/actions.js +8 -12
  101. package/build/store/actions.js.map +1 -1
  102. package/build/store/constants.js +3 -6
  103. package/build/store/constants.js.map +1 -1
  104. package/build/store/index.js +3 -4
  105. package/build/store/index.js.map +1 -1
  106. package/build/store/reducer.js +1 -2
  107. package/build/store/reducer.js.map +1 -1
  108. package/build/store/selectors.js +21 -42
  109. package/build/store/selectors.js.map +1 -1
  110. package/build-module/components/header/fullscreen-mode-close/index.js +10 -6
  111. package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
  112. package/build-module/components/header/index.js +7 -7
  113. package/build-module/components/header/index.js.map +1 -1
  114. package/build-module/components/header/mode-switcher/index.js +0 -5
  115. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  116. package/build-module/components/header/writing-menu/index.js +4 -17
  117. package/build-module/components/header/writing-menu/index.js.map +1 -1
  118. package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -1
  119. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  120. package/build-module/components/layout/index.js +6 -3
  121. package/build-module/components/layout/index.js.map +1 -1
  122. package/build-module/components/sidebar/post-visibility/index.js +1 -0
  123. package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
  124. package/build-module/components/sidebar/settings-header/index.js +16 -10
  125. package/build-module/components/sidebar/settings-header/index.js.map +1 -1
  126. package/build-module/components/sidebar/settings-sidebar/index.js +33 -9
  127. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  128. package/build-module/components/sidebar/template-summary/index.js +4 -8
  129. package/build-module/components/sidebar/template-summary/index.js.map +1 -1
  130. package/build-module/components/visual-editor/index.js +5 -4
  131. package/build-module/components/visual-editor/index.js.map +1 -1
  132. package/build-module/components/welcome-guide/index.js +6 -6
  133. package/build-module/components/welcome-guide/index.js.map +1 -1
  134. package/build-module/editor.js +34 -32
  135. package/build-module/editor.js.map +1 -1
  136. package/build-module/hooks/{use-post-history.js → use-navigate-to-entity-record.js} +20 -26
  137. package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -0
  138. package/build-module/hooks/validate-multiple-use/index.js +26 -4
  139. package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
  140. package/build-module/plugins/welcome-guide-menu-item/index.js +2 -2
  141. package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
  142. package/build-module/store/actions.js +7 -10
  143. package/build-module/store/actions.js.map +1 -1
  144. package/build-style/style-rtl.css +29 -22
  145. package/build-style/style.css +29 -22
  146. package/package.json +32 -32
  147. package/src/components/header/fullscreen-mode-close/index.js +13 -10
  148. package/src/components/header/fullscreen-mode-close/test/index.js +31 -5
  149. package/src/components/header/index.js +10 -8
  150. package/src/components/header/mode-switcher/index.js +16 -25
  151. package/src/components/header/style.scss +40 -26
  152. package/src/components/header/writing-menu/index.js +3 -16
  153. package/src/components/layout/index.js +3 -2
  154. package/src/components/sidebar/post-visibility/index.js +1 -0
  155. package/src/components/sidebar/settings-header/index.js +17 -9
  156. package/src/components/sidebar/settings-sidebar/index.js +44 -9
  157. package/src/components/sidebar/template-summary/index.js +3 -7
  158. package/src/components/visual-editor/index.js +4 -2
  159. package/src/components/visual-editor/style.scss +1 -1
  160. package/src/components/welcome-guide/index.js +11 -6
  161. package/src/editor.js +50 -50
  162. package/src/hooks/{use-post-history.js → use-navigate-to-entity-record.js} +23 -27
  163. package/src/hooks/validate-multiple-use/index.js +28 -3
  164. package/src/plugins/welcome-guide-menu-item/index.js +3 -3
  165. package/src/store/actions.js +20 -12
  166. package/src/style.scss +0 -1
  167. package/src/test/editor.native.js +8 -5
  168. package/build/hooks/use-post-history.js.map +0 -1
  169. package/build-module/hooks/use-post-history.js.map +0 -1
@@ -22,24 +22,24 @@ var _store = require("../../store");
22
22
  function WelcomeGuide() {
23
23
  const {
24
24
  isActive,
25
- isTemplateMode
25
+ isEditingTemplate
26
26
  } = (0, _data.useSelect)(select => {
27
27
  const {
28
28
  isFeatureActive
29
29
  } = select(_store.store);
30
30
  const {
31
- getRenderingMode
31
+ getCurrentPostType
32
32
  } = select(_editor.store);
33
- const _isTemplateMode = getRenderingMode() === 'template-only';
34
- const feature = _isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide';
33
+ const _isEditingTemplate = getCurrentPostType() === 'wp_template';
34
+ const feature = _isEditingTemplate ? 'welcomeGuideTemplate' : 'welcomeGuide';
35
35
  return {
36
36
  isActive: isFeatureActive(feature),
37
- isTemplateMode: _isTemplateMode
37
+ isEditingTemplate: _isEditingTemplate
38
38
  };
39
39
  }, []);
40
40
  if (!isActive) {
41
41
  return null;
42
42
  }
43
- return isTemplateMode ? (0, _react.createElement)(_template.default, null) : (0, _react.createElement)(_default.default, null);
43
+ return isEditingTemplate ? (0, _react.createElement)(_template.default, null) : (0, _react.createElement)(_default.default, null);
44
44
  }
45
45
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_editor","_default","_interopRequireDefault","_template","_store","WelcomeGuide","isActive","isTemplateMode","useSelect","select","isFeatureActive","editPostStore","getRenderingMode","editorStore","_isTemplateMode","feature","_react","createElement","default"],"sources":["@wordpress/edit-post/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideDefault from './default';\nimport WelcomeGuideTemplate from './template';\nimport { store as editPostStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst { isActive, isTemplateMode } = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\t\tconst { getRenderingMode } = select( editorStore );\n\t\tconst _isTemplateMode = getRenderingMode() === 'template-only';\n\t\tconst feature = _isTemplateMode\n\t\t\t? 'welcomeGuideTemplate'\n\t\t\t: 'welcomeGuide';\n\n\t\treturn {\n\t\t\tisActive: isFeatureActive( feature ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t};\n\t}, [] );\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn isTemplateMode ? <WelcomeGuideTemplate /> : <WelcomeGuideDefault />;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKe,SAASM,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC,QAAQ;IAAEC;EAAe,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC7D,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,YAAc,CAAC;IACnD,MAAM;MAAEC;IAAiB,CAAC,GAAGH,MAAM,CAAEI,aAAY,CAAC;IAClD,MAAMC,eAAe,GAAGF,gBAAgB,CAAC,CAAC,KAAK,eAAe;IAC9D,MAAMG,OAAO,GAAGD,eAAe,GAC5B,sBAAsB,GACtB,cAAc;IAEjB,OAAO;MACNR,QAAQ,EAAEI,eAAe,CAAEK,OAAQ,CAAC;MACpCR,cAAc,EAAEO;IACjB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAER,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOC,cAAc,GAAG,IAAAS,MAAA,CAAAC,aAAA,EAACd,SAAA,CAAAe,OAAoB,MAAE,CAAC,GAAG,IAAAF,MAAA,CAAAC,aAAA,EAAChB,QAAA,CAAAiB,OAAmB,MAAE,CAAC;AAC3E"}
1
+ {"version":3,"names":["_data","require","_editor","_default","_interopRequireDefault","_template","_store","WelcomeGuide","isActive","isEditingTemplate","useSelect","select","isFeatureActive","editPostStore","getCurrentPostType","editorStore","_isEditingTemplate","feature","_react","createElement","default"],"sources":["@wordpress/edit-post/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideDefault from './default';\nimport WelcomeGuideTemplate from './template';\nimport { store as editPostStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst { isActive, isEditingTemplate } = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\t\tconst { getCurrentPostType } = select( editorStore );\n\t\tconst _isEditingTemplate = getCurrentPostType() === 'wp_template';\n\n\t\tconst feature = _isEditingTemplate\n\t\t\t? 'welcomeGuideTemplate'\n\t\t\t: 'welcomeGuide';\n\n\t\treturn {\n\t\t\tisActive: isFeatureActive( feature ),\n\t\t\tisEditingTemplate: _isEditingTemplate,\n\t\t};\n\t}, [] );\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn isEditingTemplate ? (\n\t\t<WelcomeGuideTemplate />\n\t) : (\n\t\t<WelcomeGuideDefault />\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKe,SAASM,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC,QAAQ;IAAEC;EAAkB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAChE,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,YAAc,CAAC;IACnD,MAAM;MAAEC;IAAmB,CAAC,GAAGH,MAAM,CAAEI,aAAY,CAAC;IACpD,MAAMC,kBAAkB,GAAGF,kBAAkB,CAAC,CAAC,KAAK,aAAa;IAEjE,MAAMG,OAAO,GAAGD,kBAAkB,GAC/B,sBAAsB,GACtB,cAAc;IAEjB,OAAO;MACNR,QAAQ,EAAEI,eAAe,CAAEK,OAAQ,CAAC;MACpCR,iBAAiB,EAAEO;IACpB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAER,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOC,iBAAiB,GACvB,IAAAS,MAAA,CAAAC,aAAA,EAACd,SAAA,CAAAe,OAAoB,MAAE,CAAC,GAExB,IAAAF,MAAA,CAAAC,aAAA,EAAChB,QAAA,CAAAiB,OAAmB,MAAE,CACtB;AACF"}
package/build/editor.js CHANGED
@@ -13,11 +13,13 @@ var _components = require("@wordpress/components");
13
13
  var _coreData = require("@wordpress/core-data");
14
14
  var _preferences = require("@wordpress/preferences");
15
15
  var _commands = require("@wordpress/commands");
16
+ var _blockEditor = require("@wordpress/block-editor");
17
+ var _i18n = require("@wordpress/i18n");
16
18
  var _layout = _interopRequireDefault(require("./components/layout"));
17
19
  var _editorInitialization = _interopRequireDefault(require("./components/editor-initialization"));
18
20
  var _store = require("./store");
19
21
  var _lockUnlock = require("./lock-unlock");
20
- var _usePostHistory = _interopRequireDefault(require("./hooks/use-post-history"));
22
+ var _useNavigateToEntityRecord = _interopRequireDefault(require("./hooks/use-navigate-to-entity-record"));
21
23
  /**
22
24
  * WordPress dependencies
23
25
  */
@@ -29,6 +31,14 @@ var _usePostHistory = _interopRequireDefault(require("./hooks/use-post-history")
29
31
  const {
30
32
  ExperimentalEditorProvider
31
33
  } = (0, _lockUnlock.unlock)(_editor.privateApis);
34
+ const {
35
+ BlockRemovalWarningModal
36
+ } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
37
+ // Prevent accidental removal of certain blocks, asking the user for
38
+ // confirmation.
39
+ const blockRemovalRules = {
40
+ 'bindings/core/pattern-overrides': (0, _i18n.__)('Blocks from synced patterns that can have overriden content.')
41
+ };
32
42
  function Editor({
33
43
  postId: initialPostId,
34
44
  postType: initialPostType,
@@ -37,10 +47,11 @@ function Editor({
37
47
  ...props
38
48
  }) {
39
49
  const {
50
+ initialPost,
40
51
  currentPost,
41
- getPostLinkProps,
42
- goBack
43
- } = (0, _usePostHistory.default)(initialPostId, initialPostType);
52
+ onNavigateToEntityRecord,
53
+ onNavigateToPreviousEntityRecord
54
+ } = (0, _useNavigateToEntityRecord.default)(initialPostId, initialPostType);
44
55
  const {
45
56
  hasInlineToolbar,
46
57
  post,
@@ -55,50 +66,37 @@ function Editor({
55
66
  const {
56
67
  getEntityRecord,
57
68
  getPostType,
58
- getEntityRecords,
59
69
  canUser
60
70
  } = select(_coreData.store);
61
71
  const {
62
72
  getEditorSettings
63
73
  } = select(_editor.store);
64
- const isTemplate = ['wp_template', 'wp_template_part'].includes(currentPost.postType);
65
- // Ideally the initializeEditor function should be called using the ID of the REST endpoint.
66
- // to avoid the special case.
67
- let postObject;
68
- if (isTemplate) {
69
- const posts = getEntityRecords('postType', currentPost.postType, {
70
- wp_id: currentPost.postId
71
- });
72
- postObject = posts?.[0];
73
- } else {
74
- postObject = getEntityRecord('postType', currentPost.postType, currentPost.postId);
75
- }
74
+ const postObject = getEntityRecord('postType', currentPost.postType, currentPost.postId);
76
75
  const supportsTemplateMode = getEditorSettings().supportsTemplateMode;
77
76
  const isViewable = (_getPostType$viewable = getPostType(currentPost.postType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
78
77
  const canEditTemplate = canUser('create', 'templates');
79
78
  return {
80
79
  hasInlineToolbar: isFeatureActive('inlineToolbar'),
81
80
  preferredStyleVariations: select(_preferences.store).get('core/edit-post', 'preferredStyleVariations'),
82
- template: supportsTemplateMode && isViewable && canEditTemplate ? getEditedPostTemplate() : null,
81
+ template: supportsTemplateMode && isViewable && canEditTemplate && currentPost.postType !== 'wp_template' ? getEditedPostTemplate() : null,
83
82
  post: postObject
84
83
  };
85
84
  }, [currentPost.postType, currentPost.postId]);
86
85
  const {
87
86
  updatePreferredStyleVariations
88
87
  } = (0, _data.useDispatch)(_store.store);
89
- const editorSettings = (0, _element.useMemo)(() => {
90
- const result = {
91
- ...settings,
92
- getPostLinkProps,
93
- goBack,
94
- __experimentalPreferredStyleVariations: {
95
- value: preferredStyleVariations,
96
- onChange: updatePreferredStyleVariations
97
- },
98
- hasInlineToolbar
99
- };
100
- return result;
101
- }, [settings, hasInlineToolbar, preferredStyleVariations, updatePreferredStyleVariations, getPostLinkProps, goBack]);
88
+ const defaultRenderingMode = currentPost.postType === 'wp_template' ? 'all' : 'post-only';
89
+ const editorSettings = (0, _element.useMemo)(() => ({
90
+ ...settings,
91
+ onNavigateToEntityRecord,
92
+ onNavigateToPreviousEntityRecord,
93
+ defaultRenderingMode,
94
+ __experimentalPreferredStyleVariations: {
95
+ value: preferredStyleVariations,
96
+ onChange: updatePreferredStyleVariations
97
+ },
98
+ hasInlineToolbar
99
+ }), [settings, hasInlineToolbar, preferredStyleVariations, updatePreferredStyleVariations, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, defaultRenderingMode]);
102
100
  if (!post) {
103
101
  return null;
104
102
  }
@@ -111,8 +109,11 @@ function Editor({
111
109
  ...props
112
110
  }, (0, _react.createElement)(_editor.ErrorBoundary, null, (0, _react.createElement)(_commands.CommandMenu, null), (0, _react.createElement)(_editorInitialization.default, {
113
111
  postId: currentPost.postId
114
- }), (0, _react.createElement)(_layout.default, null)), (0, _react.createElement)(_editor.PostLockedModal, null)));
112
+ }), (0, _react.createElement)(_layout.default, {
113
+ initialPost: initialPost
114
+ }), (0, _react.createElement)(BlockRemovalWarningModal, {
115
+ rules: blockRemovalRules
116
+ })), (0, _react.createElement)(_editor.PostLockedModal, null)));
115
117
  }
116
- var _default = Editor;
117
- exports.default = _default;
118
+ var _default = exports.default = Editor;
118
119
  //# sourceMappingURL=editor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_editor","_element","_components","_coreData","_preferences","_commands","_layout","_interopRequireDefault","_editorInitialization","_store","_lockUnlock","_usePostHistory","ExperimentalEditorProvider","unlock","editorPrivateApis","Editor","postId","initialPostId","postType","initialPostType","settings","initialEdits","props","currentPost","getPostLinkProps","goBack","usePostHistory","hasInlineToolbar","post","preferredStyleVariations","template","useSelect","select","_getPostType$viewable","isFeatureActive","getEditedPostTemplate","editPostStore","getEntityRecord","getPostType","getEntityRecords","canUser","coreStore","getEditorSettings","editorStore","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","canEditTemplate","preferencesStore","get","updatePreferredStyleVariations","useDispatch","editorSettings","useMemo","result","__experimentalPreferredStyleVariations","value","onChange","_react","createElement","SlotFillProvider","useSubRegistry","__unstableTemplate","ErrorBoundary","CommandMenu","default","PostLockedModal","_default","exports"],"sources":["@wordpress/edit-post/src/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\nimport { unlock } from './lock-unlock';\nimport usePostHistory from './hooks/use-post-history';\n\nconst { ExperimentalEditorProvider } = unlock( editorPrivateApis );\n\nfunction Editor( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n\t...props\n} ) {\n\tconst { currentPost, getPostLinkProps, goBack } = usePostHistory(\n\t\tinitialPostId,\n\t\tinitialPostType\n\t);\n\n\tconst { hasInlineToolbar, post, preferredStyleVariations, template } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { isFeatureActive, getEditedPostTemplate } =\n\t\t\t\t\tselect( editPostStore );\n\t\t\t\tconst {\n\t\t\t\t\tgetEntityRecord,\n\t\t\t\t\tgetPostType,\n\t\t\t\t\tgetEntityRecords,\n\t\t\t\t\tcanUser,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tconst { getEditorSettings } = select( editorStore );\n\t\t\t\tconst isTemplate = [\n\t\t\t\t\t'wp_template',\n\t\t\t\t\t'wp_template_part',\n\t\t\t\t].includes( currentPost.postType );\n\t\t\t\t// Ideally the initializeEditor function should be called using the ID of the REST endpoint.\n\t\t\t\t// to avoid the special case.\n\t\t\t\tlet postObject;\n\t\t\t\tif ( isTemplate ) {\n\t\t\t\t\tconst posts = getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tcurrentPost.postType,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twp_id: currentPost.postId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tpostObject = posts?.[ 0 ];\n\t\t\t\t} else {\n\t\t\t\t\tpostObject = getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tcurrentPost.postType,\n\t\t\t\t\t\tcurrentPost.postId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst supportsTemplateMode =\n\t\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\t\tconst isViewable =\n\t\t\t\t\tgetPostType( currentPost.postType )?.viewable ?? false;\n\t\t\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\t\t\treturn {\n\t\t\t\t\thasInlineToolbar: isFeatureActive( 'inlineToolbar' ),\n\t\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t\t),\n\t\t\t\t\ttemplate:\n\t\t\t\t\t\tsupportsTemplateMode && isViewable && canEditTemplate\n\t\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\tpost: postObject,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ currentPost.postType, currentPost.postId ]\n\t\t);\n\n\tconst { updatePreferredStyleVariations } = useDispatch( editPostStore );\n\n\tconst editorSettings = useMemo( () => {\n\t\tconst result = {\n\t\t\t...settings,\n\t\t\tgetPostLinkProps,\n\t\t\tgoBack,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasInlineToolbar,\n\t\t};\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasInlineToolbar,\n\t\tpreferredStyleVariations,\n\t\tupdatePreferredStyleVariations,\n\t\tgetPostLinkProps,\n\t\tgoBack,\n\t] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ExperimentalEditorProvider\n\t\t\t\tsettings={ editorSettings }\n\t\t\t\tpost={ post }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t__unstableTemplate={ template }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t<CommandMenu />\n\t\t\t\t\t<EditorInitialization postId={ currentPost.postId } />\n\t\t\t\t\t<Layout />\n\t\t\t\t</ErrorBoundary>\n\t\t\t\t<PostLockedModal />\n\t\t\t</ExperimentalEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Editor;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,OAAA,GAAAC,sBAAA,CAAAR,OAAA;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;EACZ;EAEA,OACC,IAAAmC,MAAA,CAAAC,aAAA,EAAC9D,WAAA,CAAA+D,gBAAgB,QAChB,IAAAF,MAAA,CAAAC,aAAA,EAACpD,0BAA0B;IAC1BQ,QAAQ,EAAGqC,cAAgB;IAC3B7B,IAAI,EAAGA,IAAM;IACbP,YAAY,EAAGA,YAAc;IAC7B6C,cAAc,EAAG,KAAO;IACxBC,kBAAkB,EAAGrC,QAAU;IAAA,GAC1BR;EAAK,GAEV,IAAAyC,MAAA,CAAAC,aAAA,EAAChE,OAAA,CAAAoE,aAAa,QACb,IAAAL,MAAA,CAAAC,aAAA,EAAC3D,SAAA,CAAAgE,WAAW,MAAE,CAAC,EACf,IAAAN,MAAA,CAAAC,aAAA,EAACxD,qBAAA,CAAA8D,OAAoB;IAACtD,MAAM,EAAGO,WAAW,CAACP;EAAQ,CAAE,CAAC,EACtD,IAAA+C,MAAA,CAAAC,aAAA,EAAC1D,OAAA,CAAAgE,OAAM,MAAE,CACK,CAAC,EAChB,IAAAP,MAAA,CAAAC,aAAA,EAAChE,OAAA,CAAAuE,eAAe,MAAE,CACS,CACX,CAAC;AAErB;AAAC,IAAAC,QAAA,GAEczD,MAAM;AAAA0D,OAAA,CAAAH,OAAA,GAAAE,QAAA"}
1
+ {"version":3,"names":["_data","require","_editor","_element","_components","_coreData","_preferences","_commands","_blockEditor","_i18n","_layout","_interopRequireDefault","_editorInitialization","_store","_lockUnlock","_useNavigateToEntityRecord","ExperimentalEditorProvider","unlock","editorPrivateApis","BlockRemovalWarningModal","blockEditorPrivateApis","blockRemovalRules","__","Editor","postId","initialPostId","postType","initialPostType","settings","initialEdits","props","initialPost","currentPost","onNavigateToEntityRecord","onNavigateToPreviousEntityRecord","useNavigateToEntityRecord","hasInlineToolbar","post","preferredStyleVariations","template","useSelect","select","_getPostType$viewable","isFeatureActive","getEditedPostTemplate","editPostStore","getEntityRecord","getPostType","canUser","coreStore","getEditorSettings","editorStore","postObject","supportsTemplateMode","isViewable","viewable","canEditTemplate","preferencesStore","get","updatePreferredStyleVariations","useDispatch","defaultRenderingMode","editorSettings","useMemo","__experimentalPreferredStyleVariations","value","onChange","_react","createElement","SlotFillProvider","useSubRegistry","__unstableTemplate","ErrorBoundary","CommandMenu","default","rules","PostLockedModal","_default","exports"],"sources":["@wordpress/edit-post/src/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { CommandMenu } from '@wordpress/commands';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\nimport { unlock } from './lock-unlock';\nimport useNavigateToEntityRecord from './hooks/use-navigate-to-entity-record';\n\nconst { ExperimentalEditorProvider } = unlock( editorPrivateApis );\nconst { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );\n// Prevent accidental removal of certain blocks, asking the user for\n// confirmation.\nconst blockRemovalRules = {\n\t'bindings/core/pattern-overrides': __(\n\t\t'Blocks from synced patterns that can have overriden content.'\n\t),\n};\n\nfunction Editor( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n\t...props\n} ) {\n\tconst {\n\t\tinitialPost,\n\t\tcurrentPost,\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useNavigateToEntityRecord( initialPostId, initialPostType );\n\n\tconst { hasInlineToolbar, post, preferredStyleVariations, template } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { isFeatureActive, getEditedPostTemplate } =\n\t\t\t\t\tselect( editPostStore );\n\t\t\t\tconst { getEntityRecord, getPostType, canUser } =\n\t\t\t\t\tselect( coreStore );\n\t\t\t\tconst { getEditorSettings } = select( editorStore );\n\n\t\t\t\tconst postObject = getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tcurrentPost.postType,\n\t\t\t\t\tcurrentPost.postId\n\t\t\t\t);\n\n\t\t\t\tconst supportsTemplateMode =\n\t\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\t\tconst isViewable =\n\t\t\t\t\tgetPostType( currentPost.postType )?.viewable ?? false;\n\t\t\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\t\t\treturn {\n\t\t\t\t\thasInlineToolbar: isFeatureActive( 'inlineToolbar' ),\n\t\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t\t),\n\t\t\t\t\ttemplate:\n\t\t\t\t\t\tsupportsTemplateMode &&\n\t\t\t\t\t\tisViewable &&\n\t\t\t\t\t\tcanEditTemplate &&\n\t\t\t\t\t\tcurrentPost.postType !== 'wp_template'\n\t\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\tpost: postObject,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ currentPost.postType, currentPost.postId ]\n\t\t);\n\n\tconst { updatePreferredStyleVariations } = useDispatch( editPostStore );\n\tconst defaultRenderingMode =\n\t\tcurrentPost.postType === 'wp_template' ? 'all' : 'post-only';\n\n\tconst editorSettings = useMemo(\n\t\t() => ( {\n\t\t\t...settings,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasInlineToolbar,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasInlineToolbar,\n\t\t\tpreferredStyleVariations,\n\t\t\tupdatePreferredStyleVariations,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode,\n\t\t]\n\t);\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ExperimentalEditorProvider\n\t\t\t\tsettings={ editorSettings }\n\t\t\t\tpost={ post }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t__unstableTemplate={ template }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t<CommandMenu />\n\t\t\t\t\t<EditorInitialization postId={ currentPost.postId } />\n\t\t\t\t\t<Layout initialPost={ initialPost } />\n\t\t\t\t\t<BlockRemovalWarningModal rules={ blockRemovalRules } />\n\t\t\t\t</ErrorBoundary>\n\t\t\t\t<PostLockedModal />\n\t\t\t</ExperimentalEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Editor;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAKA,IAAAS,OAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,qBAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AACA,IAAAc,0BAAA,GAAAJ,sBAA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AAc;IAC7ByC,cAAc,EAAG,KAAO;IACxBC,kBAAkB,EAAGhC,QAAU;IAAA,GAC1BT;EAAK,GAEV,IAAAqC,MAAA,CAAAC,aAAA,EAAClE,OAAA,CAAAsE,aAAa,QACb,IAAAL,MAAA,CAAAC,aAAA,EAAC7D,SAAA,CAAAkE,WAAW,MAAE,CAAC,EACf,IAAAN,MAAA,CAAAC,aAAA,EAACxD,qBAAA,CAAA8D,OAAoB;IAAClD,MAAM,EAAGQ,WAAW,CAACR;EAAQ,CAAE,CAAC,EACtD,IAAA2C,MAAA,CAAAC,aAAA,EAAC1D,OAAA,CAAAgE,OAAM;IAAC3C,WAAW,EAAGA;EAAa,CAAE,CAAC,EACtC,IAAAoC,MAAA,CAAAC,aAAA,EAACjD,wBAAwB;IAACwD,KAAK,EAAGtD;EAAmB,CAAE,CACzC,CAAC,EAChB,IAAA8C,MAAA,CAAAC,aAAA,EAAClE,OAAA,CAAA0E,eAAe,MAAE,CACS,CACX,CAAC;AAErB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEcnD,MAAM"}
@@ -137,7 +137,7 @@ class Editor extends _element.Component {
137
137
  }))));
138
138
  }
139
139
  }
140
- var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
140
+ var _default = exports.default = (0, _compose.compose)([(0, _data.withSelect)(select => {
141
141
  const {
142
142
  getEditorMode
143
143
  } = select(_store.store);
@@ -156,5 +156,4 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
156
156
  editEntityRecord
157
157
  };
158
158
  })])(Editor);
159
- exports.default = _default;
160
159
  //# sourceMappingURL=editor.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_memize","_interopRequireDefault","require","_reactNative","_reactNativeGestureHandler","_element","_editor","_blocks","_data","_compose","_reactNativeBridge","_components","_coreData","_layout","_store","Editor","Component","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","memize","maxSize","setTitleRef","bind","settings","isRTL","I18nManager","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","subscribeSetFocusOnTitle","postTitleRef","focus","focusTitleWhenAvailable","subscriptionParentFeaturedImageIdNativeUpdated","subscribeFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","serialize","parse","type","status","meta","_react","createElement","GestureHandlerRootView","style","flex","SlotFillProvider","EditorProvider","useSubRegistry","default","_default","compose","withSelect","select","getEditorMode","editPostStore","withDispatch","dispatch","coreStore","exports"],"sources":["@wordpress/edit-post/src/editor.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { I18nManager } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { EditorProvider } from '@wordpress/editor';\nimport { parse, serialize } from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport {\n\tsubscribeSetFocusOnTitle,\n\tsubscribeFeaturedImageIdNativeUpdated,\n} from '@wordpress/react-native-bridge';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { store as editPostStore } from './store';\n\nclass Editor extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\t// need to set this globally to avoid race with deprecations\n\t\t// defaulting to true to avoid issues with a not-yet-cached value\n\t\tconst { galleryWithImageBlocks = true } = props;\n\t\twindow.wp.galleryBlockV2Enabled = galleryWithImageBlocks;\n\n\t\tif ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {\n\t\t\t// Enable html mode if the initial mode the parent wants it but we're not already in it.\n\t\t\tthis.props.switchEditorMode( 'text' );\n\t\t}\n\n\t\tthis.getEditorSettings = memize( this.getEditorSettings, {\n\t\t\tmaxSize: 1,\n\t\t} );\n\n\t\tthis.setTitleRef = this.setTitleRef.bind( this );\n\t}\n\n\tgetEditorSettings( settings ) {\n\t\tsettings = {\n\t\t\t...settings,\n\t\t\tisRTL: I18nManager.isRTL,\n\t\t};\n\n\t\treturn settings;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { editEntityRecord, postType, postId } = this.props;\n\n\t\tthis.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(\n\t\t\t() => {\n\t\t\t\tif ( this.postTitleRef ) {\n\t\t\t\t\tthis.postTitleRef.focus();\n\t\t\t\t} else {\n\t\t\t\t\t// If the post title ref is not available, we postpone setting focus to when it's available.\n\t\t\t\t\tthis.focusTitleWhenAvailable = true;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentFeaturedImageIdNativeUpdated =\n\t\t\tsubscribeFeaturedImageIdNativeUpdated( ( payload ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ featured_media: payload.featuredImageId },\n\t\t\t\t\t{\n\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentSetFocusOnTitle ) {\n\t\t\tthis.subscriptionParentSetFocusOnTitle.remove();\n\t\t}\n\n\t\tif ( this.subscribeFeaturedImageIdNativeUpdated ) {\n\t\t\tthis.subscribeFeaturedImageIdNativeUpdated.remove();\n\t\t}\n\t}\n\n\tsetTitleRef( titleRef ) {\n\t\tif ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {\n\t\t\tthis.focusTitleWhenAvailable = false;\n\t\t\ttitleRef.focus();\n\t\t}\n\n\t\tthis.postTitleRef = titleRef;\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tsettings,\n\t\t\tinitialEdits,\n\t\t\tpost,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfeaturedImageId,\n\t\t\tinitialHtml,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tconst editorSettings = this.getEditorSettings( settings );\n\n\t\tconst normalizedPost = post || {\n\t\t\tid: postId,\n\t\t\ttitle: {\n\t\t\t\traw: props.initialTitle || '',\n\t\t\t},\n\t\t\tfeatured_media: featuredImageId,\n\t\t\tcontent: {\n\t\t\t\t// Make sure the post content is in sync with gutenberg store\n\t\t\t\t// to avoid marking the post as modified when simply loaded\n\t\t\t\t// For now, let's assume: serialize( parse( html ) ) !== html.\n\t\t\t\traw: serialize( parse( initialHtml || '' ) ),\n\t\t\t},\n\t\t\ttype: postType,\n\t\t\tstatus: 'draft',\n\t\t\tmeta: [],\n\t\t};\n\n\t\treturn (\n\t\t\t<GestureHandlerRootView style={ { flex: 1 } }>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ normalizedPost }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Layout setTitleRef={ this.setTitleRef } />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</GestureHandlerRootView>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getEditorMode } = select( editPostStore );\n\n\t\treturn {\n\t\t\tmode: getEditorMode(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { editEntityRecord } = dispatch( coreStore );\n\t\treturn {\n\t\t\tswitchEditorMode,\n\t\t\teditEntityRecord,\n\t\t};\n\t} ),\n] )( Editor );\n"],"mappings":";;;;;;;;AAGA,IAAAA,OA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C,GAAG2D,QAAQ,CAAEF,YAAc,CAAC;EACtD,MAAM;IAAE/C;EAAiB,CAAC,GAAGiD,QAAQ,CAAEC,eAAU,CAAC;EAClD,OAAO;IACN5D,gBAAgB;IAChBU;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAErB,MAAO,CAAC;AAAAwE,OAAA,CAAAV,OAAA,GAAAC,QAAA"}
1
+ {"version":3,"names":["_memize","_interopRequireDefault","require","_reactNative","_reactNativeGestureHandler","_element","_editor","_blocks","_data","_compose","_reactNativeBridge","_components","_coreData","_layout","_store","Editor","Component","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","memize","maxSize","setTitleRef","bind","settings","isRTL","I18nManager","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","subscribeSetFocusOnTitle","postTitleRef","focus","focusTitleWhenAvailable","subscriptionParentFeaturedImageIdNativeUpdated","subscribeFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","serialize","parse","type","status","meta","_react","createElement","GestureHandlerRootView","style","flex","SlotFillProvider","EditorProvider","useSubRegistry","default","_default","exports","compose","withSelect","select","getEditorMode","editPostStore","withDispatch","dispatch","coreStore"],"sources":["@wordpress/edit-post/src/editor.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { I18nManager } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { EditorProvider } from '@wordpress/editor';\nimport { parse, serialize } from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport {\n\tsubscribeSetFocusOnTitle,\n\tsubscribeFeaturedImageIdNativeUpdated,\n} from '@wordpress/react-native-bridge';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { store as editPostStore } from './store';\n\nclass Editor extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\t// need to set this globally to avoid race with deprecations\n\t\t// defaulting to true to avoid issues with a not-yet-cached value\n\t\tconst { galleryWithImageBlocks = true } = props;\n\t\twindow.wp.galleryBlockV2Enabled = galleryWithImageBlocks;\n\n\t\tif ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {\n\t\t\t// Enable html mode if the initial mode the parent wants it but we're not already in it.\n\t\t\tthis.props.switchEditorMode( 'text' );\n\t\t}\n\n\t\tthis.getEditorSettings = memize( this.getEditorSettings, {\n\t\t\tmaxSize: 1,\n\t\t} );\n\n\t\tthis.setTitleRef = this.setTitleRef.bind( this );\n\t}\n\n\tgetEditorSettings( settings ) {\n\t\tsettings = {\n\t\t\t...settings,\n\t\t\tisRTL: I18nManager.isRTL,\n\t\t};\n\n\t\treturn settings;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { editEntityRecord, postType, postId } = this.props;\n\n\t\tthis.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(\n\t\t\t() => {\n\t\t\t\tif ( this.postTitleRef ) {\n\t\t\t\t\tthis.postTitleRef.focus();\n\t\t\t\t} else {\n\t\t\t\t\t// If the post title ref is not available, we postpone setting focus to when it's available.\n\t\t\t\t\tthis.focusTitleWhenAvailable = true;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentFeaturedImageIdNativeUpdated =\n\t\t\tsubscribeFeaturedImageIdNativeUpdated( ( payload ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ featured_media: payload.featuredImageId },\n\t\t\t\t\t{\n\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentSetFocusOnTitle ) {\n\t\t\tthis.subscriptionParentSetFocusOnTitle.remove();\n\t\t}\n\n\t\tif ( this.subscribeFeaturedImageIdNativeUpdated ) {\n\t\t\tthis.subscribeFeaturedImageIdNativeUpdated.remove();\n\t\t}\n\t}\n\n\tsetTitleRef( titleRef ) {\n\t\tif ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {\n\t\t\tthis.focusTitleWhenAvailable = false;\n\t\t\ttitleRef.focus();\n\t\t}\n\n\t\tthis.postTitleRef = titleRef;\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tsettings,\n\t\t\tinitialEdits,\n\t\t\tpost,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfeaturedImageId,\n\t\t\tinitialHtml,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tconst editorSettings = this.getEditorSettings( settings );\n\n\t\tconst normalizedPost = post || {\n\t\t\tid: postId,\n\t\t\ttitle: {\n\t\t\t\traw: props.initialTitle || '',\n\t\t\t},\n\t\t\tfeatured_media: featuredImageId,\n\t\t\tcontent: {\n\t\t\t\t// Make sure the post content is in sync with gutenberg store\n\t\t\t\t// to avoid marking the post as modified when simply loaded\n\t\t\t\t// For now, let's assume: serialize( parse( html ) ) !== html.\n\t\t\t\traw: serialize( parse( initialHtml || '' ) ),\n\t\t\t},\n\t\t\ttype: postType,\n\t\t\tstatus: 'draft',\n\t\t\tmeta: [],\n\t\t};\n\n\t\treturn (\n\t\t\t<GestureHandlerRootView style={ { flex: 1 } }>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ normalizedPost }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Layout setTitleRef={ this.setTitleRef } />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</GestureHandlerRootView>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getEditorMode } = select( editPostStore );\n\n\t\treturn {\n\t\t\tmode: getEditorMode(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { editEntityRecord } = dispatch( coreStore );\n\t\treturn {\n\t\t\tswitchEditorMode,\n\t\t\teditEntityRecord,\n\t\t};\n\t} ),\n] )( Editor );\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,0BAAA,GAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AAIA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AAKA,IAAAW,OAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AA1BA;AACA;AACA;;AAKA;AACA;AACA;;AAaA;AACA;AACA;;AAIA,MAAMa,MAAM,SAASC,kBAAS,CAAC;EAC9BC,WAAWA,CAAEC,KAAK,EAAG;IACpB,KAAK,CAAE,GAAGC,SAAU,CAAC;;IAErB;IACA;IACA,MAAM;MAAEC,sBAAsB,GAAG;IAAK,CAAC,GAAGF,KAAK;IAC/CG,MAAM,CAACC,EAAE,CAACC,qBAAqB,GAAGH,sBAAsB;IAExD,IAAKF,KAAK,CAACM,sBAAsB,IAAIN,KAAK,CAACO,IAAI,KAAK,QA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AAK,GAEV,IAAAmD,MAAA,CAAAC,aAAA,EAACzD,OAAA,CAAAgE,OAAM;MAAC/C,WAAW,EAAG,IAAI,CAACA;IAAa,CAAE,CAC3B,CACC,CACK,CAAC;EAE3B;AACD;AAAC,IAAAgD,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEc,IAAAG,gBAAO,EAAE,CACvB,IAAAC,gBAAU,EAAIC,MAAM,IAAM;EACzB,MAAM;IAAEC;EAAc,CAAC,GAAGD,MAAM,CAAEE,YAAc,CAAC;EAEjD,OAAO;IACN3D,IAAI,EAAE0D,aAAa,CAAC;EACrB,CAAC;AACF,CAAE,CAAC,EACH,IAAAE,kBAAY,EAAIC,QAAQ,IAAM;EAC7B,MAAM;IAAE5D;EAAiB,CAAC,GAAG4D,QAAQ,CAAEF,YAAc,CAAC;EACtD,MAAM;IAAEhD;EAAiB,CAAC,GAAGkD,QAAQ,CAAEC,eAAU,CAAC;EAClD,OAAO;IACN7D,gBAAgB;IAChBU;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAErB,MAAO,CAAC"}
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = usePostHistory;
6
+ exports.default = useNavigateToEntityRecord;
7
7
  var _element = require("@wordpress/element");
8
- var _url = require("@wordpress/url");
9
8
  /**
10
9
  * WordPress dependencies
11
10
  */
@@ -22,9 +21,9 @@ var _url = require("@wordpress/url");
22
21
  * @param {string} initialPostType The post type of the post when the editor loaded.
23
22
  *
24
23
  * @return {Object} An object containing the `currentPost` variable and
25
- * `getPostLinkProps` and `goBack` functions.
24
+ * `onNavigateToEntityRecord` and `onNavigateToPreviousEntityRecord` functions.
26
25
  */
27
- function usePostHistory(initialPostId, initialPostType) {
26
+ function useNavigateToEntityRecord(initialPostId, initialPostType) {
28
27
  const [postHistory, dispatch] = (0, _element.useReducer)((historyState, {
29
28
  type,
30
29
  post
@@ -43,28 +42,22 @@ function usePostHistory(initialPostId, initialPostType) {
43
42
  postId: initialPostId,
44
43
  postType: initialPostType
45
44
  }]);
46
- const getPostLinkProps = (0, _element.useCallback)(params => {
47
- const currentArgs = (0, _url.getQueryArgs)(window.location.href);
48
- const currentUrlWithoutArgs = (0, _url.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs));
49
- const newUrl = (0, _url.addQueryArgs)(currentUrlWithoutArgs, {
50
- post: params.postId,
51
- action: 'edit'
52
- });
45
+ const initialPost = (0, _element.useMemo)(() => {
53
46
  return {
54
- href: newUrl,
55
- onClick: event => {
56
- event.preventDefault();
57
- dispatch({
58
- type: 'push',
59
- post: {
60
- postId: params.postId,
61
- postType: params.postType
62
- }
63
- });
64
- }
47
+ type: initialPostType,
48
+ id: initialPostId
65
49
  };
50
+ }, [initialPostType, initialPostId]);
51
+ const onNavigateToEntityRecord = (0, _element.useCallback)(params => {
52
+ dispatch({
53
+ type: 'push',
54
+ post: {
55
+ postId: params.postId,
56
+ postType: params.postType
57
+ }
58
+ });
66
59
  }, []);
67
- const goBack = (0, _element.useCallback)(() => {
60
+ const onNavigateToPreviousEntityRecord = (0, _element.useCallback)(() => {
68
61
  dispatch({
69
62
  type: 'pop'
70
63
  });
@@ -72,8 +65,9 @@ function usePostHistory(initialPostId, initialPostType) {
72
65
  const currentPost = postHistory[postHistory.length - 1];
73
66
  return {
74
67
  currentPost,
75
- getPostLinkProps,
76
- goBack: postHistory.length > 1 ? goBack : undefined
68
+ initialPost,
69
+ onNavigateToEntityRecord,
70
+ onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord : undefined
77
71
  };
78
72
  }
79
- //# sourceMappingURL=use-post-history.js.map
73
+ //# sourceMappingURL=use-navigate-to-entity-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_element","require","useNavigateToEntityRecord","initialPostId","initialPostType","postHistory","dispatch","useReducer","historyState","type","post","length","slice","postId","postType","initialPost","useMemo","id","onNavigateToEntityRecord","useCallback","params","onNavigateToPreviousEntityRecord","currentPost","undefined"],"sources":["@wordpress/edit-post/src/hooks/use-navigate-to-entity-record.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useReducer, useMemo } from '@wordpress/element';\n\n/**\n * A hook that records the 'entity' history in the post editor as a user\n * navigates between editing a post and editing the post template or patterns.\n *\n * Implemented as a stack, so a little similar to the browser history API.\n *\n * Used to control displaying UI elements like the back button.\n *\n * @param {number} initialPostId The post id of the post when the editor loaded.\n * @param {string} initialPostType The post type of the post when the editor loaded.\n *\n * @return {Object} An object containing the `currentPost` variable and\n * `onNavigateToEntityRecord` and `onNavigateToPreviousEntityRecord` functions.\n */\nexport default function useNavigateToEntityRecord(\n\tinitialPostId,\n\tinitialPostType\n) {\n\tconst [ postHistory, dispatch ] = useReducer(\n\t\t( historyState, { type, post } ) => {\n\t\t\tif ( type === 'push' ) {\n\t\t\t\treturn [ ...historyState, post ];\n\t\t\t}\n\t\t\tif ( type === 'pop' ) {\n\t\t\t\t// Try to leave one item in the history.\n\t\t\t\tif ( historyState.length > 1 ) {\n\t\t\t\t\treturn historyState.slice( 0, -1 );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn historyState;\n\t\t},\n\t\t[ { postId: initialPostId, postType: initialPostType } ]\n\t);\n\n\tconst initialPost = useMemo( () => {\n\t\treturn {\n\t\t\ttype: initialPostType,\n\t\t\tid: initialPostId,\n\t\t};\n\t}, [ initialPostType, initialPostId ] );\n\n\tconst onNavigateToEntityRecord = useCallback( ( params ) => {\n\t\tdispatch( {\n\t\t\ttype: 'push',\n\t\t\tpost: { postId: params.postId, postType: params.postType },\n\t\t} );\n\t}, [] );\n\n\tconst onNavigateToPreviousEntityRecord = useCallback( () => {\n\t\tdispatch( { type: 'pop' } );\n\t}, [] );\n\n\tconst currentPost = postHistory[ postHistory.length - 1 ];\n\n\treturn {\n\t\tcurrentPost,\n\t\tinitialPost,\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord:\n\t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AF,oBAAW,EAAE,MAAM;IAC3Db,QAAQ,CAAE;MAAEG,IAAI,EAAE;IAAM,CAAE,CAAC;EAC5B,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMa,WAAW,GAAGjB,WAAW,CAAEA,WAAW,CAACM,MAAM,GAAG,CAAC,CAAE;EAEzD,OAAO;IACNW,WAAW;IACXP,WAAW;IACXG,wBAAwB;IACxBG,gCAAgC,EAC/BhB,WAAW,CAACM,MAAM,GAAG,CAAC,GACnBU,gCAAgC,GAChCE;EACL,CAAC;AACF"}
@@ -12,6 +12,30 @@ var _compose = require("@wordpress/compose");
12
12
  * WordPress dependencies
13
13
  */
14
14
 
15
+ /**
16
+ * Recursively find very first block of an specific block type.
17
+ *
18
+ * @param {Object[]} blocks List of blocks.
19
+ * @param {string} name Block name to search.
20
+ *
21
+ * @return {Object|undefined} Return block object or undefined.
22
+ */
23
+ function findFirstOfSameType(blocks, name) {
24
+ if (!Array.isArray(blocks) || !blocks.length) {
25
+ return;
26
+ }
27
+ for (const block of blocks) {
28
+ if (block.name === name) {
29
+ return block;
30
+ }
31
+
32
+ // Search inside innerBlocks.
33
+ const firstBlock = findFirstOfSameType(block.innerBlocks, name);
34
+ if (firstBlock) {
35
+ return firstBlock;
36
+ }
37
+ }
38
+ }
15
39
  const enhance = (0, _compose.compose)(
16
40
  /**
17
41
  * For blocks whose block type doesn't support `multiple`, provides the
@@ -36,9 +60,7 @@ const enhance = (0, _compose.compose)(
36
60
  // Otherwise, only pass `originalBlockClientId` if it refers to a different
37
61
  // block from the current one.
38
62
  const blocks = select(_blockEditor.store).getBlocks();
39
- const firstOfSameType = blocks.find(({
40
- name
41
- }) => block.name === name);
63
+ const firstOfSameType = findFirstOfSameType(blocks, block.name);
42
64
  const isInvalid = firstOfSameType && firstOfSameType.clientId !== block.clientId;
43
65
  return {
44
66
  originalBlockClientId: isInvalid && firstOfSameType.clientId
@@ -103,7 +125,6 @@ function getOutboundType(blockName) {
103
125
  blocks
104
126
  }) => type === 'block' && blocks.length === 1 // What about when .length > 1?
105
127
  );
106
-
107
128
  if (!transform) {
108
129
  return null;
109
130
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_components","_data","_blockEditor","_hooks","_i18n","_compose","enhance","compose","withSelect","select","block","multiple","hasBlockSupport","name","blocks","blockEditorStore","getBlocks","firstOfSameType","find","isInvalid","clientId","originalBlockClientId","withDispatch","dispatch","selectFirst","selectBlock","withMultipleValidation","createHigherOrderComponent","BlockEdit","props","_react","createElement","blockType","getBlockType","outboundType","getOutboundType","key","style","minHeight","Warning","actions","Button","variant","onClick","__","onReplace","createBlock","attributes","title","blockName","transform","findTransform","getBlockTransforms","type","length","addFilter"],"sources":["@wordpress/edit-post/src/hooks/validate-multiple-use/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { Button } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { Warning, store as blockEditorStore } from '@wordpress/block-editor';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\nconst enhance = compose(\n\t/**\n\t * For blocks whose block type doesn't support `multiple`, provides the\n\t * wrapped component with `originalBlockClientId` -- a reference to the\n\t * first block of the same type in the content -- if and only if that\n\t * \"original\" block is not the current one. Thus, an inexisting\n\t * `originalBlockClientId` prop signals that the block is valid.\n\t *\n\t * @param {Component} WrappedBlockEdit A filtered BlockEdit instance.\n\t *\n\t * @return {Component} Enhanced component with merged state data props.\n\t */\n\twithSelect( ( select, block ) => {\n\t\tconst multiple = hasBlockSupport( block.name, 'multiple', true );\n\n\t\t// For block types with `multiple` support, there is no \"original\n\t\t// block\" to be found in the content, as the block itself is valid.\n\t\tif ( multiple ) {\n\t\t\treturn {};\n\t\t}\n\n\t\t// Otherwise, only pass `originalBlockClientId` if it refers to a different\n\t\t// block from the current one.\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\tconst firstOfSameType = blocks.find(\n\t\t\t( { name } ) => block.name === name\n\t\t);\n\t\tconst isInvalid =\n\t\t\tfirstOfSameType && firstOfSameType.clientId !== block.clientId;\n\t\treturn {\n\t\t\toriginalBlockClientId: isInvalid && firstOfSameType.clientId,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { originalBlockClientId } ) => ( {\n\t\tselectFirst: () =>\n\t\t\tdispatch( blockEditorStore ).selectBlock( originalBlockClientId ),\n\t} ) )\n);\n\nconst withMultipleValidation = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn enhance( ( { originalBlockClientId, selectFirst, ...props } ) => {\n\t\tif ( ! originalBlockClientId ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\n\t\tconst blockType = getBlockType( props.name );\n\t\tconst outboundType = getOutboundType( props.name );\n\n\t\treturn [\n\t\t\t<div key=\"invalid-preview\" style={ { minHeight: '60px' } }>\n\t\t\t\t<BlockEdit key=\"block-edit\" { ...props } />\n\t\t\t</div>,\n\t\t\t<Warning\n\t\t\t\tkey=\"multiple-use-warning\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"find-original\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ selectFirst }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Find original' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"remove\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ () => props.onReplace( [] ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\toutboundType && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey=\"transform\"\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tprops.onReplace(\n\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\toutboundType.name,\n\t\t\t\t\t\t\t\t\t\tprops.attributes\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Transform into:' ) } { outboundType.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t),\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t<strong>{ blockType?.title }: </strong>\n\t\t\t\t{ __( 'This block can only be used once.' ) }\n\t\t\t</Warning>,\n\t\t];\n\t} );\n}, 'withMultipleValidation' );\n\n/**\n * Given a base block name, returns the default block type to which to offer\n * transforms.\n *\n * @param {string} blockName Base block name.\n *\n * @return {?Object} The chosen default block type.\n */\nfunction getOutboundType( blockName ) {\n\t// Grab the first outbound transform.\n\tconst transform = findTransform(\n\t\tgetBlockTransforms( 'to', blockName ),\n\t\t( { type, blocks } ) => type === 'block' && blocks.length === 1 // What about when .length > 1?\n\t);\n\n\tif ( ! transform ) {\n\t\treturn null;\n\t}\n\n\treturn getBlockType( transform.blocks[ 0 ] );\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-post/validate-multiple-use/with-multiple-validation',\n\twithMultipleValidation\n);\n"],"mappings":";;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAOA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAfA;AACA;AACA;;AAeA,MAAMO,OAAO,GAAG,IAAAC,gBAAO;AACtB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACC,IAAAC,gBAAU,E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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAST,eAAeA,CAAEc,SAAS,EAAG;EACrC;EACA,MAAMC,SAAS,GAAG,IAAAC,qBAAa,EAC9B,IAAAC,0BAAkB,EAAE,IAAI,EAAEH,SAAU,CAAC,EACrC,CAAE;IAAEI,IAAI;IAAEvC;EAAO,CAAC,KAAMuC,IAAI,KAAK,OAAO,IAAIvC,MAAM,CAACwC,MAAM,KAAK,CAAC,CAAC;EACjE,CAAC;;EAED,IAAK,CAAEJ,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OAAO,IAAAjB,oBAAY,EAAEiB,SAAS,CAACpC,MAAM,CAAE,CAAC,CAAG,CAAC;AAC7C;AAEA,IAAAyC,gBAAS,EACR,kBAAkB,EAClB,+DAA+D,EAC/D7B,sBACD,CAAC"}
1
+ {"version":3,"names":["_blocks","require","_components","_data","_blockEditor","_hooks","_i18n","_compose","findFirstOfSameType","blocks","name","Array","isArray","length","block","firstBlock","innerBlocks","enhance","compose","withSelect","select","multiple","hasBlockSupport","blockEditorStore","getBlocks","firstOfSameType","isInvalid","clientId","originalBlockClientId","withDispatch","dispatch","selectFirst","selectBlock","withMultipleValidation","createHigherOrderComponent","BlockEdit","props","_react","createElement","blockType","getBlockType","outboundType","getOutboundType","key","style","minHeight","Warning","actions","Button","variant","onClick","__","onReplace","createBlock","attributes","title","blockName","transform","findTransform","getBlockTransforms","type","addFilter"],"sources":["@wordpress/edit-post/src/hooks/validate-multiple-use/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { Button } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { Warning, store as blockEditorStore } from '@wordpress/block-editor';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Recursively find very first block of an specific block type.\n *\n * @param {Object[]} blocks List of blocks.\n * @param {string} name Block name to search.\n *\n * @return {Object|undefined} Return block object or undefined.\n */\nfunction findFirstOfSameType( blocks, name ) {\n\tif ( ! Array.isArray( blocks ) || ! blocks.length ) {\n\t\treturn;\n\t}\n\n\tfor ( const block of blocks ) {\n\t\tif ( block.name === name ) {\n\t\t\treturn block;\n\t\t}\n\n\t\t// Search inside innerBlocks.\n\t\tconst firstBlock = findFirstOfSameType( block.innerBlocks, name );\n\n\t\tif ( firstBlock ) {\n\t\t\treturn firstBlock;\n\t\t}\n\t}\n}\n\nconst enhance = compose(\n\t/**\n\t * For blocks whose block type doesn't support `multiple`, provides the\n\t * wrapped component with `originalBlockClientId` -- a reference to the\n\t * first block of the same type in the content -- if and only if that\n\t * \"original\" block is not the current one. Thus, an inexisting\n\t * `originalBlockClientId` prop signals that the block is valid.\n\t *\n\t * @param {Component} WrappedBlockEdit A filtered BlockEdit instance.\n\t *\n\t * @return {Component} Enhanced component with merged state data props.\n\t */\n\twithSelect( ( select, block ) => {\n\t\tconst multiple = hasBlockSupport( block.name, 'multiple', true );\n\n\t\t// For block types with `multiple` support, there is no \"original\n\t\t// block\" to be found in the content, as the block itself is valid.\n\t\tif ( multiple ) {\n\t\t\treturn {};\n\t\t}\n\n\t\t// Otherwise, only pass `originalBlockClientId` if it refers to a different\n\t\t// block from the current one.\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\tconst firstOfSameType = findFirstOfSameType( blocks, block.name );\n\t\tconst isInvalid =\n\t\t\tfirstOfSameType && firstOfSameType.clientId !== block.clientId;\n\t\treturn {\n\t\t\toriginalBlockClientId: isInvalid && firstOfSameType.clientId,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { originalBlockClientId } ) => ( {\n\t\tselectFirst: () =>\n\t\t\tdispatch( blockEditorStore ).selectBlock( originalBlockClientId ),\n\t} ) )\n);\n\nconst withMultipleValidation = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn enhance( ( { originalBlockClientId, selectFirst, ...props } ) => {\n\t\tif ( ! originalBlockClientId ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\n\t\tconst blockType = getBlockType( props.name );\n\t\tconst outboundType = getOutboundType( props.name );\n\n\t\treturn [\n\t\t\t<div key=\"invalid-preview\" style={ { minHeight: '60px' } }>\n\t\t\t\t<BlockEdit key=\"block-edit\" { ...props } />\n\t\t\t</div>,\n\t\t\t<Warning\n\t\t\t\tkey=\"multiple-use-warning\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"find-original\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ selectFirst }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Find original' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"remove\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ () => props.onReplace( [] ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\toutboundType && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey=\"transform\"\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tprops.onReplace(\n\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\toutboundType.name,\n\t\t\t\t\t\t\t\t\t\tprops.attributes\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Transform into:' ) } { outboundType.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t),\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t<strong>{ blockType?.title }: </strong>\n\t\t\t\t{ __( 'This block can only be used once.' ) }\n\t\t\t</Warning>,\n\t\t];\n\t} );\n}, 'withMultipleValidation' );\n\n/**\n * Given a base block name, returns the default block type to which to offer\n * transforms.\n *\n * @param {string} blockName Base block name.\n *\n * @return {?Object} The chosen default block type.\n */\nfunction getOutboundType( blockName ) {\n\t// Grab the first outbound transform.\n\tconst transform = findTransform(\n\t\tgetBlockTransforms( 'to', blockName ),\n\t\t( { type, blocks } ) => type === 'block' && blocks.length === 1 // What about when .length > 1?\n\t);\n\n\tif ( ! transform ) {\n\t\treturn null;\n\t}\n\n\treturn getBlockType( transform.blocks[ 0 ] );\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-post/validate-multiple-use/with-multiple-validation',\n\twithMultipleValidation\n);\n"],"mappings":";;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAOA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAfA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASO,mBAAmBA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EAC5C,IAAK,CAAEC,KAAK,CAACC,OAAO,CAAEH,MAAO,CAAC,IAAI,CAAEA,MAAM,CAACI,MAAM,EAAG;IACnD;EACD;EAEA,KAAM,MAAMC,KAAK,IAAIL,MAAM,EAAG;IAC7B,IAAKK,KAAK,CAACJ,IAAI,KAAKA,IAAI,EAAG;MAC1B,OAAOI,KAAK;IACb;;IAEA;IACA,MAAMC,UAAU,GAAGP,mBAAmB,CAAEM,KAAK,CAACE,WAAW,EAAEN,IAAK,CAAC;IAEjE,IAAKK,UAAU,EAAG;MACjB,OAAOA,UAAU;IAClB;EACD;AACD;AAEA,MAAME,OAAO,GAAG,IAAAC,gBAAO;AACtB;AACD;AACA;A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AAyB,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAST,eAAeA,CAAEc,SAAS,EAAG;EACrC;EACA,MAAMC,SAAS,GAAG,IAAAC,qBAAa,EAC9B,IAAAC,0BAAkB,EAAE,IAAI,EAAEH,SAAU,CAAC,EACrC,CAAE;IAAEI,IAAI;IAAEnD;EAAO,CAAC,KAAMmD,IAAI,KAAK,OAAO,IAAInD,MAAM,CAACI,MAAM,KAAK,CAAC,CAAC;EACjE,CAAC;EAED,IAAK,CAAE4C,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OAAO,IAAAjB,oBAAY,EAAEiB,SAAS,CAAChD,MAAM,CAAE,CAAC,CAAG,CAAC;AAC7C;AAEA,IAAAoD,gBAAS,EACR,kBAAkB,EAClB,+DAA+D,EAC/D5B,sBACD,CAAC"}
@@ -30,7 +30,7 @@ function KeyboardShortcutsHelpMenuItem({
30
30
  shortcut: _keycodes.displayShortcut.access('h')
31
31
  }, (0, _i18n.__)('Keyboard shortcuts'));
32
32
  }
33
- var _default = (0, _data.withDispatch)(dispatch => {
33
+ var _default = exports.default = (0, _data.withDispatch)(dispatch => {
34
34
  const {
35
35
  openModal
36
36
  } = dispatch(_interface.store);
@@ -38,5 +38,4 @@ var _default = (0, _data.withDispatch)(dispatch => {
38
38
  openModal
39
39
  };
40
40
  })(KeyboardShortcutsHelpMenuItem);
41
- exports.default = _default;
42
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_data","_i18n","_keycodes","_interface","_keyboardShortcutHelpModal","KeyboardShortcutsHelpMenuItem","openModal","_react","createElement","MenuItem","onClick","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","shortcut","displayShortcut","access","__","_default","withDispatch","dispatch","interfaceStore","exports","default"],"sources":["@wordpress/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { withDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';\n\nexport function KeyboardShortcutsHelpMenuItem( { openModal } ) {\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\topenModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );\n\t\t\t} }\n\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t>\n\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default withDispatch( ( dispatch ) => {\n\tconst { openModal } = dispatch( interfaceStore );\n\n\treturn {\n\t\topenModal,\n\t};\n} )( KeyboardShortcutsHelpMenuItem );\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAKA,IAAAK,0BAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGO,SAASM,6BAA6BA,CAAE;EAAEC;AAAU,CAAC,EAAG;EAC9D,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACV,WAAA,CAAAW,QAAQ;IACRC,OAAO,EAAGA,CAAA,KAAM;MACfJ,SAAS,CAAEK,4DAAkC,CAAC;IAC/C,CAAG;IACHC,QAAQ,EAAGC,yBAAe,CAACC,MAAM,CAAE,GAAI;EAAG,GAExC,IAAAC,QAAE,EAAE,oBAAqB,CAClB,CAAC;AAEb;AAAC,IAAAC,QAAA,GAEc,IAAAC,kBAAY,EAAIC,QAAQ,IAAM;EAC5C,MAAM;IAAEZ;EAAU,CAAC,GAAGY,QAAQ,CAAEC,gBAAe,CAAC;EAEhD,OAAO;IACNb;EACD,CAAC;AACF,CAAE,CAAC,CAAED,6BAA8B,CAAC;AAAAe,OAAA,CAAAC,OAAA,GAAAL,QAAA"}
1
+ {"version":3,"names":["_components","require","_data","_i18n","_keycodes","_interface","_keyboardShortcutHelpModal","KeyboardShortcutsHelpMenuItem","openModal","_react","createElement","MenuItem","onClick","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","shortcut","displayShortcut","access","__","_default","exports","default","withDispatch","dispatch","interfaceStore"],"sources":["@wordpress/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { withDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';\n\nexport function KeyboardShortcutsHelpMenuItem( { openModal } ) {\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\topenModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );\n\t\t\t} }\n\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t>\n\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default withDispatch( ( dispatch ) => {\n\tconst { openModal } = dispatch( interfaceStore );\n\n\treturn {\n\t\topenModal,\n\t};\n} )( KeyboardShortcutsHelpMenuItem );\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAKA,IAAAK,0BAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGO,SAASM,6BAA6BA,CAAE;EAAEC;AAAU,CAAC,EAAG;EAC9D,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACV,WAAA,CAAAW,QAAQ;IACRC,OAAO,EAAGA,CAAA,KAAM;MACfJ,SAAS,CAAEK,4DAAkC,CAAC;IAC/C,CAAG;IACHC,QAAQ,EAAGC,yBAAe,CAACC,MAAM,CAAE,GAAI;EAAG,GAExC,IAAAC,QAAE,EAAE,oBAAqB,CAClB,CAAC;AAEb;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,kBAAY,EAAIC,QAAQ,IAAM;EAC5C,MAAM;IAAEd;EAAU,CAAC,GAAGc,QAAQ,CAAEC,gBAAe,CAAC;EAEhD,OAAO;IACNf;EACD,CAAC;AACF,CAAE,CAAC,CAAED,6BAA8B,CAAC"}
@@ -14,10 +14,10 @@ var _editor = require("@wordpress/editor");
14
14
  */
15
15
 
16
16
  function WelcomeGuideMenuItem() {
17
- const isTemplateMode = (0, _data.useSelect)(select => select(_editor.store).getRenderingMode() === 'template-only', []);
17
+ const isEditingTemplate = (0, _data.useSelect)(select => select(_editor.store).getCurrentPostType() === 'wp_template', []);
18
18
  return (0, _react.createElement)(_preferences.PreferenceToggleMenuItem, {
19
19
  scope: "core/edit-post",
20
- name: isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide',
20
+ name: isEditingTemplate ? 'welcomeGuideTemplate' : 'welcomeGuide',
21
21
  label: (0, _i18n.__)('Welcome Guide')
22
22
  });
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_preferences","_i18n","_editor","WelcomeGuideMenuItem","isTemplateMode","useSelect","select","editorStore","getRenderingMode","_react","createElement","PreferenceToggleMenuItem","scope","name","label","__"],"sources":["@wordpress/edit-post/src/plugins/welcome-guide-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { PreferenceToggleMenuItem } from '@wordpress/preferences';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\n\nexport default function WelcomeGuideMenuItem() {\n\tconst isTemplateMode = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getRenderingMode() === 'template-only',\n\t\t[]\n\t);\n\n\treturn (\n\t\t<PreferenceToggleMenuItem\n\t\t\tscope=\"core/edit-post\"\n\t\t\tname={ isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide' }\n\t\t\tlabel={ __( 'Welcome Guide' ) }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMe,SAASI,oBAAoBA,CAAA,EAAG;EAC9C,MAAMC,cAAc,GAAG,IAAAC,eAAS,EAC7BC,MAAM,IACPA,MAAM,CAAEC,aAAY,CAAC,CAACC,gBAAgB,CAAC,CAAC,KAAK,eAAe,EAC7D,EACD,CAAC;EAED,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACV,YAAA,CAAAW,wBAAwB;IACxBC,KAAK,EAAC,gBAAgB;IACtBC,IAAI,EAAGT,cAAc,GAAG,sBAAsB,GAAG,cAAgB;IACjEU,KAAK,EAAG,IAAAC,QAAE,EAAE,eAAgB;EAAG,CAC/B,CAAC;AAEJ"}
1
+ {"version":3,"names":["_data","require","_preferences","_i18n","_editor","WelcomeGuideMenuItem","isEditingTemplate","useSelect","select","editorStore","getCurrentPostType","_react","createElement","PreferenceToggleMenuItem","scope","name","label","__"],"sources":["@wordpress/edit-post/src/plugins/welcome-guide-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { PreferenceToggleMenuItem } from '@wordpress/preferences';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\n\nexport default function WelcomeGuideMenuItem() {\n\tconst isEditingTemplate = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getCurrentPostType() === 'wp_template',\n\t\t[]\n\t);\n\n\treturn (\n\t\t<PreferenceToggleMenuItem\n\t\t\tscope=\"core/edit-post\"\n\t\t\tname={ isEditingTemplate ? 'welcomeGuideTemplate' : 'welcomeGuide' }\n\t\t\tlabel={ __( 'Welcome Guide' ) }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMe,SAASI,oBAAoBA,CAAA,EAAG;EAC9C,MAAMC,iBAAiB,GAAG,IAAAC,eAAS,EAChCC,MAAM,IACPA,MAAM,CAAEC,aAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC,KAAK,aAAa,EAC7D,EACD,CAAC;EAED,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACV,YAAA,CAAAW,wBAAwB;IACxBC,KAAK,EAAC,gBAAgB;IACtBC,IAAI,EAAGT,iBAAiB,GAAG,sBAAsB,GAAG,cAAgB;IACpEU,KAAK,EAAG,IAAAC,QAAE,EAAE,eAAgB;EAAG,CAC/B,CAAC;AAEJ"}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.__experimentalSetPreviewDeviceType = void 0;
8
8
  exports.__unstableCreateTemplate = __unstableCreateTemplate;
9
- exports.closeModal = exports.closeGeneralSidebar = exports.__unstableSwitchToTemplateMode = void 0;
9
+ exports.closeModal = exports.closeGeneralSidebar = void 0;
10
10
  exports.closePublishSidebar = closePublishSidebar;
11
11
  exports.initializeMetaBoxes = exports.hideBlockTypes = void 0;
12
12
  exports.metaBoxUpdatesFailure = metaBoxUpdatesFailure;
@@ -453,21 +453,11 @@ function setIsEditingTemplate() {
453
453
  };
454
454
  }
455
455
 
456
- /**
457
- * Switches to the template mode.
458
- */
459
- const __unstableSwitchToTemplateMode = () => ({
460
- registry
461
- }) => {
462
- registry.dispatch(_editor.store).setRenderingMode('template-only');
463
- };
464
-
465
456
  /**
466
457
  * Create a block based template.
467
458
  *
468
459
  * @deprecated
469
460
  */
470
- exports.__unstableSwitchToTemplateMode = __unstableSwitchToTemplateMode;
471
461
  function __unstableCreateTemplate() {
472
462
  (0, _deprecated.default)("dispatch( 'core/edit-post' ).__unstableCreateTemplate", {
473
463
  since: '6.5'
@@ -526,6 +516,9 @@ const toggleDistractionFree = () => ({
526
516
  registry
527
517
  }) => {
528
518
  const isDistractionFree = registry.select(_preferences.store).get('core', 'distractionFree');
519
+ if (isDistractionFree) {
520
+ registry.dispatch(_preferences.store).set('core', 'fixedToolbar', false);
521
+ }
529
522
  if (!isDistractionFree) {
530
523
  registry.batch(() => {
531
524
  registry.dispatch(_preferences.store).set('core', 'fixedToolbar', true);
@@ -542,7 +535,10 @@ const toggleDistractionFree = () => ({
542
535
  actions: [{
543
536
  label: (0, _i18n.__)('Undo'),
544
537
  onClick: () => {
545
- registry.dispatch(_preferences.store).toggle('core', 'distractionFree');
538
+ registry.batch(() => {
539
+ registry.dispatch(_preferences.store).set('core', 'fixedToolbar', isDistractionFree ? true : false);
540
+ registry.dispatch(_preferences.store).toggle('core', 'distractionFree');
541
+ });
546
542
  }
547
543
  }]
548
544
  });